TuyaAPI / link

📡 Effortlessly connect devices to WiFi and the cloud. Documentation: https://tuyaapi.github.io/link.
MIT License
15 stars 10 forks source link

Having hard time to understand Token, Region, Secret #7

Closed omersiar closed 4 years ago

omersiar commented 4 years ago

Hello,

Tuya Javascript collection is just amazing, thank you.

I just want to understand what does Token, Region and Secret changes for SmartConfig and why they are calculated for length of the UDP packages.

https://github.com/espressif/ESP8266_RTOS_SDK/tree/52f9d8c1b88cafc371a2d10a519e0d108afe2f1a/examples/wifi/smart_config

No usable example out there.

Mobile SmartConfig apps seems does not care about Token, Region and Secret and just calculates array from the BSSID, SSID, Passphrase.

https://www.espressif.com/sites/default/files/documentation/esp-touch_user_guide_en.pdf

I'm not using Tuya firmware, I'm trying to create one using Arduino framework.

smartconfig_get_version() outputs Smartconfig Version: V2.5.4

omersiar commented 4 years ago

My test code

const TuyaLink = require('@tuyapi/link');

const register = new TuyaLink.manual();

register.registerSmartLink({region: 'EU',
                           token: '00000000',
                           secret: '0000',
                           ssid: 'Hack_This!',
                           wifiPassword: 'asdasd'}).then(() => {
  console.log('Done!');
 });
omersiar commented 4 years ago

I have captured UDP packages with Wireshark, not exactly as if have been with mobile application.

codetheweb commented 4 years ago

I don't think that code/library you linked to and Tuya's solution are the same thing. Tuya calls their protocol 'Smart Link', and yours is called 'Smart Config'.

Are you looking for help with the ESP library, or linking a Tuya device?

omersiar commented 4 years ago

Smart Link is like Smart Config but with an additional cloud pairing step. Manual mode implies that is only connecting to the Local Network. I'm trying to code a CLI tool for my firmware. No need to left open this issue. Thank you.