Commit graph

9523 commits

Author SHA1 Message Date
Zihao Gao
a0efdb2112 Bluetooth: AVRCP: Move the handling of transaction labels to the App.
According to AVCTP v1.4: On the controller and the target side,
handling of transaction labels is dependent on the application.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-03-28 16:10:05 +01:00
Zihao Gao
7822bf7628 Bluetooth: AVRCP: Remove AVRCP timeout.
Remove the transaction label mechanism because:
1. Not necessary at stack, typically an application can handle the
timeout mechanism if required (very rarely).
2. It is a burden on memory size to record all pending commands.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-03-28 16:10:05 +01:00
Zihao Gao
3f747839c5 Bluetooth: AVRCP: expose macros to upper layer.
This patch expose BT_AVRCP_COMPANY_ID_SIZE to applications.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-03-28 16:10:05 +01:00
Zihao Gao
a4790aeab8 Bluetooth: AVRCP: use spec defined structures on APIs.
This patch replaced the structures defined by zephyr APIs
by those defined by AVRCP Spec.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-03-28 16:10:05 +01:00
Zihao Gao
6fe6326bea Bluetooth: AVRCP: implementation of Get Capabilities command.
This patch allows the upper layer to acquire the remote AVRCP
capabilities. These capabilities can be further used in register
notifications.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-03-28 16:10:05 +01:00
Emil Gydesen
c6e7420d52 Bluetooth: TBS: Client: Fix sizeof('\0')
sizeof('\0') is misleading as it will return 4 instead of 1,
since it will evaluate to sizeof(0), which returns the size
of the `int` type. Modify the expression to use sizeof(char)
with a comment.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-28 12:20:10 +01:00
Daniel Mangum
87d7fcf6c2 bluetooth: host: fix GATT writable Kconfig descriptions
Fixes typos in the BT_DEVICE_NAME_GATT_WRITABLE_SECURITY and
BT_DEVICE_APPEARANCE_GATT_WRITABLE descriptions.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2025-03-28 08:50:05 +01:00
Ingar Kulbrandstad
db84181c22 Bluetooth: Mesh: Fix proxy after board reboot
When the board has been provisioned and the board is rebooted
it was not possible to connect to the board through the proxy
servcie. This fixes that the Mesh Proxy servive is restarted
after the board is rebooted.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2025-03-27 14:02:12 +01:00
Håvard Reierstad
200628e8d0 Bluetooth: Mesh: Disable prov bearers on link
Previously, PB-GATT unprovisioned advs would continue being sent if a
device is provisioned or in the process of being provisioned (an active
provisioning link) over PB-ADV.

This commit introduces the `link_cancel` callback for the `prov_bearer`
struct. When a provisioning link is established over a prov bearer, all
other (active) prov bearers will be suspended through this callback, and
re-enabled when the link is closed. An exception is made for PB-REMOTE,
which can utilize the other bearers.

The call to `bt_mesh_pb_gatt_srv_disable` in settings.c is removed. This
is called in `mesh_commit`, and is not needed as this is only used
during boot, at which point the Mesh provisioning service has not yet
been enabled/registered, meaning the function does nothing.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2025-03-26 16:19:31 +01:00
Vinayak Kariappa Chettimada
1dfc53fd21 Bluetooth: Controller: Fix ull_hdr_get_cb for Peripheral role
Fix ull_hdr_get_cb() for advanced scheduling to return
ticks_slot for Peripheral role.

Relates to commit d6c3e04eb8 ("Bluetooth: Controller:
Central maximum data PDU size time spacing").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-26 16:19:19 +01:00
Ivan Iushkov
ded9c1f44d bluetooth: CS: add bt_le_cs_get_antenna_path()
added function to calculate antenna path
based on the antenna permutation index and
total number of antenna paths

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2025-03-26 11:32:57 +01:00
Lyle Zhu
22ea55c7a0 Bluetooth: Classic: Move classic functions from conn.c to conn_br.c
Move functions `bt_sco_cleanup()`, `bt_conn_create_br()`,
`bt_hci_connect_br_cancel()`, and `bt_conn_get_dst_br()` from `conn.c`
to `conn_br.c`.

Change the function `bt_hci_connect_br_cancel()` to internal public
function.

Add a header file `conn_br_internal.h`. And declare the function
`bt_hci_connect_br_cancel()` in the header file.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-25 22:15:19 +01:00
Håvard Reierstad
c77587a76b Bluetooth: Host: Clarify use of identity in docs
Clarifies the use of identity in `bluetooth.h` by specifying whether the
documentation refers to the identity address, i. e. the actual address
`bt_addr_le_t`, or the identity handle, i. e. an index corresponding to
a specific identity address.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2025-03-25 22:14:55 +01:00
Troels Nilsson
e486a06f0b Bluetooth: Controller: Remove unneeded members from ull_hdr
Several members of the ull_hdr can be removed, saving 12 bytes
from all ULL instances used (and a bit of code as well)

ticks_active_to_start is always 0 and can be removed completely

ticks_prepare_to_start is always set to
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US), so replace usage
of it by this constant

