Commit graph

517 commits

Author SHA1 Message Date
Emil Gydesen 81a1826e13 tests: bsim: Bluetooth: CSIP: Increase EXECUTE_TIMEOUT to 30
Some of the CSIP tests take a while to run given the number of
devices, and some of them started to fail in CI because of a
timeout, so we increase the EXECUTE_TIMEOUT a bit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-01 17:00:47 +01:00
huajiang zheng 3d9f76b8e5 Bluetooth: Host: add unregister connection callback function
[Description]
tests: shell: Restart bt will register the same connection callback twice.
Callback next node point to itself, when link established callback function
loop infinitely.
[Fix]
Unregister the previous callback to avoid register repeatedly.
[Test]
After bt init/disable times, create connection successfully.

Signed-off-by: huajiang zheng <huajiang.zheng@nxp.com>
2024-02-01 16:05:38 +01:00
Luis Ubieda 7e5b2a79fc Tests: Bluetooth: Host: Added Test for extended Advertisements
Where extended advertising is restablished through the use of
recycled() callback, registers over bt_conn_cb_register().

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-02-01 14:31:27 +00:00
Andries Kruithof b7078286d2 Bluetooth: audio: test: add test for long write
Added a test for long write, long read, and notifications

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-02-01 14:37:40 +01:00
Stine Åkredalen fcb8fa7b02 tests: bluetooth: mesh: blob test bugfix
Added missing end marker to test instance

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2024-02-01 10:28:53 +00:00
Emil Gydesen 8459560448 tests: bsim: Bluetooth: CAP Commander Change Volume Offset
Adds bsim test of the CAP Commander Change Volume Offset
procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:35:17 -05:00
Emil Gydesen 029afad6c1 Bluetooth: CSIP: Add bt_csip_set_member_unregister
Add support for unregistering a CSIS as the CSIP set member.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:34:27 -05:00
Emil Gydesen 01d0f1a566 Bluetooth: PBP: Fix parsing and return issue with bt_pbp_parse_announcement
bt_pbp_parse_announcement was defined as uint8_t return value function,
but returned errno values, so it was modified to return an int instead.
The return values are also now more granular and documented.

The function also triggered a coverity issue with the way that it
parsed the data->data, as it would be marked as tainted. This should
be fixed by using the net_buf_simple API, which also improves on
some other parts of the code.

Finally the meta argument for the function was changed from an
unknown sized buffer, where the caller somehow had to know the
size of the metadata before calling the parsing function, to
an output pointer. This also omits the requirement for the
caller to always copy the metadata, where now it just
gets a pointer to the metadata in the bt_data struct. The application
can now always decide whether to continue to parse the metadata or
to copy it, using the pointer and the return value of the function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:33:56 -05:00
Stine Åkredalen d5b68bad12 tests: Bluetooth: Mesh: add proxy solicitation bsim test
* Test that beacon is received after solicitation
* Test for replay attack

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2024-01-31 10:34:06 -06:00
Vinayak Kariappa Chettimada daf7c80c15 tests: bsim: Bluetooth: CAP broadcast AC testing updates
Update testing of the Audio Configurations from the BAP
spec using the CAP API.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-31 13:45:23 +01:00
Alberto Escolar Piedras 084f3cfc51 tests/bsim build: User kconfig option to set warnings as errors
Use the kconfig option COMPILER_WARNINGS_AS_ERRORS instead
of passing the compiler option directly to the build.
That allows us to do whatever needs to be done in cmake to ensure
warnings are treated as errors.

Also handle better options and paths with spaces on them.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-29 14:27:27 +01:00
Alberto Escolar Piedras cf6a3824a0 tests/bsim host/privacy/peripheral: Minor fixes to allow equality check
Minor fixes in this test script to:
* Start with an empty flash even if there was a left over flash file
  on disk
* Not overwrite the simulation activity from the first part of the test
  in the second part of the test, to allow looking into the
  traffic and to allow rerunning the test in check mode, to ensure
  there is no radio activity changes when another change is done.
* Set the simulation id to something more unique (it was just
  "peripheral" before which is too easy to be repeated in another
  test)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-24 21:19:57 +00:00
