Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
radio_poll.h File Reference

Preemption-safe "poll a condition until it holds or a deadline passes" helper. More...

#include "esphome/core/hal.h"
#include "esphome/core/application.h"
#include <cstdint>
Include dependency graph for radio_poll.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esphome::home_io_control::PollResult
 Outcome of poll_until. More...

Namespaces

namespace  esphome
namespace  esphome::home_io_control

Functions

template<typename Ready>
PollResult esphome::home_io_control::poll_until (Ready ready, uint32_t timeout_ms)
 Poll ready() until it is true or timeout_ms has passed, feeding the watchdog between samples.

Detailed Description

Preemption-safe "poll a condition until it holds or a deadline passes" helper.

Every blocking radio wait that samples a device and then compares a clock has the same hazard: if the task is descheduled between the two reads for longer than the timeout (a Wi-Fi scan, a flash write), the clock says "expired" while the device sample is already stale. Deciding on that stale sample declares a ready device dead. poll_until() fixes the order once, for every wait that must not misjudge a device on the strength of an old sample.

Definition in file radio_poll.h.