MeshNet  1.0.0
Public Member Functions | Data Fields | Protected Attributes
MeshFrame Struct Reference

#include <meshFrame.h>

Collaboration diagram for MeshFrame:
Collaboration graph
[legend]

Public Member Functions

 MeshFrame ()
 
 MeshFrame (const uint8_t *data, uint8_t dataSize)
 Fills frame fields from raw data. More...
 
 MeshFrame (const MeshFrame &mf)
 Copy constructor. More...
 
 MeshFrame (MeshFrame &&mf) noexcept
 Move constructor. More...
 
 ~MeshFrame ()
 Destructor. More...
 
MeshFrameoperator= (const MeshFrame &mf)
 Copy assignment operator. More...
 
MeshFrameoperator= (MeshFrame &&mf) noexcept
 Move assignment operator. More...
 
uint8_t Length () const
 Length of data. More...
 
uint8_t operator[] (uint8_t i) const
 
uint8_t & operator[] (uint8_t i)
 
bool HasError () const
 Checks if frame is not valid. More...
 
uint8_t GetRawLength () const
 Gets size of raw data length. More...
 
bool FromRaw (const uint8_t *data, uint8_t dataSize)
 Fills frame fields from raw data. More...
 
bool ToRaw (uint8_t *data, uint8_t &dataSize) const
 Converts structure to raw data. More...
 
uint8_t GetDataByteAt (uint8_t index) const
 Reads data byte at specified index. More...
 
bool SetDataByteAt (uint8_t index, uint8_t value)
 Sets data byte at specified index. More...
 
bool SetData (const uint8_t *data, const uint8_t dataLength)
 Sets data data. More...
 
void GetData (uint8_t *data, uint8_t &dataLength) const
 Gets data. More...
 
bool ResizeData (uint8_t size, bool doNotCopy=false)
 Resizes data. More...
 
void ClearData ()
 Clears frame data. More...
 
void Clear ()
 Clears all data in frame. More...
 
bool copyFrom (const MeshFrame &another)
 Copyies data from another frame to current frame. More...
 
void moveFrom (MeshFrame &another)
 Copyies data from another frame to current frame and clears data in another frame. More...
 
const uint8_t * d_ptr () const
 Pointer to data. More...
 
void operator= (const MeshFrameHeader &val)
 
 operator MeshFrameHeader () const
 
 operator MeshFrameHeader ()
 
bool IsSamePacket (const MeshFrameHeader &frameHeader) const
 Checks if two frames are from same packet. More...
 
bool IsSamePacket (const MeshFrame &frame) const
 Checks if two frames are from same packet. More...
 

Data Fields

MeshFrameHeader FrameHeader
 Frame header, that contains frame describing informations. More...
 

Protected Attributes

uint8_t DataSize = 0
 Size of frame data. More...
 
uint8_t * Data = NULL
 Frame data. More...
 

Constructor & Destructor Documentation

◆ MeshFrame() [1/4]

MeshFrame::MeshFrame ( )

◆ MeshFrame() [2/4]

MeshFrame::MeshFrame ( const uint8_t *  data,
uint8_t  dataSize 
)

Fills frame fields from raw data.

Parameters
[in]dataReceived data.
[in]dataSizeLength of received data in bytes.

◆ MeshFrame() [3/4]

MeshFrame::MeshFrame ( const MeshFrame mf)

Copy constructor.

◆ MeshFrame() [4/4]

MeshFrame::MeshFrame ( MeshFrame &&  mf)
noexcept

Move constructor.

◆ ~MeshFrame()

MeshFrame::~MeshFrame ( )

Destructor.

Member Function Documentation

◆ Clear()

void MeshFrame::Clear ( )

Clears all data in frame.

◆ ClearData()

void MeshFrame::ClearData ( )

Clears frame data.

◆ copyFrom()

bool MeshFrame::copyFrom ( const MeshFrame another)

Copyies data from another frame to current frame.

Parameters
anotherFrame to copy data from.
Returns
Returns true when copying was done correctly.

◆ d_ptr()

const uint8_t* MeshFrame::d_ptr ( ) const
inline

Pointer to data.

◆ FromRaw()

bool MeshFrame::FromRaw ( const uint8_t *  data,
uint8_t  dataSize 
)

Fills frame fields from raw data.

