-
-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support protocol version 3.4 #481
Comments
Hmm, that's the first instance of 3.4 that I've seen in the wild... so yes, that's probably the issue. If you send me a packet dump of when the app is controlling it I can investigate further. |
After taking a quick look at the provided packet dump, it does indeed appear to be significantly different than 3.3 / 3.1. I don't currently have plans to add support for 3.4, sorry. |
Thanks for having a look. Can you tell me how you decrypted the messages. Maybe I will try it myself. |
Decrypting messages requires a bit of background in cryptography and lots of trial and error. No guarantees but I'd be willing to take a look. |
Do you have a link to the device you bought running the 3.4 protocol? Would like to look into this myself for my C# implementation :) |
It is a SILVERCREST Gateway Zigbee Smart Home from LIDL |
If someone interested I will send linux binary (tyZ3Gw: ELF 32-bit MSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0). Seems the protocol for crypt/decrypt messages are the same AES/ECB/NoPadding. May be localKey is modified to be used for crypt/decrypt. There are also token send in registration process encrypted with md5(constant) - like broadcast message. regards, |
Finally I reverse key generation for 3.4. in 3.4 there are session_key generated runtime: SESSION_KEY negotiationclient send frame_id: 0x03 gw responds with frame_id: 0x04 client send frame_id: 0x05 all frames are aes_ecb_128 encrypted with local_key and have checksum hmacSHA256(data,local_key) SESSION_KEY generationaes_ecb_128( XOR_by_byte(client_random,gw_random) , local_key)) @codetheweb if you decide to implement this and have questions just contact me. regards, |
@harryzz that's great, thank you for taking the time to figure out the protocol! I don't have plans to implement it myself as I don't have any 3.4 devices to test with (nor much free time for TuyAPI) but happy to accept PRs that add support. 😄 |
Hello regards, |
@harryzz Why you do not do a PR ? Are there more such devices out in the wild in the meantime? Any example purchase link? |
I just came across another 3.4 device. It's the Minoston Wi-Fi Countdown Timer Switch (MT10W). Amazon Link: https://www.amazon.com/dp/B0B3WN622J?th=1
I'm not having luck with the code in harryzz`s repo, but that could be user error. I haven't done much with node.js before. |
Do you have fork of localtuya that supports 3.4? |
One more device with Protocol 3.4: https://nous.technology/product/nous-smart-wi-fi-socket-a1/de.html
|
@codetheweb I will try to take the changes from @harryzz and somehow test them to bring in a PR ... But feels that it is not all. They also send new UDP package with commandByte 35 ... will also add that. But might take some time |
PS: If someone is willing to sende me such a device please contact me at [email protected]. That could simplify things a lot |
I should get a device by monday thanks to @Domi920 |
So all friends of the 3.4 protocol ... I want to give it a shot to implement it. Please see #606 and test it and provide Feedback please in the PR. |
@harryzz is it stable on your side? I have one using using the fork where the device starts acting strange after some time ... Could it be tha the session needs to be refreshed after a certain time? |
I can't test now because my 3.4 device broke months ago. |
But was it running with your code base for some time or had it also issues? If it was running also "long connected"? |
(PS: In fact also in the pythong libs where 3.4 is supported there is no "timed reconnect or session refresh" that I noticed ... ) |
Describe the bug
I tried the example script from the read me. Tuyapi is able to find the device and to connect, but directly disconnects afterwards. It's not possible to keep the connection and listen to data.
Also tried it in Node-Red with package node-red-contrib-tuya-smart-device which uses latest tuyapi. Same error, it constantly reconnects. But at least it receives some data events which results in error logs with messages like
Error: CRC mismatch: expected -674619356, was -22843090
Maybe the problem is the protocol version 3.4? Didn't find any information if tuyapi supports 3.4.
debug output:
The text was updated successfully, but these errors were encountered: