Commit graph

193 commits

Author SHA1 Message Date
Emil Gydesen
2ab5882e0b Bluetooth: CAP: Add cap_unicast_group API
Adds a new abstract struct for unicast group that is
specific for CAP. The difference between this and the BAP
unicast group, is that the parameters are CAP streams and
thus ensuring that the streams in the group adhere to the
additional requirements that CAP has on top of BAP.

This also adds foreach functions for both CAP and BAP
to allow users to iterate on the streams in the
abstract groups.

Various samples, modules and tests have been updated
to use the CAP struct and API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-06-17 08:20:25 +02:00
Emil Gydesen
615409b349 tests: Bluetooth: Audio: Remove dependency on host mocks
Removes the dependency on the host mocks for LE Audio tests.
This is done by copying the missing mocks for assert into
the audio mocks, and then always including ztest.h.

The inclusion of ztest.h is due to the fact that
arch/cpu.h does not have an appropriate header file for
ztest, and some header files depend on ARCH_STACK_PTR_ALIGN
which is usually defined by those headers in cpu.h. However
ztest.h does define this value as well, and thus needs
to be included always.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-05-14 14:10:02 +02:00
Emil Gydesen
6ddc988c1e tests: Bluetooth: Audio: Fix includes
Updates the includes in a a few files to
avoid including unused header files and include the
ones that are used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-05-01 13:42:37 +02:00
Emil Gydesen
a4f8744ccf Bluetooth: CCP: Client: Add get_bearers
Add bt_ccp_client_get_bearers that will return the bearers of
a client so that the application can always retrieve them if they
do not store them from the discovery callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-09 15:23:07 +02:00
Emil Gydesen
065dca7e92 Bluetooth: ISO: Make setting ISO data explicit
The stack will no longer implicitly set the data path
for ISO channel, and the responsibility for doing that is
now for the upper layers/applications.

This provides additional flexibility for the higher layers
as they can better control the values and timing of the data
path, as well as support removing and even reconfiguring the
data path at will.
This also removes some complexity from the stack.

This commit also fixed a inconsistency in the disconnected
handler. CIS for centrals as well as BIS were still valid
bt_iso_chan channels in the disconnected callback,
but CIS for peripherals were completely cleaned up at this
point. This issue is fixed by moving the disconnected callback
handling to before the code to cleanup the channel for
peripherals.

Since there is a difference in how you remove data paths
depending on the GAP role (central/peripheral), the
iso_info struct type has been expanded to be more
concise of which type of CIS it is.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-19 10:56:57 +01:00
Emil Gydesen
5918427278 Bluetooth: Host: Make bt_le_addr_is_bonded public
Some GATT services and profiles define specific behavior
based on whether the remote device is bonded or not.
The internal function, bt_addr_le_is_bonded, is the
only function to do this, but it was kept internal,
and could thus not be used for those services
without including hci_core.h.

The function has been moved to the public API
so that application can determine if a remote
address is bonded or not, and has been renamed
to not use the bt_addr namespace, but rather the
bt_le.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-13 10:48:19 +01:00
Emil Gydesen
1f26899229 Bluetooth: TBS: Ensure sending notifications
The existing implemented only attempted to send all notifications,
but if host was out of ATT TX buffers the notifications would fail
and the client may miss out on important information, and would be
a spec violation.

This commit refactors notificatios in TBS so that they are always
sent.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-13 10:27:59 +01:00
Emil Gydesen
907261b619 Bluetooth: BAP: Remove GATT_CACHING req for unicast server
The unicast server does not need GATT caching and it was likely
incorrectly added earlier as a dependency.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-14 19:15:57 +00:00
Emil Gydesen
49d9b4cb69 Bluetooth: PACS: Remove BAP infix for pacs_register_param
Since the PACS service is not part of the bt_bap API it should
not use the bt_bap prefix, and instead just be bt_pacs like the
rest of the PACS API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-12 09:41:49 +01:00
Emil Gydesen
446ad0948d Bluetooth: PACS: Test and fix PACS Kconfig combinations
Add unit tests for all possible PACS combinations and
fix issues found.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-10 22:25:47 +01:00
Emil Gydesen
e7b6fd0b4b Bluetooth: PACS: Fix several issues with pacs_register
Fixed the following issues:
1) Missing guard before accessing parameters
2) Fixed bad sizeof when resetting
3) Fixed several bad offsets when removing attributes

Added tests to verify that it works now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-10 22:25:47 +01:00
Emil Gydesen
58605542a6 tests: Bluetooth: PACS: Add unit test of PACS register
Adds initiation unittesting of PACS by testing
the bt_pacs_register API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-10 22:25:47 +01:00
Emil Gydesen
026a2c54ae tests: Bluetooth: Audio: Spring cleanup for audio test files
Add missing and remove unused includes. Fix spelling mistakes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-04 12:03:04 +01:00
Emil Gydesen
9688c2d43f Bluetooth: CCP: Initial CCP Client implemenation
Added initial CCP client implementation that simply
does discovery of TBS on a remote CCP server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-28 09:46:39 +01:00
Emil Gydesen
eff93d268a Bluetooth: BAP: Add common capability check
Instead of having 2 separate and non-equal checks for
capabilities in ASCS and the Broadcast Sink, there is now
a single function in pacs.c that performs the
check.

This reduces code size and makes it easier to maintain.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-15 19:04:31 +01:00
Andries Kruithof
c9a9f0ab08 Bluetooth: Audio: Add tests for the CAP cancel command
This adds unittests and babblesim tests for the CAP cancel command

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2025-01-08 19:10:11 +01:00
Emil Gydesen
e45830893f Bluetooth: CCP: Introduce new CCP API
The CCP API for the Call Control Profile works on top of the
TBS API, and will eventually replace parts of the TBS API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-08 07:50:32 +01:00
Andries Kruithof
b8428df7c6 tests: Bluetooth: CAP: remove compiler warning
There is an unused variable, which may result in a compiler warning.

Since we can not guarantee the value of this variable
we can not test for it, so it is removed.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-12-19 04:19:01 +01:00
Fabio Baltieri
8183c991f8 tests: fix various unit tests warnings
Fix various unit test build warnings, unused variables, set but unused
variables, wrong types etc...

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-12-16 20:48:56 +01:00
Andries Kruithof
d64293b185 Bluetooth: Audio: unittest fails when BT_MAX_CONN = 1
There is a unittest to verify that the distribute broadcast code procedure
is not called with the same peer twice. This test requires a minimum
of two connections, so we disable this test when only 1 connection
can be made

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-12-09 09:50:00 +01:00
Andries Kruithof
6f180e49f9 Bluetooth: Audio: set correct project name in CMakeList.txt
Some of the unittests had an incorrect project name in the
CMakeList.txt file
This is corrected here

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-12-06 22:20:57 +01:00
Emil Gydesen
0ae976166f Bluetooth: CAP: Add broadcast source callback structs
These callbacks are trigger for changes that affect the entire
broadcast source, such as the BIG started and terminated events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-06 15:17:06 +01:00
Emil Gydesen
ab9ee0817d Bluetooth: BAP: Add broadcast source callback structs
These callbacks are trigger for changes that affect the entire
broadcast source, such as the BIG started and terminated events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-06 15:17:06 +01:00
Emil Gydesen
e73bfb92c7 tests: Bluetooth: ASCS: Fix various issues in ASCS unit tests
The ASCS unit tests had various errors after adding support for
dynamic registration.
Several tests did not properly clean up after failure, causing other
tests to fail when they shouldn't.

Moved the register tests to their own file as they should not
do the register in the "before" function.

The test_ascs_unregister_with_ases_in_config_state test was also
removed, as it had both issues and the state that it wants to test
cannot be reached with the current API - It is not possible to
put an ASE in the configured state without callbacks,
and registered callbacks prevents us from calling
bt_bap_unicast_server_unregister to trigger the case as that can
only be done if callbacks are unregistered. Since unregistering
callbacks also puts all ASEs to the idle state, it is not possible
to call bt_bap_unicast_server_unregister for a non-idle ASE.

