Commit graph

359 commits

Author SHA1 Message Date
Lingao Meng 786b9a0ad4 Bluetooth: Host: Add const prefix for UUID
Add const prefix for service uuid and char uuid.

Since Service UUID and Char UUID should not change in the service
definition, they are most reasonably defined as rodata, also for
save some ram footprint.

The field `attr->user_data` type is `void *`, as this PR change
all Service UUID to rodata, so there must add (void *) to avoid warning.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-07 16:16:43 +00:00
Emil Gydesen 3fec3964e0 Bluetooth: CAP: Move initiator/commander common code to cap_common
The CAP Initiator and the CAP Commendar share quite a lot of
functionality in terms of discovery and performing set-based
procedures.

The code for handling most of this has been moved to
cap_common.c to avoid duplicating code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-07 16:14:42 +00:00
Mariusz Skamra 6e856f1038 tests: bsim: pacs: Test bt_pacs_{set, get}_available_contexts_for_conn
This extends existing PACS BSIM tests with the new API function calls.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Mariusz Skamra 1b0e0fbd14 tests: bsim: pacs: Change printk to LOG
Replace combination of printk() to LOG_DBG() to fix the order of the
test execution logs. The printk() is printed immediately, while logs are
buffered, thus the messages from test are printed out before the stack
logs.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Jonathan Rico b68987fe9e tests: Bluetooth: add pipelined ATT write test
This verifies the zephyr host can tolerate a spec violating peer sending
ATT requests without waiting for responses.

It also tests the opposite, that is that the Zephyr host does not
pipeline requests over the air.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-06 17:53:54 +00:00
Emil Gydesen c9daed9712 Bluetooth: BAP: Refactor bt_bap_base
This removes the fixed size bt_bap_base, which provides
2 improvements:
1) The RAM usage of the broadcast sink has been reduced.
   For the Broadcast Sink sample it is a reduction of 120
   octets, but with much better scaling for supporting
   more or larger BASEs.
2) The functions to parse BASEs now support arbitrary sized
   BASEs, where they were previously restricted by our
   local Kconfig options. This allow us to parse any BASE
   from a remote device, without encounting memory issues.
   We are still memory restricted on the devices we
   actually want to sync to.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-06 17:51:47 +00:00
Jonathan Rico 20057b6564 tests: Bluetooth: add missing param to testlib
The lib was refactored, but CI didn't run the tests that used it for
some reason.
A parameter was forgotten.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-12-05 15:09:18 +01:00
Håvard Reierstad c1bbd48659 bsim: Bluetooth: Mesh: fix provision timeout
Adapts the `pb_remote_timeout` test to the updated `bt_mesh_suspend`
API.
Suspension is scheduled with a small delay to allow publications to be
sent before suspending Mesh.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-12-04 14:38:13 +01:00
Håvard Reierstad 1025906331 bsim: Bluetooth: Mesh: Add suspension test
Adds two test-cases; one for suspending and resuming Mesh,
and one for suspending Mesh and disabling Bluetooth before
re-enabling Bluetooth and resuming Mesh.

Both tests checks that periodic publication is stopped during
suspension.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-12-04 14:38:13 +01:00
Alberto Escolar Piedras 41f4826f27 tests/bsim/bluetooth: Reduce sysbuild boilerplate
Reduce the sysbuild boilerplate required for
the nrf5340bsim targets.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-12-02 07:53:11 -05:00
Mia Koen 0bcad09392 bluetooth: mesh: Doc fix Bluetooth mesh to Mesh
SIG has changed Bluetooth mesh to Bluetooth Mesh
Updating zephyr docs accordingly
Leaving out old release notes

Signed-off-by: Mia Koen <mia.koen@nordicsemi.no>
2023-12-01 10:56:18 +00:00
Aleksander Wasaznik 535e003a00 Bluetooth: Use CONFIG_BT_CONN_TX_USER_DATA_SIZE
Replace hardcoded value `8` with `CONFIG_BT_CONN_TX_USER_DATA_SIZE`,
that is `8` but is going to change.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Jonathan Rico 3fe9aaa0f1 tests: Bluetooth: add ATT clopen test
Open. Close. Do it a bunch of times. Cry a lot.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Alberto Escolar Piedras 15b2f7166a tests/bsim/compile: Add option to pass extra cmake arguments
Add an extra optional input to the script which can be used
to pass more options to cmake.
Background: With sysbuild needing to pass extra options is quite
normal. Users would normally want to add options, without necessarily
wanting to change the default cmake_args, so this new options
provides that.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-28 16:45:00 -05:00
Vinayak Kariappa Chettimada 411731f778 tests: bsim: Bluetooth: Enable nrf5340bsim CIS ACL group test
Enable testing CIS ACL group test on nrf5340bsim.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 19:59:13 +01:00
Aleksander Wasaznik 589f3ad904 Bluetooth: testlib: Create testlib/conn.h
This header file declares the functions that rely on `bluetooth/conn.h`.

