MeshNet  1.0.0
meshPacketDecoders.h
Go to the documentation of this file.
1 
14 #ifndef MESH_PACKET_DECODERS_H
15 #define MESH_PACKET_DECODERS_H
16 
17 #include "meshPacket.h"
18 
23 class ACKPD {
24 public:
30  inline static bool IsSameType(const MeshPacket& packet) {
31  return packet.GetSystemPacketType() == Type;
32  }
33 
40  inline static bool IsValid(const MeshPacket& packet) {
41  return IsSameType(packet)
42  && (packet.Length() == 4 || packet.Length() == 8)
46  }
47 
56  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
57  return (frameDataSize == 4 || frameDataSize == 8)
58  && frameData[0] == (uint8_t)Type
59  && packetHeader.FrameControl.RoutingEnabled
60  && !packetHeader.FrameControl.RelayingEnabled
61  && packetHeader.FrameControl.SystemPacket;
62  }
63 
70  inline static uint8_t GetACK_ID(const MeshPacket& packet) {
71  return packet[1];
72  }
73 
80  inline static void SetACK_ID(MeshPacket& packet, uint8_t ACK_ID) {
81  packet[1] = ACK_ID;
82  }
83 
90  inline static uint8_t GetACK_Source(const MeshPacket& packet) {
91  return packet[2];
92  }
93 
100  inline static void SetACK_Source(MeshPacket& packet, uint8_t ACK_Source) {
101  packet[2] = ACK_Source;
102  }
103 
113  inline static uint8_t GetExpectedFrameSize(const uint8_t* frameData) {
114  return frameData[3];
115  }
116 
126  inline static uint8_t GetExpectedFrameSize(const MeshPacket& packet) {
127  return packet[3];
128  }
129 
139  inline static void SetExpectedFrameSize(MeshPacket& packet, uint8_t ExpectedSize) {
140  packet[3] = ExpectedSize;
141  }
142 
146  inline static bool IsForeignNet(const MeshPacket& packet) {
147  return packet.Length() == 8;
148  }
149 
153  inline static bool IsForeignNet(uint8_t frameDataSize) {
154  return frameDataSize == 8;
155  }
156 
163  inline static MeshMAC GetForeignNetBSSID(const MeshPacket& packet) {
164  return MeshMAC(packet[4], packet[5], packet[6], packet[7]);
165  }
166 
173  inline static MeshMAC GetForeignNetBSSID(const uint8_t* frameData) {
174  return MeshMAC(frameData[4], frameData[5], frameData[6], frameData[7]);
175  }
176 
183  inline static void SetForeignNetBSSID(MeshPacket& packet, MeshMAC foreignBSSID) {
184  packet[4] = foreignBSSID.octet1;
185  packet[5] = foreignBSSID.octet2;
186  packet[6] = foreignBSSID.octet3;
187  packet[7] = foreignBSSID.octet4;
188  }
189 
200  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, uint8_t ExpectedSize = 0) {
201  if (packet.ResizePayload(4, true)) {
204  packet.PacketHeader.FrameControl.SystemPacket = true;
205  packet.PacketHeader.Source = sourceAddr;
206  packet.PacketHeader.Destination = destAddr;
207  packet[0] = Type;
208  SetACK_ID(packet, ACK_ID);
209  SetACK_Source(packet, ACK_Source);
210  SetExpectedFrameSize(packet, ExpectedSize);
211  return true;
212  }
213  else return false;
214  }
215 
227  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, MeshMAC foreignBSSID, uint8_t ExpectedSize = 0) {
228  if (packet.ResizePayload(8, true)) {
231  packet.PacketHeader.FrameControl.SystemPacket = true;
232  packet.PacketHeader.Source = sourceAddr;
233  packet.PacketHeader.Destination = destAddr;
234  packet[0] = Type;
235  SetACK_ID(packet, ACK_ID);
236  SetACK_Source(packet, ACK_Source);
237  SetExpectedFrameSize(packet, ExpectedSize);
238  SetForeignNetBSSID(packet, foreignBSSID);
239  return true;
240  }
241  else return false;
242  }
243 
247  const static SystemPacketType Type = SPT_ACK;
248 
249 private:
250  ACKPD() { }
251 };
252 
253 
258 typedef enum {
269 
274 class ERR_ACKPD {
275 public:
276 
282  inline static bool IsSameType(const MeshPacket& packet) {
283  return packet.GetSystemPacketType() == Type;
284  }
285 
292  inline static bool IsValid(const MeshPacket& packet) {
293  return IsSameType(packet)
294  && (packet.Length() == 6 || packet.Length() == 10)
298  }
299 
308  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
309  return (frameDataSize == 6 || frameDataSize == 10)
310  && frameData[0] == (uint8_t)Type
311  && packetHeader.FrameControl.RoutingEnabled
312  && !packetHeader.FrameControl.RelayingEnabled
313  && packetHeader.FrameControl.SystemPacket;
314  }
315 
322  inline static uint8_t GetACK_ID(const MeshPacket& packet) {
323  return packet[1];
324  }
325 
332  inline static void SetACK_ID(MeshPacket& packet, uint8_t ACK_ID) {
333  packet[1] = ACK_ID;
334  }
335 
342  inline static uint8_t GetACK_Source(const MeshPacket& packet) {
343  return packet[2];
344  }
345 
352  inline static void SetACK_Source(MeshPacket& packet, uint8_t ACK_Source) {
353  packet[2] = ACK_Source;
354  }
355 
365  inline static uint8_t GetExpectedFrameSize(const uint8_t* frameData) {
366  return frameData[3];
367  }
368 
378  inline static uint8_t GetExpectedFrameSize(const MeshPacket& packet) {
379  return packet[3];
380  }
381 
391  inline static void SetExpectedFrameSize(MeshPacket& packet, uint8_t ExpectedSize) {
392  packet[3] = ExpectedSize;
393  }
394 
402  inline static ERR_ACK_ErrorCode GetErrorCode(const MeshPacket& packet) {
403  return (ERR_ACK_ErrorCode) * (uint8_t*)(packet.p_ptr() + 4);
404  }
405 
413  inline static void SetErrorCode(MeshPacket& packet, ERR_ACK_ErrorCode ErrorCode) {
414  *(uint8_t*)(packet.p_ptr() + 4) = (uint8_t)ErrorCode;
415  }
416 
423  inline static uint8_t GetRepairValue(const MeshPacket& packet) {
424  return *(uint8_t*)(packet.p_ptr() + 5);
425  }
426 
433  inline static void SetRepairValue(MeshPacket& packet, uint8_t RepairValue) {
434  *(uint8_t*)(packet.p_ptr() + 5) = RepairValue;
435  }
436 
440  inline static bool IsForeignNet(const MeshPacket& packet) {
441  return packet.Length() == 10;
442  }
443 
447  inline static bool IsForeignNet(uint8_t frameDataSize) {
448  return frameDataSize == 10;
449  }
450 
457  inline static MeshMAC GetForeignNetBSSID(const MeshPacket& packet) {
458  return MeshMAC(packet[6], packet[7], packet[8], packet[9]);
459  }
460 
467  inline static MeshMAC GetForeignNetBSSID(const uint8_t* frameData) {
468  return MeshMAC(frameData[6], frameData[7], frameData[8], frameData[9]);
469  }
470 
477  inline static void SetForeignNetBSSID(MeshPacket& packet, MeshMAC foreignBSSID) {
478  packet[6] = foreignBSSID.octet1;
479  packet[7] = foreignBSSID.octet2;
480  packet[8] = foreignBSSID.octet3;
481  packet[9] = foreignBSSID.octet4;
482  }
483 
495  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue = 0) {
496  if (packet.ResizePayload(6, true)) {
499  packet.PacketHeader.FrameControl.SystemPacket = true;
500  packet.PacketHeader.Source = sourceAddr;
501  packet.PacketHeader.Destination = destAddr;
502  packet[0] = Type;
503  SetACK_ID(packet, ACK_ID);
504  SetACK_Source(packet, ACK_Source);
505  SetExpectedFrameSize(packet, 0);
506  SetErrorCode(packet, ErrorCode);
507  SetRepairValue(packet, RepairValue);
508  return true;
509  }
510  else return false;
511  }
512 
525  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, uint8_t ExpectedSize, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue = 0) {
526  if (packet.ResizePayload(6, true)) {
529  packet.PacketHeader.FrameControl.SystemPacket = true;
530  packet.PacketHeader.Source = sourceAddr;
531  packet.PacketHeader.Destination = destAddr;
532  packet[0] = Type;
533  SetACK_ID(packet, ACK_ID);
534  SetACK_Source(packet, ACK_Source);
535  SetExpectedFrameSize(packet, ExpectedSize);
536  SetErrorCode(packet, ErrorCode);
537  SetRepairValue(packet, RepairValue);
538  return true;
539  }
540  else return false;
541  }
542 
555  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, MeshMAC foreignBSSID, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue = 0) {
556  if (packet.ResizePayload(10, true)) {
559  packet.PacketHeader.FrameControl.SystemPacket = true;
560  packet.PacketHeader.Source = sourceAddr;
561  packet.PacketHeader.Destination = destAddr;
562  packet[0] = Type;
563  SetACK_ID(packet, ACK_ID);
564  SetACK_Source(packet, ACK_Source);
565  SetExpectedFrameSize(packet, 0);
566  SetErrorCode(packet, ErrorCode);
567  SetRepairValue(packet, RepairValue);
568  SetForeignNetBSSID(packet, foreignBSSID);
569  return true;
570  }
571  else return false;
572  }
573 
587  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, MeshMAC foreignBSSID, uint8_t ExpectedSize, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue = 0) {
588  if (packet.ResizePayload(10, true)) {
591  packet.PacketHeader.FrameControl.SystemPacket = true;
592  packet.PacketHeader.Source = sourceAddr;
593  packet.PacketHeader.Destination = destAddr;
594  packet[0] = Type;
595  SetACK_ID(packet, ACK_ID);
596  SetACK_Source(packet, ACK_Source);
597  SetExpectedFrameSize(packet, ExpectedSize);
598  SetErrorCode(packet, ErrorCode);
599  SetRepairValue(packet, RepairValue);
600  SetForeignNetBSSID(packet, foreignBSSID);
601  return true;
602  }
603  else return false;
604  }
605 
609  const static SystemPacketType Type = SPT_ERR_ACK;
610 
611 private:
612  ERR_ACKPD() { }
613 };
614 
615 
621 public:
627  inline static bool IsSameType(const MeshPacket& packet) {
628  return packet.GetSystemPacketType() == Type && !packet.PacketHeader.FrameControl.RoutingEnabled;
629  }
630 
637  inline static bool IsValid(const MeshPacket& packet) {
638  return IsSameType(packet)
639  && (packet.Length() == 5 || packet.Length() == 9)
642  }
643 
652  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
653  return (frameDataSize == 5 || frameDataSize == 9)
654  && frameData[0] == (uint8_t)Type
655  && !packetHeader.FrameControl.RoutingEnabled
656  && !packetHeader.FrameControl.RelayingEnabled
657  && packetHeader.FrameControl.SystemPacket;
658  }
659 
666  inline static MeshVersion GetNetVersion(const MeshPacket& packet) {
667  return *(MeshVersion*)(packet.p_ptr() + 1);
668  }
669 
676  inline static void SetNetVersion(MeshPacket& packet, MeshVersion version) {
677  *(MeshVersion*)(packet.p_ptr() + 1) = version;
678  }
679 
686  inline static MeshNetScanFlags GetFlags(const MeshPacket& packet) {
687  return *(uint16_t*)(packet.p_ptr() + 3);
688  }
689 
696  inline static MeshNetScanFlags GetFlags(const uint8_t* frameData) {
697  return *(uint16_t*)(frameData + 3);
698  }
699 
706  inline static void SetFlags(MeshPacket& packet, MeshNetScanFlags flags) {
707  *(uint16_t*)(packet.p_ptr() + 3) = flags;
708  }
709 
714  inline static bool HasResponder(const MeshPacket& packet) {
715  return packet.Length() == 9;
716  }
717 
722  inline static bool HasResponder(uint8_t frameDataSize) {
723  return frameDataSize == 9;
724  }
725 
733  inline static MeshMAC GetResponder(const MeshPacket& packet) {
734  return MeshMAC(packet[5], packet[6], packet[7], packet[8]);
735  }
736 
744  inline static MeshMAC GetResponder(const uint8_t* frameData) {
745  return MeshMAC(frameData[5], frameData[6], frameData[7], frameData[8]);
746  }
747 
755  inline static void SetResponder(MeshPacket& packet, MeshMAC responder) {
756  packet[5] = responder.octet1;
757  packet[6] = responder.octet2;
758  packet[7] = responder.octet3;
759  packet[8] = responder.octet4;
760  }
761 
770  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, MeshVersion version, MeshNetScanFlags flags) {
771  if (packet.ResizePayload(5, true)) {
774  packet.PacketHeader.FrameControl.SystemPacket = true;
775  packet.PacketHeader.Source = sourceAddr;
776  packet[0] = Type;
777  SetNetVersion(packet, version);
778  SetFlags(packet, flags);
779  return true;
780  }
781  else return false;
782  }
783 
793  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, MeshVersion version, MeshNetScanFlags flags, MeshMAC responder) {
794  if (packet.ResizePayload(9, true)) {
797  packet.PacketHeader.FrameControl.SystemPacket = true;
798  packet.PacketHeader.Source = sourceAddr;
799  packet[0] = Type;
800  SetNetVersion(packet, version);
801  SetFlags(packet, flags);
802  SetResponder(packet, responder);
803  return true;
804  }
805  else return false;
806  }
807 
811  const static SystemPacketType Type = SPT_NetScan;
812 
813 private:
815 };
816 
817 
818 
824 public:
830  inline static bool IsSameType(const MeshPacket& packet) {
831  return packet.GetSystemPacketType() == Type && packet.PacketHeader.FrameControl.RoutingEnabled;
832  }
833 
840  inline static bool IsValid(const MeshPacket& packet) {
841  return IsSameType(packet)
842  && packet.Length() >= 10 && packet.Length() <= 74
845  }
846 
855  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
856  return frameDataSize >= 10 && frameDataSize <= 74
857  && frameData[0] == (uint8_t)Type
858  && packetHeader.FrameControl.RoutingEnabled
859  && !packetHeader.FrameControl.RelayingEnabled
860  && packetHeader.FrameControl.SystemPacket;
861  }
862 
869  inline static MeshVersion GetNetVersion(const MeshPacket& packet) {
870  return *(MeshVersion*)(packet.p_ptr() + 1);
871  }
872 
879  inline static void SetNetVersion(MeshPacket& packet, MeshVersion version) {
880  *(MeshVersion*)(packet.p_ptr() + 1) = version;
881  }
882 
889  inline static MeshNodeDescFlags GetFlags(const MeshPacket& packet) {
890  return *(uint16_t*)(packet.p_ptr() + 3);
891  }
892 
899  inline static void SetFlags(MeshPacket& packet, MeshNodeDescFlags flags) {
900  *(uint16_t*)(packet.p_ptr() + 3) = flags;
901  }
902 
909  inline static MeshMAC GetForeignNetBSSID(const MeshPacket& packet) {
910  return MeshMAC(packet[5], packet[6], packet[7], packet[8]);
911  }
912 
919  inline static MeshMAC GetForeignNetBSSID(const uint8_t* frameData) {
920  return MeshMAC(frameData[5], frameData[6], frameData[7], frameData[8]);
921  }
922 
929  inline static void SetForeignNetBSSID(MeshPacket& packet, MeshMAC foreignBSSID) {
930  packet[5] = foreignBSSID.octet1;
931  packet[6] = foreignBSSID.octet2;
932  packet[7] = foreignBSSID.octet3;
933  packet[8] = foreignBSSID.octet4;
934  }
935 
942  inline static uint8_t GetHopsToGateway(const MeshPacket& packet) {
943  return packet[9];
944  }
945 
953  inline static bool IsDisconnectedNode(const MeshPacket& packet) {
954  return packet[9] == 255;
955  }
956 
963  inline static void SetHopsToGateway(MeshPacket& packet, uint8_t hops) {
964  packet[9] = hops;
965  }
966 
974  inline static char* GetSSIDPtr(const MeshPacket& packet) {
975  return (char*)(packet.p_ptr()+10);
976  }
977 
987  static bool GetSSID(const MeshPacket& packet, char* SSID, uint8_t& SSID_length) {
988  if (GetSSIDLength(packet) > 0 && SSID_length > 0) {
989  bool noTrunc = GetSSIDLength(packet) < SSID_length;
990  SSID_length = (noTrunc) ? GetSSIDLength(packet) : (SSID_length - 1);
991  memcpy(SSID, (void*)(packet.p_ptr() + 10), SSID_length);
992  SSID[SSID_length] = 0; //Null trerminator
993  return noTrunc;
994  }
995  else {
996  SSID[0] = 0; //Null trerminator
997  SSID_length = 0;
998  return false;
999  }
1000  }
1001 
1008  inline static uint16_t GetSSIDLength(const MeshPacket& packet) {
1009  return ((packet.Length() < 10) ? 0 : (packet.Length() - 10));
1010  }
1011 
1021  static bool SetSSID(MeshPacket& packet, const char* SSID, uint8_t SSID_length, bool resize = true) {
1022  if (SSID_length > 64) return false;
1023  if (SSID == NULL) SSID_length = 0;
1024  if (resize) {
1025  if (!packet.ResizePayload(10 + SSID_length, false)) {
1026  return false;
1027  }
1028  }
1029  if (packet.Length() > 10) {
1030  if (SSID_length > 0) {
1031  uint8_t minLength = packet.Length() - 10;
1032  if(SSID_length < minLength) minLength = SSID_length;
1033  memcpy((void*)(packet.p_ptr() + 10), SSID, minLength);
1034  }
1035  }
1036  else return false;
1037  return true;
1038  }
1039 
1046  static MeshNetScanResult GetResult(const MeshPacket& packet, MeshMAC BSSID) {
1047  MeshNetScanResult ret;
1048  if (!IsValid(packet)) {
1050  return ret;
1051  }
1052  ret.Address = packet.PacketHeader.Source;
1053  ret.BSSID = BSSID;
1054  ret.Flags = GetFlags(packet);
1055  ret.HopsToGateway = GetHopsToGateway(packet);
1056  ret.Version = GetNetVersion(packet);
1057  ret.SSID_length = GetSSIDLength(packet);
1058  ret.SSID_ptr = GetSSIDPtr(packet);
1059  return ret;
1060  }
1061 
1075  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshVersion version, MeshNodeDescFlags flags, MeshMAC foreignBSSID, uint8_t hops, const char* SSID, uint8_t SSID_length) {
1076  if (SSID_length > 64 || SSID == NULL) return false;
1077  if (packet.ResizePayload(10 + SSID_length, true)) {
1079  packet.PacketHeader.FrameControl.RelayingEnabled = false;
1080  packet.PacketHeader.FrameControl.SystemPacket = true;
1081  packet.PacketHeader.Source = sourceAddr;
1082  packet.PacketHeader.Destination = destAddr;
1083  packet[0] = SPT_NetScan;
1084  SetNetVersion(packet, version);
1085  SetFlags(packet, flags);
1086  SetForeignNetBSSID(packet, foreignBSSID);
1087  SetHopsToGateway(packet, hops);
1088  uint8_t minLength = packet.Length() - 10;
1089  if(SSID_length < minLength) minLength = SSID_length;
1090  memcpy((void*)(packet.p_ptr() + 10), SSID, minLength);
1091  return true;
1092  }
1093  else return false;
1094  }
1095 
1107  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshVersion version, MeshNodeDescFlags flags, MeshMAC foreignBSSID, uint8_t hops) {
1108  if (packet.ResizePayload(10, true)) {
1110  packet.PacketHeader.FrameControl.RelayingEnabled = false;
1111  packet.PacketHeader.FrameControl.SystemPacket = true;
1112  packet.PacketHeader.Source = sourceAddr;
1113  packet.PacketHeader.Destination = destAddr;
1114  packet[0] = SPT_NetScan;
1115  SetNetVersion(packet, version);
1116  SetFlags(packet, flags);
1117  SetForeignNetBSSID(packet, foreignBSSID);
1118  SetHopsToGateway(packet, hops);
1119  return true;
1120  }
1121  else return false;
1122  }
1123 
1133  static bool Construct(MeshPacket& packet, uint8_t destAddr, const MeshNetScanResult& result, MeshMAC foreignBSSID) {
1134  if (result.SSID_length > 64) return false;
1135  if (packet.ResizePayload(10 + result.SSID_length, true)) {
1137  packet.PacketHeader.FrameControl.RelayingEnabled = false;
1138  packet.PacketHeader.FrameControl.SystemPacket = true;
1139  packet.PacketHeader.Source = result.Address;
1140  packet.PacketHeader.Destination = destAddr;
1141  packet[0] = SPT_NetScan;
1142  SetNetVersion(packet, result.Version);
1143  SetFlags(packet, result.Flags);
1144  SetForeignNetBSSID(packet, foreignBSSID);
1145  SetHopsToGateway(packet, result.HopsToGateway);
1146  if (result.SSID_length > 0 && result.SSID_ptr != NULL) {
1147  uint8_t minLength = packet.Length() - 10;
1148  if(result.SSID_length < minLength) minLength = result.SSID_length;
1149  memcpy((void*)(packet.p_ptr() + 10), result.SSID_ptr, minLength);
1150  }
1151  return true;
1152  }
1153  else return false;
1154  }
1155 
1159  const static SystemPacketType Type = SPT_NetScan;
1160 
1161 private:
1163 };
1164 
1165 
1166 
1167 
1173 public:
1179  inline static bool IsSameType(const MeshPacket& packet) {
1180  return packet.GetSystemPacketType() == Type && packet.Length() == 9 && !packet.PacketHeader.FrameControl.RelayingEnabled;
1181  }
1182 
1189  inline static bool IsValid(const MeshPacket& packet) {
1190  return IsSameType(packet)
1191  && packet.Length() == 9
1194  }
1195 
1204  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
1205  return frameDataSize == 9
1206  && frameData[0] == (uint8_t)Type
1207  && packetHeader.FrameControl.RoutingEnabled
1208  && !packetHeader.FrameControl.RelayingEnabled
1209  && packetHeader.FrameControl.SystemPacket;
1210  }
1211 
1218  inline static MeshNodeDescFlags GetFlags(const MeshPacket& packet) {
1219  return *(uint16_t*)(packet.p_ptr() + 1);
1220  }
1221 
1228  inline static void SetFlags(MeshPacket& packet, MeshNodeDescFlags flags) {
1229  *(uint16_t*)(packet.p_ptr() + 1) = flags;
1230  }
1231 
1238  inline static MeshMAC GetForeignNetBSSID(const MeshPacket& packet) {
1239  return MeshMAC(packet[3], packet[4], packet[5], packet[6]);
1240  }
1241 
1248  inline static MeshMAC GetForeignNetBSSID(const uint8_t* frameData) {
1249  return MeshMAC(frameData[3], frameData[4], frameData[5], frameData[6]);
1250  }
1251 
1258  inline static void SetForeignNetBSSID(MeshPacket& packet, MeshMAC foreignBSSID) {
1259  packet[3] = foreignBSSID.octet1;
1260  packet[4] = foreignBSSID.octet2;
1261  packet[5] = foreignBSSID.octet3;
1262  packet[6] = foreignBSSID.octet4;
1263  }
1264 
1271  inline static MeshVersion GetNetVersion(const MeshPacket& packet) {
1272  return *(MeshVersion*)(packet.p_ptr() + 7);
1273  }
1274 
1281  inline static void SetNetVersion(MeshPacket& packet, MeshVersion version) {
1282  *(MeshVersion*)(packet.p_ptr() + 7) = version;
1283  }
1284 
1295  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshNodeDescFlags flags, MeshMAC foreignBSSID, MeshVersion version) {
1296  if (packet.ResizePayload(9, true)) {
1298  packet.PacketHeader.FrameControl.RelayingEnabled = false;
1299  packet.PacketHeader.FrameControl.SystemPacket = true;
1300  packet.PacketHeader.Source = sourceAddr;
1301  packet.PacketHeader.Destination = destAddr;
1302  packet[0] = Type;
1303  SetNetVersion(packet, version);
1304  SetFlags(packet, flags);
1305  SetForeignNetBSSID(packet, foreignBSSID);
1306  return true;
1307  }
1308  else return false;
1309  }
1310 
1314  const static SystemPacketType Type = SPT_Connect;
1315 
1316 private:
1318 };
1319 
1320 
1321 typedef enum {
1324  NCRRR_Full = 254,
1327 
1328 
1334 public:
1340  inline static bool IsSameType(const MeshPacket& packet) {
1341  return packet.GetSystemPacketType() == Type && ((packet.Length() >= 10 && packet.Length() <= 74) || packet.Length() <= 8) && !packet.PacketHeader.FrameControl.RelayingEnabled;
1342  }
1343 
1350  inline static bool IsValid(const MeshPacket& packet) {
1351  return IsSameType(packet)
1352  && ((packet.Length() >= 10 && packet.Length() <= 74) || packet.Length() == 8)
1355  }
1356 
1365  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
1366  return ((frameDataSize >= 10 && frameDataSize <= 74) || frameDataSize == 8)
1367  && frameData[0] == (uint8_t)Type
1368  && packetHeader.FrameControl.RoutingEnabled
1369  && !packetHeader.FrameControl.RelayingEnabled
1370  && packetHeader.FrameControl.SystemPacket;
1371  }
1372 
1379  inline static uint16_t GetFlags(const MeshPacket& packet) {
1380  return *(uint16_t*)(packet.p_ptr() + 1);
1381  }
1382 
1389  inline static void SetFlags(MeshPacket& packet, uint16_t flags) {
1390  *(uint16_t*)(packet.p_ptr() + 1) = flags;
1391  }
1392 
1399  inline static MeshMAC GetForeignNetBSSID(const MeshPacket& packet) {
1400  return MeshMAC(packet[3], packet[4], packet[5], packet[6]);
1401  }
1402 
1409  inline static MeshMAC GetForeignNetBSSID(const uint8_t* frameData) {
1410  return MeshMAC(frameData[3], frameData[4], frameData[5], frameData[6]);
1411  }
1412 
1419  inline static void SetForeignNetBSSID(MeshPacket& packet, MeshMAC foreignBSSID) {
1420  packet[3] = foreignBSSID.octet1;
1421  packet[4] = foreignBSSID.octet2;
1422  packet[5] = foreignBSSID.octet3;
1423  packet[6] = foreignBSSID.octet4;
1424  }
1425 
1432  inline static uint8_t GetAssignedAddr(const MeshPacket& packet) {
1433  return packet[7];
1434  }
1435 
1442  inline static void SetAssignedAddr(MeshPacket& packet, uint8_t address) {
1443  packet[7] = address;
1444  }
1445 
1450  inline static bool IsRefusedConnection(MeshPacket& packet) {
1451  return packet[7] >= UNKNOWN_MESH_ADDRESS || packet.Length() <= 8;
1452  }
1453 
1459  if (IsRefusedConnection(packet)) {
1460  return (NetConRespRefuseReason)packet[7];
1461  }
1462  else {
1464  }
1465  }
1466 
1473  inline static void SetRefuseReason(MeshPacket& packet, NetConRespRefuseReason reason) {
1474  packet[7] = (uint8_t)reason;
1475  }
1476 
1483  inline static uint16_t GetReservedTime(const MeshPacket& packet) {
1484  return *(uint16_t*)(packet.p_ptr() + 8);
1485  }
1486 
1493  inline static void SetReservedTime(MeshPacket& packet, uint16_t time) {
1494  *(uint16_t*)(packet.p_ptr() + 8) = time;
1495  }
1496 
1504  inline static char* GetSSIDPtr(const MeshPacket& packet) {
1505  return (char*)(packet.p_ptr() + 10);
1506  }
1507 
1517  static bool GetSSID(const MeshPacket& packet, char* SSID, uint8_t& SSID_length) {
1518  if (GetSSIDLength(packet) > 0 && SSID_length > 0) {
1519  bool noTrunc = GetSSIDLength(packet) < SSID_length;
1520  SSID_length = (noTrunc) ? GetSSIDLength(packet) : (SSID_length - 1);
1521  memcpy(SSID, (void*)(packet.p_ptr() + 10), SSID_length);
1522  SSID[SSID_length] = 0; //Null trerminator
1523  return noTrunc;
1524  }
1525  else {
1526  SSID[0] = 0; //Null trerminator
1527  SSID_length = 0;
1528  return false;
1529  }
1530  }
1531 
1538  inline static uint16_t GetSSIDLength(const MeshPacket& packet) {
1539  return ((packet.Length() < 10) ? 0 : (packet.Length() - 10));
1540  }
1541 
1551  static bool SetSSID(MeshPacket& packet, const char* SSID, uint8_t SSID_length, bool resize = true) {
1552  if (SSID_length > 64) return false;
1553  if (SSID == NULL) SSID_length = 0;
1554  if (resize) {
1555  if (!packet.ResizePayload(10 + SSID_length, false)) {
1556  return false;
1557  }
1558  }
1559  if (packet.Length() > 10) {
1560  if (SSID_length > 0) {
1561  uint8_t minLength = packet.Length() - 10;
1562  if (SSID_length < minLength) minLength = SSID_length;
1563  memcpy((void*)(packet.p_ptr() + 10), SSID, minLength);
1564  }
1565  }
1566  else return false;
1567  return true;
1568  }
1569 
1583  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC foreignBSSID, uint8_t address, uint16_t time, const char* SSID, uint8_t SSID_length) {
1584  if (SSID_length > 64 || SSID == NULL) return false;
1585  if (packet.ResizePayload(10 + SSID_length, true)) {
1587  packet.PacketHeader.FrameControl.RelayingEnabled = false;
1588  packet.PacketHeader.FrameControl.SystemPacket = true;
1589  packet.PacketHeader.Source = sourceAddr;
1590  packet.PacketHeader.Destination = destAddr;
1591  packet[0] = Type;
1592  SetAssignedAddr(packet, address);
1593  SetFlags(packet, flags);
1594  SetForeignNetBSSID(packet, foreignBSSID);
1595  SetReservedTime(packet, time);
1596  uint8_t minLength = packet.Length() - 10;
1597  if (SSID_length < minLength) minLength = SSID_length;
1598  memcpy((void*)(packet.p_ptr() + 10), SSID, minLength);
1599  return true;
1600  }
1601  else return false;
1602  }
1603 
1614  static bool ConstructRefused(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC foreignBSSID, NetConRespRefuseReason reason) {
1615  if (packet.ResizePayload(8, true)) {
1617  packet.PacketHeader.FrameControl.RelayingEnabled = false;
1618  packet.PacketHeader.FrameControl.SystemPacket = true;
1619  packet.PacketHeader.Source = sourceAddr;
1620  packet.PacketHeader.Destination = destAddr;
1621  packet[0] = Type;
1622  SetRefuseReason(packet, reason);
1623  SetFlags(packet, flags);
1624  SetForeignNetBSSID(packet, foreignBSSID);
1625  return true;
1626  }
1627  else return false;
1628  }
1629 
1633  const static SystemPacketType Type = SPT_Connect;
1634 
1635 private:
1637 };
1638 
1639 
1640 
1641 
1647 public:
1653  inline static bool IsSameType(const MeshPacket& packet) {
1654  return packet.GetSystemPacketType() == Type && packet.Length() == 9 && packet.PacketHeader.FrameControl.RelayingEnabled;
1655  }
1656 
1663  inline static bool IsValid(const MeshPacket& packet) {
1664  return IsSameType(packet)
1667  }
1668 
1677  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
1678  return frameDataSize == 9
1679  && frameData[0] == (uint8_t)Type
1680  && packetHeader.FrameControl.RoutingEnabled
1681  && packetHeader.FrameControl.RelayingEnabled
1682  && packetHeader.FrameControl.SystemPacket;
1683  }
1684 
1691  inline static MeshNodeDescFlags GetFlags(const MeshPacket& packet) {
1692  return *(uint16_t*)(packet.p_ptr() + 1);
1693  }
1694 
1701  inline static void SetFlags(MeshPacket& packet, MeshNodeDescFlags flags) {
1702  *(uint16_t*)(packet.p_ptr() + 1) = flags;
1703  }
1704 
1711  inline static MeshMAC GetRequesterMAC(const MeshPacket& packet) {
1712  return MeshMAC(packet[3], packet[4], packet[5], packet[6]);
1713  }
1714 
1721  inline static void SetRequesterMAC(MeshPacket& packet, MeshMAC requesterMAC) {
1722  packet[3] = requesterMAC.octet1;
1723  packet[4] = requesterMAC.octet2;
1724  packet[5] = requesterMAC.octet3;
1725  packet[6] = requesterMAC.octet4;
1726  }
1727 
1734  inline static MeshVersion GetNetVersion(const MeshPacket& packet) {
1735  return *(MeshVersion*)(packet.p_ptr() + 7);
1736  }
1737 
1744  inline static void SetNetVersion(MeshPacket& packet, MeshVersion version) {
1745  *(MeshVersion*)(packet.p_ptr() + 7) = version;
1746  }
1747 
1758  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshNodeDescFlags flags, MeshMAC requesterMAC, MeshVersion version) {
1759  if (packet.ResizePayload(9, true)) {
1762  packet.PacketHeader.FrameControl.SystemPacket = true;
1763  packet.PacketHeader.Hops = 0;
1764  packet.PacketHeader.From = sourceAddr;
1765  packet.PacketHeader.Source = sourceAddr;
1766  packet.PacketHeader.Destination = destAddr;
1767  packet[0] = Type;
1768  SetNetVersion(packet, version);
1769  SetFlags(packet, flags);
1770  SetRequesterMAC(packet, requesterMAC);
1771  return true;
1772  }
1773  else return false;
1774  }
1775 
1779  const static SystemPacketType Type = SPT_Connect;
1780 
1781 private:
1783 };
1784 
1785 
1786 
1792 public:
1798  inline static bool IsSameType(const MeshPacket& packet) {
1799  return packet.GetSystemPacketType() == Type && (packet.Length() == 8 || packet.Length() == 10) && packet.PacketHeader.FrameControl.RelayingEnabled;
1800  }
1801 
1808  inline static bool IsValid(const MeshPacket& packet) {
1809  return IsSameType(packet)
1812  }
1813 
1822  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
1823  return (frameDataSize == 8 || frameDataSize == 10)
1824  && frameData[0] == (uint8_t)Type
1825  && packetHeader.FrameControl.RoutingEnabled
1826  && packetHeader.FrameControl.RelayingEnabled
1827  && packetHeader.FrameControl.SystemPacket;
1828  }
1829 
1836  inline static uint16_t GetFlags(const MeshPacket& packet) {
1837  return *(uint16_t*)(packet.p_ptr() + 1);
1838  }
1839 
1846  inline static void SetFlags(MeshPacket& packet, uint16_t flags) {
1847  *(uint16_t*)(packet.p_ptr() + 1) = flags;
1848  }
1849 
1856  inline static MeshMAC GetRequesterMAC(const MeshPacket& packet) {
1857  return MeshMAC(packet[3], packet[4], packet[5], packet[6]);
1858  }
1859 
1866  inline static void SetRequesterMAC(MeshPacket& packet, MeshMAC requesterMAC) {
1867  packet[3] = requesterMAC.octet1;
1868  packet[4] = requesterMAC.octet2;
1869  packet[5] = requesterMAC.octet3;
1870  packet[6] = requesterMAC.octet4;
1871  }
1872 
1879  inline static uint8_t GetAssignedAddr(const MeshPacket& packet) {
1880  return packet[7];
1881  }
1882 
1889  inline static void SetAssignedAddr(MeshPacket& packet, uint8_t address) {
1890  packet[7] = address;
1891  }
1892 
1896  inline static bool IsRefusedConnection(MeshPacket& packet) {
1897  return packet[7] == UNKNOWN_MESH_ADDRESS || packet.Length() == 8;
1898  }
1899 
1905  if (IsRefusedConnection(packet)) {
1906  return (NetConRespRefuseReason)packet[7];
1907  }
1908  else {
1910  }
1911  }
1912 
1919  inline static void SetRefuseReason(MeshPacket& packet, NetConRespRefuseReason reason) {
1920  packet[7] = (uint8_t)reason;
1921  }
1922 
1929  inline static uint16_t GetReservedTime(const MeshPacket& packet) {
1930  return *(uint16_t*)(packet.p_ptr() + 8);
1931  }
1932 
1939  inline static void SetReservedTime(MeshPacket& packet, uint16_t time) {
1940  *(uint16_t*)(packet.p_ptr() + 8) = time;
1941  }
1942 
1954  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC requesterMAC, uint8_t address, uint16_t time) {
1955  if (packet.ResizePayload(10, true)) {
1958  packet.PacketHeader.FrameControl.SystemPacket = true;
1959  packet.PacketHeader.Hops = 0;
1960  packet.PacketHeader.From = sourceAddr;
1961  packet.PacketHeader.Source = sourceAddr;
1962  packet.PacketHeader.Destination = destAddr;
1963  packet[0] = Type;
1964  SetAssignedAddr(packet, address);
1965  SetFlags(packet, flags);
1966  SetReservedTime(packet, time);
1967  SetRequesterMAC(packet, requesterMAC);
1968  return true;
1969  }
1970  else return false;
1971  }
1972 
1983  static bool ConstructRefused(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC requesterMAC, NetConRespRefuseReason reason) {
1984  if (packet.ResizePayload(8, true)) {
1987  packet.PacketHeader.FrameControl.SystemPacket = true;
1988  packet.PacketHeader.Hops = 0;
1989  packet.PacketHeader.From = sourceAddr;
1990  packet.PacketHeader.Source = sourceAddr;
1991  packet.PacketHeader.Destination = destAddr;
1992  packet[0] = Type;
1993  SetRefuseReason(packet, reason);
1994  SetFlags(packet, flags);
1995  SetRequesterMAC(packet, requesterMAC);
1996  return true;
1997  }
1998  else return false;
1999  }
2000 
2004  const static SystemPacketType Type = SPT_Connect;
2005 
2006 private:
2008 };
2009 
2010 
2011 
2012 
2013 
2018 class PathDiscPD {
2019 public:
2025  inline static bool IsSameType(const MeshPacket& packet) {
2026  return packet.GetSystemPacketType() == Type && !packet.PacketHeader.FrameControl.RoutingEnabled;
2027  }
2028 
2035  inline static bool IsValid(const MeshPacket& packet) {
2036  return IsSameType(packet)
2037  && packet.Length() == 5
2040  }
2041 
2050  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
2051  return frameDataSize == 5
2052  && frameData[0] == (uint8_t)Type
2053  && !packetHeader.FrameControl.RoutingEnabled
2054  && packetHeader.FrameControl.RelayingEnabled
2055  && packetHeader.FrameControl.SystemPacket;
2056  }
2057 
2064  inline static MeshMAC GetMAC(const MeshPacket& packet) {
2065  return MeshMAC(packet[1], packet[2], packet[3], packet[4]);
2066  }
2067 
2074  inline static void SetMAC(MeshPacket& packet, MeshMAC MAC) {
2075  packet[1] = MAC.octet1;
2076  packet[2] = MAC.octet2;
2077  packet[3] = MAC.octet3;
2078  packet[4] = MAC.octet4;
2079  }
2080 
2089  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshMAC MAC) {
2090  if (packet.ResizePayload(5, true)) {
2091  packet.PacketHeader.FrameControl.RoutingEnabled = false;
2093  packet.PacketHeader.FrameControl.SystemPacket = true;
2094  packet.PacketHeader.Hops = 0;
2095  packet.PacketHeader.From = sourceAddr;
2096  packet.PacketHeader.Source = sourceAddr;
2097  packet.PacketHeader.Destination = destAddr;
2098  packet[0] = Type;
2099  SetMAC(packet, MAC);
2100  return true;
2101  }
2102  else return false;
2103  }
2104 
2108  const static SystemPacketType Type = SPT_PathDiscovery;
2109 
2110 private:
2112 };
2113 
2114 
2120 public:
2126  inline static bool IsSameType(const MeshPacket& packet) {
2127  return packet.GetSystemPacketType() == Type && packet.PacketHeader.FrameControl.RoutingEnabled;
2128  }
2129 
2136  inline static bool IsValid(const MeshPacket& packet) {
2137  return IsSameType(packet)
2138  && packet.Length() == 6
2141  }
2142 
2151  inline static bool IsValid(const MeshPacketHeader& packetHeader, const uint8_t* frameData, uint8_t frameDataSize) {
2152  return frameDataSize == 6
2153  && frameData[0] == (uint8_t)Type
2154  && packetHeader.FrameControl.RoutingEnabled
2155  && packetHeader.FrameControl.RelayingEnabled
2156  && packetHeader.FrameControl.SystemPacket;
2157  }
2158 
2165  inline static MeshMAC GetMAC(const MeshPacket& packet) {
2166  return MeshMAC(packet[1], packet[2], packet[3], packet[4]);
2167  }
2168 
2175  inline static void SetMAC(MeshPacket& packet, MeshMAC MAC) {
2176  packet[1] = MAC.octet1;
2177  packet[2] = MAC.octet2;
2178  packet[3] = MAC.octet3;
2179  packet[4] = MAC.octet4;
2180  }
2181 
2188  inline static uint8_t GetReqID(const MeshPacket& packet) {
2189  return packet[5];
2190  }
2191 
2198  inline static void SetReqID(MeshPacket& packet, uint8_t ReqID) {
2199  packet[5] = ReqID;
2200  }
2201 
2211  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshMAC MAC, uint8_t ReqID) {
2212  if (packet.ResizePayload(6, true)) {
2215  packet.PacketHeader.FrameControl.SystemPacket = true;
2216  packet.PacketHeader.Hops = 0;
2217  packet.PacketHeader.From = sourceAddr;
2218  packet.PacketHeader.Source = sourceAddr;
2219  packet.PacketHeader.Destination = destAddr;
2220  packet[0] = Type;
2221  SetMAC(packet, MAC);
2222  SetReqID(packet, ReqID);
2223  return true;
2224  }
2225  else return false;
2226  }
2227 
2231  const static SystemPacketType Type = SPT_PathDiscovery;
2232 
2233 private:
2235 };
2236 
2237 
2238 
2239 typedef enum {
2244 
2250 public:
2256  inline static bool IsSameType(const MeshPacket& packet) {
2257  return packet.GetSystemPacketType() == Type;
2258  }
2259 
2266  inline static bool IsValid(const MeshPacket& packet) {
2267  return IsSameType(packet)
2268  && packet.Length() == 2
2269  && (((packet[1] == MNDPT_Disconnecting || packet[1] <= MNDPT_NetworkDrop) && !packet.PacketHeader.FrameControl.RoutingEnabled)
2273  }
2274 
2282  return (MeshNetDisconnectPacketType)packet[1];
2283  }
2284 
2291  inline static void SetDisconnectType(MeshPacket& packet, MeshNetDisconnectPacketType disconnectType) {
2292  packet[1] = (uint8_t)disconnectType;
2293  }
2294 
2303  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshNetDisconnectPacketType disconnectType) {
2304  if (packet.ResizePayload(2, true)) {
2306  packet.PacketHeader.FrameControl.SystemPacket = true;
2307  packet.PacketHeader.Hops = 0;
2308  packet.PacketHeader.From = sourceAddr;
2309  packet.PacketHeader.Source = sourceAddr;
2311  packet.PacketHeader.FrameControl.RoutingEnabled = false;
2313  }
2314  else {
2316  packet.PacketHeader.Destination = destAddr;
2317  }
2318  packet[0] = Type;
2319  SetDisconnectType(packet, disconnectType);
2320  return true;
2321  }
2322  else return false;
2323  }
2324 
2328  const static SystemPacketType Type = SPT_Disconnect;
2329 
2330 private:
2332 };
2333 
2334 
2339 class PingPD {
2340 public:
2346  inline static bool IsSameType(const MeshPacket& packet) {
2347  return packet.GetSystemPacketType() == Type;
2348  }
2349 
2356  inline static bool IsValid(const MeshPacket& packet) {
2357  return IsSameType(packet)
2358  && packet.Length() >= 8
2362  }
2363 
2370  inline static MeshPingFlags GetFlags(const MeshPacket& packet) {
2371  return *(uint16_t*)(packet.p_ptr() + 1);
2372  }
2373 
2380  inline static void SetFlags(MeshPacket& packet, MeshPingFlags flags) {
2381  *(uint16_t*)(packet.p_ptr() + 1) = flags;
2382  }
2383 
2390  inline static uint32_t GetPingStartTime(const MeshPacket& packet) {
2391  return *(uint32_t*)(packet.p_ptr() + 3);
2392  }
2393 
2400  inline static void SetPingStartTime(MeshPacket& packet, uint32_t pingStartTime) {
2401  *(uint32_t*)(packet.p_ptr() + 3) = pingStartTime;
2402  }
2403 
2410  inline static uint32_t GetPingID(const MeshPacket& packet) {
2411  return packet[7];
2412  }
2413 
2420  inline static void SetPingID(MeshPacket& packet, uint8_t pingID) {
2421  packet[7] = pingID;
2422  }
2423 
2430  inline static uint8_t* GetTestDataPtr(const MeshPacket& packet) {
2431  return (packet.Length() > 8)?(uint8_t*)(packet.p_ptr() + 8):NULL;
2432  }
2433 
2442  static bool GetTestData(const MeshPacket& packet, uint8_t* testData, int16_t& length) {
2443  if (GetTestDataLength(packet) > 0 && length > 0) {
2444  bool noTrunc = GetTestDataLength(packet) < length;
2445  length = (noTrunc) ? GetTestDataLength(packet) : length;
2446  memcpy(testData, (void*)(packet.p_ptr() + 8), length);
2447  return noTrunc;
2448  }
2449  else {
2450  length = 0;
2451  return false;
2452  }
2453  }
2454 
2461  inline static int16_t GetTestDataLength(const MeshPacket& packet) {
2462  return ((packet.Length() < 8) ? 0 : (packet.Length() - 8));
2463  }
2464 
2474  static bool SetTestData(MeshPacket& packet, const uint8_t* testData, int16_t length, bool resize = true) {
2475  if (length > MESH_PACKET_PAYLOAD_SIZE_LIMIT - 8) return false;
2476  if (testData == NULL || length < 0) length = 0;
2477  if (resize) {
2478  if (!packet.ResizePayload(8 + length, false)) {
2479  return false;
2480  }
2481  }
2482  if (packet.Length() > 8) {
2483  if (length > 0) {
2484  int16_t minLength = packet.Length() - 8;
2485  if (length < minLength) minLength = length;
2486  memcpy((void*)(packet.p_ptr() + 8), testData, minLength);
2487  }
2488  }
2489  else return false;
2490  return true;
2491  }
2492 
2501  static bool SetRandomTestData(MeshPacket& packet, int16_t length, bool resize = true) {
2502  if (length > MESH_PACKET_PAYLOAD_SIZE_LIMIT - 8) return false;
2503  if (length < 0) length = 0;
2504  if (resize) {
2505  if (!packet.ResizePayload(8 + length, false)) {
2506  return false;
2507  }
2508  }
2509  if (packet.Length() > 8) {
2510  if (length > 0) {
2511  length += 8;
2512  for (int16_t i = 8; i < length; i++) {
2513  packet[i] = random(0, 255);
2514  }
2515  }
2516  }
2517  else return false;
2518  return true;
2519  }
2520 
2531  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshPingFlags flags, uint32_t pingStartTime, int16_t testDataLength = 0) {
2532  if (testDataLength < 0) testDataLength = 0;
2533  if (testDataLength <= MESH_PACKET_PAYLOAD_SIZE_LIMIT - 8 && packet.ResizePayload(8 + testDataLength, true)) {
2536  packet.PacketHeader.FrameControl.SystemPacket = true;
2537  packet.PacketHeader.Source = sourceAddr;
2538  packet.PacketHeader.From = sourceAddr;
2539  packet.PacketHeader.Hops = 0;
2540  packet.PacketHeader.Destination = destAddr;
2541  packet[0] = Type;
2542  SetFlags(packet, flags);
2543  SetPingStartTime(packet, pingStartTime);
2544  SetRandomTestData(packet, testDataLength, false);
2545  return true;
2546  }
2547  else return false;
2548  }
2549 
2561  static bool Construct(MeshPacket& packet, uint8_t sourceAddr, uint8_t destAddr, MeshPingFlags flags, uint32_t pingStartTime, const uint8_t* testData, int16_t testDataLength) {
2562  if (testDataLength < 0 || testData == NULL) testDataLength = 0;
2563  if (testDataLength <= MESH_PACKET_PAYLOAD_SIZE_LIMIT - 8 && packet.ResizePayload(8 + testDataLength, true)) {
2566  packet.PacketHeader.FrameControl.SystemPacket = true;
2567  packet.PacketHeader.Source = sourceAddr;
2568  packet.PacketHeader.From = sourceAddr;
2569  packet.PacketHeader.Hops = 0;
2570  packet.PacketHeader.Destination = destAddr;
2571  packet[0] = Type;
2572  SetFlags(packet, flags);
2573  SetPingStartTime(packet, pingStartTime);
2574  SetTestData(packet, testData, testDataLength, false);
2575  return true;
2576  }
2577  else return false;
2578  }
2579 
2583  const static SystemPacketType Type = SPT_Ping;
2584 
2585 private:
2586  PingPD() { }
2587 };
2588 
2589 
2590 #endif // !MESH_PACKET_DECODERS_H
NetConRespPD::SetReservedTime
static void SetReservedTime(MeshPacket &packet, uint16_t time)
Sets reserved time in DHCP table in minutes.
Definition: meshPacketDecoders.h:1493
RelNetConRespPD::GetReservedTime
static uint16_t GetReservedTime(const MeshPacket &packet)
Gets reserved time in DHCP table in minutes.
Definition: meshPacketDecoders.h:1929
MeshNetScanResult
Structure, which holds network scan result.
Definition: meshPacketFlags.h:452
RelNetConRespPD::SetFlags
static void SetFlags(MeshPacket &packet, uint16_t flags)
Sets network connect flags.
Definition: meshPacketDecoders.h:1846
MeshNetScanResult::Address
uint8_t Address
Address of node.
Definition: meshPacketFlags.h:461
NetScanRespPD::GetSSIDLength
static uint16_t GetSSIDLength(const MeshPacket &packet)
Gets length of SSID.
Definition: meshPacketDecoders.h:1008
RelNetConRespPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:1808
NetScanRespPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:855
MeshPingFlags
Ping packets flags.
Definition: meshPacketFlags.h:374
NetConRespPD::GetReservedTime
static uint16_t GetReservedTime(const MeshPacket &packet)
Gets reserved time in DHCP table in minutes.
Definition: meshPacketDecoders.h:1483
PathDiscRespPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:2126
PingPD::GetPingID
static uint32_t GetPingID(const MeshPacket &packet)
Gets ping packet ID.
Definition: meshPacketDecoders.h:2410
RelNetConRequestPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:1653
ACKPD::GetACK_Source
static uint8_t GetACK_Source(const MeshPacket &packet)
Gets Source of packet (which with ID creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:90
ERR_ACKPD::GetACK_Source
static uint8_t GetACK_Source(const MeshPacket &packet)
Gets Source of packet (which with ID creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:342
PathDiscRespPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshMAC MAC, uint8_t ReqID)
Constructs packet of current type.
Definition: meshPacketDecoders.h:2211
NetConRequestPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:1314
PingPD::GetFlags
static MeshPingFlags GetFlags(const MeshPacket &packet)
Gets ping packet flags. First flags says, if current packet is response or request.
Definition: meshPacketDecoders.h:2370
EAET_SameFrameReceived
@ EAET_SameFrameReceived
Definition: meshPacketDecoders.h:261
DisconnectPD
Static class, that groups static methods to decode node disconnect packet.
Definition: meshPacketDecoders.h:2249
MeshFrameControl::RoutingEnabled
volatile bool RoutingEnabled
Enables or disables routing. When routing is enabled, packet will contain address of next node,...
Definition: meshPacketFlags.h:51
PingPD::SetFlags
static void SetFlags(MeshPacket &packet, MeshPingFlags flags)
Sets ping packet flags. First flags says, if current packet is response or request.
Definition: meshPacketDecoders.h:2380
RelNetConRespPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC requesterMAC, uint8_t address, uint16_t time)
Constructs packet of current type.
Definition: meshPacketDecoders.h:1954
RelNetConRespPD::RelNetConRespPD
RelNetConRespPD()
Definition: meshPacketDecoders.h:2007
NetScanRequestPD::SetFlags
static void SetFlags(MeshPacket &packet, MeshNetScanFlags flags)
Sets network scan flags.
Definition: meshPacketDecoders.h:706
NetScanRespPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:830
NetScanRespPD
Static class, that groups static methods to decode network scan response packet.
Definition: meshPacketDecoders.h:823
PingPD::SetRandomTestData
static bool SetRandomTestData(MeshPacket &packet, int16_t length, bool resize=true)
Sets random test data to ping packet.
Definition: meshPacketDecoders.h:2501
NetConRequestPD
Static class, that groups static methods to decode network connection request packet.
Definition: meshPacketDecoders.h:1172
NetConRespPD::SetForeignNetBSSID
static void SetForeignNetBSSID(MeshPacket &packet, MeshMAC foreignBSSID)
Sets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:1419
ACKPD::GetExpectedFrameSize
static uint8_t GetExpectedFrameSize(const uint8_t *frameData)
Gets size of frame, which is expected to be received after this acknowledgement. Designed for packet ...
Definition: meshPacketDecoders.h:113
RelNetConRespPD::SetRefuseReason
static void SetRefuseReason(MeshPacket &packet, NetConRespRefuseReason reason)
Sets refuse reason when connection was refused.
Definition: meshPacketDecoders.h:1919
NetConRespPD::GetSSIDLength
static uint16_t GetSSIDLength(const MeshPacket &packet)
Gets length of SSID.
Definition: meshPacketDecoders.h:1538
MeshFrameControl::SystemPacket
volatile bool SystemPacket
True when current packet is system packet.
Definition: meshPacketFlags.h:64
NetConRespPD::SetSSID
static bool SetSSID(MeshPacket &packet, const char *SSID, uint8_t SSID_length, bool resize=true)
Sets SSID of network to packet.
Definition: meshPacketDecoders.h:1551
BROADCAST_MESH_ADDRESS
#define BROADCAST_MESH_ADDRESS
Address, that is used for broadcast. Not implemented yet.
Definition: meshConfig.h:50
NetConRespPD::SetFlags
static void SetFlags(MeshPacket &packet, uint16_t flags)
Sets network connect flags.
Definition: meshPacketDecoders.h:1389
PingPD::PingPD
PingPD()
Definition: meshPacketDecoders.h:2586
PingPD::SetPingID
static void SetPingID(MeshPacket &packet, uint8_t pingID)
Sets ping packet ID.
Definition: meshPacketDecoders.h:2420
ERR_ACKPD::IsForeignNet
static bool IsForeignNet(const MeshPacket &packet)
Checks if frame is for foreign network.
Definition: meshPacketDecoders.h:440
ERR_ACKPD::GetACK_ID
static uint8_t GetACK_ID(const MeshPacket &packet)
Gets ID of packet (which with Source creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:322
NetScanRequestPD::SetNetVersion
static void SetNetVersion(MeshPacket &packet, MeshVersion version)
Sets version of used MeshNet.
Definition: meshPacketDecoders.h:676
RelNetConRequestPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:1677
NetScanRequestPD::GetNetVersion
static MeshVersion GetNetVersion(const MeshPacket &packet)
Gets version of used MeshNet.
Definition: meshPacketDecoders.h:666
ACKPD::IsForeignNet
static bool IsForeignNet(uint8_t frameDataSize)
Checks if frame is for foreign network. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:153
PingPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshPingFlags flags, uint32_t pingStartTime, const uint8_t *testData, int16_t testDataLength)
Constructs packet of current type.
Definition: meshPacketDecoders.h:2561
NetScanRespPD::GetSSIDPtr
static char * GetSSIDPtr(const MeshPacket &packet)
Gets pointer to network SSID. The SSID is not null terminated, that's why you have to check itslength...
Definition: meshPacketDecoders.h:974
MNDPT_DisconnectRequest
@ MNDPT_DisconnectRequest
Definition: meshPacketDecoders.h:2241
RelNetConRespPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:1822
MeshMAC::octet3
uint8_t octet3
Third octet of MeshMAC address.
Definition: meshHelper.h:216
MeshPacket::GetSystemPacketType
SystemPacketType GetSystemPacketType() const
Gets type of system packet.
Definition: meshPacket.cpp:119
ACKPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:40
PingPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:2583
EAET_InvalidPacket
@ EAET_InvalidPacket
Definition: meshPacketDecoders.h:267
NetScanRequestPD::SetResponder
static void SetResponder(MeshPacket &packet, MeshMAC responder)
Sets responder BSSID or MAC address. To check if responder is BSSID or MAC, call GetFlags() methods a...
Definition: meshPacketDecoders.h:755
ACKPD::SetACK_ID
static void SetACK_ID(MeshPacket &packet, uint8_t ACK_ID)
Sets ID of packet (which with Souce creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:80
NetScanRespPD::GetSSID
static bool GetSSID(const MeshPacket &packet, char *SSID, uint8_t &SSID_length)
Copyies SSID from packet to buffer. The SSID is null terminated here. If IsDisconnectedNode() method ...
Definition: meshPacketDecoders.h:987
EAET_FrameOrderError
@ EAET_FrameOrderError
Definition: meshPacketDecoders.h:264
RelNetConRequestPD::GetRequesterMAC
static MeshMAC GetRequesterMAC(const MeshPacket &packet)
Gets MAC address of node, which requests network connection.
Definition: meshPacketDecoders.h:1711
NetScanRespPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshVersion version, MeshNodeDescFlags flags, MeshMAC foreignBSSID, uint8_t hops)
Constructs packet of current type. Use this method when node is not connected to any network.
Definition: meshPacketDecoders.h:1107
ACKPD
Static class, that groups static methods to decode ACK packet.
Definition: meshPacketDecoders.h:23
NetScanRequestPD
Static class, that groups static methods to decode network scan request packet.
Definition: meshPacketDecoders.h:620
NetConRespPD
Static class, that groups static methods to decode network connection response packet.
Definition: meshPacketDecoders.h:1333
RelNetConRespPD::SetRequesterMAC
static void SetRequesterMAC(MeshPacket &packet, MeshMAC requesterMAC)
SetsMAC address of node, which requests network connection.
Definition: meshPacketDecoders.h:1866
ACKPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, MeshMAC foreignBSSID, uint8_t ExpectedSize=0)
Constructs packet of current type.
Definition: meshPacketDecoders.h:227
ACKPD::ACKPD
ACKPD()
Definition: meshPacketDecoders.h:250
PathDiscPD::GetMAC
static MeshMAC GetMAC(const MeshPacket &packet)
Gets MAC address of node, which evoked packet discovery.
Definition: meshPacketDecoders.h:2064
UNKNOWN_MESH_ADDRESS
#define UNKNOWN_MESH_ADDRESS
Address, of node, when node is not connected to any network.
Definition: meshConfig.h:62
NetConRequestPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:1204
ERR_ACKPD::GetExpectedFrameSize
static uint8_t GetExpectedFrameSize(const uint8_t *frameData)
Gets size of frame, which is expected to be received after this acknowledgement. Designed for packet ...
Definition: meshPacketDecoders.h:365
MeshMAC::octet1
uint8_t octet1
First octet of MeshMAC address.
Definition: meshHelper.h:226
NetConRequestPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:1179
PathDiscPD::SetMAC
static void SetMAC(MeshPacket &packet, MeshMAC MAC)
Sets MAC address of node, which evoked packet discovery.
Definition: meshPacketDecoders.h:2074
DisconnectPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:2256
ACKPD::SetExpectedFrameSize
static void SetExpectedFrameSize(MeshPacket &packet, uint8_t ExpectedSize)
Sets size of frame, which is expected to be received after this acknowledgement. This has to be used,...
Definition: meshPacketDecoders.h:139
ERR_ACK_ErrorCode
ERR_ACK_ErrorCode
Definition: meshPacketDecoders.h:258
RelNetConRequestPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:1779
PingPD::GetTestDataLength
static int16_t GetTestDataLength(const MeshPacket &packet)
Gets length of test data.
Definition: meshPacketDecoders.h:2461
NetScanRespPD::GetFlags
static MeshNodeDescFlags GetFlags(const MeshPacket &packet)
Gets network scan response flags.
Definition: meshPacketDecoders.h:889
RelNetConRequestPD::GetNetVersion
static MeshVersion GetNetVersion(const MeshPacket &packet)
Gets version of used MeshNet.
Definition: meshPacketDecoders.h:1734
PingPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshPingFlags flags, uint32_t pingStartTime, int16_t testDataLength=0)
Constructs packet of current type.
Definition: meshPacketDecoders.h:2531
NetScanRequestPD::GetResponder
static MeshMAC GetResponder(const uint8_t *frameData)
Gets responder BSSID or MAC address. To check if responder is BSSID or MAC, call GetFlags() methods a...
Definition: meshPacketDecoders.h:744
ACKPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:247
DisconnectPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:2328
ERR_ACKPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, MeshMAC foreignBSSID, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue=0)
Constructs packet of current type.
Definition: meshPacketDecoders.h:555
RelNetConRespPD::SetAssignedAddr
static void SetAssignedAddr(MeshPacket &packet, uint8_t address)
Sets address assigned to node which requested connection.
Definition: meshPacketDecoders.h:1889
MeshPacket::PacketHeader
MeshPacketHeader PacketHeader
Mesh packet header.
Definition: meshPacket.h:192
ERR_ACKPD::SetRepairValue
static void SetRepairValue(MeshPacket &packet, uint8_t RepairValue)
Sets value, that can be used for solving the error. Some error codes does not contains this value.
Definition: meshPacketDecoders.h:433
MeshFrameControl::RelayingEnabled
volatile bool RelayingEnabled
Enables or disables relaying. When relaying is enabled, can be relayied to nodes, which are not neigh...
Definition: meshPacketFlags.h:58
DisconnectPD::SetDisconnectType
static void SetDisconnectType(MeshPacket &packet, MeshNetDisconnectPacketType disconnectType)
Sets disconnect packet type.
Definition: meshPacketDecoders.h:2291
NetScanRespPD::SetHopsToGateway
static void SetHopsToGateway(MeshPacket &packet, uint8_t hops)
Sets hop count of node to its gateway connection.
Definition: meshPacketDecoders.h:963
RelNetConRequestPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:1663
NetScanRequestPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, MeshVersion version, MeshNetScanFlags flags, MeshMAC responder)
Constructs packet of current type.
Definition: meshPacketDecoders.h:793
PathDiscRespPD::SetMAC
static void SetMAC(MeshPacket &packet, MeshMAC MAC)
Sets MAC address of node, which evoked packet discovery.
Definition: meshPacketDecoders.h:2175
NetConRespPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:1350
ERR_ACKPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, MeshMAC foreignBSSID, uint8_t ExpectedSize, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue=0)
Constructs packet of current type.
Definition: meshPacketDecoders.h:587
NetConRespPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:1365
MeshNetDisconnectPacketType
MeshNetDisconnectPacketType
Definition: meshPacketDecoders.h:2239
PathDiscPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshMAC MAC)
Constructs packet of current type.
Definition: meshPacketDecoders.h:2089
EAET_None
@ EAET_None
Definition: meshPacketDecoders.h:259
NetScanRequestPD::GetResponder
static MeshMAC GetResponder(const MeshPacket &packet)
Gets responder BSSID or MAC address. To check if responder is BSSID or MAC, call GetFlags() methods a...
Definition: meshPacketDecoders.h:733
PathDiscRespPD::GetReqID
static uint8_t GetReqID(const MeshPacket &packet)
Gets ID of path discovery packet, this response belongs to.
Definition: meshPacketDecoders.h:2188
ERR_ACKPD::SetForeignNetBSSID
static void SetForeignNetBSSID(MeshPacket &packet, MeshMAC foreignBSSID)
Sets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:477
RelNetConRespPD::GetRequesterMAC
static MeshMAC GetRequesterMAC(const MeshPacket &packet)
Gets MAC address of node, which requests network connection.
Definition: meshPacketDecoders.h:1856
meshPacket.h
This file contains class which can be used to handling mesh packets.
PathDiscRespPD::PathDiscRespPD
PathDiscRespPD()
Definition: meshPacketDecoders.h:2234
NetConRequestPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const MeshPacket &packet)
Gets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:1238
PingPD::SetTestData
static bool SetTestData(MeshPacket &packet, const uint8_t *testData, int16_t length, bool resize=true)
Sets test data to ping packet.
Definition: meshPacketDecoders.h:2474
MeshNetScanResult::Flags
MeshNodeDescFlags Flags
Mesh node description flags, which describes every node.
Definition: meshPacketFlags.h:469
RelNetConRequestPD::SetNetVersion
static void SetNetVersion(MeshPacket &packet, MeshVersion version)
Sets version of used MeshNet.
Definition: meshPacketDecoders.h:1744
NetScanRespPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const uint8_t *frameData)
Gets BSSID of foreign network, which has to receive this frame. Designed for packet header checking i...
Definition: meshPacketDecoders.h:919
NetConRequestPD::GetNetVersion
static MeshVersion GetNetVersion(const MeshPacket &packet)
Gets version of used MeshNet.
Definition: meshPacketDecoders.h:1271
EAET_FrameSizeExceeded
@ EAET_FrameSizeExceeded
Definition: meshPacketDecoders.h:262
ERR_ACKPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:609
NetConRespPD::IsRefusedConnection
static bool IsRefusedConnection(MeshPacket &packet)
Checks if connection is refused.
Definition: meshPacketDecoders.h:1450
RelNetConRespPD
Static class, that groups static methods to decode relayied network connection response packet.
Definition: meshPacketDecoders.h:1791
NetConRequestPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshNodeDescFlags flags, MeshMAC foreignBSSID, MeshVersion version)
Constructs packet of current type.
Definition: meshPacketDecoders.h:1295
NetScanRespPD::SetForeignNetBSSID
static void SetForeignNetBSSID(MeshPacket &packet, MeshMAC foreignBSSID)
Sets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:929
NetConRespRefuseReason
NetConRespRefuseReason
Definition: meshPacketDecoders.h:1321
NetConRequestPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const uint8_t *frameData)
Gets BSSID of foreign network, which has to receive this frame. Designed for packet header checking i...
Definition: meshPacketDecoders.h:1248
ERR_ACKPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const uint8_t *frameData)
Gets BSSID of foreign network, which has to receive this frame. Designed for packet header checking i...
Definition: meshPacketDecoders.h:467
PathDiscRespPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:2151
NetScanRespPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const MeshPacket &packet)
Gets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:909
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
RelNetConRespPD::GetAssignedAddr
static uint8_t GetAssignedAddr(const MeshPacket &packet)
Gets address assigned to node which requested connection.
Definition: meshPacketDecoders.h:1879
ERR_ACKPD::SetACK_ID
static void SetACK_ID(MeshPacket &packet, uint8_t ACK_ID)
Sets ID of packet (which with Source creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:332
NetConRespPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const uint8_t *frameData)
Gets BSSID of foreign network, which has to receive this frame. Designed for packet header checking i...
Definition: meshPacketDecoders.h:1409
PathDiscRespPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:2136
ACKPD::SetACK_Source
static void SetACK_Source(MeshPacket &packet, uint8_t ACK_Source)
Sets Source of packet (which with ID creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:100
RelNetConRespPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:2004
NetConRespPD::GetAssignedAddr
static uint8_t GetAssignedAddr(const MeshPacket &packet)
Gets address assigned to node which requested connection.
Definition: meshPacketDecoders.h:1432
ERR_ACKPD::IsForeignNet
static bool IsForeignNet(uint8_t frameDataSize)
Checks if frame is for foreign network. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:447
ERR_ACKPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue=0)
Constructs packet of current type.
Definition: meshPacketDecoders.h:495
ERR_ACKPD::GetErrorCode
static ERR_ACK_ErrorCode GetErrorCode(const MeshPacket &packet)
Gets error code, that describes error.
Definition: meshPacketDecoders.h:402
NetConRespPD::SetAssignedAddr
static void SetAssignedAddr(MeshPacket &packet, uint8_t address)
Sets address assigned to node which requested connection.
Definition: meshPacketDecoders.h:1442
RelNetConRespPD::SetReservedTime
static void SetReservedTime(MeshPacket &packet, uint16_t time)
Sets reserved time in DHCP table in minutes.
Definition: meshPacketDecoders.h:1939
RelNetConRequestPD::SetFlags
static void SetFlags(MeshPacket &packet, MeshNodeDescFlags flags)
Sets network connect flags.
Definition: meshPacketDecoders.h:1701
MeshPacket::ResizePayload
bool ResizePayload(uint16_t size, bool doNotCopy=false)
Resizes payload.
Definition: meshPacket.cpp:150
NetScanRequestPD::HasResponder
static bool HasResponder(const MeshPacket &packet)
Checks if frame has specified responder. If responder BSSID is specified, only nodes with that BSSID ...
Definition: meshPacketDecoders.h:714
MeshPacket::p_ptr
const uint8_t * p_ptr() const
Pointer to payload.
Definition: meshPacket.h:315
DisconnectPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshNetDisconnectPacketType disconnectType)
Constructs packet of current type.
Definition: meshPacketDecoders.h:2303
MeshPacketHeader::FrameControl
MeshFrameControl FrameControl
Contains flags, that controls frame.
Definition: meshPacket.h:49
PingPD
Static class, that groups static methods to decode ping packet.
Definition: meshPacketDecoders.h:2339
MeshNetScanResult::BSSID
MeshMAC BSSID
BSSID of network, the node which responsed is connected to. If node is not connected to any network (...
Definition: meshPacketFlags.h:457
NetConRequestPD::NetConRequestPD
NetConRequestPD()
Definition: meshPacketDecoders.h:1317
MeshPacketHeader::Destination
uint8_t Destination
Address of destination source node.
Definition: meshPacket.h:72
PathDiscRespPD::GetMAC
static MeshMAC GetMAC(const MeshPacket &packet)
Gets MAC address of node, which evoked packet discovery.
Definition: meshPacketDecoders.h:2165
DisconnectPD::DisconnectPD
DisconnectPD()
Definition: meshPacketDecoders.h:2331
PingPD::GetTestDataPtr
static uint8_t * GetTestDataPtr(const MeshPacket &packet)
Gets pointer to test data in ping packet.
Definition: meshPacketDecoders.h:2430
NetScanRequestPD::GetFlags
static MeshNetScanFlags GetFlags(const MeshPacket &packet)
Gets network scan flags.
Definition: meshPacketDecoders.h:686
NetScanRequestPD::HasResponder
static bool HasResponder(uint8_t frameDataSize)
Checks if frame has specified responder. If responder BSSID is specified, only nodes with that BSSID ...
Definition: meshPacketDecoders.h:722
PathDiscPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:2025
EAET_PacketResendNeeded
@ EAET_PacketResendNeeded
Definition: meshPacketDecoders.h:266
MeshNetScanResult::SSID_length
uint8_t SSID_length
Length of SSID without null terminator. If node is not connected to any network, 0 is set.
Definition: meshPacketFlags.h:482
SPT_NetScan
typedef SPT_NetScan
Definition: meshPacket.h:22
ACKPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const uint8_t *frameData)
Gets BSSID of foreign network, which has to receive this frame. Designed for packet header checking i...
Definition: meshPacketDecoders.h:173
SPT_Disconnect
typedef SPT_Disconnect
Definition: meshPacket.h:26
RelNetConRespPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:1798
NetScanRequestPD::NetScanRequestPD
NetScanRequestPD()
Definition: meshPacketDecoders.h:814
ERR_ACKPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:292
NetScanRequestPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:811
NetConRespPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:1633
RelNetConRequestPD::RelNetConRequestPD
RelNetConRequestPD()
Definition: meshPacketDecoders.h:1782
MeshNodeDescFlags
Mesh node description flags, which describes every node on connection or when scan is performed.
Definition: meshPacketFlags.h:299
NetScanRespPD::SetFlags
static void SetFlags(MeshPacket &packet, MeshNodeDescFlags flags)
Sets network scan flags.
Definition: meshPacketDecoders.h:899
ERR_ACKPD::SetACK_Source
static void SetACK_Source(MeshPacket &packet, uint8_t ACK_Source)
Sets Source of packet (which with ID creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:352
RelNetConRequestPD
Static class, that groups static methods to decode relayied network connection request packet.
Definition: meshPacketDecoders.h:1646
ERR_ACKPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, uint8_t ExpectedSize, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue=0)
Constructs packet of current type.
Definition: meshPacketDecoders.h:525
NetConRespPD::GetFlags
static uint16_t GetFlags(const MeshPacket &packet)
Gets network connect flags.
Definition: meshPacketDecoders.h:1379
ERR_ACKPD::SetErrorCode
static void SetErrorCode(MeshPacket &packet, ERR_ACK_ErrorCode ErrorCode)
Sets error code, that describes error.
Definition: meshPacketDecoders.h:413
NetScanRespPD::GetHopsToGateway
static uint8_t GetHopsToGateway(const MeshPacket &packet)
Gets hop count of node to its gateway connection.
Definition: meshPacketDecoders.h:942
EAET_SamePacketReceived
@ EAET_SamePacketReceived
Definition: meshPacketDecoders.h:260
PingPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:2346
MeshPacketHeader::From
uint8_t From
Address of neighbor node, which last time relayied current packet.
Definition: meshPacket.h:77
NetConRequestPD::SetForeignNetBSSID
static void SetForeignNetBSSID(MeshPacket &packet, MeshMAC foreignBSSID)
Sets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:1258
NetConRespPD::ConstructRefused
static bool ConstructRefused(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC foreignBSSID, NetConRespRefuseReason reason)
Constructs refused connection response packet of current type.
Definition: meshPacketDecoders.h:1614
NetScanRequestPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:637
MeshNetScanResult::Version
MeshVersion Version
MeshNet version, the node is using.
Definition: meshPacketFlags.h:465
MeshNetScanResult::HopsToGateway
uint8_t HopsToGateway
Hops from current node to gateway. If node is gateway (Address == 0) 0 is set.
Definition: meshPacketFlags.h:473
PathDiscPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:2035
ERR_ACKPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:308
MeshMAC
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
ACKPD::GetExpectedFrameSize
static uint8_t GetExpectedFrameSize(const MeshPacket &packet)
Gets size of frame, which is expected to be received after this acknowledgement. This has to be used,...
Definition: meshPacketDecoders.h:126
NetScanRespPD::SetNetVersion
static void SetNetVersion(MeshPacket &packet, MeshVersion version)
Sets version of used MeshNet.
Definition: meshPacketDecoders.h:879
NetConRespPD::NetConRespPD
NetConRespPD()
Definition: meshPacketDecoders.h:1636
ACKPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const MeshPacket &packet)
Gets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:163
DisconnectPD::GetDisconnectType
static MeshNetDisconnectPacketType GetDisconnectType(const MeshPacket &packet)
Gets disconnect packet type.
Definition: meshPacketDecoders.h:2281
PingPD::GetTestData
static bool GetTestData(const MeshPacket &packet, uint8_t *testData, int16_t &length)
Copyies test data from ping packet to buffer.
Definition: meshPacketDecoders.h:2442
PathDiscPD
Static class, that groups static methods to decode path discovery packet.
Definition: meshPacketDecoders.h:2018
NetConRequestPD::SetFlags
static void SetFlags(MeshPacket &packet, MeshNodeDescFlags flags)
Sets network connect flags.
Definition: meshPacketDecoders.h:1228
ERR_ACKPD::GetExpectedFrameSize
static uint8_t GetExpectedFrameSize(const MeshPacket &packet)
Gets size of frame, which is expected to be received after this acknowledgement. This has to be used,...
Definition: meshPacketDecoders.h:378
INVALID_MESH_ADDRESS
#define INVALID_MESH_ADDRESS
Address, that is invalid and cannot be used.
Definition: meshConfig.h:56
PingPD::GetPingStartTime
static uint32_t GetPingStartTime(const MeshPacket &packet)
Gets time, when ping was sent.
Definition: meshPacketDecoders.h:2390
MeshPacketHeader
This structure contains informations about mesh packet, that are stored in it's header.
Definition: meshPacket.h:42
NetConRespPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC foreignBSSID, uint8_t address, uint16_t time, const char *SSID, uint8_t SSID_length)
Constructs packet of current type.
Definition: meshPacketDecoders.h:1583
NetConRespPD::SetRefuseReason
static void SetRefuseReason(MeshPacket &packet, NetConRespRefuseReason reason)
Sets refuse reason when connection was refused.
Definition: meshPacketDecoders.h:1473
SPT_ERR_ACK
typedef SPT_ERR_ACK
Definition: meshPacket.h:21
NetScanRespPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:1159
ACKPD::IsForeignNet
static bool IsForeignNet(const MeshPacket &packet)
Checks if frame is for foreign network.
Definition: meshPacketDecoders.h:146
MeshPacket::Length
uint16_t Length() const
Length of payload.
Definition: meshPacket.h:197
MeshPacketHeader::Hops
uint8_t Hops
Count of hops, that message done during transmission. Source MNode has 0 hops, next one 1 hop,...
Definition: meshPacket.h:87
NetScanRequestPD::GetFlags
static MeshNetScanFlags GetFlags(const uint8_t *frameData)
Gets network scan flags.
Definition: meshPacketDecoders.h:696
ACKPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint8_t ACK_ID, uint8_t ACK_Source, uint8_t ExpectedSize=0)
Constructs packet of current type.
Definition: meshPacketDecoders.h:200
SPT_Connect
typedef SPT_Connect
Definition: meshPacket.h:23
PathDiscPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:2108
NetScanRespPD::GetNetVersion
static MeshVersion GetNetVersion(const MeshPacket &packet)
Gets version of used MeshNet.
Definition: meshPacketDecoders.h:869
PathDiscPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:2050
NetScanRespPD::SetSSID
static bool SetSSID(MeshPacket &packet, const char *SSID, uint8_t SSID_length, bool resize=true)
Sets SSID of network to packet.
Definition: meshPacketDecoders.h:1021
PathDiscRespPD::SetReqID
static void SetReqID(MeshPacket &packet, uint8_t ReqID)
Sets ID of path discovery packet, this response belongs to.
Definition: meshPacketDecoders.h:2198
NetScanRespPD::GetResult
static MeshNetScanResult GetResult(const MeshPacket &packet, MeshMAC BSSID)
Converts data from packet to MeshNetScanResult.
Definition: meshPacketDecoders.h:1046
RelNetConRespPD::IsRefusedConnection
static bool IsRefusedConnection(MeshPacket &packet)
Checks if connection is refused.
Definition: meshPacketDecoders.h:1896
PingPD::SetPingStartTime
static void SetPingStartTime(MeshPacket &packet, uint32_t pingStartTime)
Sets time, when ping was sent.
Definition: meshPacketDecoders.h:2400
NetConRespPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const MeshPacket &packet)
Gets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:1399
NetConRequestPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:1189
NetConRequestPD::GetFlags
static MeshNodeDescFlags GetFlags(const MeshPacket &packet)
Gets network connect flags.
Definition: meshPacketDecoders.h:1218
ERR_ACKPD::SetExpectedFrameSize
static void SetExpectedFrameSize(MeshPacket &packet, uint8_t ExpectedSize)
Sets size of frame, which is expected to be received after this acknowledgement. This has to be used,...
Definition: meshPacketDecoders.h:391
MESH_PACKET_PAYLOAD_SIZE_LIMIT
#define MESH_PACKET_PAYLOAD_SIZE_LIMIT
Mesh packet payload size limit in bytes. Protects memory from large space allocation.
Definition: meshConfig.h:116
PathDiscPD::PathDiscPD
PathDiscPD()
Definition: meshPacketDecoders.h:2111
MeshNetScanResult::SSID_ptr
char * SSID_ptr
Pointer to network name (SSID). If node is not connected to any network, NULL is set.
Definition: meshPacketFlags.h:478
PathDiscRespPD
Static class, that groups static methods to decode path discovery response packet.
Definition: meshPacketDecoders.h:2119
ACKPD::SetForeignNetBSSID
static void SetForeignNetBSSID(MeshPacket &packet, MeshMAC foreignBSSID)
Sets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:183
MNDPT_Disconnecting
@ MNDPT_Disconnecting
Definition: meshPacketDecoders.h:2240
NetConRequestPD::SetNetVersion
static void SetNetVersion(MeshPacket &packet, MeshVersion version)
Sets version of used MeshNet.
Definition: meshPacketDecoders.h:1281
NetConRespPD::GetSSID
static bool GetSSID(const MeshPacket &packet, char *SSID, uint8_t &SSID_length)
Copyies SSID from packet to buffer. The SSID is null terminated here. If IsRefusedConnection() method...
Definition: meshPacketDecoders.h:1517
NetScanRequestPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, MeshVersion version, MeshNetScanFlags flags)
Constructs packet of current type.
Definition: meshPacketDecoders.h:770
RelNetConRequestPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshNodeDescFlags flags, MeshMAC requesterMAC, MeshVersion version)
Constructs packet of current type.
Definition: meshPacketDecoders.h:1758
NetScanRequestPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:652
ERR_ACKPD::GetRepairValue
static uint8_t GetRepairValue(const MeshPacket &packet)
Gets value, that can be used for solving the error. Some error codes does not contains this value.
Definition: meshPacketDecoders.h:423
NCRRR_Refused
@ NCRRR_Refused
Definition: meshPacketDecoders.h:1323
RelNetConRespPD::GetRefuseReason
static NetConRespRefuseReason GetRefuseReason(MeshPacket &packet)
Gets refuse reason when connection was refused.
Definition: meshPacketDecoders.h:1904
SPT_PathDiscovery
typedef SPT_PathDiscovery
Definition: meshPacket.h:28
NetScanRespPD::NetScanRespPD
NetScanRespPD()
Definition: meshPacketDecoders.h:1162
ERR_ACKPD
Static class, that groups static methods to decode ERR_ACK packet.
Definition: meshPacketDecoders.h:274
PathDiscRespPD::Type
const static SystemPacketType Type
Type of system packet, that can be decoded with current decoder.
Definition: meshPacketDecoders.h:2231
NCRRR_Full
@ NCRRR_Full
Definition: meshPacketDecoders.h:1324
RelNetConRequestPD::GetFlags
static MeshNodeDescFlags GetFlags(const MeshPacket &packet)
Gets network connect flags.
Definition: meshPacketDecoders.h:1691
NetScanRespPD::Construct
static bool Construct(MeshPacket &packet, uint8_t destAddr, const MeshNetScanResult &result, MeshMAC foreignBSSID)
Constructs packet of current type.
Definition: meshPacketDecoders.h:1133
ACKPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:30
RelNetConRequestPD::SetRequesterMAC
static void SetRequesterMAC(MeshPacket &packet, MeshMAC requesterMAC)
SetsMAC address of node, which requests network connection.
Definition: meshPacketDecoders.h:1721
MNDPT_NetworkDrop
@ MNDPT_NetworkDrop
Definition: meshPacketDecoders.h:2242
NetConRespPD::GetRefuseReason
static NetConRespRefuseReason GetRefuseReason(MeshPacket &packet)
Gets refuse reason when connection was refused.
Definition: meshPacketDecoders.h:1458
NetScanRespPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:840
NetScanRespPD::IsDisconnectedNode
static bool IsDisconnectedNode(const MeshPacket &packet)
Checks if node is connected to any network or not. If this returns true, the BSSID of network which i...
Definition: meshPacketDecoders.h:953
MeshMAC::octet2
uint8_t octet2
Second octet of MeshMAC address.
Definition: meshHelper.h:221
EAET_AllocationError
@ EAET_AllocationError
Definition: meshPacketDecoders.h:265
RelNetConRespPD::ConstructRefused
static bool ConstructRefused(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC requesterMAC, NetConRespRefuseReason reason)
Constructs refused connection response packet of current type.
Definition: meshPacketDecoders.h:1983
ERR_ACKPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:282
PingPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:2356
ERR_ACKPD::ERR_ACKPD
ERR_ACKPD()
Definition: meshPacketDecoders.h:612
SPT_Ping
typedef SPT_Ping
Definition: meshPacket.h:29
NetScanRespPD::Construct
static bool Construct(MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshVersion version, MeshNodeDescFlags flags, MeshMAC foreignBSSID, uint8_t hops, const char *SSID, uint8_t SSID_length)
Constructs packet of current type. Use this method when node is connected to some network.
Definition: meshPacketDecoders.h:1075
ACKPD::IsValid
static bool IsValid(const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.
Definition: meshPacketDecoders.h:56
MeshVersion
Structure that represents MeshNet version. Real size of this class is always 2 bytes.
Definition: meshHelper.h:310
NetConRespPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:1340
RelNetConRespPD::GetFlags
static uint16_t GetFlags(const MeshPacket &packet)
Gets network connect flags.
Definition: meshPacketDecoders.h:1836
ERR_ACKPD::GetForeignNetBSSID
static MeshMAC GetForeignNetBSSID(const MeshPacket &packet)
Gets BSSID of foreign network, which has to receive this frame.
Definition: meshPacketDecoders.h:457
NCRRR_None
@ NCRRR_None
Definition: meshPacketDecoders.h:1322
MeshPacketHeader::Source
uint8_t Source
Address of message source node.
Definition: meshPacket.h:67
MeshMAC::octet4
uint8_t octet4
Fourth octet of MeshMAC address.
Definition: meshHelper.h:211
NetConRespPD::GetSSIDPtr
static char * GetSSIDPtr(const MeshPacket &packet)
Gets pointer to network SSID. The SSID is not null terminated, that's why you have to check itslength...
Definition: meshPacketDecoders.h:1504
MeshNetScanFlags
Network scan request flags.
Definition: meshPacketFlags.h:187
DisconnectPD::IsValid
static bool IsValid(const MeshPacket &packet)
Checks if packet is valid.
Definition: meshPacketDecoders.h:2266
NetScanRequestPD::IsSameType
static bool IsSameType(const MeshPacket &packet)
Checks if system packet type match decoder type, but does not check its validity.
Definition: meshPacketDecoders.h:627
NCRRR_Error
@ NCRRR_Error
Definition: meshPacketDecoders.h:1325
EAET_PacketSizeExceeded
@ EAET_PacketSizeExceeded
Definition: meshPacketDecoders.h:263
ACKPD::GetACK_ID
static uint8_t GetACK_ID(const MeshPacket &packet)
Gets ID of packet (which with Souce creates unique packet identifier), that is being acknowledged.
Definition: meshPacketDecoders.h:70