-
Notifications
You must be signed in to change notification settings - Fork 458
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
WiFi.status() wrongly reports WL_CONNECTED even when WiFi is lost and RSSI is always 0 dBm #762
Comments
Thanks for the report and MCVE. The RSSI reporting 0dbm while connected or disconnected is actually a limitation of the CYW43 driver. It doesn't report common things like that. It doesn't even report BSSID or channel. Nothing we can do here unless the driver gets fixed (it talks to a undocumented proprietary blob). The incorrect |
On the WL_CONNECTED side, the code here also seems correct: arduino-pico/libraries/WiFi/src/WiFiClass.cpp Lines 472 to 484 in 5787b4c
The logic simply polls the CYW43 blob driver and uses that to determine connected or not. If the CYW43 driver reports the connection is still up, there's not much we can do here. As you probably are guessing, I've found the CYW43 driver something of a work in progress. We've even had to patch it to support simple things like multicast. --edit--- We may be able to hook into the event callbacks and track the link state on our own, ignoring what the driver says: |
I totally understand and post the issue here so that we can work on a patch similar to
This seems the best way to fix. |
I just did a quick test to patch in some logic based on the callbacks and it seems like the event is not actually being received on associate/disassociate. 😞 I probably need to instrument it and dump all events while adding/removing to see exactly what is happening and where it might be overridden.
|
This is just a temporary and inefficient kludge using
Terminal output
|
#### Releases v1.2.1 1. Workaround for RP2040W WiFi.status() bug. Check [WiFi.status() wrongly reports WL_CONNECTED even when WiFi is lost and RSSI is always 0 dBm #762](earlephilhower/arduino-pico#762) 2. Add example [WiFiMulti_RP2040W](examples/WiFiMulti_RP2040W)
Why not make it something more universal? If you ping In the meantime, I'll leave this open as something to work on. I'm not sure how much progress we can make, but I'll give it a try since it's such a basic operation. |
I first tried I'll try again later to see what's really wrong with I hope I'll have a look at the cyw43 driver, but not sure if I can spend time there to understand. Hopefully @oddstr13 can help here. |
@khoih-prog unfortunately I don't have any inside knowledge of how the firmware works, all I have to go by is the public git repo. I don't have time right now (and likely not for a good while) to have a deeper dive into this. The pico doxygen might be helpful for discovering what's available. I'd suggest submitting issues upstream, even tho they seem to be slow at responding right now. |
YEah, that document suggests that the existing code is correctly calling the right API, but the API is returning "connected" when the AP itself is down. @khoih-prog how long after the AP is shut off do you wait before checking the |
I've tried to power off AP, after many minutes, still |
I've retested using The ttl is configurable, according to network The code
Debug Terminal
|
There may be an issue in the CYW43 driver that causes a link to never be reported as going down once it has connected, when it was disassociated or when the wlan shuts off unexpectedly. Work around it by clearing the internal link active in a TCP callback for the CYW43 driver. Reports disconnection properly now, as well as reconnection. Fixes #762
@khoih-prog can you give #774 a try and report back? A simple "print connected()" loop now seems to work properly for me. |
Oh yeah, it takes ~5 seconds to notice a link drop in my experience with this chip. |
I've tested and can confirm that Great work, please merge the PR #774 |
There may be an issue in the CYW43 driver that causes a link to never be reported as going down once it has connected, when it was disassociated or when the wlan shuts off unexpectedly. Work around it by clearing the internal link active in a TCP callback for the CYW43 driver. Reports disconnection properly now, as well as reconnection. Fixes #762
Bug Description
WiFi.status()
still reportsWL_CONNECTED
arduino-pico/libraries/WiFi/src/WiFiClass.cpp
Lines 472 to 484 in 5787b4c
0 dBm
, even WiFi is connectedarduino-pico/libraries/WiFi/src/WiFiClass.cpp
Lines 320 to 323 in 5787b4c
This bug is very similar to [Portenta_H7] WiFi.status() wrongly reports WL_CONNECTED even when WiFi is lost #381
MRE
Using the following sketch
Arduino IDE v1.8.19,
arduino-pico core v2.4.0
RASPBERRY_PI_PICO_W using CYW43439 WiFi
Terminal output
The text was updated successfully, but these errors were encountered: