Skip to content
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

Fix WiFi disconnect event not being propagated. #3085

Merged
merged 5 commits into from
Sep 11, 2019

Conversation

edoardoo
Copy link
Contributor

Relative to #3006.
A short recap:
I've just removed the true from the disconnect event callback in order to prevent the WiFi module to be stopped. This somehow prevented the disconnect event to be propagated.
Not sure about other side effects.

@edoardoo edoardoo changed the title Fix WiFi disconnect event not being propageted. Fix WiFi disconnect event not being propagated. Aug 16, 2019
@me-no-dev
Copy link
Member

I think it kinda makes sense not to restart the radio, but maybe it was there for a reason that is no longer true :)

@edoardoo
Copy link
Contributor Author

😄 yeah, I also thought that it is probably some kind of inheritance of the earliest stages of esp specifications.
It's not much, but at the moment I'm using it without the true on 6 devices and they are all successfully propagating the disconnect event.

@simap
Copy link

simap commented Feb 19, 2020

I find myself here because I'm getting an AUTH_EXPIRE every so often (from minutes to a day or so), and the esp32 is not reconnecting. Reconnect is set:

WiFi.setAutoReconnect(true);

I suspect that maybe the code that is supposed to reconnect here:

            WiFi.disconnect();
            WiFi.begin();

which was modified in this PR, isn't reconnecting because mode still has STA set. the begin() call calls to WiFiGenericClass::enableSTA(), which checks that before trying.

I wrote a small program that would let me trigger this pair of calls, and it is unreliable. Sometimes wifi reconnects, but often it doesn't. I added some logging in WiFiGenericClass::enableSTA() and indeed, it is triggering the guard that checks the current mode.

When I put the true back in WiFi.disconnect(true); the pair reliably restarts WiFi.

I am using version 1.0.4.

I think this change should be reverted, perhaps there is some other way to allow disconnect propagation. I don't know why my WiFi is causing AUTH_EXPIRE in the first place, but it seems that in this state the code cannot be resilient to such things. Without this the ESP32 will just drop off WiFi and never come back until reset. FWIW, I have dozens of ESP8266 devices that do not have this problem on the same WiFi network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants