diff --git a/Software/src/common.h b/Software/src/common.h index 41dfd81..cfaa9ff 100644 --- a/Software/src/common.h +++ b/Software/src/common.h @@ -35,6 +35,8 @@ #define OTA_DELAY 50 // ticks -> 10ms / tick #endif +#define SHUTDOWN_DELAY_MS 5000 + #define ATOMIC_FS_UPDATE #ifndef ADMIN_PASSWORD diff --git a/Software/src/main.cpp b/Software/src/main.cpp index 3c7142d..ad538b8 100644 --- a/Software/src/main.cpp +++ b/Software/src/main.cpp @@ -735,8 +735,19 @@ void toggleWiFiAP(boolean shutdown) void SystemShutdown() { - StoreConfig_EEPROM(); - ESP.restart(); + static uint32_t shutdown_delay = 0; + + if (shutdown_delay == 0) + { + shutdown_delay = millis() + SHUTDOWN_DELAY_MS; + Serial.printf("Shutdown requested - Restarting in %d seconds\n", SHUTDOWN_DELAY_MS); + } + if (shutdown_delay < millis()) + { + StoreConfig_EEPROM(); + StorePersistence_EEPROM(); + ESP.restart(); + } } uint32_t Process_Impulse_WheelSpeed() diff --git a/Software/src/webui.cpp b/Software/src/webui.cpp index ce01e5f..fa62d8f 100644 --- a/Software/src/webui.cpp +++ b/Software/src/webui.cpp @@ -348,7 +348,7 @@ void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const Stri { Serial.println("Update complete"); Serial.flush(); - ESP.restart(); + globals.systemStatus = sysStat_Shutdown; } } }