The testcase.yaml was also missing some Kconfig options to
properly enable the client tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-26 15:43:13 -05:00
Andries Kruithof
bb3bab7a34 Bluetooth: Audio: implement the distribute broadcast code procedure
Implemenation of the distribute broadcast code CAP procedure, as well
as unittesting

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-11-25 21:52:53 +01:00
Emil Gydesen
c4fbe38219 Bluetooth: BAP: Depend on BT_PER_ADV_SYNC instead of select
Change the select of BT_PER_ADV_SYNC and BT_EXT_ADV to
depends on. This is an effort to reduce the use of
select for Kconfig options.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
4c86a5cc8d Bluetooth: BAP: Depend on BT_PAC_{SNK,SRC} instead of select
Modify ASCS and BAP Broadcast sink to depend on the PAC options
instead of selecting them.

Since Kconfig does not support "depends on X if Y",
a select for PAC_{SRC,SNK} is used depending on
ASCS_ASE_{SRC,SNK}.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
c0f86011cb Bluetooth: BAP: Depend on BT_ISO_SYNC_RECEIVER instead of select
The BAP Kconfigs option now depends on
BT_ISO_BROADCASTER instead of selecting it.

This is an effort to reduce the use of select in LE Audio.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
d22c7b0cf2 Bluetooth: BAP: Depend on BT_ISO_BROADCASTER instead of select
The BAP_BROADCAST_SOURCE Kconfig option now depends on
BT_ISO_BROADCASTER instead of selecting it.

This is an effort to reduce the use of select in LE Audio.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
df6b5981bf Bluetooth: Audio: depends on GATT instead of select
Modify the Kconfig options to depend on the GATT
features rather than selecting them.

This is part of an effort to reduce the amount of
selects we use in LE Audio.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Fredrik Danebjer
f970b066d2 Bluetooth: audio: Add possibility to use static broadcast id
Removed the generation of broadcast id inside the stack. It is now up
to the application to generate this by itself. The CAP sample has
been modified to allow either a static broadcast, or a random one.
All of this is handled in the application.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2024-10-25 14:07:25 +02:00
Emil Gydesen
fb6c4427b8 Bluetooth: Audio: Add helpers for broadcast name
Added helper functions to set and get broadcast name
for codec capabilities and codec configs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-23 16:54:28 +02:00
Emil Gydesen
2dc1113a94 Bluetooth: CAP: Add support for handling ASE errors
If we get an error/rejection from the CAP acceptor when
performing the Unicast Audio Start or Stop procedure then
we need to abort the procedure and let the application determine
what the next step is.

This change triggered a corner case when connecting to multiple
CAP acceptors as the CAP initiatior. This was also fixed as part
of this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-23 16:53:44 +02:00
Babak Arisian
7f820d59c0 Bluetooth: Audio: Update SCAN_DELEGATOR dependency to GATT_DYNAMIC_DB
Changed dependency of the BT_BAP_SCAN_DELEGATOR to GATT_DYNAMIC_DB
from 'select' to 'depends on' and solved all loop dependencies
caused by this change.

Fixes #79108

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-10-23 16:53:37 +02:00
Emil Gydesen
cd5a9f62bb tests: Bluetooth: CCID: Add unit testing of CCID
Add unit tests of the CCID functions.
To support these new tests, the GATT mocks need to
support dynamic GATT DB so we can add and remove
a service that contains CCIDs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-15 04:10:28 -04:00
Emil Gydesen
dc97bbd35f Bluetooth: Audio: Rename bt_audio_codec_qos -> bt_bap_qos_cfg
The QoS structure is not related to a codec, but rather a
stream, and should thus not use the "Codec" name.

The BAP and ASCS specs refer to the QoS as
"QoS configuration" several places, so it is an obvious
choice for a name.

Since the structure is defined and used by BAP, the prefix
was changed from bt_audio to bt_bap.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-04 16:34:22 +01:00
Andries Kruithof
a63665438a Bluetooth: Audio: improve broadcast reception stop unittest
Add more parameter checking for the unittests for the
CAP procedure 'broadcast reception stop'

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-10-02 09:59:23 +02:00
Andries Kruithof
8295deb966 Bluetooth: Audio: CAP implement broadcast reception stop
Implement the CAP broadcast reception stop procedures and
add unit tests

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-10-02 09:59:23 +02:00
Emil Gydesen
fa4f2ffc47 Bluetooth: CAP: Add support for doing just disable for unicast stop
The unicast_stop function is changed to primarily do a
BAP disable instead of a release, with optional
support for releasing the streams once they have been disabled.

This also adds unittests for the procedure which also
allow us to remove the invalid param testing from the BSIM tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-01 09:54:04 +02:00
Emil Gydesen
7ef2f81413 Bluetooth: Audio: Add helpers for assisted listening stream
Added helper functions to set and get assisted listening
stream values for codec capabilities and codec configs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-23 10:03:47 +02:00
Emil Gydesen
f57a040808 Bluetooth: BAP: Add bondable requirement for BAP
BAP mandates support for bondable mode for all central and
peripheral roles.

Due to Kconfig circular dependencies, some additional
Kconfig changes had to be made.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-19 18:27:53 +01:00
Emil Gydesen
594bef84f8 tests: Bluetooth: Fix minor issues for bap_base unit tests
An unused variable was removed and some callbacks were
corrected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-11 14:01:46 -04:00
Emil Gydesen
069619a4ee tests: Bluetooth: BAP: Fix BT_BAP_BASE dependency for unit tests
The unit tests needed to enable the hidden Kconfig
BT_BAP_BASE. Instead of adding an additional Kconfig for this,
just enable one of the roles that enable it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-11 14:01:46 -04:00
Fredrik Danebjer
c9da274eb2 Bluetooth: ascs: Add dynamic ASE registration
Added option to set the ASE count through the bap API, making ASE
configuration runtime available. The upper limit of ASEs are still
bound by the Kconfig options set for ASEs.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2024-09-11 07:41:12 -04:00
Henrik Brix Andersen
159f7dbbb1 lib: net_buf: rename header file from zephyr/net/buf.h to zephyr/net_buf.h
Move the network buffer header file from zephyr/net/buf.h to
zephyr/net_buf.h as the implementation now lives outside of the networking
subsystem.

Add (deprecated) zephyr/net/buf.h header to maintain compatibility with old
file path.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-09-07 11:19:05 -05:00
Henrik Brix Andersen
ced80b13bf lib: net_buf: move the network buffer implementation to lib
Move the net_buf implementation from the networking subsystem to a library
as they have no dependency on the networking subsystem.

Network buffers are used in subsystems outside of networking
(e.g. Bluetooth, USB).

Fixes: #36374

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-09-07 11:19:05 -05:00
Emil Gydesen
f500f7c22f Bluetooth: CAP: Fix dependency on BT_BAP_STREAM
The CAP commander used bt_audio_valid_ltv which required
BT_BAP_STREAM to be enabled, but the CAP Commander does not
need BT_BAP_STREAM to be enabled.

Moved the function to audio.c which is always compiled for
the CAP Commander, thus removing the requirement for
BT_BAP_STREAM and the accompanying bt_bap_stream.c file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:16 +01:00
Emil Gydesen
0e4e7628fd Bluetooth: CAP: Add check for streaming state when starting unicast
When calling bt_cap_initiator_unicast_audio_start on a set of streams
that are all in the streaming state we return early with -EALREADY.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-03 10:43:59 +02:00
Emil Gydesen
4279cebcbd tests: Bluetooth: CAP: Ensure that unicast_start works in any state
The unicast_start procedure should take a stream in any state
and put it in the streaming state. Adds tests with streams
in various states.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-03 10:43:59 +02:00
Emil Gydesen
eaf92a1494 tests: Bluetooth: CAP: Initiator unicast start unittests
Adds unittests for the CAP Initiator start procedure, simply
verifying that the procedure works as well as
testing invalid parameters.
This also allows us to remove the invalid behavior checks
from the babblesim test implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-26 17:27:36 -04:00