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

send data from client to specific server via unicast address

Hi Guys,

We are currently working on a mesh sensor network. I have already developed a vendor sensor model (client and server). The client will also work as a gateway and will run on a nRF52840 DK. The Provisioner is on a separate DK just like in the Light Switch Example. The sonsors are a costum hardware with an nRF52840 on it.

The sensor send data on regular bases to the client via the mesh and the client then send it via UART to a computer.

During the provisioning process the nodes are picked randomly to add them to the network. Now the problem is that I have to know which device has received which unicast address.

I now want to send an On/Off message from the client to a unicast address and set an LED to identify which node it is. For that I have to change the publication address of the client locally. So is this possible without the provisioner? I have read that there is the following function available to change the publication address of a node: access_model_publish_address_set()

I found out that this function is in the access_config. h file decelerated but I haven't found a access_config.c file.

So which files do I have to include to use this functions?

Is there another way to change the publication address of a node locally?

Best regards,

Michel

 

Parents
  • You change the publication address like this: 

    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(destination_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 != destination_address)) {
            /* This should never assert */
            NRF_MESH_ASSERT(dsm_address_publish_remove(publish_address_handle) == NRF_SUCCESS);
            status = dsm_address_publish_add(destination_address, &publish_address_handle);
          } else {
            /* Use the retrieved publish_address_handle */
          }
        } else {
    
          status = dsm_address_publish_add(destination_address, &publish_address_handle);
        }
      }
    
      switch (status) {
      case NRF_ERROR_NO_MEM:
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "NRF_ERROR_NO_MEM\n");
        //            status_error_pub_send(handle, p_message, sig_model, ACCESS_STATUS_INSUFFICIENT_RESOURCES);
        return;
    
      case NRF_SUCCESS:
        break;
    
      default:
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "ACCESS_STATUS_UNSPECIFIED_ERROR\n");
        //            status_error_pub_send(handle, p_message, sig_model, ACCESS_STATUS_UNSPECIFIED_ERROR);
        return;
      }
    
      NRF_MESH_ASSERT(access_model_publish_address_set(m_clients[0].model_handle, publish_address_handle) == NRF_SUCCESS);

    destination_address is unicast address you want to send on/off command. You can figure out which header file you must include by searching the function on all solution. 
Reply Children
No Data
Related