Commit graph

2414 commits

Author SHA1 Message Date
Lang Xie
b41d19d85e Bluetooth: Host: Add bsim test for GATT multi notify
Checks that bt_gatt_notify_multiple works as expected.

Signed-off-by: Lang Xie <lang.xie@nordicsemi.no>
2022-08-19 14:09:43 +02:00
Aleksandr Khromykh
46f0d86227 tests: Bluetooth: Mesh: adapt bsim beacon tests for ext adv
Beacon test had trick for extended advertiser. That has been added as
conditional compilation. Additionally, waiting beacon procedure
waits for 1 more second to avoid boundary case since
the extended advertiser is more precisionive.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-08-19 12:08:27 +02:00
Aleksandr Khromykh
be8d357775 tests: Bluetooth: Mesh: fix reprovisioning test with ext adv
Extended advertiser has better latency without any delays than legacy one.
If couple of config model commands start sequently then
the first ones are received normally but the next one are transmitted in
parallel with leftover communication (retransmissions) of the previous one.
That causes collisions and broken test despite the functionality itself
is ok. Adding delays between commands solves crossovering tx time.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-08-19 12:08:27 +02:00
Aleksandr Khromykh
f7c77da5c8 tests: Bluetooth: Mesh: adapt bsim lpn tests for ext adv
mesh extended advertiser is not well tested. As the first step
the mesh babblesim tests should pass on extended advertiser as well
as on legacy advertiser. Minor fix to avoid lpn collisions in
friendship tests with multi lpns.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-08-19 12:08:27 +02:00
Mariusz Skamra
6219c12035 Bluetooth: csis: Expose bt_csis_generate_rsi function
The function will be used to update the RSI value. The returned value
can be later used in advertisement data for set identification. This
removes the need of specific bt_csis_advertise function so that the user
can call the API to generate new RSI once needed (e.g. on RPA change).
This allows the user to manage the advertisement data to fit it's needs.

< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
        Extended advertising: Disabled (0x00)
        Number of sets: 1 (0x01)
        Entry 0
          Handle: 0x00
          Duration: 0 ms (0x00)
          Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 33
        Handle: 0x00
        Operation: Complete extended advertising data (0x03)
        Fragment preference: Minimize fragmentation (0x01)
        Data length: 0x1d
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Unknown EIR field 0x2e: 16e61d64dc45
        Name (complete): audio test shell
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Data (0x08|0x0037) ncmd 1
	Status: Success (0x00)
< HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7
        Advertising handle: 0x00
        Advertising random address: 4E:21:29:F8:94:93 (Resolvable)
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Advertising Set Random Address (0x08|0x0035) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
        Extended advertising: Enabled (0x01)
        Number of sets: 1 (0x01)
        Entry 0
          Handle: 0x00
          Duration: 0 ms (0x00)
          Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
        Status: Success (0x00)

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-19 12:07:31 +02:00
Herman Berget
3a02e60398 Bluetooth: Tests: Add tests for EATT flag API
Checks that both notifications and requests work using the different
channel options.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Herman Berget
8873b7f05d Bluetooth: Tests: Use chan_opt BT_ATT_CHAN_ANY
The chan_opt field of GATT parameter structs must be set.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Gerard Marull-Paretas
aa1d2cf3d0 tests: bluetooth: initialize devices at compile time
Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Torsten Rasmussen
1a119b4121 tests: use CONFIG_ZTEST_NEW_API=y for bluetooth/controller/ctrl_cte_req
The bluetooth/controller/ctrl_cte_req wrongly defaulted to old Ztest API
after the introduction of the new unit_testing board.

Enforce use of CONFIG_ZTEST_NEW_API to get test working again.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-19 05:15:07 +09:00
Torsten Rasmussen
c23be568fb tests: add Kconfig file to bluetooth ctrl_data_length_update testcases
With Kconfig support in unittest the bluetooth ctrl_data_length_update
test fails because the symbols being configured are promptless or
disabled because of dependencies.

Add a Kconfig file to make needed symbols visible in unittest mode.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Torsten Rasmussen
0f15d89a26 tests: remove testing for board unit_testing
Remove boilerplate code:
> if (NOT BOARD STREQUAL unit_testing)
>    message(FATAL_ERROR "This project can only be used with...")
> endif()

