EnigmaIOT  0.9.3
Secure sensor and gateway platform based on ESP8266 and ESP32
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Node Class Reference

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...
 
void setLastMessageCounter (uint16_t counter)
 Sets counter for last received message from node. More...
 
void setMacAddress (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...
 
void updatePacketsRate (float value)
 Adds a new message rate value for filter calculation. 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 ffor a specific nope. More...
 
int64_t t1
 
int64_t t2
 
int64_t t3
 
int64_t t4
 Timestaps to calculate clock offset. 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 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 initAsSleepy
 Stores initial sleepy node. If this is false, this node does not accept sleep time changes. More...
 
uint8_t mac [ENIGMAIOT_ADDR_LEN]
 Node address. More...
 
uint8_t key [KEY_LENGTH]
 Shared key. More...
 
timer_t lastMessageTime
 Node state. More...
 
FilterClassrateFilter
 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...
 

Friends

class NodeList
 

Detailed Description

Class definition for a single sensor Node.

Definition at line 93 of file NodeList.h.

Constructor & Destructor Documentation

◆ Node() [1/2]

Node::Node ( )

Plain constructor.

Returns
Returns a new unregistered Node instance

Definition at line 77 of file NodeList.cpp.

◆ Node() [2/2]

Node::Node ( node_t  nodeData)

Constructor that initializes data from another Node data.

Parameters
nodeDatanode_instance struct that contains initalization values for new Node
Returns
Returns a new Node instance with same data as given node_instance struct

Definition at line 83 of file NodeList.cpp.

Member Function Documentation

◆ getEncriptionKey()

uint8_t* Node::getEncriptionKey ( )
inline

Gets Node encryption key.

Returns
Returns a pointer to Node encryption key

Definition at line 157 of file NodeList.h.

◆ getInitAsSleepy()

bool Node::getInitAsSleepy ( )
inline

Gets initial sleepy mode.

Returns
true if node started as sleepy. false otherwise

Definition at line 306 of file NodeList.h.

◆ getKeyValidFrom()

time_t Node::getKeyValidFrom ( )
inline

Gets last time that key was agreed with gateway.

Returns
Time in milliseconds of last key agreement

Definition at line 171 of file NodeList.h.

◆ getLastMessageCounter()

uint16_t Node::getLastMessageCounter ( )
inline

Gets counter for last received message from node.

Returns
Message counter

Definition at line 202 of file NodeList.h.

◆ getLastMessageTime()

time_t Node::getLastMessageTime ( )
inline

Gets last time that node sent a message.

Returns
Time in milliseconds of last received node message

Definition at line 187 of file NodeList.h.

◆ getMacAddress()

uint8_t* Node::getMacAddress ( )
inline

Gets address from Node.

Returns
Returns a pointer to Node address

Definition at line 112 of file NodeList.h.

◆ getNodeData()

node_t Node::getNodeData ( )

Gets a struct that represents node object. May be used for node serialization.

Returns
Node struct

Definition at line 17 of file NodeList.cpp.

◆ getNodeId()

uint16_t Node::getNodeId ( )
inline

Gets Node identifier.

Returns
Returns Node identifier

Definition at line 120 of file NodeList.h.

◆ getNodeName()

char* Node::getNodeName ( )
inline

Gets Node name.

Returns
Returns Node name

Definition at line 136 of file NodeList.h.

◆ getSleepy()

bool Node::getSleepy ( )
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.

Returns
true if node sleeps after sending a message and wait for downlink. false if downlink may happen in any moment

Definition at line 315 of file NodeList.h.

◆ getStatus()

status_t Node::getStatus ( )
inline

Gets status for finite state machine that represents node.

Returns
Node status

Definition at line 252 of file NodeList.h.

◆ initRateFilter()

void Node::initRateFilter ( )
protected

Starts smoothing filter.

Definition at line 66 of file NodeList.cpp.

◆ isKeyValid()

bool Node::isKeyValid ( )
inline

Gets shared key validity for this node.

Returns
true if node shared key is valid. false otherwise

Definition at line 228 of file NodeList.h.

◆ isRegistered()

bool Node::isRegistered ( )
inline

Gets registration state of this node.

Returns
true if node is registered on gateway. false otherwise

Definition at line 244 of file NodeList.h.

◆ printToSerial()

void Node::printToSerial ( Stream *  port = &Serial)

Dumps node data to the given stream, Serial by default. This method may be used for debugging.

Parameters
portStream to print data to

Definition at line 31 of file NodeList.cpp.

◆ reset()

void Node::reset ( )

Resets all node fields to a default initial and not registered state.

Definition at line 104 of file NodeList.cpp.

◆ setEncryptionKey()

void Node::setEncryptionKey ( const uint8_t *  key)

Sets encryption key.

Parameters
keyNew key

Definition at line 11 of file NodeList.cpp.

◆ setInitAsSleepy()

void Node::setInitAsSleepy ( bool  sleepy)
inline

Records if node started as a sleepy node or not. If it did not started so it will never accept sleep time changes.

Parameters
sleepytrue if node started as sleepy. false otherwise

Definition at line 298 of file NodeList.h.

◆ setKeyValid()

void Node::setKeyValid ( bool  status)
inline

Sets shared key validity for this node.

Parameters
statusnode key validity

Definition at line 236 of file NodeList.h.

◆ setKeyValidFrom()

void Node::setKeyValidFrom ( time_t  keyValidFrom)
inline

Sets time when key was agreed with gateway.

Parameters
keyValidFromTime on key agreement

Definition at line 179 of file NodeList.h.

◆ setLastMessageCounter()

void Node::setLastMessageCounter ( uint16_t  counter)
inline

Sets counter for last received message from node.

Parameters
counterMessage counter

Definition at line 210 of file NodeList.h.

◆ setLastMessageTime()

void Node::setLastMessageTime ( )
inline

Sets current moment as last node message time.

Definition at line 194 of file NodeList.h.

◆ setMacAddress()

void Node::setMacAddress ( uint8_t *  macAddress)
inline

Sets node address.

Parameters
macAddressNode address

Definition at line 218 of file NodeList.h.

◆ setNodeId()

void Node::setNodeId ( uint16_t  nodeId)
inline

Sets a new Node identifier.

Parameters
nodeIdNew nodeId value

Definition at line 128 of file NodeList.h.

◆ setNodeName()

void Node::setNodeName ( const char *  name)
inline

Sets Node name.

Parameters
nameCustom node name. This should be unique in the network

Definition at line 148 of file NodeList.h.

◆ setSleepy()

void Node::setSleepy ( bool  sleepy)
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.

Parameters
sleepytrue if node sleeps after sending a message and wait for downlink. false if downlink may happen in any moment

Definition at line 286 of file NodeList.h.

◆ setStatus()

void Node::setStatus ( status_t  status)
inline

Sets status for finite state machine that represents node.

Parameters
statusNode status

Definition at line 260 of file NodeList.h.

◆ updatePacketsRate()

void Node::updatePacketsRate ( float  value)

Adds a new message rate value for filter calculation.

Parameters
valueNext value for calculation

Definition at line 99 of file NodeList.cpp.

Friends And Related Function Documentation

◆ NodeList

friend class NodeList
friend

Definition at line 355 of file NodeList.h.

Member Data Documentation

◆ initAsSleepy

bool Node::initAsSleepy
protected

Stores initial sleepy node. If this is false, this node does not accept sleep time changes.

Definition at line 343 of file NodeList.h.

◆ key

uint8_t Node::key[KEY_LENGTH]
protected

Shared key.

Definition at line 345 of file NodeList.h.

◆ keyValid

bool Node::keyValid
protected

Node shared key valid.

Definition at line 337 of file NodeList.h.

◆ keyValidFrom

timer_t Node::keyValidFrom
protected

Last time that Node and Gateway agreed a key.

Definition at line 341 of file NodeList.h.

◆ lastMessageCounter

uint16_t Node::lastMessageCounter
protected

Last message counter state for specific Node.

Definition at line 339 of file NodeList.h.

◆ lastMessageTime

timer_t Node::lastMessageTime
protected

Node state.

Definition at line 346 of file NodeList.h.

◆ mac

uint8_t Node::mac[ENIGMAIOT_ADDR_LEN]
protected

Node address.

Definition at line 344 of file NodeList.h.

◆ nodeId

uint16_t Node::nodeId
protected

Node identifier asigned by gateway.

Definition at line 340 of file NodeList.h.

◆ nodeName

char Node::nodeName[NODE_NAME_LENGTH]
protected

Node name. Use as a human friendly name to avoid use of numeric address*‍/.

Definition at line 348 of file NodeList.h.

◆ packetErrors

uint32_t Node::packetErrors = 0

Number of errored packets.

Definition at line 330 of file NodeList.h.

◆ packetNumber

uint32_t Node::packetNumber = 0

Number of packets received from node to gateway.

Definition at line 329 of file NodeList.h.

◆ packetsHour

double Node::packetsHour = 0

Packet rate ffor a specific nope.

Definition at line 332 of file NodeList.h.

◆ per

double Node::per = 0

Current packet error rate of a specific node.

Definition at line 331 of file NodeList.h.

◆ qMessageLength

size_t Node::qMessageLength

Queued message length.

Definition at line 326 of file NodeList.h.

◆ qMessagePending

bool Node::qMessagePending = false

True if message should be sent just after next data message

Definition at line 327 of file NodeList.h.

◆ queuedMessage

uint8_t Node::queuedMessage[MAX_MESSAGE_LENGTH]

Message queued for sending to node in case of sleepy mode.

Definition at line 325 of file NodeList.h.

◆ rateFilter

FilterClass* Node::rateFilter
protected

Filter for message rate smoothing.

Definition at line 347 of file NodeList.h.

◆ sleepyNode

bool Node::sleepyNode = true
protected

Node sleepy definition.

Definition at line 342 of file NodeList.h.

◆ status

status_t Node::status
protected

Current node status. See enum node_status

Definition at line 338 of file NodeList.h.

◆ t1

int64_t Node::t1

Definition at line 333 of file NodeList.h.

◆ t2

int64_t Node::t2

Definition at line 333 of file NodeList.h.

◆ t3

int64_t Node::t3

Definition at line 333 of file NodeList.h.

◆ t4

int64_t Node::t4

Timestaps to calculate clock offset.

Definition at line 333 of file NodeList.h.


The documentation for this class was generated from the following files: