TuyaAPI / link

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

link fail when wifi password contain «%» #6

Open swil85 opened 4 years ago

swil85 commented 4 years ago

Hello, i have a wifi password containing some special characters like % or ! When removing them everything work great with a tuya curtain switch.

I read the code from smartLinkEncode, but dont really see what’s wrong !

Can u help me !

thank’s in advance.

codetheweb commented 4 years ago

Does it link correctly with special characters if you use the official Tuya Smart app?

swil85 commented 4 years ago

Hello, yes it work with tuya smart app and smart life app. (but ifttt dont see my devices :( )

swil85 commented 4 years ago

Hi, have you successfully reproduced the issue ? Can it caused by "string substitution patterns" like "%d" "%s" "%f" … ?

codetheweb commented 4 years ago

Sorry, this slipped through the cracks.

It's possible the device is expecting ASCII encoding instead of the UTF8 that we're currently doing. To test that theory, we would have to edit https://github.com/TuyaAPI/link/blob/7df3e5e24f29d26e13aee785a298dca89516be0d/lib/link.js#L156 and https://github.com/TuyaAPI/link/blob/7df3e5e24f29d26e13aee785a298dca89516be0d/lib/link.js#L159

to look like Buffer.from(..., 'ascii'). Might also have to then change https://github.com/TuyaAPI/link/blob/7df3e5e24f29d26e13aee785a298dca89516be0d/lib/link.js#L261, but I think that should work as-is.

It's not a huge priority for me ATM, but if you or someone else wants to see if that fixes it I can merge in the changes.