as that is now handled by boards.cmake when validating the board.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Mariusz Skamra
541d946d10 Bluetooth: audio: Add HAS client support for preset switching
This adds client support for switching the active preset along with bsim
tests implementation.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-18 12:46:27 +02:00
Mariusz Skamra
8b06f7a5e1 Bluetooth: shell: Add multi-cis support
Add support for multiple CIS.

Relates: ASCS/SR/SPE/BI-{15,16}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-17 12:10:51 +02:00
Mariusz Skamra
e0d36beb72 Bluetooth: audio: Add security requirements check
The LE Audio related profiles define specific security requirements that
client have to met to gain access to related characteristics. This
introduces internal wrapper API for GATT characteristics and CCC
descriptors to ensure the security.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 12:19:43 +02:00
Andries Kruithof
6fe1299c33 Bluetooth: controller: llcp: fix CI tests for new LLCP
Setting the new LLCP as default exposed errors in CI tests, which
are fixed here
Note that advanced scheduling needs to be disabled. Work is in
progress for implementing this for the new LLCP

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-08-14 21:59:09 +02:00
Jonathan Rico
96f077f8c1 Bluetooth: gatt: reproduce #48880
Modify bsim_test_notify to fail in the same way as #48880.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-14 17:14:41 +02:00
Andries Kruithof
d2d241ac9a Bluetooth: llcp: test: fix bsim test for eatt
The Babblesim test for eatt for reconfiguration of MTU is not
foolproof. Central actually generates two mtu update events.
This is fixed by only setting the reconfigured flag when the MTU actually
changes to the new values

In the Babblesim test for eatt for collision the peripheral
needs to sync with central to ensure collisions occur.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-08-10 12:39:16 +02:00
Gerard Marull-Paretas
a7c3e7e84a doxygen: remove redundant usages of def
The def command Indicates that a comment block contains documentation
for a #define macro. This is useful if the comment block documents a
macro not adjacent to it, e.g.

```c
/**
 * @def MAX(x,y)
 * @brief Computes the maximum of @a x and @a y.
 */
 #ifdef XXX
 #define MAX(x,y) ...
 #endif
```

However, it is not necessary if the comment is adjacent to the
definition, e.g.

```c
/**
 * @brief Computes the maximum of @a x and @a y.
 */
 #define MAX(x,y) ...
```

This patch removes all unnecessary def entries in-tree.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-09 12:29:28 +02:00
Krzysztof Kopyściński
f71741cea0 tests: bluetooth: tester: add support for testing Multiple Notifications
Enabled Multiple Notifications and added command for
bt_gatt_notify_multiple().

