Commit graph

9523 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
17d695a535 Bluetooth: Controller: Simplify required ISO PDU length and buffer count
Simplify the defines calculating the minimum required ISO
PDU length and the buffer count.

Co-authored-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-24 20:18:37 +00:00
Vinayak Kariappa Chettimada
662acab1ae Bluetooth: Controller: Fix ISO Tx PDU buffer counts for fragmentation
Fix ISO Tx PDU buffer count required when SDU fragmentation
is used.

Rename BT_CTLR_CONN_ISO_SDU_LEN_MAX to
BT_CTLR_ISO_TX_SDU_LEN_MAX so the value is common to both
Broadcast and Connected ISO transmissions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-24 20:18:37 +00:00
Vinayak Kariappa Chettimada
4161db72cd Bluetooth: Controller: Rename to BT_CTLR_ISO_TX_PDU_BUFFERS
Rename the internal BT_CTLR_ISO_TX_BUFFERS to
BT_CTLR_ISO_TX_PDU_BUFFERS correct represent the number
of actual ISO PDU buffers allocated in the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-24 20:18:37 +00:00
Yago Fontoura do Rosario
ee8266797c bluetooth: id: Fix logging
* Logging module already adds a new line, no need to add it

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2025-02-24 15:37:41 +00:00
Yago Fontoura do Rosario
f0af67afa0 bluetooth: id: Fix uninitialized variable
* This variable default value has to be true, so that the
application can return false in the expired callback

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2025-02-24 15:37:41 +00:00
Luis Ubieda
f1be8afc46 bluetooth: Guard gatt_prepare_write against calls while disconnected
Fixes #84752.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-02-24 15:37:18 +00:00
Ludvig Jordet
0460c9fdae Bluetooth: Mesh: Update Kconfig help about Mesh on System WQ
This updates the help text for the Kconfig option BT_MESH_WORKQ_SYS to
take into account the change made in PR #84282 which causes the host to
no longer return -ENOBUFS. Since the mesh will now instead block the
work queue, a note has been added about a potential consequence of this.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2025-02-21 18:02:50 +00:00
Vinayak Kariappa Chettimada
d382fca6ff Bluetooth: Controller: Fix HCI command buffer allocation failure
Fix HCI command buffer allocation failure, that can cause
loss of Host Number of Completed Packets command.

Fail by rejecting the HCI Host Buffer Size command if the
required number of HCI command buffers are not allocated in
the Controller implementation.

When Controller to Host data flow control is supported in
the Controller only build, ensure that BT_BUF_CMD_TX_COUNT
is greater than or equal to (BT_BUF_RX_COUNT + Ncmd),
where Ncmd is supported maximum Num_HCI_Command_Packets in
the Controller implementation.

