Merge pull request #605 from tekka007/CoreCosmetics

Code harmonization
This commit is contained in:
Henrik Ekblad
2016-10-09 23:01:25 +02:00
committed by GitHub
7 changed files with 176 additions and 178 deletions
+5 -5
View File
@@ -54,7 +54,7 @@
// Enable radio "feature" if one of the radio types was enabled
#if defined(MY_RADIO_NRF24) || defined(MY_RADIO_RFM69) || defined(MY_RS485)
#define MY_RADIO_FEATURE
#define MY_SENSOR_NETWORK
#endif
// HARDWARE
@@ -167,7 +167,7 @@
#endif
#if defined(MY_GATEWAY_MQTT_CLIENT)
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
// We assume that a gateway having a radio also should act as repeater
#define MY_REPEATER_FEATURE
#endif
@@ -205,7 +205,7 @@
#include "core/MyProtocolMySensors.cpp"
// GATEWAY - CONFIGURATION
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
// We assume that a gateway having a radio also should act as repeater
#define MY_REPEATER_FEATURE
#endif
@@ -308,7 +308,7 @@
#endif
// Make sure to disable child features when parent feature is disabled
#if !defined(MY_RADIO_FEATURE)
#if !defined(MY_SENSOR_NETWORK)
#undef MY_OTA_FIRMWARE_FEATURE
#undef MY_REPEATER_FEATURE
#undef MY_SIGNING_NODE_WHITELISTING
@@ -321,7 +321,7 @@
#endif
#if !defined(MY_CORE_ONLY)
#if !defined(MY_GATEWAY_FEATURE) && !defined(MY_RADIO_FEATURE)
#if !defined(MY_GATEWAY_FEATURE) && !defined(MY_SENSOR_NETWORK)
#error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
#endif
#endif
+1 -1
View File
@@ -61,7 +61,7 @@ inline void gatewayTransportProcess() {
}
}
} else {
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
transportSendRoute(_msg);
#endif
}
+103 -110
View File
@@ -19,10 +19,10 @@
#include "MySensorsCore.h"
ControllerConfig _cc; // Configuration coming from controller
NodeConfig _nc; // Essential settings for node to work
MyMessage _msg; // Buffer for incoming messages.
MyMessage _msgTmp; // Buffer for temporary messages (acks and nonces among others).
ControllerConfig _cc; // Configuration coming from controller
NodeConfig _nc; // Essential settings for node to work
MyMessage _msg; // Buffer for incoming messages
MyMessage _msgTmp; // Buffer for temporary messages (acks and nonces among others)
bool _nodeRegistered = false;
@@ -32,7 +32,7 @@ bool _nodeRegistered = false;
void (*_timeCallback)(unsigned long); // Callback for requested time messages
void _process() {
void _process(void) {
hwWatchdogReset();
#if defined (MY_DEFAULT_TX_LED_PIN) || defined(MY_DEFAULT_RX_LED_PIN) || defined(MY_DEFAULT_ERR_LED_PIN)
@@ -47,7 +47,7 @@ void _process() {
gatewayTransportProcess();
#endif
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
transportProcess();
#endif
@@ -57,11 +57,9 @@ void _process() {
#endif
}
void _infiniteLoop() {
void _infiniteLoop(void) {
while(1) {
#if defined(ARDUINO_ARCH_ESP8266)
yield();
#endif
yield();
#if defined (MY_DEFAULT_TX_LED_PIN) || defined(MY_DEFAULT_RX_LED_PIN) || defined(MY_DEFAULT_ERR_LED_PIN)
ledsProcess();
#endif
@@ -71,7 +69,7 @@ void _infiniteLoop() {
}
}
void _begin() {
void _begin(void) {
hwWatchdogReset();
if (preHwInit)
@@ -102,16 +100,14 @@ void _begin() {
readFirmwareSettings();
#endif
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
// Save static parent id in eeprom (used by bootloader)
hwWriteConfig(EEPROM_PARENT_NODE_ID_ADDRESS, MY_PARENT_NODE_ID);
transportInitialise();
while (!isTransportReady()) {
hwWatchdogReset();
transportProcess();
#if defined(ARDUINO_ARCH_ESP8266)
yield();
#endif
yield();
}
#endif
@@ -176,7 +172,7 @@ void _begin() {
}
void _registerNode() {
void _registerNode(void) {
#if defined (MY_REGISTRATION_FEATURE) && !defined(MY_GATEWAY_FEATURE)
debug(PSTR("MCO:REG:REQ\n")); // registration request
setIndication(INDICATION_REQ_REGISTRATION);
@@ -184,7 +180,7 @@ void _registerNode() {
uint8_t counter = MY_REGISTRATION_RETRIES;
// only proceed if register response received or retries exceeded
do {
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_REGISTRATION_REQUEST, false).set(MY_CORE_VERSION));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_REGISTRATION_REQUEST).set(MY_CORE_VERSION));
} while (!wait(2000, C_INTERNAL, I_REGISTRATION_RESPONSE) && counter--);
#else
@@ -193,20 +189,20 @@ void _registerNode() {
#endif
}
void presentNode() {
void presentNode(void) {
setIndication(INDICATION_PRESENT);
// Present node and request config
#if defined(MY_GATEWAY_FEATURE)
// Send presentation for this gateway device
#if defined(MY_REPEATER_FEATURE)
present(NODE_SENSOR_ID, S_ARDUINO_REPEATER_NODE);
(void)present(NODE_SENSOR_ID, S_ARDUINO_REPEATER_NODE);
#else
present(NODE_SENSOR_ID, S_ARDUINO_NODE);
(void)present(NODE_SENSOR_ID, S_ARDUINO_NODE);
#endif
#else
#if defined(MY_OTA_FIRMWARE_FEATURE)
presentBootloaderInformation();
presentBootloaderInformation();
#endif
// Send signing preferences for this node to the GW
@@ -214,17 +210,17 @@ void presentNode() {
// Send presentation for this radio node
#if defined(MY_REPEATER_FEATURE)
present(NODE_SENSOR_ID, S_ARDUINO_REPEATER_NODE);
(void)present(NODE_SENSOR_ID, S_ARDUINO_REPEATER_NODE);
#else
present(NODE_SENSOR_ID, S_ARDUINO_NODE);
(void)present(NODE_SENSOR_ID, S_ARDUINO_NODE);
#endif
// Send a configuration exchange request to controller
// Node sends parent node. Controller answers with latest node configuration
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CONFIG, false).set(_nc.parentNodeId));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CONFIG).set(_nc.parentNodeId));
// Wait configuration reply.
wait(2000, C_INTERNAL, I_CONFIG);
(void)wait(2000, C_INTERNAL, I_CONFIG);
#endif
@@ -234,15 +230,15 @@ void presentNode() {
}
uint8_t getNodeId() {
uint8_t getNodeId(void) {
return _nc.nodeId;
}
uint8_t getParentNodeId() {
uint8_t getParentNodeId(void) {
return _nc.parentNodeId;
}
ControllerConfig getConfig() {
ControllerConfig getConfig(void) {
return _cc;
}
@@ -258,14 +254,14 @@ bool _sendRoute(MyMessage &message) {
return gatewayTransportSend(message);
}
#endif
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
return transportSendRoute(message);
#else
return false;
#endif
}
bool send(MyMessage &message, bool enableAck) {
bool send(MyMessage &message, const bool enableAck) {
message.sender = _nc.nodeId;
mSetCommand(message, C_SET);
mSetRequestAck(message, enableAck);
@@ -283,37 +279,42 @@ bool send(MyMessage &message, bool enableAck) {
#endif
}
void sendBatteryLevel(uint8_t value, bool enableAck) {
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_BATTERY_LEVEL, enableAck).set(value));
bool sendBatteryLevel(const uint8_t value, const bool ack) {
return _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_BATTERY_LEVEL, ack).set(value));
}
void sendHeartbeat(void) {
#if defined(MY_RADIO_FEATURE)
uint32_t heartbeat = transportGetHeartbeat();
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT_RESPONSE, false).set(heartbeat));
bool sendHeartbeat(const bool ack) {
#if defined(MY_SENSOR_NETWORK)
const uint32_t heartbeat = transportGetHeartbeat();
return _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT_RESPONSE, ack).set(heartbeat));
#else
(void)ack;
return false;
#endif
}
void present(uint8_t childSensorId, uint8_t sensorType, const char *description, bool enableAck) {
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, childSensorId, C_PRESENTATION, sensorType, enableAck).set(childSensorId==NODE_SENSOR_ID?MYSENSORS_LIBRARY_VERSION:description));
bool present(const uint8_t childSensorId, const uint8_t sensorType, const char *description, const bool ack) {
return _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, childSensorId, C_PRESENTATION, sensorType, ack).set(childSensorId==NODE_SENSOR_ID?MYSENSORS_LIBRARY_VERSION:description));
}
void sendSketchInfo(const char *name, const char *version, bool enableAck) {
if (name) _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_NAME, enableAck).set(name));
if (version) _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_VERSION, enableAck).set(version));
bool sendSketchInfo(const char *name, const char *version, const bool ack) {
bool result = true;
if (name) result &= _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_NAME, ack).set(name));
if (version) result &= _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_VERSION, ack).set(version));
return result;
}
void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination) {
_sendRoute(build(_msgTmp, destination, childSensorId, C_REQ, variableType, false).set(""));
bool request(const uint8_t childSensorId, const uint8_t variableType, const uint8_t destination) {
return _sendRoute(build(_msgTmp, destination, childSensorId, C_REQ, variableType).set(""));
}
void requestTime() {
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_TIME, false).set(""));
bool requestTime(const bool ack) {
return _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_TIME, ack).set(""));
}
// Message delivered through _msg
bool _processInternalMessages() {
uint8_t type = _msg.type;
bool _processInternalMessages(void) {
const uint8_t type = _msg.type;
if (_msg.sender == GATEWAY_ADDRESS) {
if (type == I_REBOOT) {
@@ -340,7 +341,7 @@ bool _processInternalMessages() {
presentNode();
}
else if (type == I_HEARTBEAT_REQUEST) {
sendHeartbeat();
(void)sendHeartbeat();
}
else if (type == I_TIME) {
// Deliver time to callback
@@ -353,7 +354,7 @@ bool _processInternalMessages() {
// Clears child relay data for this node
setIndication(INDICATION_CLEAR_ROUTING);
transportClearRoutingTable();
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN, false).set("ok"));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN).set("OK"));
}
#endif
}
@@ -367,23 +368,23 @@ bool _processInternalMessages() {
if (route != BROADCAST_ADDRESS) {
debug(PSTR("MCO:PIM:ROUTE N=%d,R=%d\n"), cnt, route);
uint8_t outBuf[2] = { (uint8_t)cnt,route };
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG, false).set(outBuf, 2));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG).set(outBuf, 2));
wait(200);
}
}
#endif
}
else if (debug_msg == 'V') { // CPU voltage
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG, false).set(hwCPUVoltage()));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG).set(hwCPUVoltage()));
}
else if (debug_msg == 'F') { // CPU frequency in 1/10Mhz
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG, false).set(hwCPUFrequency()));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG).set(hwCPUFrequency()));
}
else if (debug_msg == 'M') { // free memory
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG, false).set(hwFreeMem()));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG).set(hwFreeMem()));
}
else if (debug_msg == 'E') { // clear MySensors eeprom area and reboot
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG, false).set("ok"));
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG).set("OK"));
for (int i = EEPROM_START; i<EEPROM_LOCAL_CONFIG_ADDRESS; i++) hwWriteConfig(i, 0xFF);
setIndication(INDICATION_REBOOT);
hwReboot();
@@ -409,7 +410,7 @@ bool _processInternalMessages() {
// delay for fast GW and slow nodes
delay(5);
#endif
_sendRoute(build(_msgTmp, _msg.sender, NODE_SENSOR_ID, C_INTERNAL, I_REGISTRATION_RESPONSE, false).set(approveRegistration));
(void)_sendRoute(build(_msgTmp, _msg.sender, NODE_SENSOR_ID, C_INTERNAL, I_REGISTRATION_RESPONSE).set(approveRegistration));
#else
return false; // processing of this request via controller
#endif
@@ -421,46 +422,42 @@ bool _processInternalMessages() {
}
void saveState(uint8_t pos, uint8_t value) {
void saveState(const uint8_t pos, const uint8_t value) {
hwWriteConfig(EEPROM_LOCAL_CONFIG_ADDRESS+pos, value);
}
uint8_t loadState(uint8_t pos) {
uint8_t loadState(const uint8_t pos) {
return hwReadConfig(EEPROM_LOCAL_CONFIG_ADDRESS+pos);
}
void wait(unsigned long ms) {
unsigned long enter = hwMillis();
while (hwMillis() - enter < ms) {
void wait(const uint32_t waitingMS) {
const uint32_t enteringMS = hwMillis();
while (hwMillis() - enteringMS < waitingMS) {
_process();
#if defined(ARDUINO_ARCH_ESP8266)
yield();
#endif
yield();
}
}
bool wait(unsigned long ms, uint8_t cmd, uint8_t msgtype) {
unsigned long enter = hwMillis();
bool wait(const uint32_t waitingMS, const uint8_t cmd, const uint8_t msgtype) {
const uint32_t enteringMS = hwMillis();
// invalidate msg type
_msg.type = !msgtype;
bool expectedResponse = false;
while ( (hwMillis() - enter < ms) && !expectedResponse ) {
while ( (hwMillis() - enteringMS < waitingMS) && !expectedResponse ) {
_process();
#if defined(ARDUINO_ARCH_ESP8266)
yield();
#endif
yield();
expectedResponse = (mGetCommand(_msg) == cmd && _msg.type == msgtype);
}
return expectedResponse;
}
int8_t _sleep(const uint32_t ms, const bool smartSleep, const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2) {
debug(PSTR("MCO:SLP:MS=%lu,SMS=%d,I1=%d,M1=%d,I2=%d,M2=%d\n"), ms, smartSleep, interrupt1, mode1, interrupt2, mode2);
int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2) {
debug(PSTR("MCO:SLP:MS=%lu,SMS=%d,I1=%d,M1=%d,I2=%d,M2=%d\n"), sleepingMS, smartSleep, interrupt1, mode1, interrupt2, mode2);
// OTA FW feature: do not sleep if FW update ongoing
#if defined(MY_OTA_FIRMWARE_FEATURE)
if (_fwUpdateOngoing) {
debug(PSTR("!MCO:SLP:FWUPD\n")); // sleeping not possible, FW update ongoing
wait(ms);
wait(sleepingMS);
return MY_SLEEP_NOT_POSSIBLE;
}
#endif
@@ -473,27 +470,25 @@ int8_t _sleep(const uint32_t ms, const bool smartSleep, const uint8_t interrupt1
(void)mode2;
debug(PSTR("!MCO:SLP:REP\n")); // sleeping not possible, repeater feature enabled
wait(ms);
wait(sleepingMS);
return MY_SLEEP_NOT_POSSIBLE;
#else
uint32_t sleepingTime = ms;
#if defined(MY_RADIO_FEATURE)
uint32_t sleepingTimeMS = sleepingMS;
#if defined(MY_SENSOR_NETWORK)
// Do not sleep if transport not ready
if (!isTransportReady()) {
debug(PSTR("!MCO:SLP:TNR\n")); // sleeping not possible, transport not ready
uint32_t sleepEnter = hwMillis();
uint32_t sleepDelta = 0;
while (!isTransportReady() && (sleepDelta < sleepingTime) && (sleepDelta < MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS)) {
const uint32_t sleepEnterMS = hwMillis();
uint32_t sleepDeltaMS = 0;
while (!isTransportReady() && (sleepDeltaMS < sleepingTimeMS) && (sleepDeltaMS < MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS)) {
_process();
#if defined(ARDUINO_ARCH_ESP8266)
yield();
#endif
sleepDelta = hwMillis() - sleepEnter;
yield();
sleepDeltaMS = hwMillis() - sleepEnterMS;
}
// sleep remainder
if (sleepDelta < sleepingTime) {
sleepingTime -= sleepDelta; // calculate remaining sleeping time
debug(PSTR("MCO:SLP:MS=%lu\n"), sleepingTime);
if (sleepDeltaMS < sleepingTimeMS) {
sleepingTimeMS -= sleepDeltaMS; // calculate remaining sleeping time
debug(PSTR("MCO:SLP:MS=%lu\n"), sleepingTimeMS);
}
else {
// no sleeping time left
@@ -504,65 +499,65 @@ int8_t _sleep(const uint32_t ms, const bool smartSleep, const uint8_t interrupt1
if (smartSleep) {
// notify controller about going to sleep
sendHeartbeat();
(void)sendHeartbeat();
wait(MY_SMART_SLEEP_WAIT_DURATION_MS); // listen for incoming messages
}
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
debug(PSTR("MCO:SLP:TPD\n")); // sleep, power down transport
transportPowerDown();
#endif
setIndication(INDICATION_SLEEP);
int8_t res = MY_SLEEP_NOT_POSSIBLE; // default
int8_t result = MY_SLEEP_NOT_POSSIBLE; // default
if (interrupt1 != INTERRUPT_NOT_DEFINED && interrupt2 != INTERRUPT_NOT_DEFINED) {
// both IRQs
res = hwSleep(interrupt1, mode1, interrupt2, mode2, sleepingTime);
result = hwSleep(interrupt1, mode1, interrupt2, mode2, sleepingTimeMS);
}
else if (interrupt1 != INTERRUPT_NOT_DEFINED && interrupt2 == INTERRUPT_NOT_DEFINED) {
// one IRQ
res = hwSleep(interrupt1, mode1, sleepingTime);
result = hwSleep(interrupt1, mode1, sleepingTimeMS);
}
else if (interrupt1 == INTERRUPT_NOT_DEFINED && interrupt2 == INTERRUPT_NOT_DEFINED) {
// no IRQ
res = hwSleep(sleepingTime);
result = hwSleep(sleepingTimeMS);
}
setIndication(INDICATION_WAKEUP);
debug(PSTR("MCO:SLP:WUP=%d\n"), res); // sleep wake-up
return res;
debug(PSTR("MCO:SLP:WUP=%d\n"), result); // sleep wake-up
return result;
#endif
}
// sleep functions
int8_t sleep(const uint32_t ms, const bool smartSleep) {
return _sleep(ms, smartSleep);
int8_t sleep(const uint32_t sleepingMS, const bool smartSleep) {
return _sleep(sleepingMS, smartSleep);
}
int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms, const bool smartSleep) {
return _sleep(ms, smartSleep, interrupt, mode);
int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS, const bool smartSleep) {
return _sleep(sleepingMS, smartSleep, interrupt, mode);
}
int8_t sleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t ms, const bool smartSleep) {
return _sleep(ms, smartSleep, interrupt1, mode1, interrupt2, mode2);
int8_t sleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t sleepingMS, const bool smartSleep) {
return _sleep(sleepingMS, smartSleep, interrupt1, mode1, interrupt2, mode2);
}
// deprecated smartSleep() functions
int8_t smartSleep(const uint32_t ms) {
int8_t smartSleep(const uint32_t sleepingMS) {
// compatibility
return _sleep(ms, true);
return _sleep(sleepingMS, true);
}
int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms) {
int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS) {
// compatibility
return _sleep(ms, true, interrupt, mode);
return _sleep(sleepingMS, true, interrupt, mode);
}
int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t ms) {
int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t sleepingMS) {
// compatibility
return _sleep(ms, true, interrupt1, mode1, interrupt2, mode2);
return _sleep(sleepingMS, true, interrupt1, mode1, interrupt2, mode2);
}
@@ -573,11 +568,9 @@ void nodeLock(const char* str) {
while (1) {
setIndication(INDICATION_ERR_LOCKED);
debug(PSTR("MCO:NLK:NODE LOCKED. TO UNLOCK, GND PIN %d AND RESET\n"), MY_NODE_UNLOCK_PIN);
#if defined(ARDUINO_ARCH_ESP8266)
yield();
#endif
_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID,C_INTERNAL, I_LOCKED, false).set(str));
#if defined(MY_RADIO_FEATURE)
yield();
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID,C_INTERNAL, I_LOCKED).set(str));
#if defined(MY_SENSOR_NETWORK)
transportPowerDown();
debug(PSTR("MCO:NLK:TPD\n")); // power down transport
#endif
+51 -46
View File
@@ -122,17 +122,17 @@ extern MyMessage _msgTmp; //!< Buffer for temporary messages (acks and nonc
/**
* Return this nodes id.
*/
uint8_t getNodeId();
uint8_t getNodeId(void);
/**
* Return the parent node id.
*/
uint8_t getParentNodeId();
uint8_t getParentNodeId(void);
/**
* Sends node information to the gateway.
*/
void presentNode();
void presentNode(void);
/**
* Each node must present all attached sensors before any values can be handled correctly by the controller.
@@ -143,17 +143,18 @@ void presentNode();
* @param description A textual description of the sensor.
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @param description A textual description of the sensor.
* @return true Returns true if message reached the first stop on its way to destination.
*/
void present(uint8_t sensorId, uint8_t sensorType, const char *description="", bool ack=false);
bool present(const uint8_t sensorId, const uint8_t sensorType, const char *description="", const bool ack = false);
/**
* Sends sketch meta information to the gateway. Not mandatory but a nice thing to do.
* @param name String containing a short Sketch name or NULL if not applicable
* @param version String containing a short Sketch version or NULL if not applicable
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
*
* @return true Returns true if message reached the first stop on its way to destination.
*/
void sendSketchInfo(const char *name, const char *version, bool ack=false);
bool sendSketchInfo(const char *name, const char *version, const bool ack = false);
/**
* Sends a message to gateway or one of the other nodes in the radio network
@@ -162,22 +163,24 @@ void sendSketchInfo(const char *name, const char *version, bool ack=false);
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @return true Returns true if message reached the first stop on its way to destination.
*/
bool send(MyMessage &msg, bool ack=false);
bool send(MyMessage &msg, const bool ack = false);
/**
* Send this nodes battery level to gateway.
* @param level Level between 0-100(%)
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
*
* @return true Returns true if message reached the first stop on its way to destination.
*/
void sendBatteryLevel(uint8_t level, bool ack=false);
bool sendBatteryLevel(const uint8_t level, const bool ack = false);
/**
* Send a heartbeat message (I'm alive!) to the gateway/controller.
* The payload will be an incremental 16 bit integer value starting at 1 when sensor is powered on.
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @return true Returns true if message reached the first stop on its way to destination.
*/
void sendHeartbeat(void);
bool sendHeartbeat(const bool ack = false);
/**
* Requests a value from gateway or some other sensor in the radio network.
@@ -186,19 +189,21 @@ void sendHeartbeat(void);
* @param childSensorId The unique child id for the different sensors connected to this Arduino. 0-254.
* @param variableType The variableType to fetch
* @param destination The nodeId of other node in radio network. Default is gateway
* @return true Returns true if message reached the first stop on its way to destination.
*/
void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination=GATEWAY_ADDRESS);
bool request(const uint8_t childSensorId, const uint8_t variableType, const uint8_t destination = GATEWAY_ADDRESS);
/**
* Requests time from controller. Answer will be delivered to receiveTime function in sketch.
*
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @return true Returns true if message reached the first stop on its way to destination.
*/
void requestTime();
bool requestTime(const bool ack = false);
/**
* Returns the most recent node configuration received from controller
*/
ControllerConfig getConfig();
ControllerConfig getConfig(void);
/**
* Save a state (in local EEPROM). Good for actuators to "remember" state between
@@ -210,7 +215,7 @@ ControllerConfig getConfig();
* @param pos The position to store value in (0-255)
* @param value to store in position
*/
void saveState(uint8_t pos, uint8_t value);
void saveState(const uint8_t pos, const uint8_t value);
/**
* Load a state (from local EEPROM).
@@ -218,36 +223,36 @@ void saveState(uint8_t pos, uint8_t value);
* @param pos The position to fetch value from (0-255)
* @return Value to store in position
*/
uint8_t loadState(uint8_t pos);
uint8_t loadState(const uint8_t pos);
/**
* Wait for a specified amount of time to pass. Keeps process()ing.
* This does not power-down the radio nor the Arduino.
* Because this calls process() in a loop, it is a good way to wait
* in your loop() on a repeater node or sensor that listens to messages.
* @param ms Number of milliseconds to sleep.
* @param waitingMS Number of milliseconds to wait.
*/
void wait(unsigned long ms);
void wait(const uint32_t waitingMS);
/**
* Wait for a specified amount of time to pass or until specified message received. Keeps process()ing.
* This does not power-down the radio nor the Arduino.
* Because this calls process() in a loop, it is a good way to wait
* in your loop() on a repeater node or sensor that listens to messages.
* @param ms Number of milliseconds to sleep.
* @param waitingMS Number of milliseconds to wait.
* @param cmd Command of incoming message.
* @param msgtype Message type.
* @return True if specified message received
*/
bool wait(unsigned long ms, uint8_t cmd, uint8_t msgtype);
bool wait(const uint32_t waitingMS, const uint8_t cmd, const uint8_t msgtype);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer.
* @param ms Number of milliseconds to sleep.
* @param sleepingMS Number of milliseconds to sleep.
* @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep.
* @return @ref MY_WAKE_UP_BY_TIMER if timer woke it up, @ref MY_SLEEP_NOT_POSSIBLE if not possible (e.g. ongoing FW update)
*/
int8_t sleep(const uint32_t ms, const bool smartSleep = false);
int8_t sleep(const uint32_t sleepingMS, const bool smartSleep = false);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change.
@@ -255,11 +260,11 @@ int8_t sleep(const uint32_t ms, const bool smartSleep = false);
* is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
* @param interrupt Interrupt that should trigger the wakeup
* @param mode RISING, FALLING, CHANGE
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms=0, const bool smartSleep = false);
int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0, const bool smartSleep = false);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change for two separate interrupts.
@@ -269,20 +274,20 @@ int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms=0, c
* @param mode1 Mode for first interrupt (RISING, FALLING, CHANGE)
* @param interrupt2 Second interrupt that should trigger the wakeup
* @param mode2 Mode for second interrupt (RISING, FALLING, CHANGE)
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep.
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t sleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t ms=0, const bool smartSleep = false);
int8_t sleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t sleepingMS = 0, const bool smartSleep = false);
/**
* \deprecated Use sleep(ms, true) instead
* Same as sleep(), send heartbeat and process incoming messages before going to sleep.
* Specify the time to wait for incoming messages by defining MY_SMART_SLEEP_WAIT_DURATION to a time (ms).
* @param ms Number of milliseconds to sleep.
* @param sleepingMS Number of milliseconds to sleep.
* @return @ref MY_WAKE_UP_BY_TIMER if timer woke it up, @ref MY_SLEEP_NOT_POSSIBLE if not possible (e.g. ongoing FW update)
*/
int8_t smartSleep(const uint32_t ms);
int8_t smartSleep(const uint32_t sleepingMS);
/**
* \deprecated Use sleep(interrupt, mode, ms, true) instead
@@ -290,10 +295,10 @@ int8_t smartSleep(const uint32_t ms);
* Specify the time to wait for incoming messages by defining MY_SMART_SLEEP_WAIT_DURATION to a time (ms).
* @param interrupt Interrupt that should trigger the wakeup
* @param mode RISING, FALLING, CHANGE
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms = 0);
int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0);
/**
* \deprecated Use sleep(interrupt1, mode1, interrupt2, mode2, ms, true) instead
@@ -303,16 +308,16 @@ int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms
* @param mode1 Mode for first interrupt (RISING, FALLING, CHANGE)
* @param interrupt2 Second interrupt that should trigger the wakeup
* @param mode2 Mode for second interrupt (RISING, FALLING, CHANGE)
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t ms=0);
int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t sleepingMS = 0);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change for two separate interrupts.
* See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
* is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @param interrupt1 (optional) First interrupt that should trigger the wakeup
* @param mode1 (optional) Mode for first interrupt (RISING, FALLING, CHANGE)
* @param interrupt2 (optional) Second interrupt that should trigger the wakeup
@@ -320,7 +325,7 @@ int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t i
* @param smartSleep (optional) Set True if sending heartbeat and process incoming messages before going to sleep.
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t _sleep(const uint32_t ms, const bool smartSleep = false, const uint8_t interrupt1 = INTERRUPT_NOT_DEFINED, const uint8_t mode1 = MODE_NOT_DEFINED, const uint8_t interrupt2 = INTERRUPT_NOT_DEFINED, const uint8_t mode2 = MODE_NOT_DEFINED);
int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep = false, const uint8_t interrupt1 = INTERRUPT_NOT_DEFINED, const uint8_t mode1 = MODE_NOT_DEFINED, const uint8_t interrupt2 = INTERRUPT_NOT_DEFINED, const uint8_t mode2 = MODE_NOT_DEFINED);
#ifdef MY_NODE_LOCK_FEATURE
@@ -343,7 +348,7 @@ void nodeLock(const char* str);
/**
* @brief Node initialisation
*/
void _begin();
void _begin(void);
/**
* @brief Main framework process
*/
@@ -352,19 +357,19 @@ void _process(void);
* @brief Processes internal messages
* @return True if received message requires further processing
*/
bool _processInternalMessages();
bool _processInternalMessages(void);
/**
* @brief Puts node to a infinite loop if unrecoverable situation detected
*/
void _infiniteLoop();
void _infiniteLoop(void);
/**
* @brief Handles registration request
*/
void _registerNode();
void _registerNode(void);
/**
* @brief Sends message according to routing table
* @param message
* @return True if message successfully sent to next node
* @return true Returns true if message reached the first stop on its way to destination.
*/
bool _sendRoute(MyMessage &message);
@@ -380,33 +385,33 @@ void receiveTime(unsigned long) __attribute__((weak));
/**
* @brief Node presenation
*/
void presentation() __attribute__((weak));
void presentation(void) __attribute__((weak));
/**
* @brief Called before node initialises
*/
void before() __attribute__((weak));
void before(void) __attribute__((weak));
/**
* @brief Called before any hwInitialization is done
*/
void preHwInit() __attribute__((weak));
void preHwInit(void) __attribute__((weak));
/**
* @brief Called after node initialises but before main loop
*/
void setup() __attribute__((weak));
void setup(void) __attribute__((weak));
/**
* @brief Main loop
*/
void loop() __attribute__((weak));
void loop(void) __attribute__((weak));
// Inline function and macros
static inline MyMessage& build(MyMessage &msg, const uint8_t destination, const uint8_t sensor, const uint8_t command, const uint8_t type, const bool enableAck) {
static inline MyMessage& build(MyMessage &msg, const uint8_t destination, const uint8_t sensor, const uint8_t command, const uint8_t type, const bool ack = false) {
msg.sender = _nc.nodeId;
msg.destination = destination;
msg.sensor = sensor;
msg.type = type;
mSetCommand(msg,command);
mSetRequestAck(msg,enableAck);
mSetRequestAck(msg,ack);
mSetAck(msg,false);
return msg;
}
+3 -3
View File
@@ -106,7 +106,7 @@ static bool skipSign(MyMessage &msg) {
// Helper to prepare a signing presentation message
static void prepareSigningPresentation(MyMessage &msg, uint8_t destination) {
// Only supports version 1 for now
build(msg, destination, NODE_SENSOR_ID, C_INTERNAL, I_SIGNING_PRESENTATION, false).set("");
(void)build(msg, destination, NODE_SENSOR_ID, C_INTERNAL, I_SIGNING_PRESENTATION).set("");
mSetLength(msg, 2);
mSetPayloadType(msg, P_CUSTOM); // displayed as hex
msg.data[0] = SIGNING_PRESENTATION_VERSION_1;
@@ -188,7 +188,7 @@ bool signerProcessInternal(MyMessage &msg) {
#if defined(MY_SIGNING_ATSHA204)
if (signerAtsha204GetNonce(msg)) {
#endif
if (!_sendRoute(build(msg, msg.sender, NODE_SENSOR_ID, C_INTERNAL, I_NONCE_RESPONSE, false))) {
if (!_sendRoute(build(msg, msg.sender, NODE_SENSOR_ID, C_INTERNAL, I_NONCE_RESPONSE))) {
SIGN_DEBUG(PSTR("Failed to transmit nonce!\n"));
} else {
SIGN_DEBUG(PSTR("Transmitted nonce\n"));
@@ -314,7 +314,7 @@ bool signerSignMsg(MyMessage &msg) {
} else {
// Send nonce-request
_signingNonceStatus=SIGN_WAITING_FOR_NONCE;
if (!_sendRoute(build(_msgSign, msg.destination, msg.sensor, C_INTERNAL, I_NONCE_REQUEST, false).set(""))) {
if (!_sendRoute(build(_msgSign, msg.destination, msg.sensor, C_INTERNAL, I_NONCE_REQUEST).set(""))) {
SIGN_DEBUG(PSTR("Failed to transmit nonce request!\n"));
return false;
}
+12 -12
View File
@@ -134,7 +134,7 @@ void stParentTransition(void) {
_nc.distance = DISTANCE_INVALID; // Set distance to max and invalidate parent node ID
_nc.parentNodeId = AUTO;
// Broadcast find parent request
(void)transportRouteMessage(build(_msgTmp, BROADCAST_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_REQUEST, false).set(""));
(void)transportRouteMessage(build(_msgTmp, BROADCAST_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_REQUEST).set(""));
#endif
}
@@ -181,7 +181,7 @@ void stIDTransition(void) {
// send ID request
setIndication(INDICATION_REQ_NODEID);
TRANSPORT_DEBUG(PSTR("TSM:ID:REQ\n")); // request node ID
(void)transportRouteMessage(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_ID_REQUEST, false).set(""));
(void)transportRouteMessage(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_ID_REQUEST).set(""));
}
}
@@ -214,7 +214,7 @@ void stUplinkTransition(void) {
setIndication(INDICATION_CHECK_UPLINK);
_transportSM.pingResponse = INVALID_HOPS;
_transportSM.pingActive = true;
(void)transportRouteMessage(build(_msgTmp,GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_PING, false).set((uint8_t)1));
(void)transportRouteMessage(build(_msgTmp,GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_PING).set((uint8_t)1));
#endif
}
@@ -265,7 +265,7 @@ void stReadyUpdate(void) {
if (hwMillis() - _lastNetworkDiscovery > MY_TRANSPORT_DISCOVERY_INTERVAL_MS) {
_lastNetworkDiscovery = hwMillis();
TRANSPORT_DEBUG(PSTR("TSM:READY:NWD REQ\n")); // send transport network discovery
(void)transportRouteMessage(build(_msgTmp, BROADCAST_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DISCOVER_REQUEST, false).set(""));
(void)transportRouteMessage(build(_msgTmp, BROADCAST_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DISCOVER_REQUEST).set(""));
}
#else
if (_transportSM.failedUplinkTransmissions > MY_TRANSPORT_MAX_TX_FAILURES) {
@@ -298,7 +298,7 @@ void stFailureTransition(void) {
_transportSM.uplinkOk = false; // uplink nok
_transportSM.transportActive = false; // transport inactive
setIndication(INDICATION_ERR_INIT_TRANSPORT);
#if defined(MY_RADIO_FEATURE)
#if defined(MY_SENSOR_NETWORK)
TRANSPORT_DEBUG(PSTR("TSM:FAIL:PDT\n")); // power down transport, no need until re-init
transportPowerDown();
#endif
@@ -344,11 +344,11 @@ bool isTransportSearchingParent(void) {
}
bool isMessageReceived(void) {
return _transportSM.MsgReceived;
return _transportSM.msgReceived;
}
void resetMessageReceived(void) {
_transportSM.MsgReceived = false;
_transportSM.msgReceived = false;
}
@@ -507,7 +507,7 @@ uint8_t transportPingNode(const uint8_t targetId) {
else {
_transportSM.pingActive = true;
_transportSM.pingResponse = INVALID_HOPS;
(void)transportRouteMessage(build(_msgTmp, targetId, NODE_SENSOR_ID, C_INTERNAL, I_PING, false).set((uint8_t)1));
(void)transportRouteMessage(build(_msgTmp, targetId, NODE_SENSOR_ID, C_INTERNAL, I_PING).set((uint8_t)1));
// Wait for ping reply or timeout
(void)transportWait(2000, C_INTERNAL, I_PONG);
}
@@ -579,7 +579,7 @@ void transportProcessMessage(void) {
#endif
// set message received flag
_transportSM.MsgReceived = true;
_transportSM.msgReceived = true;
// Is message addressed to this node?
if (destination == _nc.nodeId) {
@@ -647,7 +647,7 @@ void transportProcessMessage(void) {
// delay for fast GW and slow nodes
delay(5);
#endif
(void)transportRouteMessage(build(_msgTmp, sender, NODE_SENSOR_ID, C_INTERNAL, I_PONG, false).set((uint8_t)1));
(void)transportRouteMessage(build(_msgTmp, sender, NODE_SENSOR_ID, C_INTERNAL, I_PONG).set((uint8_t)1));
return; // no further processing required
}
if (type == I_PONG) {
@@ -700,7 +700,7 @@ void transportProcessMessage(void) {
TRANSPORT_DEBUG(PSTR("TSF:MSG:GWL OK\n")); // GW uplink ok
// random delay minimizes collisions
delay(hwMillis() & 0x3ff);
(void)transportRouteMessage(build(_msgTmp, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(_nc.distance));
(void)transportRouteMessage(build(_msgTmp, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE).set(_nc.distance));
}
else {
TRANSPORT_DEBUG(PSTR("!TSF:MSG:GWL FAIL\n")); // GW uplink fail, do not respond to parent request
@@ -718,7 +718,7 @@ void transportProcessMessage(void) {
if (last == _nc.parentNodeId) {
// random wait to minimize collisions
delay(hwMillis() & 0x3ff);
(void)transportRouteMessage(build(_msgTmp, sender, NODE_SENSOR_ID, C_INTERNAL, I_DISCOVER_RESPONSE, false).set(_nc.parentNodeId));
(void)transportRouteMessage(build(_msgTmp, sender, NODE_SENSOR_ID, C_INTERNAL, I_DISCOVER_RESPONSE).set(_nc.parentNodeId));
// no return here (for fwd if repeater)
}
}
+1 -1
View File
@@ -236,7 +236,7 @@ typedef struct {
// 8 bits
uint8_t failedUplinkTransmissions : 4; //!< counter failed uplink transmissions (max 15)
uint8_t failureCounter : 3; //!< counter for TSM failures (max 7)
bool MsgReceived : 1; //!< flag message received
bool msgReceived : 1; //!< flag message received
// 8 bits
uint8_t pingResponse; //!< stores I_PONG hops
} transportSM;