-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Resolve #3967: set connected false once disconnected #3968
Conversation
159c973
to
d26bdc5
Compare
You might want to test under conditions of gradually reducing signal strength - walk away with the device until connectivity is lost, then walk it back towards the AP. This can produce different results compared to switching the AP off and back on. |
Also see this issue. |
Interesting. I can do further checking, however with first “beacon timeout” and then “NO AP” it follows the steps to keep retrying - it’s just until it connects the status now says “connecting” rather than “connected”. From the linked issue it seems like you’re connecting first time, which works fine. Without this fix, the status will be stuck as STAT_GOT_IP because the modnetwork.c flag for connected will never be false. At least now it says STAT_CONNECTING, and when the AP is reconnected to automatically there is definitely another event from ESP-IDF which boots the status flag back to connected. From a user point of view querying the interface if the AP becomes unavailable I’ll get the status as connected even though Ifconfig returns “0.0.0.0”. Does this make sense? |
Yes, it makes sense and I think what you're doing is important: we need a truly reliable way of determining connected - connecting - disconnected status. In testing I did find differences in the behaviour of ESP32 between switching the AP off and on compared with gradually reducing the signal strength as described above. There are other ways in which connectivity can be lost such as sporadic RF interference but these are hard to test. The best I could manage was to run the ESP32 for long periods near to the limit of radio range. In my resilient asynchronous MQTT client I failed to achieve resilient operation on ESP32 partly because (to quote from my README):
Incidentally a way to do these tests is to power the device from one of those USB batteries intended for recharging smartphones. |
I’m actually looking at using the MQTT client, right now I’m using the simple client. Currently I am working on a wifi manager which reads in a network file and that can run on the cooperative event loop to detect the changes in state every so often. This becomes more important if you travel with the ESP32 or need to maintain different config, or in my case use a roaming profile now that BSSID can be specified. Where the whole thing fell over was with detecting that the wifi disconnected, the STA_IF would always report it was connected as mentioned above. From an “OS” later that’s all it should really do, just try to reconnect. |
Hi, is there any update on this? I just ran into the same problem using the latest MicroPython build. Or is there another approach/library/MP variant everyone is using these days for ESP32 that solves these problems? |
No updates, I was waiting for this to be merged but no answer. I'll have to rebase it now. @dpgeorge might shed some light. If there's an opportunity for this to go in I will take another look. Long story short, I end up using the IP_ADDRESS != '0.0.0.0' - not ideal but gives the intended results assuming DHCP is working. |
Thanks, I'm glad it's resolved. |
Have tested this and it appears to behave as expected, am not sure if there is historical reason why connected was never set to false, however after:
I can confirm the device reconnects with a proper ifconfig (which was 0.0.0.0 during the hotspot downtime). Can also confirm during step 2, that the status is connecting (1001).
@dpgeorge issue was created for discussion, however this seems to retain the auto-reconnect while providing a status() that returns STAT_CONNECTING while it is reconnecting instead of STAT_GOT_IP.
wifi_reconnect_fix_log.log
logs attached