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

Mesh 3.1: Client node send message to server node via unicast after provision by smartphone

Hi guys,

After i provision for client node or server node by smartphone i have unicast address for server model or client model. How can i send message from client to server via unicast address of server model. I have try example light switch and that example i must use publish address (group address), after provision i config publish address of client and server. Then i subcribe these pubish address each other, i realize clien and server use publish address to transfer message, isn't unicast address and i wonder how client send message to server not use group address.

Sorry beacause my english isn't good. Thanks a lot

Parents
  • Hi,

    1. In the client Node Configuration, expand the Elements section.
    2. Select the first Generic OnOff Client model instance.
    3. In the Publish section, set the Publish Address to one of the following addresses of the server nodes:
      • the unicast address of any server node. This configures the client example as follows:
        • The Button 1 on the client board turns ON LED 1 on the corresponding server board.
        • The Button 2 on the client board turns OFF LED 1 on the corresponding server board.
      • group addresses – if you choose this option, remember to subscribe the server nodes to these group addresses.

    See more here https://www.nordicsemi.com/DocLib/Content/SDK_Doc/Mesh_SDK/v3-1-0/md_examples_light_switch_README

    Best Regards,

    Marjeris

  • Thank you, I have understood how it works. I wonder how  can i change the publish address in my application code. I am try this code inside config_server.c and can I change publish address when there is an address exist in app nrf mesh? Do you think this code right ?

    void custom_change_publish_address(uint32_t publish_address){
    
    uint32_t status = NRF_SUCCESS;
    dsm_handle_t publish_address_handle = DSM_HANDLE_INVALID;
    nrf_mesh_address_t publish_address_stored;
    
    
    if (access_model_publish_address_get(m_clients[0].model_handle, &publish_address_handle) != NRF_SUCCESS) {
    status = dsm_address_publish_add(publish_address, &publish_address_handle);
    }
    else {
    if (dsm_address_get(publish_address_handle, &publish_address_stored) == NRF_SUCCESS) {
    if ((publish_address_stored.type == NRF_MESH_ADDRESS_TYPE_VIRTUAL) ||
    (publish_address_stored.type != NRF_MESH_ADDRESS_TYPE_VIRTUAL && publish_address_stored.value != publish_address)) {
    NRF_MESH_ASSERT(dsm_address_publish_remove(publish_address_handle) == NRF_SUCCESS);
    status = dsm_address_publish_add(publish_address, &publish_address_handle);
    } 
    } else {
    status = dsm_address_publish_add(publish_address, &publish_address_handle);
    }
    }
    NRF_MESH_ASSERT(access_model_publish_address_set(m_clients[0].model_handle, publish_address_handle) == NRF_SUCCESS);
    }

Reply
  • Thank you, I have understood how it works. I wonder how  can i change the publish address in my application code. I am try this code inside config_server.c and can I change publish address when there is an address exist in app nrf mesh? Do you think this code right ?

    void custom_change_publish_address(uint32_t publish_address){
    
    uint32_t status = NRF_SUCCESS;
    dsm_handle_t publish_address_handle = DSM_HANDLE_INVALID;
    nrf_mesh_address_t publish_address_stored;
    
    
    if (access_model_publish_address_get(m_clients[0].model_handle, &publish_address_handle) != NRF_SUCCESS) {
    status = dsm_address_publish_add(publish_address, &publish_address_handle);
    }
    else {
    if (dsm_address_get(publish_address_handle, &publish_address_stored) == NRF_SUCCESS) {
    if ((publish_address_stored.type == NRF_MESH_ADDRESS_TYPE_VIRTUAL) ||
    (publish_address_stored.type != NRF_MESH_ADDRESS_TYPE_VIRTUAL && publish_address_stored.value != publish_address)) {
    NRF_MESH_ASSERT(dsm_address_publish_remove(publish_address_handle) == NRF_SUCCESS);
    status = dsm_address_publish_add(publish_address, &publish_address_handle);
    } 
    } else {
    status = dsm_address_publish_add(publish_address, &publish_address_handle);
    }
    }
    NRF_MESH_ASSERT(access_model_publish_address_set(m_clients[0].model_handle, publish_address_handle) == NRF_SUCCESS);
    }

Children
Related