Commit graph

734 commits

Author SHA1 Message Date
Pavel Vasilyev
ed051cddb9 tests: bluetooth: mesh: add subnet bridge bsim tests
This commit adds the following tests:
- Simple test for bridging table
- Test bridging table state changes
- Test persistence storage of subnet bridge
- Test IV Index update with subnet bridge
- Test network key removal for subnet bridge

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-09-17 05:22:32 -04:00
Ingar Kulbrandstad
709c006b58 Bluetooth: Mesh: Bridge Configuration Client/Server API
Adding documentation and function calles for the API's
in Bridge Configuration Client model and Bridge
Configuration Server model.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2024-09-17 05:22:32 -04:00
Emil Gydesen
eb22e1fc98 Bluetooth: TBS: Make GTBS mandatory
Any places that checked for GTBS is now always enabled
as GTBS is mandatory to support, and the Kconfig option
was removed.

Also removed a duplicate Kconfig option for TBS,
BT_TBS_SERVICE_COUNT, as it was unused.

The other Kconfig option BT_TBS_BEARER_COUNT is used
instead exclusively to set it if needed.

Since GTBS can now exist alone, it must also
support having its own calls and other values.
This means that the GTBS and TBS instances now share
the same underlying struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-17 09:45:48 +02:00
Emil Gydesen
ae6c20d324 Bluetooth: BAP: BA: Replace bools with atomic
Replace the boolean values for the BAP Broadcast Assistant
with an atomic value. This prevents a rare, but possible,
race condition.

The busy flag has been replaced with 3 atomic values which
provide better granularity in error handling, and allows for
some concurrent write and read requests.

To describe the new behavior, the return values in the documentation
has been updated, and the error handling in the API
functions has improved.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-12 13:01:48 -04:00
Théo Battrel
54d1bb73dc Tests: bsim: Use correct compilation folder
If a test was written outside 'app_root' the 'app' path may contain
previous directory ('..') which would lead to the compilation file being
written outside the 'WORK_DIR'.

Fix the issue by checking if the 'app' is inside 'app_root', if it's
not, use the absolute path to the app for creating the 'this_dir'
variable.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-09-12 14:47:49 +02: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
Pisit Sawangvonganan
442a0686fc style: tests: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-09-11 07:40:35 -04:00
Benjamin Cabé
fc9e7962c2 doc: sphinx-lint: fix unbalanced-inline-literals-delimiters
used sphinx-lint to catch unbalanced inline literal markup.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-09-11 07:39:30 -04:00
Emil Gydesen
fa0bbad205 tests: Bluetooth: Run Audio BSIM test on nrf5340bsim
Add support for running the audio BSIM tests on the
nrf5340bsim board.

This expands the tests we run in CI.

To support all tests with the hci_ipc sample for the netcore,
it is updated to support a bit more while still fitting on the
netcore on the nRF5340 series.

The behavior of advertisement seems to differ a little bit,
which required the bap_unicast_server_test.c to update how it
restarts advertisements.

Two broadcast tests that are passing on the nRF52 BSIM is also
failing due an assert. This should be investigated at a later
time.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-09 15:23:57 +03: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
Emil Gydesen
c82adf5db6 tests: Bluetooth: BAP: Use fallbacks for bcast bsim tests
Use fallbacks in codec cfg functions in the BAP broadcast
babblesim tests to avoid unnecessary noise in the logs of
the tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 17:02:47 -04:00
Emil Gydesen
57b35e1047 Bluetooth: TBS: Allow multiple callbacks for client
The TBS client callbacks are just informative so we
provide the information to multiple listeners.

To support this for the long strings, the function
handle_string_long_read was refactored.

