-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Change of WiFi behavior after recent commit: disconnect(true) seems to *permanently* close WiFi #3522
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
Comments
Maybe related to this issue: #1306 (comment) ? |
I set my build back to 1.11.0, which is dated right before the commit you linked and I do still see similar issues. |
1.11.0? There's no 1.11.0 release. Do you mean 1.0.1? If so, that's kind of old. And no matter what build you used, it seems you are talking for some other unrelated issue. I'm not talking about delays to connect sometimes or periodic instabilities. The OP describes an easily reproducible situation 100% of the times, where WiFi is totally dead. No delays - no, "sometimes it kinda works". Any WiFi call returns immediately with an error mentioning "wifi not start". It never gets to a point that makes sense discussing about TCP/IP and MQTT. It seems you experience issues unrelated to mine. |
I think I mixed the PlatformIO numbers then. |
I would really appreciate it if someone could acknowledge that this is indeed a general issue and doesn't occur only on me. The original post contains code you can copy/paste , edit one line for your access point credentials and immediately confirm if you experience the issue or not. |
I had a similar issue on my ESP32 with "WiFi.mode(WIFI_STA);" not turning the WIFI back on after a "WiFi.mode(WIFI_OFF);" (and causing a "esp_wifi_disconnect 1153 wifi not start" error message.) As identified above by @mouridis (#3522) , this error was introduced by commit 0cdfb0b ("Add support for WiFi long range mode (#3190)" dated 6Oct19). The solution I found was to change a single line in the "WiFiGeneric.cpp" file back to the original line as follows: From the new:
Back to the original:
@me-no-dev: I am unsure if this will effect the "WiFi long range mode" code, but it certainly fixes my ""esp_wifi_disconnect 1153 wifi not start" error. PS. A simple sketch to demonstrate this issue is as follows:
|
I am using Ethernet LAN8720. After disconnecting WiFi and trying to reconnect, I got an error every time. I tried some tips, but nothing helped. I accidentally discovered that if you turn on the access point mode, turn off Wifi again, then after that the connection will be successful |
* Add support for WiFi long range mode * Update WiFiGeneric.cpp
I can confirm that using the following code to disable wifi after using it: and then trying to connect to WiFi again with: fails with errors: With @Rob58329 's fix, it works:
|
I have the same problem: void p(int n) {
Serial.println(n);
}
void test() {
Serial.println(WiFi.getMode());
WiFi.persistent(false); p(1);
WiFi.disconnect(true); p(2);
WiFi.enableSTA(true); p(3);
WiFi.begin(... ...); p(4);
}
Result:
1 <--- mode WIFI_MODE_STA
1 That's all. Stops at |
@me-no-dev The workaround that @Rob58329 mentioned in the comment above seems to work for us having this issue. The question is, is this a general solution or is it just a workaround that works for us but breaks other use cases? I guess bottom line is, if a PR is submitted with this, will it be accepted? |
I think he was trying to avoid a crash that can occur if you ask for the state before the device has been initialized. Submit it with |
The @lbernstone alterative |
Have found this behaviour also last week! |
This commit fixes issue espressif#3522 where WiFi service fails to start after a WiFi.disconnect(true) or a WiFi.mode(WIFI_OFF).
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
…ssif#4114) This commit fixes issue espressif#3522 where WiFi service fails to start after a WiFi.disconnect(true) or a WiFi.mode(WIFI_OFF).
Fix issue espressif#3522 (WiFi does not restart after stopped) (espressif#4114)
Hardware:
Board: LOLIN32
Core Installation version: Latest commit (4846d9c)
IDE name: Arduino IDE / VSCode
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 921600
Computer OS: Win10-x64
Description:
An old piece of code that worked for some time stopped working after updating core to latest commit (4846d9c). More specifically calls to WiFi.scanNetworks() failed with messages like this in the serial:
By git bisecting, I found the last core version that my code works to be commit e506136. Code stops working in commit 0cdfb0b.
By slimming down my code, this is a simple sketch to reproduce the issue:
It initially attempts to send a HTTP GET request to a server and get the payload (successfully). After that it calls WiFi.disconnect(true) to disconnect and set WiFi mode to WIFI_OFF. It then waits for anything in the Serial to call WiFi.scanNetworks() and output the number of found networks.
That call fails in recent core commits (after 0cdfb0b) and succeeds in older ones, hence the change in behavior.
Now, one could argue that this is a fix and not an issue, because WiFi is off after disconnect(true), so it's normal for scanNetworks() to fail. But it seems that scanNetworks() fails even if you try to change the WiFi mode to WIFI_STA again, which should not happen.
Just replace the loop() above with this one:
This still fails.
I also tried WiFi.mode(WIFI_MODE_STA) and WiFi.enableSTA(true) instead of WiFi.mode(WIFI_STA) but WiFi.scanNetworks() always fails with the above message in the Serial.
Now, until that time, I thought this issue was specific to WiFi.scanNetworks(). Then I replaced it in the loop() with a call to WiFiCheck() - the same function that is called successfully in setup().
These calls to WiFiCheck() fail.
It seems that after the initial disconnect(true), there is no way to change the WiFi mode again.
The text was updated successfully, but these errors were encountered: