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

How can I retrieve rx_handle and cccd_handle on DM_EVT_DEVICE_CONTEXT_LOADED?

I am testing this on ble_app_hrs and ble_app_hrs_c. After devices are bound I would like to skip discovery as it takes long time. So all I need to do is get the service's handles on DM_EVT_LINK_SECURE event. I suppose I should retrieve it in DM_EVT_DEVICE_CONTEXT_LOADED, but how?

Currently I have hardcoded these values and it works, but this is ugly code (device_manager_event_handler()).

case DM_EVT_LINK_SECURED:
    if(m_is_bonded) {
        m_ble_hrc_c.hrs_handle = 0xE; // load these
        m_ble_hrs_c.hrs_cccd_handle = 0xF;
        err_code = ble_hrs_c_notif_enable(&m_ble_hrs_c);
    } else {
        err_code = ble_db_discovery_start(&m_ble_db_discovery, p_event->event_param.p_gap_param->conn_handle);
    }
    APP_ERROR_CHECK(err_code);
    break;

case DM_EVT_DEVICE_CONTEXT_LOADED:
    // load handles here
    break;
Related