How to subscribe to group address in mesh

Hello, 

Could someone point to a tutorial or doc, where I can learn how to subscribe to a group in mesh in code. I can do this using the nRF app, however, I would like to do this in code. 

The purpose for this is that instead of the client asking for the temperature, I would like the server to periodically send the temperature.

I believe the way to do this is through: 

bt_mesh_sensor_srv_pub(&sensor_srv, ctx,&chip_temp, &val);

I am unsure what to change ctx (if that even is the correct variable) for a group address or a specific address.
Thank you,
Shahin
Parents
  • Hi,

    The purpose for this is that instead of the client asking for the temperature, I would like the server to periodically send the temperature.

    Please note that through use of periodic publishing you can configure the device once to periodically send the temperature. If periodic publishing to the configured publish address covers your needs, then you can rely on functionality already implemented in the stack.

    I believe the way to do this is through: 

    Yes, for publishing to a different address than the currently configured publish address, you can use bt_mesh_sensor_srv_pub(). If you want to publish to the currently configured publish address, then you can instead use bt_mesh_sensor_srv_sample() which in addition handles getting the current sensor reading before publishing.

    I am unsure what to change ctx (if that even is the correct variable) for a group address or a specific address.

    The ctx parameter is a struct bt_mesh_msg_ctx, where the uint16_t addr field is the one to use for the address. You can use that field both for unicast addresses and group addresses.

    Regards,
    Terje

  • All sorted, 

    Seems I missed 

    .send_ttl = BT_MESH_TTL_DEFAULT,
    Thank you for your help!
Reply Children
No Data
Related