Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/releases/release-notes-4.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Deprecated APIs and options
* :c:enum:`bt_hci_bus` was deprecated as it was not used. :c:macro:`BT_DT_HCI_BUS_GET` should be
used instead.

* :kconfig:option:`CONFIG_BT_AUTO_PHY_UPDATE` was deprecated and has been replaced with
role-specific (central vs peripheral) options that allow specifying exactly which PHY is
preferred for automatic updates.

* :kconfig:option:`CONFIG_POSIX_READER_WRITER_LOCKS` is deprecated. Use :kconfig:option:`CONFIG_POSIX_RW_LOCKS` instead.

* :c:func:`bt_ctlr_set_public_addr` is deprecated in favor of using
Expand Down Expand Up @@ -125,6 +129,14 @@ New APIs and options
* :c:struct:`bt_iso_broadcaster_info` now contains a ``big_handle`` and a ``bis_number`` field
* :c:struct:`bt_iso_sync_receiver_info` now contains a ``big_handle`` and a ``bis_number`` field
* :c:struct:`bt_le_ext_adv_info` now contains an ``sid`` field with the Advertising Set ID.
* :kconfig:option:`CONFIG_BT_AUTO_PHY_PERIPHERAL_NONE`
* :kconfig:option:`CONFIG_BT_AUTO_PHY_PERIPHERAL_1M`
* :kconfig:option:`CONFIG_BT_AUTO_PHY_PERIPHERAL_2M`
* :kconfig:option:`CONFIG_BT_AUTO_PHY_PERIPHERAL_CODED`
* :kconfig:option:`CONFIG_BT_AUTO_PHY_CENTRAL_NONE`
* :kconfig:option:`CONFIG_BT_AUTO_PHY_CENTRAL_1M`
* :kconfig:option:`CONFIG_BT_AUTO_PHY_CENTRAL_2M`
* :kconfig:option:`CONFIG_BT_AUTO_PHY_CENTRAL_CODED`

* CPUFreq

Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/central_hr/overlay-phy_coded.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CONFIG_BT_EXT_ADV=y
CONFIG_BT_CTLR_PHY_CODED=y

# Disable auto PHY update, to switch to 2M PHY
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y

# Increase Scan Data Length, as Complete Local Name is placed in the
# AUX_ADV_IND PDU compared to when it is placed in ADV_SCAN_IND PDU in the case
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/central_hr/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ tests:
- nrf5340dk/nrf5340/cpuapp
extra_args:
- CONFIG_BT_EXT_ADV=y
- CONFIG_BT_AUTO_PHY_UPDATE=n
- CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
tags: bluetooth
sysbuild: true
2 changes: 1 addition & 1 deletion samples/bluetooth/central_multilink/prj.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_PRIVACY=y

CONFIG_BT_MAX_CONN=62
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DYNAMIC_DB=y
CONFIG_BT_ATT_PREPARE_COUNT=3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_CHANNEL_SOUNDING=y

Expand Down
3 changes: 0 additions & 3 deletions samples/bluetooth/peripheral_hr/overlay-phy_coded.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ CONFIG_BT_EXT_ADV=y
# Enable Coded PHY support
CONFIG_BT_CTLR_PHY_CODED=y

# Disable auto PHY update, to switch to 2M PHY
CONFIG_BT_AUTO_PHY_UPDATE=n

# Increase Advertising Data Length, as Complete Local Name too needs to be
# placed in the AUX_ADV_IND PDU compared to when it is placed in ADV_SCAN_IND
# PDU in the case of legacy advertising.
Expand Down
1 change: 0 additions & 1 deletion samples/bluetooth/peripheral_hr/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ tests:
- nrf5340dk/nrf5340/cpuapp
extra_args:
- CONFIG_BT_EXT_ADV=y
- CONFIG_BT_AUTO_PHY_UPDATE=n
tags: bluetooth
sysbuild: true
sample.bluetooth.peripheral_hr_rv32m1_vega_openisa_rv32m1_ri5cy:
Expand Down
1 change: 0 additions & 1 deletion samples/bluetooth/peripheral_identity/prj.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_PRIVACY=y