This collects `testlib/connect.h`, `conn_ref.h` and `conn_wait.h` into one.

Initial documentation for the functions in this file is also added.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-22 14:55:43 +00:00
Pavel Vasilyev 3bc17d1d18 Bluetooth: Mesh: Fix async behavior of Private Beacon Client API
The Private Beacon Client API requires a response argument to allow to
call the API in the asynchronous manner
(https://github.com/zephyrproject-rtos/zephyr/pull/56426).

Because the removal of the EXPERIMENTAL tag for this API was not
released yet, it should be OK to change this API.
The EXPERIMENTAL tag has been removed here:
https://github.com/zephyrproject-rtos/zephyr/pull/64866

Coverity-CID: 330039
Coverity-CID: 330029
Coverity-CID: 329977

Fixes #65336
Fixes #65338
Fixes #65354

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Lingao Meng 5f1c2f199b Bluetooth: Mesh: Make element as rodata
the reason is that the Mesh Profile clearly stipulates that Mesh nodes
cannot change their own element definitions.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-20 09:22:55 +01:00
Lingao Meng 2cd8d40b97 Bluetooth: Mesh: Split Model Structure
Split Model Variables to separate structue.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-16 16:52:14 +01:00
Lingao Meng ab08f34fd9 Bluetooth: Mesh: Make bt_mesh_model as rodata
Since model struct most of member should not change at run time,
so mark as const will be suitable and safely.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-16 16:52:14 +01:00
Lingao Meng e1d4451976 bsim: bluetooth: mesh: Increase Net Transmit Count value on the node
This is to increase probability of reception of responses (Config Status
messages) from the node when the provisioner sends a Set message and the
node response with a Status message at the same time so that the message
collide.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-15 10:01:47 +01:00
Vinayak Kariappa Chettimada 09c69731cd Bluetooth: Controller: Reduce RTN for requested Max Transport Latency
Add implementation to reduce CIG's CIS retransmissions so as
to meet the Host requested Maximum Transport Latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-14 09:46:02 +01:00
Kamil Piszczek ae05c5ea30 tests: bsim: bluetooth: host: privacy: peripheral: test rpa sharing mode
Added a new configuration to the BabbleSim Bluetooth Peripheral Privacy
test to cover the code path for the RPA sharing mode.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-14 09:22:51 +01:00
Kamil Piszczek f6d6742ca1 bluetooth: id: make sharing RPA between adv sets optional
Added a Kconfig option that makes the RPA sharing feature optional. By
default, the Zephyr Bluetooth stack now uses the RPA rotation policy
that was active before the introduction of the RPA sharing functionality
in the following PR:

https://github.com/zephyrproject-rtos/zephyr/pull/55449

The new Kconfig option configures the advertising sets linked with the
same Bluetooth identity to use the same Resolvable Private Address in
a given rotation period. After the RPA timeout, the new RPA is
generated and shared between the advertising sets in the subsequent
rotation period.

When this option is disabled, the generated RPAs of the advertising
sets differ from each other in a given rotation period.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-14 09:22:51 +01:00
Emil Gydesen 89612932b0 tests: Bluetooth: Enable passing CAP AC 441 tests
Enable some previously disabled CAP AC tests for 44.1 KHz,
as they are now passing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-13 09:46:57 +01:00
Mariusz Skamra f80b237e30 tests: Bluetooth: Add tests for ATT automatic security elevation
This adds tests for automatic security elevation and retry on security
errors. This includes two tests:
1. where the security is elevated by the central
2. the security is elevated by security request, so pairing is already
   in progress.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-13 09:45:20 +01:00
Emil Gydesen 9f3858aad9 tests: bsim: Bluetooth: Remove broadcast_source_get_base_inval
Removed the tests for invalid bt_bap_broadcast_source_get_base
parameters and state, as those tests now implemented as unit tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-13 09:41:56 +01:00
Emil Gydesen 175a2f3287 tests: bsim: Bluetooth: Remove broadcast_source_get_id_inval
Removed the tests for invalid bt_bap_broadcast_source_get_id
parameters and state, as those tests now implemented as unit tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-13 09:41:56 +01:00
Aleksandr Khromykh c5ee143d77 Bluetooth: Mesh: no more tinycrypt in ble mesh tfm image
PR allows to get rid of tinycrypt objects from
the final binary of the ble mesh apps based on
PSA TFM crypto.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-08 15:09:50 +00:00
Kamil Piszczek b182c92af5 tests: bsim: bluetooth: host: privacy: peripheral: add RPA check
Modified the BabbleSim test for the Bluetooth test under the
host/privacy/peripheral category. Added the RPA check in the scan
callback context of the scanning tester device to validate if the
DUT advertising address is correct.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-08 15:09:22 +00:00
Kamil Piszczek 069bd8376c tests: bsim: bluetooth: host: privacy: peripheral: test after reboot
Extended the scope of the BabbleSim test for the Bluetooth test under
the host/privacy/peripheral category. The tests ensures correct RPA
advertising after the system a reboot when the Bluetooth identities
are preloaded from the Settings subsystem.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-08 15:09:22 +00:00
Aleksander Wasaznik bfff0f9f4c Bluetooth: Host: Tests: Move testlib to common
This is the first patch with the goal of establishing a common library
for Bluetooth utilities that are commonly used for setup in Bluetooth
Host tests. The ultimate goal is to remove redundant (near) copies of
these utilities and other more ad-hoc solutions.

This patch moves one instance of testlib (from
tests/bsim/bluetooth/host/att/long_read) to
tests/bluetooth/common/testlib and makes it a proper CMake library.

The long_read test is updated to link to the new CMake library.

Further changes and de-duplication will come in later patches.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-07 10:09:33 +01:00
Emil Gydesen 9e58ad31e9 tests: Bluetooth: BAP Broadcast sink RX fail fix
Added an additional check before failing a BSIM test
on ISO error, so that when we stop the broadcast source
(after the sink have received the expected data), lost data
does not trigger a test failure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-07 09:55:14 +01:00
Alberto Escolar Piedras b3447ec068 tests bsim: Add simple tests for broadcast audio source/sink samples
Add an initial test based on the broadcast audio source/sink samples
which runs them together and after waiting for a predefined
amount of time, checks how many audio packets has the
sink received, and if over a threshold, passes the test.

This test can be expanded after to cover more functionality from
these samples.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-06 15:17:15 +01:00
Alberto Escolar Piedras c914c512a0 samples/tests: Remove REQUIRES_FULL_LIBC=y due to LIBLC3
As now this is handled by the LIBLC3 kconfig

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-06 10:10:27 +01:00
Emil Gydesen 9a73cbadc0 tests: Bluetooth: Update BAP broadcast tests to use sync
Update the BAP broadcast tests to use the BSIM sync API
instead of sleeps, to ensure that everything is sent
and receive correctly, regardless of timing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-06 10:03:45 +01:00
Emil Gydesen b2174662d6 tests: Bluetooth: Audio: Add BSIM sync API
Add mechanism and API to sync devices via the babblesim
backchannels.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-06 10:03:45 +01:00
Alberto Escolar Piedras a0ed29409b tests bsim: Add tests for unicast client/server samples
Add a test based on the unicase client/server samples
which runs them together and after waiting for a predefined
amount of time, checks how many audio packets has the
client received, and if over a threshold, passes the test.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-03 08:35:38 +01:00
Carles Cufi 9cf07bbdb5 bluetooth: Rename rpmsg HCI driver and sample to ipc
The existing driver and sample:

- drivers/bluetooth/hci/rpmsg
- samples/bluetooth/hci_rpmsg

are no longer correctly named, since they now use the IPC subsystem to
send and receive data. The IPC subsystem can use RPMsg as a transport,
but that is one of several selectable backends.

I initially wanted to deprecated both the BT_RPMSG Kconfig option as
well as the zephyr,bt-hci-rpmsg-ipc chosen node in Devicetree. However,
this proved to be undoable in the case of the Kconfig option. This is
because it's a choice option, and those have special behavior. In
particular, the only practical way to deprecate would've been to keep
the old Kconfig option outside the choice (much like it's done in this
commit) but then also add a 'depends on !BT_RPMSG' on each of the
remaining choice symbols *except* on the new BT_HCI_IPC one. This, however,
only works correctly for .conf files. If a board instead sets the
default BT_HCI_BUS_TYPE in the Kconfig.defconfig file then the Kconfig
tree parsing would fail, because it'd try to set it to a value
(BT_RPMSG) that is no longer part of the choice.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-11-02 08:32:20 +02:00
Alberto Escolar Piedras 482416db01 tests/bsim bis: Reduce the test verbosity
The test was printing one line for each packet it was sending
by default. That creates a huge log and slows things down.
Instead, let's only print those with verbosity set at 4 or higher.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-31 09:31:42 -05:00
Alberto Escolar Piedras 464435e22b CI bsim workflow: Also run some split BT stack tests
Also run some split BT stack tests on the nrf5340 platform
to test this configuration.

Move the selection of which BT tests are built and run
in each platform to files in the tests/bsim/ folder.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-31 09:31:42 -05:00
Alberto Escolar Piedras 21f755d651 tests/bsim run_parallel: Allow TESTS_FILE with search paths
With TESTS_FILE the user could provide a file with a list of
tests to run.
Now we also support that file containing a mix of
tests and paths in which to search for tests.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-31 09:31:42 -05:00
Alberto Escolar Piedras 10d7b1908e tests/bsim run_parallel: Ignore any script with compile in its name
Note just those called exactly compile.sh

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-31 09:31:42 -05:00
Alberto Escolar Piedras c6f2cca515 tests/bsim/bt bis: Add support for split build with sysbuild
Add sysbuild build files, which allows building this test
both for the targets we could already before
(nrf52_bsim & nrf5340bsim_nrf5340_cpunet)
and also adds support for the a split build with the
nrf5340bsim_nrf5340_cpuapp.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-31 09:31:42 -05:00
Alberto Escolar Piedras a84349280b tests/bsim/bt conn: Add support for split build with sysbuild
Add sysbuild build files, which allows building this test
both for the targets we could already before
(nrf52_bsim & nrf5340bsim_nrf5340_cpunet)
and also adds support for the a split build with the
nrf5340bsim_nrf5340_cpuapp.

Note that when doing a split build the controller is
taken from the hci_rpmsg BT sample, and therefore the
controller configuration in this folder is not used.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-31 09:31:42 -05:00
Alberto Escolar Piedras c5d6ef1487 tests/bsim compile: Add support for sysbuild
Add support for sysbuild builds, which can be selected
by settings the variable sysbuild.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-31 09:31:42 -05:00
Alberto Escolar Piedras e934e49aa9 tests bsim cis: Fix sim_id collision
This test was reusing the sim_id from an l2cap test,
which was colliding with the corresponding l2cap test
when they were run in parallel.
Fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-30 11:35:45 +01:00
Alberto Escolar Piedras b12785f86d tests/bsim/bt bis: Do not call into controller in split builds
Use the HCI layer to update the channel map instead of calling directly
into the controller.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/64441

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-30 09:26:06 +01:00
Keith Packard 565c9376f1 tests: Switch from NEWLIB_LIBC to REQUIRES_FULL_LIBC
Instead of forcing use of NEWLIB_LIBC, select any available complete C
library implementation. Add CONFIG_REQUIRES_FLOAT_PRINTF where needed.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-10-25 08:32:06 +02:00
Andries Kruithof 8b3b8cf2ad Bluetooth: ISO: extend API for setting SDU interval
The BT Core Spec v5.4 allows separate SDU_Interval to
be set on C_To_P and P_To_C directions,
but this is not possible with the existing interface.

This PR splits the interval parameter in the call to
bt_iso_sig_create into one for C_To_P
and one for P_To_C

It also splits the latency parameter into one for
C_To_P and one for P_To_C

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>

Bluetooth: ISO: update UI for extended API

The API for setting the SDU interval and latency have been updated.
This PR also updates the setting of these by the user in the shell
and the iso_connected_benchmark sample

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-23 15:22:10 +02:00