Skip to content

Commit d0e5946

Browse files
committed
rename save/load BondKey
1 parent 1210b3e commit d0e5946

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

libraries/Bluefruit52Lib/src/BLEConnection.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ bool BLEConnection::bonded(void)
9393
return _bonded;
9494
}
9595

96+
bool BLEConnection::secured(void)
97+
{
98+
return _secured;
99+
}
100+
96101
uint8_t BLEConnection::getRole (void)
97102
{
98103
return _role;
@@ -237,16 +242,15 @@ bool BLEConnection::loadCccd(void)
237242
return bond_load_cccd(_role, _conn_hdl, &_bond_id_addr);
238243
}
239244

240-
bool BLEConnection::saveLongTermKey(bond_keys_t const* ltkey)
245+
bool BLEConnection::saveBondKey(bond_keys_t const* ltkey)
241246
{
242247
bond_save_keys(_role, _conn_hdl, ltkey);
243248
_bond_id_addr = ltkey->peer_id.id_addr_info;
244-
_secured = true; // paired with new device
245249
_bonded = true;
246250
return true;
247251
}
248252

249-
bool BLEConnection::loadLongTermKey(bond_keys_t* ltkey)
253+
bool BLEConnection::loadBondKey(bond_keys_t* ltkey)
250254
{
251255
_bonded = bond_load_keys(_role, &_peer_addr, ltkey);
252256
VERIFY(_bonded);
@@ -267,7 +271,7 @@ bool BLEConnection::requestPairing(void)
267271

268272
// bond_keys_t ltkey;
269273
//
270-
// if ( loadLongTermKey(&ltkey) ) // central only
274+
// if ( loadBondKey(&ltkey) ) // central only
271275
// {
272276
// // We already bonded with this peer previously
273277
// // Encrypt the connection using stored Longterm Key

libraries/Bluefruit52Lib/src/BLEConnection.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ class BLEConnection
7474

7575
uint16_t handle(void);
7676
bool connected(void);
77-
bool paired(void);
77+
bool paired(void); // todo removed
7878
bool bonded(void);
79+
bool secured(void);
7980

8081
uint8_t getRole(void);
8182
uint16_t getMtu (void);
@@ -105,8 +106,9 @@ class BLEConnection
105106
bool getWriteCmdPacket(void);
106107
bool waitForIndicateConfirm(void);
107108

108-
bool saveLongTermKey(bond_keys_t const* ltkey);
109-
bool loadLongTermKey(bond_keys_t* ltkey);
109+
bool saveBondKey(bond_keys_t const* ltkey);
110+
bool loadBondKey(bond_keys_t* ltkey);
111+
bool removeBondKey(void);
110112

111113
bool saveCccd(void);
112114
bool loadCccd(void);

libraries/Bluefruit52Lib/src/BLEPairing.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
349349
// Pairing succeeded --> save encryption keys ( Bonding )
350350
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
351351
{
352-
conn->saveLongTermKey(&_bond_keys);
352+
conn->saveBondKey(&_bond_keys);
353353
}
354354

355355
// Invoke callback
@@ -364,17 +364,19 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
364364
// - Else return NULL --> Initiate key exchange
365365
ble_gap_evt_sec_info_request_t* sec_info = (ble_gap_evt_sec_info_request_t*) &evt->evt.gap_evt.params.sec_info_request;
366366

367-
LOG_LV2("PAIR", "Addr ID = %d, Addr Type = 0x%02X", sec_info->peer_addr.addr_id_peer, sec_info->peer_addr.addr_type);
368-
LOG_LV2_BUFFER("Address", sec_info->peer_addr.addr, 6);
367+
LOG_LV2("PAIR", "Address: ID = %d, Type = 0x%02X, %02X:%02X:%02X:%02X:%02X:%02X",
368+
sec_info->peer_addr.addr_id_peer, sec_info->peer_addr.addr_type,
369+
sec_info->peer_addr.addr[0], sec_info->peer_addr.addr[1], sec_info->peer_addr.addr[2],
370+
sec_info->peer_addr.addr[3], sec_info->peer_addr.addr[4], sec_info->peer_addr.addr[5]);
369371

370372
bond_keys_t bkeys;
371373

372-
if ( conn->loadLongTermKey(&bkeys) )
374+
if ( conn->loadBondKey(&bkeys) )
373375
{
374-
sd_ble_gap_sec_info_reply(conn_hdl, &bkeys.own_enc.enc_info, &bkeys.peer_id.id_info, NULL);
376+
VERIFY_STATUS(sd_ble_gap_sec_info_reply(conn_hdl, &bkeys.own_enc.enc_info, &bkeys.peer_id.id_info, NULL), );
375377
} else
376378
{
377-
sd_ble_gap_sec_info_reply(conn_hdl, NULL, NULL, NULL);
379+
VERIFY_STATUS(sd_ble_gap_sec_info_reply(conn_hdl, NULL, NULL, NULL), );
378380
}
379381
}
380382
break;

libraries/Bluefruit52Lib/src/services/BLEDfu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void bledfu_control_wr_authorize_cb(uint16_t conn_hdl, BLECharacteristic*
140140
if ( conn->paired() )
141141
{
142142
bond_keys_t bkeys;
143-
if ( conn->loadLongTermKey(&bkeys) )
143+
if ( conn->loadBondKey(&bkeys) )
144144
{
145145
peer_data->addr = bkeys.peer_id.id_addr_info;
146146
peer_data->irk = bkeys.peer_id.id_info;

0 commit comments

Comments
 (0)