Skip to content

Commit a91be50

Browse files
committed
Merge pull request arduino#295 from tekka007/harmonization
I_HEARTBEAT_RESPONSE and typo
2 parents e3d86d9 + 8da7f8b commit a91be50

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

libraries/MySensors/core/MyMessage.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ typedef enum {
163163
I_INCLUSION_MODE, I_CONFIG, I_FIND_PARENT, I_FIND_PARENT_RESPONSE,
164164
I_LOG_MESSAGE, I_CHILDREN, I_SKETCH_NAME, I_SKETCH_VERSION,
165165
I_REBOOT, I_GATEWAY_READY,
166-
I_REQUEST_SIGNING, /*!< Indicates senter require signed messages (bool param) */
166+
I_REQUEST_SIGNING, /*!< Indicates sender require signed messages (bool param) */
167167
I_GET_NONCE, /*!< Request for a nonce */
168168
I_GET_NONCE_RESPONSE, /*!< Payload is nonce data */
169-
I_HEARTBEAT, I_PRESENTATION, I_DISCOVER, I_DISCOVER_RESPONSE
169+
I_HEARTBEAT, I_PRESENTATION, I_DISCOVER, I_DISCOVER_RESPONSE, I_HEARTBEAT_RESPONSE
170170
} mysensor_internal;
171171

172172

libraries/MySensors/core/MySensorCore.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void sendBatteryLevel(uint8_t value, bool enableAck) {
215215
}
216216

217217
void sendHeartbeat(void) {
218-
_sendRoute(build(_msg, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT, false).set(_heartbeat++));
218+
_sendRoute(build(_msg, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT_RESPONSE, false).set(_heartbeat++));
219219

220220
}
221221

@@ -271,15 +271,8 @@ void _processInternalMessages() {
271271
presentation();
272272
}
273273
} else if (type == I_HEARTBEAT) {
274-
if (!mGetAck(_msg)) {
275-
// Send heartbeat ack message back to sender (with the same payload)
276-
_msgTmp = _msg;
277-
mSetRequestAck(_msgTmp,false); // Reply without ack flag (otherwise we would end up in an eternal loop)
278-
mSetAck(_msgTmp,true);
279-
_msgTmp.sender = _nc.nodeId;
280-
_msgTmp.destination = _msg.sender;
281-
_sendRoute(_msgTmp);
282-
}
274+
// Send heartbeat ack message back to sender (with the same payload)
275+
_sendRoute(build(_msg, _nc.nodeId, _msg.sender, _msg.sensor, C_INTERNAL, I_HEARTBEAT_RESPONSE, false).set(_heartbeat++));
283276
} else if (type == I_TIME && receiveTime) {
284277
// Deliver time to callback
285278
if (receiveTime)

libraries/MySensors/core/MyTransport.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ inline void transportProcess() {
9494
!mGetAck(_msg) &&
9595
(mGetCommand(_msg) != C_INTERNAL ||
9696
(type != I_GET_NONCE_RESPONSE && type != I_GET_NONCE && type != I_REQUEST_SIGNING &&
97-
type != I_ID_REQUEST && type != I_ID_RESPONSE &&
98-
type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE))) {
97+
type != I_ID_REQUEST && type != I_ID_RESPONSE &&
98+
type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE &&
99+
type != I_HEARTBEAT && type != I_HEARTBEAT_RESPONSE))) {
99100
if (!mGetSigned(_msg)) {
100101
// Got unsigned message that should have been signed
101102
debug(PSTR("no sign\n"));
@@ -414,7 +415,8 @@ boolean transportSendRoute(MyMessage &message) {
414415
(mGetCommand(message) != C_INTERNAL ||
415416
(type != I_GET_NONCE && type != I_GET_NONCE_RESPONSE && type != I_REQUEST_SIGNING &&
416417
type != I_ID_REQUEST && type != I_ID_RESPONSE &&
417-
type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE))) {
418+
type != I_FIND_PARENT && type != I_FIND_PARENT_RESPONSE &&
419+
type != I_HEARTBEAT && type != I_HEARTBEAT_RESPONSE))) {
418420
// Send nonce-request
419421
_signingNonceStatus=SIGN_WAITING_FOR_NONCE;
420422
if (!_sendRoute(build(_msgTmp, _nc.nodeId, message.destination, message.sensor, C_INTERNAL, I_GET_NONCE, false).set(""))) {

0 commit comments

Comments
 (0)