CONFIG_BT_DEVICE_NAME="Zephyr Peripheral"
Expand Down
4 changes: 3 additions & 1 deletion subsys/bluetooth/common/hci_common_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

/* Auto initiated additional HCI command buffers enqueued in the Host */
#define BT_BUF_CMD_TX_REMOTE_VERSION COND_CODE_1(CONFIG_BT_REMOTE_VERSION, (1), (0))
#define BT_BUF_CMD_TX_AUTO_PHY_UPDATE COND_CODE_1(CONFIG_BT_AUTO_PHY_UPDATE, (1), (0))
#define BT_BUF_CMD_TX_AUTO_PHY_UPDATE (IS_ENABLED(CONFIG_BT_PHY_UPDATE) && \
(!IS_ENABLED(CONFIG_BT_AUTO_PHY_PERIPHERAL_NONE) || \
!IS_ENABLED(CONFIG_BT_AUTO_PHY_CENTRAL_NONE)))
#define BT_BUF_CMD_TX_AUTO_DATA_LEN_UPDATE COND_CODE_1(CONFIG_BT_AUTO_DATA_LEN_UPDATE, (1), (0))

#else /* CONFIG_BT_HCI_RAW */
Expand Down
59 changes: 51 additions & 8 deletions subsys/bluetooth/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,68 @@ config BT_CONN_CHECK_NULL_BEFORE_CREATE
dereferencing, the connection object stays alive which can lead to an
unpredictable behavior.

if BT_PHY_UPDATE

config BT_USER_PHY_UPDATE
bool "User control of PHY Update Procedure"
depends on BT_PHY_UPDATE
help
Enable application access to initiate the PHY Update Procedure.
The application can also register a callback to be notified about PHY
changes on the connection. The current PHY info is available in the
connection info.

config BT_AUTO_PHY_UPDATE
bool "Auto-initiate PHY Update Procedure"
depends on BT_PHY_UPDATE
default y if !BT_USER_PHY_UPDATE
bool "Auto-initiate PHY Update Procedure [DEPRECATED]"
select DEPRECATED
help
Initiate PHY Update Procedure on connection establishment.
Initiate PHY Update Procedure on connection establishment. This will attempt
to update the connection to use 2M PHY, however it doesn't actually guarantee
that this is what will be used in the end.

This option has been deprecated in favor of role specific options. The equivalent
behavior can be accomplished by enabling BT_AUTO_PHY_PERIPHERAL_2M and
BT_AUTO_PHY_CENTRAL_2M.

choice
prompt "Auto PHY update for peripheral role"
depends on BT_PERIPHERAL
default BT_AUTO_PHY_PERIPHERAL_2M if BT_AUTO_PHY_UPDATE
default BT_AUTO_PHY_PERIPHERAL_NONE

config BT_AUTO_PHY_PERIPHERAL_NONE
bool "No PHY preference"

config BT_AUTO_PHY_PERIPHERAL_1M
bool "1M PHY"

config BT_AUTO_PHY_PERIPHERAL_2M
bool "2M PHY"

config BT_AUTO_PHY_PERIPHERAL_CODED
bool "Coded PHY"

endchoice # BT_AUTO_PHY_PERIPHERAL

choice
prompt "Auto PHY update for central role"
depends on BT_CENTRAL
default BT_AUTO_PHY_CENTRAL_2M

config BT_AUTO_PHY_CENTRAL_NONE
bool "No PHY preference"

config BT_AUTO_PHY_CENTRAL_1M
bool "1M PHY"

config BT_AUTO_PHY_CENTRAL_2M
bool "2M PHY"

config BT_AUTO_PHY_CENTRAL_CODED
bool "Coded PHY"

endchoice # BT_AUTO_PHY_CENTRAL

Disable this if you want the PHY Update Procedure feature supported
but want to rely on the remote device to initiate the procedure at its
discretion or want to initiate manually.
endif # BT_PHY_UPDATE

config BT_USER_DATA_LEN_UPDATE
bool "User control of Data Length Update Procedure"
Expand Down
94 changes: 77 additions & 17 deletions subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,26 +1681,85 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
/* Group Connected BT_CONN only in this */
#if defined(CONFIG_BT_CONN)

