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

Some troubles in creating groups

I'm trying to create more groups in mesh.We know that all the nodes(servers) are  divided into two groups called ODD and EVEN,so I want to create more groups.

I have changed some codes in the provisioner and client.

In the provisioner node_step.c,the changes as follows,

add the     NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT3,  in config_steps_t,

in the function of config_step_execute(),


}

static void config_step_execute(void)
{
   ......

    switch (*mp_config_step)
    {
      ......

    

        
        case NODE_SETUP_CONFIG_PUBLICATION_ONOFF_SERVER:
        {
            config_publication_state_t pubstate = {0};
            pubstate.element_address = m_current_node_addr;
            pubstate.publish_address.type = NRF_MESH_ADDRESS_TYPE_UNICAST;
            if ((m_current_node_addr % 3) == 1)
            {
                pubstate.publish_address.value = UNPROV_START_ADDRESS + ELEMENT_IDX_ONOFF_CLIENT1;
            }
            else if ((m_current_node_addr % 3) == 2)
            {
                pubstate.publish_address.value = UNPROV_START_ADDRESS + ELEMENT_IDX_ONOFF_CLIENT2;
            }
            else
            {
                pubstate.publish_address.value = UNPROV_START_ADDRESS + ELEMENT_IDX_ONOFF_CLIENT3;            
            }
            ......
        }

        /* Configure subscription address for the On/Off server */
        case NODE_SETUP_CONFIG_SUBSCRIPTION_ONOFF_SERVER:
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Adding subscription\n");
            uint16_t element_address = m_current_node_addr;
            nrf_mesh_address_t address = {NRF_MESH_ADDRESS_TYPE_INVALID, 0, NULL};
            address.type = NRF_MESH_ADDRESS_TYPE_GROUP;
            if (m_current_node_addr % 0x03 ==1)//
            {
                address.value  = GROUP_ADDRESS_111;
            }
            else if (m_current_node_addr % 0x03 ==2)
            {
                address.value  = GROUP_ADDRESS_222;
            }
            else
            {
                address.value  = GROUP_ADDRESS_333;
            }
           ......
            
            break;
        }

        case NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT1:
        {
            config_publication_state_t pubstate = {0};
            client_pub_state_set(&pubstate,
                                 m_current_node_addr + ELEMENT_IDX_ONOFF_CLIENT1,
                                 GROUP_ADDRESS_111);
            retry_on_fail(config_client_model_publication_set(&pubstate));

            static const access_status_t exp_status[] = {ACCESS_STATUS_SUCCESS};
            expected_status_set(CONFIG_OPCODE_MODEL_PUBLICATION_STATUS, ARRAY_SIZE(exp_status), exp_status);
            break;
        }

        case NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT2:
        {
            config_publication_state_t pubstate = {0};
            client_pub_state_set(&pubstate,
                                 m_current_node_addr + ELEMENT_IDX_ONOFF_CLIENT2,
                                 GROUP_ADDRESS_222);
            retry_on_fail(config_client_model_publication_set(&pubstate));

            static const access_status_t exp_status[] = {ACCESS_STATUS_SUCCESS};
            expected_status_set(CONFIG_OPCODE_MODEL_PUBLICATION_STATUS, ARRAY_SIZE(exp_status), exp_status);
            break;
        }
//add
        case NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT3:
        {
            config_publication_state_t pubstate = {0};
            client_pub_state_set(&pubstate,
                                 m_current_node_addr + ELEMENT_IDX_ONOFF_CLIENT3,
                                 GROUP_ADDRESS_333);
            retry_on_fail(config_client_model_publication_set(&pubstate));

            static const access_status_t exp_status[] = {ACCESS_STATUS_SUCCESS};
            expected_status_set(CONFIG_OPCODE_MODEL_PUBLICATION_STATUS, ARRAY_SIZE(exp_status), exp_status);
            break;
        }

        default:
            ERROR_CHECK(NRF_ERROR_NOT_FOUND);
            break;
    }
}

I added #define GROUP_ADDRESS_333  (0xC004); and #define ELEMENT_IDX_ONOFF_CLIENT3       (3)    in example_network_config.h.

Also in the cient , I set 0,1 to control the 1st group;2,3 to control 2nd group;4,5 to control 3rd group,

static void button_event_handler(uint32_t button_number)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);

    ......

    switch(button_number)
    {
        case 0:
        case 2:
        case 4:
            set_params.on_off = APP_STATE_ON;
            break;

        case 1:
        case 3:
        case 5:
            set_params.on_off = APP_STATE_OFF;
            break;
    }

......
    switch (button_number)
    {
        case 0:
        case 1:
            /* Demonstrate acknowledged transaction, using 1st client model instance */
            /* In this examples, users will not be blocked if the model is busy */
            (void)access_model_reliable_cancel(m_clients[0].model_handle);
            status = generic_onoff_client_set(&m_clients[0], &set_params, &transition_params);
            hal_led_pin_set(BSP_LED_0, set_params.on_off);
            break;

        case 2:
        case 3:
            /* Demonstrate un-acknowledged transaction, using 2nd client model instance */
            status = generic_onoff_client_set_unack(&m_clients[1], &set_params,
                                                    &transition_params, APP_UNACK_MSG_REPEAT_COUNT);
            hal_led_pin_set(BSP_LED_1, set_params.on_off);
            break;

        case 4:
        case 5:
            /* Demonstrate un-acknowledged transaction, using 3nd client model instance */
            status = generic_onoff_client_set_unack(&m_clients[2], &set_params,
                                                    &transition_params, APP_UNACK_MSG_REPEAT_COUNT);
            hal_led_pin_set(BSP_LED_2, set_params.on_off);
            break;
    }

  ......
    }
}

I changed #define CLIENT_MODEL_INSTANCE_COUNT  (3); and #define GROUP_ADDR_COUNT       (3)    in light_switch_example_common.h.

After I finished these work,I found that the servers can react to two groups and the 3rd group without any reaction,the log of debug in client:

0> <t:          0>, main.c,  309, ----- BLE Mesh Light Switch Client Demo -----
 0> <t:          0>, mesh_softdevice_init.c,  117, Initializing SoftDevice...
 0> <t:          0>, mesh_softdevice_init.c,   75, Enabling BLE...
 0> <t:         16>, mesh_softdevice_init.c,  109, sd_ble_enable: app_ram_base should be adjusted to 0x20002DA0
 0> <t:        531>, main.c,  276, Initializing and adding models
 0> <t:        566>, main.c,  341, Device UUID : 0059CCAA000000000D10EC4F9C0BA8D1
  < 0
 0> <t:      59538>, main.c,  177, Button 0 pressed
 0> <t:      59540>, main.c,  206, Sending msg: ONOFF SET 1
 0> <t:      60437>, main.c,  124, Acknowledged transfer success.
 0> <t:      60440>, main.c,  150, OnOff server: 0x0106, Present OnOff: 0, Target OnOff: 1, Remaining Time: 100 ms
 0> <t:      62174>, main.c,  150, OnOff server: 0x0106, Present OnOff: 1, Target OnOff: 1, Remaining Time: 100 ms
 0> <t:      65625>, main.c,  155, OnOff server: 0x0106, Present OnOff: 1
  < 1
 0> <t:      95574>, main.c,  177, Button 1 pressed
 0> <t:      95576>, main.c,  206, Sending msg: ONOFF SET 0
 0> <t:      96149>, main.c,  124, Acknowledged transfer success.
 0> <t:      96151>, main.c,  150, OnOff server: 0x0106, Present OnOff: 1, Target OnOff: 0, Remaining Time: 100 ms
 0> <t:     101202>, main.c,  155, OnOff server: 0x0106, Present OnOff: 0
  < 2
 0> <t:     125058>, main.c,  177, Button 2 pressed
 0> <t:     125060>, main.c,  206, Sending msg: ONOFF SET 1
 0> <t:     127633>, main.c,  150, OnOff server: 0x0104, Present OnOff: 1, Target OnOff: 1, Remaining Time: 100 ms
 0> <t:     131199>, main.c,  155, OnOff server: 0x0104, Present OnOff: 1
  < 3
 0> <t:     151266>, main.c,  177, Button 3 pressed
 0> <t:     151268>, main.c,  206, Sending msg: ONOFF SET 0

any help i'll appreciate very much.

nrf52832, nrf5 SDK for Mesh v2.2.0, nrf5 SDK 15.0.

Parents Reply Children
  • Hi Zhengrui,

    I don't see an issue with your code. You would need to debug and check:

    - If your client can actually send packet to the address of group 3. You can check on access layer the actual packet sent when you press the button.Please check packet_tx() function in access.c 

    - If your server is actually subscribe to the Group 3 address. You can test this by using the python PyACI to send dummy packet to that address. 

    It's worth to try using the PyACI to setup some nodes with the publication/subscription address to the group address that you are testing.

    I would suggest you to try playing with the provisioner on the phone app, and the PyACI to get to know more about the address, it's make it easier when you want to try to automate it with the code of the provisioner. For the app you can have a look at this video. For the PyACI, you should follow this guide. 

  • I tried it ,when I input 4 or 5 in RTT Viewer to control the group3, it shows Publication not configured for client 4 or 5.I don't  think that there is client 4 or 5.

    If I configure 3 servers for the address of 0x1004,0x1005,0x1006, two of them can act to the client,but the third have no action when I send 4/5 to the server.

    Did I have some understanding for it ?Or some codes lost in the client?

  • Hi Zhenrui, 

    I'm sorry for the late response, I am on vacation. 

    Please make sure you have created extra client model and extra element on the client side. I strongly suggest you to play with either the phone app (if you have proxy) to do provisioning or the PyACI to make sure you have all you need on the client and server side, and then can start to modify the provisioner to do provisioning instead of using the app/PyACI

  • em, I have changed some code on the client to add them but it seems like invalid for the client.Can you tell me where and how to add extra client and extra element on the client side? So that I can change the codes correctly.

    Thanks.

  • Hi Zhengrui, 

    Have you tried to increase CLIENT_MODEL_INSTANCE_COUNT ? 

    When you increase CLIENT_MODEL_INSTANCE_COUNT, the ACCESS_ELEMENT_COUNT will be increased accordingly. 

    You would need to increase ACCESS_MODEL_COUNT (=2+CLIENT_MODEL_INSTANCE_COUNT) as well. 

    After that you should have the number of client model to match with what you need. 

Related