Commit graph

101 commits

Author SHA1 Message Date
Jordan Yates 07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Valerio Setti 9032f8d791 bt-crypto: add option to use PSA APIs instead of TinyCrypt
This commit adds CONFIG_BT_USE_PSA_API to allow the end
user to prefer PSA APIs over TinyCrypt for crypto operations
in bluetooth. Of course, this is possible only if
a PSA provider is available on the system, i.e.
CONFIG_PSA_CRYPTO_CLIENT is set.

This commit also extends tests/bluetooth/bt_crypto adding
a test case for PSA.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-14 15:41:34 +02:00
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Johan Hedberg 484fe3f06c Bluetooth: Remove bt_read_static_addr() "hack"
This function was used to shortcut HCI for combined host + controller
builds. It doesn't provide much value and adds complexity to the HCI
driver interface, so just remove it. This means vendor-specific HCI
commands is now the only way for the host to access the same
information.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-14 18:21:11 -04:00
Jonathan Rico bc5d531165 Bluetooth: tests: fix buf tests
Delete tests that did not end up bringing any value.

What ended up happening is busy-work to "make the test pass" without
understanding what's their original purpose.

Worse, the CI change-based testing is broken and doesn't pick them up,
even by PRs modifying the tests themeselves.
See #68008

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-04-30 16:20:23 +02:00
Rubin Gerritsen 237c59585e Bluetooth: Host: Rename bt_conn_state_t states for clarity
To make it easier to understand the code, the following was done:
- Use INITIATING/ADV for state names that are exclusive to central
  or peripheral. Previously it was not necessarily clear that the state
  BT_CONN_CONNECTING was for central only by just looking at where
  it was used. The terms INITIATING/ADV were used in favor
  of central and peripheral as these terms also work for SCO connection
  establishment.
- BT_CONN_CONNECTING_SCAN -> BT_CONN_SCAN_BEFORE_INITIATING
  to make it more clear that we are not scanning and connecting at
  the same time. The new name should make it more clear why we are
  scanning - only with the intention to start the initiator later.
- BT_CONN_CONNECTING_AUTO -> BT_CONN_INITIATING_FILTER_LIST.
  This makes it clear that this state is something different than
  BT_CONN_AUTO_CONNECT.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-04-23 15:31:59 +02:00
Lyle Zhu 40cf23daff Bluetooth: Rename BT_BREDR to BT_CLASSIC
Rename BT_BREDR to BT_CLASSIC
Rename CONFIG_BT_BREDR to CONFIG_BT_CLASSIC

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-03-07 11:26:45 +02:00
Aleksander Wasaznik b6a10516b0 Bluetooth: Host: Remove bt_buf_get_cmd_complete
After the previous commit, this function no longer has any users.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-31 17:50:35 +01:00
Aleksander Wasaznik df5548dddb Bluetooth: Host: Remove overspecifying test for bt_buf_get_evt
The next commit will change the behavior of `bt_buf_get_evt` to no
longer use `bt_buf_get_cmd_complete`. We have to remove the test that
would prevent this.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-31 17:50:35 +01:00
Anas Nashif afc319e3fa ztest: shell: add shell support
- Support for listing both testcases and testsuites
- Support for running single suites or single test cases
- Support shuffling tests and repeating execution based on command line
  arguments.

For example, build with

west build -p  -b qemu_cortex_m3  tests/kernel/sleep   -t run -- \
-DCONFIG_ZTEST_SHUFFLE=y -DCONFIG_ZTEST_SHELL=y

Following commands are available:

uart:~$ ztest
ztest - Ztest commands
Subcommands:
  run-all          :Run all tests
  shuffle          :Shuffle tests
  list-testsuites  :List all test suites
  list-testcases   :List all test cases
  run-testsuite    :Run test suite
  run-testcase     :Run testcase

shuffle accepts two arguments --suite_iter and --case_iter which allows
repeated exercution of testcases or suites.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-01-09 09:58:57 +01:00
Armin Brauns 5b1b260f80 bluetooth: add HCI driver parameter to set controller's public address
This allows HCI drivers to expose vendor-specific functions to set the
public address.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-11-29 10:44:25 +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
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Arkadiusz Kozdra 82d8f09de1 bluetooth: host: track connection type enum
The enum used for connection types gets named bt_conn_type to guard
against accidental usage of generic integers with relation to it.

