Mesh route table contains all known routes. Source address column value has to be unique. Size of table can be defined using template like this:
More...
|
| MeshRouteTable (const uint32_t rowLife) |
| Constructor. More...
|
|
bool | set (int16_t index, uint8_t source, uint8_t neighbor, uint8_t hop, int16_t valid=-1) |
| Sets row values in table. More...
|
|
int16_t | set (uint8_t source, uint8_t neighbor, uint8_t hop, int16_t valid=-1) |
| Sets row values in table. Row index is established using getIndexOfSource() method. If no row with specified source was found. New row is created in blank space. More...
|
|
int16_t | set (const MeshRouteTableRow &row, int16_t valid=-1) |
| Sets row values in table. Row index is established using getIndexOfSource() method. If no row with specified source was found. New row is created in blank space. More...
|
|
bool | add (uint8_t source, uint8_t neighbor, uint8_t hop) |
| Adds or overwrites data in row. This method works slightly different, because it implements part of mesh routing logic. More...
|
|
bool | add (const MeshRouteTableRow &val) |
| Adds or overwrites data in row. This method works slightly different as basic add method, because it implements part of mesh routing logic. If row with specified source exists and better metric is received, row is updated. If val is direct neighbor, row is always prolonged. If no valid row with specified source was found, new row is created. If table is full, oldset row which is not gateway will be overwritten. More...
|
|
void | operator+= (const MeshRouteTableRow &val) |
|
bool | removeBySource (uint8_t source) |
| Removes row, which contains specified source address. More...
|
|
int16_t | removeByNeighbor (uint8_t neighbor) |
| Removes all rows with specified neighbor address. More...
|
|
int16_t | removeByAddress (uint8_t address) |
| Removes all rows which contains specified address in "Source" or "Neighbor" field. More...
|
|
bool | isRowDirectNeighbor (int16_t index) const |
| Checks if row contains record of direct neighbor (source number and neighbor number are equal). More...
|
|
bool | sourceExists (uint8_t source) const |
| Checks if source node exists in table. More...
|
|
bool | neighborExists (uint8_t neighbor) const |
| Checks if neighbor node exists in table. More...
|
|
int16_t | getIndexOfSource (uint8_t source) const |
| Gets index of source address. More...
|
|
int16_t | getNeighborFromSource (int8_t source) const |
| Gets neighbor, which is connected (directly or indirectly) with source node. More...
|
|
uint8_t | getDirectNeighborCount () const |
| Gets number direct neighbors in buffer. More...
|
|
void | setNewCallback (void(*callback)(MeshRouteTable< BufferSize > *, int16_t, const MeshRouteTableRow &, uint8_t)) |
| Sets callback function, which is called when new record was inserted to table. This callback is not called if row value is set. More...
|
|
| MicroTable (const uint32_t rowLife) |
| Constructor. More...
|
|
const MeshRouteTableRow & | get (int16_t index) const |
| Gets row from table by index. More...
|
|
MeshRouteTableRow | get (int16_t index) |
| Gets row from table by index. More...
|
|
const MeshRouteTableRow & | operator[] (int16_t index) const |
| Gets row from table by index. More...
|
|
MeshRouteTableRow | operator[] (int16_t index) |
| Gets row from table by index. More...
|
|
bool | set (int16_t index, const MeshRouteTableRow &row) |
| Sets row values in table. Row life time is set to maximum. More...
|
|
bool | set (int16_t index, const MeshRouteTableRow &row, int16_t rawLifeTime_) |
| Sets row values in table. More...
|
|
bool | remove (const MeshRouteTableRow &rowRef) |
| Removes first row, which is equal to rowRef. More...
|
|
bool | remove (int16_t index) |
| Removes row at index. More...
|
|
void | clear () |
| Removes all rows data. More...
|
|
void | validate () |
| Decreases all valid column values in specified interval (row lifetime). If valid value is 0, row will not be longer valid. More...
|
|
bool | setRawRemainingLifeTime (int16_t index, uint8_t rawLifeTime_=255) |
| Sets row life time. Valid counter for this rowcan be changed, only when row is still valid. More...
|
|
virtual int16_t | getIndexOf (const MeshRouteTableRow &rowRef) const |
| Gets index of row which is equal to rowRef. More...
|
|
int16_t | getFirstBlankRowIndex (int16_t startPos=0) const |
| Gets index of first blank row. More...
|
|
int16_t | getOldestRowIndex () const |
| Gets index of first oldest row. More...
|
|
bool | exists (int16_t index) const |
| Checks if row at specified index exists in table. More...
|
|
bool | exists (const MeshRouteTableRow &rowRef) const |
| Checks if any row, which is equal to rowRef exists in table. More...
|
|
bool | isRowBlank (int16_t index) const |
| Checks if row is blank or not. Row, that is not valid is blank. More...
|
|
int16_t | size () const |
| Gets capacity of table in rows. More...
|
|
int16_t | count () const |
| Gets number of used rows in buffer. More...
|
|
uint8_t | getMaxRowLifeTime () const |
| Gets the maximum row life time in millisseconds. More...
|
|
int16_t | getRealUsedSize () const |
| Gets real used count of rows in table. This value is calculated like this: last_used_row_index + 1. More...
|
|
uint8_t | getFragmentation () const |
| Calculates fragmentation in %. Fragmentation is calculated like this: (getRealUsedSize() - count())/getRealUsedSize() More...
|
|
void | defragment () |
| Removes blank spaces between rows. Call this to speed up searching when buffer is fragmented. More...
|
|
uint32_t | getRowRemainingLifeTime (int16_t index) const |
| Gets selected row's remaining life time in milliseconds. More...
|
|
uint8_t | getRawRowRemainingLifeTime (int16_t index) const |
| Gets selected row's raw remaining life time. More...
|
|
uint32_t | getLifeTimeResolution () const |
| Gets life time resolution in milliseconds. More...
|
|
uint8_t | convertLifeTimeToRaw (uint32_t lifeTime) const |
| Converts life time in milliseconds to raw life time value. Value is rounded up. More...
|
|
uint32_t | convertRawToLifeTime (uint8_t rawLifeTime) const |
| Converts raw life time value to life time in milliseconds. Value is aproximate. To get accurate result, use getRowRemainingLifeTime() method. More...
|
|
virtual size_t | getRawDataSize () const |
| Calculates, how many bytes will be printed, when using command printRaw. More...
|
|
virtual size_t | printRaw (OSTREAM &stream, const char tableIdentifier[4]) const |
| Prints raw table data through stream. Those data can be decoded in PC or in another MCU. More...
|
|
size_t | print (OSTREAM &stream, bool showIndexes=true, bool doNotPrintBlank=true, bool showRemainingRowLifetime=true) const |
| Prints items from table to stream. More...
|
|
size_t | printTo (Print &p) const override |
| Makes this class printable. More...
|
|
|
void | onCreate (int16_t index, const MeshRouteTableRow &newValue, uint8_t newRawLifeTime) override |
| This method is called when valid row is set to blank space. It is called after count calculation is done, but before buffer is updated. More...
|
|
void | onRemove (int16_t index, const MeshRouteTableRow &oldValue, uint8_t oldRawLifeTime, bool removedByValidation=false) override |
| This method is called when valid row is set to new value. It is called after count calculation is done, but before buffer is updated. More...
|
|
void | onClear () override |
| This method is called when table is cleared. It is called after cleaning is done, so all variables are fresh. More...
|
|
int16_t | getOldestRowIndexNotGW () const |
| Gets index of first oldest row, except gateway nodes. More...
|
|
virtual void | onSet (int16_t index, const MeshRouteTableRow &oldValue, uint8_t oldRawLifeTime, const MeshRouteTableRow &newValue, uint8_t newRawLifeTime) |
| This method is called when valid row is set to new value. It is called after count calculation is done, but before buffer is updated. More...
|
|
virtual void | onRowLifeChanged (int16_t index, uint8_t old_raw, uint8_t new_raw) |
| This method is called when table is cleared. It is called after cleaning is done, so all variables are fresh. More...
|
|
template<int16_t BufferSize>
class MeshRouteTable< BufferSize >
Mesh route table contains all known routes. Source address column value has to be unique. Size of table can be defined using template like this:
Size of route table in example is 255 rows and lifetime of one row is 60 seconds.
How data are stored:
index (not physically stored) | Source [uint8_t] | Neighbor [uint8_t] | Hops [uint8_t] | Valid [uint8_t] |
0 | XXX | XXX | XXX | XXX |
1 | XXX | XXX | XXX | XXX |
... | ... | ... | ... | ... |
255 - depends on BufferSize | XXX | XXX | XXX | XXX |