Hello,
I work on an application which use the pc-ble-driver 1.0 as BLE central for handling external peripheral devices.
Now, I am working on bonding procedure. To make it simpler I started from 'Just Works' bonding and followed this chart. So, after established connection with peripheral device I call sd_ble_gap_authenticate
as follows:
ble_gap_sec_params_t ble_gap_sec_params;
memset(&ble_gap_sec_params, 0, sizeof(ble_gap_sec_params));
ble_gap_sec_params.bond = 1;
ble_gap_sec_params.mitm = 0;
ble_gap_sec_params.lesc = 0;
ble_gap_sec_params.keypress = 0;
ble_gap_sec_params.io_caps = BLE_GAP_IO_CAPS_NONE;
ble_gap_sec_params.oob = 0;
ble_gap_sec_params.min_key_size = 7;
ble_gap_sec_params.max_key_size = 16;
ble_gap_sec_params.kdist_peer.enc = 1;
ble_gap_sec_params.kdist_peer.id = 1;
err_code = sd_ble_gap_authenticate(p_adapter, p_ble_gattc_evt->conn_handle, &ble_gap_sec_params);
It works well (returns NRF_SUCCESS
) and after that I get the BLE_GAP_EVT_SEC_PARAMS_REQUEST
event. So, it seems to be OK to this point. My problem starts on calling sd_ble_gap_sec_params_reply
. I do it as follows:
switch (p_ble_evt->header.evt_id)
{
...
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
{
ble_gap_sec_keyset_t keys_exchanged;
keys_exchanged.keys_own.p_enc_key = NULL;
keys_exchanged.keys_own.p_id_key = NULL;
keys_exchanged.keys_own.p_sign_key = NULL;
keys_exchanged.keys_own.p_pk = NULL;
keys_exchanged.keys_peer.p_enc_key = &bond_table[0].peer_enc_key;
keys_exchanged.keys_peer.p_id_key = &bond_table[0].peer_id;
keys_exchanged.keys_peer.p_sign_key = NULL;
keys_exchanged.keys_peer.p_pk = NULL;
err_code = sd_ble_gap_sec_params_reply(p_adapter,
p_ble_evt->evt.gap_evt.conn_handle,
BLE_GAP_SEC_STATUS_SUCCESS,
NULL,
&keys_exchanged);
printf("sd_ble_gap_sec_params_reply err_code: 0x%X\n", err_code);
}
break;
...
}
The main problem is that the sd_ble_gap_sec_params_reply
doesn't return anything. The application just hangs on this call.
Could you tell me why it happens? Do I something wrong? If so, why the API call doesn't return an error?
Best regards,
Mike