/* We don't want the application to get a PHY update callback upon connection
* establishment on 2M PHY. Therefore we must prevent issuing LE Set PHY
* in this scenario.
*
* It is ifdef'd because the struct fields don't exist in some configs.
*/
static bool uses_symmetric_2mbit_phy(struct bt_conn *conn)
#if defined(CONFIG_BT_AUTO_PHY_PERIPHERAL_1M)
#define AUTO_PHY_PERIPHERAL BT_HCI_LE_PHY_1M
#define AUTO_PHY_PERIPHERAL_PREF BT_HCI_LE_PHY_PREFER_1M
#define AUTO_PHY_PERIPHERAL_SUPPORTED(_feat) (true)
#elif defined(CONFIG_BT_AUTO_PHY_PERIPHERAL_2M)
#define AUTO_PHY_PERIPHERAL BT_HCI_LE_PHY_2M
#define AUTO_PHY_PERIPHERAL_PREF BT_HCI_LE_PHY_PREFER_2M
#define AUTO_PHY_PERIPHERAL_SUPPORTED(feat) BT_FEAT_LE_PHY_2M(feat)
#elif defined(CONFIG_BT_AUTO_PHY_PERIPHERAL_CODED)
#define AUTO_PHY_PERIPHERAL BT_HCI_LE_PHY_CODED
#define AUTO_PHY_PERIPHERAL_PREF BT_HCI_LE_PHY_PREFER_CODED
#define AUTO_PHY_PERIPHERAL_SUPPORTED(feat) BT_FEAT_LE_PHY_CODED(feat)
#else
/* Dummy values when there's no preference */
#define AUTO_PHY_PERIPHERAL (0)
#define AUTO_PHY_PERIPHERAL_PREF (0)
#define AUTO_PHY_PERIPHERAL_SUPPORTED(_feat) (false)
#endif

#if defined(CONFIG_BT_AUTO_PHY_CENTRAL_1M)
#define AUTO_PHY_CENTRAL BT_HCI_LE_PHY_1M
#define AUTO_PHY_CENTRAL_PREF BT_HCI_LE_PHY_PREFER_1M
#define AUTO_PHY_CENTRAL_SUPPORTED(_feat) (true)
#elif defined(CONFIG_BT_AUTO_PHY_CENTRAL_2M)
#define AUTO_PHY_CENTRAL BT_HCI_LE_PHY_2M
#define AUTO_PHY_CENTRAL_PREF BT_HCI_LE_PHY_PREFER_2M
#define AUTO_PHY_CENTRAL_SUPPORTED(feat) BT_FEAT_LE_PHY_2M(feat)
#elif defined(CONFIG_BT_AUTO_PHY_CENTRAL_CODED)
#define AUTO_PHY_CENTRAL BT_HCI_LE_PHY_CODED
#define AUTO_PHY_CENTRAL_PREF BT_HCI_LE_PHY_PREFER_CODED
#define AUTO_PHY_CENTRAL_SUPPORTED(feat) BT_FEAT_LE_PHY_CODED(feat)
#else
/* Dummy values when there's no preference */
#define AUTO_PHY_CENTRAL (0)
#define AUTO_PHY_CENTRAL_PREF (0)
#define AUTO_PHY_CENTRAL_SUPPORTED(_feat) (false)
#endif

