77[[nodiscard]]
inline uint32_t
settle_delay_ms(uint32_t interval_ms, uint32_t hint_delay_ms,
bool cap_for_stop) {
79 if (hint_delay_ms != 0)
80 delay = std::min(delay, hint_delay_ms);
105 void set_interval(
const std::string &device_id, uint32_t interval_ms);
107 [[nodiscard]] uint32_t
get_interval(
const std::string &device_id)
const;
113 void begin_tracking(
const std::string &device_id, uint32_t initial_delay_ms, uint32_t now);
115 void clear(
const std::string &device_id);
120 [[nodiscard]] uint32_t
get_next_update(
const std::string &device_id)
const;
125 uint32_t
on_exchange_failed(
const std::string &device_id,
bool auth_like, uint32_t now);
134 [[nodiscard]]
bool is_tracking_active(
const std::string &device_id, uint32_t now)
const;
139 [[nodiscard]] std::optional<std::string>
pop_due_device(uint32_t now);
142 std::map<std::string, PollTracking> tracking_;
145 static uint32_t retry_delay_ms(uint8_t consecutive_failures,
bool auth_like);
Per-hub poll scheduling and failure-backoff policy.
void set_interval(const std::string &device_id, uint32_t interval_ms)
Set the configured follow-up poll interval (ms; 0 = legacy one-shot settle only).
bool is_tracking_active(const std::string &device_id, uint32_t now) const
True when the device has an active bounded polling window (deadline set and not expired).
uint32_t get_next_update(const std::string &device_id) const
uint32_t get_interval(const std::string &device_id) const
Return the configured interval (0 when not set or unconfigured).
void clear_failure_streaks(const std::string &device_id)
Reset failure streaks after a successful exchange response.
void set_next_update(const std::string &device_id, uint32_t abs_time)
Schedule the next poll at an absolute millis() timestamp.
uint32_t on_exchange_failed(const std::string &device_id, bool auth_like, uint32_t now)
Record a failed background poll; apply backoff or clear tracking if the window expired.
void begin_tracking(const std::string &device_id, uint32_t initial_delay_ms, uint32_t now)
Begin bounded follow-up polling after a command or remote activity.
uint8_t get_status_poll_failures(const std::string &device_id) const
uint8_t get_auth_poll_failures(const std::string &device_id) const
uint32_t get_poll_deadline(const std::string &device_id) const
void clear(const std::string &device_id)
Stop all polling for a device and reset failure counts. Preserves interval_ms.
std::optional< std::string > pop_due_device(uint32_t now)
Return and consume the first device whose next_update is overdue.
static constexpr uint32_t STATUS_RETRY_AFTER_FAIL_STEP4_MS
Fourth retry after a silent failure.
uint32_t settle_delay_ms(uint32_t interval_ms, uint32_t hint_delay_ms, bool cap_for_stop)
Resolve the follow-up settle-poll delay while a device may still be moving.
static constexpr uint32_t ONEWAY_QUIET_PERIOD_MS
Hold queued background polls back for this long after any 1W frame, so a poll the hub itself schedule...
static constexpr uint32_t STATUS_AUTH_RETRY_AFTER_FAIL_MAX_MS
Steady-state after repeated auth failures.
static constexpr uint32_t ONEWAY_POLL_DEFER_CAP_MS
Hard cap on how long sustained 1W traffic may hold a background poll back in total,...
static constexpr uint32_t DEFAULT_SETTLE_POLL_DELAY_MS
Default follow-up settle-poll delay used while a device may still be moving, when no explicit poll in...
static constexpr uint32_t REMOTE_ACTIVITY_STATUS_POLL_DELAY_MS
Delay before polling after overheard remote traffic.
static constexpr uint32_t STATUS_RETRY_AFTER_FAIL_STEP3_MS
Third retry after a silent failure.
static constexpr uint32_t MAX_TRACKED_STATUS_POLL_WINDOW_MS
Hard stop for bounded follow-up polling after a command or remote activity.
static constexpr uint32_t STATUS_RETRY_AFTER_FAIL_MS
First retry after a silent failure.
static constexpr uint32_t STATUS_RETRY_AFTER_FAIL_MAX_MS
Steady-state backoff after many silent failures.
static constexpr uint32_t INITIAL_STATUS_REQUEST_DELAY_MS
Delay before the first post-boot status request from an entity.
static constexpr uint32_t STATUS_AUTH_RETRY_AFTER_FAIL_STEP2_MS
Second retry.
static constexpr uint32_t STATUS_AUTH_RETRY_AFTER_FAIL_MS
First retry after a challenge-seen failure.
static constexpr uint32_t STOP_SETTLE_POLL_CAP_MS
Upper bound on the settle-poll delay after a STOP command.
static constexpr uint32_t STATUS_RETRY_AFTER_FAIL_STEP2_MS
Second retry after a silent failure.
Per-device poll scheduling state.
uint8_t auth_poll_failures
Consecutive background poll failures that saw a 0x3C challenge.
uint8_t status_poll_failures
Consecutive background poll failures (silent — no reply).
uint32_t poll_deadline
Hard stop for bounded follow-up polling.
uint32_t interval_ms
Configured follow-up poll interval (0 = no configured cadence; delays fall back to device hint / defa...
uint32_t next_update
Absolute millis() timestamp for the next poll; 0 = idle.