This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Self provisioning

Hi;

i am using sdk 17.0.2 and mesh 5.0.0. 

i am using light switch instance.In addition, the system works properly when provisioning is made with a smartphone.

I want self provisioning in this example. In other words, I want it to know both its own addressing and the address of the node to which it will send.

I took the code from the  https://devzone.nordicsemi.com/f/nordic-q-a/44515/mesh-node-self-provisioninglink and made the node get its own address. but I couldn't find any information on how to determine the address to send to.

#define APPKEY_INDEX (0)
#define NETKEY_INDEX (0)
#define GROUP_ADDRESS (0xCAFE)
    uint8_t netkey[16] = {0x79, 0xF5, 0xF1, 0x6A, 0x43, 0x22, 0x17, 0xDF, 0x1D, 0xC1, 0x59, 0x10, 0x13, 0x0A, 0x31, 0x6F};
    uint8_t appkey[16] = {0x5B, 0xD8, 0xDE, 0xB4, 0x49, 0xAB, 0x15, 0x1B, 0x72, 0x7F, 0xD4, 0x56, 0xF5, 0x49, 0x81, 0x9B};

    nrf_mesh_network_secmat_t KEY;
    //static const uint8_t KEY[NRF_MESH_KEY_SIZE] = NETKEY;
    dsm_local_unicast_address_t local_address = {0x0060, ACCESS_ELEMENT_COUNT};
    dsm_handle_t net_handle, dev_handle, app_handle, vendor_handle, handle;
    handle = DSM_HANDLE_INVALID;
    dev_handle = DSM_HANDLE_INVALID;
    ERROR_CHECK(dsm_local_unicast_addresses_set(&local_address));
    ERROR_CHECK(dsm_subnet_add(0, KEY.privacy_key, &net_handle));
    ERROR_CHECK(dsm_devkey_add(local_address.address_start, net_handle, KEY.privacy_key, &dev_handle));
    KEY.privacy_key[15] = 0xA0;
    ERROR_CHECK(dsm_appkey_add(0, net_handle, KEY.privacy_key, &app_handle));
    //PERSISTENT_STORAGE
    ERROR_CHECK(config_server_bind(dev_handle));
    //bool IsValid = vendor_handle_get(&vendor_handle);
    //if (IsValid == 0)
    //  while (1)
    //; //stay locked
    ERROR_CHECK(access_model_application_bind(m_clients_simple.model_handle, app_handle));

    // Add the address to the DSM as a subscription address:
    int i = dsm_address_subscription_add(GROUP_ADDRESS, &handle);
    // Add the subscription to the model:
    i = access_model_subscription_add(m_clients_simple.model_handle, handle);
    //dsm_address_publish_add(0x0051,
    custom_change_publish_address(0x0051);
    mesh_stack_device_reset(); //power cycle after self provisioning

The above code allowed the node to get its own address, but when I send it, I get a Publication not configured for client warning. What is the missing code for the provisioning process?

Parents Reply Children
  • my english can be bad.i am sorry.Yes.  i having problem trying to set the publication address.I couldn't find a clear example or tutorial on this subject.

  • Hi,

    Looking at your code snippet, you would probably need to call access_model_publish_application_set() and access_model_publish_address_set() as well. Function access_model_publish_address_set() need to be called if you want to change the publication address of a model on a node locally. 

    I also suggest have a look into the light switch client example from nRF5 Mesh SDK v1.0.1, In this version the client and provisioner was combined. The SDK version is really old but the example is a good source of reference if you want to combine the two.

  • Thanks Mttrinh.magic codes access_model_publish_application_set() and access_model_publish_address_set(). what you said with nice results. My code and it works fine. Here are the passwords.

     m_group_handle = DSM_HANDLE_INVALID;
        dsm_local_unicast_address_t local_address = {0x0020, ACCESS_ELEMENT_COUNT};
        ERROR_CHECK(dsm_local_unicast_addresses_set(&local_address));
        ERROR_CHECK(dsm_address_publish_add(0x0011, &m_group_handle));
        ERROR_CHECK(dsm_subnet_add(0, m_netkey, &m_netkey_handle));
        ERROR_CHECK(dsm_appkey_add(0, m_netkey_handle, m_appkey, &m_appkey_handle));
    
        ERROR_CHECK(access_model_application_bind(m_clients_simple.model_handle, m_appkey_handle));
        ERROR_CHECK(access_model_publish_application_set(m_clients_simple.model_handle, m_appkey_handle));
        ERROR_CHECK(access_model_publish_address_set(m_clients_simple.model_handle, m_group_handle));
        ERROR_CHECK(access_model_application_bind(server.model_handle, m_appkey_handle));
    
        dsm_handle_t subscription_address_handle;
        dsm_address_subscription_add(CLIENT_PUB_GROUP_ADDRESS_EVEN, &subscription_address_handle);
    
        access_model_subscription_add(m_clients_simple.model_handle, subscription_address_handle);
        access_model_subscription_add(server.model_handle, subscription_address_handle);

Related