Jonathan Rico 6fa5d1e6a5 Bluetooth: L2CAP: fix net buf frags handling
Fix the handling of buffers with fragments. What seems to have been
broken is the metadata reference that was not passed to the next frag in
the chain.

Add a test to regression too.

The main user of this is IPSP.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-24 14:56:16 +01:00
Vinayak Kariappa Chettimada d1e4c17e6d tests: bsim: Bluetooth: Mesh: Adjust timeout for Adv Extensions use
Adjust mesh test timing and timeout value for Advertising
Extensions use/fix in Zephyr Controller. The scanning in
Zephyr Controller is delayed when using extended scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-24 10:44:12 +01:00
Anders Storrø 93a6ee501a Bluetooth: Mesh: Add artificial beacon delay
After removing 20ms in advertiser, all subnetwork beacons are sent as high
dense packet of frames with minimal distance between them. That might
cause collisions if beacon interval on devices will coincide.

This commit adds an artificial delay between each subnet advertsing
beacons.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-01-23 10:02:00 +01:00
Emil Gydesen b857ef7f83 Bluetooth: BAP: Add ISO state callbacks
Add callbacks to the stream objects that reflects the
state of the isochronous channel. The connected callback
is called when the isochronous channel is connected, and
similarly the disconnected callback is called when it is
disconnected.

There is a special case for unicast, where if the ACL
disconnects first, then we won't get a ISO disconnect
callback. It should be assumed that the isochronous channel
is no longer valid when the BAP stream enters the idle state,
i.e. when the "released" callback is called.

The purpose of the new callbacks is to provide additional
information to the application. Especially the unicast client
can use this to determine when the stream_start function
can be called again, as there can only ever be 1 outstanding
CIS connection request at a time, but there can be multiple
GATT requests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-22 12:59:11 +01:00
Kamil Piszczek c16d9699a3 tests: bsim: bluetooth: host: gatt: general: improve conn ref handling
Improved the connection reference handling in the BabbleSim test
project in the Bluetooth Host category.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2024-01-22 10:32:41 +00:00
Kamil Piszczek a369eb7b36 tests: bsim: bluetooth: host: gatt: add authorization callback API test
Added a new BabbleSim test that validates the authorization callback API
from the Bluetooth GATT header.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2024-01-19 16:08:46 +01:00
Pavel Vasilyev 981c79b7ce Bluetooth: Mesh: Drop explicit support for Bluetooth Mesh 1.0.1
Bluetooth Mesh Protocol 1.1 is backward compatible with Bluetooth Mesh
Profile 1.0.1, therefore the stack can still be qualified for 1.0.1 if
needed. But explicit support for both versions requires additional
maintenance efforts and doubles the CI time. To make the stack
qualifiable for 1.0.1, the one needs to remove Private Beacons reception
and compile out SHA256 algorithm support.

What is changed:
- Removed `CONFIG_BT_MESH_V1d1` option.
- Removed `transport_legacy.c` which was using 1.0.1 implementation. The
  new transport layer has new SaR logic that should still be possible to
  qualify for 1.0.1.
- Removed the legacy transport Kconfig options. They are superseded by
  the new transport Kconfig options.
- Tester app: `overlay-mesh-v1d1.conf` is merged into
  `overlay-mesh.conf`.
- Removed BabbleSim tests for 1.0.1.
- Updated documentation.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Emil Gydesen c999e4600d tests: Bluetooth: CAP: Add test of change volume procedure
Add testing of the CAP Commander Change Volume procedure
in BSIM.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 12:00:09 -05:00
Alberto Escolar Piedras 53c121381f CI bsim workflow: Add UART tests to the bsim workflow
Add new workflow steps to the babblesim workflow to run
also the UART tests on the nrf52_bsim.
This commit:
* Enables the single device tests (which we may
move to the normal twister workflow once we fix the
requirement for a fixture)
* Adds as a placeholder the infra for multidevice tests.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-16 14:55:07 -05:00
Bi Jian 06fa287d45 Bluetooth: Audio: Update audio location definitions
The meaning of bit0 in the audio location bitmap will change to
mono audio, so we update the audio location macro and releated
test cases.

Refer to BT SIG ES-22266.

