awilliams / wifi-presence

Presence detection on OpenWrt routers using connect/disconnect events of WiFi clients. Events are published to MQTT with Home Assistant integration.
MIT License
64 stars 8 forks source link

SSID with mixed UTF-8 and ASCII characters cannot be handled correctly #7

Closed zhangjingye03 closed 1 year ago

zhangjingye03 commented 2 years ago

Hi Adam,

Thanks for this great integration!

However, my WiFi SSID begins with UTF-8 character and then ASCII one, like ω=2πf. In this case, status from hostapd_cli gives something below, which mixes \x and normal ASCII chars.

ssid[0]=\xcf\x89=2\xcf\x80f

https://github.com/awilliams/wifi-presence/blob/b2b64ea8bce28ef5047b66c9929817240f65bc36/internal/hostapd/status.go#L58-L67

The code above just replace \x and then decode hex, which still contains non-hex chars, resulting Error: encoding/hex: invalid byte on my device. I'm not familiar with golang though, but maybe we could use strconv.Unquote instead? (Ref)

Thanks

awilliams commented 2 years ago

Thank you for the detailed report @zhangjingye03, and sorry you are experiencing that issue.

I believe you've identified the section of code responsible for this issue. I'll take a closer look in the coming days and hopefully will have a fix soon.

awilliams commented 2 years ago

@zhangjingye03 I've added a fix (#8) for your issue. Please, if you can, try out v0.2.0 and let me know if it fixes your issue. Thanks

awilliams commented 1 year ago

Closing. Please re-open @zhangjingye03 if you experience any related issues.