Description
Board
ESP32DevkitCVE/IE
Device Description
The devkit with an external antenna connector(CVIE) an external antenna is connected, in the case of the one with internal antenna nothing is connected besides a PC using an USB-A to USB-Micro-B cable.
Hardware Configuration
Nothing connected.
Version
latest master (checkout manually)
IDE Name
PlatformIO - Eclipse
Operating System
Ubuntu 20.04
Flash frequency
40MHz
PSRAM enabled
no
Upload speed
921600
Description
After updating a sketch from 1.0.6 to 2.0.2 I noticed that the WiFi in STA mode doesn't get an IP until it times out and reconnects.
This can already take a few minutes, and is the case even tho the first WiFi method called in that sketch is WiFi.disconnect(true);
.
After finally connecting WiFi works for a few minutes, before silently stopping(No log output even with CORE_DEBUG_LEVEL
set to 5).
After not working for a few minutes it causes a disconnect event, on which my sketch would then reconnect.
This actually works, and doesn't take a few minutes.
After some useless debugging I then tried to find a minimal sketch to reproduce this.
My end result was pretty much just a web server, but I will post this sketch below.
I then tried the SimpleWiFiServer
example. which seems to have the same issues, except it didn't seem to ever reconnect.
Restarting the ESP did not seem to change anything at all.
This might be related to #4980
In the log of my custom sketch below I used a bash script to request the content of the web server every 3 seconds.
As far as I know that is the only thing that interacted with the ESP during the time of the test.
The log doesn't seem to change much even without the script, however I wanted to know when it stops working.
Here the script:
while true
do
curl -s --connect-timeout 5 http://192.168.2.138/index.html > /dev/null
if [ $? == 0 ]; then
echo OK
else
echo ERROR
fi
sleep 3
done
Sketch
#include <ESPAsyncWebServer.h>
extern const char WIFI_SSID[] = "WIFI_SSID";
extern const char WIFI_PASS[] = "WPA_PASSPHRASE";
uint64_t start = 0;
AsyncWebServer server(80);
void onWiFiGotIp(WiFiEvent_t event, WiFiEventInfo_t eventInfo) {
Serial.print("IP Address: ");
Serial.println((IPAddress) eventInfo.got_ip.ip_info.ip.addr);
Serial.print("WiFi ready after ");
Serial.print(millis() - start);
Serial.println("ms.");
}
void onWiFiDisonnected(WiFiEvent_t event) {
Serial.println("WiFi Disconnected");
WiFi.disconnect(true);
delay(100);
WiFi.begin(WIFI_SSID, WIFI_PASS);
}
void setupWebServer() {
server.on("/index.html", HTTP_GET, [] (AsyncWebServerRequest *request) {
request->send(200, "text/plain", "OK");
});
server.onNotFound([] (AsyncWebServerRequest *request) {
request->send(404, "text/plain", "Not Found");
});
server.begin();
}
void setup() {
start = millis();
Serial.begin(115200);
Serial.println("setup start");
WiFi.disconnect(true);
WiFi.onEvent(onWiFiGotIp, ARDUINO_EVENT_WIFI_STA_GOT_IP);
WiFi.onEvent(onWiFiDisonnected, ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
WiFi.begin(WIFI_SSID, WIFI_PASS);
setupWebServer();
Serial.println("setup end");
}
void loop() {
delay(100);
}
Debug Message
SimpleWiFiServer log:
Click here to show
rst:0x1 (POWERON_RESET),boot:0x13 (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:2
load:0x3fff0030,len:1184
load:0x40078000,len:12784
load:0x40080400,len:3032
entry 0x400805e4
[ 2][V][WiFiServer.h:42] WiFiServer(): WiFiS�␘ƕ��:WiFiServer(port=80, ...)
[ 4][D][esp32-hal-cpu.c:214] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
Connecting to WLAN-8C1784
[ 77][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 173][V][WiFiGeneric.cpp:96] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[ 172][V][WiFiGeneric.cpp:283] _arduino_event_cb(): STA Started
[ 179][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 2 - STA_START
[ 231][V][WiFiGeneric.cpp:295] _arduino_event_cb(): STA Connected: SSID: WLAN-8C1784, BSSID: 84:9c:a6:8c:17:50, Channel: 7, Auth: WPA2_PSK
[ 233][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[ 258][V][WiFiGeneric.cpp:305] _arduino_event_cb(): STA Got New IP:192.168.2.137
[ 259][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[ 262][D][WiFiGeneric.cpp:914] _eventCallback(): STA IP: 192.168.2.137, MASK: 255.255.255.0, GW: 192.168.2.1
.
WiFi connected.
IP address:
192.168.2.137
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
New Client.
GET /index.html HTTP/1.1
Host: 192.168.2.137
User-Agent: curl/7.68.0
Accept: */*
Client Disconnected.
[240064][V][WiFiGeneric.cpp:300] _arduino_event_cb(): STA Disconnected: SSID: WLAN-8C1784, BSSID: 84:9c:a6:8c:17:50, Reason: 7
[240065][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[240072][W][WiFiGeneric.cpp:873] _eventCallback(): Reason: 7 - NOT_ASSOCED
[360065][V][WiFiGeneric.cpp:309] _arduino_event_cb(): STA IP Lost
[360066][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 9 - STA_LOST_IP
Custom Sketch(posted above) Debug Log:
Click here to show
rst:0x1 (POWERON_RESET),boot:0x13 (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:2
load:0x3fff0030,len:1184
load:0x40078000,len:12784
load:0x40080400,len:3032
entry 0x400805e4
[␀␘␂␂␂��m␑um����2-hal-cpu.c:214] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
setup start
[ 65][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 159][V][WiFiGeneric.cpp:96] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[ 157][V][WiFiGeneric.cpp:283] _arduino_event_cb(): STA Started
[ 165][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 2 - STA_START
setup end
[ 229][V][WiFiGeneric.cpp:295] _arduino_event_cb(): STA Connected: SSID: WLAN-8C1784, BSSID: 84:9c:a6:8c:17:50, Channel: 7, Auth: WPA2_PSK
[ 231][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[ 75550][V][WiFiGeneric.cpp:300] _arduino_event_cb(): STA Disconnected: SSID: WLAN-8C1784, BSSID: 84:9c:a6:8c:17:50, Reason: 7
[ 75551][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 75558][W][WiFiGeneric.cpp:873] _eventCallback(): Reason: 7 - NOT_ASSOCED
WiFi Disconnected
[ 75576][V][WiFiGeneric.cpp:286] _arduino_event_cb(): STA Stopped
[ 75705][V][WiFiGeneric.cpp:96] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[ 75703][V][WiFiGeneric.cpp:283] _arduino_event_cb(): STA Started
[ 75721][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 3 - STA_STOP
[ 75721][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 75725][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 2 - STA_START
[ 75766][V][WiFiGeneric.cpp:295] _arduino_event_cb(): STA Connected: SSID: WLAN-8C1784, BSSID: 84:9c:a6:8c:17:50, Channel: 7, Auth: WPA2_PSK
[ 75768][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[ 75850][V][WiFiGeneric.cpp:305] _arduino_event_cb(): STA Got New IP:192.168.2.138
[ 75851][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[ 75854][D][WiFiGeneric.cpp:914] _eventCallback(): STA IP: 192.168.2.138, MASK: 255.255.255.0, GW: 192.168.2.1
IP Address: 192.168.2.138
WiFi ready after 75835ms.
[438184][V][WiFiGeneric.cpp:300] _arduino_event_cb(): STA Disconnected: SSID: WLAN-8C1784, BSSID: 84:9c:a6:8c:17:50, Reason: 7
[438185][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[438192][W][WiFiGeneric.cpp:873] _eventCallback(): Reason: 7 - NOT_ASSOCED
WiFi Disconnected
[438212][V][WiFiGeneric.cpp:286] _arduino_event_cb(): STA Stopped
[438339][V][WiFiGeneric.cpp:283] _arduino_event_cb(): STA Started
[438340][V][WiFiGeneric.cpp:96] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[438359][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 3 - STA_STOP
[438359][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 0 - WIFI_READY
[438362][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 2 - STA_START
[438419][V][WiFiGeneric.cpp:295] _arduino_event_cb(): STA Connected: SSID: WLAN-8C1784, BSSID: 84:9c:a6:8c:17:50, Channel: 7, Auth: WPA2_PSK
[438421][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[438448][V][WiFiGeneric.cpp:305] _arduino_event_cb(): STA Got Same IP:192.168.2.138
[438449][D][WiFiGeneric.cpp:852] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[438452][D][WiFiGeneric.cpp:914] _eventCallback(): STA IP: 192.168.2.138, MASK: 255.255.255.0, GW: 192.168.2.1
IP Address: 192.168.2.138
WiFi ready after 438433ms.
Other Steps to Reproduce
It works correctly with version 1.0.6, if the event names are changed to account for the version change.
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status