bond clean up
This commit is contained in:
1 parent
eb8b20649c
commit
d53d59e522
2 files changed
+9
-7
No files matched your search
@@ -181,7 +181,7 @@ bool BLEGap::requestPairing(uint16_t conn_hdl)
|
||||
|
||||
xSemaphoreTake(peer->pair_sem, portMAX_DELAY);
|
||||
|
||||
// Failed to pair using central stored keys, this happens when
|
||||
// Failed to pair using central stored keys, this happens when
|
||||
// Prph delete bonds while we did not --> let's remove the obsolete keyfile and move on
|
||||
if ( !peer->paired && (cntr_ediv != 0xffff) )
|
||||
{
|
||||
@@ -383,9 +383,12 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
|
||||
// Occurs if bonded + reconnection, or we initiate the pairing process
|
||||
if ( !( conn_sec->sec_mode.sm == 1 && conn_sec->sec_mode.lv == 1) )
|
||||
{
|
||||
// Previously bonded --> secure by re-connection process --> Load & Set Sys Attr (Apply Service Context)
|
||||
// Else Init Sys Attr
|
||||
bond_load_cccd(peer->role, conn_hdl, peer->ediv);
|
||||
// Previously bonded --> secure by re-connection process --> Load & Set SysAttr (Apply Service Context)
|
||||
// Else Init SysAttr (first bonded)
|
||||
if ( !bond_load_cccd(peer->role, conn_hdl, peer->ediv) )
|
||||
{
|
||||
sd_ble_gatts_sys_attr_set(conn_hdl, NULL, 0, 0);
|
||||
}
|
||||
|
||||
peer->paired = true;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ bool bond_save_cccd (uint8_t role, uint16_t conn_hdl, uint16_t ediv)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bond_load_cccd(uint8_t role, uint16_t cond_hdl, uint16_t ediv)
|
||||
bool bond_load_cccd(uint8_t role, uint16_t conn_hdl, uint16_t ediv)
|
||||
{
|
||||
bool loaded = false;
|
||||
|
||||
@@ -219,7 +219,7 @@ bool bond_load_cccd(uint8_t role, uint16_t cond_hdl, uint16_t ediv)
|
||||
|
||||
file.read(sys_attr, len);
|
||||
|
||||
if ( ERROR_NONE == sd_ble_gatts_sys_attr_set(cond_hdl, sys_attr, len, SVC_CONTEXT_FLAG) )
|
||||
if ( ERROR_NONE == sd_ble_gatts_sys_attr_set(conn_hdl, sys_attr, len, SVC_CONTEXT_FLAG) )
|
||||
{
|
||||
loaded = true;
|
||||
BOND_LOG("Loaded CCCD from file %s ( offset = %d, len = %d bytes )", filename, file.size() - (len + 1), len);
|
||||
@@ -233,7 +233,6 @@ bool bond_load_cccd(uint8_t role, uint16_t cond_hdl, uint16_t ediv)
|
||||
if ( !loaded )
|
||||
{
|
||||
LOG_LV1("BOND", "CCCD setting not found");
|
||||
sd_ble_gatts_sys_attr_set(cond_hdl, NULL, 0, 0);
|
||||
}
|
||||
|
||||
return loaded;
|
||||
|
||||
Reference in new issue
Block a user