Closed CelliesProjects closed 2 weeks ago
I do agree it may sound confusing, but I am not sure this really is a bug. Afterall these are two quite different concepts, connected and gotIP. It can take a while to get an IP from the DHCP server, especially for IPv6 it may take several seconds.
Not sure what "Arduino" claims how 'connected' should be interpreted.
@TD-er Maybe not all, but most example sketches for esp32 use this construct to connect to WiFi.
while (!WiFi.isConnected())
delay(10);
I don't claim it is a bug, but it surprised me. And my assumptions about code behaviour might be wrong.
Yep, that's why I also wonder what "the Arduino" expected interpretation should be.
@me-no-dev - FYI.
Issue report confirmed. This behaviour started with Arduino Core 3.0.0. Such behaviour is not noticed with Arduino Core 2.0.17, which marks a change break.
Arduino WiFi Library (upstream) has no isConnect()
API.
It relies on status()
to know when it is connected to WiFi.
https://docs.arduino.cc/libraries/wifi/
Possible Status are:
typedef enum {
WL_NO_SHIELD = 255,
WL_IDLE_STATUS = 0,
WL_NO_SSID_AVAIL,
WL_SCAN_COMPLETED,
WL_CONNECTED,
WL_CONNECT_FAILED,
WL_CONNECTION_LOST,
WL_DISCONNECTED
} wl_status_t;
The WiFi Arduino API may consider implicitly that as soon as status is WL_CONNECT
, there is a valid IP address associated.
The current behaviour may be acceptable or not. We will discuss it internally. I'll report here the results.
Decision: We will change WiFi.isConnected()
to only return when WiFi is connected and ESP32 has got an IP address to make it work as before. I'll add a PR to fix it.
@CelliesProjects - Thank you for the report and quick fix. We will apply it!
Board
esp32-s3
Device Description
Just a plain old esp32-s3
Hardware Configuration
Nothing of consequence
Version
v3.0.7
IDE Name
PlatformIO
Operating System
Mint Linux
Flash frequency
80
PSRAM enabled
yes
Upload speed
921600
Description
WiFi.localIP()
should report the IP address. Instead it displays0.0.0.0
after a succesfull connection. After a while it does show the correct IP.Fix
A quick fix here was to change
isConnected()
inWiFiSTA.cpp
to the snippet below.This change gives the expected behaviour.
Sketch
Debug Message
Other Steps to Reproduce
I did not try any other hw.
I have checked existing issues, online documentation and the Troubleshooting Guide