MeshNet  1.0.0
meshNetGateway.h
Go to the documentation of this file.
1 
11 #ifndef MESH_NET_GATEWAY_h
12 #define MESH_NET_GATEWAY_h
13 
14 #include "mesh.h"
15 class MeshNetGateway: public MeshNet
16 {
17 public:
19  MeshNet(true),
20  dhcpTable(DHCPTABLE_ROW_LIFETIME)
21  {
22 #ifdef SIMULATION
23  dhcpTable.mn = this;
24  dhcpTable.descriptor = "dhcp";
25 #endif //SIMULATION
26  }
27 
36  virtual bool begin(MeshMAC mac, RFInterface& RFI, const char* SSID_);
37 
42  bool begin(MeshMAC mac, RFInterface& RFI) override {
43  return false;
44  }
45 
52  bool begin() override;
53 
58  bool end() override;
59 
66  bool dropNetwork(bool forced);
67 
75  bool requestNodeDisconnect(uint8_t address);
76 
83 
88  inline void setDiscRequestFailedCallback(bool(*callback)(MeshNet*, uint8_t)) {
89  reqNodeDiscFailed = callback;
90  }
91 
103  inline void setOnConnectionPermissionCallback(bool(*callback)(MeshNetGateway*, uint16_t, uint16_t, MeshMAC)) {
104  connectionPermissionFunc = callback;
105  }
106 
107  bool printDHCPTable(OSTREAM* stream);
108 
112  void handle() override;
113 
114 
115 #if (MESH_IMPL_CONSOLE_ITEM == 1)
116 
118 
119  bool respond(SerialConsole *console, Stream *stream, CommandWords &cmd) override;
120 
121 #endif //MESH_IMPL_CONSOLE_ITEM == 1
122 
123 protected:
124 
132  void processPacket(MeshPacket& packet, MeshMAC BSSID) override;
133 
142  virtual void onPacketError(MeshPacketError error, uint8_t packetID, uint8_t packetDest, SystemPacketType packetType, const MeshPacket* packet_ptr) override;
143 
151  void routeTableUpdate(const MeshPacketHeader& header, MeshMAC BSSID, int8_t rssi) override;
152 
158  void onNodeLost(uint8_t address, bool nodeLostForever) override;
159 
164  void makeInvalidDHCPRow(uint8_t address);
165 
175  void onDHCPValidityChanged(int16_t index, bool valid, bool removed);
176 
177 #if (MESH_IMPL_CONSOLE_ITEM == 1)
178 
180 
186  void showGatewayHelp(SerialConsole *console, Stream *stream);
187 
188 #endif //MESH_IMPL_CONSOLE_ITEM == 1
189 
198  bool(*connectionPermissionFunc)(MeshNetGateway*, uint16_t, uint16_t, MeshMAC) = NULL;
199 
203  bool(*reqNodeDiscFailed)(MeshNet*, uint8_t) = NULL;
204 
206 
207 };
208 
209 #endif // !MESH_NET_GATEWAY_h
MeshMACTable
Mesh MAC table, is lookup table for node address and MAC address. It acts as DHCP table....
Definition: meshTables.h:1168
MeshNetGateway::setOnConnectionPermissionCallback
void setOnConnectionPermissionCallback(bool(*callback)(MeshNetGateway *, uint16_t, uint16_t, MeshMAC))
Sets pointer to function, which is called when gateway has to decide, if node can be connected to net...
Definition: meshNetGateway.h:103
RFInterface
Radio frequency interface, that helps to use meshNet with different radios or communication types....
Definition: RFInterface.h:48
MeshNetGateway::begin
bool begin(MeshMAC mac, RFInterface &RFI) override
This method cannot be used with gateway, that's why it always returns false.
Definition: meshNetGateway.h:42
MeshNetGateway::setDiscRequestFailedCallback
void setDiscRequestFailedCallback(bool(*callback)(MeshNet *, uint8_t))
This timeout is called, when requestNodeDisconnect() failed, because response was not received until ...
Definition: meshNetGateway.h:88
MeshNet
This class implements MeshNet protocol for microcontrollers.
Definition: mesh.h:104
MeshNetGateway::end
bool end() override
Disables mesh node. It is recommended to drop network before calling this method to get know to nodes...
Definition: meshNetGateway.cpp:30
MeshNetGateway
Definition: meshNetGateway.h:15
MeshNetGateway::begin
bool begin() override
Starts MeshNet gateway instance for current node with last setings.
Definition: meshNetGateway.cpp:26
MeshNetGateway::requestNodeDisconnect
bool requestNodeDisconnect(uint8_t address)
Request node disconnection from network. Node may ignore this request or may not receive this request...
Definition: meshNetGateway.cpp:47
MeshNetGateway::onNodeLost
void onNodeLost(uint8_t address, bool nodeLostForever) override
This method is called, when some node is disconnected from network or does not responds to sent packe...
Definition: meshNetGateway.cpp:247
MeshNetGateway::onDHCPValidityChanged
void onDHCPValidityChanged(int16_t index, bool valid, bool removed)
This method is called when DHCP row validity has changed. There can be 3 states of validity:
Definition: meshNetGateway.cpp:263
MeshNetGateway::routeTableUpdate
void routeTableUpdate(const MeshPacketHeader &header, MeshMAC BSSID, int8_t rssi) override
Updates route table when valid packet from node with same network is received.ň
Definition: meshNetGateway.cpp:236
MeshNetGateway::processPacket
void processPacket(MeshPacket &packet, MeshMAC BSSID) override
Processed received packet. Called in processReceived() method.
Definition: meshNetGateway.cpp:77
MeshNetGateway::handle
void handle() override
This method has to be called in main program loop as often as possible.
Definition: meshNetGateway.cpp:269
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
MeshNetGateway::MeshNetGateway
MeshNetGateway()
Definition: meshNetGateway.h:18
mesh.h
This file contains class called MeshNet, which implements sensory mesh protocol for microcontrollers.
OSTREAM
#define OSTREAM
Definition: meshConfig.h:41
MeshNetGateway::onPacketError
virtual void onPacketError(MeshPacketError error, uint8_t packetID, uint8_t packetDest, SystemPacketType packetType, const MeshPacket *packet_ptr) override
This method is called when some error happened to any packet created by current node.
Definition: meshNetGateway.cpp:224
MeshNetGateway::printDHCPTable
bool printDHCPTable(OSTREAM *stream)
Definition: meshNetGateway.cpp:69
DHCPTABLE_ROW_LIFETIME
#define DHCPTABLE_ROW_LIFETIME
Definition: meshConfig.h:150
MeshMAC
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
MeshNetGateway::makeInvalidDHCPRow
void makeInvalidDHCPRow(uint8_t address)
Makes invalid row in DHCP table by assigned address.
Definition: meshNetGateway.cpp:255
MeshPacketHeader
This structure contains informations about mesh packet, that are stored in it's header.
Definition: meshPacket.h:42
MeshNetGateway::dropNetwork
bool dropNetwork(bool forced)
Drops whole network, all nodes will be disconnected when they receive this packet....
Definition: meshNetGateway.cpp:38
MeshPacketError
MeshPacketError
Enumeration that represents state or error of sent MeshPacket in MeshNet.
Definition: mesh.h:80