mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-10-28 11:14:58 +00:00
Merge pull request #3291 from hkuehl/claude/intelligent-curie-mm0eyf
fix: restart from WebUI no longer needs the browser tab to stay open
This commit is contained in:
@@ -32,6 +32,7 @@ This release is based on the latest Espressif/Arduino core version 3. It brings
|
|||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
|
- restart from the WebUI (Restart button, firmware/settings upload) only happened while the browser tab stayed open. If the tab was closed the restart was silently dropped after 5 minutes, leaving a new firmware uninstalled. EMS-ESP now restarts on its own if the WebUI hasn't picked up the pending restart within 10 seconds
|
||||||
- shunting yard show json
|
- shunting yard show json
|
||||||
- `system/sendmail` called from a Command or the Scheduler computed its value twice, which stripped the quotes from literal text and then failed on characters like `!`. Also shunting yard treated a `?` inside a quoted string as a ternary, so text like `"too hot?"` returned nothing
|
- `system/sendmail` called from a Command or the Scheduler computed its value twice, which stripped the quotes from literal text and then failed on characters like `!`. Also shunting yard treated a `?` inside a quoted string as a ternary, so text like `"too hot?"` returned nothing
|
||||||
- memory leak when using different timezones for ems-esp and thermostat[#3184](https://github.com/emsesp/EMS-ESP32/issues/3184)
|
- memory leak when using different timezones for ems-esp and thermostat[#3184](https://github.com/emsesp/EMS-ESP32/issues/3184)
|
||||||
|
|||||||
+4
-2
@@ -2110,9 +2110,11 @@ void EMSESP::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset status after a timeout
|
// reset status after a timeout. A pending restart is never reset, it's handled in System::loop()
|
||||||
if (EMSESP::system_.systemStatus() != SYSTEM_STATUS::SYSTEM_STATUS_NORMAL) {
|
|
||||||
static uint32_t starttime = 0;
|
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) {
|
if (starttime == 0) {
|
||||||
starttime = uuid::get_uptime_ms();
|
starttime = uuid::get_uptime_ms();
|
||||||
} else if (uuid::get_uptime_ms() - starttime > SYSTEM_STATUS_RESET_TIMEOUT) {
|
} else if (uuid::get_uptime_ms() - starttime > SYSTEM_STATUS_RESET_TIMEOUT) {
|
||||||
|
|||||||
@@ -1025,6 +1025,20 @@ void System::uart_init() {
|
|||||||
// checks system health and handles LED flashing wizardry
|
// checks system health and handles LED flashing wizardry
|
||||||
// returns true if the LED flash is active
|
// returns true if the LED flash is active
|
||||||
bool System::loop() {
|
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
|
// check if we're supposed to do a reset/restart
|
||||||
if (systemStatus() == SYSTEM_STATUS::SYSTEM_STATUS_RESTART_REQUESTED) {
|
if (systemStatus() == SYSTEM_STATUS::SYSTEM_STATUS_RESTART_REQUESTED) {
|
||||||
system_restart();
|
system_restart();
|
||||||
|
|||||||
@@ -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
|
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();
|
void set_partition_install_date();
|
||||||
|
|
||||||
volatile bool recovery_installed_pending_ = false; // set by the main loop, handled on the AsyncTCP task
|
volatile bool recovery_installed_pending_ = false; // set by the main loop, handled on the AsyncTCP task
|
||||||
|
|||||||
Reference in New Issue
Block a user