Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Client side (on the light switch example) to receive broadcast messages

I am estudying and modifying the light switch example.

the example shared in the SDK, this example works as star network. (1 client and 3 (or many) servers) where:

- The client sends (unicast and broadcast) messages to servers

- The server only sends unicast messages (reply) to client.

In this moment I already can to send and receive broadcast messages between the servers, but in this message type, the client side does not treat  the message.

What modification I need to do, to client side "undestand" that him are receiving a broadcast messages?

Parents
  • First off, Bluetooth mesh is not a start network. It is a mesh network with many to many communication capabilities.

    Have you updated the server to send & receive broadcast messages? If so, can you not just make the same modifications to the client example as you did to the server side to receive the broadcast messages?

  • Hi Bjorn

    Have you updated the server to send & receive broadcast messages?

    In the original example (light Switch) the servers already received messages from client, but the server only answer to client. The communication server to server I did it!

    If so, can you not just make the same modifications to the client example as you did to the server side to receive the broadcast messages?

    In the server side I am sending a message with broadcast address 0xCAFE, and in this format all server received the messages. This way, the client side also received the messages, but for some reason this message is not trated

    The problem is that the solution has a list with all the servers provisioned and when I send a broadcast message all servers received (client doesn't receive, because it is not present in this list). I am not sure if this is the real problem.

    My doubt is: How can I send a broadcast message from server side and receive it in the application layer (simple_on_off_client.c)?

    In the device_state_manager.c  there are the follow function that is used when we sent a broadcast messages.

    static bool rx_group_address_get(uint16_t address, nrf_mesh_address_t * p_address)
    {
     dsm_handle_t handle;
     if (address_nonvirtual_subscription_exists(address, &handle))
     {
         p_address->value = address;
         p_address->type = NRF_MESH_ADDRESS_TYPE_GROUP;
         p_address->p_virtual_uuid = NULL;
         return true;
    }
      else
      {
        return false;
      }
    }

    Why in the server side the address_nonvirtual_subscription_exists(address, &handle) function retuns true and in the client side the same function returns false?

  • You should be able to send a broadcast message from the server side & receive it in the application layer of the client. Regarding the function, address_nonvirtual_subscription_exists(), this means that the nonvirtual address does not exist in the rx address list of the client, whereas it does in the server.

  • Hi Bjorn,

    I think that I am not clear in my doubt.

    As I said in my last comment, in the server side I am sending a message using the broadcast address 0xCAFE, and in this format all server received the messages. This feature works fine!

    This way, the client side also received the messages, but for some reason this message is not trated.

    Regarding the function, address_nonvirtual_subscription_exists(), this means that the nonvirtual address does not exist in the rx address list of the client, whereas it does in the server.

    It is exactly this my question! I know that address_nonvirtual_subscription_exists has a list that has the devices able to receive the message.

    My doubt is: How I can to insert the client in this list, for the client device to trate the broadcast message sends from any server.

     

  • The non virtual addresses list is located in device_state_manager.c: 

    /** Non-virtual addresses */
    static regular_address_t m_addresses[DSM_NONVIRTUAL_ADDR_MAX];

    You might be able to use this function here:

    static void nonvirtual_address_set(uint16_t raw_address, dsm_handle_t handle)
    {
        m_addresses[handle].address = raw_address;
        m_addresses[handle].subscription_count = 0;
        m_addresses[handle].publish_count = 0;
        bitfield_set(m_addr_nonvirtual_allocated, handle);
        bitfield_set(m_addr_nonvirtual_needs_flashing, handle);
    }

    Seems like this function is used inside the add_address function:

    static uint32_t add_address(uint16_t raw_address, dsm_handle_t * p_address_handle, dsm_address_role_t role)

     

  • The question is:

    Why the servers receives the broadcast messages and the client not?

    what function do I need to modify to the client receives the broadcast messages?

  • I think it might be of interest to take a look at this devzone post. It seems some people have had a few difficulties, but most people have gotten it working after debugging a bit. 

Reply Children
  • Hi Bjorn,

    This post didnt help me because, I already did the communication between client and server by unicast messages.

    What I wanna do now is subscribe tha client to receive broadcast messages since in tlight switch example only server side receive the broadcast messages, the client side dont..

    How I told above, I already  send broadcast messages from server to server (trought 0xCAFE address), but the client dont receive these messages because it is not subscribed.

    I need to modify the light switch example to init the client side able to receive broadcast messages.

  • As you probably already know, the simple_on_off_client_set_unreliable() function inside the simple_on_off_client.c file in the light switch client example (mesh sdk 1.0.1) sends the broadcast messages from the client to the server. I believe you could add this function to the server (which you might have already done) & before you call the access_model_publish() function, you can call this function:

    void address_set(uint16_t addr)
    {
        ERROR_CHECK(dsm_address_publish_add(addr, &m_central_handle));
        ERROR_CHECK(access_model_publish_address_set(m_server.model_handle, m_central_handle));
    }

    where, addr is the GROUP_ADDRESS (0xCAFE), m_central_handle is defined as:

    static dsm_handle_t m_central_handle;

    & m_server is already defined in main.c of the light_switch_server example. This should hopefully set the group address in the server & allow you to broadcast a message from the server to the client.

    I am not fully certain this will work, but it is a starting point.

Related