Commit graph

2414 commits

Author SHA1 Message Date
Szymon Janc
d434eac86f tests: bluetooth: tester: Fix zero length array in middle of struct
Zero length arrays are only allowed at the end of the structure. Here
those were used as placeholders for BTP response creation and can be
easily replaced with common member.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-07-27 20:51:30 +03:00
Jonathan Rico
dc053dc6d2 Bluetooth: shell: Enable sysbuild for nRF5340
Enable sysbuild for nRF5340 app core.

This automatically builds the image for the network core, making a
better user experience.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-27 20:51:10 +03:00
Emil Gydesen
8be6db67fc Bluetooth: ISO/BAP: Refactor BIS bitfield
Refactors teh BIS bitfield values used for ISO
and BAP.

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

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

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

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 15:19:46 +03:00
Emil Gydesen
f338bf6fae Bluetooth: Host: Discard advertising data if not explicit scanning
If the application is not explicitly scanning, then there is not
really any need to parse advertising reports nor send them to the
application.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 15:12:39 +03:00
Rubin Gerritsen
85eadcfddc Bluetooth: Mark bt_<type>_err_to_str() APIs experimental
It was pointed out in a future PR that they should have
a corresponding experimental Kconfig entry.

See PR #73795.

This updates the APIs added in PR #73826 and PR #74295.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-07-11 13:11:59 -04:00
alperen sener
8382fea5b3 test: bluetooth: Correct profile names MBT and DFU
Profile names MBT and DFU are updated as MBTM and DFUM respectively,
according to TCRL 2024-1.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2024-07-11 16:15:10 +02:00
Jonathan Rico
4afe745a1d Bluetooth: host: Add lower bound for CONFIG_BT_BUF_ACL_RX_COUNT
See comment above assert for more.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-10 11:47:26 -04:00
Théo Battrel
96d8682a5b Bluetooth: Shell: Fix native shell build
Following changes in HCI drivers
(https://github.com/zephyrproject-rtos/zephyr/pull/72323) the build for
the snippet allowing to have the Bluetooth shell run with BabbleSim was
broken.

Fix the snippet by disabling the HCI UART driver.

Add a twister test case that will build the snippet in CI to avoid
silent breaking.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-07-10 11:47:07 -04:00
Szymon Janc
7bfd6b6256 test: bluetooth: Update ICS to TCRL 2024-1
This ICS was generated with new Qualification Workspace tool.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-07-08 14:57:12 -04:00
Szymon Janc
8665117411 test: bluetooth: Remove qualification project BLS file
With new BT SIG Qualification Workspace it is no longer possible to
export/import full project. Only ICS export/import is possible.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-07-08 14:57:12 -04:00
Emil Gydesen
d05f211289 tests: Bluetooth: tester: Re-add support for checksum
The bug should be fixed now, so it possible to have it enabled as
long as OTS is not registered with the feature flag.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-06 17:02:23 +02:00
Sreeram Tatapudi
d0474cefde tests: bluetooth: shell: Enable flow control
Enabling UART flow control for CYW20829

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2024-07-02 09:35:33 +02:00
Emil Gydesen
7b0784c1f6 Bluetooth: ASCS: Validate num_ases in CP requests
Add validation of the number of ASEs in control point
write requests.

This validates that the number of ASEs
in the control point is not greater than the total number
of ASEs we support.

This also validates that the GATT MTU is large enough to
hold all the responses from the write since those can only be
sent as notifications and never be truncated.

Finally this validates and updates the size of the buffer used to
hold the responses, which may be an optimization for some builds.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-28 07:20:47 -04:00
Emil Gydesen
15d66ccc23 Bluetooth: Tester: Fix issue with initializing adv_params
The macro was changed to return a const pointer, but the
BTP use the returned pointer in a non-const way.

Modify the usage so that the macro is used to initialize
the adv_param instead, and then provide a non-const pointer
to tester_gap_create_adv_instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-27 15:14:48 -04:00
Jordan Yates
243eb36b18 everywhere: reindent .overlay files with tabs
`checkpatch.pl` requires that dts sources are indented with tabs,
fix all the spaces that slipped in while checkpatch wasn't watching.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-26 15:59:44 +02:00
Lingao Meng
302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
Lingao Meng
dfc948a753 tests: bluetooth: fix missing net_buf_ref(rsp)
Remove unused rsp.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-24 14:26:22 +02:00
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
Szymon Janc
78b93feb6d tests: bluetooth: tester: Enable BT_TINYCRYPT_ECC for nRF5340
This needs to be enabled in nRF53 CPUAPP for LE SC support to be
enabled.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-06-20 12:04:18 -04:00
Rubin Gerritsen
69fb606579 Bluetooth: Host: Define bt_security_err_to_str()
This can be useful if application developers
want to print them in the applications.

Later we can also use them in
the host to improve debuggability.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-20 15:34:39 +02:00
Rubin Gerritsen
4e30803e15 Bluetooth: Host: Define bt_gatt_err_to_str()
The function reuses the ATT implementation.
To make the function simpler to use, the function handles both positive
and negative values.

Unfortunately the APIs do not document if the API returns an
errno val or a GATT return value.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-20 15:34:39 +02:00
Rubin Gerritsen
b25985ad6a Bluetooth: Host: Define bt_smp_err_to_str()
This API converts a SMP error code to a string.
This can be useful if application developers want
to print them in the applications.

BT_SMP_ERR_SUCCESS was added for completeness.

Later we can also use them in the host to improve debuggability.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-20 15:34:39 +02:00
Rubin Gerritsen
94d712e5cf Bluetooth: Host: Define bt_att_err_to_str()
This can be useful if application developers
want to print them in the applications.

Later we can also use them in
the host to improve debuggability.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-20 15:34:39 +02:00
Yong Cong Sin
1899e4f667 bluetooth: remove CONFIG_BT_DEBUG_LOG
`CONFIG_BT_DEBUG_LOG` has been deprecated for more than 2
releases, replace it with `CONFIG_BT` + `CONFIG_LOG`:

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-18 14:33:58 -04:00
Nazar Palamar
36fb0279d2 test: bluetooth/tester: fix ccc_find_by_attr
Added check if ccc_values[i].attr != NULL,
before accessing to ccc_values[i].attr structure:
(handle == ccc_values[i].attr->handle)

On 20829 platform it's causing hard fault, not sure about
another platforms (in GAP testing).

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2024-06-15 04:43:31 -04:00
Nazar Palamar
492439af79 test: bluetooth/tester: add overlays for cyw920829m2evk_02 board
- added overlays for cyw920829m2evk_02 board

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2024-06-15 04:43:31 -04:00
Rubin Gerritsen
bfba19dc41 Bluetooth: Host: Add the API bt_hci_err_to_str()
This API converts a HCI error code to a string.
This can be useful if application developers want to print them
in the applications.

Later we can also use them in the host to improve debuggability.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-14 19:17:48 +02:00
Valerio Setti
32b43564df bt: hci_ecc: 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/mesh/basic/bluetooth.mesh.gatt adding a specific
case using PSA.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-14 15:41:34 +02:00
Valerio Setti
32b792b21f bluetooth: remove BT_TINYCRYPT_ECC in bluetooth mesh tests
Some bluetooth test were using BT_TINYCRYPT_ECC without also
setting BT_ECC. This means that BT_TINYCRYPT_ECC gets disabled
as it depends on BT_ECC.
This commit fix this by removing BT_TINYCRYPT_ECC in all test
for bluetooth mesh.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-14 15:41:34 +02:00
Valerio Setti
814b2ed457 bt-host: add option to use PSA APIs instead of TinyCrypt
By enabling CONFIG_BT_USE_PSA_API the user can specify to use
PSA APIs instead of TinyCrypt for crypto operations in bluetooth
host module.

This commit also extends tests/bluetooth/gatt in order to
add a PSA test.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-14 15:41:34 +02: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
Jens Rehhoff Thomsen
ab9fd0b5c9 Bluetooth: BAP: Add bt_bap_base_get_size function
bt_bap_base_get_size function returns the size of the BASE.

Fixes #73847

Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
2024-06-14 15:34:23 +02:00
Andries Kruithof
7902457437 Bluetooth: audio: test: Unittests for broadcast reception start
Implement unit tests for the broadcast reception start procedure,
both with proper and with improper parameters.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-06-13 16:48:58 -04:00
Alberto Escolar Piedras
5d1afa1a3b tests: Bluetooth: bap_broadcast_source: Fix call
bt_audio_codec_cfg_get_chan_allocation() now takes an
extra parameter.
Let's set it to the value which keeps the old behaviour.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-13 11:47:14 -04:00
Nithin Ramesh Myliattil
df45858d0f Bluetooth: BAP: Broadcast Source: Update stream codec config data
When creating a BAP broadcast source with bt_bap_broadcast_source_create
only the subgroup information is stored in the streams and the remaining
BIS specific information is not stored in the stream->codec_cfg,
which it should.
Fix is to store bis specific information also in stream codec config.
Updated broadcast source BSIM test to verify above usecase.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2024-06-13 08:04:27 -04:00
Emil Gydesen
a62ee400dc tests: Bluetooth: CAP: Add initial CAP initiator unit tests
These test only test the basic functionality of
bt_cap_initiator_unicast_discover so far, but will be expanded.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-13 05:42:04 -04:00
Emil Gydesen
db4d4cfda2 Bluetooth: Audio: Add fallback to cfg_meta_get_pref_context
Added a fallback parameter to
bt_audio_codec_cfg_meta_get_pref_context
as absence of pref context in BAP implicitly means a unspecified
for LC3.

In the case that it is absent BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED
is the returned value.

While the metadata for codec cfg and codec cap are similar,
this only applies for codec cfg as per BAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-13 05:41:47 -04:00
Emil Gydesen
c4b3b72b07 Bluetooth: Audio: Add fallback to max_codec_frames_per_sdu
Added a fallback parameter to
bt_audio_codec_cap_get_max_codec_frames_per_sdu
as absence of max codec frames per SDU in BAP implicitly
means a single frame for LC3.

In the case that it is absent 1 is the returned value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-13 05:41:47 -04:00
Emil Gydesen
579b4f7e37 Bluetooth: Audio: Add fallback to supported_audio_chan_counts
Added a fallback parameter to
bt_audio_codec_cap_get_supported_audio_chan_counts
as absence of channel count in BAP implicitly means a single channel
for Lc3.

In the case that it is absent 1 is the returned value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-13 05:41:47 -04:00
Emil Gydesen
a33543f02e tests: Bluetooth: Audio: Fix bad values in codec cap unit tests
Some codec cap unit tests were using codec cfg values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-13 05:41:47 -04:00
Emil Gydesen
c6cc034b5c Bluetooth: Audio: Add fallback to get_chan_allocation
Added a fallback parameter to
bt_audio_codec_cfg_get_chan_allocation as absence of
channel allocation in BAP implicitly means Mono.
In the case that it is absent,
BT_AUDIO_LOCATION_MONO_AUDIO is the returned value.

This commit also fixes the implementation of
bt_audio_codec_cfg_get_frame_blocks_per_sdu as it only applies to
LC3 (as per the BAP spec). It also adds additional testing of it

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-13 05:41:47 -04:00
Emil Gydesen
be307f8ad9 Bluetooth: Audio: Change lang to 3-byte value from uint32_t
The 3-byte value suits the assigned number much better,
and also allows for less memory copies when getting and
setting the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-12 12:54:16 -04:00
Emil Gydesen
f08bc644a1 Bluetooth: Audio: Rename stream_lang to lang
Remove the "stream" part of the value and functions to
better fit with the name in the assigned numbers document.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-12 12:54:16 -04:00
Johan Hedberg
0b8e56120c Bluetooth: doc: Update documentation for the new HCI API
Update references to devicetree chosen properties and how devicetree nodes
should be defined in order to enable the new HCI drivers.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-06-11 19:42:49 -04:00
Johan Hedberg
1824dcda7c Bluetooth: tests: Convert to new HCI driver API
Convert all Bluetooth tests that define dummy HCI driver instances to use
the new HCI driver API. This requires both a custom DTS binding as well
as an app-specific overlay file.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Johan Hedberg
00d66339fc Bluetooth: drivers: h5: Convert to new HCI driver API
Convert the H:5 HCI driver to use the new HCI driver API.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Troels Nilsson
bed717e2a5 Bluetooth: Controller: Refactor of ull_adv_sync_pdu_set_clear()
ull_adv_sync_pdu_set_clear does pretty much everything, causing
it to be very complex and awkward to use. In addition, it only handles
a single PDU, meaning callers have to handle the chain.
It has been replaced with simpler, more complete functions for handling
the relevant operations

Fixed issues include:

- Fragmentation of adv data over HCI is now decoupled from PDU
  fragmentation, fixing HCI/DDI/BI-13-C, LL/DDI/ADV/BV-26-C and
  LL/DDI/ADV/BV-55-C
- Adding BigInfo now preserves the PDU chain
- Enabling periodic advertising with ADI on would sometimes fail
  due to insufficient space in a single PDU to add ADI

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-06-11 16:38:05 +03:00
Yassine El Aissaoui
bb770c5965 samples: tests: bluetooth: Add support for frdm_rw612
Adding bt_tester support.

Adding bt_tester app build
with Twister for frdm_rw612 board

Fix failing tests/samples due to unsufficent MPU ressources
by releasing unnecessary MPU regions.

Twister builds added on peripheral/central ht and
enabled Power manager on those examples to cover
the CI builds with PM enabled.

Signed-off-by: Yassine El Aissaoui <yassine.elaissaoui@nxp.com>
2024-06-10 07:02:06 -07:00
Emil Gydesen
8136f740df tests: Bluetooth: Move audio related BTP files
Move the audio related files to a new subdirectory called
audio.

The purpose of this is to clean up the file structure a bit,
and also allow for better filtering of the files.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-07 22:08:59 -05:00
Vinayak Kariappa Chettimada
d6f2bc9669 Bluetooth: Controller: Add explicit LLCP error code check
Add unit tests to cover explicit LLCP error code check and
cover the same in the Controller implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00