Increased possible number of connections to execute GATT/SR/GAN/BV-02-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2022-08-05 13:01:46 +02:00
Yuval Peress
000bdb16c7 test: BT: ctrl_isoal: run clang-format
Run clang-format on the ctrl_isoal test's main.c

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-03 21:20:40 +02:00
Yuval Peress
4659524374 ztest: mock: Remove ztest mock from BT ctrl_isoal
Remove use of ztest mock Kconfig from BT ctrl_isoal tests.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-03 21:20:40 +02:00
Yuval Peress
fb5fabc3fb ztest: mock: Update BT ctrl_isoal allocation to use fff
Remove references to ztest mock used in `sink_sdu_emit_test`.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-03 21:20:40 +02:00
Yuval Peress
926830e546 ztest: mock: Update BT ctrl_isoal allocation to use fff
Remove references to ztest mock used in `sink_sdu_write_test`.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-03 21:20:40 +02:00
Yuval Peress
8589e34a50 ztest: mock: Update BT ctrl_isoal allocation to use fff
Remove references to ztest mock used in `sink_sdu_alloc_test`.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-03 21:20:40 +02:00
Vinayak Kariappa Chettimada
e6c8aaf629 Bluetooth: Controller: Refactor DF impl to add aux offset in ULL context
Refactor DF implementation to add aux offset in the aux
pointer field of the parent PDU when chain PDU is added
and/or is duplicated when PDU contents are updated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
aa5c0c0a90 Bluetooth: Controller: Rename Kconfig to BT_CTLR_ADV_AUX_PDU_BACK2BACK
Rename Kconfig BT_CTLR_ADV_PDU_BACK2BACK to
BT_CTLR_ADV_AUX_PDU_BACK2BACK to represent use of
back-to-back for Extended Advertising PDU chaining support
similar to BT_CTLR_ADV_SYNC_PDU_BACK2BACK that is used to
represent the use of back-to-back for Periodic Advertising
PDU chaining support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Fabio Baltieri
def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Michal Narajowski
fab8e29ee2 Bluetooth: Mesh: Add model publish support to Health Client
Mesh Profile Specification errata 11310
Section 4.4.4.1
"This model shall support model publication, as defined in Section
4.2.2 of the Mesh Profile specification and model subscription,
as defined in section 4.2.3 of the Mesh Profile specification."

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
2022-08-01 18:04:42 +01:00
Michal Narajowski
e98df9f160 tests: bluetooth: tester: Fix Health Fault Test command
The buffer for response was too small.

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
2022-08-01 18:04:42 +01:00
Aleksander Wasaznik
419c540a5c Bluetooth: Test: Split up test "uuid"
Create a separate file and test suite for each tested function.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-08-01 18:05:12 +02:00
Aleksander Wasaznik
a2bbc422a2 Bluetooth: Test bt_uuid_to_str
Add missing unit tests for `bt_uuid_to_str`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-08-01 18:05:12 +02:00
Kumar Gala
2c990384d6 tests: Remove label property from devicetree overlays
"label" properties are not required.  Remove them from tests.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-28 20:52:20 +02:00
Lingao Meng
e80161c86d Bluetooth: Mesh: Fix unable iv recovery 0 0 -> 1 0
According Mesh Spec 1.0.1:

Upon receiving and successfully authenticating to
Secure Network beacon for a primary subnet whose
IV Index is 1 or more higher than the current known IV
Index, the node shall set its current IV Index and its
current IV Update procedure state from the values in
this Secure Network beacon.

Look like test_iv_index.c:81
``` C

(bt_mesh_net_iv_update(TEST_IV_IDX + 1, BCN_IV_IN_IDLE));

```

This test case already exists, but the wrong testcase
to test wrong code.

Move `is_iv_recovery` into `bt_mesh_net_iv_update`.
First check whether it is IV recovery, and then carry out
the subsequent IV normal update procedure.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-07-28 19:47:36 +01:00
Emil Gydesen
d4b132a059 Bluetooth: Audio: Unicast client read available contexts
Read the available contexts during discovery and subscribe
for notifications.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-28 08:29:29 +02:00
Benjamin Björnsson
33b43547e8 tests: bluetooth: bttester: Update test to use DEVICE_DT_GET
Update test to use DEVICE_DT_GET in order to remove usage of
device_get_binding.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-27 18:44:22 +02:00
Piotr Pryga
ae56306557 tests: Bluetooth: llpc: Fix enc proc assert on released ctx num
Due to added call to ull_cp_tx_nrf call in common function event_done,
encryption test test_encryption_start_periph_rem_no_ltk failed with
assert caused by unexpected number of free control procedure contexts.

That is caused by internal call to rr_check_done and lr_check_done
in the ull_cp_tx_nrf that frees last unreleased context.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-25 15:17:22 +02:00
Piotr Pryga
01a8d2bdf9 tests: Bluetooth: llpc: Add at-instant conn evt proc in collision UT
Unit tests reposnsible for verification of collisions mitigation
didn't have handling for delayed completion of PHY Update control
procedure. The PHY Update is completed on event generated when
"at-instant" connection event is on air.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-25 15:17:22 +02:00
Piotr Pryga
64d67604b7 tests: Bluetooth: llcp: Add handling delayed PHY UPD compl in CTE REQ UT
The PHY Update control procedure completion is delayed to event
"instant-on-air". That has to be handled in CTE Request control
procedure unit test.

The changes required are:
- Added handling of event done for "at-instant" connection event.
  This is required to call ull_cp_tx_ntf function to send an
  envet "instant-on-air" to PHY Update procedure state machine.
  This is the delayed completion of PHY Update procedure.
