ret_code_t im_whitelist_create(pm_peer_id_t * p_peer_ids, uint8_t n_peer_ids, ble_gap_whitelist_t * p_whitelist) { VERIFY_MODULE_INITIALIZED(); VERIFY_PARAM_NOT_NULL(p_whitelist); ret_code_t err_code; p_whitelist->addr_count = 0; p_whitelist->irk_count = 0; m_im.n_irk_whitelist_peer_ids = 0; for (uint32_t peer_index = 0; peer_index < n_peer_ids; peer_index++) { uint16_t conn_handle = im_conn_handle_get(p_peer_ids[peer_index]); if (ble_conn_state_status(conn_handle) != BLE_CONN_STATUS_CONNECTED) { pm_peer_data_flash_t peer_data; err_code = pdb_read_buf_get(p_peer_ids[peer_index], PM_PEER_DATA_ID_BONDING, &peer_data, NULL); if (err_code == NRF_ERROR_INVALID_PARAM || err_code == NRF_ERROR_NOT_FOUND) { return NRF_ERROR_INVALID_PARAM; } if (p_whitelist->pp_addrs != NULL && peer_data.p_bonding_data->peer_id.id_addr_info.addr_type != BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE && peer_data.p_bonding_data->peer_id.id_addr_info.addr_type != BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE ) { memcpy(m_im.whitelist_addrs[peer_index].addr, peer_data.p_bonding_data->peer_id.id_addr_info.addr, BLE_GAP_ADDR_LEN ); m_im.whitelist_addrs[peer_index].addr_type = peer_data.p_bonding_data->peer_id.id_addr_info.addr_type; p_whitelist->pp_addrs[peer_index] = &m_im.whitelist_addrs[peer_index]; p_whitelist->addr_count++; } if (p_whitelist->pp_irks != NULL && is_valid_irk(&(peer_data.p_bonding_data->peer_id.id_info)) ) { memcpy(m_im.whitelist_irks[peer_index].irk, peer_data.p_bonding_data->peer_id.id_info.irk, BLE_GAP_SEC_KEY_LEN ); p_whitelist->pp_irks[peer_index] = &m_im.whitelist_irks[peer_index]; p_whitelist->irk_count++; m_im.irk_whitelist_peer_ids[peer_index] = p_peer_ids[peer_index]; m_im.n_irk_whitelist_peer_ids++; } } } return NRF_SUCCESS; }
ret_code_t pm_conn_sec_status_get(uint16_t conn_handle, pm_conn_sec_status_t * p_conn_sec_status) { VERIFY_MODULE_INITIALIZED(); VERIFY_PARAM_NOT_NULL(p_conn_sec_status); ble_conn_state_status_t status = ble_conn_state_status(conn_handle); if (status == BLE_CONN_STATUS_INVALID) { return BLE_ERROR_INVALID_CONN_HANDLE; } p_conn_sec_status->connected = (status == BLE_CONN_STATUS_CONNECTED); p_conn_sec_status->bonded = ble_conn_state_user_flag_get(conn_handle, m_bonding_flag_id); p_conn_sec_status->encrypted = ble_conn_state_encrypted(conn_handle); p_conn_sec_status->mitm_protected = ble_conn_state_mitm_protected(conn_handle); return NRF_SUCCESS; }