|
AlteriomPainlessMesh v2.1.1
Easy ESP32/ESP8266 mesh networking with Alteriom IoT extensions
|
SentBuffer stores messages (strings) and allows them to be read in any length with priority-based scheduling. More...
#include <buffer.hpp>
Classes | |
| struct | SendStats |
Public Member Functions | |
| SentBuffer () | |
| bool | push (const T &message, bool priority=false) |
| bool | pushWithPriority (const T &message, uint8_t priorityLevel) |
| size_t | requestLength (size_t buffer_length) |
| void | read (size_t length, temp_buffer_t &buf) |
| const char * | readPtr (size_t length) |
| void | freeRead () |
| bool | empty () |
| void | clear () |
| size_t | size () |
| uint8_t | getLastReadPriority () const |
| SendStats | getStats () const |
SentBuffer stores messages (strings) and allows them to be read in any length with priority-based scheduling.
|
inline |
|
inline |
|
inline |
|
inline |
Clear the previously read messages from the buffer.
Should be called after a call of read() to clear the buffer.
|
inline |
Get priority of the last read message
|
inline |
|
inline |
push a message into the buffer with multi-level priority support.
| message | The message to queue |
| priority | Whether this is a high priority message (legacy bool API) |
Legacy API: High priority messages (true) will be sent to the front of the buffer This maintains backward compatibility with existing code.
|
inline |
push a message with explicit priority level (0-3)
| message | The message to queue |
| priorityLevel | Priority level: 0=CRITICAL, 1=HIGH, 2=NORMAL, 3=LOW |
Messages are scheduled in priority order. Within same priority, FIFO order is maintained.
The buffer holds at most PAINLESSMESH_MAX_SENT_BUFFER_MESSAGES entries. At the cap, the newest message of a strictly lower priority class is evicted to make room (mirroring MessageQueue::makeSpace(): CRITICAL evicts HIGH/NORMAL/LOW, HIGH evicts NORMAL/LOW, NORMAL evicts LOW, LOW evicts nothing); when no lower-priority message exists the incoming message is rejected. Either way the drop is counted in getStats().dropped.
|
inline |
Read the given length into the passed buffer (copy mode)
Note the user should first make sure the requested length is available using SentBuffer.requestLength(), otherwise this function might fail. Note that if multiple messages are read then they are separated using '\0'.
Performance note: Consider using readPtr() for zero-copy access when possible.
|
inline |
Returns a pointer directly to the highest priority message
Note the user should first make sure the requested length is available using SentBuffer.requestLength(), otherwise this function might fail. Note that if multiple messages are read then they are separated using '\0'.
|
inline |
Request whether the passed length is readable
Returns the actual length available (<= the requested length
|
inline |