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
  • The group address (GROUP_ADDRESS = 0xCAFE) is assigned to the server in configuration phase.

    You can find the assigning at PROV_STATE_CONFIG_SUBSCRIPTION event in do_config_step() in provisioner.c

    If you want to assign different group address to different server, you can modify the code inside that event handler, and change the address.value there.

    Another option is to change the subscription address locally on the server. To do that you follow what 's inside the configuration server on the server side handle_config_model_subscription_add().

    Basically you need to call dsm_address_subscription_add() to add the group address to the DSM address database. And then call access_model_subscription_add() to assign the server model to listen to that address.

    Similarly, when you want to broadcast to a group address or change between broadcast address, you do dsm_address_publish_add() to add the address to the database and then access_model_publish_address_set() to mount the address ID to the model. Check access_setup() in the client's code.

Reply
  • The group address (GROUP_ADDRESS = 0xCAFE) is assigned to the server in configuration phase.

    You can find the assigning at PROV_STATE_CONFIG_SUBSCRIPTION event in do_config_step() in provisioner.c

    If you want to assign different group address to different server, you can modify the code inside that event handler, and change the address.value there.

    Another option is to change the subscription address locally on the server. To do that you follow what 's inside the configuration server on the server side handle_config_model_subscription_add().

    Basically you need to call dsm_address_subscription_add() to add the group address to the DSM address database. And then call access_model_subscription_add() to assign the server model to listen to that address.

    Similarly, when you want to broadcast to a group address or change between broadcast address, you do dsm_address_publish_add() to add the address to the database and then access_model_publish_address_set() to mount the address ID to the model. Check access_setup() in the client's code.

Children
  • Thanks Bui, Your message help a lot

    When walk along the code , i am a bit confusion about the

    m_clients[GROUP_CLIENT_INDEX].model_handle vs m_group_handle in main.c
    
    ERROR_CHECK(access_model_publish_address_set(m_clients[GROUP_CLIENT_INDEX].model_handle, m_group_handle));
    

    It is found that when the data broadcast to the Group, by sending by the function simple_on_off_client_set_unreliable, it is using the model_handle instead the m_group_handle;

    Have i mixed up something there?

    So, in case when i have more than one group, I should still make use of the m_clients[GROUP_CLIENT_INDEX],

  • Yes, but there are 4 clients on the client example (each one is one element ). 3 of them talk to the 3 servers and the last one talks to the group address. That's why you see m_clients[GROUP_CLIENT_INDEX].model_handle there.

  • So, in case if i not only have one group will be in the network, i should create

    static simple_on_off_client_t m_clients[SERVER_COUNT];
    static simple_on_off_client_t m_group_clients[GROUP_COUNT];
    

    such that the m_client is used to talk with the individual server while m_group_client is used to talk with the group?

  • But i am still not full related the m_clients[GROUP_CLIENT_INDEX].model_handle Vs m_group_handler.

    Should I call the following routine always in a pair, to maintain their relationship?

    ERROR_CHECK(dsm_address_publish_add(group_address, &m_group_handle[m_group_count]));
    ERROR_CHECK(access_model_publish_address_set(m_group_clients[m_group_count].model_handle, m_group_handle[m_group_count]));
    

    To be specific, if i would like to call the simple_on_off_client_set_unreliable, how can i related the group_address, such that the group_handle, to the m_client(m_group_client) in my case?

  • More hack in the code, seems in the nrf_mesh_config_app.h, also got a boundary that the Group only set with One only??

    #define ACCESS_ELEMENT_COUNT (1 + SERVER_COUNT) /* One element per Simple OnOff client instance */
    
    #define ACCESS_MODEL_COUNT (1 + /* Configuration client / \ 1 + / Health client / \ GROUP_COUNT + / Simple OnOff client (group) / \ SERVER_COUNT / Simple OnOff client (per server) */)
    

    I should update this parameters also?

Related