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

Added timeout to WiFiScan.cpp to prevent getting stuck at WIFI_SCAN_RUNNING #3197

Merged
merged 6 commits into from
Sep 11, 2019

Conversation

EricMc1289
Copy link
Contributor

@EricMc1289 EricMc1289 commented Sep 11, 2019

If you start a scan for networks if the esp is connecting to an ap the scan request is aborted by the sdk without returning an error. See here espressif/esp-idf#3044 for reference.

In my case the scan routine is running in its own thread so i can't assume when the scanNetworks is triggered. If it gets triggered while the esp is connecting the connect has priority and the SYSTEM_EVENT_SCAN_DONE event is never triggered. In that particular case the WIFI_SCANNING_BIT is never cleared and you're not able to scan for networks without a reset.

To prevent that case i modified the WiFiScan.ccp to include a timeout mechanism to reset a failed scan. So I added a define SCAN_ERROR_DELAY with a value of 10000 for 10s as timeout and the parameter _scanStarted.

If the SYSTEM_EVENT_SCAN_DONE event is not fired within the SCAN_ERROR_DELAY the scanComplete method returns WIFI_SCAN_FAILED to indicate that the scan failed.

@me-no-dev
Copy link
Member

please fix tabs and spaces and also make the timeout be connected to max_ms_per_chan * 20.

@me-no-dev me-no-dev merged commit bab3a70 into espressif:master Sep 11, 2019
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.

2 participants