Commit graph

9787 commits

Author SHA1 Message Date
Valerio Setti
aaf463ca7b Bluetooth: make MBEDTLS_AES_ROM_TABLES implied not selected
MBEDTLS_AES_ROM_TABLES let Mbed TLS use precomputed AES tables instead
of generating them at runtime and placing in RAM. It clearly helps
reducing the RAM footprint, but at the same time it increases the ROM
one. In order to let the final user decide which kind of optimization
they prefer, we change the "select" statement with "imply".

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-01-15 22:57:20 +01:00
Pavel Vasilyev
6463d15a66 bluetooth: mesh: Remove assertion for Received List message PDU size
According to MshDFUv1.0, section 6.2.3.5, the Firmware Distribution
Receivers List message is not limited by the size of the receivers list:

```
The number of selected entries shall be limited by the following:
- The number of entries shall not exceed the value of the Entries Limit
  field from the Firmware Distribution Receivers Get message.
- The number of entries shall not cause the message payload to exceed
  the maximum Access PDU size.
```

Thus, this assertion is incorrect as it doesn't allow to have the
receivers list bigger than number of maximal Access PDU size.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-01-15 22:57:01 +01:00
Emil Gydesen
eff93d268a Bluetooth: BAP: Add common capability check
Instead of having 2 separate and non-equal checks for
capabilities in ASCS and the Broadcast Sink, there is now
a single function in pacs.c that performs the
check.

This reduces code size and makes it easier to maintain.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-15 19:04:31 +01:00
Emil Gydesen
ba5971e703 Bluetooth: ISO: Move contents of Kconfig.iso to common Kconfig
Move the contents of Kconfig.iso to the common Kconfig
file.

The main reason for this is that the Kconfig.iso filename
has caused issues for some, due to the .iso filename extension.

The contents have been moved to right after the Kconfig options
for BT_CONN which are quite similar.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-15 01:39:35 +01:00
Vinayak Kariappa Chettimada
363c1431dd Bluetooth: controller: Fixup Broadcast ISO pre-transmission groups > 1
Fixup payload_index to be uint16_t to avoid index overflow.

Do not remember why ptc is 4 bits, where as it must be 5 bit
value similar to nse; added an assertion check until it is
fixed.

Fix ISO Broadcaster and ISO Sync Receiver for PTO > 1 and
use of Pre-Transmission Group Counts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-14 15:37:53 +01:00
Vinayak Kariappa Chettimada
9cd9f4150d Bluetooth: Controller: Add back the use of pre-transmissions
Add back the implementation in the Controller that tries to
enable pre-transmissions to improve time diversity to aid a
remote ISO Sync Receiver role device.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-14 15:37:53 +01:00
Morten Priess
d58724d7d7 Bluetooth: controller: Fix ISO broadcaster pre-transmission groups > 1
For pre-transmission groups > 1, the broadcaster link layer would fetch
incorrect payloads from the TX node queue.

Update payload index calculation to reference correct TX payload. Fix
PTO FIXMEs and range checks.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2025-01-14 15:37:53 +01:00
Marcin Szymczyk
94589b784b modules: hal_nordic: nrfx: cleanup
* Move all KConfig configuration from CMake to `nrfx_kconfig.h`
* Move macro utils from `nrfx_kconfig.h` to `nrfx_zephyr_utils.h`
* Move GRTC channels allocation from `nrfx_kconfig.h` to
  `nrfx_reserved_resources.h`

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2025-01-14 13:38:03 +01:00
Aleksandr Khromykh
967b096ad9 Bluetooth: Mesh: use secure storage in ble mesh
Commit:
 - adds dependency of the mbedtls psa usage on secure storage
 - removes PSA ITS emulator and enables usage of
   the secure storage in ble mesh bsim tests
 - enables secure storage in all ble mesh and related samples

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-01-14 13:23:47 +01:00
Pisit Sawangvonganan
bd9249457a bluetooth: shell: completely eliminate the dependency on ctx_shell
This commit removes the `ctx_shell` declaration from the Bluetooth shell,
marking a milestone in eliminating this dependency.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Pisit Sawangvonganan
2ea23cec7c bluetooth: classic: shell: eliminate ctx_shell usage
This change aims to eliminate the dependency on `ctx_shell` in
the Bluetooth `classic/shell/*`, making the code more maintainable.
Replaced `shell_*` functions that depended on `ctx_shell` with
the appropriate `bt_shell_*` functions.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Pisit Sawangvonganan
f70359bc7c bluetooth: mesh: shell: eliminate ctx_shell usage
This change aims to eliminate the dependency on `ctx_shell` in
the Bluetooth `mesh/shell/*`, making the code more maintainable.
Replaced `shell_*` functions that depended on `ctx_shell` with
the appropriate `bt_shell_*` functions.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Pisit Sawangvonganan
f1516c960a bluetooth: audio: shell: eliminate ctx_shell usage
This change aims to eliminate the dependency on `ctx_shell` in
the Bluetooth `audio/shell/*`, making the code more maintainable.
Replaced `shell_*` functions that depended on `ctx_shell` with
the appropriate `bt_shell_*` functions.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Pisit Sawangvonganan
eeda631ee5 bluetooth: shell: move bt_shell_private.c to common folder
Relocated `bt_shell_private.c` to the `common` folder to enable
independent use between `BT_SHELL` and `BT_MESH_SHELL`.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Kyra Lengfeld
64d8713683 Bluetooth: Mesh: use settings priority feature
By using `SETTINGS_STATIC_HANDLER_DEFINE_WITH_CPRIO` we can ensure that
BT subsystems always get loaded after BT, and BT Mesh after both of
them.

This solves the host having to register a GATT service in a delayed
manner, as we are sure to now register the GATT service after sc_commit
sets `SC_LOAD`.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2025-01-14 00:00:56 +01:00
alperen sener
37cdfe818b bluetooth: mesh: fix mesh pb gatt cli uuid usage
uuid needs to be keept in pb_gatt_cli server context until the client
is connected to server, otherwise, since we only kept the pointer from
the net_buffer, any incoming unprovisioned beacon before the connection
is established may overwrite uuid.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2025-01-14 00:00:44 +01:00
Yago Fontoura do Rosario
9f7736259f Bluetooth: Host: Ensure conn_ready access is thread safe
* The `bt_dev.le.conn_ready` list is accessed by the tx_processor
which runs in a workqueue, but `bt_conn_data_ready` can be called
from different threads so we need to make sure that nothing will
trigger a context switch while we are manipulating the list since
sys_slist_*() functions are not thread safe.
* This only happens if call to `bt_conn_data_ready` is performed
from a preemptive task which can happen depending on the
application.

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2025-01-13 10:08:55 +01:00
Lyle Zhu
132a24d21c Bluetooth: LE: BAP: Check buf len before using it
Check whether the length of buf is consistent with the valid data
received for op code BT_BAP_BASS_OP_ADD_SRC and BT_BAP_BASS_OP_MOD_SRC.

If the length of buf is inconsistent with the valid data received, the
response is error code BT_ATT_ERR_WRITE_REQ_REJECTED instead of other
errors.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-01-10 14:47:54 +01:00
Emil Gydesen
48ac31c7a2 Bluetooth: TMAP: Remove double definitions of TMAP roles support
Both the TMAP kconfig file and public header file defined
which roles were supported.

The Kconfig file options were recently added and were more
up to date (and correct), and allows for other Kconfig files
to use these values, thus allowing for more flexibility when
implementing applications.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-09 15:49:10 +01:00
Emil Gydesen
cc042a6a70 Bluetooth: Host: Refactor provacative comment
There is no reason to call people who disable
asserts for animals.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-08 07:51:17 +01:00
Emil Gydesen
e45830893f Bluetooth: CCP: Introduce new CCP API
The CCP API for the Call Control Profile works on top of the
TBS API, and will eventually replace parts of the TBS API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-08 07:50:32 +01:00
Emil Gydesen
a0b1e75268 Bluetooth: MPL: Fix build issues with the MPL shell
If logging (CONFIG_LOGGING) was disabled, then the shell
could not build. Ideally the (test) functions should not
depend on logging, but rather only CONFIG_BT_TESTING.

The shell commands were also properly guarded.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-07 00:27:17 +01:00
Vinayak Kariappa Chettimada
9678ff2041 Bluetooth: Controller: Include mem and ecb in-system tests
Include mem and ecb implementation in-system tests.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-01 02:04:33 +01:00
Vinayak Kariappa Chettimada
17846ed1f4 Bluetooth: Controller: nRF54L: Fix ecb tag name should be unique
Fix ecb tag name for violation to rule 5.7 (Tag name should
be unique) tag: ecb.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-01 02:04:33 +01:00
Vinayak Kariappa Chettimada
de13d36865 Bluetooth: Controller: Refactor isr_ecb and unit testing
Refactor the NRF_ECB isr_ecb function to reduce redundant
common code.

Updated the unit tests to use Bluetooth Specification
defined test vectors.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-01 02:04:33 +01:00
Vinayak Kariappa Chettimada
1dfebd6c1a Bluetooth: Controller: Add NRF_ECB crypto support in nRF54L15 SoC
Add NRF_ECB crypto support in nRF54L15 SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-01 02:04:33 +01:00
Emil Gydesen
8c38d1b9a3 Bluetooth: TMAP: Add role validation for bt_tmap_register
Add validation that the device supports the role
set by bt_tmap_register.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-27 14:09:13 +01:00
Emil Gydesen
abe2e0df57 Bluetooth: BAP: BA: Add validation of add/mod src
The functions did not verify the provided parameters before
sending it as a control point operation.

