Skip to content

Commit 0bb2369

Browse files
authored
Merge pull request #911 from kueblc/dr-tuya
Attempt to automatically diagnose common issues
2 parents 869386c + 1cc2bdc commit 0bb2369

File tree

4 files changed

+159
-6
lines changed

4 files changed

+159
-6
lines changed

scripts/dr_tuya.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
NON_ESP_WARNING="WARNING: it appears this device does not use an ESP82xx and therefore cannot install ESP based firmware"
4+
5+
get_macs_from_wifi_log () {
6+
grep AP-STA-CONNECTED smarthack-wifi.log |
7+
cut -d ' ' -f3 |
8+
sort | uniq
9+
}
10+
11+
get_ouis_from_wifi_log () {
12+
get_macs_from_wifi_log |
13+
tr -d : | grep -Po "^.{6}"
14+
}
15+
16+
psk_02 () {
17+
grep -q "ID: 02" smarthack-psk.log
18+
}
19+
20+
web_non_esp () {
21+
grep -q "$NON_ESP_WARNING" smarthack-web.log
22+
}
23+
24+
udp_non_esp () {
25+
grep -q "$NON_ESP_WARNING" smarthack-udp.log
26+
}
27+
28+
esp_oui () {
29+
get_ouis_from_wifi_log | grep -iqf- oui/esp.txt
30+
}
31+
32+
non_esp_oui () {
33+
get_ouis_from_wifi_log | grep -iqf- oui/nonesp.txt
34+
}
35+
36+
check_for_common_issues () {
37+
if psk_02; then
38+
echo "Your device's firmware is too new."
39+
echo "Tuya patched the PSK vulnerability that we use to establish a connection."
40+
echo "You might still be able to flash this device over serial."
41+
echo "For more information and to follow progress on solving this issue see:"
42+
echo "https://github.com/ct-Open-Source/tuya-convert/wiki/Collaboration-document-for-PSK-Identity-02"
43+
exit 1
44+
fi
45+
if web_non_esp || udp_non_esp || non_esp_oui; then
46+
echo "Your device does not use an ESP82xx."
47+
echo "This means you cannot flash custom ESP firmware even over serial."
48+
exit 1
49+
fi
50+
if esp_oui; then
51+
echo "An ESP82xx based device connected according to your wifi log."
52+
echo "If this is the device you are trying to flash, another issue may be preventing it from flashing."
53+
echo "Otherwise, it could be that the device does not use an ESP82xx or it did not connect."
54+
else
55+
echo "No ESP82xx based devices connected according to your wifi log."
56+
echo "Here is a list of all the MAC addresses that connected:"
57+
get_macs_from_wifi_log
58+
echo
59+
echo "If you see your IoT device in this list, it is not an ESP82xx based device."
60+
echo "Otherwise, another issue may be preventing it from connecting."
61+
fi
62+
echo "For additional information, check the *.log files inside the scripts folder."
63+
echo "Please include these logs when opening a new issue on our GitHub issue tracker."
64+
}
65+
66+
check_for_common_issues
67+

scripts/oui/esp.txt

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# "Espressif Inc." OUIs
2+
# updated Jan 26 2021
3+
083AF2
4+
0CDC7E
5+
10521C
6+
18FE34
7+
240AC4
8+
2462AB
9+
246F28
10+
24A160
11+
24B2DE
12+
2C3AE8
13+
2CF432
14+
30AEA4
15+
3C6105
16+
3C71BF
17+
40F520
18+
483FDA
19+
4C11AE
20+
4C7525
21+
500291
22+
545AA6
23+
5CCF7F
24+
600194
25+
6055F9
26+
68C63A
27+
70039F
28+
7C9EBD
29+
7CDFA1
30+
807D3A
31+
840D8E
32+
84CCA8
33+
84F3EB
34+
8CAAB5
35+
8CCE4E
36+
9097D5
37+
943CC6
38+
94B97E
39+
98CDAC
40+
98F4AB
41+
9C9C1F
42+
A020A6
43+
A0764E
44+
A47B9D
45+
A4CF12
46+
A4E57C
47+
A8032A
48+
AC67B2
49+
ACD074
50+
B4E62D
51+
B8F009
52+
BCDDC2
53+
BCFF4D
54+
C44F33
55+
C45BBE
56+
C4DD57
57+
C82B96
58+
CC50E3
59+
D8A01D
60+
D8BFC0
61+
D8F15B
62+
DC4F22
63+
E09806
64+
E0E2E6
65+
E868E7
66+
E8DB84
67+
ECFABC
68+
F008D1
69+
F4CFA2
70+
FCF5C4

scripts/oui/nonesp.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Known unsupported OUIs including
2+
# "Tuya (HK) Limietd"
3+
# "Tuya Smart Inc."
4+
# "Beijing Winner Microelectronics Ltd"
5+
# updated Jan 26 2021
6+
000D8A
7+
000F89
8+
10D561
9+
1869D8
10+
286DCD
11+
68572D
12+
708976
13+
807484
14+
84E342
15+
D4A651
16+
DC446D
17+
E078A3

start_flash.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,12 @@ while true; do
7979
printf .
8080
if (( --i == 0 )); then
8181
echo
82-
echo "Device did not appear with the intermediate firmware"
83-
echo "Check the *.log files in the scripts folder"
82+
echo "Timed out while waiting for the device to (re)connect"
8483
pkill -f smartconfig/main.py && echo "Stopping smart config"
85-
echo "If the device left easy pairing mode (LED stopped blinking quickly) when config"
86-
echo "packets were sent, your device may have too new of firmware for this tool:"
87-
echo "see https://github.com/ct-Open-Source/tuya-convert/wiki/Collaboration-document-for-PSK-Identity-02#known-affected-devices"
88-
echo
84+
echo "======================================================"
85+
echo "Attempting to diagnose the issue..."
86+
./dr_tuya.sh
87+
echo "======================================================"
8988
read -p "Do you want to try flashing another device? [y/N] " -n 1 -r
9089
echo
9190
[[ "$REPLY" =~ ^[Yy]$ ]] || break 2

0 commit comments

Comments
 (0)