This also allows for multiple users of the TBS client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:47 +01:00
Emil Gydesen
94e548120b Bluetooth: BAP: SD: Added missing bad code when using mod_src
When the encrypt state was changed via
bt_bap_scan_delegator_mod_src then we didn't set the bad
broadcast code correctly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:34 +01:00
Emil Gydesen
34fa014682 tests: Bluetooth: Add test for incorrect bcode as assistant
Add a bsim test that verifies the behavior when the
assistant provides an incorrect code to the broadcast
sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:34 +01:00
Emil Gydesen
8b8f727761 Bluetooth: BAP: Add support for reconfiguring unicast group
This allows applications to modify the values set by an
existing unicast group, assuming that none of the streams in
the CIG has been connected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-03 10:43:53 +02:00
Emil Gydesen
2c6dae4364 tests: Bluetooth: Audio: Add -RealEncryption=1 to all bsim tests
Several BSIM tests did not enable -RealEncryption=1.
Since everything in LE Audio effectively requires encryption,
we should enable it, as we have seen a few tests passing before
that shouldn't, because they didn't set -RealEncryption=1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-31 06:43:33 -04:00
Vinayak Kariappa Chettimada
be7445de04 tests: bsim: Bluetooth: central_hr_peripheral_hr for nrf54l15bsim
Enable central HR peripheral HR samples for nrf54l15bsim.
RealEncryption is BabbleSIM is not enabled as nRF54L port
in Zephyr Controller is not yet supported and the test is
also not using security (SMP pairing).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
32f07a5cb6 Revert "tests/bsim: Provisionally disable the nrf54l15 BT tests"
This reverts commit 3d729986e0.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Emil Gydesen
303d0b786f tests: Bluetooth: BAP: Add test to test invalid bcode
Add a babblesim test for testing the behavior when providing
an invalid broadcast code as the broadcast sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-30 11:44:05 -04: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
Nithin Ramesh Myliattil
baa5683e59 bluetooth: BAS: add battery level status char to bas service
Added the battery level status char to bas service
as per bas_1.1 spec. Added BSIM test for BAS service
to test the NTF/INDs of BAS characteristics.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2024-08-20 18:59:14 -04:00
Jan Müller
c910520f4d Bluetooth: Host: Rework enabling of scanner
To make the scanner module more understandable and more streamlined, I
reworked the update mechanism of the scanner. The scanner tracks now the
parameters that were used to enable it and the reason why it is running.
This facilitates state logic and allows other modules to "start the
scanner", altough it is already running.
This is mostly a refactoring and not a functional change.

Added a test to verify the behavior.

Signed-off-by: Jan Müller <jan.mueller@nordicsemi.no>

add to task
2024-08-20 14:54:25 -04:00
Chang An
e8db417a00 LE Audio: add conn parameter for bt_vcp_vol_rend_cb
Add conn parameter to status/flags callbacks of bt_vcp_vol_rend_cb
to differentiate between remote and local changes.

Signed-off-by: Chang An <chang.an_1@nxp.com>
2024-08-20 14:45:35 +02:00
Pisit Sawangvonganan
b7d55d8ec6 style: tests: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-20 10:33:51 +02:00
Andries Kruithof
1f1241af8f Bluetooth: Audio: tests: remove code duplication
The function interval_to_sync_timeout was copied several places.
Made it into a common function and removed duplicate code

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-08-19 10:02:11 -04:00
Andries Kruithof
98e7362891 Bluetooth: Audio: CAP: Remove unused globals from babblesim test
The CAP acceptor test had some unused globals, which are removed

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-08-19 10:02:11 -04:00
Andries Kruithof
b7f5e7eb9e Bluetooth: Audio: CAP: refactoring babblesim test for acceptor
The babblesim tests for the CAP acceptor test have been refactored
for improved readability

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-08-19 10:02:11 -04:00
Jonathan Rico
6fa6c4c256 Bluetooth: L2CAP: Downgrade user_data API error to a warning
When user_data is not zeroed-out, the API returns an error. Downgrade
the API error to a warning log instead.

