-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Issues with both documentation and implementation of WiFi.status() in ESP8266WiFi library #7005
Comments
I think users mainly rely on I also think that we will allow some (minor) backward compatibility issues for release 3.0.0. |
So what's your suggestion based on that assessment?
|
@thierer we've discussed internally, and what you put forth here has merit. Like you pointed out, this impacts compatibility, so we keep status quo for now and any changes must be targeted for v3. |
Fair enough. I don't have a PR, but IMHO the way to go is to not rely on (I suspect the reason why
I'll see if I find time to come up with a PR. |
Closing as duplicate #7432, let's follow-up there ! |
Platform
Problem Description
The docs for WiFi.status() state
The code just does a mapping from the return values of
wifi_station_get_connect_status()
to Arduino constants:IMHO the documentation and the code have the following issues:
WL_NO_SSID_AVAIL
andWL_CONNECT_FAILED
From what I experienced, both states only happen with
setAutoReconnect(true)
. That's mostly an issue with the underlying esp8266 sdk, but I think the docs should at least state the fact. Also, looking at the code suggests that a wrong password isn't the only possible cause though I don't know under which circumstanceswifi_station_get_connect_status()
would returnSTATION_CONNECT_FAIL
.WL_IDLE_STATUS
andWL_DISCONNECTED
I think the two status values are mixed up. The implementation should probably reflect the semantics of the original Arduino library, quoted below:
WL_IDLE_STATUS
: it is a temporary status assigned whenWiFi.begin()
is called and remains active until the number of attempts expires (resulting inWL_CONNECT_FAILED
) or a connection is established (resulting inWL_CONNECTED
);WL_DISCONNECTED
: assigned when disconnected from a network;But as it is implemented now, it's excatly the other way round:
WL_IDLE_STATUS
is reported before and afterWiFi.begin()
resp.WiFi.disconnect()
are called andWL_DISCONNECTED
in the time between the two calls before a connection has been made:Demo sketch
Output:
I'd be happy to prepare a PR, but I'd like to discuss the prefered solution first:
The obvious fix would be to swap the two symbols in the switch statement, but that would break backwards compatibilty with programs that rely on the current behaviour.
At very least the docs should be updated: I have the impression that for
WL_IDLE_STATUS
andWL_DISCONNECTED
they try to represent what the implementation would be if it matched the definition of the original library, so if 1. isn't an option, then the annotations for these two values should be swapped.The longer term goal should imho be to fix WiFi.status() to better represent the current state of the connection. That would include making
WL_NO_SSID_AVAIL
andWL_CONNECT_FAILED
work withsetAutoReconnect(false)
and maybe add the currently unsupported stateWL_CONNECTION_LOST
. i won't promise anything :), but would such a PR be considered given that it would break backwards compatibility even more?The text was updated successfully, but these errors were encountered: