Bluetooth: Fix auto PHY update on connection
Since the PHY update complete event can be generated due to the procedure being initiated by the peer, use a flag to differentiate between local auto update initiated on connection complete versus peer initiated anytime in the connection. This is necessary to avoid repeated initiation of auto-update procedures intended only to be issued on connection complete. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
ce881890e3
commit
ed187ebccd
2 changed files with 11 additions and 4 deletions
|
@ -24,6 +24,7 @@ enum {
|
|||
BT_CONN_BR_NOBOND, /* SSP no bond pairing tracker */
|
||||
BT_CONN_BR_PAIRING_INITIATOR, /* local host starts authentication */
|
||||
BT_CONN_CLEANUP, /* Disconnected, pending cleanup */
|
||||
BT_CONN_AUTO_PHY_UPDATE, /* Auto-update PHY */
|
||||
|
||||
/* Total number of flags - must be at the end of the enum */
|
||||
BT_CONN_NUM_FLAGS,
|
||||
|
|
|
@ -802,10 +802,10 @@ static void le_conn_complete(struct net_buf *buf)
|
|||
}
|
||||
}
|
||||
|
||||
if (BT_FEAT_LE_PHY_2M(bt_dev.le.features) ||
|
||||
BT_FEAT_LE_PHY_CODED(bt_dev.le.features)) {
|
||||
if (BT_FEAT_LE_PHY_2M(bt_dev.le.features)) {
|
||||
err = hci_le_set_phy(conn);
|
||||
if (!err) {
|
||||
atomic_set_bit(conn->flags, BT_CONN_AUTO_PHY_UPDATE);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -834,12 +834,13 @@ static void le_remote_feat_complete(struct net_buf *buf)
|
|||
sizeof(conn->le.features));
|
||||
}
|
||||
|
||||
if (BT_FEAT_LE_PHY_2M(bt_dev.le.features) ||
|
||||
BT_FEAT_LE_PHY_CODED(bt_dev.le.features)) {
|
||||
if (BT_FEAT_LE_PHY_2M(bt_dev.le.features) &&
|
||||
BT_FEAT_LE_PHY_2M(conn->le.features)) {
|
||||
int err;
|
||||
|
||||
err = hci_le_set_phy(conn);
|
||||
if (!err) {
|
||||
atomic_set_bit(conn->flags, BT_CONN_AUTO_PHY_UPDATE);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -864,8 +865,13 @@ static void le_phy_update_complete(struct net_buf *buf)
|
|||
BT_DBG("PHY updated: status: 0x%x, tx: %u, rx: %u",
|
||||
evt->status, evt->tx_phy, evt->rx_phy);
|
||||
|
||||
if (!atomic_test_and_clear_bit(conn->flags, BT_CONN_AUTO_PHY_UPDATE)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
update_conn_param(conn);
|
||||
|
||||
done:
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue