Skip to content

Commit

Permalink
bluetooth: nrf52: Fix bug that pairing is required for each connections
Browse files Browse the repository at this point in the history
There are the following issues which cause reconnection without bonding information:
- Pass no own data by sd_ble_sec_params_reply().
- Pass no data by sd_ble_sec_info_reply()
  • Loading branch information
SPRESENSE committed Oct 13, 2022
1 parent f6b8231 commit 38f09fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions sdk/modules/bluetooth/hal/nrf52/ble_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,11 +1594,11 @@ void onSecInfoRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt)
{
continue;
}
if(!memcmp(BondInfoInFlash[index].peerEncKey.master_id.rand, secinfo->master_id.rand, BLE_GAP_SEC_RAND_LEN))
if(!memcmp(BondInfoInFlash[index].ownEncKey.master_id.rand, secinfo->master_id.rand, BLE_GAP_SEC_RAND_LEN))
{
BLE_PRT("onSecInfoRequest: master_id exitsting index %d\n", index);
enc_info = &BondInfoInFlash[index].peerEncKey.enc_info;
id_info = &BondInfoInFlash[index].peerIdKey.id_info;
enc_info = &BondInfoInFlash[index].ownEncKey.enc_info;
id_info = &BondInfoInFlash[index].ownIdKey.id_info;
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/modules/bluetooth/hal/nrf52/ble_comm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ typedef struct
{
BLE_GapConnHandle connHandle;
BLE_GapBondInfo bondInfo;
//ble_gap_id_key_t ownIdKey;
//ble_gap_enc_key_t ownEncKey;
ble_gap_id_key_t ownIdKey;
ble_gap_enc_key_t ownEncKey;
ble_gap_id_key_t peerIdKey;
ble_gap_enc_key_t peerEncKey;
} bleGapWrapperBondInfo;
Expand Down
12 changes: 6 additions & 6 deletions sdk/modules/bluetooth/hal/nrf52/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ int BLE_GapExchangePairingFeature(BLE_GapConnHandle connHandle, BLE_GapPairingFe
memset(&secParams,0,sizeof(secParams));
memset(&keysExchanged,0,sizeof(keysExchanged));

//memset(&gapMem.wrapperBondInfo.ownEncKey,0,sizeof(gapMem.wrapperBondInfo.ownEncKey));
//memset(&gapMem.wrapperBondInfo.ownIdKey,0,sizeof(gapMem.wrapperBondInfo.ownIdKey));
memset(&gapMem.wrapperBondInfo.ownEncKey,0,sizeof(gapMem.wrapperBondInfo.ownEncKey));
memset(&gapMem.wrapperBondInfo.ownIdKey,0,sizeof(gapMem.wrapperBondInfo.ownIdKey));
memset(&gapMem.wrapperBondInfo.peerEncKey,0,sizeof(gapMem.wrapperBondInfo.peerEncKey));
memset(&gapMem.wrapperBondInfo.peerIdKey,0,sizeof(gapMem.wrapperBondInfo.peerIdKey));

Expand All @@ -450,13 +450,13 @@ int BLE_GapExchangePairingFeature(BLE_GapConnHandle connHandle, BLE_GapPairingFe
secParams.mitm = (pairingFeature->authReq & BLE_GAP_AUTH_MITM) >> 1;
secParams.bond = (pairingFeature->authReq & BLE_GAP_AUTH_BOND) >> 0;

//secParams.kdist_own.enc = 1;
//secParams.kdist_own.id = 1;
secParams.kdist_own.enc = 1;
secParams.kdist_own.id = 1;
secParams.kdist_peer.enc = 1;
secParams.kdist_peer.id = 1;

//keysExchanged.keys_own.p_enc_key = &gapMem.wrapperBondInfo.ownEncKey;
//keysExchanged.keys_own.p_id_key = &gapMem.wrapperBondInfo.ownIdKey;
keysExchanged.keys_own.p_enc_key = &gapMem.wrapperBondInfo.ownEncKey;
keysExchanged.keys_own.p_id_key = &gapMem.wrapperBondInfo.ownIdKey;
keysExchanged.keys_peer.p_enc_key = &gapMem.wrapperBondInfo.peerEncKey;
keysExchanged.keys_peer.p_id_key = &gapMem.wrapperBondInfo.peerIdKey;

Expand Down
2 changes: 1 addition & 1 deletion sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define BSO_FILE_PATH_NAME BSO_FILE_PATH"/%s"
#define BSO_REGISTRY_DB "bso_registry_db"
*/
#define REGDB_VALUE_MAX 60
#define REGDB_VALUE_MAX 112
#define REGDB_KEY_NAME_MAX 4
/*
#define BSO_FILE_NAME_MAX 64
Expand Down

0 comments on commit 38f09fb

Please sign in to comment.