cgiWiFi: Add a watchdog to monitor WiFi - #85
Conversation
|
I found that the new watchdog feature causes interruption in the AP connection periodically if the wanted STA is not available. So, if my client is connected to ESP32 via it's AP, and there is a STA config set in ESP32, but that STA is not available, then every 30s there is a brief interruption in the connection. This caused websocket to disconnect. (and subsequently reconnect because I'm using ReconnectingWebsocket.js.) Note that the OS (windows, android) does not disconnect the WiFi connection to ESP32 when these brief interruptions occur. This isn't a major problem in my application, just an annoyance. The user should remove the STA config if it is no longer valid. The watchdog interval can be configured via define in esp32_wifi.c. Or is there a better way to accomplish robust STA reconnect? It seems the ESP32 can't scan for WiFi APs without changing it's only 2.4g radio channel briefly. Maybe there is a less disruptive way for the WiFi driver to scan other channels, like scan one channel at a time and return the the current channel in between to keep servicing it? (BTW I'm on IDF 3.3.3, maybe it's better in 4.x) |
|
This is a limitation of the radio with the esp32. Note that the ap is a soft ap, it’s just along for the ride on whatever channel you are using. It doesn’t look like anything changed in the latest rev of the docs either, https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-channel-management I’m guessing that the radio goes into search mode for the ap when you attempt an sta connection, as it can’t know in advance what channel the ap is on. Maybe you could save and specify the channel on your reconnection? This might let the radio avoid the channel scan and the drops on the ap side. For my application I ended up with a state machine that would avoid channel change cases. I can’t recall exactly but it did require limiting the overall system to prevent drops. I can share that code if you are interested in taking a peek. It’s a few years old but it worked well when I stopped using the esp32. |
…if should be connected. Also added option to start STA connection on boot.
|
I rebased this, but need to test if it is still needed. |
|
this is included in #100 |
cgiWiFi: Add a watchdog to monitor WiFi STA connection and reconnect if should be connected.
Also added option to start STA connection on boot.
I'm also adding a PR to esphttpd-freertos example project to demonstrate.
Sorry that the white-space formatting changes makes it hard to see the changes, I'm using VS-Code to auto format. I've been meaning to do a global reformat in a single commit, but not until all the outstanding PRs are closed...