-
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.
Description
Basic Infos
Hardware
Hardware: ESP-12E
Core Version: 2.4
Description
Test scenario:
1.Start sketch, access point is disabled
2.Enable access point
3.Sketch can connect to access point
4.Disable access point
5. WiFi.Status() still returns WL_CONNECTED
Settings in IDE
Module: NodeMCU 1.0 (ESP12-E)
Flash Size: 4MB
CPU Frequency: 160Mhz
Upload Using: Serial
Reset Method: nodemcu
Sketch
#include <Arduino.h>
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
Serial.println("Setup");
}
bool wifiConnect(int timeout)
{
Serial.println("Connecting to wifi...");
uint64_t start = millis();
WiFi.setAutoReconnect(false);
WiFi.setAutoConnect(false);
WiFi.mode(WiFiMode_t::WIFI_STA);
auto connectResult = WiFi.begin("AndroidAP", "*******");
while (WiFi.status() != WL_CONNECTED)
{
delay(100);
Serial.print(".");
if (millis() - start > timeout)
{
WiFi.disconnect();
return false;
}
}
Serial.println();
return true;
}
wl_status_t prevStatus;
void loop()
{
auto wifiState = WiFi.status();
if (WiFi.status() != prevStatus)
{
Serial.printf("Wifi State changed to %s\n", WlStatusToStr(WiFi.status()));
prevStatus = WiFi.status();
}
if (!WiFi.isConnected())
{
if (wifiConnect(5000))
{
Serial.println("Successfully connected");
}
else
{
Serial.println("Timeout");
}
delay(1000);
}
}
const char* WlStatusToStr(wl_status_t wlStatus)
{
switch (wlStatus)
{
case WL_NO_SHIELD: return "WL_NO_SHIELD";
case WL_IDLE_STATUS: return "WL_IDLE_STATUS";
case WL_NO_SSID_AVAIL: return "WL_NO_SSID_AVAIL";
case WL_SCAN_COMPLETED: return "WL_SCAN_COMPLETED";
case WL_CONNECTED: return "WL_CONNECTED";
case WL_CONNECT_FAILED: return "WL_CONNECT_FAILED";
case WL_CONNECTION_LOST: return "WL_CONNECTION_LOST";
case WL_DISCONNECTED: return "WL_DISCONNECTED";
default: return "Unknown";
}
}
Debug Messages from AndroidAP
Connecting to wifi...
.....................scandone
wifi evt: 1
STA disconnect: 201
..........................Timeout
Connecting to wifi...
.....................scandone
wifi evt: 1
STA disconnect: 201
..........................Timeout
Connecting to wifi...
.......wifi evt: 2
..............scandone
state: 0 -> 2 (b0)
.state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt
connected with AndroidAP, channel 6
dhcp client start...
wifi evt: 0
.ip:192.168.43.112,mask:255.255.255.0,gw:192.168.43.1
wifi evt: 3
.
Successfully connected
Wifi State changed to WL_CONNECTED
pm open,type:2 0
state: 5 -> 2 (3c0)
rm 0
pm close 7
wifi evt: 1
STA disconnect: 3
Debug messages from hardware router:
Wifi State changed to WL_CONNECTED
pm open,type:2 0
bcn_timout,ap_probe_send_start
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
wifi evt: 1
STA disconnect: 200
Wifi State changed to WL_IDLE_STATUS
Connecting to wifi...
.scandone
wifi evt: 1
STA disconnect: 201
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.