bbd5e84db0
Distinguish a cold-boot poll (UNDEFINED wakeup cause = power-on, hard reset, plug-cycle) from a normal timer wake. Encoded as the X-Boot-Reason request header; server uses it to deliberately bypass the schedule and rotate. Matches how users actually use the device: unplug-and-replug as a manual refresh. Tests: two new native cases asserting the header is "cold" on UNDEFINED wakeup and "timer" on TIMER wakeup. esp_sleep mock now exposes a settable wakeup_cause global. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
23 lines
883 B
C++
23 lines
883 B
C++
#pragma once
|
|
#include <cstdint>
|
|
|
|
extern uint64_t g_sleep_us;
|
|
extern bool g_deep_sleep_started;
|
|
|
|
// Mirror of the ESP-IDF wakeup-cause enum that the firmware actually checks.
|
|
// Tests set g_wakeup_cause directly to simulate cold-boot vs timer-wake.
|
|
typedef enum {
|
|
ESP_SLEEP_WAKEUP_UNDEFINED = 0, // cold boot / power-on / hard reset
|
|
ESP_SLEEP_WAKEUP_EXT0 = 2,
|
|
ESP_SLEEP_WAKEUP_EXT1 = 3,
|
|
ESP_SLEEP_WAKEUP_TIMER = 4, // returned to userland after deep-sleep timer
|
|
ESP_SLEEP_WAKEUP_TOUCHPAD = 5,
|
|
ESP_SLEEP_WAKEUP_ULP = 6,
|
|
} esp_sleep_wakeup_cause_t;
|
|
|
|
extern esp_sleep_wakeup_cause_t g_wakeup_cause;
|
|
|
|
inline void esp_sleep_enable_timer_wakeup(uint64_t us) { g_sleep_us = us; }
|
|
inline void esp_deep_sleep_start() { g_deep_sleep_started = true; }
|
|
inline esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause() { return g_wakeup_cause; }
|