Wired WiFi.scan result


#1

Hi,

I am having strange result from WiFi.scan() function in my firmware.

My code is as follows.

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
STARTUP(System.enableFeature(FEATURE_ETHERNET_DETECTION));
...

void setup()
{

#ifdef ETHERNETCONN
    Ethernet.on();
    Ethernet.connect();
#endif
	Particle.connect();
    delay(2000);
	Serial.begin(115200);
	Serial.println(F("Particle Argon WiFi scanning..."));
}

...

void wifi_scan_callback(WiFiAccessPoint* wap, void* data)
{
    WiFiAccessPoint& ap = *wap;
    Serial.print("SSID: ");
    Serial.println(ap.ssid);
    Serial.print("Security: ");
    Serial.println(ap.security);
    Serial.print("Channel: ");
    Serial.println(ap.channel);
    Serial.print("RSSI: ");
    Serial.println(ap.rssi);
}

void loop()
{
    static uint32_t ethernetCheckTime = millis();
    if(millis() - ethernetCheckTime > 10000)
    {
        int result_count = WiFi.scan(wifi_scan_callback);
        Serial.print(result_count);
        Serial.println(" APs scanned.");
        ethernetCheckTime = millis();
    }    
    
}

I am getting following result in serial monitor.

-210 APs scanned.

Strange is that, if I setup WiFi credential in tinker app and module has connected to cloud,
I can getting valid result.

6 APs Scanned.

SSID: XXXX
Channel: x
RSSI: -23

SSID: XXXX
Channel: x
RSSI: -45

I am not sure, what is issue within usage WiFi.scan() in my code.

Thanks.


#2

Do you mean to use WiFi.scan() while actually connected via Ethernet?
I wouldn’t be surprised if that wasn’t working.

On the other hand, how would you expect Particle.connect() to ever connect if that wasn’t the case?