Skip to content

Added a disconnect before connect #3123

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

Closed
wants to merge 3 commits into from

Conversation

terryjmyers
Copy link

as per section 3.5.13 in the "ESP8266 Non-OS SDK API Reference" (https://espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf) the function wifi_station_connect states:
"If the ESP8266 is already connected to a router, wifi_station_disconnect
must be called first, before calling wifi_station_connect. "
I've always had to call WiFi.Disconnect() first which calls wifi_station_disconnect(), but if we add a disconnect always before a standard connect, it will make programming on the fly network changes eaiser.

as per section 3.5.13 in the "ESP8266 Non-OS SDK API Reference" (https://espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf) the function wifi_station_connect states:
"If the ESP8266 is already connected to a router, wifi_station_disconnect
must be called first, before calling wifi_station_connect. "
I've always had to call WiFi.Disconnect() first which calls wifi_station_disconnect(), but if we add a disconnect always before a standard connect, it will make programming on the fly network changes eaiser.
@igrr
Copy link
Member

igrr commented May 8, 2017

Thanks for the PR!

Could you please clarify the issue which is being solved? I have always thought that calling WiFi.disconnect() before WiFi.connect with different credentials is intentional, because it makes the purpose of the code clear — disconnect from the current network and then connect to the new one.

@pfeerick
Copy link
Contributor

I'd suggest that this was proposed merely for convenience... i.e. being able to just call WiFi.connect() again without having to worry about the disconnect if already connected to a network. Handy, but if you really want that, I think a macro in that sketch would be better, as I agree with iggr, it would be better to have it explicit so the intent is clear in the code. Maybe we can let this one go?

@earlephilhower earlephilhower added this to the 2.6.2 milestone Nov 18, 2019
@earlephilhower
Copy link
Collaborator

This is a simple 1-liner and we should be able to agree or drop it with the next release.

If calling wifi_station_disconnect() when disconnected is legal (and required before wifi_station_connect(), I'm not seeing any issue with it. If it is illegal to do so, this should be closed.

@devyte
Copy link
Collaborator

devyte commented Nov 26, 2019

I am not convinced about this. My own wifi setup sequence doesn't (sdk-) disconnect before connecting, and it works even when already connected. My suspicion is that the sdk already does this internally, likely implemented in a later release than when this PR was proposed.
Closing.

@devyte devyte closed this Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants