Commit graph zephyr/tests/bluetooth/audio
Author SHA1 Message Date
Arkadiusz Grzelka
3ae8217cf7 Bluetooth: PACS: Fix notify property of Sink and Source PAC
The Sink and Source PAC characteristics set the notify property under
CONFIG_BT_PAC_SNK_LOC_NOTIFIABLE and CONFIG_BT_PAC_SRC_LOC_NOTIFIABLE,
but their CCCD follows CONFIG_BT_PAC_SNK_NOTIFIABLE and
CONFIG_BT_PAC_SRC_NOTIFIABLE.

With only the PAC option set, a client's CCCD write is rejected with
CCC Improper Configuration. With only the location option set, the
property has no CCCD behind it.

Gate the property on the PAC option.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-10-14 08:40:58 +02:00
Emil Gydesen
a4e5cbf41b Bluetooth: Audio: Use bt_att_get_max_ntf_size
Use the public bt_att_get_max_ntf_size function to get the
current notification size, rather than using the
LE Audio specific one.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-09-30 12:42:59 +02:00
Emil Gydesen
d439b0abf2 Bluetooth: CCP: Add server support for bearer URI schemes
Add support for setting and getting the bearer URI schemes supported
list using the CCP API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-09-23 19:17:27 +02:00
Emil Gydesen
4a39357776 Bluetooth: CCP: Client: Add support for read bearer URI schemes
Add support for reading the remote bearer URI schemes supported list.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-09-23 19:15:30 +02:00
Emil Gydesen
ae8212158e tests: Bluetooth: CAP: Unit tests for bt_cap_handover_cancel
Adds unit tests for the function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-09-16 07:28:23 +02:00
Emil Gydesen
1254bf165a Bluetooth: CAP: add subprocedure callbacks for unicast start and stop
The CAP unicast audio start and stop procedures consist of several
subprocedures, and applications may need to know when each of these have
completed, e.g. to reconfigure the unicast group after the streams have
been codec configured but before they are QoS configured.

Add new callbacks to bt_cap_initiator_cb for each subprocedure of the
unicast audio start and unicast audio stop procedures. The callbacks are
only called if at least one request was sent to a CAP acceptor as part of
the subprocedure, so that subprocedures that are skipped because all
streams are already in the requested state do not trigger a callback. To
support this a new subproc_initiated field has been added to the common
procedure struct, which is reset whenever a new subprocedure is set.

The unit tests have been extended to verify both that the callbacks are
called when the subprocedures are performed, and that they are not called
when the subprocedures are skipped, and the BSIM CAP initiator unicast
test now waits for the new callbacks as part of the start and stop
procedures.

Assisted-by: Copilot:claude-opus-4.5

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-09-14 08:42:10 -04:00
Emil Gydesen
b01df6e903 Bluetooth: ASCS: Refactor ASCS to use sys_wq for cp_rsp
Refactor ASCS to use the system workqueue for the control
point notification. This is to ensure that we always send
the notification, even if we may be out of ATT buffers at
any point, but also ensures that the control point notification
is sent before any ASE notifications triggered by that control
point write.

Some refactoring was done to account for the changes when cleaning
up the ASEs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-09-12 07:52:56 -04:00
Emil Gydesen
915d63e193 Bluetooth: ASCS: Add cp_rsp_buf per client
Modify the buffer for control point responses to exist per client.
This is a requirement to later support handling the control point
notifications in the system workqueue, which enables support for
proper handling of notifications in case that we run out of ATT
buffers, as we need to store the response until then, and that we
may have multiple clients connected.

CONFIG_BT_MAX_PAIRED was chosen over CONFIG_BT_MAX_CONN as we only
care about paired (encrypted) connections, and this may scale
better at the cost of doing lookups on address instead of e.g.
bt_conn_index.