Parameters
[in]dataReceived data.
[in]dataSizeLength of received data in bytes.
Returns
Returns true when no error happened.

◆ GetData()

void MeshFrame::GetData ( uint8_t *  data,
uint8_t &  dataLength 
) const

Gets data.

Parameters
[out]dataData output buffer.
[in/out]dataLength Set length of your buffer. After data copying this value will contain copyied payload length.

◆ GetDataByteAt()

uint8_t MeshFrame::GetDataByteAt ( uint8_t  index) const

Reads data byte at specified index.

Parameters
indexIndex, where to read payload byte.
Returns
Returns byte from data at specified index or 0 when index is outside of range.

◆ GetRawLength()

uint8_t MeshFrame::GetRawLength ( ) const
inline

Gets size of raw data length.

Returns
Returns size of raw data length in bytes.

◆ HasError()

bool MeshFrame::HasError ( ) const
inline

Checks if frame is not valid.

◆ IsSamePacket() [1/2]

bool MeshFrame::IsSamePacket ( const MeshFrame frame) const
inline

Checks if two frames are from same packet.

Parameters
frameAnother frame.
Returns
Returns true when both frames are from same packet.

◆ IsSamePacket() [2/2]

bool MeshFrame::IsSamePacket ( const MeshFrameHeader frameHeader) const
inline

Checks if two frames are from same packet.

Parameters
frameHeaderAnother frame header.
Returns
Returns true when both frames are from same packet.

◆ Length()

uint8_t MeshFrame::Length ( ) const
inline

Length of data.

◆ moveFrom()

void MeshFrame::moveFrom ( MeshFrame another)

Copyies data from another frame to current frame and clears data in another frame.

Note
This is more efficient than calling copyFrom.
Parameters
anotherFrame to move data from.
Returns
Returns true when moving was done correctly.

◆ operator MeshFrameHeader() [1/2]

MeshFrame::operator MeshFrameHeader ( )
inline

◆ operator MeshFrameHeader() [2/2]

MeshFrame::operator MeshFrameHeader ( ) const
inline

◆ operator=() [1/3]

MeshFrame & MeshFrame::operator= ( const MeshFrame mf)

Copy assignment operator.

◆ operator=() [2/3]

void MeshFrame::operator= ( const MeshFrameHeader val)
inline

◆ operator=() [3/3]

MeshFrame & MeshFrame::operator= ( MeshFrame &&  mf)
noexcept

Move assignment operator.

◆ operator[]() [1/2]

uint8_t& MeshFrame::operator[] ( uint8_t  i)
inline

◆ operator[]() [2/2]

uint8_t MeshFrame::operator[] ( uint8_t  i) const
inline

◆ ResizeData()

bool MeshFrame::ResizeData ( uint8_t  size,
bool  doNotCopy = false 
)

Resizes data.

Parameters
sizeNew size. Allowed value from 0 to MESH_FRAME_SIZE_LIMIT-8 or MESH_FRAME_SIZE_LIMIT-7 when frame is not carriage frame.
doNotCopyTrue to do not copy old data.
Returns
Returns true when resizing was sucessfull.

◆ SetData()

bool MeshFrame::SetData ( const uint8_t *  data,
const uint8_t  dataLength 
)

Sets data data.

Parameters
[in]dataNew data.
[in]dataLengthLength of new data.
Returns
Returns true when data was copyied.

◆ SetDataByteAt()

bool MeshFrame::SetDataByteAt ( uint8_t  index,
uint8_t  value 
)

Sets data byte at specified index.

Parameters
indexIndex, where to set data byte.
valueByte valeu to set.
Returns
Returns true when byte was set.

◆ ToRaw()

bool MeshFrame::ToRaw ( uint8_t *  data,
uint8_t &  dataSize 
) const

Converts structure to raw data.

Parameters
[out]dataOutput raw data buffer.
[in,out]dataSizeInput is reserved size of data buffer and output is contains raw data size.
Returns
Returns true when structure was converted to raw data or false when data buffer has not enough space.

Field Documentation

◆ Data

uint8_t* MeshFrame::Data = NULL
protected

Frame data.

◆ DataSize

uint8_t MeshFrame::DataSize = 0
protected

Size of frame data.

◆ FrameHeader

MeshFrameHeader MeshFrame::FrameHeader

Frame header, that contains frame describing informations.


The documentation for this struct was generated from the following files: