|
Home IO Control
ESPHome add-on for IO-Homecontrol devices
|
Per-device periodic limitation-read schedule and miss counter. More...
#include <rain_poll_policy.h>
Public Member Functions | |
| void | set_interval (const std::string &device_id, uint32_t interval_ms, uint32_t now, uint32_t random) |
Set the poll interval and schedule the first poll at rain_poll_first_delay_ms(random) after now. | |
| uint32_t | get_interval (const std::string &device_id) const |
| Return the configured interval (0 when the device is not scheduled). | |
| bool | has_due (uint32_t now) const |
True when any device's poll is due at now. | |
| std::optional< std::string > | pop_due_device (uint32_t now, uint32_t random) |
Return one device whose poll is due and immediately schedule its next poll at rain_poll_jittered_interval_ms() after now, so a poll that is later dropped from the operation queue (pairing flushes background work) is skipped rather than lost forever. | |
| void | defer (const std::string &device_id, uint32_t delay_ms, uint32_t now) |
Pull the device's next poll forward to delay_ms after now. Never pushes it later. | |
| bool | on_poll_failed (const std::string &device_id) |
| Count one unanswered poll (saturating). | |
| void | on_poll_succeeded (const std::string &device_id) |
| Clear the unanswered-poll count. | |
| bool | first_error_reply (const std::string &device_id) |
| True the first time it is called for a device that answered the limitation read with an error reply, false afterwards, so the log names that once instead of every poll. | |
| uint8_t | get_failures (const std::string &device_id) const |
| Consecutive unanswered polls (0 for an unscheduled device). | |
| uint32_t | get_next_poll (const std::string &device_id) const |
| Absolute millis() time of the device's next poll (0 for an unscheduled device). | |
Per-device periodic limitation-read schedule and miss counter.
Definition at line 61 of file rain_poll_policy.h.
| void esphome::home_io_control::RainPollPolicy::defer | ( | const std::string & | device_id, |
| uint32_t | delay_ms, | ||
| uint32_t | now ) |
Pull the device's next poll forward to delay_ms after now. Never pushes it later.
Definition at line 50 of file rain_poll_policy.cpp.
|
nodiscard |
True the first time it is called for a device that answered the limitation read with an error reply, false afterwards, so the log names that once instead of every poll.
Definition at line 74 of file rain_poll_policy.cpp.
|
nodiscard |
Consecutive unanswered polls (0 for an unscheduled device).
Definition at line 82 of file rain_poll_policy.cpp.
|
nodiscard |
Return the configured interval (0 when the device is not scheduled).
Definition at line 30 of file rain_poll_policy.cpp.
|
nodiscard |
Absolute millis() time of the device's next poll (0 for an unscheduled device).
Definition at line 87 of file rain_poll_policy.cpp.
|
nodiscard |
True when any device's poll is due at now.
Lets the caller draw a random number only when pop_due_device() will use it.
Definition at line 35 of file rain_poll_policy.cpp.
| bool esphome::home_io_control::RainPollPolicy::on_poll_failed | ( | const std::string & | device_id | ) |
Count one unanswered poll (saturating).
Definition at line 59 of file rain_poll_policy.cpp.
| void esphome::home_io_control::RainPollPolicy::on_poll_succeeded | ( | const std::string & | device_id | ) |
Clear the unanswered-poll count.
Definition at line 68 of file rain_poll_policy.cpp.
|
nodiscard |
Return one device whose poll is due and immediately schedule its next poll at rain_poll_jittered_interval_ms() after now, so a poll that is later dropped from the operation queue (pairing flushes background work) is skipped rather than lost forever.
Returns nullopt when nothing is due. Comparison is wrap-safe across the 32-bit millis() rollover.
Definition at line 40 of file rain_poll_policy.cpp.
| void esphome::home_io_control::RainPollPolicy::set_interval | ( | const std::string & | device_id, |
| uint32_t | interval_ms, | ||
| uint32_t | now, | ||
| uint32_t | random ) |
Set the poll interval and schedule the first poll at rain_poll_first_delay_ms(random) after now.
0 removes the device from the schedule.
Definition at line 19 of file rain_poll_policy.cpp.