MeshNet
1.0.0
|
Optimized FIFO buffer for microcontrolers, that can store only MeshPacket structure. This class contains 2 FIFO buffers, first for high priority (routed packet), second for low priority (flood packet). Size of each inner FIFO can be specified in template. Template parameters are: More...
#include <meshBuffers.h>
Public Member Functions | |
const MeshPacket & | front () const |
Gets the first (oldest with the highest priority) item from the buffer. More... | |
MeshPacket & | front () |
Gets the first (oldest with the highest priority) item from the buffer. More... | |
const MeshPacket & | back () const |
Gets the last (newest with the lowest priority) item from the buffer. More... | |
MeshPacket & | back () |
Gets the last (newest with the lowest priority) item from the buffer. More... | |
bool | get (MeshPacket &item, uint8_t index) const |
Gets item from the buffer by index. More... | |
const MeshPacket & | operator[] (int index) const |
Gets item from the buffer by index. More... | |
MeshPacket & | operator[] (int index) |
Gets item from the buffer by index. More... | |
void | push (MeshPacket const &item) |
Pushes item after last item in buffer. When buffer is full, first (oldest with the highest priority) item will be overwritten and lostItemsCount() will be incremented by 1. More... | |
void | push (MeshPacket &&item) |
Pushes item after last item in buffer. When buffer is full, first (oldest with the highest priority) item will be overwritten and lostItemsCount() will be incremented by 1. More... | |
MeshPacket && | popMove () |
Reads and removes first (oldest with the highest priority) item from the buffer. When buffer is empty, exception may be thrown. More... | |
bool | pop () |
Removes first (oldest with the highest priority) item from the buffer. More... | |
bool | removeAt (uint8_t index) |
Removes item at specified index. After removing, count() will return new value. More... | |
uint8_t | removeMulti (uint8_t startPos, uint8_t itmCount) |
Removes number of item from specified index. After removing, count() will return new value. More... | |
uint8_t | removeIf (bool(*dec)(const MeshPacket &)) |
Removes specified items. More... | |
uint8_t | removeByDestination (uint8_t destination) |
Removes all packets with specified destination. More... | |
bool | existsID (uint8_t ID, uint8_t source) const |
Checks if there is packet in buffer with specified ID and source address, which creates unique packet identifier. More... | |
int16_t | getIndexOfPacket (uint8_t ID, uint8_t source) const |
Gets index of packet from unique packet identifier, which consists from ID and packet source address. More... | |
bool | empty () const |
Checks if buffer is empty. More... | |
uint8_t | count () const |
Gets how many items are stored in buffer. More... | |
uint8_t | highCount () const |
Gets how many items are stored in high priority buffer. More... | |
uint8_t | lowCount () const |
Gets how many items are stored in low priority buffer. More... | |
uint8_t | size () const |
Gets maximum count of items, that can be stored in buffer. More... | |
uint8_t | highSize () const |
Gets maximum count of items, that can be stored in high priority buffer. More... | |
uint8_t | lowSize () const |
Gets maximum count of items, that can be stored in low priority buffer. More... | |
uint8_t | lostItemsCount () const |
void | restartLostItemsCounter () |
Restarts lostItemsCount counter. More... | |
void | clear () |
Clears whole buffer. More... | |
MeshPacketFIFO< ROUTE_BufferSize > & | highFIFO () |
Gets reference to high priority FIFO. More... | |
const MeshPacketFIFO< ROUTE_BufferSize > & | highFIFO () const |
Gets reference to high priority FIFO. More... | |
MeshPacketFIFO< ROUTE_BufferSize > & | lowFIFO () |
Gets reference to low priority FIFO. More... | |
const MeshPacketFIFO< ROUTE_BufferSize > & | lowFIFO () const |
Gets reference to low priority FIFO. More... | |
size_t | getRawDataSize () const |
Calculates, how many bytes will be printed, when using command printRaw. More... | |
virtual size_t | printRaw (OSTREAM &stream, const char *customTag) |
Prints raw FIFO data through stream. Those data can be decoded in PC or in another MCU. More... | |
virtual size_t | print (OSTREAM &stream, bool showIndexes=true) const |
Prints items as table from FIFO buffer to stream. More... | |
virtual size_t | sizeOf () const |
Gets size of the whole FIFO in bytes. More... | |
size_t | printTo (Print &p) const override |
Makes this class printable. More... | |
Protected Attributes | |
MeshPacketFIFO< ROUTE_BufferSize > | routeBuffer |
MeshPacketFIFO< FLOOD_BufferSize > | floodBuffer |
Optimized FIFO buffer for microcontrolers, that can store only MeshPacket structure. This class contains 2 FIFO buffers, first for high priority (routed packet), second for low priority (flood packet). Size of each inner FIFO can be specified in template. Template parameters are:
index (not physically stored) | MeshPacket |
---|---|
0 | XXX |
1 | XXX |
... | ... |
XXX - depends on BufferSize | XXX |
|
inline |
Gets the last (newest with the lowest priority) item from the buffer.
|
inline |
Gets the last (newest with the lowest priority) item from the buffer.
|
inline |
Clears whole buffer.
|
inline |
Gets how many items are stored in buffer.
|
inline |
Checks if buffer is empty.
|
inline |
Checks if there is packet in buffer with specified ID and source address, which creates unique packet identifier.
ID | ID of packet to check if exists. |
source | Source address of packet. |
|
inline |
Gets the first (oldest with the highest priority) item from the buffer.
|
inline |
Gets the first (oldest with the highest priority) item from the buffer.
|
inline |
Gets item from the buffer by index.
item | Reference to item, that will be filled by data from buffer. |
index | Index of item to get. Index 0 is the first (oldest with highest priority) item from the buffer, same as using front() method. |
|
inline |
Gets index of packet from unique packet identifier, which consists from ID and packet source address.
ID | Packet ID to look for. |
source | Packet source address to look for. |
|
inline |
Calculates, how many bytes will be printed, when using command printRaw.
|
inline |
Gets how many items are stored in high priority buffer.
|
inline |
Gets reference to high priority FIFO.
|
inline |
Gets reference to high priority FIFO.
|
inline |
Gets maximum count of items, that can be stored in high priority buffer.
|
inline |
@breif Gets how many items were lost (overwrote).
|
inline |
Gets how many items are stored in low priority buffer.
|
inline |
Gets reference to low priority FIFO.
|
inline |
Gets reference to low priority FIFO.
|
inline |
Gets maximum count of items, that can be stored in low priority buffer.
|
inline |
Gets item from the buffer by index.
index | Index of item to get. Index 0 is the first (oldest with highest priority) item from the buffer, same as using front() method. |
|
inline |
Gets item from the buffer by index.
index | Index of item to get. Index 0 is the first (oldest with highest priority) item from the buffer, same as using front() method. |
|
inline |
|
inline |
Reads and removes first (oldest with the highest priority) item from the buffer. When buffer is empty, exception may be thrown.
|
inlinevirtual |
Prints items as table from FIFO buffer to stream.
stream | Stream, where data will be printed. |
showIndexes | True to show indexes of items in printed table. |
|
inlinevirtual |
Prints raw FIFO data through stream. Those data can be decoded in PC or in another MCU.
Byte | Data | Data name |
---|---|---|
0-3 | "MFF:" | Data label (Micro FIFO). |
4-7 | Custom tag | |
7 | Allocated buffer size (Max number of rows). | |
8 | Size of one row in bytes. (255 = unknown, size of each row has to be stored at the begining of row data) | |
9 | Used rows count (length and CRC bytes not included). | |
10.....x | Raw data | |
last 4 bytes | CRC-32 (excluded 0-3 bytes) |
stream | Stream where to print raw data. |
customTag | Custom data type tag. Maximum length is 4 characters. |
|
inlineoverride |
Makes this class printable.
p | Stream, where to print data. |
|
inline |
Pushes item after last item in buffer. When buffer is full, first (oldest with the highest priority) item will be overwritten and lostItemsCount() will be incremented by 1.
item | Item to push into buffer. |
|
inline |
Pushes item after last item in buffer. When buffer is full, first (oldest with the highest priority) item will be overwritten and lostItemsCount() will be incremented by 1.
item | Item to push into buffer. |
|
inline |
Removes item at specified index. After removing, count() will return new value.
Some optimizations are done here to reduce remove time.
index | Index of item to remove. |
|
inline |
Removes all packets with specified destination.
Some optimizations are done here to reduce remove time.
destination | Packet, which has same destination will be removed. |
|
inline |
Removes specified items.
Some optimizations are done here to reduce remove time.
dec | Function, which returns true to remove item. |
|
inline |
Removes number of item from specified index. After removing, count() will return new value.
Some optimizations are done here to reduce remove time.
startPos | Index of first item to remove. |
itmCount | Count of items to remove (including first one). |
|
inline |
Restarts lostItemsCount counter.
|
inline |
Gets maximum count of items, that can be stored in buffer.
|
inlinevirtual |
Gets size of the whole FIFO in bytes.
|
protected |
|
protected |