Go to the documentation of this file.
12 #ifndef MESH_PACKET_BUILDER_H
13 #define MESH_PACKET_BUILDER_H
185 FrameRecv_func = callback;
204 PacketCheck_func = callback;
227 return predictedMinPacketDataLength;
236 return predictedMinPacketDataLength - 1 + headerFrameSize;
322 return LastPacket.PacketHeader;
330 return LastPacket.PacketHeader.FrameControl;
373 return lastReceiveTime;
386 uint32_t lastReceiveTime = 0;
388 uint16_t predictedMinPacketDataLength = 0;
389 uint8_t maxFrameSize = 32;
390 uint8_t headerFrameSize = 0;
391 uint16_t receivedPayloadCount = 0;
392 uint8_t remainingCarriages = 0;
395 uint8_t carriageCount = 0;
401 int16_t RSSI_sum = 0;
408 void discardLastPacket();
411 inline uint32_t millis();
449 #endif // !MESH_PACKET_BUILDER_H
@ MPB_FullPacketOK
Definition: meshPacketBuilder.h:29
MeshMAC GetLastPacketBSSID() const
Gets BSSID of last packet.
Definition: meshPacketBuilder.h:305
int8_t GetMinRSSI() const
Gets minimum RSSI of received packet's frames.
Definition: meshPacketBuilder.h:363
bool IsEmpty() const
Checks if any packet was built or being built or had an error at built.
Definition: meshPacketBuilder.h:243
@ MPB_FrameSizeExceededError
ERROR: Frame size exceeded and will be ignored. This may happened, when frame is larger then maximum ...
Definition: meshPacketBuilder.h:57
uint16_t GetPredictedMaxPacketDataLength() const
Gets maximum predicted packet data length in bytes of packet, that is currently being built.
Definition: meshPacketBuilder.h:235
Structure, that contains bit flags used for Frame Control in MeshPacket. Size of this structure is al...
Definition: meshPacketFlags.h:25
MeshPacketHeader PacketHeader
Packet header of received packet.
Definition: meshPacketBuilder.h:431
This class implements MeshNet protocol for microcontrollers.
Definition: mesh.h:104
Structure, which has data, that are needed for ACK packet creation.
Definition: meshPacketBuilder.h:420
@ MPB_AllocationError
FATAL ERROR: Cannot allocate space for pacet payload, whole packet will be discarded....
Definition: meshPacketBuilder.h:90
MeshPacketBuilderStatus GetStatus() const
Gets status of packet, that was built or is being built or had build error. Ignored frames are not re...
Definition: meshPacketBuilder.h:253
void SetMaxFrameSize(uint8_t size)
Sets maximum frame size. Defaultly set to 32.
Definition: meshPacketBuilder.cpp:263
void SetFrameReceivedCallback(void(*callback)(MeshPacketBuilder *, MeshPacketBuilderStatus, const MeshFrameHeader &, const uint8_t *, uint8_t, int8_t))
Sets callback function, that is called when valid frame is received. This function can be used to cal...
Definition: meshPacketBuilder.h:184
@ MPB_PayloadSizeExceededError
FATAL ERROR: Payload size exceeded and whole packet will be discarded. This may happened,...
Definition: meshPacketBuilder.h:85
typedef SPT_ERROR
Definition: meshPacket.h:33
bool PacketAvailable() const
Checks if packet was built. If yes, you can get it using method GetBuiltPacket().
Definition: meshPacketBuilder.h:267
@ MPB_SameFrameReceived
WARNING: Same frame from carriage was received multiple times. This may happened, when ACK was not re...
Definition: meshPacketBuilder.h:41
@ MPB_Ignored
Definition: meshPacketBuilder.h:33
Definition: meshFrame.h:126
This class can build packet from multiple frames. It is usually used to concatinate data from packet,...
Definition: meshPacketBuilder.h:126
This file contains class which can be used to handling mesh packets.
const MeshPacket & GetBuiltPacket() const
Gets packet, that was built.
Definition: meshPacketBuilder.h:282
uint8_t CarriageFramesCount() const
Count of all frames the packet was splitted at.
Definition: meshPacketBuilder.cpp:292
@ MPB_InvalidFrameError
ERROR: Invalid frame appended and will be ignored. This may happened, when frame was corrupted.
Definition: meshPacketBuilder.h:48
SystemPacketType Type
Type of received packet.
Definition: meshPacketBuilder.h:436
bool PacketIsBuilding() const
Checks if packet is building right now and is not already built.
Definition: meshPacketBuilder.h:260
SystemPacketType GetLastPacketSystemType() const
Gets system packet type of last packet. If packet is not system packet, SPT_ERROR is returned.
Definition: meshPacketBuilder.h:313
MeshPacketBuilderStatus
Mesh packet builder status.
Definition: meshPacketBuilder.h:23
MeshPacket & GetBuiltPacket()
Gets packet, that was built.
Definition: meshPacketBuilder.h:290
@ MPB_PartPacketOK
Definition: meshPacketBuilder.h:31
Class, that stores mesh packet with it's data. The size of this class can be slightly bigger then rea...
Definition: meshPacket.h:158
uint8_t GetMaxFrameSize() const
Gets maximum frame size.
Definition: meshPacketBuilder.h:217
@ MPB_None
Definition: meshPacketBuilder.h:25
MeshMAC BSSID
BSSID of received packet.
Definition: meshPacketBuilder.h:441
@ MPB_PacketIntegrityError
ERROR: Packet integrity check failed. Some frame from carriage was corupted.
Definition: meshPacketBuilder.h:97
MeshFrameControl GetLastPacketFrameControl() const
Gets frame control of last packet.
Definition: meshPacketBuilder.h:329
bool HasError() const
Checks if any error happened during packet building.
Definition: meshPacketBuilder.h:274
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
uint8_t remainingFrames
Count of remaining frames.
Definition: meshPacketBuilder.h:446
uint8_t ReceivedFramesCount() const
Gets count of received frames from current packet.
Definition: meshPacketBuilder.h:351
uint32_t GetAppendingEndTime() const
Gets time, when appending of last packet has ended. This can be used as time, when was last part of t...
Definition: meshPacketBuilder.h:372
void SetPacketCheckCallback(bool(*callback)(MeshPacketBuilder *, const MeshPacketHeader &, MeshMAC, SystemPacketType, const uint8_t *, uint8_t, int8_t))
Sets callback function, that is called when new packet is going to start build. This callback functio...
Definition: meshPacketBuilder.h:203
@ MPB_InvalidPacketError
ERROR: Invalid packet appended and packet will be ignored. This may happened, when system packet was ...
Definition: meshPacketBuilder.h:77
void Clear()
Clears all appended data and last packet.
Definition: meshPacketBuilder.cpp:234
MeshPacket && TakeBuiltPacket()
Takes packet, that was built and calls clear method.
Definition: meshPacketBuilder.cpp:271
MeshPacketHeader GetLastPacketHeader() const
Gets header of last packet.
Definition: meshPacketBuilder.h:321
MeshPacketBuilderStatus Append(const uint8_t *rawData, uint8_t rawDataSize, int8_t rssi)
Appends MeshFrame (that will be created from raw data) to packet builder.
Definition: meshPacketBuilder.cpp:3
typedef enum
Definition: meshPacket.h:20
uint8_t RemainingCarriageFramesCount() const
Count of remaining frames in carriage.
Definition: meshPacketBuilder.cpp:285
int8_t GetAverageRSSI() const
Gets average RSSI of received packet's frames.
Definition: meshPacketBuilder.cpp:299
uint16_t GetPredictedMinPacketDataLength() const
Gets minimum predicted packet data length in bytes of packet, that is currently being built.
Definition: meshPacketBuilder.h:226
@ MPB_FrameHeaderMissingError
ERROR: Appended frame from carriage, but frame header is missing. Frame will be ignored....
Definition: meshPacketBuilder.h:71
@ MPB_FrameOrderError
ERROR: Appended frame from carriage, that was not expected yet. Frame will be ignored....
Definition: meshPacketBuilder.h:63