DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
sleep_sched.h File Reference

Dynamic sleep-cycle scheduler (DETWS_ENABLE_SLEEP_SCHED). More...

#include "ServerConfig.h"
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Detailed Description

Dynamic sleep-cycle scheduler (DETWS_ENABLE_SLEEP_SCHED).

Decides, from the time since the last activity, whether a low-power device should sleep between requests and for how long - so a battery / solar node idles most of the time yet still serves. It is a pure decision core (detws_sleep_next): given now, the last-activity timestamp, and a config, it returns the number of milliseconds to sleep (0 = stay awake). The device stays awake until it has been idle for idle_ms, then sleeps in windows that ramp from min_ms up to max_ms the longer the idle streak runs (so a briefly-idle device wakes often and responsively, a long-idle one sleeps deep).

Pure, zero heap, no stdlib, and takes an explicit now, so it is fully host-testable with a synthetic clock. The scheduler only decides the window; the app applies it per its own policy (an esp_light_sleep_start() with a timer wakeup, modem sleep, or deep sleep). It sits beside services/radio_power (modem sleep): that trims radio power while awake, this schedules the sleep.

Definition in file sleep_sched.h.