Go to the documentation of this file.
31 #if MESH_IMPL_CONSOLE_ITEM == 1
32 #include <SerialConsole.h>
145 virtual bool begin();
280 int16_t
send(uint8_t addr,
const uint8_t* data, uint16_t dataSize);
339 int16_t
ping(uint8_t addr, uint32_t timeout, int16_t testDataLength = 0);
343 #ifndef MESH_NO_STATISTICS
348 #endif // !MESH_NO_STATISTICS
526 #ifndef MESH_NO_STATISTICS
680 #endif // !MESH_NO_STATISTICS
733 #ifndef MESH_NO_STATISTICS
740 #endif // !MESH_NO_STATISTICS
863 #if (MESH_IMPL_CONSOLE_ITEM == 1)
868 const char* getName()
override;
870 bool compareName(
char *name, uint8_t nameLength)
override;
872 bool respond(SerialConsole *console, Stream *stream, CommandWords &cmd)
override;
874 void respondRaw(SerialConsole *console, Stream *stream,
const char* value)
override;
876 void registerConsole(SerialConsole *console)
override;
878 void unregisterConsole()
override;
882 #endif //MESH_IMPL_CONSOLE_ITEM == 1
889 inline uint32_t millis()
const {
893 inline uint32_t micros()
const {
897 inline uint64_t micros64()
const {
898 return rf->micros64();
901 inline void delay(uint32_t time)
const {
902 return rf->delay(time);
905 inline void delayMicroseconds(uint32_t time)
const {
906 return rf->delayMicroseconds(time);
909 inline std::chrono::nanoseconds PauseSimulationTimer() {
910 return rf->PauseSimulationTimer();
913 inline void ResumeSimulationTimer() {
914 rf->ResumeSimulationTimer();
917 inline std::mutex& GetStreamMutex() {
918 return rf->GetStreamMutex();
921 inline std::mutex& GetMutex() {
922 return rf->GetMutex();
925 inline bool isLogOnly() {
926 return rf->isLogOnly();
929 inline void logTableChange(std::string& descriptor, TableChangeType changeType,
const char* data) {
930 return rf->logTableChange(descriptor, changeType, data);
938 static bool allocateInstancesBuffer(
int size);
943 static void deleteInstancesBuffer();
972 #if (MESH_IMPL_CONSOLE_ITEM == 1)
978 void showHelp(SerialConsole *console, Stream *stream);
979 #endif //MESH_IMPL_CONSOLE_ITEM
1035 #ifndef MESH_NO_STATISTICS
1044 #endif // !MESH_NO_STATISTICS
1098 bool sendACK(
const MeshACKSetup& setup,
bool asDisconnected =
false,
bool asConnectedToOld =
false);
1146 virtual void onNodeLost(uint8_t address,
bool nodeLostForever);
1240 bool systemPing(uint8_t addr, uint32_t timeout);
1573 #ifndef MESH_NO_STATISTICS
1607 #endif // !MESH_NO_STATISTICS
1611 #if MESH_IMPL_CONSOLE_ITEM == 1
1615 SerialConsole* srConsole = NULL;
1688 void clear(
bool disconnecting);
1701 static int instArrSize;
1708 #endif // SIMULATION
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
Definition: mesh.h:83
MeshPacketSplitter packetSplitter
Splits MeshPacket to multiple MeshFrames for transmission.
Definition: mesh.h:1628
bool packetSplitting()
Checks if some packet is loaded in packet splitter.
Definition: mesh.h:1078
Structure, which holds network scan result.
Definition: meshPacketFlags.h:452
void(* netScanResponseCallback)(MeshNet *, const MeshNetScanResult &)
Pointer to callback function called when network scan response was received.
Definition: mesh.h:1514
bool printWaitingFIFO(OSTREAM *stream) const
Prints waiting FIFO buffer in pretty format to stream.
Definition: mesh.cpp:2638
uint8_t AddrPriv
Address of current node. Can be between 0 - 250 or 254 when disconnected.
Definition: mesh.h:1360
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
Definition: mesh.h:88
This file contains interface (pattern) class, that has to be overridden to create driver for radio wh...
static size_t printMeshDisconnectReason(OSTREAM &stream, MeshDisconnectReason value)
Prints MeshDisconnectReason to stream.
Definition: mesh.cpp:2702
void setOnReceive(void(*callback)(MeshNet *, MeshPacket &))
Sets callback function, which is called when data packet is received.
Definition: mesh.h:845
uint8_t getNeighborNode(uint8_t address) const
Gets address of neighbor node, which is next node in path.
Definition: mesh.h:436
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
void setOnConnectedCallback(void(*callback)(MeshNet *))
Sets callback function, which is called when current node is connected to network.
Definition: mesh.h:776
Radio frequency interface, that helps to use meshNet with different radios or communication types....
Definition: RFInterface.h:48
@ MDR_DisconnectCalled
Definition: mesh.h:68
Structure, that contains one row with data from out ID table.
Definition: meshTables.h:249
uint8_t getLastID()
Gets last generated ID.
Definition: mesh.h:966
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
Definition: meshHelper.h:195
MeshPacketBuilder packetBuilder
Combines received MeshFrames to MeshPacket.
Definition: mesh.h:1623
bool canBeGateway() const
Checks if current node can be used as gateway or is used as gateway.
Definition: mesh.h:473
@ MDR_ConnectionTimeout
Definition: mesh.h:64
bool printIDTable(OSTREAM *stream) const
Prints ID Table in pretty format to stream.
Definition: mesh.cpp:2612
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
MeshMAC oldBSSID
Old BSSID of network the node was connected to last time.
Definition: mesh.h:1397
uint32_t disconnectUntil
Until this time in milliseconds node has to be disconnected.
Definition: mesh.h:1500
bool ignoreRSSIThreshold
True to ignore RSSI threshold on received network scan responses during scan.
Definition: mesh.h:1331
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
@ MDR_None
Definition: mesh.h:56
This class implements MeshNet protocol for microcontrollers.
Definition: mesh.h:104
void abortCurrentPacketTransmission(bool packetLost)
Aborts splitting and transmission of packet currently loaded in packetSplitter.
Definition: mesh.h:1034
uint8_t GetCurrentFrameIndex() const
Gets index of frame, that will be splitted.
Definition: meshPacketSplitter.h:173
uint32_t getLostFramesTotalCnt() const
Gets total count of lost frames. Frame is marked as lost, when attempt to send false,...
Definition: mesh.h:535
uint32_t sentPacketsInNetwork
Definition: mesh.h:1599
Structure, which has data, that are needed for ACK packet creation.
Definition: meshPacketBuilder.h:420
Structure, that contains one row with data from route table.
Definition: meshTables.h:70
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
Definition: mesh.h:86
MeshRouteTable< ROUTETABLE_SIZE > RTable
Routing table.
Definition: mesh.h:1635
void removeThisFromInstArr()
Removes this instance from instances array. This method has to be called in destructor.
Definition: mesh.cpp:3489
bool waitingBufferCheck
True if waitBuffer has to be checked and some packets has to be sent.
Definition: mesh.h:1336
@ MeshConnectionScan
Definition: mesh.h:45
uint32_t getLostRemoteDataPacketsCnt() const
Gets total count of lost data packets outside of current node created by current node....
Definition: mesh.h:608
static uint8_t instCount
Count of created instances of this class.
Definition: mesh.h:1713
@ MPE_Full_waitingFIFO
Definition: mesh.h:87
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
uint32_t lostPacketsTotal
Definition: mesh.h:1583
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
bool disconnect()
Disconnects current node from mesh network. It is recommended to check isDisconnecting() and isConnec...
Definition: mesh.cpp:318
char SSID[65]
SSID of network, node is connected to.
Definition: mesh.h:1375
MeshPacketStatus getPacketStatus(uint8_t ID) const
Tries to check, where is packet, that was sent by it's ID.
Definition: mesh.cpp:549
void disableAutoConnect()
Disables auto connection.
Definition: mesh.cpp:312
int16_t send(uint8_t addr, const uint8_t *data, uint16_t dataSize)
Sends data packet to specified node.
Definition: mesh.cpp:482
static MeshNet * instances[]
Array of all created MeshNet instances. Thanks to this array callback functions of MicroTable,...
Definition: mesh.h:1707
uint32_t lostPacketsInNetwork
Definition: mesh.h:1584
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
uint32_t relayiedPackets
Definition: mesh.h:1602
void(* onConnected)(MeshNet *)
This method is called when node is connected to network.
Definition: mesh.h:1519
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
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
MeshMAC lastScanResponderBSSID
BSSID of network, the system network scan was assigned to.
Definition: mesh.h:1471
MeshConnectionState connectionState
Connection state of current node.
Definition: mesh.h:1432
MeshOIDTable< OIDTABLE_SIZE > OIDTable
Table of sent (output) packets ID and destination (source is current node address)....
Definition: mesh.h:1652
bool printOIDTable(OSTREAM *stream) const
Prints OID Table in pretty format to stream.
Definition: mesh.cpp:2628
@ MPE_GenErr
Definition: mesh.h:91
@ MPE_Invalid
Definition: mesh.h:90
@ MeshDisconnected
Definition: mesh.h:44
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
#define UNKNOWN_MESH_ADDRESS
Address, of node, when node is not connected to any network.
Definition: meshConfig.h:62
bool isConnected() const
Checks if node is connected to any network.
Definition: mesh.h:383
MeshFIDTable< FIDTABLE_SIZE > FIDTable
Definition: mesh.h:1645
MeshDisconnectReason lastDisconnectReason
Last disconnect or connection fail reason.
Definition: mesh.h:1437
ERR_ACK_ErrorCode
Definition: meshPacketDecoders.h:258
@ MPE_OIDT_Overwrritten
Definition: mesh.h:82
static size_t printMeshConnectionState(OSTREAM &stream, MeshConnectionState value)
Prints MeshConnectionState to stream.
Definition: mesh.cpp:2691
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
This class supports splitting MeshPacket to multiple MeshFrames in one carriage. MeshPackets are spli...
Definition: meshPacketSplitter.h:50
@ MDR_ConnectionRefused
Definition: mesh.h:60
uint8_t oldNodeAddress
Old node address, that was assigned to node when it has been connected to some network.
Definition: mesh.h:1392
virtual ~MeshNet()
Virtual destructor.
Definition: mesh.cpp:100
MeshMAC autoConnectBSSID
BSSID of network, this node has to automatically connect to.
Definition: mesh.h:1483
@ MPE_AllocErr
Definition: mesh.h:92
void(* onDisconnected)(MeshNet *, MeshDisconnectReason, MeshMAC, uint8_t)
This method is called when node is disconnected from network.
Definition: mesh.h:1529
This file contains MeshPacketSplitter class, which can split MeshPacket to multiple MeshFrames.
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
uint8_t currentNetworkPackets
Count of packets in buffers, that belongs to the current connected network.
Definition: mesh.h:1442
uint8_t channel
Channel number, that will be set or is set.
Definition: mesh.h:1353
@ MDR_NotFound
Definition: mesh.h:59
MeshConnectionState
Enumeration that represents connection state of MeshNet.
Definition: mesh.h:43
MeshMAC NetworkBSSID
If node is disconnected, this is same as NodeMAC, else NetworkBSSID equals BSSID address of connected...
Definition: mesh.h:1370
uint32_t scanEndTime
Time in milliseconds, when network scan ends.
Definition: mesh.h:1450
MeshPacketError pushOutPacket(MeshPacket &packet, uint32_t timeout=0)
Pushes packet to output FIFO buffer.
Definition: mesh.cpp:2487
This file contains class which can concatinate packet splitted to frames back to packet.
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
uint8_t msgIDPriv
Last value of packet ID.
Definition: mesh.h:1671
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
Definition: mesh.h:62
@ MDR_ConnectionRemoteError
Definition: mesh.h:63
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
Definition: meshPacketDecoders.h:2239
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
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
void Restart(MeshMAC bssid, uint8_t maxFrameSize_)
Restarts splitting with old packet, which is reused.
Definition: meshPacketSplitter.cpp:24
const uint8_t MinChannelNumber
Minimum channel number. When this value is equal or higher than MaxChannelNumber, radio channel canno...
Definition: RFInterface.h:272
This class can build packet from multiple frames. It is usually used to concatinate data from packet,...
Definition: meshPacketBuilder.h:126
virtual void handle()
This method has to be called in main program loop as often as possible.
Definition: mesh.cpp:631
This file contains class which can be used to handling mesh packets.
void onSystemDisconnect(MeshDisconnectReason reason)
Do necessary work after node was disconnected or connection was aborted. onDisconnected method is cal...
Definition: mesh.cpp:2234
uint64_t lastReceiveTime
Time when last frame was received in microseconds.
Definition: mesh.h:1415
void restartCurrentPacketTransmission()
Restarts transmission of current packet. Splitting is restarted.
Definition: mesh.h:1053
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
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
uint32_t sentFramesInNetwork
Definition: mesh.h:1595
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
This class safetly handles allocation and deallocation of memory. It can be used in conjunction with ...
Definition: meshVariableArray.h:32
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
uint32_t lastScanTime
Time in milliseconds, when network scan was last time executed.
Definition: mesh.h:1455
@ MeshDisconnecting
Definition: mesh.h:48
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
bool sourceExists(uint8_t source) const
Checks if source node exists in table.
Definition: meshTables.h:1521
bool netScanRunning() const
Checks if network scan is running.
Definition: mesh.h:407
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
uint8_t GetRemainingFramesCount() const
Gets count of remaining frames, that will be splitted.
Definition: meshPacketSplitter.h:143
uint32_t lostFramesTotal
Definition: mesh.h:1579
MeshPacketBuilderStatus
Mesh packet builder status.
Definition: meshPacketBuilder.h:23
MeshPacketPriorityFIFO< MESH_OFIFO_HIGH_SIZE, MESH_OFIFO_LOW_SIZE > outFIFO
Packets that waits in buffer to be sent.
Definition: mesh.h:1659
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
uint32_t getSentDataPacketsCnt() const
Gets count of successfully sent data packets created by current node for current network....
Definition: mesh.h:667
Class, that stores mesh packet with it's data. The size of this class can be slightly bigger then rea...
Definition: meshPacket.h:158
bool beginCalled
True if begin was called.
Definition: mesh.h:1341
uint32_t lostRemotePackets
Definition: mesh.h:1587
bool pathExists(uint8_t address) const
Checks if path to specified node exists.
Definition: mesh.h:418
@ MPE_OK
Definition: mesh.h:81
uint32_t lastSentTime
Time, when was last frame sent in milliseconds.
Definition: mesh.h:1420
void clear(bool disconnecting)
Clears current class data.
Definition: mesh.cpp:159
MeshDisconnectReason
Enumeration that represents disconnect or connection fail reason of MeshNet.
Definition: mesh.h:55
RFInterface * getRadioInterfacePtr() const
Gets pointer to radio interface.
Definition: mesh.h:520
uint32_t connectionStepTime
Time in milliseconds, when connection state was last changed.
Definition: mesh.h:1477
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
Definition: mesh.h:61
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
uint32_t autoConnectInterval
Auto connect interval in milliseconds.
Definition: mesh.h:1493
bool connect(MeshMAC netBSSID, bool autoConnect=false, uint32_t autoConnectInterval=30000)
Connects to specified network.
Definition: mesh.cpp:248
void(* onReceive)(MeshNet *, MeshPacket &)
Function called when data packet is received.
Definition: mesh.h:1545
void(* onPacketErrorCallback)(MeshNet *, MeshPacketError, uint8_t, uint8_t, const MeshPacket *)
Definition: mesh.h:1569
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
uint32_t sentDataPackets
Definition: mesh.h:1601
void(* onRemDisconnected)(MeshNet *, uint8_t)
This method is called when some node from network is disconnected.
Definition: mesh.h:1537
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
#define OSTREAM
Definition: meshConfig.h:41
@ MeshConnectionRequest
Definition: mesh.h:46
bool setChannel(uint8_t channel_)
Sets network channel.
Definition: mesh.cpp:149
uint8_t lowestHopsToGateway
The smallest count of hops to gateway established during last system network scan.
Definition: mesh.h:1461
int16_t systemPingID
ID of last system ping packet.
Definition: mesh.h:1507
@ MDR_NetworkDrop
Definition: mesh.h:70
void processReceived()
Processes received frames.
Definition: mesh.cpp:1087
This file contains static classes that can decode system packets.
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
uint32_t getSentFramesInNetworkCnt() const
Gets total count of successfully sent frames. Frame is successfully sent, when send was successful an...
Definition: mesh.h:636
void processTransmit()
Processes transmission of one frame from output FIFO.
Definition: mesh.cpp:1594
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
This file contains classes, that implements tables for microcontrollers.
MeshPacketFIFO< MESH_WFIFO_SIZE > waitingFIFO
Packets, that has to be sent as routed packet, but path is not known yet.
Definition: mesh.h:1664
bool packetSplittingStarted
True if packet splitting has started.
Definition: mesh.h:1321
const bool canBeGateway_
True if current node can be used as gateway.
Definition: mesh.h:1311
This file contains classes, that implements FIFO buffers.
bool printRTable(OSTREAM *stream) const
Prints Route Table in pretty format to stream.
Definition: mesh.cpp:2604
uint32_t lostFramesInNetwork
Definition: mesh.h:1580
void Clear()
Clears and releases all rsources and stops splitting.
Definition: meshPacketSplitter.cpp:87
uint32_t sentFramesTotal
Definition: mesh.h:1594
size_t printMeshNetworkInfo(OSTREAM &stream) const
Prints informations about network, node is connected to.
Definition: mesh.cpp:2654
uint32_t getRelayiedPacketsCnt() const
Gets count of successfully relayed packets (packets, that were not created by current node)....
Definition: mesh.h:676
bool packetTransmitting()
Checks if some frame of currently splitting packet has been already transmitted.
Definition: mesh.h:1070
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
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
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
uint32_t getLostPacketsTotalCnt() const
Gets total count of lost packets created by current node. This count does not include packet,...
Definition: mesh.h:559
uint8_t getNewID()
Generates new ID for packet.
Definition: mesh.h:957
uint8_t frameTranCnt
(Re)Transmission count of last sent frame.
Definition: mesh.h:1425
bool sentFrameWasACK
True when sent frame was acknowledged.
Definition: mesh.h:1316
bool createPath(uint8_t address)
Creates path to specified node.
Definition: mesh.cpp:2566
virtual void processPacket(MeshPacket &packet, MeshMAC BSSID)
Processes received packet. Called in processReceived() method.
Definition: mesh.cpp:1198
#define INVALID_MESH_ADDRESS
Address, that is invalid and cannot be used.
Definition: meshConfig.h:56
uint32_t lostRelayiedPackets
Definition: mesh.h:1591
void resetStatistics()
Resets statistics data.
Definition: mesh.cpp:607
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
const uint8_t MaxChannelNumber
Maximum channel number. When this value is equal or lower than MinChannelNumber, radio channel cannot...
Definition: RFInterface.h:267
bool receiveInterruptEnabled
True if interrupt will be fired when new frame is received.
Definition: mesh.h:1346
MeshConnectionState getConnectionState() const
Gets connection state of current node.
Definition: mesh.h:398
#define MESH_IMPL_CONSOLE_ITEM
Set to 1 to implement SerialConsole ConsoleItem to MeshNet.
Definition: meshConfig.h:281
bool isMainGateway() const
Checks if node is main gateway of network. Only main gateway can manage network. Other nodes,...
Definition: mesh.h:481
void handleReceivedInterrupt()
uint8_t getMinChannel()
Get minimum channel number, that can be set using setChannel() method.
Definition: mesh.h:366
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
uint32_t sentPacketsTotal
Definition: mesh.h:1598
uint64_t CTS_until
Clear to send until this time in microseconds, so node cannot send frames until this time....
Definition: mesh.h:1410
void onSystemPingReceived(bool valid, uint32_t duration)
This method is called when system ping packet response was received.
Definition: mesh.cpp:2459
void addThisToInstArr()
Writes new class instance to the array of all created MeshNet instances. We need to know all created ...
Definition: mesh.cpp:3476
uint32_t lostRemoteDataPackets
Definition: mesh.h:1588
size_t printStatistics(OSTREAM &stream) const
Prints statistics informations.
Definition: mesh.cpp:2669
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
Definition: mesh.h:89
MeshMAC getNetworkBSSID() const
Gets BSSID of network, the node is connected to.
Definition: mesh.h:497
bool SendPacketAsFrame(MeshPacket &packet, MeshMAC bssid)
Sends packet, which is converted using method PacketToFrame() to frame, which is then sends....
Definition: mesh.cpp:1901
bool sendingPacketIsForeign
True if packet, that is loaded in packetSplitter is for foreign network.
Definition: mesh.h:1326
@ MDR_DisconnectRequest
Definition: mesh.h:69
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
static size_t printMeshPacketError(OSTREAM &stream, MeshPacketError value)
Prints MeshPacketError to stream.
Definition: mesh.cpp:2719
MeshMAC getNodeMAC() const
Gets current node unique MAC address.
Definition: mesh.h:505
typedef SPT_PathDiscovery
Definition: meshPacket.h:28
bool isDisconnecting() const
Checks if node is disconnecting right now. Node is finally disconnected after disconnect timeout or w...
Definition: mesh.h:390
virtual bool end()
Disables mesh node. It is recommended to disconnect from network before calling this method,...
Definition: mesh.cpp:134
#define IS_VALID_MESH_ADDRESS(address)
Checks if mesh address is valid. Accepted values from 0 to MAX_MESH_ADDRESS.
Definition: meshConfig.h:82
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
bool printFIDTable(OSTREAM *stream) const
Prints FID Table in pretty format to stream.
Definition: mesh.cpp:2620
MeshNet()
Constructor without arguments.
Definition: mesh.h:119
uint32_t getSentPacketsInNetworkCnt() const
Gets count of successfully sent packets created by current node for current network....
Definition: mesh.h:657
MeshOIDTableRemoveReason
Definition: meshTables.h:1916
@ MDR_Unknown
Definition: mesh.h:73
@ MeshConnected
Definition: mesh.h:47
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
Definition: mesh.h:85
uint32_t getSentFramesTotalCnt() const
Gets total count of successfully sent frames. Frame is successfully sent, when send was successful an...
Definition: mesh.h:627
bool isBackupGateway() const
Checks if node is backup gateway of network. Only main gateway can manage network....
Definition: mesh.h:489
int16_t getNeighborFromSource(int8_t source) const
Gets neighbor, which is connected (directly or indirectly) with source node.
Definition: meshTables.h:1566
RFInterface * rf
Pointer to radio interface, that is used by current class.
Definition: mesh.h:1404
void restartCurrentPacketTransmission(uint8_t maxFrameSize)
Restarts transmission of current packet. Splitting is restarted.
Definition: mesh.h:1062
static MeshNet ** getInstances()
Gets array of all created MeshNet instances.
Definition: mesh.h:857
Structure that represents MeshNet version. Real size of this class is always 2 bytes.
Definition: meshHelper.h:310
uint32_t lostDataPackets
Definition: mesh.h:1590
uint32_t nextAutoConnectTime
Time in milliseconds, when auto connection attempt will be invoked.
Definition: mesh.h:1488
virtual bool begin()
Starts MeshNet instance for current node with last settings.
Definition: mesh.cpp:130
MeshMAC NodeMAC
Unique node physical MeshMAC address.
Definition: mesh.h:1365
Network scan request flags.
Definition: meshPacketFlags.h:187
#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
uint8_t getMaxChannel()
Get maximum channel number, that can be set using setChannel() method.
Definition: mesh.h:373
MeshPacketError
Enumeration that represents state or error of sent MeshPacket in MeshNet.
Definition: mesh.h:80
@ MPE_NodeLost
Definition: mesh.h:84
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
bool sendDisconnectPacket(MeshNetDisconnectPacketType type)
Immediately sends disconnect packet (without pushing to outFIFO), that says current node is disconnec...
Definition: mesh.cpp:387
const static MeshVersion Version
Version of MeshNet protocol.
Definition: mesh.h:468
const MeshPacket & GetSplittedPacket() const
Gets packet, that is being splitted.
Definition: meshPacketSplitter.h:272
uint8_t availablePacketsToSend(uint8_t destAddress, bool ACK_R=false) const
Checks how many packet can be sent right now.
Definition: mesh.cpp:466
bool pathCreating(uint8_t address) const
Checks if path to specified node is creating right now.
Definition: mesh.h:427
bool printOutFIFO(OSTREAM *stream) const
Prints output FIFO buffer in pretty format to stream.
Definition: mesh.cpp:2646