fix(operation): EXT0 wakeup on BOOT button so 5-sec-hold reset works during sleep
Bug: the device only woke from deep sleep on a timer; pressing BOOT during sleep did nothing. The 5-second-hold reset only worked in the brief awake window during a poll, which made the documented "hold BOOT to reset" gesture appear broken to the user. Reported live 2026-05-09. Fix: arm EXT0 wakeup on PIN_BTN_RESET (active-low — BOOT is pulled-up on the dev board) at every esp_deep_sleep_start. After the press wakes the chip, setup() runs and the existing check_reset_button() handles the rest of the 5-second hold and triggers the NVS clear + reprovision. Mocks: esp_sleep.h gains gpio_num_t typedef + g_ext0_wakeup_pin/level globals so the native test can assert the call shape. Test: FW-RESET-WAKE pins the contract — every deep_sleep_start must arm EXT0 on PIN_BTN_RESET, level 0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -316,5 +316,13 @@ void normal_operation_impl(const String& mac, HTTP& http, const String& url, Pre
|
||||
}
|
||||
|
||||
esp_sleep_enable_timer_wakeup(sleepMs * 1000ULL);
|
||||
// Wake on the BOOT button so the user-facing 5-second-hold reset works
|
||||
// even during deep sleep. Without this, the button only does anything
|
||||
// during the brief poll-and-paint window when the device is awake, and
|
||||
// a full sleep cycle (default minutes) of holding does nothing.
|
||||
// Pin is GPIO 0 (PIN_BTN_RESET); active-low because BOOT is pulled-up
|
||||
// and shorts to ground on press. After EXT0 wakes the chip, setup()
|
||||
// runs and check_reset_button() handles the remainder of the hold.
|
||||
esp_sleep_enable_ext0_wakeup((gpio_num_t)PIN_BTN_RESET, 0);
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user