-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
waiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.Waiting on additional info. If it's not received, the issue may be closed.
Milestone
Description
WiFi.status() returns WL_CONNECTED after connection is lost when using WiFi.setAutoReconnect( false );
The included MCVE produces the following output:
SDK:3.0.0-dev(c0f7b44)/Core:2.5.0=20500000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1/BearSSL:6778687
mode : sta(a0:20:a6:0a:a6:96) + softAP(a2:20:a6:0a:a6:96)
add if0
Looking for WiFi ....wlstatus:WL_IDLE_STATUS=0
WiFi.localIP():(IP unset)
.scandone
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt
connected with TEST, channel 3
dhcp client start...
ip:192.168.43.39,mask:255.255.255.0,gw:192.168.43.45
connected to TEST
wlstatus:WL_CONNECTED=3
WiFi.localIP():192.168.43.39
wlstatus:WL_CONNECTED=3
WiFi.localIP():192.168.43.39
state: 5 -> 2 (3a0)
rm 0
wlstatus:WL_CONNECTED=3
WiFi.localIP():(IP unset)
wlstatus:WL_CONNECTED=3
WiFi.localIP():(IP unset)
wlstatus:WL_CONNECTED=3
WiFi.localIP():(IP unset)
wlstatus:WL_CONNECTED=3
WiFi.localIP():(IP unset)
wlstatus:WL_CONNECTED=3
The AP was turned off shortly after the connection was established and you will notice the logs show loss of IP but status() returns WL_CONNECTED. This only happens when using WiFi.setAutoReconnect( false )
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
ESP8266WiFiMulti wifiMulti;
boolean connectioWasAlive = true;
const char* statuses[] = { "WL_IDLE_STATUS=0", "WL_NO_SSID_AVAIL=1", "WL_SCAN_COMPLETED=2", "WL_CONNECTED=3", "WL_CONNECT_FAILED=4", "WL_CONNECTION_LOST=5", "WL_DISCONNECTED=6"};
void setup()
{
Serial.begin(115200);
Serial.println();
WiFi.setAutoReconnect( false );
wifiMulti.addAP("TEST", "12345678");
}
unsigned long timestamp = millis();
void monitorWiFi()
{
if (millis() - timestamp > 2000) {
timestamp = millis();
Serial.print("wlstatus:");
Serial.println(statuses[WiFi.status()]);
Serial.print("WiFi.localIP():");
Serial.println(WiFi.localIP().toString());
}
if (wifiMulti.run() != WL_CONNECTED)
{
if (connectioWasAlive == true)
{
connectioWasAlive = false;
Serial.print("Looking for WiFi ");
}
Serial.print(".");
delay(500);
}
else if (connectioWasAlive == false)
{
connectioWasAlive = true;
Serial.printf(" connected to %s\n", WiFi.SSID().c_str());
}
}
void loop()
{
monitorWiFi();
}
neu-rah, slow-down, IMAN4K, lightning003 and TD-er
Metadata
Metadata
Assignees
Labels
waiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.Waiting on additional info. If it's not received, the issue may be closed.