SignalK / SensESP

Universal Signal K sensor framework for the ESP32 platform
https://signalk.org/SensESP/
Apache License 2.0
153 stars 81 forks source link

WiFi connection logic improvements #579

Closed mairas closed 2 years ago

mairas commented 2 years ago

SensESP WiFi connection logic was a bit fragile and unnecessarily complex. Different connecting code was used depending on whether the WiFI AP was hard-coded or configured via WiFi Manager, and also reconnecting in case of lost WiFi was unreliable. This PR attempts to address those issues.

Major changes:

ba58smith commented 2 years ago

If you change the actual SSID and/or password of your wifi network, do you just reset the SensESP device, so that WiFiManager will launch?

mairas commented 2 years ago

If you change the actual SSID and/or password of your wifi network, do you just reset the SensESP device, so that WiFiManager will launch?

Yes. You'll save yourself some hassle if you remember to perform the reset before changing the SSID. Otherwise you might have to create e.g. a mobile phone hotspot with the correct SSID and password to access the device.

It might be possible to revisit the topic in the future and make the WiFiManager setup properly non-blocking, or make it run in a separate ESP32 task, but both are a bit more substantial changes than I was prepared to tackle at this point. This way, all network configuration could go through WiFiManager (even in the case of hard-coded values), and the operation would not prevent other code from running while the configuration portal is active.

Some future improvements here would be:

ckcrs commented 2 years ago

Thanks a lot... Just testing and curios about "device is still operating normally, albeit without network" part. Should I also expect to see normal data output from esp32 at my usb serial connection? Sancan PS: I can see below on by usb serial, till it reconnects to my restarting RPi, then data reporting starts: "(wifi_station_disconnected)(C1) Disconnected from wifi. (connect)(C0) WiFi is disconnected. SignalK client connection will connect when WiFi is connected.

Edit: I guess not, not related with freetos. :)

mairas commented 2 years ago

Thanks a lot... Just testing and curios about "device is still operating normally, albeit without network" part. Should I also expect to see normal data output from esp32 at my usb serial connection?

If you're referring to the Signal K deltas that are printed out when the data is transmitted to the SK server, then no, that data is not printed out as long as the data isn't being transmitted.