|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
Dynamic sleep-cycle scheduler (PROTOCORE_ENABLE_SLEEP_SCHED). More...
#include "protocore_config.h"Go to the source code of this file.
Dynamic sleep-cycle scheduler (PROTOCORE_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 (protocore_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 (a light sleep with a timer wakeup, modem sleep, or deep sleep). It sits beside network_drivers/physical/radio_power (modem sleep): that trims radio power while awake, this schedules the sleep.
Definition in file sleep_sched.h.