Relates to commit 81614307e9 ("Bluetooth: Add workaround
for no command buffer available")'.

Relates to commit 297f4f481f ("Bluetooth: Split HCI
command & event buffers to two pools").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-21 11:30:38 +00:00
Vinayak Kariappa Chettimada
cc1b53445c Bluetooth: Host: Remove nested allocation of HCI command buffer
Remove nested allocation of HCI command buffer so that one
less HCI command buffer is needed starting extended
advertising with privacy enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-21 11:30:38 +00:00
Jens Rehhoff Thomsen
c44334374e Bluetooth: host: Fix bug in scan start
When scanning is started on bt_bap_broadcast_assistant_scan_start then
BAP_BA_FLAG_SCANNING flag for the broadcast assistant instance should
not be cleared.

Fixes #85937

Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
2025-02-20 14:55:56 +00:00
Zihao Gao
7e18f8060a Bluetooth: Shell: fix assert when print address.
This patch fix the assertion caused by null address pointer
that occurs when BR/EDR pairing completed.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-02-20 11:47:39 +01:00
Pavel Vasilyev
9757ffa5fa bluetooth: host: smp: fix deadlock when public key generation fails
When `bt_le_oob_get_local` or `bt_le_ext_adv_oob_get_local` is called
and SMP is enabled, `bt_smp_le_oob_generate_sc_data` is called to
generate a Random Number and a Confirmation Value needed for OOB data.
These values are based on the device's public key.

The public key is generated only once when `bt_smp_init` is called.
If public key generation fails, the callback passed to `bt_pub_key_get`
is called with `pkey` set to NULL. The `bt_smp_pkey_ready` callback
gets called, but it doesn't release the `sc_local_pkey_ready` semaphore
thus leaving `bt_smp_le_oob_generate_sc_data` wait for semaphore with
`K_FOREVER`.

This commit replaces the semaphore with a conditional variable and
requests a public key again if the key is NULL thus solving 2 issues:
- handling the case where the callback was triggered notifying about the
  completion of the public key request, but the key was not generated,
- handling the case where multiple threads trying to acquire the same
  sempahore.

The timeout is used instead of K_FOREVER to avoid cases when callback
has never been triggered.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-02-18 18:44:23 +01:00
Lyle Zhu
3f81e81598 Bluetooth: AVDTP: Fix memory leak issue
In function `avdtp_send`, there is case that if the session->req is not
NULL, then the buf will be lost.

Release the allocated buffer by buffer allocated function when the buf
is failed to send.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-02-18 13:30:53 +01:00
Emil Gydesen
1280f432f4 Bluetooth: ASCS: Missing cleanup of stream for idle state
When the stream enters the idle state, some values were not
properly reset (e.g. the stream->ep).

Use the bt_bap_stream_detach function to clean up the stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-17 21:16:10 +01:00
Vinayak Kariappa Chettimada
dcdd330895 Bluetooth: Controller: Fix redundant reset of sync aux association
Remove redundant reset of LLL sync aux context association.

Related to commit 3263729020 ("Bluetooth: Controller: Fix
assertion terminating Periodic Sync").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-17 15:47:36 +00:00
Vinayak Kariappa Chettimada
49642efa41 Bluetooth: Controller: Fix regression in scan aux release
Fix regression in scan aux release now that aux context is
retrieved from the node rx when supporting multiple chain
reception.

Relates to commit a8065926ac ("Bluetooth: Controller: Fix
to release aux context stored in node rx").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-17 15:47:36 +00:00
Aleksandr Khromykh
acc752fce4 Bluetooth: Mesh: remove weak attribute and rename functions
Commit removes weak attribute and renames some functions
in crypto_psa.c since there is no centralized distribution
of the PSA key ID in bsim tests and no necessity to
reimplement native mesh approach.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-02-17 08:09:28 +01:00
Emil Gydesen
94d5d59be7 Bluetooth: AICS: Fix check for BT_AICS_INPUT_TYPE
The check did not take the highest value into account.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-15 07:23:37 +01:00
Emil Gydesen
907261b619 Bluetooth: BAP: Remove GATT_CACHING req for unicast server
The unicast server does not need GATT caching and it was likely
incorrectly added earlier as a dependency.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-14 19:15:57 +00:00
Emil Gydesen
9eaf232b57 Bluetooth: BAP: Fix notifications for scan delegator
Instead of providing NULL for bt_gatt_notify_uuid we
iterate on the connection objects and ensure that we
properly truncate the notification based on each
connection's GATT MTU.

This ensures that we send the right size for all
connections.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-14 19:15:42 +00:00
Emil Gydesen
7bcd1e78de Bluetooth: Audio: Add common bt_audio_get_max_ntf_size
Add a common function to get the maximum notification
size, instead of having multiple implementations of this.
Ideally this function should be moved to the GATT API,
but for now just implement it for LE audio and then move to
GATT later.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-14 19:15:42 +00:00
Emil Gydesen
317cc9d52e Bluetooth: CCP: Add missing documentation for CCP discover
Added missing documentation for
bt_ccp_call_control_client_discover.

Added missing handling of -ENOTCONN in the function as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-14 19:15:31 +00:00
Lyle Zhu
50a3a6ec7c Bluetooth: SDP: Check if frame len is consistent with attr list count
The total attributes list bytes count is only used to check the tail
room of response buffer. And the remaining frame length is used to
copy data from receiving buffer.

It does not check whether the remaining frame length is consistent with
the total attributes list bytes count.

Add the checking to make sure the attributes list is complete. And it
is used to make sure the response buffer can be accessed safety.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-02-14 19:15:02 +00:00
Zihao Gao
53bba45281 Bluetooth: AVRCP: implementation for passthrough commands
This patch alllows to send passthough command from CT to TG.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-02-14 17:13:23 +01:00
alperen sener
3fdb81cd1f bluetooth: mesh: Correct callback check mesh blob client
xfer_progress_complete should be checked instead of end callback

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2025-02-14 17:10:39 +01:00
Thomas Deppe
dcbcbe824d Bluetooth: Host: Add host support for Advertising Coding Selection
Extends the API for Advertising Coding Selection.

The API is extended to set the Advertising Coding Selection
(Host Support) bit. With this feature, the primary and
secondary PHY can now explicitly report S=2 or S=8 coding
in the extended advertising report. Previously, the report
only indicated LE Coded regardless of whether S=2 or S=8
data coding was used. The API now sets the host support bit
and ensures that the advertising PHY coding scheme is
conveyed to the application via the scan callback.

The support is enabled by CONFIG_BT_EXT_ADV_CODING_SELECTION,
and requires a controller that selects
CONFIG_BT_CTLR_ADV_EXT_CODING_SELECTION_SUPPORT.

Signed-off-by: Thomas Deppe <thomas.deppe@nordicsemi.no>
2025-02-14 17:08:23 +01:00
Emil Gydesen
fe6f63f92d Bluetooth: PACS: Add missing break in switch for sup ctx get
Add a missing break in supported_context_get, as it was not
intended to fallthrough to BT_AUDIO_DIR_SOURCE or default.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-14 17:05:47 +01:00
Tomi Fontanilles
0c368e85b1 secure_storage: add a global registry header file for PSA key IDs
We need to make sure that within Zephyr different users of the PSA APIs
don't interfere with each other because of using the same numerical IDs
for persistent assets.

This takes care of the PSA key IDs when using persistent keys through
the PSA Crypto API.
See the comments in `<zephyr/psa/key_ids.h>` for more information.

This removes the recently-introduced Kconfig options that allowed changing
the base IDs subsystems were using for their persistent keys.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2025-02-13 20:22:09 +01:00
Kamil Piszczek
7c828bd232 bluetooth: dis: add Kconfig for disabling optional characteristics
Added new Kconfig option set that allows the user to control the
presence of the following optional characteristics:

- Manufacturer Name String
- Model Number String

Depreacted the old configuration that can be deleted in the future
Zephyr releases.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2025-02-13 16:46:12 +01:00
Make Shi
f8ebbb3fef Bluetooth: AVCTP: Implement the functionality of avctp_l2cap_accept
- Implement the functionality of avctp_l2cap_accept to accept an L2CAP
  connection for the AVCTP protocol.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-02-13 12:16:30 +01:00
Marek Pieta
c7f3ad6307 bluetooth: host: Allow for ECDH operations through system workq
Change allows performing ECDH operations through system workq. This is
done to allow reducing memory consumption by disabling the long workq on
small SoCs.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2025-02-12 20:26:28 +01:00
Ingar Kulbrandstad
45f233ba61 Bluetooth: Mesh: Remove experimental TF-M PSA
Remove the experimental flag from BT_MESH_USES_TFM_PSA.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2025-02-12 20:18:16 +01:00
Vinayak Kariappa Chettimada
a8065926ac Bluetooth: Controller: Fix to release aux context stored in node rx
Fix to release aux context stored in node rx, and not in the
superior scan or sync context as the one in the superior scan
or sync context could be reset or have a different new aux
context when multiple advertising chain reception is used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:24:52 +01:00
Vinayak Kariappa Chettimada
3263729020 Bluetooth: Controller: Fix assertion terminating Periodic Sync
Fix assertion due to changes introduced to support multiple
advertising chain reception.

Auxiliary context association with the Periodic Sync context
was not cleared due to which when terminating a Periodic
Synchronization triggered an assertion check, under race
conditions, detecting that the auxiliary context was already
released.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:24:52 +01:00
Vinayak Kariappa Chettimada
2461552e19 Bluetooth: Controller: Fix Periodic Sync for multiple chain reception
Fix regression introduced in Periodic Advertising
Synchronization due to change related to multiple
Advertising chain reception.

Related commit c334ed515b ("Bluetooth: Controller: Fix
multiple Extended Adv chain reception"), and
commit da792a9e17 ("Bluetooth: Controller: Fix interleaved
extended scanning assert").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:24:52 +01:00
Emil Gydesen
571f26cf1a Bluetooth: Rename BLE to Bluetooth (LE) where applicable
The BLE acronym is not an official description of Bluetooth
LE, and the Bluetooth SIG only ever refers to it as Bluetooth
Low Energy or Bluetooth LE, so Zephyr should as well.

This commit does not change any board or vendor specific
documentation, and the term BLE may still be used in those.
It will be up to the vendors to update it if they want,
since many of them are using the term BLE in their
products.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-12 12:24:18 +01:00
Vinayak Kariappa Chettimada
8ebc4f3384 Bluetooth: Controller: Fix sync_delay and latency in LE BIG Complete
Fix missing sync_delay and transport_latency information in HCI
LE BIG Complete event.

Relates to commit 1a640e4711 ("Bluetooth: controller:
Included transport latency in LE_Big_Established").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:23:51 +01:00
Vinayak Kariappa Chettimada
83e2ec3c9b Bluetooth: Controller: Fix device address in Periodic Adv Sync
Fix incorrect device address reported in the LE Periodic
Advertising Sync Established event when using Periodic
Advertiser List.

During Extended Scanning there can be an ADV_EXT_IND PDU
received between currently being received ADV_EXT_IND PDU
and AUX_ADV_IND PDU; if the one received between has an
address match then incorrectly the Periodic Synchronization
was established to the device whos AUX_ADV_IND PDU is being
received. Fix by storing the auxiliary context that has the
address match and compare with it when matching the SID in
SyncInfo of AUX_ADV_IND PDU being received prior to creating
the synchronization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:22:52 +01:00
Vinayak Kariappa Chettimada
5119896c7d Bluetooth: Controller: Fix BT_CTLR_LOW_LAT_ULL conditional code
Fix BT_CTLR_LOW_LAT_ULL conditional compilation code by
decoupling it from BT_CTLR_LOW_LAT code.

BT_CTLR_LOW_LAT_ULL makes ULL execution context to tailchain
in comparison to continuously process in a while loop.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:22:18 +01:00
Emil Gydesen
49d9b4cb69 Bluetooth: PACS: Remove BAP infix for pacs_register_param
Since the PACS service is not part of the bt_bap API it should
not use the bt_bap prefix, and instead just be bt_pacs like the
rest of the PACS API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-12 09:41:49 +01:00
Johan Hedberg
90367c8dd1 Bluetooth: Host: Classic: Fix allocated PSM comparison
The code for checking for allocated BR/EDR PSMs was potentially resulting
in an integer overflow, due to doing a <= UINT16_MAX (0xffff) comparison
on a uint16_t variable. To avoid this, use a uint32_t variable internally.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-02-12 02:26:57 +01:00
Emil Gydesen
b67d291207 Bluetooth: Host: Add type check for bt_conn API
Added a new function, bt_conn_is_type, that returns whether
the provided conn object is of the provided type.

This check is then used to ensure that the conn objects
supplied to other bt_conn function are of the right type.
The right type has also been documented for these functions.

This is an initial commit for a larger change in the BT Host,
as similar checks should be added to the L2CAP, GATT, ISO,
Audio and possibly Mesh APIs.

The type check could have been implemented by using the
bt_conn_get_info function, but that requires additional
function calls as well as memory allocation and copy.
Since bt_conn_is_type is designed to be widely used, it
was suited for its own function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-11 22:04:51 +01:00
Aleksandr Khromykh
4bb595718d Bluetooth: Mesh: remove double cdb node storing
Commit removes the double cdb node entry storing
into the settings if device was reprovisioned over
nppi interface.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-02-11 18:56:37 +01:00
Emil Gydesen
788486b972 Bluetooth: ISO: Add range to BT_ISO_MAX_BIG
If BT_ISO_BROADCAST is enabled, then we shall support
at least 1 BIG and at most BT_EXT_ADV_MAX_ADV_SET since
each BIG requires its own advertising set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-11 15:42:03 +01:00
Lingao Meng
f5bd2170d1 tests: bsim: Add testcase for bluetooth mesh extended advertiser
Add some configuration for test adv_ext.c

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-02-11 15:38:35 +01:00
Lingao Meng
2ebdcfa963 Bluetooth: Mesh: Remove START_PENDING flags
Remove START_PENDING flag, and replace with
bt_mesh_adv_is_empty_by_tag

not only make adv_ext.c more readable, but also enhancement

In previous implementation, after proxy started, will check
this flag, and when the flag is true, will direct stop proxy
and re-enter schedule, but has one problem, this flag set true,
but buf will be empty, such as when sending mesh relay messages
will for-each every sets, until find not-active, but also set
previous set START_PENDING flags, so will cause proxy advertising
started->stop->started.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-02-11 15:38:35 +01:00
Lingao Meng
bcac572ab4 Bluetooth: Mesh: Remove ADV_FLAG_PROXY_START, due to meanless
The first why introduce ADV_FLAG_PROXY_START
see here(https://github.com/zephyrproject-rtos/zephyr/pull/58826)

The main core change is to mark ADV_FLAG_PROXY as moving to the last
enabled proxy instead of before.

But introducing the ADV_FLAG_PROXY_START flag seems meaningless.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-02-11 15:38:35 +01:00
Tom Hughes
8218bf6b0a Bluetooth: TBS: Fix -Wsometimes-uninitialized warning
Building bluetooth.shell.audio.only_gtbs with clang warns:

subsys/bluetooth/audio/tbs.c:1646:6: error: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
        if (param->gtbs) {
            ^~~~~~~~~~~
subsys/bluetooth/audio/tbs.c:1667:9: note: uninitialized use occurs here
        return ret;
               ^~~
subsys/bluetooth/audio/tbs.c:1646:2: note: remove the 'if' if its
condition is always true
        if (param->gtbs) {
        ^~~~~~~~~~~~~~~~~
subsys/bluetooth/audio/tbs.c:1626:9: note: initialize the variable 'ret'
to silence this warning
        int ret;
               ^
                = 0

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-11 03:07:39 +01:00
Emil Gydesen
9fca7ee3a5 Bluetooth: Controller: Fix casting in radio_aa_set for BASE0
We have previously fixed an issue with shifting and
assigning the value without a cast, but coverity
is still complaining about aa[1] and aa[0] with:

"Casting narrower unsigned aa[1] to wider signed type
int effectively tests its lower bound."

Using the common function, sys_get_le24, should fix this issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-11 03:07:27 +01:00
Pavel Vasilyev
b7f16f1041 bluetooth: mesh: delayable_msg: cast to avoid truncation issue
Explicitly cast Kconfig option value to avoid truncation issue reported
by Coverity.

Fixes #84697
Coverity-CID: 487737

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-02-10 22:26:31 +01:00