Skip to content
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

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Member

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.

Copy link
Collaborator Author

@SuGlider SuGlider Nov 11, 2024

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?

Copy link
Member

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.

}

/**
Expand Down
Loading