Chat freely about anything...

User avatar
By btidey
#73395 I use the excellent WifiManager library in all my projects to establish the wifi connection.

To avoid getting stuck in a config mode if there is any temporary down time in the wifi connection I use the time out facility to alternate between wifimanager mode and doing a normal connect.
Code: Select all      wifiManager.setConfigPortalTimeout(180);
      wifiManager.autoConnect(WM_NAME, WM_PASSWORD);


That has all worked well. However, I have discovered that the wifimanager timeout leaves the AP mode active so that one can get into a condition where it timeouts, reconnects normally and leaves the AP network active. This persists until the device is reset and with multiple devices one can end up with lots of extra spurious AP points.

I have now changed the autoconnect to
Code: Select all      if(!wifiManager.autoConnect(WM_NAME, WM_PASSWORD)) WiFi.mode(WIFI_STA);


Does that make sense or is there a better way?