Environment ESP32-WROOM-32UE.
I need to run WiFi.scanNetworks()
asynchronously for my project. My sample code returns a list of discovered networks however the output during WiFi.scanComplete()
does not make sense. Snippet from test code:
void _scan_check() {
int asyncscan = WiFi.scanNetworks(true);
delay(1000);
int status = WiFi.scanComplete();
while(status < 0) {
Serial.printf("Status = %d", status);
delay(1000);
status = WiFi.scanComplete();
}
Serial.printf("Status = %d", status);
}
When run I get the following output (commented):
Status = -1 //equal to WIFI_SCAN_RUNNING
Status = -1 //equal to WIFI_SCAN_RUNNING
Status = -1 //equal to WIFI_SCAN_RUNNING
Status = -1 //equal to WIFI_SCAN_RUNNING
Status = -2 //equal to WIFI_SCAN_FAILED
Status = -2 //equal to WIFI_SCAN_FAILED
Status = 7 // discovered 7 networks
This happens regardless of how many networks discovered. So my question is, why do I always get one or more WIFI_SCAN_FAILED
prior to getting the actual count of discovered networks?
Is this an undocumented way it works or is there some bug with the ESP32 backend code?