From ac3e80d8389b5e3aa9969cb3391f8232bcab30a6 Mon Sep 17 00:00:00 2001 From: Mike Vanis Date: Tue, 15 Dec 2020 10:46:03 +0000 Subject: [PATCH 1/3] nuke wifi if it hasnt connected for two minutes --- ESP32-SOCKETIO.ino | 2 +- wifi.ino | 33 +++++++-------------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/ESP32-SOCKETIO.ino b/ESP32-SOCKETIO.ino index a7ddf26..7e27a4f 100644 --- a/ESP32-SOCKETIO.ino +++ b/ESP32-SOCKETIO.ino @@ -73,7 +73,7 @@ using namespace ace_button; #define RGBLEDPWMSTART 120 #define FASTLONGFADE 120 unsigned long LONGFADEMINUTESMAX = 360; -#define LONGFADECHECKMILLIS 60000 +#define LONGFADECHECKMILLIS 120000 unsigned long prevLongFadeVal[NUMPIXELS] = {0,0}; uint8_t hue[NUMPIXELS]; uint8_t saturation[NUMPIXELS]; diff --git a/wifi.ino b/wifi.ino index df6ac0f..fa5f176 100644 --- a/wifi.ino +++ b/wifi.ino @@ -72,7 +72,7 @@ void connectToWifi(String credentials) { if (ssid.size() > 0) { for (int i = 0; i < ssid.size(); i++) { if (isWifiValid(ssid[i])) { - wifiMulti.addAP(checkSsidForSpelling(ssid[i]).c_str(), pass[i]); + wifiMulti.addAP(checkSsidForSpelling(ssid[i]).c_str(), pass[i]); } } } else { @@ -134,31 +134,12 @@ void connectToWifi(String credentials) { if (millis() - wifiMillis > WIFICONNECTTIMEOUT) { // Timeout, check if we're out of range. - while (hasConnected) { - // Out of range, keep trying - uint8_t _currentStatus = wifiMulti.run(); - if (_currentStatus == WL_CONNECTED) { - digitalWrite(LED_BUILTIN, 0); - preferences.begin("scads", false); - preferences.putBool("hasConnected", true); - preferences.end(); - break; - } - else { - digitalWrite(LED_BUILTIN, 1); - delay(100); - Serial.print("."); - } - yield(); - } - if (!hasConnected) { - // Wipe credentials and reset - Serial.println("Wifi connect failed, Please try your details again in the captive portal"); - preferences.begin("scads", false); - preferences.putString("wifi", ""); - preferences.end(); - ESP.restart(); - } + // Wipe credentials and reset + Serial.println("Wifi connect failed, Please try your details again in the captive portal"); + preferences.begin("scads", false); + preferences.putString("wifi", ""); + preferences.end(); + ESP.restart(); } delay(100); From fefdd9562665d44333f95d6a9bea813c157a231d Mon Sep 17 00:00:00 2001 From: Mike Vanis Date: Tue, 15 Dec 2020 11:11:09 +0000 Subject: [PATCH 2/3] remove hasConnected from memories --- wifi.ino | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/wifi.ino b/wifi.ino index fa5f176..99d57bd 100644 --- a/wifi.ino +++ b/wifi.ino @@ -84,10 +84,6 @@ void connectToWifi(String credentials) { long wifiMillis = millis(); bool connectSuccess = false; - preferences.begin("scads", false); - bool hasConnected = preferences.getBool("hasConnected"); - preferences.end(); - while (!connectSuccess) { uint8_t currentStatus = wifiMulti.run(); @@ -121,13 +117,6 @@ void connectToWifi(String credentials) { if (currentStatus == WL_CONNECTED) { // Connected! - - if (!hasConnected) { - preferences.begin("scads", false); - preferences.putBool("hasConnected", true); - preferences.end(); - hasConnected = true; - } connectSuccess = true; break; } From 444b6fd1b10405793fbc3ad5c19d87e25e2898e5 Mon Sep 17 00:00:00 2001 From: Mike Vanis Date: Tue, 15 Dec 2020 11:58:39 +0000 Subject: [PATCH 3/3] change wifi timeout to 2 mins --- ESP32-SOCKETIO.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESP32-SOCKETIO.ino b/ESP32-SOCKETIO.ino index 7e27a4f..cf5d503 100644 --- a/ESP32-SOCKETIO.ino +++ b/ESP32-SOCKETIO.ino @@ -36,7 +36,7 @@ int currentSetupStatus = setup_pending; #define PROJECT_SLUG "ESP32-SOCKETIO" #define VERSION "v0.2" #define ESP32set -#define WIFICONNECTTIMEOUT 60000 +#define WIFICONNECTTIMEOUT 120000 #define SSID_MAX_LENGTH 31 #include