Signed-off-by: Bi Jian <bi_jian@qq.com>
2024-01-16 14:27:40 -05:00
Emil Gydesen fd3e334539 tests: Bluetooth: Audio: Fix channel allocation
The channel allocation was incorrect when setting up multiple
streams to a single device, in which case we should apply
individual bits to each stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:31:12 -06:00
Jonathan Rico 38c39af4df Bluetooth: L2CAP: Prepend SDU header immediately
Previously it was not always possible to prepend the header.

It was not possible if the application neglected to reserve the space
for headers.  This is bad because it forces a buffer segment allocation
even if the buffer had enough room for the headers. E.g. a payload of 10
bytes in a netbuf of 30 bytes would have been segmented.

We now explicitly reject the buffer if it does not have the headroom.

This allows us to do a nice thing; simplify L2CAP segmentation.

We convert the SDU from the application into a PDU payload, by
prepending the SDU header, i.e. the SDU length in the original buffer.

This PDU payload is ready to be chunked into PDUs without having to keep
track of where in the SDU we are. This has the effect of removing a
bunch of logic in the segmentation machine.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-16 11:29:43 +00:00
Aleksandr Khromykh 4e7d64b1b4 Bluetooth: Mesh: enable access responses randomization
Enable by default the access layer responses random delays.
Commit also adapts all mesh models, samples and
babblesim tests to use random delay functionality correctly.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-01-16 11:29:20 +00:00
Jonathan Rico 3e1a82226d tests: Bluetooth: use unique IDs for l2cap bsim tests
If $BASH_SOURCE is the empty string, then those two tests end up with
the same simulation ID. That's not a good time.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-12 09:33:44 -06:00
Emil Gydesen baf8c47473 tests: bsim: Bluetooth: GMAP broadcast AC testing
Add testing of all GMAP broadcast audio configuration with
GMAP broadcast presets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-11 16:13:00 +00:00
Emil Gydesen 79af154ae7 tests: bsim: Bluetooth: CAP broadcast AC testing
Add testing of the Audio Configurations from the BAP spec using
the CAP API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-11 16:13:00 +00:00
Emil Gydesen 9310b34b44 tests: bsim: Bluetooth: BAP: Refactor bap_test_stream
Refactor the bap_test_stream struct and rename to audio_test_stream
so that it can be used by CAP as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-11 16:13:00 +00:00
Piotr Golyzniak a27ae686d3 tests: bsim: add testcase.yaml to bsim bis test
For better manageability of tests building, add possibility to build
BabbleSim Bluetooth BIS tests by Twister.

Signed-off-by: Piotr Golyzniak <metody159@gmail.com>
2024-01-10 12:10:58 +01:00
Alberto Escolar Piedras 009fcd70e5 tests bsim bt: Add basic connection test with HCI UART async controllers
Add a basic connection test between two devices,
in which the controllers are in separate nrf52_bsim devices
connected over UART to the devices running the host+app.
The controllers are running the HCI UART async sample.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-10 10:01:37 +01:00
Alberto Escolar Piedras 398e4b121a tests bsim bt: Add basic connection test with HCI UART controllers
Add a basic connection test between two devices,
in which the controllers are in separate nrf52_bsim devices
connected over UART to the devices running the host+app.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-10 10:01:37 +01:00
Emil Gydesen 3099520921 tests: bsim: Bluetooth: BAP Broadcast update to 2 bis
Update the bsim test for the BAP broadcast to use 2 bis.
This tests a larger part of the code, and also verifies
that we can send and receive on 2 BIS without any ISO errors.

This requires the ADV interval to be a multiple of ISO interval
- 10ms, so the advertising interval has been set to 80ms.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-09 09:59:42 +01:00
Daniela Andreea Dumitrache 3bfb2e3ab2 Bluetooth: Audio: Add implementation for PBP and dedicated sample apps.
PBP API allows sources to create a Public Broadcast Announcement.
PBP API to parse a Public Broadcast Announcement.

public_broadcast_source application starts extended advertising and
includes a Public Broadcast Announcement. The advertised broadcast
audio stream quality will cycle between high and standard quality.

public_broadcast_sink application scans for broadcast sources and
synchronizes to the first found source which defines a Public Broadcast
Announcement including a High Quality Public Broadcast Audio Stream
configuration.

Add bsim tests for Public Broadcast Profile APIs.

Add shell implementation for Public Broadcast Profile APIs.

Signed-off-by: Daniela Andreea Dumitrache <danielaandreea.dumitrache@nxp.com>
2024-01-09 09:59:23 +01:00
Håvard Reierstad 9c3ca4573a bsim: Bluetooth: Mesh: Add gatt suspension test
Adds two test-cases to `test_suspend.c`, both checking that gatt
advertisement is stopped when suspending Mesh, and that is started again
when Mesh is resumed.

The first test-case involves suspending and resuming Mesh, and
the second test-case involves suspending Mesh and disabling Bluetooth,
then re-enabling Bluetooth and resuming Mesh.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-01-08 13:21:58 -05:00
Håvard Reierstad 0480367d77 bsim: Bluetooth: Mesh: refactor suspend test
Renames tx to DUT and rx to Tester to clarify roles in test.

Re-uses the same body for suspend/resume and suspend/disable/resume
for DUT with a parameter to toggle disabling BT.

Re-uses the same Tester config in both existing test-cases as the
previous configs were duplicates.

Updates the dut suspension status in the message handler.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-01-08 13:21:58 -05:00
Håvard Reierstad ee337087fa bsim: Bluetooth: Mesh: extract common adv logic
Extracts logic related to waiting for packets from
`test_advertiser.c` and `test_beacon.c` to use in a sync mechanism.
Introduces a sync mechanism in bsim with the functions
`bt_mesh_test_send_over_adv` and `bt_mesh_test_wait_for_packet`

Extracts gatt-related logic from `test_advertiser.c` into a separate
file so it can be re-used.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-01-08 13:21:58 -05:00
Aleksandr Khromykh b4dc12b42b tests: Bluetooth: Mesh: optimize proxy beacon test
Emitting network beacons in parallel to proxy functionality
causes collisions. The commit disables network beacons and
allows the test scenario to be more precise.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-01-08 14:17:04 +01:00
Jonathan Rico 7127c2a733 tests: Bluetooth: Add debug options to host/l2cap/stress
Enable quality-of-life kconfig options.
Add destroy callbacks to track lifetime of app buffers.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-05 14:30:18 +01:00
Théo Battrel ba80bc7134 Tests: Bluetooth: Fix conn_stress compilation warn
On newer GCC version warnings were emitted because of a `memcpy`. The
size parameter was larger than the source's size because it was using
the size of the destination, which was a `bt_uuid_128` when the source
is a `bt_uuid_16`.

Fix the issue by creating a new variable for CCC UUID in both the
central and peripheral code. The variable need to be static because the
discover parameters must remain valid until the start of the discover
attribute callback.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-12-27 16:07:46 +00:00
Anders Storrø 7d373c7c28 Bluetooth: Mesh: Fix broken proxy adv test
Relaxes test requirements for proxy_adv_multi_subnet_coex
to resolve failing test on CI.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-20 11:48:18 +01:00
Aleksandr Khromykh ac4cfe9880 Bluetooth: Mesh: remove 20ms tx delay in adv bearer
The recommendation to have 20ms is fair for two
consecutive messages over a single bearer. When mesh
sends two messages it can be interpreted as two
bearers working in parallel. No need to keep
an artificial 20ms delay for that. Delay was
removed and all related bsim tests were fixed.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-12-19 16:20:36 +01:00
Aleksandr Khromykh 8d51a1dac5 tests: Bluetooth: Mesh: relax beacon test time conditions
Some beacon tests have strict time conditions and depend
on randomization interval that doesn't guarantee test pass.
This change fixes strict conditions.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-12-19 16:20:36 +01:00
Emil Gydesen 8df987935b Bluetooth: MPL: Add track position notifications during seeking
When seeking the media player should notify clients about the
track position change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-19 08:51:21 +01:00
Emil Gydesen cda5e58aa5 Bluetooth: CAP: Commander discovery support
Implement the CAP Commander discovery function.

Adds support for it in the shell.

This includes initial babblesim and unit testing as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-19 08:50:40 +01:00
Anders Storrø f70929a8f1 tests: Bluetooth: Mesh: Add proxy adv coex test.
Adds test that verifies correct Proxy advertisement behavior for
a device where the Proxy adv requirements changes over time,
both for single and multiple subnets.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-18 09:29:41 +01:00
Anders Storrø 6c67ab3a63 Bluetooth: Mesh: Refactor proxy adv
Refactors proxy advertising implementation to allow fair sharing of
advertising resources between all subnets.

In the new implementation, each subnet is agnostic to any other subnet
that might have active proxy advertisement work. When proxy
advertisement is triggered, the implementation will first check how
many subnets that has active work. If there are more than one active
subnet, a maximum timeslot will be calculated to ensure that all active
subnets get access to the medium. The implementation will then poll
the next eligible subnet for a proxy advertising request. If the
duration of this request exceeds the maximum timeslot, the duration
for the next advertisement will be set to the maximum value.

If a proxy advertisement for a subnet is interrupted by other
advertising activity, the implementation will now ensure that the
interrupted proxy adv continues from the point where it was
interrupted so that the subnet gets to utilize the entire allocated
timeslot.

This PR also alters the priv_proxy_net_id_multi Bsim test to align
with the refactored proxy advertising scheme.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-18 09:29:41 +01:00
Pavel Vasilyev fe70e50d41 Bluetooth: Mesh: Added support for randomly delaying publications
The section 3.7.3.1 of the mesh specification recommends to delay
a message publication in certain cases:
- at power-up or upon state change for a time between 20 to 500 ms
- for periodic publications for a time between 20 to 50 ms

This change implements this recommendation by adding the
`CONFIG_BT_MESH_DELAYABLE_PUBLICATION` Kconfig option which enables
the randomization code and by adding the `bt_mesh_model_pub.delayable`
bit field which allows each model decide whether the publications
should be delayed for this model or not.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-12-18 09:29:24 +01:00
Jonathan Rico a05a47573a Bluetooth: ATT: Internalize ATT PDU TX pool
Why?
- metadata is easier to manage as an array + index
  - less error-prone -> less memory-management bugs
- we can. because of the previous refactor
- PDU allocations are more predictable
- ATT buffer size can be optimized by app
- isolates ATT from the rest of the ACL users
  - decouples ATT PDU size from e.g. SMP w/ LESC

Drawbacks:
- higher memory usage
- kconfig change

The higher memory use is only temporary, as this will be followed-up
with more refactors that should bring it back down.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-15 17:14:56 +02:00
Mariusz Skamra daa7a99b8c tests: bsim: has: 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-14 19:07:28 +00:00
Mariusz Skamra 0b8b67e346 tests: bsim: has: Clean up the #ifdef
Use if(IS_ENABLED(...)) {...} instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-14 19:07:28 +00:00
Anders Storrø 25d44a828d Bluetooth: Mesh: Rename prov_dev->provisionee
Renames "prov device" references and options to
"provisionee" to align implementation with Mesh
Protocol specification v1.1, section 5.4.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-13 13:57:46 +01:00
Jonathan Rico 2dab5dd0a0 tests: Bluetooth: add babblesim connection stress test
This is supposed to stress the host buffer and metadata handling.

It is not really testing any particular thing, ie. the pass criteria is
just that each peripheral can send and receive a fixed number of GATT
notifications without any device crashing or locking up.

Original version by Ahmed Moheib (from cloud2ground).

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-12-12 21:43:45 +02:00
Mariusz Skamra 3b4ce7f8e9 tests: bsim: gatt: ccc_store: Reproduce the subscription lost issue
Zephyr by default renews the characteristic value subscription on every
reconnection. If the ACL is disconnected in the middle of this
procedure, all the subscriptions waiting to be renewed are removed, even
if the device was successfully subscribed already.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:32:45 +01:00
Mariusz Skamra 90770afa23 tests: bsim: gatt: ccc_store: Replace bt_gatt_write with bt_gatt_subscribe
This changes the way the GATT Client subscribes to the characteristic
value changes. The bt_gatt_write usage was replaced by dedicated
bt_gatt_subscribe API function call, so that the test verifies the GATT
Client API side as well.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:32:45 +01:00
Emil Gydesen cdd4bc6a48 Bluetooth: GMAP: Add GMAP BSIM test
Add BSIM testing of GMAP, with all spec-specified audio
configuration combinations added and tested.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 18:30:57 +01:00
Mariusz Skamra a42fb9d586 tests: bsim: gatt: Fix missing connection reference release
This fixes missing connection reference release.
The bt_conn_le_create returns the connection object reference that needs
to be released by API caller.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-11 09:54:13 +01:00
Lingao Meng 683098728a Bluetooth: Mesh: Use memslab replace with net_buf_pool
Use memslab more efficiency than net_buf_pool and consume
less ram with flash resource.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-08 20:19:10 +00:00
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
Aleksander Wasaznik 9f42c92e26 Bluetooth: Host: Fix GATT Long Read for EATT
When EATT is established, the value returned from `bt_att_get_mtu` is
not useful to determine the ATT_MTU that applies to a ATT response. This
is because `bt_att_get_mtu` may return the value for a different bearer
than the request is serviced on.

To fix this, the params struct for the GATT read operation is given a
new field that will record the ATT_MTU that applies to this ATT
operation. This value is then used to determine if the GATT long read
operation is concluded.

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

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-10-23 11:01:21 +02:00
Alberto Escolar Piedras 18d6919092 tests bsim: Disable bap_broadcast_audio_assistant
The test is currently broken in main and blocking
all other development when triggered.
Let's disable it by now as a provisional measure.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-20 15:20:32 -05:00
Anders Storrø fe9ffdaded tests: Bluetooth: Mesh: Op_agg coex loopback test
Adds coexistence Bsim test for Opcode Aggregator models using loopback.
The test verifies that the Opcode Aggregator server and client can send
messages to each other on the loopback interface.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:16:33 +02:00
Anders Storrø fc152c8e43 tests: Bluetooth: Mesh: Add op_agg coex test
Adds coexistence Bsim test for Opcode Aggregator models.
The test verifies that the Opcode Aggregator server and client can be
present and functional when operating on the same device.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:16:33 +02:00
Emil Gydesen 0e67c990cd tests: Bluetooth: BAP: Add broadcast sink with assistant test
Add a test for the broadcast sink that uses the BAP
Scan Delegator functionality with a Broadcast Assistant
device adding the broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:10:37 +02:00
Jonathan Rico 098b5bd05b tests: bsim: send SIGKILL if app doesn't respond to SIGTERM
I have seen the CI hang (both downstream and upstream) as the executable
doesn't always respond to the SIGTERM sent by `timeout`.

This will prevent that behavior. 5 whole seconds ought to be enough to
clean-up a small program.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-10-20 15:07:58 +02:00
Anders Storrø cc87833116 tests: Bluetooth: Mesh: Add priv beacon cache test
Adds Bsim test that verifies private beacon cache functionality.
The test checks that replays of the same private beacon
message is discarded.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:07:51 +02:00
Anders Storrø eb480a7599 tests: Bluetooth: Mesh: Add SNB cache test
Adds Bsim test that verifies SNB cache functionality.
The test checks that replays of the same SNB
message is discarded.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:07:51 +02:00
Anders Storrø f9ee38060d tests: Bluetooth: Mesh: Arg bug in beacon creation
Fixes bug in private_beacon_create function in beacon test
implementation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:07:51 +02:00
Jonathan Rico 028cf8037b tests: Bluetooth: add sleep in notify cb testcase
Validates that nothing nefarious happens if the application decides to
wait an arbitrary amount of time in notification callbacks.

Also validates that a disconnection during said waiting works as
expected.

E.g. in #48505, the user was trying to send data synchronously over UART
_inside_ the notification callback. Then the device was disconnected
whilst still waiting.

This kind of pattern is not recommended, but the stack should still
function correctly, stalling the "BT RX" thread shouldn't result in
state corruption or resource leakage.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-10-20 15:05:45 +02:00
Emil Gydesen 779f725db3 Bluetooth: CAP: Add verification of CCIDs as the initiator
When the initiator provides CCID in the metadata, we verify
that the CCIDs exist on the device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:05:33 +02:00
Anders Storrø 49bd77ad54 tests: Bluetooth: Mesh: Priv Proxy GATT test
Adds test verifying that Private Beacons are received
over a GATT proxy connection.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:04:54 +02:00
Emil Gydesen a2ab57c240 Bluetooth: Audio: Update bsim and shell to use codec set chan alloc
Update the BSIM test and the shell to use
bt_audio_codec_cfg_set_chan_allocation rather than implementing
their own versions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:00:27 +02:00
Emil Gydesen f67f840def tests: Bluetooth: Add tx/rx and data verification for BAP unicast
The BAP unicast babblesim tests now does RX and TX
and verifies that the data is correctly received on both
the client and server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:56:28 +02:00
Emil Gydesen ab60f5e6bc tests: bsim: Bluetooth: BAP Broadcast data validation
Add validation of sending and receiving dummy data.
Previously, due to a bug, we actually never sent any data
and still passed the test.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:56:28 +02:00
Pavel Vasilyev 7c7ea38471 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: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-20 14:54:17 +02:00
Lingao Meng c2b2641fc1 Bluetooth: Mesh: Move ext adv sector to vector
Obviously, it looks obscure by putting it in a sector,
so, let's move to vector.

