Commit graph

9,920 commits

Author SHA1 Message Date
Mark Wang
c8763596c9 bluetooth: avdtp: unify the avdtp error code based on Zephyr err code
get the avdtp error code based on Zephyr err code to make the codes more
clear.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
(cherry picked from commit 1d4d97fdb41791501eb63934f096bcc88cb2da81)
2025-10-15 12:06:56 +03:00
Mark Wang
1032b1e567 bluetooth: a2dp: avoid clearing the cmd req
If the previous cmd req is triggered, the cmd fail to trigger again and
keep the previous cmd req.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
(cherry picked from commit f4197d51b62799748a75c97bd0b68778185ff293)
2025-10-15 12:06:56 +03:00
Mark Wang
eb3af0b9a6 bluetooth: a2dp: remove meaningless if
The `a2dp` is got by `req` through CONTAINER_OF, then the if always is
true.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
(cherry picked from commit 24ef59d835c69a30fe8a8e6569405791532d9e0d)
2025-10-15 12:06:56 +03:00
Mark Wang
d5fb16bd31 bluetooth: a2dp: use avdtp struct to fill data to net buf
avdtp defines the data format by struct, use it to fill net buf.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
(cherry picked from commit a89f4eddac6f13f981f2ca0b94f07edaad104afa)
2025-10-15 12:06:56 +03:00
Mark Wang
8e6a853654 bluetooth: avdtp: check buf tail room
check the buf tail room before adding data to buf.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
(cherry picked from commit 65f8a9e03baf899684198e707170ad17817f7ce5)
2025-10-15 12:06:56 +03:00
Mark Wang
0fd58cc20c bluetooth: a2dp: implement get_config
implement get configuration

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
(cherry picked from commit 54cae2e75bcb7ee38ec4d7c24cef8835e3836a05)
2025-10-15 12:06:56 +03:00
Mark Wang
3d81dc086d bluetooth: a2dp: implement delay report
implement delay report

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-10-15 12:06:56 +03:00
Lyle Zhu
64a544935b Bluetooth: HFP_AG: Fix SLC connected event early notify issue
In current implementation, the SLC connected event will be early
notified. It causes the SLC state of AG is not aligned with the state
of HF.

The SLC connected event should be notified after the procedure of HF
indicators is done if the HF indicators feature is supported by both
devices.

Do not notify the SLC connected event after the AG has successfully
responded with information about how call hold and multiparty services
are supported if the HF indicators feature is supported by both
devices.

Notify the SLC connected event after the procedure of HF indicators is
done.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-15 12:06:22 +03:00
Johan Hedberg
3fa1b98c4f Bluetooth: Update TX buffer calculation with auto PHY changes
Make sure to consider both the new peripheral and central Kconfig options
when calculating needed TX buffers.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-10-14 18:53:08 +02:00
Johan Hedberg
30b4c3e438 Bluetooth: Host: Add role-specific auto PHY update options
The BT_AUTO_PHY_UPDATE option was problematic in the sense that it didn't
really allow any kind of fine-tuning of what automation is desired. In
particular, it didn't allow specifying which PHY was the preferred one (it
was hardcoded to 2M) and also didn't allow specifying role-specific
(central vs peripheral) preferences.

To solve this, deprecate the old option, and instead introduce
role-specific options that allow specifying 1M/2M/Coded/None as the
preference. The new options have slightly different defaults than the new:
for central role 2M stays as the preference, however since it's uncommon to
require automated changes on the peripheral side the default is set to
None there.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-10-14 18:53:08 +02:00
Xiang Liu
8e9fa6a273 bluetooth: remove blocking operation in bt_conn_get_info
bt_conn_get_info API is used to retrieve connection-related
information. However, bt_conn_get_info sends the HCI command
BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE to retrieve current
key_size, causing excessive blocking time.