This also fixes a bug where BT_BAP_BIS_SYNC_NO_PREF was not
allowed when pa_sync=0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-27 14:08:57 +01:00
Emil Gydesen
2b197aff02 Bluetooth: BAP: Modify range of BT_BAP_BROADCAST_SNK_SUBGROUP_COUNT
The range of BT_BAP_BROADCAST_SNK_SUBGROUP_COUNT should be relative to
BT_BAP_BASS_MAX_SUBGROUPS. The broadcast sink depends on the scan
delegator, and thus it does not make sense for the broadcast sink
to support more subgroups than what the scan delegator supports.

Since this no longer relates to the number of streams, there
may be new runtime errors if applications attempt
to sync to more subgroups than the number of ISO channels
supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-27 12:36:40 +01:00
Théo Battrel
18c2ea2336 Tests: Bluetooth: Check GATT settings cleanup
Check that the GATT settings added when bonding to a peer and
subscribing to a CCC are correctly deleted when calling `bt_unpair`.

Testing hooks have been added in the Bluetooth settings abstraction
layer to know which key are being added/deleted.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-12-24 16:07:32 +01:00
Théo Battrel
65334e0104 Bluetooth: Host: Clear settings CF instead of CCC
`bt_gatt_clear_cf` was calling `bt_settings_delete_ccc` instead of
`bt_settings_delete_cf`. This was causing some settings to be left over.

Fix the issue by using the correct function.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-12-24 16:07:32 +01:00
Make Shi
3f4ff78c1b Bluetooth: classic: Kconfig: set BT_RFCOMM_DLC_STACK_SIZE default 512
For the shell RFCOMM case, these is a stack overflow problem when do
disconnect, so need to increase the CONFIG_BT_RFCOMM_DLC_STACK_SIZE.
Set CONFIG_BT_RFCOMM_DLC_STACK_SIZE default 512.

Signed-off-by: Make Shi <make.shi@nxp.com>
2024-12-24 04:22:37 +01:00
Szymon Janc
eccd8adc68 Bluetooth: Host: Fix not sending Service Changed indication
gatt_unregister() clears handles if those were auto-assigned by host.
This resulted in Service Changed indication not beding sent since
call to sc_indicate() pass already cleared handles.

This was affecting GATT/SR/GAS/BV-01-C and GATT/SR/GAS/BV-07-C test
cases.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-12-23 17:10:28 +01:00
Emil Gydesen
1f4ca01c86 Bluetooth: BAP: Fix BIS_Sync value in update_recv_state_base
The BASE doesn't affect the BIS sync value, and should thus not
change it.

This fixes a bug where the broadcast sink may prematurely
set the BIS sync value to e.g. 1 before actually
syncing to the BIG.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-23 13:23:47 +01:00
Mark Wang
19dee0e937 tests: bluetooth: shell: add a2dp new features test
add test for reconfigure, release, suspend, abort and disconnect.
app_config_req and app_reconfig_req always accept the req,
so don't need to handle reject case.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-12-23 09:15:35 +01:00
Mark Wang
70c73aa317 Bluetooth: A2DP: implement close, suspend and abort
implement avdtp close, suspend and abort and the a2dp
interfaces.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-12-23 09:15:35 +01:00
Mark Wang
6a6f2c2fca Bluetooth: A2DP: implement reconfig and optimize codes
Implement the bt_a2dp_stream_reconfig: Modify reconfig_req callback to
pass codec_cfg to application. Remove reconfig_rsp callback,
config_rsp is used. Remove reconfigured callback,
configured callback is used.

move the status to common struct bt_avdtp_req,
use same bt_avdtp_ctrl_params to process control-like avdtp
cmds (start, open etc), use the same a2dp_ctrl_ind to process
control-like cmds (start, open etc), use the same
bt_a2dp_ctrl_cb to process control-like cmds (start, open etc),
use the same bt_avdtp_ctrl to process control-like cmds
(start, open etc), optimize getting a2dp conn by index,
use sem to replace mutex and optimze the lock codes to be
based on context/instance.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-12-23 09:15:35 +01:00
Mark Wang
b8399c31a2 Bluetooth: A2DP: clang-format the codes
run clang-format

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-12-23 09:15:35 +01:00
Aleksander Wasaznik
e8c5405609 Bluetooth: Controller: Fix headroom reservation for ISO
Calling `net_buf_reserve` removed any previous reservation, which
includes the reservation by hci_ipc to hold the H4 type byte. This
resulted in a out-of-bounds net_buf_push in hci_ipc.

