Merge branch 'emsesp:dev' into dev

This commit is contained in:
Proddy
2026-10-13 07:51:57 +02:00
committed by GitHub
4 changed files with 25 additions and 3 deletions
+5 -3
View File
@@ -2154,9 +2154,11 @@ void EMSESP::loop() {
}
}
// reset status after a timeout
if (EMSESP::system_.systemStatus() != SYSTEM_STATUS::SYSTEM_STATUS_NORMAL) {
static uint32_t starttime = 0;
// reset status after a timeout. A pending restart is never reset, it's handled in System::loop()
static uint32_t starttime = 0;
if (EMSESP::system_.systemStatus() == SYSTEM_STATUS::SYSTEM_STATUS_NORMAL || EMSESP::system_.systemStatus() == SYSTEM_STATUS::SYSTEM_STATUS_PENDING_RESTART) {
starttime = 0;
} else {
if (starttime == 0) {
starttime = uuid::get_uptime_ms();
} else if (uuid::get_uptime_ms() - starttime > SYSTEM_STATUS_RESET_TIMEOUT) {
+14
View File
@@ -1028,6 +1028,20 @@ void System::uart_init() {
// checks system health and handles LED flashing wizardry
// returns true if the LED flash is active
bool System::loop() {
// a restart requested from the WebUI is first set to pending, so the WebUI's SystemMonitor can pick it up
// and show the restart screen before the connection drops. Don't depend on the browser tab staying open though:
// if nothing has polled the status after a short grace period, go ahead and restart anyway
if (systemStatus() == SYSTEM_STATUS::SYSTEM_STATUS_PENDING_RESTART) {
if (pending_restart_start_ == 0) {
pending_restart_start_ = uuid::get_uptime_ms();
} else if (uuid::get_uptime_ms() - pending_restart_start_ > PENDING_RESTART_TIMEOUT) {
LOG_INFO("No WebUI response to pending restart, restarting now");
systemStatus(SYSTEM_STATUS::SYSTEM_STATUS_RESTART_REQUESTED);
}
} else {
pending_restart_start_ = 0;
}
// check if we're supposed to do a reset/restart
if (systemStatus() == SYSTEM_STATUS::SYSTEM_STATUS_RESTART_REQUESTED) {
system_restart();
+5
View File
@@ -391,6 +391,11 @@ class System {
volatile uint8_t systemStatus_; // uses SYSTEM_STATUS enum - written from the AsyncTCP task (e.g. cancel) and read from the main loop during OTA
uint32_t pending_restart_start_ = 0; // uptime (ms) when a pending restart was first seen in the main loop
// restart anyway if a pending restart hasn't been picked up by the WebUI within this time (in ms)
// the SystemMonitor polls every second, so this only kicks in when the browser tab was closed or lost connection
static constexpr uint32_t PENDING_RESTART_TIMEOUT = 10000;
void set_partition_install_date();
volatile bool recovery_installed_pending_ = false; // set by the main loop, handled on the AsyncTCP task