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

access_model_application_bind() returns NRF_ERROR_NOT_FOUND?

When calling access_model_application_bind(), NRF_ERROR_NOT_FOUNDis returned?

I have had this working before, but after adding another server model I am getting the error.

Here is program leading up to the error, I imagine it is something around here I am doing wrong.

network_handle = DSM_HANDLE_INVALID;
network_group_handle = DSM_HANDLE_INVALID;
application_handle = DSM_HANDLE_INVALID;
for(size_t i = 0; i < TOTAL_DEVICE_COUNT; i++)
{
	device_handle_list[i] = DSM_HANDLE_INVALID;
}
for(size_t i = 0; i < (BEACON_CLIENT_COUNT + ALARM_SERVER_COUNT); i++)
{
	element_handle_list[i] = DSM_HANDLE_INVALID;
}

dsm_init();
dsm_local_unicast_address_t local_address =
{
    .address_start = PROVISIONER_ADDRESS,
    .count = ACCESS_ELEMENT_COUNT
};
dsm_local_unicast_addresses_set(&local_address);
dsm_address_publish_add(NETWORK_GROUP_ADDRESS, &network_group_handle);
dsm_subnet_add(0, netkey, &network_handle);
dsm_appkey_add(0, network_handle, appkey, &application_handle);


health_client_init(&local_health_client, 0, health_event_cb);
for(size_t i = 0; i < BEACON_CLIENT_COUNT; i++)
{
    beacon_client_list[i].get_id_status_cb = beacon_client_event_cb;
    beacon_client_init(&beacon_client_list[i], i);
}
alarm_server.set_alert_cb = set_alert_handler;
alarm_server.get_time_cb = get_time_handler;
alarm_server_init(&alarm_server, 0);

access_init();
access_model_application_bind(local_health_client.model_handle, application_handle); <-- ERROR!
  • I figured out the problem. access_init() should be called directly after calling dsm_init(), or at least before initializing the models.

    The solution to the problem can be seen here:

    dsm_init();
    access_init();
    ...
    

    In hindsight, it obvious it should be done like this, because access_model_add() is called in all the model init functions, and the access layer should itself be initialized before functions can be called to it.

Related