ticks_preempt_to_start is always set to
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US), so replace
usage of it by this constant

In addition, remove logic handling usage of XON_BITMASK since it
was only used by the long removed legacy LL

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-25 22:13:58 +01:00
Troels Nilsson
a87e8dce7d Bluetooth: Controller: Fix lost_payloads calculation for FT > 1
The lost_payloads calculation in ull_conn_iso_start() could easily
end up negative for CIS with FT > 1; Add a check to avoid this

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-25 22:13:45 +01:00
Aleksandr Khromykh
928208cf36 Bluetooth: Mesh: to not set valid state if mesh is not valid yet
Commit sets valid state when mesh is actualy provisioned.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-03-25 11:00:22 +01:00
Lyle Zhu
b78b855d04 Bluetooth: Classic: L2CAP: Fix building warnings
Use `UINT_TO_POINTER` to convert a number to pointer.
Use `POINTER_TO_UINT` to get a number from a pointer.

Fixes #87527.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-24 19:24:16 +01:00
Ingar Kulbrandstad
a65a16424b Bluetooth: Mesh: Fix proxy advertiser handling with GATT server enabled
When the GATT server is enabled the proxy advertiser
server need to be stopped. This solved a bug where the
Mesh Proxy Service is not restared.
This fix is done to fix several failing PTS test that
was failing when CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE
was enabled. Calling the stop_proxy_adv was left out
in a prevouis commit when doing code cleanup.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2025-03-24 19:23:45 +01:00
Pavel Vasilyev
7592b049ef bluetooth: mesh: pb_adv: Fix resending Generic Transaction Ack PDU
The Generic Provisioning protocol requires that a transaction must be
acknowledged before the next Generic Provisioning PDU is processed
(section 5.3.3, MshPRT_v1.1).

In the current PB-ADV implementation, if there is an ongoing transaction
(link.tx.adv points to a valid advertisement), any received Generic
Provisioning Start and Continuation PDUs are ignored.

This creates a scenario where a remote device misses the Transaction
Acknowledgment PDU and retransmits the last PDUs, but they are ignored
by the local device because the local device has already started sending
the next Provisioning PDU.

In particular, in the observed failure, the Provisioner missed the
Generic Transaction Acknowledgment PDU during the transmission of the
Provisioning Data PDU.

This commit modifies the processing logic for Generic Provisioning Start
and Continuation PDUs by checking if the received PDU has already been
received. If so, it attempts to re-send the Generic Transaction
Acknowledgment PDU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-03-24 15:10:39 +01:00
Emil Gydesen
159de4c0b9 Bluetooth: Controller: Fix dependency for connected ISO Kconfigs
The options for BT_CTLR_CENTRAL_ISO and
BT_CTLR_PERIPHERAL_ISO did not have the proper defaults not
dependencies when BT_LL_SW_SPLIT=y

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-24 07:58:00 +01:00
Mark Wang
e5742b2405 bluetooth: avdtp: avoid that the ret and err exist together
Keep the err in code as it is convention in Bluetooth code, remove ret,
change error_code as avdtp_err_code for avdtp protocol error.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-21 09:53:49 +01:00
Johan Hedberg
0837ad5be8 Bluetooth: Host: Remove unused include
There's no need for scan.h in direction.c.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-03-20 21:58:44 +01:00
Troels Nilsson
35371e8db1 Bluetooth: Controller: Fix possible unaligned read for ISO timestamp
Use net_buf_pull_le32() to avoid alignment issues for the ISO timestamp

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 17:15:48 +01:00
Emil Gydesen
d19abff476 Bluetooth: CSIP: Add support for dynamically setting set size
The set size can now be dynamically set and notified.
The rank is added as a argument in the case that changing
the set size, also affects the device's rank, as ranks
in a coordinated set needs to be continuous.

The set coordinator implementation has been updated
to support receiving the new set size, and providing
this information to the upper layers.

This commit adds a babblesim test for the new API,
as well as a shell command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-20 14:23:40 +01:00
Troels Nilsson
30df4762e7 Bluetooth: Controller: Fix overhead check in ull_scan_aux for SLOT_AGNOSTIC
The current overhead check needlessly flushes some events for
CONFIG_BT_TICKER_SLOT_AGNOSTIC resulting in some lost or incomplete
advertising events; Use a lower overhead value for this configuration
to avoid that

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 14:23:21 +01:00
Troels Nilsson
b6d32b94a0 Bluetooth: Controller: Fix missing initialization of expire_info_id
The scanner doesn't use the expire_info_id feature, so it needs to
be set to TICKER_NULL

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 14:22:38 +01:00
Troels Nilsson
d028532fe9 Bluetooth: Controller: Select TICKER_LAZY_GET for PAST sender
BT_CTLR_SYNC_TRANSFER_SENDER does not work without BT_TICKER_LAZY_GET;
Add a select to the config

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 12:17:02 +01:00
Troels Nilsson
334764d2fa Bluetooth: Controller: Use event_offset = 2 for large CIG Sync Delays
For a CIG with a CIG Sync Delay larger than a SDU interval, we cannot
be sure that we can target the very next ISO event when the CIG event
is ongoing; Only reduce event_offset if CIG Sync Delay is smaller
than an SDU interval

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 09:33:40 +01:00
Lyle Zhu
11fc9642c0 Bluetooth: Classic: Add a function bt_conn_get_dst_br()
Add a function `bt_conn_get_dst_br()` to get the peer address of the
classic connection.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 09:01:51 -04:00
Lyle Zhu
773298893f Bluetooth: BR: Shell: clang-format
Clang-format subsys/bluetooth/host/classic/shell/bredr.c

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
0e792d4271 Bluetooth: BR: Shell: L2CAP mode support
Add more parameters to command `connect` and `register`, including mode,
mode_optional, extended_control, and hold_credit.

Add command `credits` to give the rx credit.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
bba7efa941 Bluetooth: BR: Shell: Add L2CAP basic function commander
Add a sub-command set `l2cap` for command set `br`.

Move command `l2cap-register` to sub-command set. And rename it to
`register`.

Add command `connect`, `disconnect`, and `send` for command set
`l2cap`.

Remove original net buffer pool from `data_pool` to `data_rx_pool`.
Add a net buffer pool `data_tx_pool` for command `send`.

Do not wait anymore if no net buffer can be allocated from
`data_rx_pool`.

Dump all received data in L2CAP data received callback.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
5fd98e10bd Bluetooth: L2CAP_BR: Sending multiple SDU at same time
Improve the retransmission and flow control to support sending
multiple SDU at the same time if the TX windows is not full.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
88bd18b6cd Bluetooth: L2CAP_BR: Add mode optional support
Add mode optional support for BR l2cap connect initiator role.

If `chan->rx.optional` is true, set the mode to basic mode instead of
return error code `-ENOTSUP`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
d2a10833dd Bluetooth: L2CAP_BR: Enable Retransmission and Flow control
Enable signaling channel configuration for retransmission and Flow
control feature.

Send I-frame and S-frame. Support retransmission and Flow control for
sending.
Receive and handle I-frame and S-frame.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
18b0ac9b9a Bluetooth: conn: Make bt_conn_lookup_addr_br() public
Move the declaration of the function `bt_conn_lookup_addr_br()` from
`conn_internal.h` to `conn.h`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 10:58:29 +01:00
Michał Stasiak
32a4c9cb79 bluetooth: controller: remove select of ENTROPY_NRF_CRACEN_CTR_DRBG
ENTROPY_NRF_CRACEN_CTR_DRBG symbol is based on devicetree
node with compatible nordic,nrf-cracen-ctrdrbg. It does not
have to be selected explicitly.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-03-19 10:57:18 +01:00
Emil Gydesen
065dca7e92 Bluetooth: ISO: Make setting ISO data explicit
The stack will no longer implicitly set the data path
for ISO channel, and the responsibility for doing that is
now for the upper layers/applications.

