Subscribing to heartbeat messages in a mesh network


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hello everyone !!

I'm trying to work with heartbeat messages. I'm using android app by silicon Labs for provisioning and configuring so I can't subscribe and publish heartbeat messages using this app.

On the other hand, there is command for publishing heartbeat messages in meshctl, so I'm able to publish heartbeat messages. but, there isn't any command to subscribe for heartbeat messages.

I understand that this needs to done using configuration client,still I want to know if there is a way to subscribe just for testing purposes?

Can I use these lines of code I found at /mesh_demo/src.c  in my main.c file, hard coding the addresses

 
        struct bt_mesh_cfg_hb_sub sub = {
            .src = PUBLISHER_ADDR,
            .dst = GROUP_ADDR,
            .period = 0x10,
        };

        bt_mesh_cfg_hb_sub_set(net_idx, addr, &sub, NULL);

though adding these lines gives compilation error in my code.

--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


Steve Brown
 

Hi Ashish,

On Tue, 2017-12-26 at 17:47 +0530, ashish.shukla@... wrote:
Hello everyone !!

I'm trying to work with heartbeat messages. I'm using android app by
silicon Labs for provisioning and configuring so I can't subscribe
and publish heartbeat messages using this app.

On the other hand, there is command for publishing heartbeat messages
in meshctl, so I'm able to publish heartbeat messages. but, there
isn't any command to subscribe for heartbeat messages.

I understand that this needs to done using configuration client,still
I want to know if there is a way to subscribe just for testing
purposes?

Can I use these lines of code I found at /mesh_demo/src.c in my
main.c file, hard coding the addresses


struct bt_mesh_cfg_hb_sub sub = {
.src = PUBLISHER_ADDR,
.dst = GROUP_ADDR,
.period = 0x10,
};

bt_mesh_cfg_hb_sub_set(net_idx, addr, &sub, NULL);

though adding these lines gives compilation error in my code.

--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development
www.corvi.com

