Commit graph

9787 commits

Author SHA1 Message Date
Dmitrii Sharshakov
114bc8086d Bluetooth: ISO: fix hci_le_set_cig_params validation
Sizeof of a pointer doesn't make sense here, and
e.g. on native_sim/native/64 this would fail.

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2025-04-30 23:03:07 +02:00
Vinayak Kariappa Chettimada
5b17b5b44f Bluetooth: Controller: Fix adv aux release on insufficient resources
Fix missing adv aux release on insufficient adv data buffers
configured when starting multiple extended advertising sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-04-30 16:26:48 +02:00
Lyle Zhu
cd43e03bbe Bluetooth: classic: shell: Support L2CAP channel seg_recv
Add the callback function `seg_recv` if the configuration
`CONFIG_BT_L2CAP_SEG_RECV` is enabled.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-30 14:00:06 +02:00
Lyle Zhu
df1e2264ff Bluetooth: Classic: L2CAP: Fix seg_recv cannot work issue
When the L2CAP channel connection is in none basic mode, the
`seg_recv` cannot work properly if the configuration
`CONFIG_BT_L2CAP_SEG_RECV` is enabled. And the L2CAP channel
connection will be broken incorrectly.

Check whether the received data len exceeds the SDU length if the
`SAR` is `BT_L2CAP_CONTROL_SAR_END` or `BT_L2CAP_CONTROL_SAR_CONTI`.

And check whether the SDU length is valid if the `SAR` is
`BT_L2CAP_CONTROL_SAR_UNSEG` or `BT_L2CAP_CONTROL_SAR_START`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-30 14:00:06 +02:00
Emil Gydesen
24037ef20a Bluetooth: CAP: Broadcast: Add missing ISO test parameters
The cap_initiator_broadcast_to_bap_broadcast_param function
did not properly relay the ISO test parameters from the CAP
parameters to the BAP parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-30 10:54:56 +01:00
Troels Nilsson
9fbfa1f626 Bluetooth: Controller: Only validate CIS SDU interval for BN > 0
Some in-the-wild devices use SDU interval of 0 when BN == 0; This
is not allowed by BT Core Spec v6.0, but is not specifically
mentioned in v5.4 and earlier. To allow connecting a CIS to these
devices, relax the check on SDU interval

Note: LL/CIS/PER/BI-07-C only checks rejection of invalid SDU interval
with BN > 0, so it still passes with this change

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-04-30 09:48:24 +02:00
Lyle Zhu
e1d9db8b6e Bluetooth: Classic: L2CAP: Handle shorter data length of the request
The response L2CAP_COMMAND_REJECT_RSP(BT_L2CAP_REJ_NOT_UNDERSTOOD)
should be replied if the received L2CAP command is a invalid L2CAP
signaling command packets with extra data in the Information Payload.

Send L2CAP_COMMAND_REJECT_RSP(BT_L2CAP_REJ_NOT_UNDERSTOOD) if it a
small L2CAP signaling PDU or it has short length.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-30 07:52:03 +02:00
Johan Hedberg
fd037c7990 Bluetooth: Kconfig: Remove outdated references to bt_recv_prio()
The bt_recv() and bt_recv_prio() APIs don't exist anymore, so remove any
references to them from the Kconfig help texts.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 16:51:04 +02:00
Olivier Lesage
f4aa29d849 bluetooth: host: Fix param_len for LE CS Test command
The parameter length for this command was missing the additional
length from the arrayed parameters.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-04-29 16:49:10 +02:00
Johan Hedberg
f85d63a6cc Bluetooth: Remove USB H4 mode support
This non-standard feature never had any proper host side implementation
(e.g. it was never upstreamed to BlueZ), and since it comes with notable
maintenance overhead it's fair to just remove it.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 13:00:33 +02:00
Johan Hedberg
6113230ce3 Bluetooth: drivers: Update to use new H:4 buffer encoding
Update all HCI drivers to use the new H:4 encoding for buffers passing
to/from drivers.