Introducing this check (#76489) broke a few PTS tests, as user_data is
not initialized by `net_buf_alloc()`. Doing so is in discussion:

https://github.com/zephyrproject-rtos/zephyr/issues/77088

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-19 09:55:49 -04:00
Emil Gydesen
6956674201 tests: Bluetooth: BAP: Add -RealEncryption=1 to enc broadcast test
The shell script did not provide -RealEncryption=1 which then never
really did proper encryption, which is the point of the test.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-16 14:07:15 -04:00
Jonathan Rico
043de7da2a Bluetooth: Host: Add disconnection during TX fragmentation test
Verifies that we don't leak connection references when the peer goes out
of range whilst we are fragmenting and sending data to the controller.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-16 16:29:41 +01:00
Théo Battrel
f3dcaaee35 Tests: Bluetooth: Add another ISO frag test
This test create a setup where an ISO broadcaster will send fragmented
data and get stopped after sending the first fragment and repeating that
operation multiple time to verify that buffers are not leaked.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-08-16 11:20:14 +01:00
Andries Kruithof
363133e62c tests: Bluetooth: Allow BT_BAP_BASS_MAX_SUBGROUPS larger than 1
The BAP scan delegator test does not compile when
BT_BAP_BASS_MAX_SUBGROUPS is larger than 1.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-08-16 11:19:58 +01:00
Henrik Brix Andersen
69fe9b0c50 net: buf: remove use of special putter and getter functions
Convert users of net_buf_put() and net_buf_get() functions to use
non-wrapped putters and getters k_fifo_put() and k_fifo_get().

Special handling of net_bufs in k_fifos is no longer needed after commit
3d306c181f, since these actions are now
atomic regardless of any net_buf fragments.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-08-16 09:55:11 +02:00
Luis Ubieda
75f70c4636 tests: bsim: bluetooth: Refactor MTU Update test
To isolate Central and Peripheral in two separate builds.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-08-15 10:17:13 +01:00
Aleksander Wasaznik
8b4907ee97 Bluetooth: bsim: deduplicate compile scripts
Some tests have a compile script for that test alone, named
`_compile.sh` or `_build.sh`. These scripts are useful for developers to
avoid compiling the world. But these scripts were not run in the CI.

These scripts were previously not suitable for running in the CI because
would put the artefact in the source directory, but this is no longer
the case, and the CI could run these scripts now.

This commit renames any `<test>/test_scripts/_compile.sh` and
`<test>/test_scripts/_build.sh` to `<test>/compile.sh`. The test runner
in CI will ignores any file named `compile.sh`, so there is no need for
a underscore prefix.

This fits into and extends the hierarchical structure of `compile.sh`
chain that starts at `:/test/bsim/compile.sh`, the CI build script tree.

The newly moved scripts now become a part of the build script tree,
called from a `compile.sh` where a duplicate set of build commands was
before. The sub scripts use `run_in_background` to preserve the
parallelism as it was before this change.

This removes an error-prone duplication and makes the CI test all the
build scripts.

Tests that did not have any compile script are not given one for now.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-08-14 12:33:53 -04:00
Emil Gydesen
ba62c8d876 Bluetooth: BAP: Support setting different values per dir in CIG
The interval and latency for a CIG are set for each direction now,
allowing applications to use e.g. 10ms for sink ASEs and 7.5ms for
source ASEs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-14 09:42:16 +02:00
Jonathan Rico
e489ec2b95 Bluetooth: L2CAP: Add re-assembly stress test
Add a test that verifies no resources are leaked when re-assembling L2CAP
PDUs over an unreliable channel (ie. lots of disconnects).

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-12 10:10:48 +02:00
Jonathan Rico
76ece09cb4 Bluetooth: Host: Add ISO HCI fragmentation test
Purpose is to verify we don't fragment ISO SDUs when they should fit the
controller's MTU.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-08 06:07:08 -04:00
Guru Mehar Rachaputi
f20ac87536 tests: bsim: set log level from command-line argument
Implementation to take command-line arguments to set log level in run
time for bsim module. Set default log level if no log level is passed
at runtime

Signed-off-by: Guru Mehar Rachaputi <gurumeharrachaputi@gmail.com>
2024-08-05 10:16:36 +02:00
Vinayak Kariappa Chettimada
bc4442ece7 tests: bsim: Bluetooth: Host: Fix RPA expired old time value
Fix RPA expired old time value used for rotation timeout
validation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-02 13:40:59 +02:00
Jonathan Rico
08706f98bc Bluetooth: adapt l2cap/userdata test
Modify the test so it checks that user_data is used and then cleared by
the stack.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-01 16:49:37 +01:00
Jonathan Rico
11b3aa1f1f tests: Bluetooth: Add multi-central robustness test
This test's purpose is to verify we (as a peripheral) don't leak resources
when communicating with multiple centrals that connect and disconnect
intermittently.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-01 12:38:36 +02:00
Emil Gydesen
1b83555d4c Samples: Bluetooth: CAP Initiator broadcast support
Add broadcast support to the CAP initiator sample.

This adds new sample-specific Kconfig options to help
select the right Kconfig options based on whether
unicast, broadcast or both is being used.

This also moves common TX functionality
to cap_initiator_tx to reuse the same TX thread
and functionality.

Finally there is a babblesim implemented for
the broadcast. There is not broadcast support for the
CAP acceptor sample yet, so this test only verifies that we
get the TX complete events from the controller.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-01 08:53:08 +01:00
Emil Gydesen
38d09af445 Bluetooth: BAP: Scan delegator add src without PA sync
Modify the bt_bap_scan_delegator_add_src to take an address and
a sid instead of a PA sync object, so that the scan delegator
can add a source without syncing to the PA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-28 07:31:06 +03:00
Emil Gydesen
72d98692dc tests: Bluetooth: Add encrypted BAP broadcast test
Added test to test encrypted broadcast

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 20:49:25 +03:00
Emil Gydesen
8be6db67fc Bluetooth: ISO/BAP: Refactor BIS bitfield
Refactors teh BIS bitfield values used for ISO
and BAP.

Previously BIT(1) meant BIS index 1, which was a Zephyr choice
in the early days of ISO, as the BT Core spec did not use
a bitfield for BIS indexes.

Later the BASS specification came along and defined that
BIT(0) meant BIS index 1, which meant that we had to shift BIS
bitfields between BAP and ISO.

This commit refactors the ISO layer to use BIT(0) for Index 1 now,
which means that there is no longer a need for conversion
between the BAP and ISO layers, and that we can use a value
range defined by a BT Core spec (BASS).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 15:19:46 +03:00
Vinayak Kariappa Chettimada
04e3d0081b Bluetooth: Controller: Fix Advertising PDU memory allocation
Fix Advertising PDU memory allocation for redundant Periodic
Advertising related PDU allocations. The buffer count
related to Periodic Advertising was included twice.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-27 15:09:39 +03:00
Anas Nashif
83bd3658c3 tests: do not get ZEPHYR_BASE from ENV
find_package() already deals with finding ZEPHYR_BASE, so do not rely on
it being set in ENV, use the variable directly adter find_package() was
called.

Fixes #75387

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-07-11 13:09:53 -04:00
Jonathan Rico
4afe745a1d Bluetooth: host: Add lower bound for CONFIG_BT_BUF_ACL_RX_COUNT
See comment above assert for more.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-10 11:47:26 -04:00
Jonathan Rico
ff5c577aa8 tests: Bluetooth: Add ACL re-assembly test
This tests shows that there is a problematic buffer configuration.

The host locks up when `CONFIG_BT_BUF_ACL_RX_COUNT` is smaller or equal
to the number of connected peers, and all those peers send an L2CAP PDU
that needs re-assembly at the same time.

Although this seems far-fetched, this bug has been observed in a
real-life situation on actual hardware.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-10 11:47:26 -04:00