Skip to content

Commit ddded48

Browse files
committed
fix central reconnection with LESC
1 parent a5fea56 commit ddded48

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

libraries/Bluefruit52Lib/src/BLEPairing.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ bool BLEPairing::_authenticate(uint16_t conn_hdl)
209209

210210
bool BLEPairing::_encrypt(uint16_t conn_hdl, bond_keys_t const* ltkey)
211211
{
212-
VERIFY_STATUS(sd_ble_gap_encrypt(conn_hdl, &ltkey->peer_enc.master_id, &ltkey->peer_enc.enc_info), false);
212+
// LESC use own key, Legacy use peer key
213+
ble_gap_enc_key_t const* enc_key = ltkey->own_enc.enc_info.lesc ? &ltkey->own_enc : &ltkey->peer_enc;
214+
VERIFY_STATUS(sd_ble_gap_encrypt(conn_hdl, &enc_key->master_id, &enc_key->enc_info), false);
213215
return true;
214216
}
215217

@@ -347,9 +349,6 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
347349
// Pairing succeeded --> save encryption keys ( Bonding )
348350
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
349351
{
350-
LOG_LV2("PAIR", "Ediv = 0x%02X", _bond_keys.own_enc.master_id.ediv);
351-
LOG_LV2_BUFFER("Rand", _bond_keys.own_enc.master_id.rand, 8);
352-
353352
conn->saveLongTermKey(&_bond_keys);
354353
}
355354

0 commit comments

Comments
 (0)