The unit tests for ASCS are updated to pass without any
functional changes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-09-04 13:41:33 -04:00
Måns Ansgariusson
b64f70b0e3 bluetooth: Remove default kconfig options
The ASSERT_LEVEL=2 and ASSERT_VERBOSE=y are the default options.
Remove them to avoid future deprecation warnings.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
2026-08-31 13:11:32 -04:00
Emil Gydesen
512d61571b tests: Bluetooth: CCP: Fix tbs_bearers NULL check in get_bearers
The bearers.tbs_bearers will always be non-NULL, and the function
should instead check the individual bearers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-27 12:47:42 -04:00
Emil Gydesen
3e050933a8 tests: Bluetooth: CCP: Removed invalid check for bearers->tbs_bearers
bearers->tbs_bearers is an array and is thus always non-null.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-27 12:47:42 -04:00
Emil Gydesen
01d3e7b538 tests: Bluetooth: CAP: Handover b->u unittests
Add unit tests for the CAP handover broadcast to unicast
functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-25 08:59:49 +02:00
Emil Gydesen
21e609b847 Bluetooth: CCP: Client: Add support for get bearer tech
Add support for getting the remote bearer tech.

Also slightly modified the test of the CCP samples
to properly catch issues (e.g. we disconnect on error,
and now we check for disconnect as the samples may reconnect
and thus have false positives).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-25 08:58:52 +02:00
Emil Gydesen
ce301f954e Revert "Bluetooth: CAP: add subprocedure callbacks for unicast start and stop"
This reverts commit 54737c9fb0b7294d2cc7c396ba04782dd9b72f9b.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-19 18:43:29 -04:00
Emil Gydesen
7ccf8a1dc0 Bluetooth: CAP: add subprocedure callbacks for unicast start and stop
The CAP unicast audio start and stop procedures consist of several
subprocedures, and applications may need to know when each of these have
completed, e.g. to reconfigure the unicast group after the streams have
been codec configured but before they are QoS configured.

Add new callbacks to bt_cap_initiator_cb for each subprocedure of the
unicast audio start and unicast audio stop procedures. The callbacks are
only called if at least one request was sent to a CAP acceptor as part of
the subprocedure, so that subprocedures that are skipped because all
streams are already in the requested state do not trigger a callback. To
support this a new subproc_initiated field has been added to the common
procedure struct, which is reset whenever a new subprocedure is set.

The unit tests have been extended to verify both that the callbacks are
called when the subprocedures are performed, and that they are not called
when the subprocedures are skipped, and the BSIM CAP initiator unicast
test now waits for the new callbacks as part of the start and stop
procedures.

Assisted-by: Copilot:claude-opus-4.5

Co-authored-by: Thalley <2520413+Thalley@users.noreply.github.com>
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-19 17:12:05 +01:00
Emil Gydesen
acd3b540fa Bluetooth: CAP: fix start from QoS
Starting from QoS was not properly tested in the unit tests, and
thus did not catch a bug in the actual procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-19 17:12:05 +01:00
Emil Gydesen
c3de885b73 tests: Bluetooth: ASCS: Enable disabled Latency and PHY tests
Some tests for latency and PHY were disabled pending a bug
report which is no longer valid. Fix the validation functions
and enable the tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-08-11 17:02:13 -04:00
Benjamin Cabé
a119dbf957 build: bump minimum CMake version to 3.28.0
Raise the minimum required CMake version from 3.20.0 (documented as
3.20.5) to 3.28.0, which is satisfied by the CMake 3.28.3 package
shipped in the Ubuntu 24.04 LTS repositories. Ubuntu 24.04 is the
current Ubuntu LTS release targeted by the Zephyr getting started
guide, and by the time of the next Zephyr release, Ubuntu 22.04 will be
within months of its end of standard support. Users of distributions
shipping an older CMake can use the Kitware APT repository or a
pip-installed CMake, as the documentation already suggests.

Raising the floor to 3.28 unlocks a range of modern CMake features for
the build system, among which the cmake_file_api() command (3.27),
file(COPY_FILE) (3.21), block()/endblock() (3.25), and allows removal
of several version-conditional workarounds.