One behavioral change that's done in favor of simplicity, is that where
there's previously been switch statements that could return an error for
unsupported packet types now simply pass any received packet unchanged to
lower layers of the controller (or the HCI transport). Handling this is
now the responsibility of the lower layers, however in practice hitting
such scenarios means that there's a mismatch between configured host and
controller features.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 13:00:33 +02:00
Johan Hedberg
26d97164be Bluetooth: HCI: Use H:4 encoding for buffers
Encode the packet type as a H:4 payload prefix for buffers passing to &
from HCI drivers. The existing bt_buf_set/get_type functions are
deprecated, but kept compatible with the change, except that they can only
be called once, since they modify the buffer payload.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 13:00:33 +02:00
Emil Gydesen
54df371740 Bluetooth: TBS: Add support for long read with dirty bit
The TBS spec states that if a value is changed during a
long read procedure, then the server shall reject
read requests with offset != 0 with a specific TBS GATT
error until the value has been read from the beginning again
(i.e. with offset = 0).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-29 13:00:07 +02:00
Jiawei Yang
8b3eb368c6 Bluetooth: RFCOMM: Add RPN command sending support
Add support for Remote Port Negotiation (RPN) commands in the RFCOMM.
This allows applications to configure the serial port parameters
over RFCOMM connections, such as baud rate, data bits, stop bits, parity
and flow control.

Changes include:
- Add enumerations for RPN parameters (baud rate, data bits, stop bits,
  parity)
- Add a public API function bt_rfcomm_send_rpn_cmd() to send RPN
  commands
- Add shell command to test RPN with default parameters

This functionality is required by certain Bluetooth profiles that use
RFCOMM and need to configure serial port parameters.

Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
2025-04-29 08:17:49 +01:00
Lyle Zhu
597d76ce7d Bluetooth: Classic: HFP_HF: Fix out of bounds issue
Check whether the conn index is out of bounds.

CID 520290

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-29 08:17:28 +01:00
Lyle Zhu
be11f6fb0b Bluetooth: Classic: HFP_AG: Fix out of bounds issue
Check whether the conn index is out of bounds.

CID 520297
CID 520296

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-29 08:17:28 +01:00
Lyle Zhu
a1dce20e04 Bluetooth: Classic: L2CAP: Make TxWindow size on both sides the same
In retransmission mode and flow control mode, the TxWindow size should
be same on both sides.

When one side is updated, also update the other side.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-29 08:17:06 +01:00
Emil Gydesen
68652a6682 Bluetooth: CAP: Broadcast: Add check for memory allocation for create
When creating a broadcast source with
bt_cap_initiator_broadcast_audio_create there was no check if
all broadcast sources were already allocated, which could cause
a NULL pointer dereference.

Add a check, a test and documentation about possibly
error codes of the function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-28 16:41:06 +02:00
Lyle Zhu
6661952dd4 Bluetooth: Classic: SSP: Fix bonding flag mismatch issue
A bonding issue is found with following conditions,
a. Local is a SSP initiator and it is in non-bondable mode,
b. Peer is in bondable mode,
c. The bonding flag in Authentication_Requirements of local IOCAP is
`No Bonding`,
d. the bonding flag in Authentication_Requirements of peer IOCAP is
`Bonding`.

The bonding information will be exchanged and stored. It is incorrect
behavior.

Fix the issue by reporting a pairing failure and disconnecting the ACL
connection with error `BT_HCI_ERR_AUTH_FAIL`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-28 13:41:25 +01:00
Lyle Zhu
76c072549d Bluetooth: Classic: L2CAP: Fix the FCS incorrect issue
The FCS flag of TX direction is not set correctly if the FCS flag of
RX direction is set. The issue could be found with following steps,
Step 1, Local sends configuration request with ERET mode and FCS
omitted.
Step 2, Peer replies the configuration response without any errors.
Step 3, Peer sends configuration request with ERET mode and NO FCS.
Step 4, Local replies the configuration response without any errors.

The FCS flag of TX is cleared incorrectly.

The FCS should be enabled if any one side enables the FCS.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-28 08:36:13 +02:00
Lyle Zhu
b3581fe1d4 Bluetooth: Classic: L2CAP: Handle multi L2CAP packets of a HCI ACL
In current implementation, if the HCI ACL data length exceeds on L2CAP
packet, the HCI ACL data will be discarded.

Support the case if the transport is classic.

Add a function `bt_br_acl_recv()` to handle the multi L2CAP packets
one by one.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-28 08:36:02 +02:00
Troels Nilsson
4aad818ec2 Bluetooth: Controller: Fix window widening for parameter update
When applying the connection parameter update, the window widening
for the previous connection interval was not applied since that is
normally done in LLL

Fixed by applying the window widening in ull_conn_update_parameters()
instead in this case

