Skip to content

Commit 3f17bdf

Browse files
jori-nordicnashif
authored andcommitted
Bluetooth: Host: refactor 2M PHY auto-update
The code was a bit hard to read. From what I understood, the intent is to not send the PHY update if we are already on 2M symmetric. Signed-off-by: Jonathan Rico <[email protected]>
1 parent d65fdde commit 3f17bdf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,24 +1660,25 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
16601660

16611661
/* Group Connected BT_CONN only in this */
16621662
#if defined(CONFIG_BT_CONN)
1663+
16631664
/* We don't want the application to get a PHY update callback upon connection
16641665
* establishment on 2M PHY. Therefore we must prevent issuing LE Set PHY
16651666
* in this scenario.
1667+
*
1668+
* It is ifdef'd because the struct fields don't exist in some configs.
16661669
*/
1667-
static bool skip_auto_phy_update_on_conn_establishment(struct bt_conn *conn)
1670+
static bool uses_symmetric_2mbit_phy(struct bt_conn *conn)
16681671
{
16691672
#if defined(CONFIG_BT_USER_PHY_UPDATE)
1670-
if (IS_ENABLED(CONFIG_BT_AUTO_PHY_UPDATE) &&
1671-
IS_ENABLED(CONFIG_BT_EXT_ADV) &&
1672-
BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features)) {
1673+
if (IS_ENABLED(CONFIG_BT_EXT_ADV)) {
16731674
if (conn->le.phy.tx_phy == BT_HCI_LE_PHY_2M &&
16741675
conn->le.phy.rx_phy == BT_HCI_LE_PHY_2M) {
16751676
return true;
16761677
}
16771678
}
16781679
#else
16791680
ARG_UNUSED(conn);
1680-
#endif /* defined(CONFIG_BT_USER_PHY_UPDATE) */
1681+
#endif
16811682

16821683
return false;
16831684
}
@@ -1728,7 +1729,7 @@ static void perform_auto_initiated_procedures(struct bt_conn *conn, void *unused
17281729

17291730
if (IS_ENABLED(CONFIG_BT_AUTO_PHY_UPDATE) &&
17301731
BT_FEAT_LE_PHY_2M(bt_dev.le.features) &&
1731-
!skip_auto_phy_update_on_conn_establishment(conn)) {
1732+
!uses_symmetric_2mbit_phy(conn)) {
17321733
err = bt_le_set_phy(conn, 0U, BT_HCI_LE_PHY_PREFER_2M,
17331734
BT_HCI_LE_PHY_PREFER_2M,
17341735
BT_HCI_LE_PHY_CODED_ANY);

0 commit comments

Comments
 (0)