If the target of heartbeat publish is 0077 (meshctl's unicast address),
it will display the returned status.

Steve


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi,

Thanks Steve, it works as expected.

I watched a video on youtube by Johan, in which he demonstrates working of heartbeat messages. Which means he's developed some means to subscribe to Heartbeat messages as well. Is there some other way if I want to subscribe to heartbeat messages except meshctl?


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Tue, Dec 26, 2017 at 5:58 PM, Steve Brown <sbrown@...> wrote:
Hi Ashish,

On Tue, 2017-12-26 at 17:47 +0530, ashish.shukla@... wrote:
> Hello everyone !!
>
> I'm trying to work with heartbeat messages. I'm using android app by
> silicon Labs for provisioning and configuring so I can't subscribe
> and publish heartbeat messages using this app.
>
> On the other hand, there is command for publishing heartbeat messages
> in meshctl, so I'm able to publish heartbeat messages. but, there
> isn't any command to subscribe for heartbeat messages.
>
> I understand that this needs to done using configuration client,still
> I want to know if there is a way to subscribe just for testing
> purposes?
>
> Can I use these lines of code I found at /mesh_demo/src.c  in my
> main.c file, hard coding the addresses
>
>
>         struct bt_mesh_cfg_hb_sub sub = {
>             .src = PUBLISHER_ADDR,
>             .dst = GROUP_ADDR,
>             .period = 0x10,
>         };
>
>         bt_mesh_cfg_hb_sub_set(net_idx, addr, &sub, NULL);
>
> though adding these lines gives compilation error in my code.
>
> --
> Warm regards,
> Ashish Shukla
> Jr. Embedded Engineer
> Research & Development
> www.corvi.com
>
>
If the target of heartbeat publish is 0077 (meshctl's unicast address),
it will display the returned status.

Steve



Johan Hedberg
 

Hi Ashish,

On Wed, Dec 27, 2017, ashish.shukla@... wrote:
Thanks Steve, it works as expected.

I watched a video on youtube by Johan, in which he demonstrates working of
heartbeat messages. Which means he's developed some means to subscribe to
Heartbeat messages as well. Is there some other way if I want to subscribe
to heartbeat messages except meshctl?
The call to bt_mesh_cfg_hb_sub_set() that you found in mesh_demo is on
the right track. It will send the heartbeat subscription configuration
message to the given address, which also works if the address is the
local node. Note that you also need to have the configuration client
model as part of your models array. You didn't show us what exactly the
compilation issue is that you got, but I suspect you simply didn't have
the Configuration Client Model enabled in Kconfig. To enable it you need
to set CONFIG_BT_MESH_CFG_CLI=y.

Johan


Johan Hedberg
 

Hi Ashish,

On Wed, Dec 27, 2017, Johan Hedberg wrote:
On Wed, Dec 27, 2017, ashish.shukla@... wrote:
Thanks Steve, it works as expected.

I watched a video on youtube by Johan, in which he demonstrates working of
heartbeat messages. Which means he's developed some means to subscribe to
Heartbeat messages as well. Is there some other way if I want to subscribe
to heartbeat messages except meshctl?
The call to bt_mesh_cfg_hb_sub_set() that you found in mesh_demo is on
the right track. It will send the heartbeat subscription configuration
message to the given address, which also works if the address is the
local node. Note that you also need to have the configuration client
model as part of your models array. You didn't show us what exactly the
compilation issue is that you got, but I suspect you simply didn't have
the Configuration Client Model enabled in Kconfig. To enable it you need
to set CONFIG_BT_MESH_CFG_CLI=y.
One thing I forgot to mention: you can play with most of these features
also using tests/bluetooth/mesh_shell. It has commands for configuring
heartbeat publication & subscription. The commands aren't exactly the
same as meshctl, so be sure to check with "help" for what commands are
available and what parameters they take. The mesh shell uses internally
the same configuration client API that e.g. bt_mesh_cfg_hb_sub_set() is
a part of, so if you're interested in more examples of this API's usage,
take a look at subsys/bluetooth/host/mesh/shell.c.

Johan


Vikrant More <vikrant8051@...>
 

how to subscribe dynamically to heartbeat of any node (using meshctl) ?

I've enable CONFIG_BT_MESH_CFG_CLI=y this in prj.conf

Added "Configuration Client Model" into list of models supported by root_model -->

static struct bt_mesh_cfg_cli cfg_cli = {
};


static struct bt_mesh_model root_models[] = {
    BT_MESH_MODEL_CFG_SRV(&cfg_srv),
    BT_MESH_MODEL_CFG_CLI(&cfg_cli),
    BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
    BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_SRV, gen_onoff_op,
              &gen_onoff_pub, NULL),
    BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_LEVEL_SRV, gen_level_op,
              &gen_level_pub, NULL),
    BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_CLI, gen_onoff_cli_op,
              &gen_onoff_cli_pub, NULL),
};

------------------------------------------------------------------------------------------------------------------------------------------------


static void heartbeat(u8_t hops, u16_t feat)
{
    //Toggle LED4 on nRF52840_PDK

    NRF_P0->OUT ^= (1<<16);
}

static struct bt_mesh_cfg_srv cfg_srv = {
    .relay = BT_MESH_RELAY_DISABLED,
    .beacon = BT_MESH_BEACON_ENABLED,
#if defined(CONFIG_BT_MESH_FRIEND)
    .frnd = BT_MESH_FRIEND_ENABLED,
#else
    .frnd = BT_MESH_FRIEND_NOT_SUPPORTED,
#endif
#if defined(CONFIG_BT_MESH_GATT_PROXY)
    .gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
#else
    .gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
#endif
    .default_ttl = 7,

    /* 3 transmissions with 20ms interval */
    .net_transmit = BT_MESH_TRANSMIT(2, 20),
    .relay_retransmit = BT_MESH_TRANSMIT(2, 20),