The tree-wide cmake_minimum_required() occurrences in samples, tests
and boards are updated accordingly, together with the documentation
and the sysbuild CMake presets. The IAR C-STAT integration keeps its
own higher requirement (4.1.0).

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-03 15:03:35 -04:00
Emil Gydesen
b4a02e8a7f Bluetooth: Audio: Rename bt_bap_stream_ops fields to align with ASE states
Rename the `configured` and `qos_set` callbacks of
`struct bt_bap_stream_ops` to `codec_configured` and `qos_configured`
respectively, so that the names align with the ASE state machine names
defined by the ASCS specification.

All in-tree users (host implementation, shell, samples and tests) have
been updated accordingly, including the local callback function names
that mirror the operation names.

Assisted-by: Copilot:claude-opus-4.8
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-31 14:56:25 -04:00
Anas Nashif
032e50fb91 tests: bluetooth: rename testcase.yaml to tests.yaml
Rename the test metadata file(s) in this area from testcase.yaml to
tests.yaml so sample and test metadata share one consistent filename
across the tree. Pure rename, no content change.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-03 19:24:17 -04:00
Etienne Carriere
f89bf10662 tests: use <> to include Zephyr headers instead of ""
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.

This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
    `grep -rsl "#include \"zephyr/" tests/`

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-30 06:49:18 -04:00
Emil Gydesen
db44a526c9 Bluetooth: CAP: Ini: Compare cfg/qos in get_next_proc_param
Compare the actual values of the codec configuration
or qos configuration when in the codec configured state,
the QoS configured state or the enabling state.

In the case that the stream is one of the these states
and the parameters to set differ from what is already there,
the appropriate actions should be taken to set the right
values, even if it does not mean an actual state change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-29 13:45:36 -05:00
Emil Gydesen
78f2cdc47c Bluetooth: BAP: Fix bugs with codec configuration
This commit fixes 2 bugs:
1) Bad/missing err return from bt_bap_stream_reconfig
2) Missing handle of codec_cfg fields that are not part of the
ASCS notifcations: path_id, ctlr_transcode, target_latency and
target_phy.

To be able to set these, we need to store them somewhere, and it
makes sense to attach the ep->codec_cfg earlier so that we can store
them in there.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-29 13:45:36 -05:00
Emil Gydesen
f75389213d tests: Bluetooth: CAP: Add unittest for bt_cap_handover_[un]register
Add unittests for the bt_cap_handover_register_cb
and bt_cap_handover_unregister_cb functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-25 06:14:53 -04:00
Anas Nashif
e12bc68df2 tests: fix various typos
Fix various typos under tests/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-17 10:12:27 -04:00
Emil Gydesen
b9d82d19b4 Bluetooth: CCP: Add support for bearer technology
Add support for setting and getting the bearer technology
using the CCP API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-16 17:43:26 +02:00
Johan Hedberg
9cda39e08c Bluetooth: Host: Add bt_conn_drop() API
Add a new bt_conn_drop() function that atomically drops a connection
reference and clears the source pointer in a single step. This mirrors
the recently added net_buf_drop() API and replaces the common pattern:

  bt_conn_unref(conn);
  conn = NULL;

The new API handles a NULL pointer internally, so any guard around it
is unnecessary.

Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-06-10 10:53:36 +02:00
Emil Gydesen
aaccb51555 Bluetooth: ASCS: Introduce ascs.h
Introduce a new header file for ASCS as a step
towards decoupling ASCS and BAP.

BAP has a depdendencey on ASCS, but ASCS does not have one
for BAP, and the code should reflect that.

This is a first step that simply removes the requirement
of the BAP Unicast Server in ASCS with minimal changes.

Tasks to follow up with:
- Remove any depedency on bap.h from ascs.c
- Rename everything from ascs.h from bt_bap to bt_ascs where
  applicable
- Add unit tests specific for BAP unicast server
- Move any BAP-only requirements from ASCS to the BAP unicast
  server implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-02 11:41:03 +02:00
