WiFiManager
WiFiManager copied to clipboard
What does WIFI_REASON: 4 Mean
I'm trying to debug a minor problem that happens when I change to a new network. Everything works fine but after it restarts I need to manually restart the board once or twice before the application runs properly. This only happens happen I run WM. When I check the log I find this:
parsed json
*wm:[2] Added Parameter: key_custom
*wm:[2] Added Parameter:
*wm:[1] AutoConnect
*wm:[2] ESP32 event handler enabled
*wm:[2] Connecting as wifi client...
*wm:[2] setSTAConfig static ip not set, skipping
*wm:[1] Connecting to SAVED AP: TheIoaks
*wm:[1] connectTimeout not set, ESP waitForConnectResult...
*wm:[2] [EVENT] WIFI_REASON: 4
and at this point I need to restart the board. I searched but I cannot seem to find the meaning of "4"
WIFI_REASON_ASSOC_EXPIRE
So that seems to be not expected after you've entered the new WiFi AP information, correct?
Is it every other reboot?
You know it might be. I need to do some additional debugging before I really bother you but that's why I was trying to understand the normal flow. In general though it seems that once I change the WiFi AP I have to manually reboot twice before the board runs the code normally. After that it always runs fine.
Yeah its a known esp issue #1137
Reading through the older issues and replies am I correct that a workaround for this issue is to add a setConnectRetries(3)
?
You can try that, yes, and add longer connect timout, this issue only presents with some routers, you can also try
bool _aggresiveReconn = true; // use an agrressive reconnect strategy, WILL delay conxs
// on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections
// https://github.com/tzapu/WiFiManager/issues/1067
Also try using newer versions of esp lib core
#1067
I'm developing in VSCode with PIO and it's showing 5.1.0 is installed which was recently updated I see (11 days ago). I'll review #1067 and run some tests to see if anything changes for the better.