Commit graph

9,930 commits

Author SHA1 Message Date
Lyle Zhu
22346b47b8 Bluetooth: Classic: SDP: Support ATTR ID list setting for SA/SSA REQ
In current implementation, the ATTR ID list is set with fixed value
(0x0000, 0xffff). For the case that responding a lot of SDP record
data, the responded data cannot be processed properly due to the
receiving buffer size limitation. In this case, the ATTR ID list can
be used to reduce the length of the responding data. In this way, it
will help reduce the SDP's requirement for receiving data buffer size.

Add the attribute ID list configuration to the SDP discovery request
structure `struct bt_sdp_discover_params`.

If the `struct bt_sdp_discover_params::ids` is NULL, or
`struct bt_sdp_discover_params::ids::count` is 0, the default range
(0x0000, 0xffff) is used.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-09-10 08:27:21 +02:00
Lyle Zhu
fc6fe95ca8 Bluetooth: SDP: Notify partial records if RX buf is full
In current implementation, if the response total data length is more
than the receiving buffer size, the request cannot be completed
properly.

Improve the SDP client with the following changes,
o Notify the received completed SDP records if the case occurs, and
  then start the continuing SDP discovery,
o Stop the SDP discovery if the hold SDP record cannot be saved to the
  receiving buffer,
o Stop the SDP discovery if the `BT_SDP_DISCOVER_UUID_STOP` is
  returned by upper layer.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-09-10 08:27:01 +02:00
Lyle Zhu
aca9345ce6 Bluetooth: Classic: SDP: Refactor parsing of Service Search Pattern
In current implementation, after parsing the received service search
pattern and all matched SDP records are saved in the local variable
`matching_recs`. The max count of SDP records within its SDP
database that match the given service search pattern is
BT_SDP_MAX_SERVICES when parsing the received Service Search Pattern.
And it causes the max count registered SDP records is limited to
BT_SDP_MAX_SERVICES.

Refactor the parsing of service search pattern to remove the
limitation with the following steps.
1. Save the service search pattern to a simple buffer by calling
   the function `parse_service_search_pattern()`.
2. Traverse all registered SDP record and check for each SDP record
   if it is matched with given service search pattern by calling
   function `service_search_pattern_matched()`.
3. Use the matched SDP records to response the SDP request.

And also remove the limitation of the max count of registered SDP
records.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-09-10 08:26:50 +02:00
Lyle Zhu
cbf7576aad Bluetooth: Classic: SDP: Use slist to manage SDP records
Use slist instead of custom singly linked list to manage SDP records.

Check if the SDP record has been registered in the function
`bt_sdp_register_service()`.

Append the new SDP record to the tail of the SDP record list.

Check if the index of SDP record is overflow in the function
`bt_sdp_register_service()`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-09-10 08:26:50 +02:00
Vinayak Kariappa Chettimada
02f180c052 Bluetooth: Controller: Fix Central and Peripheral ISO single timer use
Fix incorrect LLL scheduling of subsequent subevents when
using single timer implementation, due to missing call to
accumulate the last PDU end timestamp which is essential to
setup next radio start and to setup header complete timeout.