This commit also enables asserts in hci_ipc in the audio bsim test,
which reveal the out-of-bounds write.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-12-21 05:52:37 +01:00
Make Shi
14e9840a4b Bluetooth: Shell: BR: channel is not used in register command
Cmd_register uses a fixed channel as the rfcomm channel. Cmd_register
doesn't require parameters for channels.

Signed-off-by: Make Shi <make.shi@nxp.com>
2024-12-20 16:06:26 +01:00
Emil Gydesen
6bcfdaf37a Bluetooth: ISO: Add support for cis_established_v2 in host
Add support for the bt_hci_evt_le_cis_established_v2 event in
the host.

This provided additional information to the host and application
about the CIS paramters. Especially the peripheral gets new an
important information such as the SDU size and interval.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-20 10:19:23 +01:00
Stine Akredalen
8df332714b bluetooth: mesh: health_cli: Add callback to pull msg for periodic pub
The Health Client model supports periodic publication and thus requires
the update callback to be initialized.

This commit implements a callback inside the health client model and
adds a wrapper to it so that the user can fill up the msg buffer.
This way, the Config Server will always accept
Config Model Publication Set message with periodic publication
parameters. If the users callback returns an error or is not
implemented, the periodic publication will be aborted.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2024-12-20 10:18:54 +01:00
Kyra Lengfeld
b65f53dd76 Bluetooth: Mesh: enable scanner before enabling proxy gatt
Once proxy gatt is enabled, due to the nature of gatt advertisements
being continuous, the controller will reject starting the scanner after
enabling proxy gatt. As such we should start the scanner first.

Currently the order works as we are using k_work to postpone the proxy
gatt service registration, because services can't be registered between
initializing BT and loading the settings.
Once we start using the new settings priority feature, we are sure to
envoke enabling proxy gatt after loading the settings, so the delayed
enabling can and should be removed.

This preventetive fix has been tested by running relevant bsim tests
after rearranging in which order the settings of the subsystems are
loaded via `h_commit`.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2024-12-19 12:37:54 +01:00
Lyle Zhu
830c1f8134 Bluetooth: AVDTP: Check buffer length before pulling it
Check the remaining data length of net buffer before pulling data from
it.

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

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-12-18 10:17:45 +01:00
Chang Kim
98928c0a4f bluetooth: host: Add conditions to ATT_READ_BY_TYPE_REQ handler
Core spec V5.4 Vol. 3 Part G 2.5.2.1 Robust Caching specifies
the conditions where Database Out Of Sync (0x12) error needs to
be returned as follows:

If a client that has indicated support for robust caching (by
setting the Robust Caching bit in the Client Supported Features
characteristic) is change-unaware then the server shall send an
ATT_ERROR_RSP PDU with the Error Code parameter set to Database
Out Of Sync (0x12) when either of the following happen:
• That client requests an operation at any Attribute Handle or
list of Attribute Handles by sending an ATT request.
• That client sends an ATT_READ_BY_TYPE_REQ PDU with Attribute
Type other than «Include» or «Characteristic» and an Attribute
Handle range other than 0x0001 to 0xFFFF.

Add the conditions to ATT_READ_BY_TYPE_REQ handler.

Signed-off-by: Chang Kim <changshik@meta.com>
2024-12-17 11:37:27 +00:00
Vinayak Kariappa Chettimada
da792a9e17 Bluetooth: Controller: Fix interleaved extended scanning assert
Fix interleaved extended scanning assert.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-12-16 10:53:30 +01:00
Make Shi
7349c8572d Bluetooth: Shell: BR: Set user data size for rfcomm tx pool
The user data size of the RFCOMM tx pool is zero. There is not enough
space to put the tx_meta data. Use CONFIG_BT_CONN_TX_USER_DATA_SIZE to
set the data size for the RFCOMM tx pool.

Signed-off-by: Make Shi <make.shi@nxp.com>
2024-12-16 08:35:10 +01:00
Make Shi
232ecfd880 Bluetooth: L2CAP_BR: Use LOG_WRN for not enough room in user_data
Using LOG_WRN could indicate that something about the user
configuration needs to be changed.

Signed-off-by: Make Shi <make.shi@nxp.com>
2024-12-16 08:34:58 +01:00
Pisit Sawangvonganan
865152fbe2 bluetooth: host: gatt: consolidate net_buf_add call
Consolidate `net_buf_add` calls using known `param->len`
to streamline the codebase.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-12-16 08:34:42 +01:00
Make Shi
345c3f17eb Bluetooth: Shell: BR: Add NULL pointer check for result->resp_buf
In case the peer device has NO SDP record, the result is valid,
but the result->resp_buf is NULL, it would introduce a hardfault.
Therefore, also add a NULL pointer check for result->resp_buf.

Signed-off-by: Make Shi <make.shi@nxp.com>
2024-12-13 09:13:17 +01:00