Commit graph

8828 commits

Author SHA1 Message Date
Troels Nilsson
6f64f77557 Bluetooth: Controller: Remove incorrect check of RFU bit
RFU bits has to be ignored according to the spec; In addition,
some MediaTek devices seems to have it set (by mistake I assume),
so having the check means we cannot sync to these devices

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-10-18 17:47:14 +01:00
Vinayak Kariappa Chettimada
b4182caf77 Bluetooth: Controller: Fix Periodic Adv Chain PDU channel indices
Fix missing population of channel indices for Periodic
Advertising Chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 17:46:23 +01:00
Vinayak Kariappa Chettimada
1eb74c43df Bluetooth: Controller: Fix Extended Adv Chain PDU channel indices
Fix missing population of channel indices for Extended
Advertising Chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 17:46:23 +01:00
Pavel Vasilyev
8acb1cc577 bluetooth: host: conn: Check if *conn is not NULL
This commit adds a warning and a Kconfig option to `bt_conn_le_create`
and `bt_conn_le_create_synced` functions which are meant to warn a user
of a potential leakage of an active connection object.

This change is implemented due to frequent incorrect use of the
connection pointer where a pointer to an existing connection object
is overwritten by `bt_conn_le_create` and `bt_conn_le_create_synced`
functions which in turns leads to sporadic critical bugs. See
https://github.com/zephyrproject-rtos/zephyr/pull/78284#discussion_r1754304535
for more details.

The Kconfig option is introduced instead of always returning the error
to not affect current implementations. However, it is recommended to
keep this option enabled to avoid potential bugs.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-10-18 17:46:04 +01:00
Adam Cavender
18f508144e bluetooth: host: CS support for various HCI commands
Adds HCI support for:
- LE CS Security Enable
- LE CS Procedure Enable
- LE CS Set Procedure Parameters
- LE CS Set Channel Classification
- LE CS Read Local Supported Capabilities
- LE CS Write Cached Remote Supported Capabilities
- LE CS Write Cached Remote FAE Table

Signed-off-by: Adam Cavender <adam.cavender@nordicsemi.no>
2024-10-18 14:15:49 +02:00
Vinayak Kariappa Chettimada
ee844550b7 Bluetooth: Controller: Fix short prepare timeout start (2nd attempt)
Fix to setup correct short prepare timeout when preempt
callback does not find the prepare in the head of the
pipeline. In this case, find the short prepare and setup
a fresh preempt timeout for the determined short prepare
present in the pipeline.

