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

How to send data to all node over mesh

I want to send data to all node by mesh 2.1.1.

From the Mesh profile(3.4.2.4 Group address),the dst_addr = 0xFFFF is send to all node .

I try to setting "packet_tx()"funtion as follows(The red part is add):

nrf_mesh_address_t dst_address;
dsm_handle_t appkey_handle;
dsm_handle_t subnet_handle = DSM_HANDLE_INVALID;
if (p_rx_message != NULL)
{
appkey_handle = p_rx_message->meta_data.appkey_handle;
subnet_handle = p_rx_message->meta_data.subnet_handle;
dst_address = p_rx_message->meta_data.src;
}
else
{
appkey_handle = m_model_pool[handle].model_info.publish_appkey_handle;
if (dsm_address_get(m_model_pool[handle].model_info.publish_address_handle, &dst_address) != NRF_SUCCESS)
{
return NRF_ERROR_NOT_FOUND;
}
if (dst_address.value == NRF_MESH_ADDR_UNASSIGNED)
{
return NRF_ERROR_INVALID_ADDR;
}
}
dst_address.type = NRF_MESH_ADDRESS_TYPE_GROUP;
dst_address.value = 0xFFFF;
dst_address.p_virtual_uuid = NULL;

But other node Can't receiv data.

Parents
  • Hi,

    This case should be helpful. Regarding your question, you want to send a message to a group address, which all of the server nodes will subscribe to. You can either do this by making a few changes to the provisioner & client source codes or by using the proxy client & proxy server examples instead. If you use the proxy examples, you should provision the nodes via the nRF Mesh app for iOS or Android.

    It seems like you want to use the first solution, so I will explain this in detail below:

    In the provisioner, you will notice that four client models are being configured (one for each button the client nRF52 dev kit) (i.e. cases NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT1-4). If you look at clients 3 &4, you notice that one is configured to send messages to the odd group address & the other sends to the even group address. What you can do is subscribe all nodes to the odd group address for example.

    That way, whenever you press button 3 on the client kit, the lights on all server nodes should either turn on or off. 

    First off, you want to change the code in the NODE_SETUP_CONFIG_SUBSCRIPTION_ONOFF_SERVER case in node_setup.c of the provisioner from this:

                if (m_current_node_addr % 0x02)
                {
                    address.value  = GROUP_ADDRESS_ODD;
                }
                else
                {
                    address.value  = GROUP_ADDRESS_EVEN;
                }

    to this:

    //            if (m_current_node_addr % 0x02)
    //            {
    //                address.value  = GROUP_ADDRESS_ODD;
    //            }
    //            else
    //            {
    //                address.value  = GROUP_ADDRESS_EVEN;
    //            }
                address.value  = GROUP_ADDRESS_ODD;

    Then, go to the client example & understand the code in case 3. The code snippet below sends a simple on off client unreliable message (i.e. unacknowledged message) to the odd group, which in our case is all server nodes. This is due to the changes made in the on off server group address subscription we did above in the provisioner code.

            case 3:
                /* send a group message to the ODD group, with inverted GPIO pin value */
                status = simple_on_off_client_set_unreliable(&m_clients[button_number],
                                                             !hal_led_pin_get(BSP_LED_0 + button_number),
                                                             GROUP_MSG_REPEAT_COUNT);
                if (status == NRF_SUCCESS)
                {
                    hal_led_pin_set(BSP_LED_0 + button_number, !hal_led_pin_get(BSP_LED_0 + button_number));
                }
                break;

    Now, whenever you press button 3 on the client board, all lights should either turn on or off on all server boards. This is because the client is publishing a group message to all of the servers that are subscribed to that group address.

    Kind Regards,

    Bjørn

Reply
  • Hi,

    This case should be helpful. Regarding your question, you want to send a message to a group address, which all of the server nodes will subscribe to. You can either do this by making a few changes to the provisioner & client source codes or by using the proxy client & proxy server examples instead. If you use the proxy examples, you should provision the nodes via the nRF Mesh app for iOS or Android.

    It seems like you want to use the first solution, so I will explain this in detail below:

    In the provisioner, you will notice that four client models are being configured (one for each button the client nRF52 dev kit) (i.e. cases NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT1-4). If you look at clients 3 &4, you notice that one is configured to send messages to the odd group address & the other sends to the even group address. What you can do is subscribe all nodes to the odd group address for example.

    That way, whenever you press button 3 on the client kit, the lights on all server nodes should either turn on or off. 

    First off, you want to change the code in the NODE_SETUP_CONFIG_SUBSCRIPTION_ONOFF_SERVER case in node_setup.c of the provisioner from this:

                if (m_current_node_addr % 0x02)
                {
                    address.value  = GROUP_ADDRESS_ODD;
                }
                else
                {
                    address.value  = GROUP_ADDRESS_EVEN;
                }

    to this:

    //            if (m_current_node_addr % 0x02)
    //            {
    //                address.value  = GROUP_ADDRESS_ODD;
    //            }
    //            else
    //            {
    //                address.value  = GROUP_ADDRESS_EVEN;
    //            }
                address.value  = GROUP_ADDRESS_ODD;

    Then, go to the client example & understand the code in case 3. The code snippet below sends a simple on off client unreliable message (i.e. unacknowledged message) to the odd group, which in our case is all server nodes. This is due to the changes made in the on off server group address subscription we did above in the provisioner code.

            case 3:
                /* send a group message to the ODD group, with inverted GPIO pin value */
                status = simple_on_off_client_set_unreliable(&m_clients[button_number],
                                                             !hal_led_pin_get(BSP_LED_0 + button_number),
                                                             GROUP_MSG_REPEAT_COUNT);
                if (status == NRF_SUCCESS)
                {
                    hal_led_pin_set(BSP_LED_0 + button_number, !hal_led_pin_get(BSP_LED_0 + button_number));
                }
                break;

    Now, whenever you press button 3 on the client board, all lights should either turn on or off on all server boards. This is because the client is publishing a group message to all of the servers that are subscribed to that group address.

    Kind Regards,

    Bjørn

Children
Related