MeshNet
1.0.0
|
This class supports splitting MeshPacket to multiple MeshFrames in one carriage. MeshPackets are splitted, because they can contain larger payload than frame. Those frames can be then sent over radio to another receiver, which can build packet from those frames MeshPacketBuilder. More...
#include <meshPacketSplitter.h>
Public Member Functions | |
bool | SplitNew (const MeshPacket &packet, MeshMAC bssid, uint8_t maxFrameSize_) |
Starts splitting new packet to frames, this has to be called first before splitting. More... | |
bool | SplitNew (MeshPacket &&packet, MeshMAC bssid, uint8_t maxFrameSize_) |
Starts splitting new packet to frames, this has to be called first before splitting. More... | |
bool | SplitNewMove (MeshPacket &packet, MeshMAC bssid, uint8_t maxFrameSize_) |
Starts splitting new packet to frames, this has to be called first before splitting. More... | |
void | Restart (MeshMAC bssid, uint8_t maxFrameSize_) |
Restarts splitting with old packet, which is reused. More... | |
void | Restart (uint8_t maxFrameSize_) |
Restarts splitting with old packet, which is reused. More... | |
void | Restart (MeshMAC bssid) |
Restarts splitting with old packet, which is reused. More... | |
void | Restart () |
Restarts splitting with old packet, which is reused. Alternative name to this method is SeekToBegin(). More... | |
void | Clear () |
Clears and releases all rsources and stops splitting. More... | |
uint8_t | GetMaxFrameSize () const |
Gets maximum frame size, that was set in SplitNew(), SplitNewMove() or Restart() method. More... | |
uint8_t | GetLastCarriageFrameSize () const |
Gets size of frame, that will be at the end of carriage. All other frames has size same as GetMaxFrameSize(). When frame doesn't have to be splitted, size of that frame is returned. More... | |
uint8_t | GetFramesCount () const |
Gets count of frames into which the packet will be splitted. More... | |
uint8_t | GetRemainingFramesCount () const |
Gets count of remaining frames, that will be splitted. More... | |
uint8_t | GetCurrentFrameSize () const |
Gets size of the current frame, which will be splitted. More... | |
uint8_t | GetCurrentFrameDataSize () const |
Gets size of data part of the current frame, which will be splitted. More... | |
uint8_t | GetFrameSize (uint8_t index) const |
Gets size of frame at specific index. More... | |
uint8_t | GetFrameDataSize (uint8_t index) const |
Gets size of data part of frame at specific index. More... | |
uint8_t | GetCurrentFrameIndex () const |
Gets index of frame, that will be splitted. More... | |
bool | Seek (uint8_t frameIndex) |
Seeks (moves) to the frame set by index. This can be used, when same packet has to be retransmitted after calling SplitNextAsFrame(), SplitNextAsFrameHeaderAndData() or SplitNextAsFrameRawData(). More... | |
bool | SeekToNext () |
Seeks (moves) to the next frame. More... | |
bool | SeekToEnd () |
Seeks (moves) to the end, after last frame, that has to be splitted. More... | |
MeshFrame | SplitNextAsFrame () |
Splits current frame and moves to another. More... | |
bool | SplitNextAsFrameHeaderAndData (MeshFrameHeader &header, uint8_t *data, uint8_t &dataSize) |
Splits current frame and moves to another. More... | |
bool | SplitNextAsFrameRawData (uint8_t *rawData, uint8_t &dataSize) |
Splits current frame and moves to another. More... | |
MeshFrame | SplitCurrentAsFrame (bool moveToNext=false) |
Splits current frame and does not move to another. Same frame can be splitted multiple times using this method. More... | |
bool | SplitCurrentAsFrameHeaderAndData (MeshFrameHeader &header, uint8_t *data, uint8_t &dataSize, bool moveToNext=false) |
Splits current frame and does not move to another. Same frame can be splitted multiple times using this method. More... | |
bool | SplitCurrentAsFrameRawData (uint8_t *rawData, uint8_t &dataSize, bool moveToNext=false) |
Splits current frame and does not move to another. Same frame can be splitted multiple times using this method. More... | |
const MeshPacket & | GetSplittedPacket () const |
Gets packet, that is being splitted. More... | |
MeshPacket && | TakeSplittedPacket () |
Takes packet, that was splitted and calls clear method. More... | |
Protected Attributes | |
MeshPacket | sPacket |
MeshMAC | lastBSSID |
MeshFrameHeader | lastHeader |
uint8_t | carriageFrameCount = 0 |
uint8_t | lastCarriageFrameDataSize = 0 |
uint8_t | maxFrameSize = 32 |
uint8_t | splitDataPos = 0 |
uint8_t | remainingCarriageCount = 0 |
This class supports splitting MeshPacket to multiple MeshFrames in one carriage. MeshPackets are splitted, because they can contain larger payload than frame. Those frames can be then sent over radio to another receiver, which can build packet from those frames MeshPacketBuilder.
Carriage is set of frames which was splitted. The first frame in carriage is called header frame or head frame. It contains all packet header fields and part of data. Other frames are called only carriage frames, they contains only necessary frame header fields to identify frame and another part of data. Every carriage contains count of remaining frames. This is field called CarriageCount. Those carriage frames has to be sorted by CarriageCount.
Table bellow shows the worst case performance, when packet with 512 bytes of data need to be sent. In the first column is maximum size of frame (maxFrameSize parameter). In the second column is calculated summation of all bytes in all splitted frames including header bytes. In the last column is number of frames, the packet will be splitted to.
Max frame size [bytes] | Frame size summation [bytes] | Count of splitted frames |
---|---|---|
24 | 780 | 33 |
32 | 692 | 22 |
48 | 620 | 13 |
64 | 596 | 10 |
96 | 564 | 6 |
128 | 556 | 5 |
void MeshPacketSplitter::Clear | ( | ) |
Clears and releases all rsources and stops splitting.
uint8_t MeshPacketSplitter::GetCurrentFrameDataSize | ( | ) | const |
Gets size of data part of the current frame, which will be splitted.
|
inline |
Gets index of frame, that will be splitted.
uint8_t MeshPacketSplitter::GetCurrentFrameSize | ( | ) | const |
Gets size of the current frame, which will be splitted.
uint8_t MeshPacketSplitter::GetFrameDataSize | ( | uint8_t | index | ) | const |
Gets size of data part of frame at specific index.
index | Index of frame, which data part size needs to be get. |
|
inline |
Gets count of frames into which the packet will be splitted.
uint8_t MeshPacketSplitter::GetFrameSize | ( | uint8_t | index | ) | const |
Gets size of frame at specific index.
index | Index of frame, which size needs to be get. |
|
inline |
Gets size of frame, that will be at the end of carriage. All other frames has size same as GetMaxFrameSize(). When frame doesn't have to be splitted, size of that frame is returned.
|
inline |
Gets maximum frame size, that was set in SplitNew(), SplitNewMove() or Restart() method.
|
inline |
Gets count of remaining frames, that will be splitted.
|
inline |
Gets packet, that is being splitted.
void MeshPacketSplitter::Restart | ( | ) |
Restarts splitting with old packet, which is reused. Alternative name to this method is SeekToBegin().
void MeshPacketSplitter::Restart | ( | MeshMAC | bssid | ) |
Restarts splitting with old packet, which is reused.
bssid | New BSSID, that has to be set to each frame. |
void MeshPacketSplitter::Restart | ( | MeshMAC | bssid, |
uint8_t | maxFrameSize_ | ||
) |
Restarts splitting with old packet, which is reused.
bssid | New BSSID, that has to be set to each frame. |
maxFrameSize_ | New max frame size. |
void MeshPacketSplitter::Restart | ( | uint8_t | maxFrameSize_ | ) |
Restarts splitting with old packet, which is reused.
maxFrameSize_ | New max frame size. |
bool MeshPacketSplitter::Seek | ( | uint8_t | frameIndex | ) |
Seeks (moves) to the frame set by index. This can be used, when same packet has to be retransmitted after calling SplitNextAsFrame(), SplitNextAsFrameHeaderAndData() or SplitNextAsFrameRawData().
frameIndex | Index of frame, where to seek. |
bool MeshPacketSplitter::SeekToEnd | ( | ) |
Seeks (moves) to the end, after last frame, that has to be splitted.
bool MeshPacketSplitter::SeekToNext | ( | ) |
Seeks (moves) to the next frame.
MeshFrame MeshPacketSplitter::SplitCurrentAsFrame | ( | bool | moveToNext = false | ) |
Splits current frame and does not move to another. Same frame can be splitted multiple times using this method.
moveToNext | True when splitter has to move to another frame after splitting. When you want to use it, it is recommended to use moveToNext() method. |
bool MeshPacketSplitter::SplitCurrentAsFrameHeaderAndData | ( | MeshFrameHeader & | header, |
uint8_t * | data, | ||
uint8_t & | dataSize, | ||
bool | moveToNext = false |
||
) |
Splits current frame and does not move to another. Same frame can be splitted multiple times using this method.
[out] | header | Header of frame, that was splitted. |
[out] | data | Buffer reserved for data from splitted frame. Size of this buffer has to be minimally same as GetCurrentFrameDataSize() value. |
[out] | dataSize | The size of data copyied to data buffer. This value is not checked when copying to data buffer, that why you has to check it before calling this function using GetCurrentFrameDataSize() method. |
moveToNext | True when splitter has to move to another frame after splitting. When you want to use it, it is recommended to use moveToNext() method. |
bool MeshPacketSplitter::SplitCurrentAsFrameRawData | ( | uint8_t * | rawData, |
uint8_t & | dataSize, | ||
bool | moveToNext = false |
||
) |
Splits current frame and does not move to another. Same frame can be splitted multiple times using this method.
[out] | header | Header of frame, that was splitted. |
[out] | rawData | Buffer reserved for data, from which the frame can be created. Size of this buffer has to be minimally same as GetMaxFrameSize() value. |
[out] | dataSize | The size of data copyied to data buffer. This value is not checked when copying to data buffer, that why you has to check it before calling this function using GetCurrentFrameSize() method. |
moveToNext | True when splitter has to move to another frame after splitting. When you want to use it, it is recommended to use moveToNext() method. |
bool MeshPacketSplitter::SplitNew | ( | const MeshPacket & | packet, |
MeshMAC | bssid, | ||
uint8_t | maxFrameSize_ | ||
) |
Starts splitting new packet to frames, this has to be called first before splitting.
packet | Packet, that has to be splitted. This packed is copyied. |
bssid | BSSID, that has to be inserted to each frame header. |
maxFrameSize_ | Maximum size of frames. Can be set from MESH_FRAME_SIZE_MIN_LIMIT to MESH_FRAME_SIZE_LIMIT. |
bool MeshPacketSplitter::SplitNew | ( | MeshPacket && | packet, |
MeshMAC | bssid, | ||
uint8_t | maxFrameSize_ | ||
) |
Starts splitting new packet to frames, this has to be called first before splitting.
packet | Packet, that has to be splitted. This packed is moved, to class memory. |
bssid | BSSID, that has to be inserted to each frame header. |
maxFrameSize_ | Maximum size of frames. Can be set from MESH_FRAME_SIZE_MIN_LIMIT to MESH_FRAME_SIZE_LIMIT. |
bool MeshPacketSplitter::SplitNewMove | ( | MeshPacket & | packet, |
MeshMAC | bssid, | ||
uint8_t | maxFrameSize_ | ||
) |
Starts splitting new packet to frames, this has to be called first before splitting.
packet | Packet, that has to be splitted. This packed is moved, to class memory. |
bssid | BSSID, that has to be inserted to each frame header. |
maxFrameSize_ | Maximum size of frames. Can be set from MESH_FRAME_SIZE_MIN_LIMIT to MESH_FRAME_SIZE_LIMIT. |
|
inline |
Splits current frame and moves to another.
|
inline |
Splits current frame and moves to another.
[out] | header | Header of frame, that was splitted. |
[out] | data | Buffer reserved for data from splitted frame. Size of this buffer has to be minimally same as GetCurrentFrameDataSize() value. |
[out] | dataSize | The size of data copyied to data buffer. This value is not checked when copying to data buffer, that why you has to check it before calling this function using GetCurrentFrameDataSize() method. |
|
inline |
Splits current frame and moves to another.
[out] | header | Header of frame, that was splitted. |
[out] | rawData | Buffer reserved for data, from which the frame can be created. Size of this buffer has to be minimally same as GetMaxFrameSize() value. |
[out] | dataSize | The size of data copyied to data buffer. This value is not checked when copying to data buffer, that why you has to check it before calling this function using GetCurrentFrameSize() method. |
MeshPacket && MeshPacketSplitter::TakeSplittedPacket | ( | ) |
Takes packet, that was splitted and calls clear method.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |