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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>