- Remote requested PHY Update completion is also delayed and completed
  on "instant-on-air" event, hence the local CTE Request is not executed
  at the same connection event as PHY Update completion. This caused
  changes to check_phy_update_and_cte_req_complete function. The functin
  does not hanle CTE Request completion anymore. This also implies
  changes to run_phy_update_central and run_phy_update_peripheral.
  These function do not need to get CTE request argument anymore
  because it was just passed to check_phy_update_and_cte_req_complete.
  The check_phy_update_cte_req_complete was renamed to check_phy_update.
  The test test_cte_req_wait_for_remote_phy_update_complete was changed
  to execute and verify local CTE request procedure explicitly after
  completion of PHY Update.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-25 15:17:22 +02:00
Piotr Pryga
f2f65b9a42 tests: Bluetooth: llcp: Add missing at-instant conn event processing
The test_phy_update_central_rem_collision didn't have processing
of an "at-instant" connection event. Thas causes the remote requesed
PHY update to hand in waiting for instant on air state and whole
test to fail.

To fix the problem, proper processing of "at-instant" connection evnet
has to be added. In consequence the local PHY update procedure, that
as waiting for end of the remote procedure is delayed by one connection
event.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-25 15:17:22 +02:00
Piotr Pryga
0204506165 tests: Bluetooth: llpc: Add instant on air notification for PHY UPD
Unit tests does not maintain connection events hence there is no
notification to PHY upodate state machine about instant on air
event. That has to be simulated by explicit call to ull_cp_tx_nrf.

In unit tests the event_done function is responsible for handling
all steps done at end of connection event, so it is the best place
to simulate the instant on air event and send it to LLCP state machine.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-25 15:17:22 +02:00
Yuval Peress
43f9f806a9 ztest: mock: update BT host_long_adv_recv to FFF
Migrate the BT tests for host_long_adv_recv to use FFF instead of
ztest mock which is being deprecated.

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-25 15:15:24 +02:00
Yuval Peress
2b828f2af7 ztest: mock: Remove unused mocking dependency from BT ctrl_hci
The BT ctrl_hci test was enabling ztest mocking but never using it.

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-22 10:33:17 +02:00
Yuval Peress
42115c3f9e ztest: mock: Remove unused mock from BT ctrl_sw_privacy_unit
The BT test ctrl_sw_privacy_unit was enabling mocking but never using
it. Clean it up and remove the Kconfig.

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-22 10:32:27 +02:00
Emil Gydesen
df75bfd8f6 Bluetooth: Audio: Add PACS location read for unicast client
The unicast client will now read the PACS location value
during the discovery procedure, as well as subscribing to
it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-19 12:27:00 +00:00
Pavel Vasilyev
b9078e98e6 tests: Bluetooth: Mesh: Add ability to abort bsim mesh tests by ctrl-c
Sometimes there is a need to interrupt mesh babblesim tests when
debugging or implementing new tests. Calling Ctrl-C doesn't work as it
only aborts the test script, but not the executables. This fix adds a
trap for Ctrl-C to kill all test instances run by the script.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-07-19 10:30:56 +02:00
Tomislav Milkovic
0fe2c1fe90 everywhere: Fix legacy include paths
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths

Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
2022-07-18 16:16:47 +00:00
Jonathan Rico
7411b451da Bluetooth; GATT: don't immediately cancel CCC write request
`bt_gatt_unsubscribe` was pending a write to the CCC and then immediately
canceling it.

Fixes #47682 .

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-15 10:01:15 +02:00
Fredrik Danebjer
04a080bf70 Bluetooth: Audio: TBS Client optional procedures actually optional
This change makes the optional procedures in the TBS Client optional
and configurable through Kconfig.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-07-14 15:48:28 +00:00
Piotr Pryga
aaaeefdb11 tests: Bluetooth: llcp: ctrl cte req migrate to new ZTEST API
Migrate LLCP unit tests in ctrl_cte_req to new ZTEST API.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-14 10:38:31 +02:00
Piotr Pryga
8be0999dfb tests: Bluetooth: df: connectionless cte tx migrate to new ZTEST API
Migrate tests in connectionless_cte_tx to new ZTEST API.

Remove main.c source file because is unncessary when automatic
unit tests registration is available. Also former use of
predicate to select unit tests for execution is removed
because the tests are split into two distinct tests suites
that has its't own setup and teardown phases.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-13 16:13:57 +02:00