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?

  • 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?

  • 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.

  • Should we also need to consider to take care the follows in nrf_mesh_config_app.h, while GROUP_COUNT is added for the number of Group that i can support in the Network?

    /**
     * @defgroup DSM_CONFIG Device State Manager configuration
     * Sizes for the internal storage of the Device State Manager.
     * @{
     */
    /** Maximum number of subnetworks. */
    #define DSM_SUBNET_MAX                                  (1)
    /** Maximum number of applications */
    #define DSM_APP_MAX                                     (1)
    /** Maximum number of device keys */
    #define DSM_DEVICE_MAX                                  (SERVER_COUNT)
    /** Maximum number of virtual addresses. */
    #define DSM_VIRTUAL_ADDR_MAX                            (GROUP_COUNT)
    /** Maximum number of non-virtual addresses. One for each of the servers and a group address. */
    #define DSM_NONVIRTUAL_ADDR_MAX                         (SERVER_COUNT + GROUP_COUNT)
    /** Number of flash pages reserved for the DSM storage */
    #define DSM_FLASH_PAGE_COUNT                            (1)
    

    Where can i found more about the info of Virtual Vs non-virtual?

Related