Troubleshooting nRF Mesh Heartbeat Feature Configuration in Version 5

"Hello, I'm trying to set up the Heartbeat feature in my nRF Mesh network using the nRF Mesh app. I've provisioned and configured both a server and a client, and I've set up the Heartbeat Publication and Subscription addresses as well as the Heartbeat Subscription Period. However, I'm not seeing any Heartbeat messages and I'm not sure what to do next.

I'm using nRF Mesh version 5 and I've checked that both devices have the Heartbeat feature enabled. I've also confirmed that the addresses I'm using for the Publication and Subscription are unique and not already in use by other devices in the network.

One thing I'm not sure about is where to see the result of the Heartbeat feature once it's configured. I've checked the app and I don't see any Heartbeat log or message feature. Is there somewhere else I should be looking?

Any advice or troubleshooting tips would be greatly appreciated. Thank you!"

  • Hi Muhammad,

    I noticed you had four follow-up questions but have now deleted them and closed this DevZone thread. I'm sorry if the wait made you make that decision. I was double-checking something with my team before answering you.

    I hope everything is working fine for you now.

  • Although I have many questions, I have been able to answer some through experimentation. This is why I have decided to close the thread.

    For instance, I was trying to determine how to find the optimal TTL value from the heartbeat feature. I discovered that this is typically done by analyzing the hops value.

    Thank you for your response.

  • Hi ,

    I have trouble trouble getting callbacks.

    I setup the mesh sensor example. The server observer should give me some information regarding the heartbeat. Therefore I created a group called "heartbeat" inside the nrf mesh app and the sensor server publishes the heartbeat with a count of 2048 and period of 4 seconds to this group.

    The sensor server subscribes to the group with a period of more than half an hour, so that I can see inside the app that there are messages incoming. So thats fine and working properly.

    Now I want to display the information from the heartbeat in the console. Therefore I implemented the structures in the model_handler.c as follows (by reference to https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.0/zephyr/connectivity/bluetooth/api/mesh/heartbeat.html#c.bt_mesh_hb_sub):

    // Define callback function to handle heartbeat events
    void hb_sub_cb(const struct bt_mesh_hb_sub *sub, uint8_t hops, uint16_t feat) {
        // This function will be called when a heartbeat message is received
        // src: Source address of the heartbeat message
        // dst: Destination address of the heartbeat message
        // hops: Number of hops the message took
        // period: Period of the heartbeat message
        printk("Heartbeat received\n");
        LOG_INF("Heartbeat received from 0x%04x\n", sub->src);
        LOG_INF("\t\t dst      = 0x%04x\n", sub->dst);
        LOG_INF("\t\t hops     = %d\n", hops);
        LOG_INF("\t\t period   = %d\n", sub->period);
    }

    void hb_sub_end_cb(const struct bt_mesh_hb_sub *sub) {
        // This function will be called when the subscription period ends
        LOG_INF("Heartbeat subscription ended\n");
    }

    void hb_pub_sent_cb(const struct bt_mesh_hb_pub *pub) {
        // This function will be called when a heartbeat message is sent
        // dst: Destination address of the heartbeat message
        // count: Number of heartbeat messages sent
        // period: Period of the heartbeat message

        printk("Heartbeat published\n");
        LOG_INF("\t\t dst      = 0x%04x\n", pub->dst);
        LOG_INF("\t\t count    = %d\n", pub->count);
        LOG_INF("\t\t period   = %d\n", pub->period);
    }

    static struct bt_mesh_hb_cb hb_cb = {
        .recv = hb_sub_cb,
        .sub_end = hb_sub_end_cb,
        .pub_sent = hb_pub_sent_cb,
    };

    I also setup the definition for the heartbeat callback as follows:

    const struct bt_mesh_comp *model_handler_init(void)
    {
        k_work_init_delayable(&attention_blink_work, attention_blink);

        dk_button_handler_add(&button_handler);
       
        BT_MESH_HB_CB_DEFINE(hb_cb);

        return ∁
    }

    However when I build the application I get the warning that "'hb_cb' defined but not used [-Wunused-variable]" and nothing from the heartbeat i displayed in the serial monitor although I can see through nrf mesh app that messages are received.

    Am I missing something?

    I am using nRF Connect SDK v2.6.0

    Best,

    Toni

  • Hi Toni, 

    This seems to be a logging setup issue, which makes it not completely relate to the topic discuss here; and I see that you have opened a new case for your question:  Trouble Logging Heartbeat. Let's continue there.

    Best,

    Hieu

Related