27#include "esphome/core/preferences.h"
56 "the stride must let many unclean reboots in a row still land inside a device's "
57 "acceptance window — a larger stride buys fewer flash writes and pays in silent desync");
123 uint16_t reserved{0};
124 ESPPreferenceObject pref;
128 const Counter *find_(
const uint8_t node_id[
NODE_ID_SIZE])
const;
130 std::vector<Counter> counters_;
Per-controller-identity rolling sequence counters, persisted across reboots.
bool seed(const uint8_t node_id[NODE_ID_SIZE], uint16_t value)
Force an identity's counter to a specific value and persist it immediately.
void add_identity(const uint8_t node_id[NODE_ID_SIZE], uint16_t initial_sequence)
Register a controller identity and load its persisted counter.
bool next(const uint8_t node_id[NODE_ID_SIZE], uint16_t &out)
Reserve and return the next sequence for an identity.
bool peek(const uint8_t node_id[NODE_ID_SIZE], uint16_t &out) const
The next sequence this identity would hand out, without reserving it.
static constexpr uint8_t NODE_ID_SIZE
Device/node addresses are 3 bytes (e.g., "123ABC").
static constexpr uint16_t ONEWAY_SEQUENCE_REBOOT_HEADROOM
How many consecutive unclean reboots the stride must survive while staying inside a device's acceptan...
static constexpr uint16_t ONEWAY_SEQUENCE_ACCEPTANCE_WINDOW
How far ahead of its stored high-water mark a device will still accept a jump.
static constexpr uint16_t ONEWAY_SEQUENCE_STRIDE
How many sequences one flash write reserves.
Fundamental IO-Homecontrol frame and crypto size constants.