Alberto Escolar Piedras
fba3f901ad tests/bluetooth/audio/cap_initiator: Be sure to free all malloc'ed memory
One of the tests is purposedly overwriting the stream pointer to NULL.
Which means it is lost and can't be free'd.
To avoid a memory leak warning, let's make sure we free it at the end
of each test by keeping the cap_streams ptr in the fixture.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-05-25 18:19:24 +02:00
Alberto Escolar Piedras
ab12d96334 tests/bluetooth/audio/bap_base: Free a malloc variable
To avoid a memory leak warning with valgrind.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-05-25 18:19:24 +02:00
Emil Gydesen
f825a8745f tests: Bluetooth: Audio: apply U suffix to unsigned integer literals
Apply the U suffix to unsigned integer literal constants used in
contexts involving unsigned types (uint8_t, uint16_t, uint32_t,
uint64_t, size_t, etc.) with coding guideline 40  which requires that
"A u or U suffix shall be applied to all integer constants that are
represented in an unsigned type".
In addition to this requirement, this commit also ads U to any unsigned
literal integer for the sake of completeness.

Changes are limited to literal values in assignments, initializations,
comparisons, and for-loop bounds where the context is unambiguously
unsigned.

Assisted-by: GitHub Copilot:claude-sonnet-4.6

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-19 12:53:46 +02:00
Emil Gydesen
f38c0cf7e5 tests: Bluetooth: CAP: Handover u->b unittests
Adds unittests for the handover from unicast to broadcast
APIs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-18 15:13:55 +01:00
Emil Gydesen
a2110e70fa Bluetooth: TBS: Rename features to optional opcodes
The characteristic name and definitions in the TBS spec for
the values are "optional opcodes" instead of "support features".

Additionally, the field is 16-bit, instead of the current 8-bit
in the register parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-18 10:14:52 +01:00
Emil Gydesen
0f653263ae tests: Bluetooth: Audio: Add missing error checks
Add missing error checks for any function calls in the
affected files, as that is required by the Zephyr coding guidelines.

Assisted-by: Copilot:claude-sonnet-4.6

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-15 12:57:17 +02:00
Emil Gydesen
418d6a7210 tests: Bluetooth: CCP: Server: Fix bad check for name
The provided name `inval_bearer_name` were not correctly set
as too long as it was not properly NULL terminated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-05 16:03:28 +01:00
Emil Gydesen
a89f48bcde tests: Bluetooth: Audio: add ARG_UNUSED to unused function parameters
Apply ARG_UNUSED() to unused function arguments as per the Zephyr
coding guidelines

Assisted-by: GitHub Copilot

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-04 22:08:20 +02:00
Emil Gydesen
e60165f45b Bluetooth: TBS: Add enum, move and rename TECHNOLOGY
The technology values defined in tbs.h are actually defined
in assigned numbers under the HFP. They have been moved to
the assigned_numbers.h file, and name to match the placement
in Assigned Numbers. They have been defined in an enum instead
of multiple #define's, to more easily refer to them.

The callback for reading technology was likewise updated to use
the new enum.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-30 13:59:23 -04:00
Emil Gydesen
028634623f Bluetooth: Audio: Add checks for UTF when getting broadcast name
Add checks to verify the valid length of broadcast names
in codec_cfg and codec_cap, both in terms of size in octets,
but also in terms of length in characters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:22:20 +02:00
Emil Gydesen
a259ad8311 Bluetooth: Audio: Add checks for UTF when setting broadcast name
Add checks to verify the valid length of broadcast names
in codec_cfg and codec_cap, both in terms of size in octets,
but also in terms of length in characters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:22:20 +02:00
Emil Gydesen
6548ed48af Bluetooth: CCP: Client: Add support for get bearer uci
Add support for getting the remote bearer UCI.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:21:17 +02:00
Emil Gydesen
7ac6f02ffb tests: Bluetooth: audio: replace implicit integer-to-boolean checks
MISRA-C requires essentially boolean types in control flow.
Convert all if/while conditions using err or ret
as implicit booleans to explicit comparisons:

- if (err)  -> if (err != 0)
- Same rules applied to while statements and ret variable

