-
Notifications
You must be signed in to change notification settings - Fork 29
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
[esp32] Fix mgos_wifi_scan never completing if wifi in connecting state #24
Conversation
@cpq @rojer @dimonomid can we get this merged pleaseeeeeee 👍 |
+1 ! |
@tripflex I don't maintain Cesanta code these days, so would appreciate if you don't mention me here. Thanks. |
Okay sorry, wasn't aware -- won't tag you anymore |
Thanks @tripflex, this is working for me. |
sorry for the delay, please update the branch and address two comments |
FWIW, I spoke too soon about this working for me. I have since upgraded to 2.13.1 libs and even trying @rojer's recommended changes, I still get the "scan invalid now!" message. Would it be bad practice to just call [edit] |
@rojer I updated the PR per your recommendations |
@tripflex gh says there are conflicts with the master, please rebase |
This PR
This PR adds a connecting variable to determine if wifi is in connecting state, and if so, it calls
esp_wifi_disconnect
before calling scan for wifi networks.I tested this using my captive portal demo app:
https://github.com/tripflex/captive-portal-wifi-stack-demo
And it fixed the problem perfectly. Because the connect timer is still running from mgos, it will still continue connection attempt after scan is completed, moving on to next sta, etc.
Related to: #18
and: tripflex/captive-portal-wifi-stack#1
If wifi sta is enabled and is attempting to connect to a non-existent SSID, calling
mgos_wifi_scan
will never complete andmos console
shows this error:Which if the SSID is not in range or does not exist, it will never end up connecting to anything, and scan is never actually called.
Instead of having some kind of hack in our libraries or apps, I feel as though this should be handled through the wifi lib to stop the connection attempt and actually run the scan, instead of just printing an error to console.
Related to:
espressif/esp-idf#2497
Which is related to the 3.0.x IDF versions
Looks like this is how they fixed it in wifimanager port for esp:
https://github.com/alanswx/ESPAsyncWiFiManager/pull/45/files
IDF Docs specifically reference this issue as well:
https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/wifi.html#scan-when-wi-fi-is-connecting
mos-libs issue: https://github.com/cesanta/mos-libs/issues/26
#23