Skip to content

Commit 7a28e07

Browse files
committed
fix bonding with public/static address
1 parent 81a305e commit 7a28e07

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

libraries/Bluefruit52Lib/src/BLECharacteristic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
531531
{
532532
LOG_LV2("GATTS", "attr's value, uuid = 0x%04X, len = %d", request->uuid.uuid, request->len);
533533
LOG_LV2_BUFFER(NULL, request->data, request->len);
534+
LOG_LV2(NULL, "\r\n");
534535

535536
if (_wr_cb)
536537
{

libraries/Bluefruit52Lib/src/BLESecurity.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,13 @@ void BLESecurity::_eventHandler(ble_evt_t* evt)
360360
// Pairing succeeded --> save encryption keys ( Bonding )
361361
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
362362
{
363+
if (!status->kdist_peer.id)
364+
{
365+
// Peer does not provide IRK, it is possible that device uses Public/Static address which
366+
// IRK is not needed. We will use the connect address instead
367+
_bond_keys.peer_id.id_addr_info = conn->getPeerAddr();
368+
}
369+
363370
conn->saveBondKey(&_bond_keys);
364371
}
365372

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,14 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
784784
_setConnLed(true);
785785

786786
ble_gap_evt_connected_t const * para = &evt->evt.gap_evt.params.connected;
787+
ble_gap_addr_t const* peer_addr = &para->peer_addr;
787788

788-
LOG_LV1("GAP", "Conn Interval= %.2f ms, Latency = %d, Supervisor Timeout = %d ms",
789+
(void) peer_addr;
790+
791+
LOG_LV2("GAP", "MAC = %02X:%02X:%02X:%02X:%02X:%02X, Type = %d, Resolved = %d",
792+
peer_addr->addr[5], peer_addr->addr[4], peer_addr->addr[3], peer_addr->addr[2], peer_addr->addr[1], peer_addr->addr[0],
793+
peer_addr->addr_type, peer_addr->addr_id_peer);
794+
LOG_LV2("GAP", "Conn Interval = %.2f ms, Latency = %d, Supervisor Timeout = %d ms",
789795
para->conn_params.max_conn_interval*1.25f, para->conn_params.slave_latency, 10*para->conn_params.conn_sup_timeout);
790796

791797
if ( _connection[conn_hdl] )

0 commit comments

Comments
 (0)