Fixes EBQ test failure in LL/CON/PER/BV-10-C

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-04-25 15:56:04 +02:00
Aleksandr Khromykh
855639a3db bluetooth: mesh: keep scanner enabled if lpn has been disabled
Commit fixes the issue when scanner is disabled when
lpn is disabled.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-04-25 14:05:27 +02:00
Nithin Ramesh Myliattil
a94cdafdb7 Bluetooth: CSIP: Fix ntf issue to clients on reboot
On reboot, client list to notify is not updated properly.
Fix is to check and add the reconnected clients on
security changed cb.

Subscription check is added before notify to clients.
BT Enable check is added in the register function before adding
bonded devices to client list.

Also typo is corrected in add_bonded_addr_to_client_list in the
second loop.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2025-04-25 14:04:37 +02:00
Jens Rehhoff Thomsen
73000a6154 Bluetooth: host: Ensure BASS notifications are sent
Update bit array (number of connections) added for each receive state.
Notifications are attempted to be sent in the system workqueue and
retried if failing.

Issue #85487

Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
2025-04-25 14:04:12 +02:00
Max Emde
e04d828219 Bluetooth: BAP: Update encrypt_state when BIG synced after bad code
- When encrypt_state in a receive state of the scan delegator is
  BT_BAP_BIG_ENC_STATE_BAD_CODE, make sure that on synchronization
  encrypt_state is updated to BT_BAP_BIG_ENC_STATE_DEC, as this
  implies that a correct code was provided, so that the broadcast
  assistant is not asked for a correct code any longer.

Signed-off-by: Max Emde <mxem@demant.com>
2025-04-24 11:57:25 +02:00
Emil Gydesen
c8742a3cec Bluetooth: Mesh: Add missing includes to va.h
The va.h file used both uintX and bool without including
the appropriate header files, which can cause a compile issue
if the file is included in the wrong order.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-24 10:39:21 +02:00
Mark Wang
5c4dece721 bluetooth: classic: smp: fix the wrong Responder Key Distribution
BR_SEND_KEYS_SC should be used to determine the value of
Responder Key Distribution when sending pairing_response to
reply smp br pairing_request.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-04-23 10:04:23 +02:00
Emil Gydesen
11c3ee12a8 Bluetooth: BAP: Sink: Move mod_src_param to RAM
The mod_src_param was several places stored on the stack.
However this is a complex paramater struct that has
2 Kconfig options that can significantly increase the size,
and the maximum size of the parameter is nearly 8 KiB, and
was always place the in the BT RX thread's stack.

For this reason, the param is now stored in a single
static variable in RAM instead, so that the BT RX thread's stack
does not need to be increased based on the Kconfig options,
as that is quite difficult for users to be aware of.

The add_src_param has been left as is, as that stored in
the calling thread, and it is easier for an application
to determine if the calling thread needs additional stack
space.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-22 16:53:58 +02:00
Gudipudi Ramana Kumar
aafcd4f851 bluetooth: audio: Update bad code in BASS to be v1.0.1 compliant
Bad Broadcast Code in BASS/Scan Delegator if BIG_Encryption
field value = 0x03 (Bad_Code), Bad_Code shall be set to the
value 0xFFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF according to BASS v1.0.1

Signed-off-by: Gudipudi Ramana Kumar <gudipudiramanakumar@gmail.com>
2025-04-22 16:53:49 +02:00
Make Shi
d879e8482f Bluetooth: Classic: L2CAP: Set the BR chan identifier for PENDING Case
When the connection status is "PENDING", need reset the br channel
identifier to the correct value before resend the connection response,
otherwise these is in an "ident mismatch" error being reported.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-04-22 10:00:08 +02:00
Lyle Zhu
40b10ccf8d Bluetooth: Classic: SSP: Only set MITM when sec level is more than 2
The local device shall only set the MITM protection required flag if
the local device itself requires MITM protection.

Only set MITM flag when the required security level is more than 2 and
pairing method is not `JUST_WORKS`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-21 12:43:42 +02:00
Emil Gydesen
efdca63c25 Bluetooth: Host: Add missing includes for all BT host files
Added missing includes and fixed typos in the files.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-17 21:17:29 +02:00
Emil Gydesen
1efd817dbd Bluetooth: Shell: Add missing includes for all BT host shell files
Added missing includes and fixed typos in the files.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-17 21:17:29 +02:00
Aleksandr Khromykh
b53b5e198a bluetooth: rename _bt_gatt_ccc and clarify usage
Bluetooth had two public types with similar name _bt_gatt_ccc and
bt_gatt_ccc, but for absolutely different purposes.
That caused misunderstanding of relationship of them and cases
where to use which one.

Commit changes name of _bt_gatt_ccc to more suitable by usage and
improves documentation of it.

