Skip to content

Commit 5fcaeaa

Browse files
joerchannashif
authored andcommitted
Bluetooth: Host: Fix unable to connect using host resolution
Fix issue unable to connect to bonded peer when host resolution is used either because the controller does not support privacy, or the controller resolving list was exceeded. In this case we need to use the RPA from the advertising report directly, there is a small chance of the peer cycling the RPA here, in which case the connection might be unsuccessful. Bug introduced here: 45da629 Fixes: #18306 Signed-off-by: Joakim Andersson <[email protected]>
1 parent 96d56cc commit 5fcaeaa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

subsys/bluetooth/host/hci_core.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ static int hci_le_create_conn(const struct bt_conn *conn)
634634
struct net_buf *buf;
635635
struct bt_hci_cp_le_create_conn *cp;
636636
u8_t own_addr_type;
637+
const bt_addr_le_t *peer_addr;
637638
int err;
638639

639640
if (IS_ENABLED(CONFIG_BT_PRIVACY)) {
@@ -673,7 +674,14 @@ static int hci_le_create_conn(const struct bt_conn *conn)
673674
cp->scan_interval = sys_cpu_to_le16(BT_GAP_SCAN_FAST_INTERVAL);
674675
cp->scan_window = cp->scan_interval;
675676

676-
bt_addr_le_copy(&cp->peer_addr, &conn->le.dst);
677+
peer_addr = &conn->le.dst;
678+
#if defined(CONFIG_BT_SMP)
679+
if (!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size) {
680+
/* Host resolving is used, use the RPA directly. */
681+
peer_addr = &conn->le.resp_addr;
682+
}
683+
#endif
684+
bt_addr_le_copy(&cp->peer_addr, peer_addr);
677685
cp->own_addr_type = own_addr_type;
678686
cp->conn_interval_min = sys_cpu_to_le16(conn->le.interval_min);
679687
cp->conn_interval_max = sys_cpu_to_le16(conn->le.interval_max);
@@ -1406,6 +1414,7 @@ static void check_pending_conn(const bt_addr_le_t *id_addr,
14061414
goto failed;
14071415
}
14081416

1417+
bt_addr_le_copy(&conn->le.resp_addr, addr);
14091418
if (hci_le_create_conn(conn)) {
14101419
goto failed;
14111420
}

0 commit comments

Comments
 (0)