tzapu / WiFiManager

ESP8266 WiFi Connection manager with web captive portal
http://tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/
MIT License
6.45k stars 1.94k forks source link

WiFi connection stuck in an infinite retry #1710

Closed rusty-labs closed 4 months ago

rusty-labs commented 4 months ago

Basic Infos

Hardware

WiFimanager Branch/Release: Master

Esp8266/Esp32:

Hardware: Heltec wifi-lora-32-v3

Core Version: 2.4.0, staging

Description

Steps to reproduce

As a result program is stuck in an infinite reconnection loop

Problem can be solved by changing

_aggresiveReconn = false

Settings in IDE

Module: wifi-lora-32-v3

Sketch

WiFi.mode(WIFI_STA);

        wm.addParameter(&paramMqttServer);
        wm.addParameter(&paramMqttPort);
        wm.addParameter(&paramMqttUser);
        wm.addParameter(&paramMqttPassword);

        std::vector<const char *> wm_menu = {"wifi", "exit"};
        wm.setShowInfoUpdate(false);
        wm.setShowInfoErase(false);
        wm.setMenu(wm_menu);

        bool res = wm.autoConnect(_SSID);

Debug Messages

*wm:Connect Wifi, ATTEMPT # 2 of 13
*wm:Connecting to SAVED AP: xxx
E (30510) wifi:sta is connecting, return error
[ 30074][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 3 of 25
*wm:Connecting to SAVED AP: xxx
E (42016) wifi:sta is connecting, return error
[ 41580][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 4 of 37
*wm:Connecting to SAVED AP: xxx
E (53522) wifi:sta is connecting, return error
[ 53086][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 5 of 49
*wm:Connecting to SAVED AP: xxx
E (65028) wifi:sta is connecting, return error
[ 64592][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 6 of 57
*wm:Connecting to SAVED AP: xxx
E (76534) wifi:sta is connecting, return error
[ 76098][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 7 of 69
tablatronix commented 4 months ago

Hmm how tf is _connectretries increasing? Lol what in the world

rusty-labs commented 4 months ago

There is only one reason

if (info.wifi_sta_disconnected.reason == WIFI_REASON_ASSOC_FAIL)
    {
      if (_aggresiveReconn)
        _connectRetries += 4;
      DEBUG_WM(DEBUG_VERBOSE, F("[EVENT] WIFI_REASON: AUTH FAIL"));
    }

_connectretries is increased exactly by 12, meaning that the code above is being called 3 times

tablatronix commented 4 months ago

What line is that code? I missed it

rusty-labs commented 4 months ago

https://github.com/tzapu/WiFiManager/blob/0d84861270c3cd64f72a4eaf34443ee580d2547e/WiFiManager.cpp#L3833

tablatronix commented 4 months ago

I am so dumb. Lol usually this error only happens once I guess this should only be set one time

rusty-labs commented 4 months ago

There is a typo if(_aggresiveReconn & _connectRetries<4)