WiFiManager icon indicating copy to clipboard operation
WiFiManager copied to clipboard

What does WIFI_REASON: 4 Mean

Open GeorgeIoak opened this issue 1 year ago • 8 comments

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"

GeorgeIoak avatar Aug 06 '22 02:08 GeorgeIoak

WIFI_REASON_ASSOC_EXPIRE

tablatronix avatar Aug 09 '22 16:08 tablatronix

So that seems to be not expected after you've entered the new WiFi AP information, correct?

GeorgeIoak avatar Aug 10 '22 00:08 GeorgeIoak

Is it every other reboot?

tablatronix avatar Aug 10 '22 00:08 tablatronix

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.

GeorgeIoak avatar Aug 10 '22 00:08 GeorgeIoak

Yeah its a known esp issue #1137

tablatronix avatar Aug 10 '22 02:08 tablatronix

Reading through the older issues and replies am I correct that a workaround for this issue is to add a setConnectRetries(3) ?

GeorgeIoak avatar Aug 11 '22 00:08 GeorgeIoak

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

tablatronix avatar Aug 11 '22 01:08 tablatronix

#1067

tablatronix avatar Aug 11 '22 01:08 tablatronix

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.

GeorgeIoak avatar Aug 11 '22 23:08 GeorgeIoak