|
AlteriomPainlessMesh v2.1.1
Easy ESP32/ESP8266 mesh networking with Alteriom IoT extensions
|
#include <ack.hpp>
Public Member Functions | |
| void | seed (uint32_t value) |
| uint32_t | nextMessageId () |
| bool | full () const |
| bool | track (uint32_t msgId, const std::list< uint32_t > &destinations, deliveryCallback_t callback, uint32_t timeoutMs, uint32_t now) |
| bool | handleAck (uint32_t msgId, uint32_t fromNode, uint32_t now) |
| bool | collectAck (uint32_t msgId, uint32_t fromNode, uint32_t now, std::list< DeliveryResult > &results) |
| size_t | expire (uint32_t now) |
| size_t | collectExpired (uint32_t now, std::list< DeliveryResult > &results) |
| size_t | pending () const |
| void | clear () |
Protected Attributes | |
| std::map< uint32_t, PendingAck > | entries |
| uint32_t | counter = 0 |
AckTracker - tracks outgoing messages awaiting acknowledgment
Time is passed in explicitly (millis() on device) so the tracker stays platform independent and unit testable. All time comparisons are uint32 wraparound safe.
|
inline |
Drop all pending messages without firing callbacks
|
inline |
Match an acknowledgment without invoking user code.
Mesh receive dispatch uses this form so callbacks can be scheduled after the connection read task has unwound. Tracker state is still updated synchronously and exactly once.
|
inline |
Collect timeout results without invoking user callbacks
Mesh uses this form to defer callbacks until receive dispatch has unwound. Direct AckTracker users retain the synchronous expire() API.
|
inline |
Fire timeout callbacks for expired messages
| now | Current time (millis()) |
|
inline |
Whether the tracker is at its pending-message limit
|
inline |
Process an incoming acknowledgment
Fires the callback with delivered = true and the measured latency.
|
inline |
Generate the next unique, non-zero message id
|
inline |
Number of messages awaiting acknowledgment
|
inline |
Seed the message-id counter
Called once at mesh init with a random value so ids do not restart at 1 after a reboot — a delayed ACK for a pre-reboot message could otherwise match a fresh message's id and report a false delivered = true.
|
inline |
Start tracking a message
| msgId | Unique id from nextMessageId() |
| destinations | Nodes expected to acknowledge |
| callback | Fired once per destination (ack or timeout) |
| timeoutMs | Time to wait for acknowledgments |
| now | Current time (millis()) |
|
protected |
|
protected |