MeshNet  1.0.0
meshPacketSplitter.h
Go to the documentation of this file.
1 
11 #ifndef MESH_PACKET_SPLITTER_H
12 #define MESH_PACKET_SPLITTER_H
13 
14 #include "meshPacket.h"
15 
51 public:
52 
61  bool SplitNew(const MeshPacket& packet, MeshMAC bssid, uint8_t maxFrameSize_);
62 
72  bool SplitNew(MeshPacket&& packet, MeshMAC bssid, uint8_t maxFrameSize_);
73 
83  bool SplitNewMove(MeshPacket& packet, MeshMAC bssid, uint8_t maxFrameSize_);
84 
90  void Restart(MeshMAC bssid, uint8_t maxFrameSize_);
91 
96  void Restart(uint8_t maxFrameSize_);
97 
102  void Restart(MeshMAC bssid);
103 
107  void Restart();
108 
112  void Clear();
113 
117  inline uint8_t GetMaxFrameSize() const {
118  return maxFrameSize;
119  }
120 
125  inline uint8_t GetLastCarriageFrameSize() const {
127  }
128 
134  inline uint8_t GetFramesCount() const {
135  return carriageFrameCount;
136  }
137 
143  inline uint8_t GetRemainingFramesCount() const {
144  return remainingCarriageCount;
145  }
146 
150  uint8_t GetCurrentFrameSize() const;
151 
155  uint8_t GetCurrentFrameDataSize() const;
156 
161  uint8_t GetFrameSize(uint8_t index) const;
166  uint8_t GetFrameDataSize(uint8_t index) const;
167 
173  inline uint8_t GetCurrentFrameIndex() const{
175  }
176 
183  bool Seek(uint8_t frameIndex);
184 
189  bool SeekToNext();
190 
195  bool SeekToEnd();
196 
203  return SplitCurrentAsFrame(true);
204  }
205 
215  inline bool SplitNextAsFrameHeaderAndData(MeshFrameHeader& header, uint8_t* data, uint8_t& dataSize) {
216  return SplitCurrentAsFrameHeaderAndData(header, data, dataSize, true);
217  }
218 
228  inline bool SplitNextAsFrameRawData(uint8_t* rawData, uint8_t& dataSize) {
229  return SplitCurrentAsFrameRawData(rawData, dataSize, true);
230  }
231 
232 
240  MeshFrame SplitCurrentAsFrame(bool moveToNext = false);
241 
253  bool SplitCurrentAsFrameHeaderAndData(MeshFrameHeader& header, uint8_t* data, uint8_t& dataSize, bool moveToNext = false);
254 
266  bool SplitCurrentAsFrameRawData(uint8_t* rawData, uint8_t& dataSize, bool moveToNext = false);
267 
272  inline const MeshPacket& GetSplittedPacket() const {
273  return sPacket;
274  }
275 
282 
283 
284 protected:
285 
289  uint8_t carriageFrameCount = 0;
291  uint8_t maxFrameSize = 32;
292  uint8_t splitDataPos = 0;
294 
295 };
296 
297 #endif // !MESH_PACKET_SPLITTER_H
MeshPacketSplitter::SeekToEnd
bool SeekToEnd()
Seeks (moves) to the end, after last frame, that has to be splitted.
Definition: meshPacketSplitter.cpp:165
MeshPacketSplitter::SplitNew
bool SplitNew(const MeshPacket &packet, MeshMAC bssid, uint8_t maxFrameSize_)
Starts splitting new packet to frames, this has to be called first before splitting.
Definition: meshPacketSplitter.cpp:3
MeshPacketSplitter::splitDataPos
uint8_t splitDataPos
Definition: meshPacketSplitter.h:292
MeshPacketSplitter::GetFrameSize
uint8_t GetFrameSize(uint8_t index) const
Gets size of frame at specific index.
Definition: meshPacketSplitter.cpp:113
MeshPacketSplitter::lastHeader
MeshFrameHeader lastHeader
Definition: meshPacketSplitter.h:288
MeshPacketSplitter::GetCurrentFrameIndex
uint8_t GetCurrentFrameIndex() const
Gets index of frame, that will be splitted.
Definition: meshPacketSplitter.h:173
MeshPacketSplitter::Restart
void Restart()
Restarts splitting with old packet, which is reused. Alternative name to this method is SeekToBegin()...
Definition: meshPacketSplitter.cpp:82
MeshPacketSplitter::SplitNextAsFrame
MeshFrame SplitNextAsFrame()
Splits current frame and moves to another.
Definition: meshPacketSplitter.h:202
MeshPacketSplitter::TakeSplittedPacket
MeshPacket && TakeSplittedPacket()
Takes packet, that was splitted and calls clear method.
Definition: meshPacketSplitter.cpp:302
MeshPacketSplitter::SplitCurrentAsFrameHeaderAndData
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 th...
Definition: meshPacketSplitter.cpp:185
MeshPacketSplitter::carriageFrameCount
uint8_t carriageFrameCount
Definition: meshPacketSplitter.h:289
MeshPacketSplitter::SplitNextAsFrameRawData
bool SplitNextAsFrameRawData(uint8_t *rawData, uint8_t &dataSize)
Splits current frame and moves to another.
Definition: meshPacketSplitter.h:228
MeshPacketSplitter::lastCarriageFrameDataSize
uint8_t lastCarriageFrameDataSize
Definition: meshPacketSplitter.h:290
MeshPacketSplitter
This class supports splitting MeshPacket to multiple MeshFrames in one carriage. MeshPackets are spli...
Definition: meshPacketSplitter.h:50
MeshPacketSplitter::SplitNextAsFrameHeaderAndData
bool SplitNextAsFrameHeaderAndData(MeshFrameHeader &header, uint8_t *data, uint8_t &dataSize)
Splits current frame and moves to another.
Definition: meshPacketSplitter.h:215
MeshFrame
Definition: meshFrame.h:126
meshPacket.h
This file contains class which can be used to handling mesh packets.
MeshPacketSplitter::lastBSSID
MeshMAC lastBSSID
Definition: meshPacketSplitter.h:287
MeshPacketSplitter::GetRemainingFramesCount
uint8_t GetRemainingFramesCount() const
Gets count of remaining frames, that will be splitted.
Definition: meshPacketSplitter.h:143
MeshPacket
Class, that stores mesh packet with it's data. The size of this class can be slightly bigger then rea...
Definition: meshPacket.h:158
MeshPacketSplitter::SplitNewMove
bool SplitNewMove(MeshPacket &packet, MeshMAC bssid, uint8_t maxFrameSize_)
Starts splitting new packet to frames, this has to be called first before splitting.
Definition: meshPacketSplitter.cpp:17
MeshPacketSplitter::sPacket
MeshPacket sPacket
Definition: meshPacketSplitter.h:286
MeshPacketSplitter::GetCurrentFrameDataSize
uint8_t GetCurrentFrameDataSize() const
Gets size of data part of the current frame, which will be splitted.
Definition: meshPacketSplitter.cpp:104
MeshPacketSplitter::GetCurrentFrameSize
uint8_t GetCurrentFrameSize() const
Gets size of the current frame, which will be splitted.
Definition: meshPacketSplitter.cpp:98
MeshPacketSplitter::Clear
void Clear()
Clears and releases all rsources and stops splitting.
Definition: meshPacketSplitter.cpp:87
MeshPacketSplitter::SplitCurrentAsFrameRawData
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 th...
Definition: meshPacketSplitter.cpp:237
MeshMAC
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
MeshPacketSplitter::maxFrameSize
uint8_t maxFrameSize
Definition: meshPacketSplitter.h:291
MeshPacketSplitter::GetLastCarriageFrameSize
uint8_t GetLastCarriageFrameSize() const
Gets size of frame, that will be at the end of carriage. All other frames has size same as GetMaxFram...
Definition: meshPacketSplitter.h:125
MeshPacketSplitter::SplitCurrentAsFrame
MeshFrame SplitCurrentAsFrame(bool moveToNext=false)
Splits current frame and does not move to another. Same frame can be splitted multiple times using th...
Definition: meshPacketSplitter.cpp:174
MeshPacketSplitter::GetFramesCount
uint8_t GetFramesCount() const
Gets count of frames into which the packet will be splitted.
Definition: meshPacketSplitter.h:134
MeshPacketSplitter::Seek
bool Seek(uint8_t frameIndex)
Seeks (moves) to the frame set by index. This can be used, when same packet has to be retransmitted a...
Definition: meshPacketSplitter.cpp:128
MeshPacketSplitter::remainingCarriageCount
uint8_t remainingCarriageCount
Definition: meshPacketSplitter.h:293
MeshPacketSplitter::SeekToNext
bool SeekToNext()
Seeks (moves) to the next frame.
Definition: meshPacketSplitter.cpp:147
MeshPacketSplitter::GetMaxFrameSize
uint8_t GetMaxFrameSize() const
Gets maximum frame size, that was set in SplitNew(), SplitNewMove() or Restart() method.
Definition: meshPacketSplitter.h:117
MeshPacketSplitter::GetFrameDataSize
uint8_t GetFrameDataSize(uint8_t index) const
Gets size of data part of frame at specific index.
Definition: meshPacketSplitter.cpp:119
MeshFrameHeader
Definition: meshFrame.h:20
MeshPacketSplitter::GetSplittedPacket
const MeshPacket & GetSplittedPacket() const
Gets packet, that is being splitted.
Definition: meshPacketSplitter.h:272