This provides additional flexibility for the higher layers
as they can better control the values and timing of the data
path, as well as support removing and even reconfiguring the
data path at will.
This also removes some complexity from the stack.

This commit also fixed a inconsistency in the disconnected
handler. CIS for centrals as well as BIS were still valid
bt_iso_chan channels in the disconnected callback,
but CIS for peripherals were completely cleaned up at this
point. This issue is fixed by moving the disconnected callback
handling to before the code to cleanup the channel for
peripherals.

Since there is a difference in how you remove data paths
depending on the GAP role (central/peripheral), the
iso_info struct type has been expanded to be more
concise of which type of CIS it is.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-19 10:56:57 +01:00
Troels Nilsson
48fd8874e9 Bluetooth: Host: Fix missing endianness conversion for ISO ts
The timestamp was missing an endianness conversion

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-18 19:54:24 +01:00
Johan Hedberg
81e7569fa1 Bluetooth: Host: Fix format specifier warnings
Use %zu for size_t and %zd for ssize_t, and don't use those specifiers for
any other type. Also make sure that field width specifiers get typecast to
the expected int type.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-03-18 16:45:29 +01:00
Emil Gydesen
fb68b4be7e Revert "Bluetooth: Audio: Use generic count_bits to count bits"
This reverts commit ee335399c1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-18 16:39:47 +01:00
Emil Gydesen
ee335399c1 Bluetooth: Audio: Use generic count_bits to count bits
Instead of re-implementing or assuming that POPCOUNT is available
we now use the generic function from Zephyr.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-17 21:03:56 -04:00
Vinayak Kariappa Chettimada
0a4480ce61 Bluetooth: Controller: Fix connection update interval_us variables
Fix connection update microsecond interval variable data
type, to use 32-bit so that a value upto 2000 seconds, i.e.
4 seconds interval and 499 peripheral latency can be stored.

Regression in commit abfe5f17a9 ("Bluetooth: Controller:
1 ms connection").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-17 20:00:42 +01:00
Alberto Escolar Piedras
1dab77b49f Bluetooth: Host: ATT: Fix build warning with clang
Fix the following warning
att.c:734:3: warning: label followed by a declaration is a C23 extension
[-Wc23-extensions]
  734 |                 k_tid_t current_thread = k_current_get();
      |                 ^
By wrapping that code as a compound statement

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-17 16:25:33 +01:00
Vinayak Kariappa Chettimada
374d41a9c1 Bluetooth: Controller: ISO Receive interleaved packing support
Add ISO Receive interleaved packing support in Lower Link
Layer implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-17 16:24:33 +01:00
Vinayak Kariappa Chettimada
5b74950857 Bluetooth: Controller: ISO Broadcast interleaved packing support
Add ISO Broadcast interleaved packing support in Lower Link
Layer implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-17 16:24:33 +01:00
Vinayak Kariappa Chettimada
4243cb5df6 Bluetooth: Controller: Fix BIS interleaved packing sub_interval calc
Fix BIS sub_interval calculation for interleaved packing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-17 16:24:33 +01:00
Lyle Zhu
1708574d0a Bluetooth: BR: Add a function bt_br_bond_exists()
Add a function `bt_br_bond_exists()` to check if the address of the
classic device has been bonded.

Update release-notes-4.2.rst

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-17 14:08:04 +01:00
Timothy Keys
7ef8116969 bluetooth: host: Remove experimental flag from LE Connection Subrating
The API has not changed since it was introduced so should no longer be
considered experimental.

Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
2025-03-17 13:57:03 +01:00
Lyle Zhu
d42294d809 Bluetooth: SMP_BR: Use macros instead of hard code
Define macros for encryption value,
#define BT_HCI_ENCRYPTION_OFF           0x00
#define BT_HCI_ENCRYPTION_ON_LE_AES_CCM 0x01
#define BT_HCI_ENCRYPTION_ON_BR_E0      0x01
#define BT_HCI_ENCRYPTION_ON_BR_AES_CCM 0x02

Use the macros to replace the hard code.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-17 07:04:58 +01:00