MeshNet
1.0.0
|
Class, that stores mesh packet with it's data. The size of this class can be slightly bigger then real packet size. Fields that increasing size are: More...
#include <meshPacket.h>
Public Member Functions | |
MeshPacket () | |
MeshPacket (const MeshPacket &mp) | |
Copy constructor. More... | |
MeshPacket (MeshPacket &&mp) noexcept | |
Move constructor. More... | |
~MeshPacket () | |
Destructor. More... | |
MeshPacket & | operator= (const MeshPacket &mp) |
Copy assignment operator. More... | |
MeshPacket & | operator= (MeshPacket &&mp) noexcept |
Move assignment operator. More... | |
uint16_t | Length () const |
Length of payload. More... | |
uint8_t | operator[] (uint16_t i) const |
uint8_t & | operator[] (uint16_t i) |
SystemPacketType | GetSystemPacketType () const |
Gets type of system packet. More... | |
uint8_t | GetPayloadByteAt (uint16_t index) const |
Reads payload byte at specified index. More... | |
virtual bool | SetPayloadByteAt (uint16_t index, uint8_t value) |
Sets payload byte at specified index. More... | |
virtual bool | SetPayload (const uint8_t *payload, const uint16_t payloadLength) |
Sets payload data. More... | |
bool | SetPayload (const MeshVariableArray< uint8_t > &va) |
Copyies payload data from variable array to current packet payload. More... | |
virtual bool | SetPayload (MeshVariableArray< uint8_t > &&va) |
Copyies payload data from variable array to current packet payload and clears data in that variable array. More... | |
void | GetPayload (uint8_t *payload, uint16_t &payloadLength) const |
Gets payload data. More... | |
bool | GetPayload (MeshVariableArray< uint8_t > &payload) const |
Copyies payload data. More... | |
MeshVariableArray< uint8_t > | TakePayload () |
Takes payload data. Payload will be cleared after this operation, because std::move was used. This method has a lot better performance than GetPayload() method, because there is no manual copying. More... | |
bool | ResizePayload (uint16_t size, bool doNotCopy=false) |
Resizes payload. More... | |
void | ClearPayload () |
Clears payload data. More... | |
virtual void | Clear () |
Clears all data in packet. More... | |
virtual bool | copyFrom (const MeshPacket &another) |
Copyies data from another packet to current packet. More... | |
virtual void | moveFrom (MeshPacket &another) |
Copyies data from another packet to current packet and clears data in another packet. More... | |
const uint8_t * | p_ptr () const |
Pointer to payload. More... | |
size_t | prettyPrint (OSTREAM &stream) const |
Pretty prints packet to stream. More... | |
size_t | printTo (Print &p) const override |
Makes this class printable. More... | |
size_t | printHeader (OSTREAM *stream) const override |
Prints header of table. More... | |
size_t | printLine (OSTREAM *stream) const override |
Prints this data as row to table. More... | |
size_t | sizeOf () const override |
Gets size of the whole class in bytes including dynamically allocated part. More... | |
size_t | printRaw (OSTREAM *stream, void(*CRC_calculation)(uint8_t *, size_t)) const override |
Prints current instance into stream in raw bytes. More... | |
virtual size_t | getRawSize () const override |
Calculates size of raw bytes. More... | |
virtual bool | HasError () const |
Checks if packet is not valid. More... | |
void | SetError () |
Sets that packet is not valid. More... | |
bool | GetError () const |
Checks if error is set by calling SetError() More... | |
void | ClearError () |
Sets that packet is valid. More... | |
Data Fields | |
MeshPacketHeader | PacketHeader |
Mesh packet header. More... | |
Static Protected Member Functions | |
static char | toHEXChar (OSTREAM &stream, uint8_t val) |
static size_t | printHex (OSTREAM &stream, uint8_t val) |
Protected Attributes | |
uint8_t * | Payload = NULL |
Packet payload. More... | |
uint16_t | PayloadLength: 10 |
Packet payload length. Maximum value can be 1023, because only 10 bits are used. More... | |
bool | error: 1 |
True when packet has error. More... | |
Class, that stores mesh packet with it's data. The size of this class can be slightly bigger then real packet size. Fields that increasing size are:
MeshPacket::MeshPacket | ( | ) |
MeshPacket::MeshPacket | ( | const MeshPacket & | mp | ) |
Copy constructor.
|
noexcept |
Move constructor.
MeshPacket::~MeshPacket | ( | ) |
Destructor.
|
virtual |
Clears all data in packet.
|
inline |
Sets that packet is valid.
void MeshPacket::ClearPayload | ( | ) |
Clears payload data.
|
virtual |
Copyies data from another packet to current packet.
another | Packet to copy data from. |
|
inline |
Checks if error is set by calling SetError()
|
inline |
Copyies payload data.
[out] | payload | Payload data. |
void MeshPacket::GetPayload | ( | uint8_t * | payload, |
uint16_t & | payloadLength | ||
) | const |
Gets payload data.
[out] | payload | Payload data |
[in/out] | payloadLength Set length of your buffer. After data copying this value will contain copyied payload length. |
uint8_t MeshPacket::GetPayloadByteAt | ( | uint16_t | index | ) | const |
Reads payload byte at specified index.
index | Index, where to read payload byte. |
|
overridevirtual |
SystemPacketType MeshPacket::GetSystemPacketType | ( | ) | const |
Gets type of system packet.
|
inlinevirtual |
Checks if packet is not valid.
|
inline |
Length of payload.
|
virtual |
Copyies data from another packet to current packet and clears data in another packet.
another | Packet to move data from. |
MeshPacket & MeshPacket::operator= | ( | const MeshPacket & | mp | ) |
Copy assignment operator.
|
noexcept |
Move assignment operator.
|
inline |
|
inline |
|
inline |
Pointer to payload.
size_t MeshPacket::prettyPrint | ( | OSTREAM & | stream | ) | const |
Pretty prints packet to stream.
stream | Stream, where packet will be printed. |
|
overridevirtual |
Prints header of table.
stream | Ponter to wtream, where header has to be print. |
Reimplemented from InlinePrintable.
|
staticprotected |
|
overridevirtual |
Prints this data as row to table.
stream | Ponter to wtream, where row has to be print. |
Reimplemented from InlinePrintable.
|
overridevirtual |
Prints current instance into stream in raw bytes.
CRC_calculation | Pointer to function, which provides CRC calculation, every sent byte has to be passed to this function. First parameter is pointer to data, that were printed and second is number of printed bytes. |
Reimplemented from RawPrintable.
|
override |
Makes this class printable.
p | Stream, where to print data. |
bool MeshPacket::ResizePayload | ( | uint16_t | size, |
bool | doNotCopy = false |
||
) |
Resizes payload.
size | New size. Allowed value from 0 to PAYLOAD_SIZE_LIMIT. |
doNotCopy | True to do not copy old data. |
|
inline |
Sets that packet is not valid.
|
inline |
Copyies payload data from variable array to current packet payload.
va | Variable array which data will be copyied. |
|
virtual |
Sets payload data.
[in] | payload | New payload data. |
[in] | payloadLength | Length of new data. |
|
virtual |
Copyies payload data from variable array to current packet payload and clears data in that variable array.
va | Variable array which data will be moved. |
|
virtual |
Sets payload byte at specified index.
index | Index, where to set payload byte. |
value | Byte valeu to set. |
|
inlineoverridevirtual |
Gets size of the whole class in bytes including dynamically allocated part.
Reimplemented from RawPrintable.
MeshVariableArray< uint8_t > MeshPacket::TakePayload | ( | ) |
Takes payload data. Payload will be cleared after this operation, because std::move was used. This method has a lot better performance than GetPayload() method, because there is no manual copying.
|
inlinestaticprotected |
|
protected |
True when packet has error.
MeshPacketHeader MeshPacket::PacketHeader |
Mesh packet header.
|
protected |
Packet payload.
|
protected |
Packet payload length. Maximum value can be 1023, because only 10 bits are used.