mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-30 03:13:51 +00:00
If wifi credentials ever go stale, dump them.
This solves the dreaded 5 - STA_DISCONNECTED / 2 - AUTH_EXPIRE loops
This commit is contained in:
parent
139f61d03e
commit
49378a9145
@ -43,28 +43,12 @@ bool APStartupComplete = 0;
|
|||||||
|
|
||||||
static bool needReconnect = true; // If we create our reconnector, run it once at the beginning
|
static bool needReconnect = true; // If we create our reconnector, run it once at the beginning
|
||||||
|
|
||||||
// FIXME, veto light sleep if we have a TCP server running
|
|
||||||
#if 0
|
|
||||||
class WifiSleepObserver : public Observer<uint32_t> {
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Return 0 if sleep is okay
|
|
||||||
virtual int onNotify(uint32_t newValue) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static WifiSleepObserver wifiSleepObserver;
|
|
||||||
//preflightSleepObserver.observe(&preflightSleep);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int32_t reconnectWiFi()
|
static int32_t reconnectWiFi()
|
||||||
{
|
{
|
||||||
const char *wifiName = config.network.wifi_ssid;
|
const char *wifiName = config.network.wifi_ssid;
|
||||||
const char *wifiPsw = config.network.wifi_psk;
|
const char *wifiPsw = config.network.wifi_psk;
|
||||||
|
|
||||||
if (config.network.wifi_enabled && needReconnect && !WiFi.isConnected()) {
|
if (config.network.wifi_enabled && needReconnect && !WiFi.isConnected()) {
|
||||||
// if (radioConfig.has_preferences && needReconnect && !WiFi.isConnected()) {
|
|
||||||
|
|
||||||
if (!*wifiPsw) // Treat empty password as no password
|
if (!*wifiPsw) // Treat empty password as no password
|
||||||
wifiPsw = NULL;
|
wifiPsw = NULL;
|
||||||
@ -72,11 +56,12 @@ static int32_t reconnectWiFi()
|
|||||||
if (*wifiName) {
|
if (*wifiName) {
|
||||||
needReconnect = false;
|
needReconnect = false;
|
||||||
|
|
||||||
|
// Make sure we clear old connection credentials
|
||||||
|
WiFi.disconnect(false, true);
|
||||||
|
|
||||||
DEBUG_MSG("... Reconnecting to WiFi access point\n");
|
DEBUG_MSG("... Reconnecting to WiFi access point\n");
|
||||||
WiFi.mode(WIFI_MODE_STA);
|
WiFi.mode(WIFI_MODE_STA);
|
||||||
WiFi.begin(wifiName, wifiPsw);
|
WiFi.begin(wifiName, wifiPsw);
|
||||||
|
|
||||||
// Starting timeClient;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user