Signed-off-by: Xiang Liu <liuxiang18@xiaomi.com>
2025-10-14 07:45:01 -04:00
Mark Wang
5422e3f21f bluetooth: avdtp: save avdtp session to ep
when ep is configured, the ep is used by the avdtp session, so combine
them together when ep is configured.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-10-14 12:53:27 +03:00
Mark Wang
02c5974e04 bluetooth: a2dp: ep->stream is cleared when stream l2cap is released
ep->stream is cleared when stream l2cap is released, it should not be
cleared by close and abort cmd procedure.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-10-14 12:53:27 +03:00
Mark Wang
39eaec0513 bluetooth: a2dp: improve the stream l2cap release
When signal l2cap is disconnected, use `release_work` to release the
related stream l2cap connections. When releasing the sep's stream l2cap,
use `delay_work` to check the stream l2cap disconnecting result.
Move the stream l2cap disconnecting callback to sep because the chan is
in sep, then use this callback to indicate the sep stream chan is
released and sep is idle.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-10-14 12:53:27 +03:00
Mark Wang
b9dc6a7fde bluetooth: a2dp: remove the aborted stream callback
The `released` callback is enough indicate that the stream is
invalid/released, so remove the `aborted` callback.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-10-14 12:53:27 +03:00
Emil Gydesen
1c004a08c3 Bluetooth: CCP: Client: Add support for get provider name
Add support for getting the remote bearer provider
name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-13 08:43:47 +02:00
Lyle Zhu
3ac4f92625 Bluetooth: Classic: OBEX: Optimize MOPL configuration
Set the MOPL of RX and TX to `BT_OBEX_MIN_MTU` when registering OBEX
server.

Set the TX MOPL to `BT_OBEX_MIN_MTU` when sending OBEX connection
request.

Check if the MOPL of client exceeds MTU of transport when server
receives the connection request.

Check if the MOPL of server exceeds MTU of transport when client
receives the connection response.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-10 12:59:56 -04:00
Lyle Zhu
26065ecee3 Bluetooth: Classic: GOEP: Support multiple OBEX sessions
Split the structure `struct bt_obex` into two parts.
Part 1 `struct bt_obex`, it is the common part and shared by all OBEX
sessions which share the same one transport.
Part 2 `struct bt_obex_server` and `struct bt_obex_client`. The
`struct bt_obex_server` is used to manage the OBEX session of server
role. The `struct bt_obex_client` is used to manage the OBEX session
of client role.

Add function `bt_obex_server_register()` to register the OBEX server
with specific uuid.

Add function `bt_obex_server_unregister()` to unregister the OBEX
server.

Add function `bt_obex_make_uuid()` to make UUID.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-10 12:59:56 -04:00
Lyle Zhu
6d77949698 Bluetooth: GOEP: Fix L2CAP segmented RX data handling issue
The receiving segmented L2CAP data can not be handled properly. Due to
the `struct bt_l2cap_chan_ops::alloc_buf` is NULL, the partial data
will be notified through callback `struct bt_l2cap_chan_ops::recv`.
The GOEP does not consider this issue and handles it as a completed
packet. It causes the L2CAP disconnecting due to the partial packet
cannot be processed by OBEX.

Add a RX pool, and set `struct bt_l2cap_chan_ops::alloc_buf`. The
L2CAP will allocate the buffer from the pool to buff the segmented
data. Only the completed packet will be notified through
`struct bt_l2cap_chan_ops::recv`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-10 12:58:54 -04:00
Christophe Dufaza
60c3de2722 bluetooth: host: remove useless internal flag BT_ADV_PERSIST
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].

Options and parameters for this behavior have been removed,
and the internal bit flag BT_ADV_PERSIST is now always false.

The behavior it used to configure (to keep advertising after a
connection has been established as long as there are connections
available) has also been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
a1dd571f11 bluetooth: host: remove no longer used internal API bt_le_adv_resume()
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].

Options and parameters for this behavior have been removed,
as well as all calls to bt_le_adv_resume().

Also remove adv_get_options() whose bt_le_adv_resume()
is the only caller.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
9b5ad2f8df bluetooth: host: do not attempt to resume terminated advertising sets
Automatic advertiser resumption is publicly deprecated
since Zephyr 4.0 [1].

Options and parameters for this behavior have been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
731e581174 bluetooth: host: do not resume periodic connectable advertisers
Automatic advertiser resumption is publicly deprecated since
Zephyr 4.0 [1].

Options and parameters for this behavior have been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
b3a4ff0109 bluetooth: host: do not use freed connection to resume advertising
In bt_conn_unref(), if we remove the last reference to the connection,
we notify listeners that a connection object has been freed
and can be taken, then immediately reuse this freed slot
to resume advertising.

This behavior is source of errors, and automatic advertiser resumption
is publicly deprecated since Zephyr 4.0 [1].

Options and parameters for this behavior have been removed.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
5762ff5b58 bluetooth: host: remove transitional option _BT_LE_ADV_OPT_ONE_TIME
Automatic advertiser resumption is deprecated since Zephyr 4.0 [1].

To maintain the behavior during the deprecation period, internal
transitional symbols were introduced to replace the deprecated ones
in the implementation:

- _BT_LE_ADV_OPT_CONNECTABLE: same option bit
   as BT_LE_ADV_OPT_CONNECTABLE (deprecated)
- _BT_LE_ADV_CONN_ONE_TIME: same option bit
   as BT_LE_ADV_CONN_ONE_TIME (deprecated)

The only option for connectable advertising is now BT_LE_ADV_OPT_CONN,
whose value is _BT_LE_ADV_OPT_CONNECTABLE|_BT_LE_ADV_OPT_ONE_TIME.

We can assume _BT_LE_ADV_CONN_ONE_TIME is true for connectable
advertisers, and meaningless for non-connectable advertisers.

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Christophe Dufaza
e24d3b92a3 bluetooth: host: remove transitional option _BT_LE_ADV_OPT_CONNECTABLE
Automatic advertiser resumption is deprecated since Zephyr 4.0 [1].

To maintain the behavior during the deprecation period, internal
transitional symbols were introduced to replace the deprecated ones
in the implementation:

- _BT_LE_ADV_OPT_CONNECTABLE: same option bit
   as BT_LE_ADV_OPT_CONNECTABLE (deprecated)
- _BT_LE_ADV_CONN_ONE_TIME: same option bit
   as BT_LE_ADV_CONN_ONE_TIME (deprecated)

The only option for connectable advertising is now BT_LE_ADV_OPT_CONN,
whose value is _BT_LE_ADV_OPT_CONNECTABLE|_BT_LE_ADV_OPT_ONE_TIME.

We can substitute BT_LE_ADV_OPT_CONN for _BT_LE_ADV_OPT_CONNECTABLE
when testing if an advertising set is connectable.

Note: to fix a ClangFormat warning raised by check_compliance.py,
this commit also includes a formatting change next to the lines
actually edited (subsys/bluetooth/host/id.c:810).

[1] Bluetooth: Deprecate adv auto-resume #73395

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-10-10 12:56:28 -04:00
Emil Gydesen
d4afa1989f Bluetooth: Host: Change WRN->DBG for not connect for TX
The bt_conn_tx_processor logged connections not in the
connected state as LOG_WRN, but this is a case that is handled
and could occur during regular behavior.
For this reason the log statement was changed to LOG_DBG,
as the developer/user does not need to worry about it.
Also modifies the statement to log the conn->state for
debugging purposes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-10 12:55:28 -04:00
Make Shi
528e732aad Bluetooth: Shell: BR: Add SDP discovery support for AVRCP CT/TG
Add SDP discovery handlers for AVRCP CT/TG roles and corresponding
discovery parameters and a common result handling function.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-10-09 12:42:45 -04:00
Vinayak Kariappa Chettimada
9b26e967ca Bluetooth: Controller: nRF54L: Fix to improve decryption speed
Fix to improve decryption speed. Decryption starts after
payload reception, hence use fastest mode to decrypt PDUs.
nRF54Lx only supports decryption after payload reception,
this implementation was already there in the code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-09 12:41:43 -04:00
Vinayak Kariappa Chettimada
a5e1f59686 Bluetooth: Controller: Revert relaxed radio packet assignment deadline
Reverts relaxed radio packet assignment deadline as it is
too risky and can cause invalid bits be transmitted and/or
cause MIC failures.

