-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(wifi): fixes WiFi.isconnected() to return true when it is connected and it has an IP Addr #10595
Conversation
👋 Hello SuGlider, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
Test Results 56 files 56 suites 4m 14s ⏱️ Results for commit 877d497. ♻️ This comment has been updated with latest results. |
@@ -215,7 +215,7 @@ bool WiFiSTAClass::bandwidth(wifi_bandwidth_t bandwidth) { | |||
* @return true if STA is connected to an AP | |||
*/ | |||
bool WiFiSTAClass::isConnected() { | |||
return STA.connected(); | |||
return STA.connected() && STA.hasIP(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just STA.hasIP()
is enough here. You can not have IP if you are not connected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it is configured as static IP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are correct. hasIP()
checks if either IP has been assigned or that it has static. Since even when static GOT_IP
event is received, maybe worth changing there too. Not sure what is more correct for gotIP()
, but we can discuss that later.
…addr (espressif#10595)" This reverts commit e99f1fd.
i have a question. if (WiFi.status() == WL_CONNECTED) {
} does |
Description of Change
After 3.0.x (including 3.1.x) the function
WiFiSTAClass::isConnected()
returns when it is connected to the WiFi AP but not necessarily when it has an IP address.This is a breaking change because 2.0.x only returns true when both, it is connected and it has an IP.
This PR fixes it.
Tests scenarios
Related links
Fix #10580