refs: https://github.com/zephyrproject-rtos/zephyr/pull/57883

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Lingao Meng 141467a261 Bluetooth: Mesh: Rename adv relay to adv simultaneous
Since notice that simultaneous advertising is not only used
by relay message, provision over pb-adv can also be used.
so it was changed to a more general name.

refs:https://github.com/zephyrproject-rtos/zephyr/pull/48903

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Mariusz Skamra 2735339a82 tests: Bluetooth: has: Add test Preset Changed Offline Behavior
Verify that a HAS Server IUT sends changed characteristic notifications
or indications when the Lower Tester reconnects.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Emil Gydesen 0521ffd5a3 Bluetooth: ISO: Rename BT_ISO_ADVANCED to BT_ISO_TEST_PARAMS
Rename the Kconfig option from BT_ISO_ADVANCED to
BT_ISO_TEST_PARAMS to more explicitly denote that it
enables support for using the ISO test parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:50:48 +02:00
Håvard Reierstad 393c5ce065 bsim: Bluetooth: mesh: fix model extension
In 'test_access.c', model 3 on element 1 extending model 3 on element 0
is now registered correctly. When calling 'bt_mesh_model_extend' on
models on different elements, this needs to called from the
model with the highest element index to be registered correctly.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-17 19:11:42 +03:00
Håvard Reierstad 5969ad7811 bsim: Bluetooth: mesh: Implement CDP1 test
Adds bsim test to verify that composition data page 1 (CDP1) is
encoded and decoded correctly.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-09 15:06:06 +03:00
Anders Storrø 2e3ae017e3 tests: Bluetooth: Mesh: LCD test all comp pages
Adds test for verifying split get operation for all
composition data pages.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-06 16:21:02 +03:00
Ingar Kulbrandstad a5d15ec017 Bluetooth: Mesh: Fixed issue with RPR server and client.
Fixed issue when reprovisioning is done on a device with
both RPR client and server on the same device.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-10-06 16:06:12 +03:00
Andries Kruithof e04c963d9c Test: Bluetooth: controller: add CI testing for advertising chaining
Update babblesim tests for testing chaining for advertising to ensure that
we spill over to the next PDU

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Andries Kruithof d00d44c925 Bluetooth: controller: fix failing EBQ advertising tests
Updates the chaining for advertising.
Instead of unconditionally adding a new PDU when new data
is added we now instead fill the last PDU in the chain with
the incoming data, only adding a new PDU when there is
not enough room.

This reduces the nr. of PDUs used for advertising, and also
fixes some qualification failures

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Mateusz Kapala 3c0c634340 bluetooth: tests: Improve bondable_per_connection bsim test
Added fail on pairing_failed callback for both central and peripheral.
Added pairing status checks in peripheral.

It has been done to test the case when multi-role BT device tried to
pair without bonding (peripheral role) while already previously bonded
with the same device on another Bluetooth identity as it seems that
there was an issue with it previously.

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2023-10-04 14:53:26 +01:00
Emil Gydesen e67d6c2fa4 tests: bsim: Bluetooth: Remove broadcast_source_stop_inval
Removed the tests for invalid bt_bap_broadcast_source_stop
parameters and state, as those tests now implemented as unit tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-03 14:28:19 +01:00
Alberto Escolar Piedras 55940f701c tests bsim: Limit parallel build
The compile script had been modified
to fully parallelize all images builds
in 1de363d9d5

And has been kept building everything in parallel since then.
Over time we have seen an increase in the number of hangs
for this job in CI.
This is understood as being the result of the number of images
having increased, leading to a too high load
on the worker machines which cause them to timeout their
connection to the github CI scheduler.

In b83a828825
these jobs priority was lowered to aleviate this issue,
but again we see an increased number of CI runner
disconnects.

Let's parallelize this compile jobs a bit less.
With this change, we do not build anymore the sets of
host ll and mesh test images in parallel but sequencially.
On a local test this reduces peak load from
~1700 to ~700, and eliminates issues with system
unresponsiveness; while there is no statistically measurable
increase in overall build time.
Note that the single audio image is still built in parallel
to the other 3 sets, as this was seen to improve total
build time by 2 seconds out of 1m51s.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-02 15:54:10 +03:00
Vinayak Kariappa Chettimada a178aa9855 Bluetooth: Controller: Review rework flush timeout support
Review rework changed related to flush timeout support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada 27c92fe238 tests: bsim: Bluetooth: Test RTN=2, FT=2, Cen skip 4 SE in Controller
Test RTN=2, FT=2 in Controller with 4 subevents dropped by
central.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada 291cd03818 tests: bsim: Bluetooth: Test RTN=2, FT=2, Cen skip 2 SE in Controller
Test RTN=2, FT=2 in Controller with 2 subevents dropped by
central.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada a7d2fdd02b tests: bsim: Bluetooth: Test RTN=2, FT=2, Per skip 4 SE in Controller
Test RTN=2, FT=2 in Controller with 4 subevents dropped by
peripheral.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada 2935d3b731 tests: bsim: Bluetooth: Test RTN=2, FT=2, Per skip 2 SE in Controller
Test RTN=2, FT=2 in Controller with 2 subevents dropped by
peripheral.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Emil Gydesen 1442a6cf5b tests: bsim: Bluetooth: Remove bsim testing of broadcast create inval
Removing the babblesim testing of the invalid parameters for
bt_bap_broadcast_source_create as they are now done in a unit
test instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 12:59:54 +02:00
Emil Gydesen 62787bd208 tests: bsim: Bluetooth: Remove broadcast_source_delete_inval
Removed the tests for invalid bt_bap_broadcast_source_delete
parameters and state, as those tests now implemented as unit tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 12:59:41 +02:00
Alberto Escolar Piedras 25897f8baa tests bluetooth mesh: Fix ASSERT_TRUE/FALSE with messages
The previous ASSERT_TRUE/FALSE macros looked like
they could take extra printf like parameters but did not
(those extra arguments were just dropped).

Define 2 new macros that can take those extra parameters
and fix all uses that intended to print those extra messages.

Also add an extra "\n" as the underlaying print functions
do not add end of lines on their own.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-28 13:43:51 +02:00
Alberto Escolar Piedras 146d025aa0 tests bluetooth mesh: Fix a incorrect assert
This ASSERT_TRUE should have been an assert equal
(ASSERT_TRUE checks that the first paramters != 0)
and the condition was not correct.
Fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-28 13:43:51 +02:00
Jonathan Rico c1baa8282d tests: Bluetooth: Add ATT sequential procedures test
The purpose of this test is to prove that the zephyr host can handle the
behavior described in the Bluetooth Core Specification Vol.3 Part.F
3.3.2 "Sequential protocol".

The host should be able to handle all of those in parallel: one
indication, one write request, multiple commands and multiple
notifications.

The "tester" part had to be written with a "tiny host" implementation
instead of the Zephyr host, as the ZH conflates GATT client and server
and doesn't allow a device to enqueue an ATT request + an ATT indication
on the same bearer.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-28 14:21:27 +03:00
Emil Gydesen b470e82a95 tests: bsim: Bluetooth: Remove broadcast_source_reconfigure_inval
Removed the tests for invalid bt_bap_broadcast_source_reconfigure
parameters and state, as those tests now implemented as unit tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 13:14:49 +02:00
Emil Gydesen 0f9f528214 tests: bsim: Bluetooth: ISO: Add host CIS tests
Add a simple central and peripheral CIS test that
exercises the ISO host API for unicast ISO (CIS).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 13:12:19 +02:00
Théo Battrel 2e13802a38 Bluetooth: Test: Update security/ccc_update
Previous commit reverted the `link_encrypted` filed of CCC config.
Update the test to match the new expected behavior.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-09-28 09:21:57 +02:00