@@ -28,7 +28,7 @@ MyMessage _msgTmp; // Buffer for temporary messages (acks and nonces among other
28
28
char _convBuf[MAX_PAYLOAD*2 +1 ];
29
29
#endif
30
30
31
- uint16_t _heartbeat;
31
+ uint32_t _heartbeat = 0 ;
32
32
void (*_timeCallback)(unsigned long ); // Callback for requested time messages
33
33
34
34
@@ -188,6 +188,8 @@ ControllerConfig getConfig() {
188
188
189
189
190
190
boolean _sendRoute (MyMessage &message) {
191
+ // increment heartbeat counter
192
+ _heartbeat++;
191
193
#if defined(MY_GATEWAY_FEATURE)
192
194
if (message.destination == _nc.nodeId ) {
193
195
// This is a message sent from a sensor attached on the gateway node.
@@ -215,7 +217,7 @@ void sendBatteryLevel(uint8_t value, bool enableAck) {
215
217
}
216
218
217
219
void sendHeartbeat (void ) {
218
- _sendRoute (build (_msg, _nc.nodeId , GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT_RESPONSE, false ).set (_heartbeat++ ));
220
+ _sendRoute (build (_msg, _nc.nodeId , GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT_RESPONSE, false ).set (_heartbeat));
219
221
220
222
}
221
223
@@ -271,8 +273,7 @@ void _processInternalMessages() {
271
273
presentation ();
272
274
}
273
275
} else if (type == I_HEARTBEAT) {
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++));
276
+ sendHeartbeat ();
276
277
} else if (type == I_TIME && receiveTime) {
277
278
// Deliver time to callback
278
279
if (receiveTime)
0 commit comments