Setting "struct bt_mesh_msg_ctx *ctx" for multiple addresses to send same data

Hello,

In BLE-Mesh models, we have APIs like:

int bt_mesh_model_send(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
		       struct net_buf_simple *msg,
		       const struct bt_mesh_send_cb *cb, void *cb_data)

To send data to other devices on the Mesh.

Here I observed that the context "struct bt_mesh_msg_ctx *ctx" stores the address to which the data is to be sent, like address 0x0002.

My requirement is, I want to send the same data to multiple addresses. Like 0x0002, 0x0003 etc,.

Is there any provision in context to store multiple addresses or I shall have to run "int bt_mesh_model_send()" in a for loop for all the addresses..?

Or is there a separate API to send same data to a list of addresses..?

Parents
  • Hi,

    There is no API to send the same message contents to multiple addresses, no.

    The mechanism in Bluetooth mesh for sending to multiple recipients is the use of group addresses. The models on the nodes can be configured to subscribe to multiple group addresses, and then each group address is used to reach all models subscribed to that particular group address. That way, one call to bt_mesh_model_send() is received and handled by multiple nodes, if the destination address is a group address. This is the preferred way to send to multiple nodes on a Bluetooth mesh network, as it minimizes the amount of network traffic.

    If you cannot solve this through using group addressing, then you must send individual messages to each recipient, yes.

    Regards,
    Terje

  • Thank you ,

    Can you please help me with which substitute API can be used in place of "bt_mesh_model_send()" to send data to a group..?

    Thanks,

Reply Children
  • If you can suggest a sample usage of send to a group, That would be great.

    Thanks,

  • Hi,

    For sending to a group, you must send to a group address instead of to a unicast address. Group addresses are in the range 0xC000 to 0xFEFF. You normally use exactly the same APIs as you would for unicast addresses. You can also configure the node to publish to a group address, in which case all publication will go to that group address.

    For models to receive messages for a group, you must configure the node so that the model subscribes to the group address.

    Note: There is an additional group range, 0xFF00 to 0xFFFF, which is reserved for fixed groups assigned by Bluetooth SIG, such as "all nodes", "all relays", etc. These target the first element (primary element) on various types of nodes.

    Regards,
    Terje

Related