[Solved] No heartbeat
-
I am trying to implement sendHeartbeat() periodically so my gateway knows that a sensor is alive even when it doesn't have any data to send.
The issue is that while I am pretty sure sendHeartbeat() is being called nothing is actually being sent.
This is a node running MYS 2.0.
Here's the sketch excerpt from loop():
#define MY_DEBUG if ((millis() - last_heartbeat_time) > HEARTBEAT_TIME) { // If it exceeds the heartbeat time then send a heartbeat void sendHeartbeat(); last_heartbeat_time = millis(); #ifdef MY_DEBUG Serial.println("Sent heartbeat"); #endif } wait(UPDATE_TIME);And here's the debug log:
Sent heartbeat TSP:SANCHK:OK TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=39,pt=7,l=5,sg=0,ft=0,st=ok:0.00 TSP:MSG:SEND 3-3-0-0 s=1,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=ok:4.37 Sent heartbeatI know the if clause is executing because I get the "Sent heartbeat" debug message.
The two other messages are from child sensors 1 and 2 and those seem to be working fine.
I would expect that if a message was being sent for the heartbeat I should see some kind of debug log showing the message was sent. However, I neither see a debug message nor receive a heartbeat message at the gateway.
Can anyone see any reason the above code shouldn't send a heartbeat?
Thanks,
Jeff
-
I am trying to implement sendHeartbeat() periodically so my gateway knows that a sensor is alive even when it doesn't have any data to send.
The issue is that while I am pretty sure sendHeartbeat() is being called nothing is actually being sent.
This is a node running MYS 2.0.
Here's the sketch excerpt from loop():
#define MY_DEBUG if ((millis() - last_heartbeat_time) > HEARTBEAT_TIME) { // If it exceeds the heartbeat time then send a heartbeat void sendHeartbeat(); last_heartbeat_time = millis(); #ifdef MY_DEBUG Serial.println("Sent heartbeat"); #endif } wait(UPDATE_TIME);And here's the debug log:
Sent heartbeat TSP:SANCHK:OK TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=39,pt=7,l=5,sg=0,ft=0,st=ok:0.00 TSP:MSG:SEND 3-3-0-0 s=1,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=ok:4.37 Sent heartbeatI know the if clause is executing because I get the "Sent heartbeat" debug message.
The two other messages are from child sensors 1 and 2 and those seem to be working fine.
I would expect that if a message was being sent for the heartbeat I should see some kind of debug log showing the message was sent. However, I neither see a debug message nor receive a heartbeat message at the gateway.
Can anyone see any reason the above code shouldn't send a heartbeat?
Thanks,
Jeff
-
@tekka Thanks, easy fix. I'm obviously not a C guy! I guess you only use "void" when you are defining a function.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login