Reverts commit 4dbfb22a7e ("Bluetooth: Controller: Relax
radio packet pointer assignment deadline"), and
commit 230df77993 ("Bluetooth: Controller: Relax radio
packet pointer assignment deadline").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-09 12:41:43 -04:00
Vinayak Kariappa Chettimada
1fe79a65a2 Bluetooth: Controller: Use CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET
Use CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET for nRF53 SoC
conditional compilations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-09 12:41:43 -04:00
Emil Gydesen
0abb23ffad Bluetooth: ISO: rm extra log statements in chan_send
bt_iso_chan_send and bt_iso_chan_send_ts would log
twice for each TX, which is unncessary. LOG_DBG statements
include the function name by default, so the 2nd log
statement was unncessary, and were removed.

Added logging of the ts in bt_iso_chan_send_ts which
would still make it possible to tell the 2 apart,
even if CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-08 18:25:17 -07:00
Vinayak Kariappa Chettimada
7fd5dea9cc Bluetooth: Controller: Cosmetic changes to Link Layer interface
Cosmetic changes to the Link Layer interface header file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-08 15:12:22 -04:00
Vinayak Kariappa Chettimada
8eae0bfbd0 Bluetooth: Controller: Fix single switch timer use in ISO Sync
Fix implementation of Broadcast ISO Synchronized Receiver
using single switch timer to consider minimum compare value
requirement.

This fix reduces latencies to setup radio receptions and
fixes an assertion in lll_sync_iso when radio_tmr_start_us()
is checked for latencies.

Relates to commit 5dfc58cff9 ("Bluetooth: Controller: Fix
single switch timer minimum compare value").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-08 15:09:33 -04:00
Emil Gydesen
4b9bc7d11b Bluetooth: Controller: Fix return types for ll_length
ll_length_req_send and ll_length_default_set were defined to return
a uint32_t, but only returned a uint8_t HCI error code and
was the return value was always stored as such.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-08 08:45:37 +02:00
Emil Gydesen
2140b55d29 Bluetooth: BAP: Shell: 0-init some global variables
0-init some non-static global variables to avoid
issues with uninitialized values. Also modify
the printing of the broadcast sources found slightly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-07 17:44:19 +03:00
Emil Gydesen
35909d7fdf Bluetooth: CAP: Mark err used for assert as __maybe_unused
If asserts are disabled, then `err` is unused can caused
a compiler warning.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-07 12:47:30 +02:00
Jordan Yates
1f3ce818fc bluetooth: controller: ll_sw: nordic: constant latency req
When `CONFIG_NRF_SYS_EVENT` is enabled, route constant latency requests
through the reference counted API.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-07 10:59:38 +02:00
Emil Gydesen
6c870b071a Bluetooth: Remove CONFIG_BT_BUF_ACL_RX_COUNT
Remove the deprecated CONFIG_BT_BUF_ACL_RX_COUNT config
as it has been deprecated since 4.1

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-06 20:17:14 -04:00
Emil Gydesen
360880b7c7 Bluetooth: Host: Remove bt_le_set_auto_conn
Remove the deprecated function bt_le_set_auto_conn
as it has been deprecated since 4.1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-06 20:01:04 +03:00
Emil Gydesen
5d8170bba8 Bluetooth: BAP: Add conn check assert in bt_bap_iso_bind_ep
Adds assert for bt_bap_iso_bind_ep to ensure that endpoints
from different connection don't share a CIS (a bt_bap_iso).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-03 12:51:45 +03:00
Emil Gydesen
1dc98dd932 Bluetooth: BAP: Add check to verify that eps have correct iso
Add a check that verifies that 2 endpoints from different
connection don't share a CIS, which would be invalid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-03 12:51:45 +03:00
Emil Gydesen
4f2ef519b6 Bluetooth: BAP: UC: Move iso_bind_ep to config instead of QoS
We can actually already when we bind the endpoint to the stream
perform the call to bt_bap_iso_bind_ep, if the stream has been
added to a group.

If the stream has not yet been added to a group, then when
the stream is added to a group, then bt_bap_iso_bind_ep will
be done there (existing behavior).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-03 12:51:45 +03:00
Ashirwad Paswan
21da2d056d Bluetooth: Controller: Fix missing null pointer check
Added a check for null pointer in ull_sync_iso.c file
to avoid potential crashes.

Fixes: #81997

Signed-off-by: Ashirwad Paswan <ashi06712@gmail.com>
2025-10-01 08:27:33 +02:00
Loic Domaigne
bfbc6365ac Bluetooth: Controller: fix assertion check for ptc value
Fix the issue reported by Coverity CID 487708. The LL_ASSERT was
performed on lll->ptc, which is a 4-bit bitfield and therefore always
succeeds. Instead, the computation (lll->nse - nse) should be checked
to ensure it falls within the 4-bit value range before assigning it
to lll->ptc.

Signed-off-by: Loic Domaigne <tech@domaigne.com>
2025-09-30 15:28:36 +03:00
Emil Gydesen
87e6bff4ef Bluetooth: CAP: Shell: Change to use default_unicast_group
Use default_unicast_group everywhere in the CAP shell, and mark
all creation of it as default_unicast_group.is_cap = true.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-30 11:02:29 +02:00
Emil Gydesen
ca80d25bd9 Bluetooth: CAP: Shell: Move ac_create_unicast_group to CAP
Move the function bap_ac_create_unicast_group to the CAP
shell, as that was the only user of it, and rename it to
cap_ac_create_unicast_group, and make it use the CAP API.

Also rename bap_unicast_ac_param to cap_unicast_ac_param

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-30 11:02:29 +02:00
Emil Gydesen
bf19edc8d8 Bluetooth: BAP: Shell add common unicast_group struct
Add a common unicast_group struct for both the BAP and
CAP shell, similar to the broadcast_source.

The purpose of this is to be able to use the appropriate type
for both the CAP and BAP shells, instead of using the BAP
unicast group for the CAP shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-30 11:02:29 +02:00
Håvard Reierstad
ff17e601d0 Bluetooth: Host: Add userdefined fixed l2cap chans
Adds support for the user defining their own channels within the
fixed L2CAP channel range. To make this possible, the
`bt_l2cap_fixed_chan` struct and `BT_L2CAP_CHANNEL_DEFINE` macro
needed to converted to public API. In the process of doing so, the
`_destroy` parameter was removed from the `BT_L2CAP_CHANNEL_DEFINE`
macro as it was never used (fixed channels will not be destroyed over
the lifetime of the connection). `BT_L2CAP_CHANNEL_DEFINE` is renamed
`BT_L2CAP_FIXED_CHANNEL_DEFINE` to avoid confusion

The `bt_l2cap_chan_send` function is updated to be able to send data
on fixed l2cap channels.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2025-09-29 12:38:19 -04:00
Emil Gydesen
881a24270c Bluetooth: BAP: Rename and fix bt_bap_is_x_ep
Rename the bt_bap_is_x_ep functions to better match the
modules where they are implemented.

Additionally modify the check to use IS_ARRAY_ELEMENT
in the broadcast sink and source for a stricter check.
IS_ARRAY_ELEMENT cannot easily be used in the unicast
client and server, as the endpoints are part of another
structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-29 12:38:06 -04:00