Relates to commit 7d1bc1789e ("Bluetooth: Controller: Fix
short prepare preempt timeout start").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Vinayak Kariappa Chettimada
ccec1d5150 Bluetooth: Controller: Fix delayed ULL scheduling aux PDU reception
Fix delayed ULL scheduling an auxiliary PDU reception by
skipping it. When many bufferred ADV_EXT_IND are to be
processed, the ULL scheduling could get late and then cause
the scan aux LLL to detect increased overhead start timing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Vinayak Kariappa Chettimada
7d21a61f64 Bluetooth: Controller: Fix to reschedule at window start
Fix to reschedule at window start when there are no more
tickers in the list to check for overlap.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Vinayak Kariappa Chettimada
557376a2ce Bluetooth: Controller: Fix ticks_elapsed use in reschedule_in_window
Remove ticks_elapsed use in reschedule_in_window as it has
already been used in the bottom half processing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Vinayak Kariappa Chettimada
c96375ec1e Bluetooth: Controller: Simplify ticker reschedule_in_window
Simplify ticker reschedule_in_window implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Vinayak Kariappa Chettimada
b5ec75d964 Bluetooth: Controller: Refactor to not invoke function as parameter
Minor refactor to not invoke function as parameter being
passed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Vinayak Kariappa Chettimada
bc0b283731 Bluetooth: Controller: Fix BT_RX_STACK_SIZE required
During use of tests/bluetooth/shell application to perform
extended scanning with periodic advertising and broadcast
audio source devices around, it was observed that the
application crashed due to too low BT_RX_STACK_SIZE, hence
increase by 128 bytes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Vinayak Kariappa Chettimada
5dfc58cff9 Bluetooth: Controller: Fix single switch timer minimum compare value
Fix implementation of single switch timer minimum compare
value requirement. Do not always add the maximum possible
radio latency duration, but check if the required compare
value is smaller, then use the remainder required as the
extra compare value. This fix reduces latencies to setup
radio receptions and fixes an assertion in lll_scan_aux
when radio_tmr_start_us() is checked for latencies.

Relates to commit bcd28e0a86 ("Bluetooth: Controller:
Fix sw switch single timer for spurious TXEN/RXEN").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-18 14:15:23 +02:00
Sungwoo Kim
2f50e26c40 Bluetooth: HCI: Add validation for data from controllers
Like 2ca179c, check and warn if incoming HCI event parameters exceed
the specification. This helps debugging controllers by detecting the
out-of-spec value that shouldn't appear.

Signed-off-by: Sungwoo Kim <iam@sung-woo.kim>
2024-10-18 09:17:57 +02:00
Nithin Ramesh Myliattil
40a8870c2e bluetooth: BAS: update helper text indentation of BAS Kconfig
Fix the indentation issue of BAS KConfig

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2024-10-17 15:35:58 -04:00
Szymon Janc
5b232bf1d7 Bluetooth: GATT: Allow to tune writable device appearance permissions
This allows to select if device appearance requires encryption or
authentication or none. This makes it similar to what is implemented
for device name characteristic.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-10-16 16:35:56 +01:00
Szymon Janc
398487f841 Bluetooth: GATT: Convert writable device name to KConfig choice
This makes it clear on how security requirements are set and avoid
confusion on how encryption and authentication are handled.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-10-16 16:35:56 +01:00
Lyle Zhu
0e4561bed2 Bluetooth: SSP: No MITM if required level is less than L3
Regardless IO capabilities, clear MITM flag for pairing
initiator if the required security level is less than
BT_SECURITY_L3.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-16 09:59:38 +02:00
Lingao Meng
537d215981 Bluetooth: Mesh: Fixes after proxy advertising unable to send messages
When Proxy advertising or PB-GATT Advertising Enabled and use a same
advertising sets.

As adv\_start will call multi HCI Command will cause syswork_q yield.
At same time, if another thread(BT RX) all schedule\_send will cause
unable send mesh message, because ADV\_FLAG\_ACTIVE was be set, but
ADV\_FLAG\_PROXY not set currentlly.

Add ADV\_FLAG\_SCHEDULE\_PENDING indicate mesh buf has been pendings
but not scheduled, so when proxy advertising enable, let's take again,
as we can't break or terminated adv\_start, so we must waiting proxy
advertising enabled.

But after https://github.com/zephyrproject-rtos/zephyr/pull/68558

The `k_work_is_pending` always true in `send_pending_adv`, which cause
unable to send more mesh message until more mesh message comming

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-10-16 09:58:33 +02:00
Lingao Meng
664c087d55 Bluetooth: Mesh: Refine Mesh store logic
Move flag&handler to structure, not only save some flash size
but also make code more readable.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-10-16 09:56:26 +02:00
Burak Gorduk
c5a126cedb bluetooth: host: LE CS subevent result reassembly
Adds HCI support for LE CS subevent result continue
event and the reassembly logic for the partial results.

When subevent results are completed or the subevent is
aborted, the user callback is invoked with a buffer
pointing to the HCI event buffer, so no copy is done.

When subevent results are incomplete, then a reassembly
buffer is allocated from a fixed sized pool. This buffer
is used for the reassembling of the subevent result
containing all of the step data, which is then passed
to the user via the callback. kconfigs have been added
to set the size and the count of the reassembly buffer.

Signed-off-by: Burak Gorduk <burak.gorduk@nordicsemi.no>
2024-10-15 19:09:05 -04:00
Emil Gydesen
203bcf3774 Bluetooth: CCID: Make the CCID API public
Move the CCID header to the include directory
to make it public.

This also compiles the ccid.c file whenver CONFIG_BT_CONN
is enabled, rather than having an additional Kconfig for it,
since the API is now public and may be used by other than
our internal services.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-15 04:10:28 -04:00
Emil Gydesen
5f1a573809 Bluetooth: CCID: Improved CCID allocation
Rather than throwing an assert, it will now do a better
check for already-allocated CCIDs and return an error instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-15 04:10:28 -04:00
Emil Gydesen
7461f3781e Bluetooth: CCID: Rename ccid_get_value to alloc_value
alloc_value is more correct as it does allocate a new
value, rather than just returning/getting a value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-15 04:10:28 -04:00
Erik Sandgren
5f59b35b42 Bluetooth: Host: Fix issue where uninitialized value was used
This change makes sure that when a call to `bt_id_set_scan_own_addr` is
sucessful, i.e., the return value is 0, the `own_addr_type` will
be set by the `bt_id_set_scan_own_addr`.

Not setting the `own_addr_type` in a successful call to
`bt_id_set_scan_own_addr` causes, for example,
the `start_le_scan_ext` method in `scan.c` to use an
uninitialized `own_addr_type`.

Eventually this results in an unexpected failure further down in
`start_le_scan_ext`, when sending HCI command to controller with
an uninitialized `own_addr_type`.

Signed-off-by: Erik Sandgren <erik.sandgren@nordicsemi.no>
2024-10-15 04:07:50 -04:00
Lars Knudsen
e0a262b33f Bluetooth: Audio: Fix initial Broadcast source values
If the Broadcast ID is initially set to 0x000000,
which is valid, comparison logic on add of an
actual Broadcast ID of 0x000000 fails.

Likewise for SID.

Moving INVALID_BROADCAST_ID define to bap.h

Signed-off-by: Lars Knudsen <LAKD@demant.com>
2024-10-14 13:04:31 +02:00
Marek Pieta
341f1f502d bluetooth: conn: Use a separate workqueue for connection TX notify
Use a separate workqueue instead of system workqueue for connection TX
notify processing. This makes Bluetooth stack more independent from the
system workqueue.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2024-10-11 13:16:26 -04:00
Vinayak Kariappa Chettimada
ad6c0512ad Bluetooth: Controller: Fix CIS payload count under skipped events
Fix CIS payload count calculation under skipped events that
caused CIS disconnection with reason MIC failure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-10 20:23:36 -04:00
Lars Knudsen
405492f009 Bluetooth: Audio: Shell: Fix BIS sync bit field validity check
NO PREF (0xFFFFFFFF) and BIT(0) was wrongly rejected.

Signed-off-by: Lars Knudsen <LAKD@demant.com>
2024-10-10 20:22:39 -04:00
Lars Knudsen
7f1589e23b Bluetooth: ISO: Add ISO BIS bitfield check macro
Checks validity of ISO BIS bitfield (BIT(0)|...|BIT(30))

Signed-off-by: Lars Knudsen <LAKD@demant.com>
2024-10-10 20:22:39 -04:00
Jordan Yates
257c5e6aff bluetooth: conn: increase log level of timeout ignore
Notifying users that the supplied timeout is being ignored is worthy of
a higher log level than debug. Any such usage should be changed at the
application level.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-10-10 14:59:16 -04:00
Pavel Vasilyev
74972e694b bluetooth: host: l2cap: Check conn state before queueing PDU
In case of UATT, if a connection was lost while user was holding a read
or write attribute callback, `bt_l2cap_send_pdu` (called from
`att.c::chan_send`) will anyway queue a PDU and trigger tx work. The PDU
won't be sent eventually, but neither will hold an error code, which
will allow it to bypass the error check in `att_on_sent_cb` and call
`att_sent` function.

For EATT `bt_l2cap_chan_send` is used which already handles this case
and the error code is passed to `att_on_sent_cb`.

This change adds connection state check to `bt_l2cap_send_pdu`
preventing from unnecessary code execution when connection does not
exist anymore.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-10-10 14:59:02 -04:00
Pavel Vasilyev
f7e8a8717b tests: bsim: bluetooth: host: att: Add ATT timeout test
This commit tests that the host correctly disconnects from peer when ATT
timeout happens.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-10-10 14:59:02 -04:00
Pavel Vasilyev
f712bde122 bluetooth: host: att: Implement disconnect on ATT timeout
The timeout state is local and can block new ATT operations, but does
not affect the remote side. Disconnecting the GATT connection upon ATT
timeout simplifies error handling for developers. This reduces rare
failure conditions to a common one, without needing special cases for
ATT timeouts.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-10-10 14:59:02 -04:00
Nithin Ramesh Myliattil
de14efef98 Bluetooth: BASS: add scan cb to scan delegator module.
Add scan cb to scan delegator so that Application
can be notified  when assistant starts or stops
scanning.
Also state information of Broadcast Assistant
is removed as info is not used.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2024-10-10 10:06:43 +02:00
Vinayak Kariappa Chettimada
247037bd3e Bluetooth: Controller: Fix incorrect elapsed events value
Fix incorrect elapsed events value when event prepare are
aborted in the pipeline. This caused premature supervision
timeouts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-09 18:23:10 +01:00
Vinayak Kariappa Chettimada
e21ff7067d Bluetooth: Controller: Fix BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN
Fix BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN such that event is not
aborted when near supervision timeout conditions.

Relates to commit ddf04997a5 ("Bluetooth: Controller: Add
abort fairness in overlapping Periodic Sync").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-09 18:23:10 +01:00
Vinayak Kariappa Chettimada
468b60087e Bluetooth: Controller: Introduce BT_CTLR_PERIPHERAL_ISO_RESERVE_MAX
Introduce BT_CTLR_PERIPHERAL_ISO_RESERVE_MAX Kconfig option
so that disabling this option will use minimum time
reservation and exercise the peripheral ISO connection event
continuation using is_abort_cb mechanism.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-09 18:23:10 +01:00
Vinayak Kariappa Chettimada
cadef5a64f Bluetooth: Controller: Introduce BT_CTLR_PERIPHERAL_RESERVE_MAX
Introduce BT_CTLR_PERIPHERAL_RESERVE_MAX Kconfig option so
that disabling this option will use minimum time reservation
and exercise the peripheral connection event continuation
using is_abort_cb mechanism.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-09 18:23:10 +01:00
Yago Fontoura do Rosario
029540abec Bluetooth: Controller: Handle overlapping buffers on ull_adv{.c,_aux.c}
* Setting the adv data, scan rsp and adv aux ad data can happen on
overlapping buffers
* There can be other memcpy's that need to be changed to memmove but
these are the only ones I could reproduce the issue and since memmove
has a performance penalty, I left the others as is.

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2024-10-09 13:59:07 +02:00
Emil Gydesen
e7e7386352 Bluetooth: BAP: Modify unicast client callbacks to slist
Modify the BAP unicast client callback structure to be a
linked list. The purpose of this is to have multiple listeners
of the unicast client changes and notifications.
This is needed for the CAP initiatior.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-09 09:42:30 +02:00
Ingar Kulbrandstad
b32eb0d2b2 Bluetooth: Mesh: Fix out of bounds write
Fix of the subnet bridging table function to only
compact the table if elements has been removed, and
fixing the compact function to compact the table if
several elemnts has been removed at the same time.

Fixes zephyrproject-rtos#78794

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2024-10-08 18:09:57 -04:00
Emil Gydesen
b2e61ef355 Bluetooth: BAP: Fix bad check in bt_audio_valid_qos_pref
The checks did not properly take into account
that the pref_pd_min and pref_pd_max could have valid
0 values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-08 16:58:09 +02:00
Aleksander Wasaznik
8cfad44852 Bluetooth: Deprecate adv auto-resume
The host-based adv auto-resume function has both a problematic
implementation and disagreement in the community around how it should
behave. See the issue linked resolved below for details.

This patch makes the deprecation visible to the user. The user will be
better served by a auto-resume tailored their applications use case,
based on more primitive host API like `conn_cb.recycled`, which has
obvious behavior that is unlikely to change.

Resolves: https://github.com/zephyrproject-rtos/zephyr/issues/72567

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-10-08 16:57:01 +02:00
Gerard Marull-Paretas
b2031aa20d bluetooth: controller: ll_sw: nordic: align to nrfx 3.7.0
Some enums have been renamed:

- NRF_CCM_EVENT_ENDCRYPT -> NRF_CCM_EVENT_END
- NRF_CCM_TASK_CRYPT -> NRF_CCM_TASK_START

Also adjust some TX power level settings (26/28dBm not always available
depending on the SoC revision).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-10-07 18:42:14 +02:00
Vinayak Kariappa Chettimada
c334ed515b Bluetooth: Controller: Fix multiple Extended Adv chain reception
Fix assertion when enabling simultaneous multiple Extended
Advertising chain reception that is enabled by increasing
supported auxiliary scan contexts.

ULL sets the association of aux context to scan and sync
context, and LLL resets the association; this is safer
compared to earlier implementation where ULL did both the
association and reset which caused aux context memory
leak.

Supported auxiliary scan contexts can be increased using
CONFIG_BT_CTLR_SCAN_AUX_SET value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-07 13:39:53 +02:00
Lyle Zhu
3756429b6c Bluetooth: BREDR: L2CAP: Recover ident when conn is pending
The `ident` of L2CAP BR connection req will be cleared if
function l2cap_br_conn_req_reply called to send L2CAP BR
connection rsp with result `BT_L2CAP_BR_PENDING`.

Then the invalid `ident` (it is zero) will be filled in
the L2CAP BR connection rsp after the ACL connection is
encrypted.

Recover `ident` if the result of the connection rsp is
`BT_L2CAP_BR_PENDING`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:24 -04:00
Lyle Zhu
c7c1f73045 Bluetooth: SSP: Support security level 4
Currently, error code `-ENOTSUP` will be
returned if start security with security
level 4.

For SC supported case, level 4 for ssp
should be supported.

Remove the code limitation to support
security level 4.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:15 -04:00
Lyle Zhu
7e54f13e7b Bluetooth: l2cap_br: Support Multi-Command Packet
Improve L2CAP BR to handle more than one
signaling command in one receiving L2CAP packet.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:09 -04:00
Lyle Zhu
3561540110 Bluetooth: L2CAP_BR: Set flags in CFG RSP
The flags of L2CAP_CONFIGURATION_REQ are set.
But in L2CAP_CONFIGURATION_RSP, all bits of
flags are cleared.

When used in the L2CAP_CONFIGURATION_RSP
packet, the continuation flag shall be set
to one if the flag is set to one in the
Request.

Copy flags from Request to Response if it
is a successful result.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:00 -04:00