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

Related