Additionally, it changes name of BT_GATT_CCC_INITIALIZER
to correspond the type name.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-04-17 17:24:19 +02:00
Toon Stegen
a4f89574b9 bluetooth: increase stack size for NO_OPTIMIZATIONS
when building without optimizations, the bt long thread needs more space
to not crash

Signed-off-by: Toon Stegen <toon@toostsolutions.be>
2025-04-16 17:08:02 +02:00
Emil Gydesen
da953b64c2 Bluetooth: Host: Shell: Add missing guard for CS test commands
The start_simple_cs_test and stop_cs_test depends on
CONFIG_BT_CHANNEL_SOUNDING_TEST and could cause build errors if that
is disabled while CONFIG_BT_CHANNEL_SOUNDING=y in the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-16 08:04:53 +02:00
Théo Battrel
77bdc8a435 Bluetooth: Add usage of util_eq and util_memeq
Update `bt_irk_eq` to use `util_memeq` instead of `memcmp` and the
"disconnect" BabbleSim test to use `util_eq` instead of a first
assertion on the size followed by a `memcmp`.

This is done as an example usage of the two new functions.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2025-04-14 16:06:38 +02:00
Mark Wang
6c9e478e49 Bluetooth: Classic: Fix assert when aborting initiating SCO connection
return an error instead of assert

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-04-14 13:06:20 +02:00
Lyle Zhu
918b91bc85 Bluetooth: Classic: Shell: HFP: Clear all calls if SLC is broken
If the SLC is broken, all saved calls should be cleared.

Clear all calls in the callback `hf_disconnected()` and
`ag_disconnected()`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-14 09:47:48 +02:00
Lyle Zhu
03ca91fef4 Bluetooth: Classic: HFP_AG: Don't change call status if SLC broken
In current implementation, the active/hold call will be terminated
and notify the upper layer the status change of calls when the SLC
is broken. But the calls should not be terminated in this case.

Do not terminate the calls and only clear the status of all calls.
And disconnect the SCO connection if it is established.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-14 09:47:41 +02:00
Emil Gydesen
ff9a9fe031 Bluetooth: BAP: Release read_buf_sem in receive_state_updated earlier
The semaphore should be returned before calling the application
callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-11 22:06:44 +02:00
Troels Nilsson
c3df8fcd92 Bluetooth: Controller: Add validation of received LL_CIS_REQ
Validate that a received LL_CIS_REQ is valid and reject if it is not

Fixes EBQ test failure in LL/CIS/PER/BI-07-C

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-04-10 15:51:54 +02:00
Ying Zhang
ce771c57e6 bluetooth: host: fix hang issue caused by consecutive bt disable commands
- add BT_DEV_DISABLE flag to BT_DEV_PERSISTENT_FLAGS to
  protect consecutive bt disable from running

Signed-off-by: Ying Zhang <ying.zhang_2@nxp.com>
2025-04-10 13:02:41 +02:00
Emil Gydesen
a4f8744ccf Bluetooth: CCP: Client: Add get_bearers
Add bt_ccp_client_get_bearers that will return the bearers of
a client so that the application can always retrieve them if they
do not store them from the discovery callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-09 15:23:07 +02:00
alperen sener
5b8b94e664 Bluetooth: Mesh: Stop Private NID advs upon subnet removal
Private Node Identity advertisement on a subnet should stop as soon as
the network is removed.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2025-04-09 11:43:29 +02:00
Lyle Zhu
979b088882 Bluetooth: Classic: Shell: Change acronyms to uppercase
Change `ag` of print message to `AG`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-09 08:06:04 +02:00
Lyle Zhu
3f7224a926 Bluetooth: Classic: HFP_AG: Update the callback sco_disconnected()
Change the arguments of HFP AG callback `sco_disconnected()` to SCO
conn and disconnection reason.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-09 08:06:04 +02:00
Dereje Wassie
e1d2f09898 Bluetooth: pacs: Fixed pacs_get_available_context
Fixed the bt_pacs_get_available_context API to return values of type
bt_audio_context instead of an error type.

Signed-off-by: Dereje Wassie <deiw@demant.com>
2025-04-08 14:23:30 +02:00
Lars-Ove Karlsson
76969f82a4 bluetooth: host: Avoid warning for unaligned access
Rewrote places in the bluetooth code that converts objects
larger than one byte by taking the address of an unaligned struct
member and changed it to a function that takes the value directly
and converts it to big endian.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2025-04-08 08:58:06 +02:00