Also fix typos found during review:
- Fix "Failed to ser security level" -> "Failed to set security
  level" in pacs_notify_client_test.c (4 places) and
  csip_notify_client_test.c (2 places)
- Fix "Bluetoot" -> "Bluetooth" typo in media_controller_test.c
- Fix format/argument mismatch in bap_scan_delegator_test.c:
  add missing `i` argument to FAIL() call

Assisted-by: GitHub Copilot

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 14:22:32 +02:00
Emil Gydesen
a0a513667b Bluetooth: BAP/CAP: Make qos param const
Make the qos parameter of the BAP can CAP APIs const,
as they are now only used as one-time parameters, and not stored.
This also means that any uses of this can place the qos
parameter in the stack, rather than static memory.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-24 12:58:57 +02:00
Emil Gydesen
ce33df667f Bluetooth: CAP: Fix issue with aborting CAP commander procs
Fixed issue where an aborted CAP commander procedure would
never get past bt_cap_common_proc_all_handled and thus never
call the callback with an error, e.g. if the remote CAP
Acceptor rejects a request.

The fix required a significant refactor of the broadcast
part of the CAP commander, as it was fundamentally flawed.
The biggest change is that the implementation now uses both
the receive state notification as well as the write responses
to determine completeneess. Additionally, it also handles
notifications not initiated from our write requests, i.e.
it is now more similar to an event based procedure rather
than a linear one. This also means that when the callbacks
for the start and stop procedures are now called, we have
receive the events (notifications) from the remote CAP
acceptors that they are actually synced (or not synced) to
the broadcasts.

Since the broadcast reception start and stop now waits
for the receive state to be updated, a change in the
Handover implementation was also done.

To test the solution 2 new test cases were added,
and the existing tests were modified to allow for the
new expected behavior.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-16 11:37:24 -05:00
Emil Gydesen
9969e524ad Bluetooth: BAP: Make codec_cfg param const
Make the codec_cfg parameter of the BAP can CAP APIs const,
as they are now only used as one-time parameters, and not stored.
This also means that any uses of this can place the codec_cfg
parameter in the stack, rather than static memory.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:08:12 -04:00
Emil Gydesen
b1c2d5450e Bluetooth: BAP: Make bt_bap_stream.codec_cfg const
The pointer represent the codec configuration
for a stream based on the ASE or broadcast configuration,
and serves as a read-only value. Changing it to `const` makes
this more clear.

Some minor changes were done to existing code to help
support this change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:08:12 -04:00
Emil Gydesen
2b198cf2cc Bluetooth: Audio: Make "foreach" functions consistent
Modify foreach functions in LE Audio to follow the same pattern:
Return true to continue iterating.
Return false to stop iterating.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-03-23 08:53:33 -04:00
Emil Gydesen
57155a5b2b tests: Bluetooth: Audio: Spring cleaning
Add missing header files, remove unused header files,
fix typos and missing static.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-03-20 18:18:55 +09:00
Kai Cheng
9906fdbe31 Bluetooth: Test: add dependency for bt_uuid_from_str unit tests
bt_uuid_from_str() uses hex2bin() from lib/utils/hex.c and
uuid_from_string() from lib/uuid/uuid.c. Add both dependencies
to each test CMakeLists.txt that compiles
subsys/bluetooth/host/uuid.c, fixing link failures on the
unit_testing platform.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-03-19 11:36:39 +00:00
Emil Gydesen
f8b573e7a3 Bluetooth: CCP: Modify get_bearer_uci to use output buffer
Modify bt_ccp_call_control_server_get_bearer_uci to
store the bearer UCI in an output buffer, instead of just
providing the pointer.

The reason for this is to make the result thread safe, and
avoid the user/application having a direct pointer to
internal storage.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-03-16 10:08:29 -04:00
Emil Gydesen
0e07f62e3a Bluetooth: CCP: Fix bad uses of TBS_MAX_PROVIDER_NAME_LENGTH
Several places used CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH
instead of
CONFIG_BT_CCP_CALL_CONTROL_SERVER_PROVIDER_NAME_MAX_LENGTH.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-03-04 14:34:10 +00:00