Skip to content

[WiFi] scanComplete always returns -1 after async scanNetworks is invoked #573

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

Closed
toomasz opened this issue Aug 10, 2017 · 1 comment
Closed

Comments

@toomasz
Copy link
Contributor

toomasz commented Aug 10, 2017

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: 10/aug/2017
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

scanComplete always returns -1 after async scanNetworks is invoked, even though wifi callback with SCAN_DONE event is received

It seems like duplicate of #354

Sketch:

#include <WiFi.h>

void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.println("setup completed");
}

void loop()
{
delay(500);
int8_t n = WiFi.scanComplete();
Serial.println("scanComplete: " + String(n));
if(n == -2)
{
Serial.println("Scan networks");
WiFi.scanNetworks(true);
}
if(n == -1)
{
Serial.println("Scan in progress...");
}

if(n < 0)
{
return;
}

Serial.println("networks found: " + String(n));
for (int i = 0; i < n; ++i)
{
Serial.println( String(n) + ": " + String(WiFi.SSID(i)));
}

delay(1000);
}

Debug Messages:

ts Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0010,len:4
load:0x3fff0014,len:708
load:0x40078000,len:0
load:0x40078000,len:12168
entry 0x40078a68
setup completed
[D][WiFiGeneric.cpp:182] _eventCallback(): Event: 2 - STA_START
scanComplete: -2
Scan networks
[D][WiFiGeneric.cpp:182] _eventCallback(): Event: 1 - SCAN_DONE
scanComplete: -1
Scan in progress...
scanComplete: -1
Scan in progress...
scanComplete: -1
Scan in progress...
scanComplete: -1
Scan in progress...

@toomasz
Copy link
Contributor Author

toomasz commented Aug 10, 2017

This issue is caused by passing block = true in async mode in line:

if(esp_wifi_scan_start(&config, WiFiScanClass::_scanAsync) == ESP_OK) {

I believe this line should be changed to:
if(esp_wifi_scan_start(&config, false) == ESP_OK) {

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

No branches or pull requests

1 participant