diff --git a/environments.ini b/environments.ini index 6f27295..a330d88 100644 --- a/environments.ini +++ b/environments.ini @@ -113,6 +113,7 @@ build_flags = '-DWM_PWD_FROM_MAC=true' '-DUSE_MAC_AS_GATEWAY_NAME=true' '-DZsensorC37_YL83_HMRD="HMRD"' + '-DESPWifiManualSetup=true' '-DDEEP_SLEEP_IN_US=120000000' ; Deep sleep for a period of time to conserve battery '-DESP32_EXT0_WAKE_PIN=GPIO_NUM_14' ;Should a water leak be detected immediatly wake the ESP32 and report the problem '-DESP32_EXT0_WAKE_PIN_STATE=0' ;Should a water leak be detected immediatly wake the ESP32 and report the problem, sensor state to look for wakeup diff --git a/main/ZwebUI.ino b/main/ZwebUI.ino index 695c55d..0d88558 100644 --- a/main/ZwebUI.ino +++ b/main/ZwebUI.ino @@ -46,8 +46,6 @@ QueueHandle_t webUIQueue; WebServer server(80); /*------------------- External functions ----------------------*/ - -esp_err_t nvs_flash_erase(void); extern void eraseAndRestart(); extern unsigned long uptime(); diff --git a/main/main.ino b/main/main.ino index f8dae48..f239c5c 100644 --- a/main/main.ino +++ b/main/main.ino @@ -1306,20 +1306,6 @@ void checkButton() { void checkButton() {} # endif -void eraseAndRestart() { - Log.trace(F("Formatting requested, result: %d" CR), SPIFFS.format()); - -# if defined(ESP8266) - WiFi.disconnect(true); - wifiManager.resetSettings(); - delay(5000); - ESP.reset(); -# else - nvs_flash_erase(); - ESP.restart(); -# endif -} - void saveMqttConfig() { Log.trace(F("saving config" CR)); DynamicJsonDocument json(512 + ota_server_cert.length() + mqtt_cert.length()); @@ -1923,6 +1909,25 @@ String UTCtimestamp() { return buffer; } +/* + Erase flash and restart the ESP +*/ +void eraseAndRestart() { + Log.trace(F("Formatting requested, result: %d" CR), SPIFFS.format()); + +# if defined(ESP8266) + WiFi.disconnect(true); +# ifndef ESPWifiManualSetup + wifiManager.resetSettings(); +# endif + delay(5000); + ESP.reset(); +# else + nvs_flash_erase(); + ESP.restart(); +# endif +} + #endif #if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)