Relates to commit 373dc0db71 ("Bluetooth: Controller:
Single timer use Extended Advertising nRF54L support").

Relates to commit 6e8f081385 ("Bluetooth: Controller: Fix
peripheral assert under single timer use").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-09-09 20:42:55 -04:00
Vinayak Kariappa Chettimada
aef0aee0b4 Bluetooth: Controller: Minor update to conditional compile comment
Minor update to conditional compile comment.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-09-09 20:42:55 -04:00
Emil Gydesen
59ae1595ba Bluetooth: BAP: Merge 2 if's to make sonarcloud happy
Sonarcloud suggests to merge the 2 if statements, which
makes sense to do.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 20:42:01 -04:00
Emil Gydesen
9f5c4790d9 Bluetooth: CSIP: Fix restore of CSIS on unregister
The bt_csip_set_member_unregister function unregisters
a CSIS instance and restores the attributes to the original
state (the attributes may change during registration).

The previously solution had some issues with a check when
using picolib (‘__ssp_bos_check3’ undeclared), and this
fixes that by using a proper variable for the memcpy.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 17:27:52 +02:00
Emil Gydesen
5734d7e5cd Bluetooth: Audio: Use generic sys_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-09-09 17:27:15 +02:00
Emil Gydesen
ceb567a62b Bluetooth: ISO: Cleanup BIG before stopped callback
Modify the big_disconnect function to do cleanup_big before
calling the `stopped` callback. This will allow the ISO channels,
as well as the BIG itself, to be reused for other purposes directly
in the stopped callback, without having to offload such actions
to a separate thread.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 14:52:46 +02:00
Emil Gydesen
19651491f3 Bluetooth: BAP: Fix compile issue with ep->status.state
The ep->status.state is now just ep->state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 11:44:03 +02:00
Emil Gydesen
e9b6d62908 Bluetooth: BAP: Server: Verify that ep is from ASCS
Adds a function that verifies if an endpoint pointer is
part of ASCS before performing CONTAINER_OF operations on it.

Adds checks for this in the BAP Unicast server public API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 10:30:45 +02:00
Emil Gydesen
ed74992799 Bluetooth: ASCS: Fix minor sonarqube issue with missing else
Add missing else.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 10:30:45 +02:00
Emil Gydesen
40644e75a3 Bluetooth: ASCS: Use ASE_ID where applicable
Use the ASE_ID where applicable instead of ase->ep.id

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 10:30:45 +02:00
Emil Gydesen
ce9e8f8b9e Bluetooth: BAP: Fix bad use of bt_ascs_ase_status
The bt_ascs_ase_status was stored directly in the
struct bt_bap_ep, which was an issue as
bt_ascs_ase_status is a variable sized struct.
The struct could have been moved to the end of
bt_bap_ep to avoid the issues it caused, but
there is no actual reason to use that struct
rather than storing the ID and state as
seperate values.

The ascs_ep_get_state exists but was not widely
used in ascs. Modify places to use the function
instead of directly accessing the state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 10:30:45 +02:00
Fabio Baltieri
8366365c03 util: move utf8 utils to a separate header
This moves the declaration of the utf8 utils defined in lib/utils/utf8.c
in their own header. Main reason to do this is that the current setup
requried adding an include for sys/types.h in util.h, which can result
in a build falure due to a circular header depdenecy when using:

CONFIG_POSIX_API=y
CONFIG_NEWLIB_LIBC=y
_GNU_SOURCE

the loop and error are:

- include/sys/types.h:50: <- this is a NEWLIB one
- include/zephyr/posix/sys/select.h:9:
- include/zephyr/posix/posix_types.h:30:
- include/zephyr/kernel.h:17:
- include/zephyr/kernel_includes.h:25:
- include/zephyr/sys/atomic.h:18:

include/zephyr/sys/util.h:705:1:
error: unknown type name 'ssize_t'

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-09-08 11:11:40 -04:00
Vinayak Kariappa Chettimada
aefeeb922b Bluetooth: Controller: Fix missing ISO Receiver address capture
Fix missing ISO Receiver access address capture that caused
ISO PDU reception error. Missing access address capture for
subsequent subevent when prior subevent did not have an
anchor point sync prevent proper drift compensation hence
causing ISO PDU reception error for the entire BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-09-08 16:01:09 +02:00
Vinayak Kariappa Chettimada
85f4f0483b Bluetooth: Controller: Fix ISO Sync Receiver subevent jitter
Fix the jitter considered in the PDU reception in the
subevents of ISO Sync Receiver to not exceed such that the
reception is scheduled late (causing assertion).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-09-08 16:01:09 +02:00
Kai Cheng
62a4506c6d Bluetooth: SDP: fix sdp record not uninitialized
sdp matching_recs maybe filled with uninitialized record. if
sdp_svc_search_req come from remote with invalid max_rec_count,
which is greater than num_services, matching_recs would response
uninitialized record result.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2025-09-08 14:37:29 +02:00
Mark Wang
0e86cb85f2 bluetooth: avdtp: fix the issue of registering same endpoint
return error when the already registered endpoint is registered again.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-09-05 17:10:41 +02:00
Samuel Tsai
07dc0ad40d Bluetooth: host: adv: revert 39cb574 to fix spurious error log
Commit 39cb574 changed the log level from LOG_DBG to LOG_ERR in
bt_le_adv_resume(). This causes the error log
"No valid legacy adv to resume" to appear during normal connection
establishment when using bt_le_ext_adv_start(), even though the
system is functioning correctly.

Revert the change to restore the original LOG_DBG level.

Fixes: #94954

Signed-off-by: Samuel Tsai <stsai@atmosic.com>
2025-09-05 12:27:45 +02:00
Mark Wang
06dfa99980 bluetooth: a2dp: fix the process of failed cmd
If the cmd fail to receive response (for example: timeout), the buf is
NULL, then need to callback the result.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-09-05 12:27:29 +02:00
Emil Gydesen
aa27460880 Bluetooth: CCP: Add support for set/get provider name
Add support for setting and getting the bearer provider
name. For now the name will be duplicated by the TBS
implementation, but will be optimizied in the future
so only one copy of the name exists.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-04 11:30:36 +02:00
Benjamin Cabé
0132ea07fb doc: fix spelling errors tree-wide
fix some spelling errors in code comments and Kconfig helps

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-03 17:04:13 +02:00
Emil Gydesen
29f5628c7f Bluetooth: CAP: Add bt_cap_unicast_group_get_info
Add bt_cap_unicast_group_get_info to get information about
a CAP unicast group. For now this just contain the pointer
to the BAP unicast group, which then can be used with
bt_bap_unicast_group_get_info to get information specific
to BAP. The bt_cap_unicast_group_info struct can later be
expanded with any additional information CAP may add.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-03 13:49:54 +03:00
Emil Gydesen
dae29d344a Bluetooth: BAP: Add bt_bap_unicast_group_get_info
Add bt_bap_unicast_group_get_info to get information
about a unicast group. In this first iteration the info
struct only contains the sink and source presentation
delay, but the info struct can easily be expanded on
later to contain more.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-03 13:49:54 +03:00
Emil Gydesen
e42e875777 Bluetooth: BAP: Add validation of presentation delay
BAP section 7.1 states that all streams in a direction shall
have the same presentation delay. To achieve this, we need to
store the configured presentation delay for a unicast group,
so that we can compare with the new presentation delay.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-03 13:49:54 +03:00
Flavio Ceolin
9fdbe5f66e bt: host/classic: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible
array.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-09-03 13:49:31 +03:00
Flavio Ceolin
1441a5a9dc bt: controller/openisa: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible
array.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-09-03 13:49:31 +03:00
Flavio Ceolin
e50da84e74 bt: host/classic: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible
array.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-09-03 13:49:31 +03:00
Flavio Ceolin
bb66123ecd bt: controller/util: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible
array.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-09-03 13:49:31 +03:00
Flavio Ceolin
6f0e9caa9c bt: audio: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible
array.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-09-03 13:49:31 +03:00
Vinayak Kariappa Chettimada
230df77993 Bluetooth: Controller: Relax radio packet pointer assignment deadline
Relax the radio packet pointer assignment deadline assertion
until access address being transmitted. The PDU buffer is
probably only needed just after access address is being
transmitted or received by the radio. This will give some
more breathing room for slow CPUs like in nRF51x SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-09-03 01:36:57 +02:00
Emil Gydesen
2dc358cee2 Bluetooth: ISO: Add check to prevent premature BIG termination
There was an issue where terminating the BIG while in the
ISO connected callbacks could lead to continueing the loops
would cause access to cleared memory.

The simple solution to this is to simply prevent
bt_iso_big_terminate from terminating the BIGs while we are
processing the BIG HCI events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-02 18:42:04 +02:00
Emil Gydesen
258e793cc8 Bluetooth: ISO: Shell: Fix bcode for big_create
The broadcast code was attempting to read from argv[1] instead
of argv[2] that actually contains the broadcast code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-02 18:41:32 +02:00
Emil Gydesen
600010cf5f Bluetooth: BAP: Switch to new USB stack for BAP shell
Modify the BAP shell to use the new USB stack, as the current
one used is now deprecated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-02 12:33:11 +02:00
Emil Gydesen
4059d5b6a7 Bluetooth: CAP: Implement bt_cap_initiator_broadcast_foreach_stream
Implement the function bt_cap_initiator_broadcast_foreach_stream that
allows users to iterate on all BAP streams in a BAP broadcast source.
This can be used to easily get references to other broadcast streams in
the same group.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-02 11:10:22 +02:00
Pavel Vasilyev
427cf0da6a bluetooth: mesh: pb_adv: check SegN in Transaction Continuation PDU
Check that SegN is not 0. SegN = 0 is invalid as the first segment is
sent in Transaction Start PDU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-09-02 11:09:59 +02:00
Emil Gydesen
90e5b7d658 Bluetooth: Shell: Only add broadcast audio val one place
Instead of add BT_UUID_BROADCAST_AUDIO_VAL for either BAP or
CAP, we now only do it one place (in BAP). This can now be done
since the default_source.broadcast_id was recently added.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-01 16:41:05 +02:00
Emil Gydesen
6fe1474225 Bluetooth: Audio: Shell: Store broadcast_id statically
Add a broadcast_id field in broadcast_source so that it can be
lookup later, which is useful for doing broadcast assitant
procedures on a local broadcast source.

The broadcast ID is now created at the same time as the
broadcast source(s), instead at the time of retriving
the advertising data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-01 16:41:05 +02:00
Pavel Vasilyev
fe5b266ddb bluetooth: mesh: pb_adv: check TotalLength against adv buf length
Check that the buffer length of the received advertising data is less
than reported TotalLength in Transaction Start PDU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-09-01 07:44:57 -04:00
Vinayak Kariappa Chettimada
67126ab8aa Bluetooth: Controller: Fix building with Privacy without LE Encryption
Fix building with Privacy feature without enabling LE
Encryption support. This should allow being either Observer
or Broadcaster role with Privacy features.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-29 18:20:22 +02:00
Mark Wang
101add04bb bluetooth: avdtp: fix the checking of rsp_handler
rsp_handler should be used instead of cmd_handler

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-08-29 13:15:19 +02:00
Vinayak Kariappa Chettimada
4277e9ae8b tests: bsim: Bluetooth: Param update implementation review rework
Updated the test with review rework, and added comments.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00
Vinayak Kariappa Chettimada
0d1b4d2ba6 Bluetooth: Controller: Fix prepare pipeline for overlapping events
Fix prepare pipeline processing of overlapping events by
including ticks_at_expire value to uniquely identify
overlapping events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00
Vinayak Kariappa Chettimada
93b951d6fb Bluetooth: Controller: Fix prepare pipeline overflow in observer role
Fix long standing bug in processing resume events that cause
prepare pipeline overflow due to incorrectly enqueueing up
preemptor events as duplicate events in the pipeline where
being aborted before currently active event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00
Vinayak Kariappa Chettimada
c2eb901ea1 Bluetooth: Controller: Introduce prepare deferred feature
Introduce prepare being deferred due to previous events
desire to continue. In such case the deferred prepare param
will have the defer flag set.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00
Vinayak Kariappa Chettimada
8ecb264fec Bluetooth: Controller: Disable connection event continuation on overlap
Disable connection event continuation on overlap with same
connection's next event. This implementation has bugs and
needs to be fixed in subsequent commits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00
Vinayak Kariappa Chettimada
2d732e292a Bluetooth: Controller: Fix stuck forced continuation under throughput
Fix stuck forced continuation of connection event under high
throughput scenario. At near supervision timeout the force
flag is set, but in the next connection event if full
connection interval is used for data transmission and a
subsequent request to abort happens it was not honoured
causing the tx-rx chain to keep continuing until supervision
timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00
Vinayak Kariappa Chettimada
2b49185452 Bluetooth: Controller: Fix window widening on connection update
Fix window widening on connection update to current window
widening periodic at the instant, and use new periodic
window widening for subsequent new connection interval.

Relates to commit 247037bd3e ("Bluetooth: Controller: Fix
incorrect elapsed events value").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00