The added default case in several switch statements avoids warnings
against unhandled enum values.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Théo Battrel 0f079a1ab8 Bluetooth: Unit: Fix unit tests that rely on settings
Following the previous commit that introduce the settings API for the
Bluetooth subsystem, some unit tests needed to be updated to use it.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-17 07:58:07 -04:00
Théo Battrel f5ff886260 Bluetooth: Tests: Remove usage of BT_DEBUG_LOG
Remove usage of Kconfig symbol `CONFIG_BT_DEBUG_LOG` from tests. It has
been deprecated since this PR:
https://github.com/zephyrproject-rtos/zephyr/pull/56183

The Kconfig symbols has been replaced by `CONFIG_LOG=y` on most of the
cases. Or it has been removed when not needed anymore.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-07 13:56:55 -04:00
Maciej Perkowski 75b062a6d6 tests: samples: Resolve duplicates in names.
Several duplicates were found with
scripts/twister -T samples/ -T tests/ --dry-run --list-test-duplicates
This is an issue since duplicated names causes overwriting of
results. Most duplicates looked like obvious copy-pase errors.
New names where addopted looking at other tests in the same yaml
or looking at the directory/descriptio.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2023-05-16 06:21:25 -04:00
Mariusz Skamra 12d8a0d178 Bluetooth: id: Keep RPA as bt_addr_t
There is no need to store the RPA in bt_addr_le_t structure, as the
bt_addr_le_t.type is unused anyway. Both bt_rpa_create and
bt_id_set_adv_random_addr take bt_addr_t as parameter.
Saves 1 byte of address type.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-12 10:55:50 +03:00
Nithin Ramesh Myliattil 8d6b206064 subsys/bluetooth/host: Make rpa same for adv sets with same id
Add check to see if RPA is already generated for adv sets
with same id. If generated use the same address for all adv sets
with same id else create new RPA.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2023-05-11 08:31:24 +00:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Aleksander Wasaznik bb1ede6a9b Bluetooth: Use bt_addr_eq
Refactor. Using `bt_addr_eq` instead of `bt_addr_cmp`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-05-09 09:23:52 +02:00
Jonathan Rico 20f82253ac tests: Bluetooth: update buf UT behavior
a6e5755da8 changed the behavior of
`bt_buf_get_cmd_complete`, update the test accordingly.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-14 11:53:06 +02:00
Ahmed Moheb 48000cd5a4 tests: bluetooth: host: Add UT for bt_dh_key_gen()
Unit test project for bt_dh_key_gen().
This is part of subsys/bluetooth/host/ecc.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Ahmed Moheb aebd5d84a0 tests: bluetooth: host: Add UT for bt_pub_key_get()
Unit test project for bt_pub_key_get().
This is part of subsys/bluetooth/host/ecc.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Ahmed Moheb fac21b3616 tests: bluetooth: host: Add UT for bt_pub_key_gen()
Unit test project for bt_pub_key_gen().
This is part of subsys/bluetooth/host/ecc.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Ahmed Moheb a774314e69 tests: bluetooth: host: Add UT for bt_pub_key_is_debug()
Unit test project for bt_pub_key_is_debug().
This is part of subsys/bluetooth/host/ecc.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Ahmed Moheb 3c76bd06e4 tests: bluetooth: host: Add mocks for ecc.c
Add required mocks to be able to compile/test /bluetooth/host/ecc.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Théo Battrel a3ac4421d2 Bluetooth: Tests: Fix bt_buf_get_evt test
Fix #55957. The `bt_buf_get_evt` test was using `net_buf` structures
without allocating it properly.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-21 22:49:34 +09:00
Mariusz Skamra 253d0806d3 test: Bluetooth: host: Add unit tests for bt_data_parse
This adds unit tests for bt_data_parse.
The sample data concept used in test is based on AD Structures of
Advertising, Periodic Advertising, and Scan Response presented in
Core specification.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-16 11:46:36 +01:00
Henrik Brix Andersen c6c5d5842d tests: remove test_framework tag from tests non-framework tests
Remove the "test_framework" tag from tests that are not testing the ztest
framework itself.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-15 15:03:02 +01:00
Henrik Brix Andersen b721f0b3a1 tests: bluetooth: fix testcase.yaml line indentations
Fix the line indentations used in the Bluetooth testcase.yaml files.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-15 15:03:02 +01:00
Ahmed Moheb 15ed0457b5 tests: bluetooth: host: Add UT for bt_encrypt_be()
Unit test project for bt_encrypt_be().
This is part of subsys/bluetooth/host/crypto.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-14 10:48:55 +01:00
Ahmed Moheb 3638889505 tests: bluetooth: host: Add UT for bt_encrypt_le()
Unit test project for bt_encrypt_le().
This is part of subsys/bluetooth/host/crypto.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-14 10:48:55 +01:00
Ahmed Moheb 574d78483c tests: bluetooth: host: Add UT for bt_rand()
Unit test project for bt_rand().
This is part of subsys/bluetooth/host/crypto.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-14 10:48:55 +01:00
Ahmed Moheb ebf96f4148 tests: bluetooth: host: Add UT for prng_init()
Unit test project for prng_init().
This is part of subsys/bluetooth/host/crypto.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-14 10:48:55 +01:00
Ahmed Moheb 593dea7f36 tests: bluetooth: host: Add mocks for crypto.c
Add required mocks to be able to compile/test /bluetooth/host/crypto.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-14 10:48:55 +01:00
Jamie McCrae 0bad35de45 samples and tests: Use non-environmental zephyr base variable
This drops using the environmental part when referencing ZEPHYR_BASE
as the environment value does not have to be set and, in most cases,
is no longer set at all.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:10 +01:00
Jamie McCrae af78cbdc99 samples and tests: Add REQUIRED to Zephyr find_package call
Adds REQUIRED to samples and tests for finding the zephyr package
to align all samples and tests with the same call and parameters.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-02 09:58:27 +01:00
Ahmed Moheb 5eb19ab352 tests: bluetooth: host: Add UT for bt_le_oob_get_sc_data()
Unit test project for bt_le_oob_get_sc_data().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 6c7a5aa930 tests: bluetooth: host: Add UT for bt_le_oob_set_sc_data()
Unit test project for bt_le_oob_set_sc_data().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 7abdb2c9b2 tests: bluetooth: host: Add UT for bt_le_oob_set_legacy_tk()
Unit test project for bt_le_oob_set_legacy_tk().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 811bdf8986 tests: bluetooth: host: Add UT for bt_le_ext_adv_oob_get_local()
Unit test project for bt_le_ext_adv_oob_get_local().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb e1d0df2bb3 tests: bluetooth: host: Add UT for bt_le_oob_get_local()
Unit test project for bt_le_oob_get_local().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>

# Conflicts:
#	tests/bluetooth/host/id/CMakeLists.txt
2023-01-17 13:13:28 +01:00
Ahmed Moheb ae32ce93d1 tests: bluetooth: host: Add UT for bt_br_oob_get_local()
Unit test project for bt_br_oob_get_local().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 9338965c58 tests: bluetooth: host: Add UT for bt_id_set_adv_own_addr()
Unit test project for bt_id_set_adv_own_addr().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb b31a4b3f70 tests: bluetooth: host: Add UT for bt_id_set_scan_own_addr()
Unit test project for bt_id_set_scan_own_addr().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 15748f9a79 tests: bluetooth: host: Add UT for bt_id_set_create_conn_own_addr()
Unit test project for bt_id_set_create_conn_own_addr().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 61c2f2e08a tests: bluetooth: host: Add UT for bt_id_delete()
Unit test project for bt_id_delete().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 1f37971e08 tests: bluetooth: host: Add UT for bt_id_reset()
Unit test project for bt_id_reset().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00
Ahmed Moheb 7456b85e7e tests: bluetooth: host: Add UT for bt_id_get()
Unit test project for bt_id_get().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00