This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Subscribe a group address for the Mesh Message

Currently, I am working with the Nordic SimpleOnOff Model of the Light switch in the Bluetooth Mesh.

I am good that the light in the mesh can be set on/off after Provisioned.

Now, i would like to divide the Board into 2 Groups, let's said Group A and Group B.

But i am not very sure how to work with that?

How can i drive a specify device to bind to a specific Group Address? I believe that i should subscribe to some service, but any sample code or pointer that can show how can I subscribe the service for that "group"?

After that, how should i send the message to "This Group" of light for On/Off.

I tried to study the code of access_model_publish, from the Mesh SDK, but seems it did not have a way to specify the Group address for boardcast.

And how about the Receiver? Should i define another set of OpCode, like SIMPLE_ON_OFF_OPCODE_GROUP_SET to do the operation there?

Parents
  • I wouldn't suggest to use 2 clients to talk to 2 groups. You can simply change public address of one client using access_model_publish_address_set().

    So if you have 2 group addresses you want to send to and want to switch between them you do this:

    ERROR_CHECK(dsm_address_publish_add(group_address1, &m_group_address_handle1));
    ERROR_CHECK(dsm_address_publish_add(group_address2, &m_group_address_handle2));
    

    You call above codes only once. The purpose is to add the 2 group address into DSM database.

    Now if you want the client publication address to group address 1 , you call this:

    access_model_publish_address_set(yourgroupclient.model_handle, m_group_address_handle1));
    

    If you want the client to send to group address 2 you call this:

    access_model_publish_address_set(yourgroupclient.model_handle, m_group_address_handle2));
    

    You can switch between them, call above function every time you switch.

    The way we use the last client as group client, is just the way we chose to do that. You can use any client to send to group address, just apply the code above.

Reply
  • I wouldn't suggest to use 2 clients to talk to 2 groups. You can simply change public address of one client using access_model_publish_address_set().

    So if you have 2 group addresses you want to send to and want to switch between them you do this:

    ERROR_CHECK(dsm_address_publish_add(group_address1, &m_group_address_handle1));
    ERROR_CHECK(dsm_address_publish_add(group_address2, &m_group_address_handle2));
    

    You call above codes only once. The purpose is to add the 2 group address into DSM database.

    Now if you want the client publication address to group address 1 , you call this:

    access_model_publish_address_set(yourgroupclient.model_handle, m_group_address_handle1));
    

    If you want the client to send to group address 2 you call this:

    access_model_publish_address_set(yourgroupclient.model_handle, m_group_address_handle2));
    

    You can switch between them, call above function every time you switch.

    The way we use the last client as group client, is just the way we chose to do that. You can use any client to send to group address, just apply the code above.

Children
  • Hi,

    I am working in light switch example and (with my modification) the servers are sending a message using the broadcast address 0xCAFE, and in this format all server received the messages. This feature works fine!

    This way, the client side also received the messages, but for some reason this message is not trated.

    This my question! I know that address_nonvirtual_subscription_exists has a list that has the devices able to receive the message.

    My doubt is: How I can to insert the client in this list, for the client device to trate the broadcast message sends from any server.

    What I wanna do now is subscribe the client to receive broadcast messages since in light switch example only server side receive the broadcast messages, the client side dont..

    How I told above, I already  send broadcast messages from server to server (trought 0xCAFE address), but the client dont receive these messages because it is not subscribed.

    I need to modify the light switch example to init the client side able to receive broadcast messages.

    Can anyone help me in this question?

     

  • Have you tried what I suggested in the first answer of calling dsm_address_subscription_add() and then call access_model_subscription_add() to add the address to the client subscription list ? 

    It's the same for server and client if you want to configure something locally. 

  • Hi Hung,

    I'm trying to implement your solution in Mesh 1.0.1, but it is crashing at:

    ERROR_CHECK(dsm_address_publish_add(GROUP_ADDRESS_CUSTOM, &m_group_handle2));

    With error code 4 ("No Memory for operation"?).

    What could it be?

    My experiment is to have 2 groups, one for 2 of the servers and another for all 3 servers.

    So far I modified the do_config_step() in provisioner.c to assign to different groups (as a first step), like:

                if ( m_target_address % 0x02)
                {
                    address.value  = GROUP_ADDRESS_CUSTOM;
                }
                else
                {
                    address.value  = GROUP_ADDRESS;
                }


    This is ok, as I'm able to talk with the nodes that subscribed to GROUP_ADDRESS.

    Now I want one of the clients to speak with the node that was assigned to GROUP_ADDRESS_CUSTOM, but it's failing as described above...

  • Hi Renato, I hope you can help, I'm trying to get my servers to send messages using the broadcast address. How did you do it?

Related