MeshNet  1.0.0
mesh.h
Go to the documentation of this file.
1 
14 #ifndef MESH_h
15 #define MESH_h
16 
17 #include <meshPacket.h>
18 #include <meshTables.h>
19 #include <meshBuffers.h>
20 #include <meshPacketBuilder.h>
21 #include <meshPacketSplitter.h>
22 #include <meshPacketDecoders.h>
23 #include <RFInterface.h>
24 
25 #ifndef SIMULATION
26 #include <wirish.h>
27 #else
28 #include <mutex>
29 #endif
30 
31 #if MESH_IMPL_CONSOLE_ITEM == 1
32 #include <SerialConsole.h>
33 #endif
34 
38 
43 typedef enum {
50 
55 typedef enum {
56  MDR_None = 0,
58  //Connection reasons - BEGIN
65  //Connection reasons - END
66 
67  //Disconnect reasons - BEGIN
71  //Disconnect reasons - END
72 
73  MDR_Unknown = 255,
75 
80 typedef enum {
81  MPE_OK = 0,
83  MPE_Timeout = -2,
84  MPE_NodeLost = -3,
89  MPE_NoRoute = -8,
90  MPE_Invalid = -9,
91  MPE_GenErr = -10,
92  MPE_AllocErr = -11
94 
98 
104 class MeshNet
105 #if (MESH_IMPL_CONSOLE_ITEM == 1)
106  :public ConsoleItem
107 #endif //MESH_IMPL_CONSOLE_ITEM == 1
108 {
109 public:
110 
114 
119  MeshNet(): MeshNet(false){}
120 
124  virtual ~MeshNet();
125 
129 
137  virtual bool begin(MeshMAC mac, RFInterface& RFI);
138 
145  virtual bool begin();
146 
152  virtual bool end();
153 
155 
161  bool setChannel(uint8_t channel_);
162 
166 
168 
187  bool connect(MeshMAC netBSSID, bool autoConnect = false, uint32_t autoConnectInterval = 30000);
188 
203  bool directConnect(MeshMAC netBSSID, uint8_t interpreterAddr);
204 
216  bool disconnect();
217 
233  void setAutoConnect(MeshMAC netBSSID, uint32_t retryInterval = 60000);
234 
238  void disableAutoConnect();
239 
241 
250  bool startNetScan(void(*responseCallback)(MeshNet*, const MeshNetScanResult&), uint32_t timeout, MeshNetScanFlags flags, MeshMAC ResponderBSSID = 0);
251 
258  bool startNetScan(void(*responseCallback)(MeshNet*, const MeshNetScanResult&), uint32_t timeout = 2000);
259 
261 
280  int16_t send(uint8_t addr, const uint8_t* data, uint16_t dataSize);
281 
299  int16_t send(uint8_t addr, const MeshVariableArray<uint8_t>& data);
300 
318  int16_t send(uint8_t addr, MeshVariableArray<uint8_t>&& data);
319 
321 
339  int16_t ping(uint8_t addr, uint32_t timeout, int16_t testDataLength = 0);
340 
342 
343 #ifndef MESH_NO_STATISTICS
344 
347  void resetStatistics();
348 #endif // !MESH_NO_STATISTICS
349 
351 
355  virtual void handle();
356 
360 
362 
366  inline uint8_t getMinChannel(){
367  return rf->MinChannelNumber;
368  }
369 
373  inline uint8_t getMaxChannel(){
374  return rf->MaxChannelNumber;
375  }
376 
378 
383  inline bool isConnected() const {
385  }
386 
390  inline bool isDisconnecting() const {
392  }
393 
399  return connectionState;
400  }
401 
403 
407  inline bool netScanRunning() const{
408  return scanEndTime >= millis() && scanEndTime != 0;
409  }
410 
412 
418  inline bool pathExists(uint8_t address) const {
419  return RTable.sourceExists(address);
420  }
421 
427  inline bool pathCreating(uint8_t address) const {
429  }
430 
436  inline uint8_t getNeighborNode(uint8_t address) const {
437  int16_t ret = RTable.getNeighborFromSource(address);
438  if (IS_VALID_MESH_ADDRESS(ret)) {
439  return (uint8_t)ret;
440  }
441  else {
442  return UNKNOWN_MESH_ADDRESS;
443  }
444  }
445 
454  uint8_t availablePacketsToSend(uint8_t destAddress, bool ACK_R = false) const;
455 
461  MeshPacketStatus getPacketStatus(uint8_t ID) const;
462 
464 
468  const static MeshVersion Version;
469 
473  inline bool canBeGateway() const {
474  return canBeGateway_;
475  }
476 
481  inline bool isMainGateway() const {
482  return canBeGateway_ && AddrPriv == 0;
483  }
484 
489  inline bool isBackupGateway() const {
491  }
492 
497  inline MeshMAC getNetworkBSSID() const {
498  return NetworkBSSID;
499  }
500 
505  inline MeshMAC getNodeMAC() const {
506  return NodeMAC;
507  }
508 
513  inline uint8_t getNodeAddress() const {
514  return AddrPriv;
515  }
516 
521  return rf;
522  }
523 
525 
526 #ifndef MESH_NO_STATISTICS
527 
535  inline uint32_t getLostFramesTotalCnt() const{
536  return lostFramesTotal;
537  }
538 
546  inline uint32_t getLostFramesInNetworkCnt() const{
547  return lostFramesInNetwork;
548  }
549 
559  inline uint32_t getLostPacketsTotalCnt() const{
560  return lostPacketsTotal;
561  }
562 
572  inline uint32_t getLostPacketsInNetworkCnt() const{
573  return lostPacketsInNetwork;
574  }
575 
585  inline uint32_t getLostDataPacketsCnt() const{
586  return lostDataPackets;
587  }
588 
597  inline uint32_t getLostRemotePacketsCnt() const{
598  return lostRemotePackets;
599  }
600 
608  inline uint32_t getLostRemoteDataPacketsCnt() const{
609  return lostRemoteDataPackets;
610  }
611 
617  inline uint32_t getLostRelayiedPacketsCnt() const{
618  return lostRelayiedPackets;
619  }
620 
627  inline uint32_t getSentFramesTotalCnt() const{
628  return sentFramesTotal;
629  }
630 
636  inline uint32_t getSentFramesInNetworkCnt() const{
637  return sentFramesInNetwork;
638  }
639 
647  inline uint32_t getSentPacketsTotalCnt() const{
648  return sentPacketsTotal;
649  }
650 
657  inline uint32_t getSentPacketsInNetworkCnt() const{
658  return sentPacketsInNetwork;
659  }
660 
667  inline uint32_t getSentDataPacketsCnt() const{
668  return sentDataPackets;
669  }
670 
676  inline uint32_t getRelayiedPacketsCnt() const{
677  return relayiedPackets;
678  }
679 
680 #endif // !MESH_NO_STATISTICS
681 
683 
689  bool printRTable(OSTREAM* stream) const;
690 
696  bool printIDTable(OSTREAM* stream) const;
697 
703  bool printFIDTable(OSTREAM* stream) const;
704 
710  bool printOIDTable(OSTREAM* stream) const;
711 
717  bool printWaitingFIFO(OSTREAM* stream) const;
718 
724  bool printOutFIFO(OSTREAM* stream) const;
725 
731  size_t printMeshNetworkInfo(OSTREAM& stream) const;
732 
733 #ifndef MESH_NO_STATISTICS
734 
739  size_t printStatistics(OSTREAM& stream) const;
740 #endif // !MESH_NO_STATISTICS
741 
748  static size_t printMeshConnectionState(OSTREAM& stream, MeshConnectionState value);
749 
756  static size_t printMeshDisconnectReason(OSTREAM& stream, MeshDisconnectReason value);
757 
764  static size_t printMeshPacketError(OSTREAM& stream, MeshPacketError value);
765 
769 
771 
776  inline void setOnConnectedCallback(void(*callback)(MeshNet*)) {
777  onConnected = callback;
778  }
779 
789  inline void setOnDisconnectedCallback(void(*callback)(MeshNet*, MeshDisconnectReason, MeshMAC, uint8_t)) {
790  onDisconnected = callback;
791  }
792 
799  inline void setOnRemoteNodeDisconnectedCallback(void(*callback)(MeshNet*, uint8_t)) {
800  onRemDisconnected = callback;
801  }
802 
804 
818  inline void setOnPingResponseCallback(void(*callback)(MeshNet*, uint8_t, uint8_t, MeshPacketError, uint8_t, uint32_t, const uint8_t*, int16_t)) {
819  onPingResponse = callback;
820  }
821 
823 
834  inline void setOnPacketErrorCallback(void(*callback)(MeshNet*, MeshPacketError, uint8_t, uint8_t, const MeshPacket*)) {
835  onPacketErrorCallback = callback;
836  }
837 
845  inline void setOnReceive(void(*callback)(MeshNet*, MeshPacket&)) {
846  onReceive = callback;
847  }
848 
852 
857  inline static MeshNet** getInstances(){
858  return instances;
859  }
860 
861 #ifndef SIMULATION
862 
863 #if (MESH_IMPL_CONSOLE_ITEM == 1)
864 
866 
867  //Returns pointer to constant char array stored in flash
868  const char* getName() override;
869 
870  bool compareName(char *name, uint8_t nameLength) override;
871 
872  bool respond(SerialConsole *console, Stream *stream, CommandWords &cmd) override;
873 
874  void respondRaw(SerialConsole *console, Stream *stream, const char* value) override;
875 
876  void registerConsole(SerialConsole *console) override;
877 
878  void unregisterConsole() override;
879 
880  static void netScanResponse(MeshNet*, const MeshNetScanResult& result);
881 
882 #endif //MESH_IMPL_CONSOLE_ITEM == 1
883 
884 
885 #else
886 
888 
889  inline uint32_t millis() const {
890  return rf->millis();
891  }
892 
893  inline uint32_t micros() const {
894  return rf->micros();
895  }
896 
897  inline uint64_t micros64() const {
898  return rf->micros64();
899  }
900 
901  inline void delay(uint32_t time) const {
902  return rf->delay(time);
903  }
904 
905  inline void delayMicroseconds(uint32_t time) const {
906  return rf->delayMicroseconds(time);
907  }
908 
909  inline std::chrono::nanoseconds PauseSimulationTimer() {
910  return rf->PauseSimulationTimer();
911  }
912 
913  inline void ResumeSimulationTimer() {
914  rf->ResumeSimulationTimer();
915  }
916 
917  inline std::mutex& GetStreamMutex() {
918  return rf->GetStreamMutex();
919  }
920 
921  inline std::mutex& GetMutex() {
922  return rf->GetMutex();
923  }
924 
925  inline bool isLogOnly() {
926  return rf->isLogOnly();
927  }
928 
929  inline void logTableChange(std::string& descriptor, TableChangeType changeType, const char* data) {
930  return rf->logTableChange(descriptor, changeType, data);
931  }
932 
938  static bool allocateInstancesBuffer(int size);
939 
943  static void deleteInstancesBuffer();
944 #endif //SIMULATION
945 
946 protected:
947 
951  MeshNet(bool canBeGateway);
952 
957  inline uint8_t getNewID() {
958  msgIDPriv++;
959  return msgIDPriv;
960  }
961 
966  inline uint8_t getLastID() {
967  return msgIDPriv;
968  }
969 
971 
972 #if (MESH_IMPL_CONSOLE_ITEM == 1)
973 
978  void showHelp(SerialConsole *console, Stream *stream);
979 #endif //MESH_IMPL_CONSOLE_ITEM
980 
984  //bool processReceivedOld();
985 
989  static void onFrameReceiveStatic(MeshPacketBuilder* builder, MeshPacketBuilderStatus status, const MeshFrameHeader& frameHeader, const uint8_t* frameData, uint8_t frameDataSize, int8_t rssi);
990 
994  void onFrameReceive(MeshPacketBuilder* builder, MeshPacketBuilderStatus status, const MeshFrameHeader& frameHeader, const uint8_t* frameData, uint8_t frameDataSize, int8_t rssi);
995 
999  static bool checkPacketStatic(MeshPacketBuilder* builder, const MeshPacketHeader& packetHeader, MeshMAC BSSID, SystemPacketType systemPacketType, const uint8_t* frameData, uint8_t frameDataSize, int8_t rssi);
1000 
1011  bool checkPacket(MeshPacketBuilder* builder, const MeshPacketHeader& packetHeader, MeshMAC BSSID, SystemPacketType systemPacketType, const uint8_t* frameData, uint8_t frameDataSize, int8_t rssi);
1012 
1016  void processReceived();
1017 
1023  virtual void processPacket(MeshPacket& packet, MeshMAC BSSID);
1024 
1028  void processTransmit();
1029 
1034  inline void abortCurrentPacketTransmission(bool packetLost) {
1035 #ifndef MESH_NO_STATISTICS
1036  if(packetSplittingStarted && frameTranCnt > 0 && packetLost){ //Some frame was sent
1037  sentFramesTotal--; //Frame was not successfully sent
1038  lostFramesTotal++;
1040  sentFramesInNetwork--; //Frame was not successfully sent
1042  }
1043  }
1044 #endif // !MESH_NO_STATISTICS
1046  packetSplittingStarted = false; //Set flag, that nothing is splitting right now
1048  }
1049 
1054  packetSplittingStarted = false;
1056  }
1057 
1062  inline void restartCurrentPacketTransmission(uint8_t maxFrameSize) {
1063  packetSplittingStarted = false;
1064  packetSplitter.Restart(maxFrameSize);
1065  }
1066 
1070  inline bool packetTransmitting() {
1071  bool headerSent = packetSplitter.GetCurrentFrameIndex() != 0;
1072  return packetSplittingStarted && (headerSent || frameTranCnt > 0);
1073  }
1074 
1078  inline bool packetSplitting() {
1080  }
1081 
1089  bool systemNetworkScan(MeshMAC responderBSSID, MeshNetScanFlags flags);
1090 
1098  bool sendACK(const MeshACKSetup& setup, bool asDisconnected = false, bool asConnectedToOld = false);
1099 
1109  bool sendERR_ACK(const MeshACKSetup& setup, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue, bool asDisconnected = false, bool asConnectedToOld = false);
1110 
1120  bool PacketToFrame(const MeshPacket& packet, MeshMAC bssid, uint8_t* outBuffer, uint8_t& bufferSize) const;
1121 
1131  bool SendPacketAsFrame(MeshPacket& packet, MeshMAC bssid);
1132 
1139  static bool isForeignNetworkPacket(const MeshPacket& packet, MeshMAC bssid);
1140 
1146  virtual void onNodeLost(uint8_t address, bool nodeLostForever);
1147 
1162  bool disconnectPriv(MeshDisconnectReason reason, bool doNotDisconnectImmediatelly, bool forceDisconnect = false);
1163 
1170 
1176 
1180  static void onOIDTRemoveStatic(MeshOIDTable<OIDTABLE_SIZE>* table, int16_t index, const MeshOIDTableRow& oldRow, uint8_t oldRawLifeTime, MeshOIDTableRemoveReason reason);
1181 
1189  virtual void onOIDTRemove(int16_t index, const MeshOIDTableRow& oldRow, uint8_t oldRawLifeTime, MeshOIDTableRemoveReason reason);
1190 
1194  static void onNewPathStatic(MeshRouteTable<ROUTETABLE_SIZE>* table, int16_t index, const MeshRouteTableRow& row, uint8_t rawLifeTime);
1195 
1201  void onNewPath(int16_t index, const MeshRouteTableRow& row);
1202 
1211  void onBufferPacketLost(const MeshPacket& packet, MeshPacketError error);
1212 
1220  void onBufferPacketRemove(const MeshPacket& packet, bool ignoreCurrentNetworkPacket, bool packetLost);
1221 
1230  virtual void onPacketError(MeshPacketError error, uint8_t packetID, uint8_t packetDest, SystemPacketType packetType, const MeshPacket* packet_ptr);
1231 
1240  bool systemPing(uint8_t addr, uint32_t timeout);
1241 
1247  void onSystemPingReceived(bool valid, uint32_t duration);
1248 
1256  virtual void routeTableUpdate(const MeshPacketHeader& header, MeshMAC BSSID, int8_t rssi);
1257 
1286  MeshPacketError pushOutPacket(MeshPacket& packet, uint32_t timeout = 0);
1287 
1293  bool createPath(uint8_t address);
1294 
1299  void checkWaitingBuffer();
1300 
1301 
1305 
1307 
1311  const bool canBeGateway_:1;
1312 
1317 
1322 
1327 
1332 
1337 
1341  bool beginCalled:1;
1342 
1347 
1349 
1353  uint8_t channel;
1354 
1356 
1361 
1366 
1371 
1375  char SSID[65];
1376 
1381  uint32_t AddrReservedUntil = 0;
1382 
1387  uint16_t AddrReservationTime = 0;
1388 
1393 
1398 
1400 
1405 
1410  uint64_t CTS_until = 0;
1411 
1415  uint64_t lastReceiveTime = 0;
1416 
1420  uint32_t lastSentTime = 0;
1421 
1425  uint8_t frameTranCnt = 0;
1426 
1428 
1433 
1438 
1443 
1445 
1446  //User scan variables
1450  uint32_t scanEndTime = 0;
1451 
1455  uint32_t lastScanTime = 0;
1456 
1457  //System scan variables
1461  uint8_t lowestHopsToGateway = 255; //Lowest hop-count to gateway found in last scan.
1462 
1466  uint8_t lowestHopsToGateway_Addr = INVALID_MESH_ADDRESS; //Address of node, which has lowest hop-count to gateway found in last scan.
1467 
1473 
1477  uint32_t connectionStepTime = 0;
1478 
1480 
1484 
1488  uint32_t nextAutoConnectTime = 0;
1489 
1493  uint32_t autoConnectInterval = 0;
1494 
1496 
1500  uint32_t disconnectUntil = 0;
1501 
1503 
1507  int16_t systemPingID = -1;
1508 
1510 
1515 
1520 
1530 
1537  void(*onRemDisconnected)(MeshNet*, uint8_t);
1538 
1546 
1559  void(*onPingResponse)(MeshNet*, uint8_t, uint8_t, MeshPacketError, uint8_t, uint32_t, const uint8_t*, int16_t);
1560 
1569  void(*onPacketErrorCallback)(MeshNet*, MeshPacketError, uint8_t, uint8_t, const MeshPacket*);
1570 
1572 
1573 #ifndef MESH_NO_STATISTICS
1574  //All statistic data is restarted when end(), clear() or resetStatistics() is called
1575  //lostFramesInNetwork, lostPacketsInNetwork, sentFramesInNetwork, sentPacketsInNetwork are restarted also when disconnected from network
1576 
1577  //Count of frames, that has been lost. ACK was not received or frame cannot be sent, because of radio error or interference.
1578  //Retransmitted frames are counted if they are lost.
1579  uint32_t lostFramesTotal = 0; //Done
1580  uint32_t lostFramesInNetwork = 0; //Done
1581 
1582  //Count of lost packets created by current node.
1583  uint32_t lostPacketsTotal = 0; //Done - but checks needed
1584  uint32_t lostPacketsInNetwork = 0; //Done - but checks needed
1585 
1586  //Count of lost packets out of current node created by current node
1587  uint32_t lostRemotePackets = 0; //Done - but checks needed
1588  uint32_t lostRemoteDataPackets = 0; //Done - but checks needed
1589 
1590  uint32_t lostDataPackets = 0; //Done - but checks needed
1591  uint32_t lostRelayiedPackets = 0; //Done - but checks needed
1592 
1593  //Count of all frames, that has been successfully sent and acknowledged when needed.
1594  uint32_t sentFramesTotal = 0; //Done
1595  uint32_t sentFramesInNetwork = 0; //Done
1596 
1597  //Count of sent packets created by current node. It is not checked if packet is successfully received.
1598  uint32_t sentPacketsTotal = 0; //Done
1599  uint32_t sentPacketsInNetwork = 0; //Done
1600 
1601  uint32_t sentDataPackets = 0; //Done
1602  uint32_t relayiedPackets = 0; //Done
1603 
1604  //TODO add count of received packets and frames
1605  //TODO add duration statistics
1606 
1607 #endif // !MESH_NO_STATISTICS
1608 
1610 
1611 #if MESH_IMPL_CONSOLE_ITEM == 1
1612 
1615  SerialConsole* srConsole = NULL;
1616 #endif
1617 
1619 
1624 
1629 
1631 
1636 
1641 
1646 
1653 
1655 
1660 
1665 
1666 private:
1667 
1671  uint8_t msgIDPriv = 0xFF;
1672 
1677  void addThisToInstArr();
1678 
1682  void removeThisFromInstArr();
1683 
1688  void clear(bool disconnecting);
1689 
1690 
1691 #ifdef SIMULATION
1692 
1696  static MeshNet** instances;
1697 
1701  static int instArrSize;
1702 #else
1703 
1707  static MeshNet* instances[];
1708 #endif // SIMULATION
1709 
1713  static uint8_t instCount;
1714 
1715 };
1716 
1717 #endif
MeshNet::onBufferPacketRemove
void onBufferPacketRemove(const MeshPacket &packet, bool ignoreCurrentNetworkPacket, bool packetLost)
This method is called when any packet is removed from waitingFIFO or outFIFO.
Definition: mesh.cpp:2352
MPE_Timeout
@ MPE_Timeout
Definition: mesh.h:83
MeshNet::packetSplitter
MeshPacketSplitter packetSplitter
Splits MeshPacket to multiple MeshFrames for transmission.
Definition: mesh.h:1628
MeshNet::packetSplitting
bool packetSplitting()
Checks if some packet is loaded in packet splitter.
Definition: mesh.h:1078
MeshNetScanResult
Structure, which holds network scan result.
Definition: meshPacketFlags.h:452
MeshNet::netScanResponseCallback
void(* netScanResponseCallback)(MeshNet *, const MeshNetScanResult &)
Pointer to callback function called when network scan response was received.
Definition: mesh.h:1514
MeshNet::printWaitingFIFO
bool printWaitingFIFO(OSTREAM *stream) const
Prints waiting FIFO buffer in pretty format to stream.
Definition: mesh.cpp:2638
MeshNet::AddrPriv
uint8_t AddrPriv
Address of current node. Can be between 0 - 250 or 254 when disconnected.
Definition: mesh.h:1360
MeshOIDTable::existsDestAndSysPacketType
bool existsDestAndSysPacketType(uint8_t destination, SystemPacketType type) const
Checks if row with specified destination address and system packet type exists.
Definition: meshTables.h:2069
MPE_LostRemote
@ MPE_LostRemote
Definition: mesh.h:88
RFInterface.h
This file contains interface (pattern) class, that has to be overridden to create driver for radio wh...
MeshRouteTable< ROUTETABLE_SIZE >
MeshNet::printMeshDisconnectReason
static size_t printMeshDisconnectReason(OSTREAM &stream, MeshDisconnectReason value)
Prints MeshDisconnectReason to stream.
Definition: mesh.cpp:2702
MeshNet::setOnReceive
void setOnReceive(void(*callback)(MeshNet *, MeshPacket &))
Sets callback function, which is called when data packet is received.
Definition: mesh.h:845
MeshNet::getNeighborNode
uint8_t getNeighborNode(uint8_t address) const
Gets address of neighbor node, which is next node in path.
Definition: mesh.h:436
MeshNet::sendERR_ACK
bool sendERR_ACK(const MeshACKSetup &setup, ERR_ACK_ErrorCode ErrorCode, uint8_t RepairValue, bool asDisconnected=false, bool asConnectedToOld=false)
Sends ERROR ACK to last received frame. This has to be done when some error happened to last received...
Definition: mesh.cpp:1814
MeshNet::setOnConnectedCallback
void setOnConnectedCallback(void(*callback)(MeshNet *))
Sets callback function, which is called when current node is connected to network.
Definition: mesh.h:776
RFInterface
Radio frequency interface, that helps to use meshNet with different radios or communication types....
Definition: RFInterface.h:48
MDR_DisconnectCalled
@ MDR_DisconnectCalled
Definition: mesh.h:68
MeshOIDTableRow
Structure, that contains one row with data from out ID table.
Definition: meshTables.h:249
MeshNet::getLastID
uint8_t getLastID()
Gets last generated ID.
Definition: mesh.h:966
MeshNet::onOIDTRemove
virtual void onOIDTRemove(int16_t index, const MeshOIDTableRow &oldRow, uint8_t oldRawLifeTime, MeshOIDTableRemoveReason reason)
This method is called when any row from OID table is removed.
Definition: mesh.cpp:2297
MeshPacketStatus
MeshPacketStatus
Definition: meshHelper.h:195
MeshNet::packetBuilder
MeshPacketBuilder packetBuilder
Combines received MeshFrames to MeshPacket.
Definition: mesh.h:1623
MeshNet::canBeGateway
bool canBeGateway() const
Checks if current node can be used as gateway or is used as gateway.
Definition: mesh.h:473
MDR_ConnectionTimeout
@ MDR_ConnectionTimeout
Definition: mesh.h:64
MeshNet::printIDTable
bool printIDTable(OSTREAM *stream) const
Prints ID Table in pretty format to stream.
Definition: mesh.cpp:2612
MeshNet::setOnPingResponseCallback
void setOnPingResponseCallback(void(*callback)(MeshNet *, uint8_t, uint8_t, MeshPacketError, uint8_t, uint32_t, const uint8_t *, int16_t))
Sets callback function, which is called when ping response is received, or when ping timed out.
Definition: mesh.h:818
MeshNet::oldBSSID
MeshMAC oldBSSID
Old BSSID of network the node was connected to last time.
Definition: mesh.h:1397
MeshNet::disconnectUntil
uint32_t disconnectUntil
Until this time in milliseconds node has to be disconnected.
Definition: mesh.h:1500
MeshNet::ignoreRSSIThreshold
bool ignoreRSSIThreshold
True to ignore RSSI threshold on received network scan responses during scan.
Definition: mesh.h:1331
MeshNet::disconnectPriv
bool disconnectPriv(MeshDisconnectReason reason, bool doNotDisconnectImmediatelly, bool forceDisconnect=false)
Disconnects current node from mesh network. It is recommended to check isDisconnecting() and isConnec...
Definition: mesh.cpp:322
MeshOIDTable< OIDTABLE_SIZE >
MDR_None
@ MDR_None
Definition: mesh.h:56
MeshNet
This class implements MeshNet protocol for microcontrollers.
Definition: mesh.h:104
MeshNet::abortCurrentPacketTransmission
void abortCurrentPacketTransmission(bool packetLost)
Aborts splitting and transmission of packet currently loaded in packetSplitter.
Definition: mesh.h:1034
MeshPacketSplitter::GetCurrentFrameIndex
uint8_t GetCurrentFrameIndex() const
Gets index of frame, that will be splitted.
Definition: meshPacketSplitter.h:173
MeshNet::getLostFramesTotalCnt
uint32_t getLostFramesTotalCnt() const
Gets total count of lost frames. Frame is marked as lost, when attempt to send false,...
Definition: mesh.h:535
MeshNet::sentPacketsInNetwork
uint32_t sentPacketsInNetwork
Definition: mesh.h:1599
MeshACKSetup
Structure, which has data, that are needed for ACK packet creation.
Definition: meshPacketBuilder.h:420
MeshRouteTableRow
Structure, that contains one row with data from route table.
Definition: meshTables.h:70
MeshNet::getSentPacketsTotalCnt
uint32_t getSentPacketsTotalCnt() const
Gets total count of successfully sent packets created by current node. This value also includes packe...
Definition: mesh.h:647
MPE_Full_outFIFO
@ MPE_Full_outFIFO
Definition: mesh.h:86
MeshNet::RTable
MeshRouteTable< ROUTETABLE_SIZE > RTable
Routing table.
Definition: mesh.h:1635
MeshNet::removeThisFromInstArr
void removeThisFromInstArr()
Removes this instance from instances array. This method has to be called in destructor.
Definition: mesh.cpp:3489
MeshNet::waitingBufferCheck
bool waitingBufferCheck
True if waitBuffer has to be checked and some packets has to be sent.
Definition: mesh.h:1336
MeshConnectionScan
@ MeshConnectionScan
Definition: mesh.h:45
MeshNet::getLostRemoteDataPacketsCnt
uint32_t getLostRemoteDataPacketsCnt() const
Gets total count of lost data packets outside of current node created by current node....
Definition: mesh.h:608
MeshNet::instCount
static uint8_t instCount
Count of created instances of this class.
Definition: mesh.h:1713
MPE_Full_waitingFIFO
@ MPE_Full_waitingFIFO
Definition: mesh.h:87
MeshNet::setAutoConnect
void setAutoConnect(MeshMAC netBSSID, uint32_t retryInterval=60000)
Enables auto connect to specified network. If auto connect is enabled and node is not connected to an...
Definition: mesh.cpp:300
MeshNet::lostPacketsTotal
uint32_t lostPacketsTotal
Definition: mesh.h:1583
MeshNet::systemNetworkScan
bool systemNetworkScan(MeshMAC responderBSSID, MeshNetScanFlags flags)
Perform network scan invoked by system before connecting to any network. This can be done only when n...
Definition: mesh.cpp:444
MeshNet::disconnect
bool disconnect()
Disconnects current node from mesh network. It is recommended to check isDisconnecting() and isConnec...
Definition: mesh.cpp:318
MeshNet::SSID
char SSID[65]
SSID of network, node is connected to.
Definition: mesh.h:1375
MeshNet::getPacketStatus
MeshPacketStatus getPacketStatus(uint8_t ID) const
Tries to check, where is packet, that was sent by it's ID.
Definition: mesh.cpp:549
MeshNet::disableAutoConnect
void disableAutoConnect()
Disables auto connection.
Definition: mesh.cpp:312
MeshNet::send
int16_t send(uint8_t addr, const uint8_t *data, uint16_t dataSize)
Sends data packet to specified node.
Definition: mesh.cpp:482
MeshNet::instances
static MeshNet * instances[]
Array of all created MeshNet instances. Thanks to this array callback functions of MicroTable,...
Definition: mesh.h:1707
MeshNet::lostPacketsInNetwork
uint32_t lostPacketsInNetwork
Definition: mesh.h:1584
MeshNet::onFrameReceiveStatic
static void onFrameReceiveStatic(MeshPacketBuilder *builder, MeshPacketBuilderStatus status, const MeshFrameHeader &frameHeader, const uint8_t *frameData, uint8_t frameDataSize, int8_t rssi)
Processed received messages.
Definition: mesh.cpp:766
MeshNet::relayiedPackets
uint32_t relayiedPackets
Definition: mesh.h:1602
MeshNet::onConnected
void(* onConnected)(MeshNet *)
This method is called when node is connected to network.
Definition: mesh.h:1519
MeshNet::checkPacket
bool checkPacket(MeshPacketBuilder *builder, const MeshPacketHeader &packetHeader, MeshMAC BSSID, SystemPacketType systemPacketType, const uint8_t *frameData, uint8_t frameDataSize, int8_t rssi)
This method is called when first frame of packet has been received. It has to decide,...
Definition: mesh.cpp:853
MeshNet::systemPing
bool systemPing(uint8_t addr, uint32_t timeout)
Sends ping packet to node with specified address. When ping response is received, onSystemPingReceive...
Definition: mesh.cpp:589
MeshNet::lastScanResponderBSSID
MeshMAC lastScanResponderBSSID
BSSID of network, the system network scan was assigned to.
Definition: mesh.h:1471
MeshNet::connectionState
MeshConnectionState connectionState
Connection state of current node.
Definition: mesh.h:1432
MeshNet::OIDTable
MeshOIDTable< OIDTABLE_SIZE > OIDTable
Table of sent (output) packets ID and destination (source is current node address)....
Definition: mesh.h:1652
MeshNet::printOIDTable
bool printOIDTable(OSTREAM *stream) const
Prints OID Table in pretty format to stream.
Definition: mesh.cpp:2628
MPE_GenErr
@ MPE_GenErr
Definition: mesh.h:91
MPE_Invalid
@ MPE_Invalid
Definition: mesh.h:90
MeshDisconnected
@ MeshDisconnected
Definition: mesh.h:44
MeshNet::getLostPacketsInNetworkCnt
uint32_t getLostPacketsInNetworkCnt() const
Gets count of lost packets created by current node for current network. This count does not include p...
Definition: mesh.h:572
UNKNOWN_MESH_ADDRESS
#define UNKNOWN_MESH_ADDRESS
Address, of node, when node is not connected to any network.
Definition: meshConfig.h:62
MeshNet::isConnected
bool isConnected() const
Checks if node is connected to any network.
Definition: mesh.h:383
MeshNet::FIDTable
MeshFIDTable< FIDTABLE_SIZE > FIDTable
Definition: mesh.h:1645
MeshNet::lastDisconnectReason
MeshDisconnectReason lastDisconnectReason
Last disconnect or connection fail reason.
Definition: mesh.h:1437
MeshFIDTable< FIDTABLE_SIZE >
ERR_ACK_ErrorCode
ERR_ACK_ErrorCode
Definition: meshPacketDecoders.h:258
MPE_OIDT_Overwrritten
@ MPE_OIDT_Overwrritten
Definition: mesh.h:82
MeshNet::printMeshConnectionState
static size_t printMeshConnectionState(OSTREAM &stream, MeshConnectionState value)
Prints MeshConnectionState to stream.
Definition: mesh.cpp:2691
MeshNet::onPacketError
virtual void onPacketError(MeshPacketError error, uint8_t packetID, uint8_t packetDest, SystemPacketType packetType, const MeshPacket *packet_ptr)
This method is called when some error happened to any packet created by current node.
Definition: mesh.cpp:2389
MeshPacketSplitter
This class supports splitting MeshPacket to multiple MeshFrames in one carriage. MeshPackets are spli...
Definition: meshPacketSplitter.h:50
MDR_ConnectionRefused
@ MDR_ConnectionRefused
Definition: mesh.h:60
MeshNet::oldNodeAddress
uint8_t oldNodeAddress
Old node address, that was assigned to node when it has been connected to some network.
Definition: mesh.h:1392
MeshNet::~MeshNet
virtual ~MeshNet()
Virtual destructor.
Definition: mesh.cpp:100
MeshNet::autoConnectBSSID
MeshMAC autoConnectBSSID
BSSID of network, this node has to automatically connect to.
Definition: mesh.h:1483
MPE_AllocErr
@ MPE_AllocErr
Definition: mesh.h:92
MeshNet::onDisconnected
void(* onDisconnected)(MeshNet *, MeshDisconnectReason, MeshMAC, uint8_t)
This method is called when node is disconnected from network.
Definition: mesh.h:1529
meshPacketSplitter.h
This file contains MeshPacketSplitter class, which can split MeshPacket to multiple MeshFrames.
MeshNet::setOnRemoteNodeDisconnectedCallback
void setOnRemoteNodeDisconnectedCallback(void(*callback)(MeshNet *, uint8_t))
This method is called when some node (not current node) is disconnected from network.
Definition: mesh.h:799
MeshNet::currentNetworkPackets
uint8_t currentNetworkPackets
Count of packets in buffers, that belongs to the current connected network.
Definition: mesh.h:1442
MeshNet::channel
uint8_t channel
Channel number, that will be set or is set.
Definition: mesh.h:1353
MDR_NotFound
@ MDR_NotFound
Definition: mesh.h:59
MeshConnectionState
MeshConnectionState
Enumeration that represents connection state of MeshNet.
Definition: mesh.h:43
MeshNet::NetworkBSSID
MeshMAC NetworkBSSID
If node is disconnected, this is same as NodeMAC, else NetworkBSSID equals BSSID address of connected...
Definition: mesh.h:1370
MeshNet::scanEndTime
uint32_t scanEndTime
Time in milliseconds, when network scan ends.
Definition: mesh.h:1450
MeshNet::pushOutPacket
MeshPacketError pushOutPacket(MeshPacket &packet, uint32_t timeout=0)
Pushes packet to output FIFO buffer.
Definition: mesh.cpp:2487
MeshPacketFIFO< MESH_WFIFO_SIZE >
meshPacketBuilder.h
This file contains class which can concatinate packet splitted to frames back to packet.
MeshNet::onOIDTRemoveStatic
static void onOIDTRemoveStatic(MeshOIDTable< OIDTABLE_SIZE > *table, int16_t index, const MeshOIDTableRow &oldRow, uint8_t oldRawLifeTime, MeshOIDTableRemoveReason reason)
Static function, which can be used as callback. In this function correct onOIDTRemove() method is cal...
Definition: mesh.cpp:2289
MeshNet::msgIDPriv
uint8_t msgIDPriv
Last value of packet ID.
Definition: mesh.h:1671
MeshNet::getLostDataPacketsCnt
uint32_t getLostDataPacketsCnt() const
Gets count of lost data packets created by current node for current network. This count does not incl...
Definition: mesh.h:585
MDR_ConnectionError
@ MDR_ConnectionError
Definition: mesh.h:62
MDR_ConnectionRemoteError
@ MDR_ConnectionRemoteError
Definition: mesh.h:63
MeshNet::getNodeAddress
uint8_t getNodeAddress() const
Gets address of current node. If node is not connected to any network, 253 is returned.
Definition: mesh.h:513
MeshNetDisconnectPacketType
MeshNetDisconnectPacketType
Definition: meshPacketDecoders.h:2239
MeshNet::onNewPathStatic
static void onNewPathStatic(MeshRouteTable< ROUTETABLE_SIZE > *table, int16_t index, const MeshRouteTableRow &row, uint8_t rawLifeTime)
Static function, which can be used as callback. In this function correct onNewPath() method is called...
Definition: mesh.cpp:2333
MeshNet::getLostRelayiedPacketsCnt
uint32_t getLostRelayiedPacketsCnt() const
Gets count of lost relayed packets in current node (packets, that were not created by current node)....
Definition: mesh.h:617
MeshPacketSplitter::Restart
void Restart(MeshMAC bssid, uint8_t maxFrameSize_)
Restarts splitting with old packet, which is reused.
Definition: meshPacketSplitter.cpp:24
RFInterface::MinChannelNumber
const uint8_t MinChannelNumber
Minimum channel number. When this value is equal or higher than MaxChannelNumber, radio channel canno...
Definition: RFInterface.h:272
MeshPacketBuilder
This class can build packet from multiple frames. It is usually used to concatinate data from packet,...
Definition: meshPacketBuilder.h:126
MeshNet::handle
virtual void handle()
This method has to be called in main program loop as often as possible.
Definition: mesh.cpp:631
meshPacket.h
This file contains class which can be used to handling mesh packets.
MeshNet::onSystemDisconnect
void onSystemDisconnect(MeshDisconnectReason reason)
Do necessary work after node was disconnected or connection was aborted. onDisconnected method is cal...
Definition: mesh.cpp:2234
MeshNet::lastReceiveTime
uint64_t lastReceiveTime
Time when last frame was received in microseconds.
Definition: mesh.h:1415
MeshNet::restartCurrentPacketTransmission
void restartCurrentPacketTransmission()
Restarts transmission of current packet. Splitting is restarted.
Definition: mesh.h:1053
MeshNet::checkWaitingBuffer
void checkWaitingBuffer()
Checks if there are some packets in waiting buffer, which can be sent. Those packets will be sent in ...
Definition: mesh.cpp:2579
MeshNet::lowestHopsToGateway_Addr
uint8_t lowestHopsToGateway_Addr
Address of node with the smallest count of hops to gateway established during last system network sca...
Definition: mesh.h:1466
MeshNet::sentFramesInNetwork
uint32_t sentFramesInNetwork
Definition: mesh.h:1595
MeshNet::sendACK
bool sendACK(const MeshACKSetup &setup, bool asDisconnected=false, bool asConnectedToOld=false)
Sends ACK to last received frame. This has to be done when builder returns status MPB_FullPacketOK or...
Definition: mesh.cpp:1767
MeshVariableArray
This class safetly handles allocation and deallocation of memory. It can be used in conjunction with ...
Definition: meshVariableArray.h:32
MeshNet::routeTableUpdate
virtual void routeTableUpdate(const MeshPacketHeader &header, MeshMAC BSSID, int8_t rssi)
Updates route table when valid packet from node with same network is received.ň
Definition: mesh.cpp:2471
MeshNet::lastScanTime
uint32_t lastScanTime
Time in milliseconds, when network scan was last time executed.
Definition: mesh.h:1455
MeshDisconnecting
@ MeshDisconnecting
Definition: mesh.h:48
MeshNet::onBufferPacketLost
void onBufferPacketLost(const MeshPacket &packet, MeshPacketError error)
This method is called when some packet created by this node was lost, because some FIFO,...
Definition: mesh.cpp:2345
MeshRouteTable::sourceExists
bool sourceExists(uint8_t source) const
Checks if source node exists in table.
Definition: meshTables.h:1521
MeshNet::netScanRunning
bool netScanRunning() const
Checks if network scan is running.
Definition: mesh.h:407
MeshNet::isForeignNetworkPacket
static bool isForeignNetworkPacket(const MeshPacket &packet, MeshMAC bssid)
Checks if packet is for current network (with specified BSSID in BSSID parameter) or not.
Definition: mesh.cpp:1969
MeshPacketSplitter::GetRemainingFramesCount
uint8_t GetRemainingFramesCount() const
Gets count of remaining frames, that will be splitted.
Definition: meshPacketSplitter.h:143
MeshNet::lostFramesTotal
uint32_t lostFramesTotal
Definition: mesh.h:1579
MeshPacketBuilderStatus
MeshPacketBuilderStatus
Mesh packet builder status.
Definition: meshPacketBuilder.h:23
MeshNet::outFIFO
MeshPacketPriorityFIFO< MESH_OFIFO_HIGH_SIZE, MESH_OFIFO_LOW_SIZE > outFIFO
Packets that waits in buffer to be sent.
Definition: mesh.h:1659
MeshNet::getLostRemotePacketsCnt
uint32_t getLostRemotePacketsCnt() const
Gets total count of lost packets outside of current node created by current node. This value includes...
Definition: mesh.h:597
MeshNet::getSentDataPacketsCnt
uint32_t getSentDataPacketsCnt() const
Gets count of successfully sent data packets created by current node for current network....
Definition: mesh.h:667
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
MeshNet::beginCalled
bool beginCalled
True if begin was called.
Definition: mesh.h:1341
MeshNet::lostRemotePackets
uint32_t lostRemotePackets
Definition: mesh.h:1587
MeshNet::pathExists
bool pathExists(uint8_t address) const
Checks if path to specified node exists.
Definition: mesh.h:418
MPE_OK
@ MPE_OK
Definition: mesh.h:81
MeshNet::lastSentTime
uint32_t lastSentTime
Time, when was last frame sent in milliseconds.
Definition: mesh.h:1420
MeshNet::clear
void clear(bool disconnecting)
Clears current class data.
Definition: mesh.cpp:159
MeshDisconnectReason
MeshDisconnectReason
Enumeration that represents disconnect or connection fail reason of MeshNet.
Definition: mesh.h:55
MeshNet::getRadioInterfacePtr
RFInterface * getRadioInterfacePtr() const
Gets pointer to radio interface.
Definition: mesh.h:520
MeshNet::connectionStepTime
uint32_t connectionStepTime
Time in milliseconds, when connection state was last changed.
Definition: mesh.h:1477
MeshNet::ping
int16_t ping(uint8_t addr, uint32_t timeout, int16_t testDataLength=0)
Sends ping packet to node with specified address. When ping response is received, callback function s...
Definition: mesh.cpp:565
MDR_NetworkFull
@ MDR_NetworkFull
Definition: mesh.h:61
MeshNet::directConnect
bool directConnect(MeshMAC netBSSID, uint8_t interpreterAddr)
Connects to specified network, but without scan. In this case, you have to know address of node,...
Definition: mesh.cpp:272
MeshNet::autoConnectInterval
uint32_t autoConnectInterval
Auto connect interval in milliseconds.
Definition: mesh.h:1493
MeshNet::connect
bool connect(MeshMAC netBSSID, bool autoConnect=false, uint32_t autoConnectInterval=30000)
Connects to specified network.
Definition: mesh.cpp:248
MeshNet::onReceive
void(* onReceive)(MeshNet *, MeshPacket &)
Function called when data packet is received.
Definition: mesh.h:1545
MeshNet::onPacketErrorCallback
void(* onPacketErrorCallback)(MeshNet *, MeshPacketError, uint8_t, uint8_t, const MeshPacket *)
Definition: mesh.h:1569
MeshNet::AddrReservationTime
uint16_t AddrReservationTime
Time in minutes the address can be reserved for in DHCP table in main gateway. This value is obtained...
Definition: mesh.h:1387
MeshPacketPriorityFIFO< MESH_OFIFO_HIGH_SIZE, MESH_OFIFO_LOW_SIZE >
MeshNet::sentDataPackets
uint32_t sentDataPackets
Definition: mesh.h:1601
MeshNet::onRemDisconnected
void(* onRemDisconnected)(MeshNet *, uint8_t)
This method is called when some node from network is disconnected.
Definition: mesh.h:1537
MeshNet::onPingResponse
void(* onPingResponse)(MeshNet *, uint8_t, uint8_t, MeshPacketError, uint8_t, uint32_t, const uint8_t *, int16_t)
Function called when ping response is received or when ping timed out.
Definition: mesh.h:1559
OSTREAM
#define OSTREAM
Definition: meshConfig.h:41
MeshConnectionRequest
@ MeshConnectionRequest
Definition: mesh.h:46
MeshNet::setChannel
bool setChannel(uint8_t channel_)
Sets network channel.
Definition: mesh.cpp:149
MeshNet::lowestHopsToGateway
uint8_t lowestHopsToGateway
The smallest count of hops to gateway established during last system network scan.
Definition: mesh.h:1461
MeshNet::systemPingID
int16_t systemPingID
ID of last system ping packet.
Definition: mesh.h:1507
MDR_NetworkDrop
@ MDR_NetworkDrop
Definition: mesh.h:70
MeshNet::processReceived
void processReceived()
Processes received frames.
Definition: mesh.cpp:1087
meshPacketDecoders.h
This file contains static classes that can decode system packets.
MeshNet::getLostFramesInNetworkCnt
uint32_t getLostFramesInNetworkCnt() const
Gets count of lost frames for current network. Frame is marked as lost, when attempt to send false,...
Definition: mesh.h:546
MeshNet::getSentFramesInNetworkCnt
uint32_t getSentFramesInNetworkCnt() const
Gets total count of successfully sent frames. Frame is successfully sent, when send was successful an...
Definition: mesh.h:636
MeshNet::processTransmit
void processTransmit()
Processes transmission of one frame from output FIFO.
Definition: mesh.cpp:1594
MeshNet::startNetScan
bool startNetScan(void(*responseCallback)(MeshNet *, const MeshNetScanResult &), uint32_t timeout, MeshNetScanFlags flags, MeshMAC ResponderBSSID=0)
Starts asynchronous network scanning. This function cannot be called when scan is actually running.
Definition: mesh.cpp:399
meshTables.h
This file contains classes, that implements tables for microcontrollers.
MeshNet::waitingFIFO
MeshPacketFIFO< MESH_WFIFO_SIZE > waitingFIFO
Packets, that has to be sent as routed packet, but path is not known yet.
Definition: mesh.h:1664
MeshIDTable< IDTABLE_SIZE >
MeshNet::packetSplittingStarted
bool packetSplittingStarted
True if packet splitting has started.
Definition: mesh.h:1321
MeshNet::canBeGateway_
const bool canBeGateway_
True if current node can be used as gateway.
Definition: mesh.h:1311
meshBuffers.h
This file contains classes, that implements FIFO buffers.
MeshNet::printRTable
bool printRTable(OSTREAM *stream) const
Prints Route Table in pretty format to stream.
Definition: mesh.cpp:2604
MeshNet::lostFramesInNetwork
uint32_t lostFramesInNetwork
Definition: mesh.h:1580
MeshPacketSplitter::Clear
void Clear()
Clears and releases all rsources and stops splitting.
Definition: meshPacketSplitter.cpp:87
MeshNet::sentFramesTotal
uint32_t sentFramesTotal
Definition: mesh.h:1594
MeshNet::printMeshNetworkInfo
size_t printMeshNetworkInfo(OSTREAM &stream) const
Prints informations about network, node is connected to.
Definition: mesh.cpp:2654
MeshNet::getRelayiedPacketsCnt
uint32_t getRelayiedPacketsCnt() const
Gets count of successfully relayed packets (packets, that were not created by current node)....
Definition: mesh.h:676
MeshNet::packetTransmitting
bool packetTransmitting()
Checks if some frame of currently splitting packet has been already transmitted.
Definition: mesh.h:1070
MeshMAC
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
MeshNet::IDTable
MeshIDTable< IDTABLE_SIZE > IDTable
Table of received packets ID (ID+Source). This check, if some packet has been received multiple times...
Definition: mesh.h:1640
MeshNet::onNodeLost
virtual void onNodeLost(uint8_t address, bool nodeLostForever)
This method is called, when some node is disconnected from network or does not responds to sent packe...
Definition: mesh.cpp:2009
MeshNet::getLostPacketsTotalCnt
uint32_t getLostPacketsTotalCnt() const
Gets total count of lost packets created by current node. This count does not include packet,...
Definition: mesh.h:559
MeshNet::getNewID
uint8_t getNewID()
Generates new ID for packet.
Definition: mesh.h:957
MeshNet::frameTranCnt
uint8_t frameTranCnt
(Re)Transmission count of last sent frame.
Definition: mesh.h:1425
MeshNet::sentFrameWasACK
bool sentFrameWasACK
True when sent frame was acknowledged.
Definition: mesh.h:1316
MeshNet::createPath
bool createPath(uint8_t address)
Creates path to specified node.
Definition: mesh.cpp:2566
MeshNet::processPacket
virtual void processPacket(MeshPacket &packet, MeshMAC BSSID)
Processes received packet. Called in processReceived() method.
Definition: mesh.cpp:1198
INVALID_MESH_ADDRESS
#define INVALID_MESH_ADDRESS
Address, that is invalid and cannot be used.
Definition: meshConfig.h:56
MeshPacketHeader
This structure contains informations about mesh packet, that are stored in it's header.
Definition: meshPacket.h:42
MeshNet::lostRelayiedPackets
uint32_t lostRelayiedPackets
Definition: mesh.h:1591
MeshNet::resetStatistics
void resetStatistics()
Resets statistics data.
Definition: mesh.cpp:607
MeshNet::setOnPacketErrorCallback
void setOnPacketErrorCallback(void(*callback)(MeshNet *, MeshPacketError, uint8_t, uint8_t, const MeshPacket *))
Sets callback function, which is called when packet timeout happened and packet is removed.
Definition: mesh.h:834
RFInterface::MaxChannelNumber
const uint8_t MaxChannelNumber
Maximum channel number. When this value is equal or lower than MinChannelNumber, radio channel cannot...
Definition: RFInterface.h:267
MeshNet::receiveInterruptEnabled
bool receiveInterruptEnabled
True if interrupt will be fired when new frame is received.
Definition: mesh.h:1346
MeshNet::getConnectionState
MeshConnectionState getConnectionState() const
Gets connection state of current node.
Definition: mesh.h:398
MESH_IMPL_CONSOLE_ITEM
#define MESH_IMPL_CONSOLE_ITEM
Set to 1 to implement SerialConsole ConsoleItem to MeshNet.
Definition: meshConfig.h:281
MeshNet::isMainGateway
bool isMainGateway() const
Checks if node is main gateway of network. Only main gateway can manage network. Other nodes,...
Definition: mesh.h:481
MeshNet::handleReceivedInterrupt
void handleReceivedInterrupt()
MeshNet::getMinChannel
uint8_t getMinChannel()
Get minimum channel number, that can be set using setChannel() method.
Definition: mesh.h:366
MeshNet::checkPacketStatic
static bool checkPacketStatic(MeshPacketBuilder *builder, const MeshPacketHeader &packetHeader, MeshMAC BSSID, SystemPacketType systemPacketType, const uint8_t *frameData, uint8_t frameDataSize, int8_t rssi)
Static function, which can be used as callback. In this function correct checkPacket() method is call...
Definition: mesh.cpp:844
MeshNet::sentPacketsTotal
uint32_t sentPacketsTotal
Definition: mesh.h:1598
MeshNet::CTS_until
uint64_t CTS_until
Clear to send until this time in microseconds, so node cannot send frames until this time....
Definition: mesh.h:1410
MeshNet::onSystemPingReceived
void onSystemPingReceived(bool valid, uint32_t duration)
This method is called when system ping packet response was received.
Definition: mesh.cpp:2459
MeshNet::addThisToInstArr
void addThisToInstArr()
Writes new class instance to the array of all created MeshNet instances. We need to know all created ...
Definition: mesh.cpp:3476
MeshNet::lostRemoteDataPackets
uint32_t lostRemoteDataPackets
Definition: mesh.h:1588
MeshNet::printStatistics
size_t printStatistics(OSTREAM &stream) const
Prints statistics informations.
Definition: mesh.cpp:2669
MeshNet::setOnDisconnectedCallback
void setOnDisconnectedCallback(void(*callback)(MeshNet *, MeshDisconnectReason, MeshMAC, uint8_t))
Sets callback function, which is called when current node is disconnected from network or when connec...
Definition: mesh.h:789
MPE_NoRoute
@ MPE_NoRoute
Definition: mesh.h:89
MeshNet::getNetworkBSSID
MeshMAC getNetworkBSSID() const
Gets BSSID of network, the node is connected to.
Definition: mesh.h:497
MeshNet::SendPacketAsFrame
bool SendPacketAsFrame(MeshPacket &packet, MeshMAC bssid)
Sends packet, which is converted using method PacketToFrame() to frame, which is then sends....
Definition: mesh.cpp:1901
MeshNet::sendingPacketIsForeign
bool sendingPacketIsForeign
True if packet, that is loaded in packetSplitter is for foreign network.
Definition: mesh.h:1326
MDR_DisconnectRequest
@ MDR_DisconnectRequest
Definition: mesh.h:69
MeshNet::AddrReservedUntil
uint32_t AddrReservedUntil
Time in milliseconds until which address of current node is for sure reserved in main gateway node's ...
Definition: mesh.h:1381
MeshNet::printMeshPacketError
static size_t printMeshPacketError(OSTREAM &stream, MeshPacketError value)
Prints MeshPacketError to stream.
Definition: mesh.cpp:2719
MeshNet::getNodeMAC
MeshMAC getNodeMAC() const
Gets current node unique MAC address.
Definition: mesh.h:505
SPT_PathDiscovery
typedef SPT_PathDiscovery
Definition: meshPacket.h:28
MeshNet::isDisconnecting
bool isDisconnecting() const
Checks if node is disconnecting right now. Node is finally disconnected after disconnect timeout or w...
Definition: mesh.h:390
MeshNet::end
virtual bool end()
Disables mesh node. It is recommended to disconnect from network before calling this method,...
Definition: mesh.cpp:134
IS_VALID_MESH_ADDRESS
#define IS_VALID_MESH_ADDRESS(address)
Checks if mesh address is valid. Accepted values from 0 to MAX_MESH_ADDRESS.
Definition: meshConfig.h:82
MeshNet::onNewPath
void onNewPath(int16_t index, const MeshRouteTableRow &row)
This method is called when new path was found (created). It is not called if path is prolonged.
Definition: mesh.cpp:2341
MeshNet::printFIDTable
bool printFIDTable(OSTREAM *stream) const
Prints FID Table in pretty format to stream.
Definition: mesh.cpp:2620
MeshNet::MeshNet
MeshNet()
Constructor without arguments.
Definition: mesh.h:119
MeshNet::getSentPacketsInNetworkCnt
uint32_t getSentPacketsInNetworkCnt() const
Gets count of successfully sent packets created by current node for current network....
Definition: mesh.h:657
MeshOIDTableRemoveReason
MeshOIDTableRemoveReason
Definition: meshTables.h:1916
MDR_Unknown
@ MDR_Unknown
Definition: mesh.h:73
MeshConnected
@ MeshConnected
Definition: mesh.h:47
MeshNet::onFrameReceive
void onFrameReceive(MeshPacketBuilder *builder, MeshPacketBuilderStatus status, const MeshFrameHeader &frameHeader, const uint8_t *frameData, uint8_t frameDataSize, int8_t rssi)
Method, which is called, when new valid frame is received. This method is used to calculate CTS time.
Definition: mesh.cpp:774
MPE_NoNetwork
@ MPE_NoNetwork
Definition: mesh.h:85
MeshNet::getSentFramesTotalCnt
uint32_t getSentFramesTotalCnt() const
Gets total count of successfully sent frames. Frame is successfully sent, when send was successful an...
Definition: mesh.h:627
MeshNet::isBackupGateway
bool isBackupGateway() const
Checks if node is backup gateway of network. Only main gateway can manage network....
Definition: mesh.h:489
MeshRouteTable::getNeighborFromSource
int16_t getNeighborFromSource(int8_t source) const
Gets neighbor, which is connected (directly or indirectly) with source node.
Definition: meshTables.h:1566
MeshNet::rf
RFInterface * rf
Pointer to radio interface, that is used by current class.
Definition: mesh.h:1404
MeshNet::restartCurrentPacketTransmission
void restartCurrentPacketTransmission(uint8_t maxFrameSize)
Restarts transmission of current packet. Splitting is restarted.
Definition: mesh.h:1062
MeshNet::getInstances
static MeshNet ** getInstances()
Gets array of all created MeshNet instances.
Definition: mesh.h:857
MeshVersion
Structure that represents MeshNet version. Real size of this class is always 2 bytes.
Definition: meshHelper.h:310
MeshNet::lostDataPackets
uint32_t lostDataPackets
Definition: mesh.h:1590
MeshNet::nextAutoConnectTime
uint32_t nextAutoConnectTime
Time in milliseconds, when auto connection attempt will be invoked.
Definition: mesh.h:1488
MeshNet::begin
virtual bool begin()
Starts MeshNet instance for current node with last settings.
Definition: mesh.cpp:130
MeshNet::NodeMAC
MeshMAC NodeMAC
Unique node physical MeshMAC address.
Definition: mesh.h:1365
MeshNetScanFlags
Network scan request flags.
Definition: meshPacketFlags.h:187
MESH_GATEWAY_MAX_ADDRESS
#define MESH_GATEWAY_MAX_ADDRESS
Maximum address, which is reserved for gateway. Defaultly addressed 0,1,2 are reserved for gateway an...
Definition: meshConfig.h:69
MeshNet::getMaxChannel
uint8_t getMaxChannel()
Get maximum channel number, that can be set using setChannel() method.
Definition: mesh.h:373
MeshPacketError
MeshPacketError
Enumeration that represents state or error of sent MeshPacket in MeshNet.
Definition: mesh.h:80
MPE_NodeLost
@ MPE_NodeLost
Definition: mesh.h:84
MeshNet::PacketToFrame
bool PacketToFrame(const MeshPacket &packet, MeshMAC bssid, uint8_t *outBuffer, uint8_t &bufferSize) const
Converts packet to frame. This can be called only if you are sure, that this packet won't be splitted...
Definition: mesh.cpp:1861
MeshNet::sendDisconnectPacket
bool sendDisconnectPacket(MeshNetDisconnectPacketType type)
Immediately sends disconnect packet (without pushing to outFIFO), that says current node is disconnec...
Definition: mesh.cpp:387
MeshFrameHeader
Definition: meshFrame.h:20
MeshNet::Version
const static MeshVersion Version
Version of MeshNet protocol.
Definition: mesh.h:468
MeshPacketSplitter::GetSplittedPacket
const MeshPacket & GetSplittedPacket() const
Gets packet, that is being splitted.
Definition: meshPacketSplitter.h:272
MeshNet::availablePacketsToSend
uint8_t availablePacketsToSend(uint8_t destAddress, bool ACK_R=false) const
Checks how many packet can be sent right now.
Definition: mesh.cpp:466
MeshNet::pathCreating
bool pathCreating(uint8_t address) const
Checks if path to specified node is creating right now.
Definition: mesh.h:427
MeshNet::printOutFIFO
bool printOutFIFO(OSTREAM *stream) const
Prints output FIFO buffer in pretty format to stream.
Definition: mesh.cpp:2646