EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Class definition for a single sensor Node. More...
#include <NodeList.h>
Public Member Functions | |
Node () | |
Plain constructor. More... | |
Node (node_t nodeData) | |
Constructor that initializes data from another Node data. More... | |
uint8_t * | getMacAddress () |
Gets address from Node. More... | |
uint16_t | getNodeId () |
Gets Node identifier. More... | |
void | setNodeId (uint16_t nodeId) |
Sets a new Node identifier. More... | |
char * | getNodeName () |
Gets Node name. More... | |
void | setNodeName (const char *name) |
Sets Node name. More... | |
uint8_t * | getEncriptionKey () |
Gets Node encryption key. More... | |
void | setEncryptionKey (const uint8_t *key) |
Sets encryption key. More... | |
time_t | getKeyValidFrom () |
Gets last time that key was agreed with gateway. More... | |
void | setKeyValidFrom (time_t keyValidFrom) |
Sets time when key was agreed with gateway. More... | |
time_t | getLastMessageTime () |
Gets last time that node sent a message. More... | |
void | setLastMessageTime () |
Sets current moment as last node message time. More... | |
uint16_t | getLastMessageCounter () |
Gets counter for last received message from node. More... | |
uint16_t | getLastControlCounter () |
Gets counter for last received control message from node. More... | |
uint16_t | getLastDownlinkMsgCounter () |
Gets counter for last downlink message from gateway. More... | |
void | setLastMessageCounter (uint16_t counter) |
Sets counter for last received message from node. More... | |
void | setLastControlCounter (uint16_t counter) |
Sets counter for last received control message from node. More... | |
void | setLastDownlinkMsgCounter (uint16_t counter) |
Sets counter for last downlink message from gateway. More... | |
void | setMacAddress (const uint8_t *macAddress) |
Sets node address. More... | |
bool | isKeyValid () |
Gets shared key validity for this node. More... | |
void | setKeyValid (bool status) |
Sets shared key validity for this node. More... | |
bool | isRegistered () |
Gets registration state of this node. More... | |
status_t | getStatus () |
Gets status for finite state machine that represents node. More... | |
void | setStatus (status_t status) |
Sets status for finite state machine that represents node. More... | |
node_t | getNodeData () |
Gets a struct that represents node object. May be used for node serialization. More... | |
void | printToSerial (Stream *port=&Serial) |
Dumps node data to the given stream, Serial by default. This method may be used for debugging. More... | |
void | reset () |
Resets all node fields to a default initial and not registered state. More... | |
void | setSleepy (bool sleepy) |
Sets node working mode regarding battery saving strategy. If node is sleepy it will turn into deep sleep after sending a message. In this case it will wait for a short while for a downlink message from gateway. More... | |
void | setInitAsSleepy (bool sleepy) |
Records if node started as a sleepy node or not. If it did not started so it will never accept sleep time changes. More... | |
bool | getInitAsSleepy () |
Gets initial sleepy mode. More... | |
bool | getSleepy () |
Gets node working mode regarding battery saving strategy. If node is sleepy it will turn into deep sleep after sending a message. In this case it will wait for a short while for a downlink message from gateway. More... | |
bool | broadcastIsEnabled () |
Returns if node broadcast mode is enabled. In that case, node is able to send and receive encrypted broadcast messages. If this is enabled this will be notified to gateway so that it sends broadcast key. Notice this mode is optional and does not disable the ability to send normal messages. More... | |
void | enableBroadcast (bool broadcast) |
Enables node broadcast mode. Node will request broadcast key to Gateway. When it is received node will be able to send and receive encrypted broadcast messages. More... | |
void | setBroadcastKeyRequested (bool request) |
Mark node to be waiting for broadcast key. More... | |
bool | isBroadcastKeyRequested () |
Checks if node is waiting for broadcast key. More... | |
void | updatePacketsRate (float value) |
Adds a new message rate value for filter calculation. More... | |
int8_t | getRSSI () |
Gets last RSSI measurement of Gateway. More... | |
void | setRSSI (int8_t rssi) |
Stores last RSSI measurement of Gateway. More... | |
bool | useTimeSync () |
Gets node info to check if it has requested time sync ever. More... | |
void | setTimeSyncEnabled () |
Mark node as time sync enabled. More... | |
uint8_t * | getVersion () |
Gets node EnigmaIOT version. More... | |
void | setVersion (uint8_t major, uint8_t minor, uint8_t incremental) |
Sets node EnigmaIOT version. More... | |
Public Attributes | |
uint8_t | queuedMessage [MAX_MESSAGE_LENGTH] |
Message queued for sending to node in case of sleepy mode. More... | |
size_t | qMessageLength |
Queued message length. More... | |
bool | qMessagePending = false |
True if message should be sent just after next data message More... | |
uint32_t | packetNumber = 0 |
Number of packets received from node to gateway. More... | |
uint32_t | packetErrors = 0 |
Number of errored packets. More... | |
double | per = 0 |
Current packet error rate of a specific node. More... | |
double | packetsHour = 0 |
Packet rate for a specific nope. More... | |
Protected Member Functions | |
void | initRateFilter () |
Starts smoothing filter. More... | |
Protected Attributes | |
bool | keyValid |
Node shared key valid. More... | |
status_t | status |
Current node status. See enum node_status More... | |
uint16_t | lastMessageCounter |
Last message counter state for specific Node. More... | |
uint16_t | lastControlCounter |
Last message counter state for specific Node. More... | |
uint16_t | lastDownlinkMsgCounter |
Last downlink message counter state for specific Node. More... | |
uint16_t | nodeId |
Node identifier asigned by gateway. More... | |
timer_t | keyValidFrom |
Last time that Node and Gateway agreed a key. More... | |
bool | sleepyNode = true |
Node sleepy definition. More... | |
bool | broadcastEnabled = false |
Node is able to send broadcast messages. More... | |
bool | broadcastKeyRequested = false |
Node is waiting for broadcast key. More... | |
bool | initAsSleepy |
Stores initial sleepy node. If this is false, this node does not accept sleep time changes. More... | |
bool | askedTimeSync = false |
uint8_t | mac [ENIGMAIOT_ADDR_LEN] |
Node address. More... | |
uint8_t | key [KEY_LENGTH] |
Shared key. More... | |
timer_t | lastMessageTime |
Node state. More... | |
FilterClass * | rateFilter |
Filter for message rate smoothing. More... | |
char | nodeName [NODE_NAME_LENGTH] |
Node name. Use as a human friendly name to avoid use of numeric address. More... | |
int8_t | rssi |
Stores last RSSI measurement. More... | |
uint8_t | enigmaIOTVersion [3] |
Protocol version, filled when a version message is received. More... | |
Friends | |
class | NodeList |
Class definition for a single sensor Node.
Definition at line 109 of file NodeList.h.
Node::Node | ( | ) |
Plain constructor.
Definition at line 78 of file NodeList.cpp.
|
explicit |
Constructor that initializes data from another Node data.
nodeData | node_instance struct that contains initalization values for new Node |
node_instance
struct Definition at line 84 of file NodeList.cpp.
|
inline |
Returns if node broadcast mode is enabled. In that case, node is able to send and receive encrypted broadcast messages. If this is enabled this will be notified to gateway so that it sends broadcast key. Notice this mode is optional and does not disable the ability to send normal messages.
true
if node has broadcast mode enabled. Definition at line 373 of file NodeList.h.
|
inline |
Enables node broadcast mode. Node will request broadcast key to Gateway. When it is received node will be able to send and receive encrypted broadcast messages.
broadcast | true to enable broadcast mode on this node. |
Definition at line 386 of file NodeList.h.
|
inline |
Gets Node encryption key.
Definition at line 173 of file NodeList.h.
|
inline |
Gets initial sleepy mode.
true
if node started as sleepy. false
otherwise Definition at line 354 of file NodeList.h.
|
inline |
Gets last time that key was agreed with gateway.
Definition at line 187 of file NodeList.h.
|
inline |
Gets counter for last received control message from node.
Definition at line 226 of file NodeList.h.
|
inline |
Gets counter for last downlink message from gateway.
Definition at line 234 of file NodeList.h.
|
inline |
Gets counter for last received message from node.
Definition at line 218 of file NodeList.h.
|
inline |
Gets last time that node sent a message.
Definition at line 203 of file NodeList.h.
|
inline |
Gets address from Node.
Definition at line 128 of file NodeList.h.
node_t Node::getNodeData | ( | ) |
Gets a struct that represents node object. May be used for node serialization.
Definition at line 17 of file NodeList.cpp.
|
inline |
|
inline |
|
inline |
Gets last RSSI measurement of Gateway.
Definition at line 418 of file NodeList.h.
|
inline |
Gets node working mode regarding battery saving strategy. If node is sleepy it will turn into deep sleep after sending a message. In this case it will wait for a short while for a downlink message from gateway.
true
if node sleeps after sending a message and wait for downlink. false
if downlink may happen in any moment Definition at line 363 of file NodeList.h.
|
inline |
Gets status for finite state machine that represents node.
Definition at line 300 of file NodeList.h.
|
inline |
Gets node EnigmaIOT version.
Definition at line 449 of file NodeList.h.
|
protected |
Starts smoothing filter.
Definition at line 67 of file NodeList.cpp.
|
inline |
Checks if node is waiting for broadcast key.
true
if node is waiting. Definition at line 404 of file NodeList.h.
|
inline |
Gets shared key validity for this node.
true
if node shared key is valid. false
otherwise Definition at line 276 of file NodeList.h.
|
inline |
Gets registration state of this node.
true
if node is registered on gateway. false
otherwise Definition at line 292 of file NodeList.h.
void Node::printToSerial | ( | Stream * | port = &Serial | ) |
Dumps node data to the given stream, Serial by default. This method may be used for debugging.
port | Stream to print data to |
Definition at line 32 of file NodeList.cpp.
void Node::reset | ( | ) |
Resets all node fields to a default initial and not registered state.
Definition at line 106 of file NodeList.cpp.
|
inline |
Mark node to be waiting for broadcast key.
request | true to mark node as waiting. |
Definition at line 396 of file NodeList.h.
void Node::setEncryptionKey | ( | const uint8_t * | key | ) |
|
inline |
Records if node started as a sleepy node or not. If it did not started so it will never accept sleep time changes.
sleepy | true if node started as sleepy. false otherwise |
Definition at line 346 of file NodeList.h.
|
inline |
Sets shared key validity for this node.
status | node key validity |
Definition at line 284 of file NodeList.h.
|
inline |
Sets time when key was agreed with gateway.
keyValidFrom | Time on key agreement |
Definition at line 195 of file NodeList.h.
|
inline |
Sets counter for last received control message from node.
counter | Message counter |
Definition at line 250 of file NodeList.h.
|
inline |
Sets counter for last downlink message from gateway.
counter | Message counter |
Definition at line 258 of file NodeList.h.
|
inline |
Sets counter for last received message from node.
counter | Message counter |
Definition at line 242 of file NodeList.h.
|
inline |
Sets current moment as last node message time.
Definition at line 210 of file NodeList.h.
|
inline |
|
inline |
Sets a new Node identifier.
nodeId | New nodeId value |
Definition at line 144 of file NodeList.h.
|
inline |
Sets Node name.
name | Custom node name. This should be unique in the network |
Definition at line 164 of file NodeList.h.
|
inline |
Stores last RSSI measurement of Gateway.
rssi | RSSI power of Gateway signal |
Definition at line 426 of file NodeList.h.
|
inline |
Sets node working mode regarding battery saving strategy. If node is sleepy it will turn into deep sleep after sending a message. In this case it will wait for a short while for a downlink message from gateway.
sleepy | true if node sleeps after sending a message and wait for downlink. false if downlink may happen in any moment |
Definition at line 334 of file NodeList.h.
|
inline |
Sets status for finite state machine that represents node.
status | Node status |
Definition at line 308 of file NodeList.h.
|
inline |
Mark node as time sync enabled.
Definition at line 441 of file NodeList.h.
|
inline |
Sets node EnigmaIOT version.
major | Major protocol version. In 0.9.6, this should be 0 |
minor | Minor protocol version. In 0.9.6, this should be 9 |
incremental | Incremental protocol version. In 0.9.6, this should be 6 |
Definition at line 459 of file NodeList.h.
void Node::updatePacketsRate | ( | float | value | ) |
Adds a new message rate value for filter calculation.
value | Next value for calculation |
Definition at line 101 of file NodeList.cpp.
|
inline |
Gets node info to check if it has requested time sync ever.
Definition at line 434 of file NodeList.h.
|
friend |
Definition at line 502 of file NodeList.h.
|
protected |
Definition at line 488 of file NodeList.h.
|
protected |
Node is able to send broadcast messages.
Definition at line 485 of file NodeList.h.
|
protected |
Node is waiting for broadcast key.
Definition at line 486 of file NodeList.h.
|
protected |
Protocol version, filled when a version message is received.
Definition at line 495 of file NodeList.h.
|
protected |
Stores initial sleepy node. If this is false, this node does not accept sleep time changes.
Definition at line 487 of file NodeList.h.
|
protected |
Shared key.
Definition at line 490 of file NodeList.h.
|
protected |
Node shared key valid.
Definition at line 477 of file NodeList.h.
|
protected |
Last time that Node and Gateway agreed a key.
Definition at line 483 of file NodeList.h.
|
protected |
Last message counter state for specific Node.
Definition at line 480 of file NodeList.h.
|
protected |
Last downlink message counter state for specific Node.
Definition at line 481 of file NodeList.h.
|
protected |
Last message counter state for specific Node.
Definition at line 479 of file NodeList.h.
|
protected |
Node state.
Definition at line 491 of file NodeList.h.
|
protected |
Node address.
Definition at line 489 of file NodeList.h.
|
protected |
Node identifier asigned by gateway.
Definition at line 482 of file NodeList.h.
|
protected |
Node name. Use as a human friendly name to avoid use of numeric address.
Definition at line 493 of file NodeList.h.
uint32_t Node::packetErrors = 0 |
Number of errored packets.
Definition at line 470 of file NodeList.h.
uint32_t Node::packetNumber = 0 |
Number of packets received from node to gateway.
Definition at line 469 of file NodeList.h.
double Node::packetsHour = 0 |
Packet rate for a specific nope.
Definition at line 472 of file NodeList.h.
double Node::per = 0 |
Current packet error rate of a specific node.
Definition at line 471 of file NodeList.h.
size_t Node::qMessageLength |
Queued message length.
Definition at line 466 of file NodeList.h.
bool Node::qMessagePending = false |
True
if message should be sent just after next data message
Definition at line 467 of file NodeList.h.
uint8_t Node::queuedMessage[MAX_MESSAGE_LENGTH] |
Message queued for sending to node in case of sleepy mode.
Definition at line 465 of file NodeList.h.
|
protected |
Filter for message rate smoothing.
Definition at line 492 of file NodeList.h.
|
protected |
Stores last RSSI measurement.
Definition at line 494 of file NodeList.h.
|
protected |
Node sleepy definition.
Definition at line 484 of file NodeList.h.
|
protected |
Current node status. See enum node_status
Definition at line 478 of file NodeList.h.