Skip to content

Commit 0ee2124

Browse files
committed
clean up BLEConnection
1 parent 1a94150 commit 0ee2124

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

libraries/Bluefruit52Lib/src/BLEConnection.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,28 +232,21 @@ bool BLEConnection::loadCccd(void)
232232
return bond_load_cccd(_role, _conn_hdl, &_bond_id_addr);
233233
}
234234

235-
bool BLEConnection::_saveLongTermKey(bond_keys_t const* ltkey)
235+
bool BLEConnection::saveLongTermKey(bond_keys_t const* ltkey)
236236
{
237237
bond_save_keys(_role, _conn_hdl, ltkey);
238238
_bond_id_addr = ltkey->peer_id.id_addr_info;
239239
_paired = true; // paired with new device
240240
return true;
241241
}
242242

243-
bool BLEConnection::_loadLongTermKey(bond_keys_t* ltkey)
243+
bool BLEConnection::loadLongTermKey(bond_keys_t* ltkey)
244244
{
245245
VERIFY( bond_load_keys(_role, &_peer_addr, ltkey) );
246246
_bond_id_addr = ltkey->peer_id.id_addr_info;
247247
return true;
248248
}
249249

250-
bool BLEConnection::loadKeys(bond_keys_t* bkeys)
251-
{
252-
return false;
253-
// FIXME dfu key sharing later
254-
//return bond_load_keys(_role, _ediv, bkeys);
255-
}
256-
257250
bool BLEConnection::requestPairing(void)
258251
{
259252
// skip if already paired
@@ -268,7 +261,7 @@ bool BLEConnection::requestPairing(void)
268261
bond_keys_t ltkeys;
269262
uint32_t err;
270263

271-
if ( _loadLongTermKey(&ltkeys) )
264+
if ( loadLongTermKey(&ltkeys) )
272265
{
273266
// We already bonded with this peer previously
274267
// Encrypt the connection using stored Longterm Key

libraries/Bluefruit52Lib/src/BLEConnection.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,17 @@ class BLEConnection
103103
bool getWriteCmdPacket(void);
104104
bool waitForIndicateConfirm(void);
105105

106+
bool saveLongTermKey(bond_keys_t const* ltkey);
107+
bool loadLongTermKey(bond_keys_t* ltkey);
108+
106109
bool saveCccd(void);
107110
bool loadCccd(void);
108111

109-
bool loadKeys(bond_keys_t* bkeys);
110-
111-
112112
/*------------------------------------------------------------------*/
113113
/* INTERNAL USAGE ONLY
114114
* Although declare as public, it is meant to be invoked by internal code.
115115
*------------------------------------------------------------------*/
116116
void _eventHandler(ble_evt_t* evt);
117-
118-
bool _saveLongTermKey(bond_keys_t const* ltkey);
119-
bool _loadLongTermKey(bond_keys_t* ltkey);
120117
};
121118

122119

libraries/Bluefruit52Lib/src/BLEPairing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
329329
LOG_LV2("PAIR", "Ediv = 0x%02X", _bond_keys.own_enc.master_id.ediv);
330330
LOG_LV2_BUFFER("Rand", _bond_keys.own_enc.master_id.rand, 8);
331331

332-
conn->_saveLongTermKey(&_bond_keys);
332+
conn->saveLongTermKey(&_bond_keys);
333333
}
334334

335335
// Invoke callback
@@ -349,7 +349,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
349349

350350
bond_keys_t bkeys;
351351

352-
if ( conn->_loadLongTermKey(&bkeys) )
352+
if ( conn->loadLongTermKey(&bkeys) )
353353
{
354354
sd_ble_gap_sec_info_reply(conn_hdl, &bkeys.own_enc.enc_info, &bkeys.peer_id.id_info, NULL);
355355
} else

libraries/Bluefruit52Lib/src/services/BLEDfu.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +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-
144-
if ( conn->loadKeys(&bkeys) )
143+
if ( conn->loadLongTermKey(&bkeys) )
145144
{
146145
peer_data->addr = bkeys.peer_id.id_addr_info;
147146
peer_data->irk = bkeys.peer_id.id_info;

0 commit comments

Comments
 (0)