From 813c5b3f38662325d597a0f347a6fea9e2bce067 Mon Sep 17 00:00:00 2001 From: tekka007 Date: Sat, 12 Dec 2015 10:25:20 +0100 Subject: [PATCH 1/2] 20151212_CORE --- libraries/MySensors/core/MyMessage.h | 4 ++-- libraries/MySensors/core/MySensorCore.cpp | 13 +++---------- libraries/MySensors/core/MyTransport.cpp | 5 +++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/libraries/MySensors/core/MyMessage.h b/libraries/MySensors/core/MyMessage.h index f9c2a29..31afa70 100644 --- a/libraries/MySensors/core/MyMessage.h +++ b/libraries/MySensors/core/MyMessage.h @@ -163,10 +163,10 @@ typedef enum { I_INCLUSION_MODE, I_CONFIG, I_FIND_PARENT, I_FIND_PARENT_RESPONSE, I_LOG_MESSAGE, I_CHILDREN, I_SKETCH_NAME, I_SKETCH_VERSION, I_REBOOT, I_GATEWAY_READY, - I_REQUEST_SIGNING, /*!< Indicates senter require signed messages (bool param) */ + I_REQUEST_SIGNING, /*!< Indicates sender require signed messages (bool param) */ I_GET_NONCE, /*!< Request for a nonce */ I_GET_NONCE_RESPONSE, /*!< Payload is nonce data */ - I_HEARTBEAT, I_PRESENTATION, I_DISCOVER, I_DISCOVER_RESPONSE + I_HEARTBEAT, I_PRESENTATION, I_DISCOVER, I_DISCOVER_RESPONSE, I_HEARTBEAT_RESPONSE } mysensor_internal; diff --git a/libraries/MySensors/core/MySensorCore.cpp b/libraries/MySensors/core/MySensorCore.cpp index 8d79bb6..a144300 100644 --- a/libraries/MySensors/core/MySensorCore.cpp +++ b/libraries/MySensors/core/MySensorCore.cpp @@ -215,7 +215,7 @@ void sendBatteryLevel(uint8_t value, bool enableAck) { } void sendHeartbeat(void) { - _sendRoute(build(_msg, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT, false).set(_heartbeat++)); + _sendRoute(build(_msg, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT_RESPONSE, false).set(_heartbeat++)); } @@ -271,15 +271,8 @@ void _processInternalMessages() { presentation(); } } else if (type == I_HEARTBEAT) { - if (!mGetAck(_msg)) { - // Send heartbeat ack message back to sender (with the same payload) - _msgTmp = _msg; - mSetRequestAck(_msgTmp,false); // Reply without ack flag (otherwise we would end up in an eternal loop) - mSetAck(_msgTmp,true); - _msgTmp.sender = _nc.nodeId; - _msgTmp.destination = _msg.sender; - _sendRoute(_msgTmp); - } + // Send heartbeat ack message back to sender (with the same payload) + _sendRoute(build(_msg, _nc.nodeId, _msg.sender, _msg.sensor, C_INTERNAL, I_HEARTBEAT_RESPONSE, false).set(_heartbeat++)); } else if (type == I_TIME && receiveTime) { // Deliver time to callback if (receiveTime) diff --git a/libraries/MySensors/core/MyTransport.cpp b/libraries/MySensors/core/MyTransport.cpp index 055bd6f..fe6c948 100644 --- a/libraries/MySensors/core/MyTransport.cpp +++ b/libraries/MySensors/core/MyTransport.cpp @@ -94,8 +94,9 @@ inline void transportProcess() { !mGetAck(_msg) && (mGetCommand(_msg) != C_INTERNAL || (type != I_GET_NONCE_RESPONSE && type != I_GET_NONCE && type != I_REQUEST_SIGNING && - type != I_ID_REQUEST && type != I_ID_RESPONSE && - type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE))) { + type != I_ID_REQUEST && type != I_ID_RESPONSE && + type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE && + type != I_HEARTBEAT))) { if (!mGetSigned(_msg)) { // Got unsigned message that should have been signed debug(PSTR("no sign\n")); From 8da7f8b3785943a87eabd5d53251fdab1e479bf4 Mon Sep 17 00:00:00 2001 From: tekka007 Date: Sat, 12 Dec 2015 10:43:54 +0100 Subject: [PATCH 2/2] 20151212_CORE2 --- libraries/MySensors/core/MyTransport.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/MySensors/core/MyTransport.cpp b/libraries/MySensors/core/MyTransport.cpp index fe6c948..2fadefb 100644 --- a/libraries/MySensors/core/MyTransport.cpp +++ b/libraries/MySensors/core/MyTransport.cpp @@ -96,7 +96,7 @@ inline void transportProcess() { (type != I_GET_NONCE_RESPONSE && type != I_GET_NONCE && type != I_REQUEST_SIGNING && type != I_ID_REQUEST && type != I_ID_RESPONSE && type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE && - type != I_HEARTBEAT))) { + type != I_HEARTBEAT && type != I_HEARTBEAT_RESPONSE))) { if (!mGetSigned(_msg)) { // Got unsigned message that should have been signed debug(PSTR("no sign\n")); @@ -415,7 +415,8 @@ boolean transportSendRoute(MyMessage &message) { (mGetCommand(message) != C_INTERNAL || (type != I_GET_NONCE && type != I_GET_NONCE_RESPONSE && type != I_REQUEST_SIGNING && type != I_ID_REQUEST && type != I_ID_RESPONSE && - type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE))) { + type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE && + type != I_HEARTBEAT && type != I_HEARTBEAT_RESPONSE))) { // Send nonce-request _signingNonceStatus=SIGN_WAITING_FOR_NONCE; if (!_sendRoute(build(_msgTmp, _nc.nodeId, message.destination, message.sensor, C_INTERNAL, I_GET_NONCE, false).set(""))) {