Skip to content

Commit 6c08d64

Browse files
Kamil Gaworanangl
authored andcommitted
[nrf fromlist] bluetooth: host: Fix reading current PHY when using extended advertising
The current PHY is read only when automatic PHY update procedure is enabled, 2M PHY is supported and extended advertising is enabled and this is done after application is notified about connection. This leads to invalid connection info PHY data which always returns 1M PHY because when using extended advertising the connection can be established on different PHY and host does not read this value from the controller in most cases. In order to have a current PHY value updated we need to read it in connection complete event before the user application is notified about connection. Upstream PR: zephyrproject-rtos/zephyr#46113 Signed-off-by: Kamil Gawor <[email protected]>
1 parent 3c8a7f7 commit 6c08d64

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

subsys/bluetooth/host/hci_core.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -967,16 +967,9 @@ static bool skip_auto_phy_update_on_conn_establishment(struct bt_conn *conn)
967967
if (IS_ENABLED(CONFIG_BT_AUTO_PHY_UPDATE) &&
968968
IS_ENABLED(CONFIG_BT_EXT_ADV) &&
969969
BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features)) {
970-
int err;
971-
972-
err = hci_le_read_phy(conn);
973-
if (err) {
974-
BT_WARN("Failed to read PHY (%d)", err);
975-
} else {
976-
if (conn->le.phy.tx_phy == BT_HCI_LE_PHY_2M &&
977-
conn->le.phy.rx_phy == BT_HCI_LE_PHY_2M) {
978-
return true;
979-
}
970+
if (conn->le.phy.tx_phy == BT_HCI_LE_PHY_2M &&
971+
conn->le.phy.rx_phy == BT_HCI_LE_PHY_2M) {
972+
return true;
980973
}
981974
}
982975
#else
@@ -1332,6 +1325,18 @@ void bt_hci_le_enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt)
13321325
}
13331326
}
13341327

1328+
#if defined(CONFIG_BT_USER_PHY_UPDATE)
1329+
if (IS_ENABLED(CONFIG_BT_EXT_ADV) &&
1330+
BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features)) {
1331+
int err;
1332+
1333+
err = hci_le_read_phy(conn);
1334+
if (err) {
1335+
BT_WARN("Failed to read PHY (%d)", err);
1336+
}
1337+
}
1338+
#endif /* defined(CONFIG_BT_USER_PHY_UPDATE) */
1339+
13351340
bt_conn_set_state(conn, BT_CONN_CONNECTED);
13361341

13371342
if (is_disconnected) {

0 commit comments

Comments
 (0)