|
EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
12 #if defined(ARDUINO) && ARDUINO >= 100
268 memcpy (
mac, macAddress, 6);
374 #ifndef DISABLE_BRCAST
387 #ifndef DISABLE_BRCAST
459 void setVersion (uint8_t major, uint8_t minor, uint8_t incremental) {
541 int8_t
checkNodeName (
const char* name,
const uint8_t* address);
uint16_t lastMessageCounter
Last message counter state for specific Node.
Node broadcastNode
Node instance that holds data used for broadcast messages. This does not represent any individual nod...
bool broadcastKeyRequested
Node is waiting for broadcast key.
void setLastDownlinkMsgCounter(uint16_t counter)
Sets counter for last downlink message from gateway.
uint16_t lastMessageCounter
Last message counter state for specific Node.
void setLastMessageTime()
Sets current moment as last node message time.
Node * findEmptyNode()
Searches for a free place for a new Node instance.
uint32_t packetNumber
Number of packets received from node to gateway.
Node * getNodeFromName(const char *name)
Gets node that correspond with given node name.
timer_t lastMessageTime
Node state.
static const size_t ENIGMAIOT_ADDR_LEN
Address size. Mac address = 6 bytes.
uint16_t lastControlCounter
Last control message counter state for specific Node.
void setNodeName(const char *name)
Sets Node name.
void printToSerial(Stream *port)
Dumps node list data to a Stream object.
bool sleepyNode
Node sleepy definition.
uint8_t * getVersion()
Gets node EnigmaIOT version.
void setStatus(status_t status)
Sets status for finite state machine that represents node.
static const uint8_t MAX_MESSAGE_LENGTH
Maximum payload size on ESP-NOW.
Node nodes[NUM_NODES]
Static Node array that holds maximum number of supported nodes.
uint32_t packetErrors
Number of errored packets.
static const uint8_t NODE_NAME_LENGTH
Maximum number of characters of node name.
bool qMessagePending
True if message should be sent just after next data message
bool isKeyValid()
Gets shared key validity for this node.
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 ...
void initBroadcastNode()
Init broadcast node data.
Node * getNewNode(const uint8_t *mac)
Finds a node that correspond with given address of creates a new one if it does not exist.
void setNodeId(uint16_t nodeId)
Sets a new Node identifier.
bool broadcastIsEnabled()
Returns if node broadcast mode is enabled. In that case, node is able to send and receive encrypted b...
bool isBroadcastKeyRequested()
Checks if node is waiting for broadcast key.
bool keyValid
Node shared key valid.
Node * getNodeFromMAC(const uint8_t *mac)
Gets node that correspond with given address.
uint16_t lastBroadcastMsgCounter
Last broadcast message counter state for all nodes, both for data and control messages.
NodeList()
Node list constructor.
uint8_t key[32]
Shared key.
void incLastBroadcastMsgCounter()
Increments last broadcast message counter stata by one.
bool initAsSleepy
Stores initial sleepy node. If this is false, this node does not accept sleep time changes.
void setRSSI(int8_t rssi)
Stores last RSSI measurement of Gateway.
bool getSleepy()
Gets node working mode regarding battery saving strategy. If node is sleepy it will turn into deep sl...
void setKeyValid(bool status)
Sets shared key validity for this node.
node_t getNodeData()
Gets a struct that represents node object. May be used for node serialization.
time_t lastMessageTime
Last time a message was received by Node.
bool keyValid
Node shared key valid.
uint16_t getLastBroadcastMsgCounter()
Ask for last broadcast message counter state.
enum node_status status_t
Node state.
status_t getStatus()
Gets status for finite state machine that represents node.
uint16_t nodeId
Node identifier asigned by gateway.
uint16_t getNodeId()
Gets Node identifier.
bool unregisterNode(uint16_t nodeId)
Frees up a node and marks it as available.
time_t getLastMessageTime()
Gets last time that node sent a message.
void setVersion(uint8_t major, uint8_t minor, uint8_t incremental)
Sets node EnigmaIOT version.
uint16_t nodeId
Node identifier asigned by gateway.
void setKeyValidFrom(time_t keyValidFrom)
Sets time when key was agreed with gateway.
void setLastControlCounter(uint16_t counter)
Sets counter for last received control message from node.
uint8_t enigmaIOTVersion[3]
Protocol version, filled when a version message is received.
bool sleepyNode
Node sleepy definition.
uint16_t lastControlCounter
Last message counter state for specific Node.
timer_t keyValidFrom
Last time that Node and Gateway agreed a key.
char nodeName[NODE_NAME_LENGTH]
Node name. Use as a human friendly name to avoid use of numeric address.
void setSleepy(bool sleepy)
Sets node working mode regarding battery saving strategy. If node is sleepy it will turn into deep sl...
Node * getBroadcastNode()
Gets broadcas node instance.
void initRateFilter()
Starts smoothing filter.
uint16_t getLastControlCounter()
Gets counter for last received control message from node.
void reset()
Resets all node fields to a default initial and not registered state.
int8_t rssi
Stores last RSSI measurement.
bool getInitAsSleepy()
Gets initial sleepy mode.
void setEncryptionKey(const uint8_t *key)
Sets encryption key.
status_t status
Current node status. See enum node_status
double packetsHour
Packet rate for a specific nope.
uint16_t lastDownlinkMsgCounter
Last downlink message counter state for specific Node.
Node * getNextActiveNode(uint16_t nodeId)
Gets next active node by nodeId.
uint8_t * getEncriptionKey()
Gets Node encryption key.
static const int NUM_NODES
Maximum number of nodes that this gateway can handle.
enum ota_status ota_status_t
Struct that define node fields. Used for long term storage needs.
uint8_t key[KEY_LENGTH]
Shared key.
uint16_t getLastMessageCounter()
Gets counter for last received message from node.
uint16_t lastDownlinkMsgCounter
Last downlink message counter state for specific Node.
status_t status
Node state.
void setMacAddress(const uint8_t *macAddress)
Sets node address.
uint8_t mac[ENIGMAIOT_ADDR_LEN]
Node address.
const uint8_t KEY_LENGTH
Key length used by selected crypto algorythm. The only tested value is 32. Change it only if you know...
char * getNodeName()
Gets Node name.
void setBroadcastKeyRequested(bool request)
Mark node to be waiting for broadcast key.
FilterClass * rateFilter
Filter for message rate smoothing.
time_t keyValidFrom
Last time that Node and Gateway agreed a key.
bool broadcastEnabled
Node is able to send broadcast messages.
void updatePacketsRate(float value)
Adds a new message rate value for filter calculation.
Class definition for a single sensor Node.
uint8_t queuedMessage[MAX_MESSAGE_LENGTH]
Message queued for sending to node in case of sleepy mode.
int8_t checkNodeName(const char *name, const uint8_t *address)
Check Node name for duplicate.
void enableBroadcast(bool broadcast)
Enables node broadcast mode. Node will request broadcast key to Gateway. When it is received node wil...
bool isRegistered()
Gets registration state of this node.
uint8_t * getMacAddress()
Gets address from Node.
time_t getKeyValidFrom()
Gets last time that key was agreed with gateway.
void printToSerial(Stream *port=&Serial)
Dumps node data to the given stream, Serial by default. This method may be used for debugging.
uint8_t mac[ENIGMAIOT_ADDR_LEN]
Node address.
double per
Current packet error rate of a specific node.
Node * getNodeFromID(uint16_t nodeId)
Gets node that correspond with given nodeId.
char nodeName[NODE_NAME_LENGTH]
Node name. Use as a human friendly name to avoid use of numeric address.
uint16_t getLastDownlinkMsgCounter()
Gets counter for last downlink message from gateway.
uint16_t countActiveNodes()
Gets the number of active nodes (registered or registering)
enum control_message_type control_message_type_t
size_t qMessageLength
Queued message length.
node_status
State definition for nodes.
void setLastMessageCounter(uint16_t counter)
Sets counter for last received message from node.
void setTimeSyncEnabled()
Mark node as time sync enabled.
bool useTimeSync()
Gets node info to check if it has requested time sync ever.
int8_t getRSSI()
Gets last RSSI measurement of Gateway.
Filter to process message rate or other values.