Commit graph

9787 commits

Author SHA1 Message Date
Lyle Zhu
001397653b Bluetooth: Classic: SMP: Set BT_LINK_KEY_SC only if BT_KEYS_SC is set
The flag `BT_LINK_KEY_SC` of LK will also be set when derive LK from
LTK.
It is a incorrect behavior.

The flag `BT_LINK_KEY_SC` should only be set if the flag `BT_KEYS_SC`
of LTK has been set.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 14:35:50 +02:00
Lyle Zhu
2695d2228b Bluetooth: Classic: SMP: Avoid stronger LK be overwrote by weaker LTK
Add the function `ltk_derive_link_key_allowed()` to check whether the
LK can be overwrote by the LTK.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 14:35:50 +02:00
Lyle Zhu
f25fe59805 Bluetooth: Classic: SMP: Recovery flag SMP_FLAG_BR_CONNECTED
The flag `SMP_FLAG_BR_CONNECTED` is cleared by the function
`smp_br_reset()` and `smp_br_init`. But the flag
`SMP_FLAG_BR_CONNECTED` should not be cleared at this time.

Recovery the flag `SMP_FLAG_BR_CONNECTED` after the all flags of SMP
cleared.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
b59bc363ea Bluetooth: Classic: SMP: Set secure connection for derived LTK
If the encrypt value of classic connection is
`BT_HCI_ENCRYPTION_ON_BR_AES_CCM`, set the flag `BT_KEYS_SC` for
the derived LTK.

Or, clear the flag `BT_KEYS_SC` for the derived LTK.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
58f6ca80ca Bluetooth: Classic: SMP: Remove old LE keys before upgrading keys
Remove the old LE keys from resolving list and NVM before upgrading
the keys.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
3712b96738 Bluetooth: Classic: SMP: Avoid derived LE keys be added multiple times
In current implementation, the flag `local_dist` will be cleared when
the distributed key frame is performed if the local is the SMP
initiator. After the distributed key is sent out, the function
`smp_pairing_br_complete()` will be called if all bits of `local_dist`
are cleared.

It causes the function `smp_pairing_br_complete()` will be called
multiple times.

Add a flag `local_distributed` to flag the all sent keys. Add only the
flag `local_distributed` is not set, preform the key distribution
frame.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
8bb67c5824 Bluetooth: Classic: SMP: Derived LE keys are not handled correctly
The derived LE keys are not saved to NVM. And the IRK is not added to
controller resolving list. It causes two issues,
Issue 1, the LE connection connection cannot be established if the adv
address of peer is RPA.
Issue 2, the LE keys are missing after the power reset.

For issue 1, add a function `smp_br_id_add_replace` to add LE keys.
For issue 2, check the BR bondable flag `BT_CONN_BR_NOBOND` instead of
`SMP_FLAG_BOND`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Vinayak Kariappa Chettimada
dd1c3948ca fixup! Bluetooth: Controller: Fix incorrect CIS payload count at CIS Estab
Fix incorrect payload count at CIS Establish due to existing
CIG event overlapping the ACL event at the instant when the
CIS gets the active flag set.

The overlapping CIG event picked up the new CIS that had its
active flag set in the current CIG event instead of at the
actual CIS offset which is in the next CIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
fcca236e42 Bluetooth: Controller: Fix CIS offset for dissimilar ACL & CIG interval
Fix CIS offset calculation due to use of decremented ACL
event counter, where as the CIS offset is inquired in the
next ACL event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
4ab805b389 Bluetooth: Controller: Fix incorrect CIS offset accepting peer instant
Fix incorrect CIS offset in use if instant is picked from
the peer sent CIS RSP PDU. Instead, keep the instant that
was sent in the CIS REQ PDU as the instant to send in the
CIS IND PDU.

This fixes CIS failed to be established when dissimilar
ACL and ISO intervals are in use.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
f2c020f53e Bluetooth: Controller: Fix incorrect CIS payload count at CIS Estab
Fix incorrect payload count at CIS Establish due to existing
CIG event overlapping the ACL event at the instant when the
CIS gets the active flag set.

The overlapping CIG event picked up the new CIS that had its
active flag set in the current CIG event instead of at the
actual CIS offset which is in the next CIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
81dd7595f0 Bluetooth: Controller: Fix Peripheral CIS sorted by CIG
Fix Peripheral CIS sorted by CIG implemenation to use CIS
offset stored in LLL context which is the correct offset
from the CIG anchor point. CIS offset in the ULL context
is the offset from the ACL anchor point at the time of
the CIS establishment.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
26eedaaf45 Bluetooth: Controller: Fix CIS event_count_prepare use
Fix CIS event_count_prepare use missed as part of fixes
related to commit be91cfedfb ("Bluetooth: Controller: Fix
incorrect event_count when CIG overlaps").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Aleksandr Khromykh
bf22fa697b Bluetooth: Mesh: remove device key candidate
Commit removes device key candidate if provisionee failed
during device key refresh procedure or mesh reset has been
called in between. Otherwise, device key candidate gets
stuck in the internal trusted storage of crypto library.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-03-28 16:11:39 +01:00
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