clean up BLEConnection
This commit is contained in:
1 parent
1a9415005b
commit
0ee2124e06
4 files changed
+9
-20
No files matched your search
@@ -232,7 +232,7 @@ bool BLEConnection::loadCccd(void)
|
||||
return bond_load_cccd(_role, _conn_hdl, &_bond_id_addr);
|
||||
}
|
||||
|
||||
bool BLEConnection::_saveLongTermKey(bond_keys_t const* ltkey)
|
||||
bool BLEConnection::saveLongTermKey(bond_keys_t const* ltkey)
|
||||
{
|
||||
bond_save_keys(_role, _conn_hdl, ltkey);
|
||||
_bond_id_addr = ltkey->peer_id.id_addr_info;
|
||||
@@ -240,20 +240,13 @@ bool BLEConnection::_saveLongTermKey(bond_keys_t const* ltkey)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLEConnection::_loadLongTermKey(bond_keys_t* ltkey)
|
||||
bool BLEConnection::loadLongTermKey(bond_keys_t* ltkey)
|
||||
{
|
||||
VERIFY( bond_load_keys(_role, &_peer_addr, ltkey) );
|
||||
_bond_id_addr = ltkey->peer_id.id_addr_info;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLEConnection::loadKeys(bond_keys_t* bkeys)
|
||||
{
|
||||
return false;
|
||||
// FIXME dfu key sharing later
|
||||
//return bond_load_keys(_role, _ediv, bkeys);
|
||||
}
|
||||
|
||||
bool BLEConnection::requestPairing(void)
|
||||
{
|
||||
// skip if already paired
|
||||
@@ -268,7 +261,7 @@ bool BLEConnection::requestPairing(void)
|
||||
bond_keys_t ltkeys;
|
||||
uint32_t err;
|
||||
|
||||
if ( _loadLongTermKey(<keys) )
|
||||
if ( loadLongTermKey(<keys) )
|
||||
{
|
||||
// We already bonded with this peer previously
|
||||
// Encrypt the connection using stored Longterm Key
|
||||
|
||||
@@ -103,20 +103,17 @@ class BLEConnection
|
||||
bool getWriteCmdPacket(void);
|
||||
bool waitForIndicateConfirm(void);
|
||||
|
||||
bool saveLongTermKey(bond_keys_t const* ltkey);
|
||||
bool loadLongTermKey(bond_keys_t* ltkey);
|
||||
|
||||
bool saveCccd(void);
|
||||
bool loadCccd(void);
|
||||
|
||||
bool loadKeys(bond_keys_t* bkeys);
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INTERNAL USAGE ONLY
|
||||
* Although declare as public, it is meant to be invoked by internal code.
|
||||
*------------------------------------------------------------------*/
|
||||
void _eventHandler(ble_evt_t* evt);
|
||||
|
||||
bool _saveLongTermKey(bond_keys_t const* ltkey);
|
||||
bool _loadLongTermKey(bond_keys_t* ltkey);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
|
||||
LOG_LV2("PAIR", "Ediv = 0x%02X", _bond_keys.own_enc.master_id.ediv);
|
||||
LOG_LV2_BUFFER("Rand", _bond_keys.own_enc.master_id.rand, 8);
|
||||
|
||||
conn->_saveLongTermKey(&_bond_keys);
|
||||
conn->saveLongTermKey(&_bond_keys);
|
||||
}
|
||||
|
||||
// Invoke callback
|
||||
@@ -349,7 +349,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
|
||||
|
||||
bond_keys_t bkeys;
|
||||
|
||||
if ( conn->_loadLongTermKey(&bkeys) )
|
||||
if ( conn->loadLongTermKey(&bkeys) )
|
||||
{
|
||||
sd_ble_gap_sec_info_reply(conn_hdl, &bkeys.own_enc.enc_info, &bkeys.peer_id.id_info, NULL);
|
||||
} else
|
||||
|
||||
@@ -140,8 +140,7 @@ static void bledfu_control_wr_authorize_cb(uint16_t conn_hdl, BLECharacteristic*
|
||||
if ( conn->paired() )
|
||||
{
|
||||
bond_keys_t bkeys;
|
||||
|
||||
if ( conn->loadKeys(&bkeys) )
|
||||
if ( conn->loadLongTermKey(&bkeys) )
|
||||
{
|
||||
peer_data->addr = bkeys.peer_id.id_addr_info;
|
||||
peer_data->irk = bkeys.peer_id.id_info;
|
||||
|
||||
Reference in new issue
Block a user