    .hb_sub.func = heartbeat,
};

On Wed, Dec 27, 2017 at 12:00 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Ashish,

On Wed, Dec 27, 2017, Johan Hedberg wrote:
> On Wed, Dec 27, 2017, ashish.shukla@... wrote:
> > Thanks Steve, it works as expected.
> >
> > I watched a video on youtube by Johan, in which he demonstrates working of
> > heartbeat messages. Which means he's developed some means to subscribe to
> > Heartbeat messages as well. Is there some other way if I want to subscribe
> > to heartbeat messages except meshctl?
>
> The call to bt_mesh_cfg_hb_sub_set() that you found in mesh_demo is on
> the right track. It will send the heartbeat subscription configuration
> message to the given address, which also works if the address is the
> local node. Note that you also need to have the configuration client
> model as part of your models array. You didn't show us what exactly the
> compilation issue is that you got, but I suspect you simply didn't have
> the Configuration Client Model enabled in Kconfig. To enable it you need
> to set CONFIG_BT_MESH_CFG_CLI=y.

One thing I forgot to mention: you can play with most of these features
also using tests/bluetooth/mesh_shell. It has commands for configuring
heartbeat publication & subscription. The commands aren't exactly the
same as meshctl, so be sure to check with "help" for what commands are
available and what parameters they take. The mesh shell uses internally
the same configuration client API that e.g. bt_mesh_cfg_hb_sub_set() is
a part of, so if you're interested in more examples of this API's usage,
take a look at subsys/bluetooth/host/mesh/shell.c.

Johan
_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users


Johan Hedberg
 

Hi Vikrant,

On Wed, Dec 27, 2017, Vikrant More wrote:
how to subscribe dynamically to heartbeat of any node (using meshctl) ?
I don't think meshctl has this support yet. IIRC, Steve sent an RFC
patch for that, but nothing has been merged upstream yet.

I've enable CONFIG_BT_MESH_CFG_CLI=y this in prj.conf

Added "Configuration Client Model" into list of models supported by
root_model -->

static struct bt_mesh_cfg_cli cfg_cli = {
};


static struct bt_mesh_model root_models[] = {
BT_MESH_MODEL_CFG_SRV(&cfg_srv),
BT_MESH_MODEL_CFG_CLI(&cfg_cli),
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_SRV, gen_onoff_op,
&gen_onoff_pub, NULL),
BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_LEVEL_SRV, gen_level_op,
&gen_level_pub, NULL),
BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_CLI, gen_onoff_cli_op,
&gen_onoff_cli_pub, NULL),
};
That all looks fine to me, however note that you don't need this if
you're planning to use an external tool like meshctl.
CONFIG_BT_MESH_CFG_CLI is only needed if you want to use Zephyr as the
configuration client.

Johan


Steve Brown
 


Hi Ashish 

On Dec 27, 2017, at 12:19 AM, "ashish.shukla@..." <ashish.shukla@...> wrote:

Hi,

Thanks Steve, it works as expected.

I watched a video on youtube by Johan, in which he demonstrates working of heartbeat messages. Which means he's developed some means to subscribe to Heartbeat messages as well. Is there some other way if I want to subscribe to heartbeat messages except meshctl?


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Tue, Dec 26, 2017 at 5:58 PM, Steve Brown <sbrown@...> wrote:
Hi Ashish,