static int do_phy_update(struct bt_conn *conn)
{
uint8_t phy, pref;
bool supported;

switch (conn->role) {
#if !defined(CONFIG_BT_AUTO_PHY_CENTRAL_NONE)
case BT_HCI_ROLE_CENTRAL:
phy = AUTO_PHY_CENTRAL;
pref = AUTO_PHY_CENTRAL_PREF;
supported = AUTO_PHY_CENTRAL_SUPPORTED(bt_dev.le.features);
break;
#endif
#if !defined(CONFIG_BT_AUTO_PHY_PERIPHERAL_NONE)
case BT_HCI_ROLE_PERIPHERAL:
phy = AUTO_PHY_PERIPHERAL;
pref = AUTO_PHY_PERIPHERAL_PREF;
supported = AUTO_PHY_PERIPHERAL_SUPPORTED(bt_dev.le.features);
break;
#endif
default:
return 0;
}

if (!supported) {
LOG_WRN("PHY 0x%02x not supported", phy);
return 0;
}

#if defined(CONFIG_BT_USER_PHY_UPDATE)
if (IS_ENABLED(CONFIG_BT_EXT_ADV)) {
if (conn->le.phy.tx_phy == BT_HCI_LE_PHY_2M &&
conn->le.phy.rx_phy == BT_HCI_LE_PHY_2M) {
return true;
/* If the current PHYs are already the preferred PHYs, no need to issue
* a PHY update procedure.
*/
if (conn->le.phy.tx_phy == phy && conn->le.phy.rx_phy == phy) {
return 0;
}
}
#else
ARG_UNUSED(conn);
#endif

return false;
return bt_le_set_phy(conn, 0U, pref, pref, BT_HCI_LE_PHY_CODED_ANY);
}

static bool can_initiate_feature_exchange(struct bt_conn *conn)
Expand Down Expand Up @@ -1767,13 +1826,14 @@ static void perform_auto_initiated_procedures(struct bt_conn *conn, void *unused
}
}

if (IS_ENABLED(CONFIG_BT_AUTO_PHY_UPDATE) && BT_FEAT_LE_PHY_2M(bt_dev.le.features) &&
!uses_symmetric_2mbit_phy(conn)) {
err = bt_le_set_phy(conn, 0U, BT_HCI_LE_PHY_PREFER_2M, BT_HCI_LE_PHY_PREFER_2M,
BT_HCI_LE_PHY_CODED_ANY);
if (IS_ENABLED(CONFIG_BT_PHY_UPDATE) &&
(!IS_ENABLED(CONFIG_BT_AUTO_PHY_CENTRAL_NONE) ||
!IS_ENABLED(CONFIG_BT_AUTO_PHY_PERIPHERAL_NONE))) {
err = do_phy_update(conn);
if (err) {
LOG_ERR("Failed LE Set PHY (%d)", err);
}

if (conn->state != BT_CONN_CONNECTED) {
return;
}
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/audio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=y

CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_AUTO_PHY_UPDATE=y

CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
# Set preferred values based on BT_BAP_CONN_PARAM_RELAXED
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/log.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=y

CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_AUTO_PHY_UPDATE=y

CONFIG_BT_ISO_BROADCASTER=y
CONFIG_BT_ISO_SYNC_RECEIVER=y
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ CONFIG_BT_AUTO_DATA_LEN_UPDATE=y
CONFIG_BT_EAD=y

CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_AUTO_PHY_UPDATE=y

CONFIG_BT_ISO_BROADCASTER=y
CONFIG_BT_ISO_SYNC_RECEIVER=y
Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/att/pipeline/dut/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CONFIG_BT_USER_DATA_LEN_UPDATE=y

# Disable auto-initiated procedures so they don't
# mess with the test's execution.
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/att/sequential/dut/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CONFIG_BT_USER_DATA_LEN_UPDATE=y

# Disable auto-initiated procedures so they don't
# mess with the test's execution.
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/gatt/device_name/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CONFIG_BT_DEVICE_NAME_GATT_WRITABLE=y
# Dependency of testlib/adv and testlib/scan.
CONFIG_BT_EXT_ADV=y

CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_GATT_AUTO_UPDATE_MTU=n
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/gatt/notify_stress/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_L2CAP_ECRED=y
CONFIG_BT_EATT=y

CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n

CONFIG_ASSERT=y
Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/gatt/settings/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CONFIG_LOG=y
CONFIG_ASSERT=y
CONFIG_BT_TESTING=y

CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/gatt/settings_clear/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CONFIG_BT_DEVICE_NAME="GATT settings clear"
# Dependency of testlib/adv and testlib/scan.
CONFIG_BT_EXT_ADV=y

CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/l2cap/credits/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

# Disable auto-initiated procedures so they don't
# mess with the test's execution.
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/host/l2cap/credits_seg_recv/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

# Disable auto-initiated procedures so they don't
# mess with the test's execution.
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_AUTO_PHY_CENTRAL_NONE=y
CONFIG_BT_AUTO_DATA_LEN_UPDATE=n
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

Expand Down
Loading
Loading