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

how to send mesh messages from client to a specific server

Hello,

I am using the light-switch example and I want to send a message or let say get the status of led of a particular server node....so how do I do that?

How to address them individually ..as the provisioner already assigns the addresses right  

BR

Nakul

Parents
  • You want to use the unicast address for sending messages to a particular node. You can find out how the light switch client node sends unicast messages to the server by taking a look at the button_event_handler() in the main.c file. The simple_on_off_client_set() function will send a unicast message to the first provisioned & configured server when button 1 is pressed on the client. 

    The simple_on_off_client_set() then calls access_model_reliable_publish(), which is where the unicast address of the server gets retrieved via the dsm_address_get() function.

    The unicast address also gets displayed in the provisioner during the app_health_event_callback() function in main.c

Reply
  • You want to use the unicast address for sending messages to a particular node. You can find out how the light switch client node sends unicast messages to the server by taking a look at the button_event_handler() in the main.c file. The simple_on_off_client_set() function will send a unicast message to the first provisioned & configured server when button 1 is pressed on the client. 

    The simple_on_off_client_set() then calls access_model_reliable_publish(), which is where the unicast address of the server gets retrieved via the dsm_address_get() function.

    The unicast address also gets displayed in the provisioner during the app_health_event_callback() function in main.c

Children
  • I understand that dsm_address_get() function gets us the address. But how to set a custom address like it is done in the nrf Mesh app video..in that unicast address can be set from thee app itself after getting provisioned...how to implement that in light-switch client? 

  • You need to use the proxy client & proxy server examples. These two examples enable connection over smartphones via PB-GATT. Then, you can test the app by following a similar setup to the nrf mesh youtube video. Configure the proxy client & server nodes like shown in the video, but then instead of adding a group publication address in the client node, add the unicast address (e.g. 0006) for the server node instead. 

    There is a also small bug in the client_publication_configured(void) function in the proxy client example.

    At the moment, the client_publication_configured function requires all four servers to be provisioned before you can publish a unicast or broadcast message.

    By changing the function to this:

    static bool client_publication_configured(uint32_t button_pressed)
    {
        dsm_handle_t pub_addr_handle;
    
        if (access_model_publish_address_get(m_clients[button_pressed].model_handle, &pub_addr_handle) == NRF_SUCCESS)
        {
            if (pub_addr_handle == DSM_HANDLE_INVALID)
            {
                return false;
            }
        }
        else
        {
            return false;
        }
        return true;
    }

    it should work. Then, you should be able to press button 1 on the proxy client to toggle the LED of the proxy_server node.

    It seems like the iOS device is setting a small connection interval & uses most of the timeslot for the mesh, leading to multiple calls to "Device is busy" on the proxy_client when pressing button 1 on the client. For now, you should be able to see quicker speeds if you disconnect from the mesh network on the nrf mesh app.

Related