Description
This seems to happen randomly (but often) on some networks. I'm seeing this on a particular wifi network almost systematically (but not quite) while the same code on the same board had worked for ages on other networks.
This is my code (simplified):
void setup() {
String client_ssid = "mySSID";
String clien_password = "mypassword";
WiFi.mode(WIFI_STA);
WiFi.begin(client_ssid.c_str(), client_password.c_str());
for (int i=0; i<20; i++) {
Serial.println("Trying to connect to Wifi '%s' with password '%s'\n", client_ssid.c_str(), client_password.c_str());
delay(1000)
if (WiFi.status()==WL_CONNECTED) {
Serial.println("...connected succesfully\n");
// Here I would normally do stuff...
return;
}
}
Serial.println("Cannot connect to WiFi!\n");
return;
}
fpm close 3
mode : sta(80:7d:3a:3c:e2:1d)
add if0
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
scandone
state: 0 -> 2 (b0)
Trying to connect to Wifi 'CASAS' with password '******'
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 17
cnt
connected with CASAS, channel 6
dhcp client start...
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
pm open,type:2 0
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Trying to connect to Wifi 'CASAS' with password '******'
Cannot connect to WiFi!
Note where it says "Connected to ... channel 6": that's not from my println()s, that's some internal output.
It was able to connect once or twice on the very same network, which is working fine and the password is correct, obviously.
I'm reporting it here because there's internal debug output that says "connected" and yet status()
is returning WL_DISCONNECTED
, so that's an inconsistency that is obviously in software. Either the debug output that says "connected" is bogus, or status()
is returning the wrong value (or it connects and immediately loses connection, and there's no debug output for that which would be a bug too - but that seems pretty unlikely).