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

Mesh node self provisioning

Hi all,

I want to self provision my node. I am using nrf52832 dev board, mesh SDK v 3.1.0, light switch client example. You may wonder why self provisioning, when there is nrf mesh provisioning mobile app, but it is the necessary intermediate step in the project where I combine the provisioner and client role in one node. The parts of code for self provisioning:

static uint8_t m_netkey; 
static uint8_t m_appkey;
static uint8_t m_self_devkey;

static dsm_handle_t m_netkey_handle;
static dsm_handle_t m_appkey_handle;
static dsm_handle_t m_self_devkey_handle;

static dsm_handle_t group_handle;
static generic_onoff_client_t m_client;

void self_provision()
{
    dsm_local_unicast_address_t local_address = {START_ADDRESS, ACCESS_ELEMENT_COUNT};
    ERROR_CHECK(dsm_local_unicast_addresses_set(&local_address));
    
    //hardcoded keys
    m_netkey = NETKEY;     
    m_appkey = APPKEY;
    m_devkey = DEVKEY;
    
    ERROR_CHECK(dsm_subnet_add(0, netkey, &m_netkey_handle));
    ERROR_CHECK(dsm_appkey_add(0, m_netkey_handle ,m_appkey, &m_appkey_handle));
    ERROR_CHECK(dsm_devkey_add(START_ADDRESS, m_netkey_handle, m_self_devkey, &m_self_devkey_handle));
    
    ERROR_CHECK(dsm_address_publish_add(FIRST_GROUP_ADDRESS, &group_handle));
}

void app_default_models_bind_setup(void)
{
    ERROR_CHECK(config_server_bind(m_self_devkey_handle));
    
    ERROR_CHECK(access_model_application_bind(m_client.model_handle, m_appkey_handle));
    ERROR_CHECK(access_model_publish_application_set(m_client.model_handle, m_appkey_handle));
    
    ERROR_CHECK(access_model_publish_address_set((m_client.model_handle, group_handle));
}

void models_init_cb(void)
{
    ERROR_CHECK(config_client_init(app_config_client_event_cb));
    ERROR_CHECK(generic_onoff_client_init(&m_client, FIRST_ELEMENT_INDEX));
}

To test if I correctly self provision the CLIENT node, I used the nrf mesh app to provision the SERVER node (lifgt switch server example), took the appkey and the netkey assigned by the mesh app, hardcoded them into the code for light switch client, configured the subscription address on the server node (using nrf mesh app) and watched, if the server reacts on the button presses on my client board. But I just watched the transfer timeout (transfer timeout - You can can object I use acknowledged messages in group messaging. I am aware of the fact, it is just temporary solution). 

My question is: Is there something missing in the code snippets above relating to be capable to self provision the node? I assume it has to do something with config client or config server model. Every help appreciated :) 

Patrik

Related