scanning after AP disappears -- errors: Now is connecting, user scan invalid now!
Posted: Tue Oct 09, 2018 2:42 pm
I'm trying to write some robust code that looks for another access point when the current one disappears.
So far (in pseudocode) I do
However, I get the following message:
I check the error state of esp_wifi_scan_start(&scanConf, 0) and it returns ESP_OK, even when it fails with the "Now is connecting, user scan invalid now" message.
Looking at the docs I think it describes this in some form:
https://docs.espressif.com/projects/esp ... n-examples
If I can't rely on the Disconnect event, is there a way to detect that the scan will fail before requesting it? And if not, what is the maximum retry time I need to wait -- and do I always have to wait that long after receiving a Disconnect event before scanning.
Additionally, is there an event I can watch for when a scan fails?
Basically I'm doing this as the customer wants the device to be online as much as fast as possible, and so I'm keen to try and find an alternate AP and reconnect as soon as possible when one goes down.
Thanks
So far (in pseudocode) I do
Code: Select all
esp_wifi_set_config(...)
esp_wifi_connect()
//AP I'm trying to connect to isn't available...
//I wait until I see the callback for a SYSTEM_EVENT_STA_DISCONNECTED event, then I call
esp_wifi_scan_start(&scanConf, 0)
and the scan never completes (nor do I see another event)wifi: Now is connecting, user scan invalid now!
I check the error state of esp_wifi_scan_start(&scanConf, 0) and it returns ESP_OK, even when it fails with the "Now is connecting, user scan invalid now" message.
Looking at the docs I think it describes this in some form:
https://docs.espressif.com/projects/esp ... n-examples
Could someone clarify what it's saying -- I don't intend to scan while still connecting; I'm assuming I can't rely on the Disconnect event to wait for this to complete?3. The scanning triggered by esp_wifi_start_scan() will not be effective until connection between ESP32 and the AP is established. If ESP32 is scanning and connecting at the same time, ESP32 will abort scanning and return a warning message and error number ESP_ERR_WIFI_STATE. If you want to do reconnection after ESP32 received disconnect event, remember to add the maximum retry time, otherwise the called scan will not work. This is especially true when the AP doesn’t exist, and you still try reconnection after ESP32 received disconnect event with the reason code WIFI_REASON_NO_AP_FOUND.
If I can't rely on the Disconnect event, is there a way to detect that the scan will fail before requesting it? And if not, what is the maximum retry time I need to wait -- and do I always have to wait that long after receiving a Disconnect event before scanning.
Additionally, is there an event I can watch for when a scan fails?
Basically I'm doing this as the customer wants the device to be online as much as fast as possible, and so I'm keen to try and find an alternate AP and reconnect as soon as possible when one goes down.
Thanks