On Tue, 2017-12-26 at 17:47 +0530, ashish.shukla@... wrote:
> Hello everyone !!
>
> I'm trying to work with heartbeat messages. I'm using android app by
> silicon Labs for provisioning and configuring so I can't subscribe
> and publish heartbeat messages using this app.
>
> On the other hand, there is command for publishing heartbeat messages
> in meshctl, so I'm able to publish heartbeat messages. but, there
> isn't any command to subscribe for heartbeat messages.
>
> I understand that this needs to done using configuration client,still
> I want to know if there is a way to subscribe just for testing
> purposes?
>
> Can I use these lines of code I found at /mesh_demo/src.c  in my
> main.c file, hard coding the addresses
>
>
>         struct bt_mesh_cfg_hb_sub sub = {
>             .src = PUBLISHER_ADDR,
>             .dst = GROUP_ADDR,
>             .period = 0x10,
>         };
>
>         bt_mesh_cfg_hb_sub_set(net_idx, addr, &sub, NULL);
>
> though adding these lines gives compilation error in my code.
>
> --
> Warm regards,
> Ashish Shukla
> Jr. Embedded Engineer
> Research & Development
> www.corvi.com
>
>
If the target of heartbeat publish is 0077 (meshctl's unicast address),
it will display the returned status.

Steve

There isn’t a heartbeat subscribe command in meshctl. It wouldn’t be hard to add. Take a look at the code and add it. I’m on vacation for a couple of weeks
Steve


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi,
Thanks for your concern Steve, I'll write the code for it. Have a good time on vacation!!!

Hi Johan,
I'm almost there with mesh shell. Only a small issue, after disabling all DEBUG messages, I still see adv stack and Kernal Stacks on terminal, which makes it difficult work with shell. How to stop seeing these messages while keeping mesh shell and printk enabled?
 


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Wed, Dec 27, 2017 at 7:15 PM, Steve Brown <sbrown@...> wrote:

Hi Ashish 

On Dec 27, 2017, at 12:19 AM, "ashish.shukla@..." <ashish.shukla@...> wrote:

Hi,

Thanks Steve, it works as expected.

I watched a video on youtube by Johan, in which he demonstrates working of heartbeat messages. Which means he's developed some means to subscribe to Heartbeat messages as well. Is there some other way if I want to subscribe to heartbeat messages except meshctl?


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Tue, Dec 26, 2017 at 5:58 PM, Steve Brown <sbrown@...> wrote:
Hi Ashish,

On Tue, 2017-12-26 at 17:47 +0530, ashish.shukla@... wrote:
> Hello everyone !!
>
> I'm trying to work with heartbeat messages. I'm using android app by
> silicon Labs for provisioning and configuring so I can't subscribe
> and publish heartbeat messages using this app.
>
> On the other hand, there is command for publishing heartbeat messages
> in meshctl, so I'm able to publish heartbeat messages. but, there
> isn't any command to subscribe for heartbeat messages.
>
> I understand that this needs to done using configuration client,still
> I want to know if there is a way to subscribe just for testing
> purposes?
>
> Can I use these lines of code I found at /mesh_demo/src.c  in my
> main.c file, hard coding the addresses
>
>
>         struct bt_mesh_cfg_hb_sub sub = {
>             .src = PUBLISHER_ADDR,
>             .dst = GROUP_ADDR,
>             .period = 0x10,
>         };
>
>         bt_mesh_cfg_hb_sub_set(net_idx, addr, &sub, NULL);
>
> though adding these lines gives compilation error in my code.
>
> --
> Warm regards,
> Ashish Shukla
> Jr. Embedded Engineer
> Research & Development
> www.corvi.com
>
>
If the target of heartbeat publish is 0077 (meshctl's unicast address),
it will display the returned status.

Steve

There isn’t a heartbeat subscribe command in meshctl. It wouldn’t be hard to add. Take a look at the code and add it. I’m on vacation for a couple of weeks
Steve


Johan Hedberg
 

Hi Ashish,

On Thu, Dec 28, 2017, ashish.shukla@... wrote:
I'm almost there with mesh shell. Only a small issue, after disabling all
DEBUG messages, I still see adv stack and Kernal Stacks on terminal, which
makes it difficult work with shell. How to stop seeing these messages while
keeping mesh shell and printk enabled?
CONFIG_INIT_STACKS=n

Johan