[Solved] No heartbeat


  • Plugin Developer

    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 heartbeat
    

    I 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


  • Admin

    @jsiddall Yes, your code does not work, you should remove void before sendHeartbeat();


  • Plugin Developer

    @tekka Thanks, easy fix. I'm obviously not a C guy! I guess you only use "void" when you are defining a function.


  • Admin

    @jsiddall yup, defining a function without return value 🙂


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 10
  • 3
  • 1
  • 2

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts