Commit graph

9787 commits

Author SHA1 Message Date
Emil Gydesen
4b68043ebb Bluetooth: MPL: Replace busy bool with atomic
Replace the busy boolean flag with an atomic value.
This prevents any race conditions with the MPL implementation.
Modifies where the new atomic value is set and cleared
so that initialization gets to finish before allowing
any reads.

Due to how the MPL is structured, and how a select cannot
be rejected from OTS, this does not give a perfect solution.
Ideally we need a separate object per OTS object, rather than
a shared one, and/or the OTS implemenation would allow
us to reject a select if the object is not currently
available or ready.

This commit does not fix the above issues, as that is a
larger undertaking.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-16 20:18:39 +02:00
Olivier Lesage
788d1a908e bluetooth: host: improve log for unhandled vs events
Aligns the logging unhandled vs events with the regular ones.
Now it prints out the code and length.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2024-09-16 20:17:57 +02:00
Sean Madigan
aa67cb238a bluetooth: shell: Add CS to BT shell with set default settings command
Use a new file and command for this where all CS commands
can live.

Added support for bt_cs_set_default_settings command.

Added test case where shell is built with CS to ensure code
is built in CI.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2024-09-16 10:02:58 +02:00
Sean Madigan
aedb330c70 bluetooth: host: Add support for CS set default settings
Added support for a new API for setting default channel
sounding settings, this is mainly a wrapper around the HCI
command.

For this add a new module for channel sounding, where new
channel sounding APIs will go.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2024-09-16 10:02:58 +02:00
Sean Madigan
7dff1c1374 bluetooth: kconfig: Add channel sounding kconfigs
Add new controller and host kconfigs for Bluetooth 6.0
Channel Sounding.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2024-09-16 10:02:58 +02:00
Vinayak Kariappa Chettimada
50b07f9480 Bluetooth: Controller: Add missing branch prediction in lll_scan_aux
Add missing branch prediction likely/unlikely hint.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-13 17:29:53 -05:00
Vinayak Kariappa Chettimada
176d8ff760 Bluetooth: Controller: Define a macro to validate aux offset value
Define a macro to validate aux offset value as it is checked
both in LLL and ULL execution contexts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-13 17:29:53 -05:00
Vinayak Kariappa Chettimada
9fa18600ee Bluetooth: Controller: Fix hang due to loop in node_rx list
Fix Controller hang due to infinite looping caused by
duplicate node_rx enqueued in auxiliary context.

When LLL scheduling is not applied due to invalid aux offset
then ULL scheduling too would skip setting up the reception
after similarly checking the validity of aux offset required
to schedule the reception of auxiliary PDU. This check in
ULL was after the received node_rx being enqueued into the
auxiliary context causing a loop in the list of node_rx.

Dequeue of a list with a loop of node_rx caused an infinite
loop execution in the Controller.

Regression introduced in commit 3590bd648f ("Bluetooth:
Controller: Fix missing invalid aux offset check").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-13 17:29:53 -05:00
Vinayak Kariappa Chettimada
437bfa5b1a Bluetooth: Controller: Infinite loop assertion on node_rx release
Add assertion check to catch infinite loop due to incorrect
node_rx release.

If same node_rx is released twice then it can lead to
infinite looping when releaseing link or node_rx buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-13 17:29:53 -05:00
Emil Gydesen
49bd80828d Bluetooth: VOCS: Replace bools with atomic
Replace the booleans used by the VOCS client to use
an atomic value instead.

The flags are modified to be used in a way that prevents
race conditions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-13 11:38:27 -05:00
Emil Gydesen
ae6c20d324 Bluetooth: BAP: BA: Replace bools with atomic
Replace the boolean values for the BAP Broadcast Assistant
with an atomic value. This prevents a rare, but possible,
race condition.

The busy flag has been replaced with 3 atomic values which
provide better granularity in error handling, and allows for
some concurrent write and read requests.

To describe the new behavior, the return values in the documentation
has been updated, and the error handling in the API
functions has improved.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-12 13:01:48 -04:00
Jonathan Rico
02c8659748 Bluetooth: Host: run clang-format on auto-init-procedures fns
Does what it says on the tin.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-09-12 13:00:54 -04:00
Jonathan Rico
ac8889907a Bluetooth: Host: Remove an indentation level in auto procedures
The else branch was unused.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-09-12 13:00:54 -04:00
Jonathan Rico
585c1f951f Bluetooth: Host: Refactor auto feature exchange
Add a bool fn so there is some room for a comment explaining why this is
not guarded by an IS_ENABLED().

Also add an optimization when building with an onboard controller.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-09-12 13:00:54 -04:00
Jonathan Rico
3f17bdfaf6 Bluetooth: Host: refactor 2M PHY auto-update
The code was a bit hard to read. From what I understood, the intent is
to not send the PHY update if we are already on 2M symmetric.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-09-12 13:00:54 -04:00
Kyra Lengfeld
0f4fde3769 Bluetooth: Mesh: add API to set chunk send interval
This commit adds a KConfig option and an API to set the interval in
which chunks get send, in milliseconds.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2024-09-12 14:50:25 +02:00
Emil Gydesen
771a3d7509 Bluetooth: CSIP: Set Coordinator: Replace bools with atomic
Replace boolean flags with atomic.
This also properly add guards for the multi-device procedures
and reduce the number of places where the busy flag is set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-12 14:48:47 +02:00
Emil Gydesen
3029916786 Bluetooth: MICP: Replace busy bool with atomic
Replace the busy boolean flag with an atomic value.
This prevents any race conditions with the MICP client implementation.

This also adds a missing check for the discovery procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-12 14:48:40 +02:00
Emil Gydesen
42602e6465 Bluetooth: TBS: Replace busy bool with atomic
Replace the busy boolean flag with an atomic value.
This prevents any race conditions with the implementation.

The discovery procedure is also now properly guarded with it
so that in case that any procedure is currently in progress
for the specific connection, then a new discovery procedure
cannot happen until all other procedures are finished.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-12 14:48:23 +02:00
Vinayak Kariappa Chettimada
9eb35c4e24 Bluetooth: Controller: Rework FAKE_ENTROPY_NATIVE_POSIX text
Rework comment text for FAKE_ENTROPY_NATIVE_POSIX used as
entropy driver for the Controller on BOARD_NRF54L15BSIM.

Relates to commit 34b6b3d9eb ("Bluetooth: Controller:
Support FAKE_ENTROPY_NATIVE_POSIX").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-12 10:02:48 +02:00
Valerio Setti
7fadfeec7c mbedtls: do not set PSA_WANT_KEY_TYPE_[RSA/ECC]_KEY_PAIR_BASIC
Mbed TLS automatically sets PSA_WANT_KEY_TYPE_[RSA/ECC]_KEY_PAIR_BASIC
whenever "_IMPORT || _EXPORT || _GENERATE || _DERIVE" operations
are set. Therefore we just set the proper actions where required.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-09-12 10:02:40 +02:00
Emil Gydesen
5e34127e4b Bluetooth: MCC: Replace busy bool with atomic
Replace the busy boolean flag with an atomic value.
This prevents any race conditions with the MCC implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-11 14:00:16 -04:00
Emil Gydesen
c012ece33e Bluetooth: GMAP: Replace busy bool with atomic
Replace the busy boolean flag with an atomic value.
This prevents any race conditions with the GMAP client implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-11 14:00:09 -04:00
Fredrik Danebjer
c9da274eb2 Bluetooth: ascs: Add dynamic ASE registration
Added option to set the ASE count through the bap API, making ASE
configuration runtime available. The upper limit of ASEs are still
bound by the Kconfig options set for ASEs.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2024-09-11 07:41:12 -04:00
Pisit Sawangvonganan
ead0dfc889 style: subsys: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-09-11 07:40:35 -04:00
Jonathan Rico
01354c0045 Bluetooth: conn: move auto-init procedures to system workqueue
`conn_auto_initiate()` starts a bunch of controller procedures (read: HCI
commands) that are fired off right after connection establishment.

Right now, it's called from the RX context, which is the same context where
resources (cmd & acl buffers) are freed. This not ideal.

But the procedures are all async, so it should be fine to schedule this
function on the system workqueue, where we have less risk of deadlocks.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-09-09 18:41:45 -04:00
Emil Gydesen
79fa6b3f54 Bluetooth: ISO: Update includes for ISO files
Updates the includes for ISO file so that it conforms to
IWYU (include what you use).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-09 13:55:20 -04:00
Lyle Zhu
8113ff7e9c bluetooth: AVDTP: Check buffer len before pulling data
Check the remaining buffer length is not less than
required data length before pulling data from the
buffer.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-09-09 13:54:56 -04:00
Johan Hedberg
131a11e61e Bluetooth: Host: Add decoding for Bluetooth HCI version 6.0
Add decoding for version 6.0, now that the new core specification has been
released.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-09-09 15:23:25 +03:00
Johan Hedberg
ceedf72c51 Bluetooth: shell: Use common HCI version decode function
There's a generally available bt_hci_get_ver_str() function, so use that
instead of defining our own.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-09-09 15:23:25 +03:00
Henrik Brix Andersen
159f7dbbb1 lib: net_buf: rename header file from zephyr/net/buf.h to zephyr/net_buf.h
Move the network buffer header file from zephyr/net/buf.h to
zephyr/net_buf.h as the implementation now lives outside of the networking
subsystem.

Add (deprecated) zephyr/net/buf.h header to maintain compatibility with old
file path.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-09-07 11:19:05 -05:00
Vinayak Kariappa Chettimada
34b6b3d9eb Bluetooth: Controller: Support FAKE_ENTROPY_NATIVE_POSIX
Add support for use of FAKE_ENTROPY_NATIVE_POSIX as entropy
driver for the Controller on BOARD_NRF54L15BSIM.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-06 11:26:19 -04:00
Emil Gydesen
fcdfdae95b Bluetooth: Audio: Add to_str functions for some assigned numbers
Add to_str functions for context, parental rating, active state,
codec cap freq, codec cap frame duration,
codec cap channel count and location.

The remaining values are just numeric values and does not
need a to_str function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 17:02:41 -04:00
Emil Gydesen
8f76cdd891 Bluetooth: TBS: Fix issues with lookup_inst_by_uri_scheme
The function took the uri as a `char *` but is in fact
not a null terminated string so change the type to uint8_t *.

Add a check fro uri_len == 0 before doing uri_len - 1

Changed the found check to just check the first octet rather
than the more costly strlen.

Fixed the type of the iterator

Add a break in the loop as we only need to find one ":"

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:51:44 -05:00
Vinayak Kariappa Chettimada
2eafc826e3 Bluetooth: Host: Fix unable to start scanning after scan param failure
Fix scan_update() implementation for missing flags clear
that prevented starting scanning after previous attempt to
start failed due to parameters being rejected by the
Controller.

Example, attempting to start coded PHY scanning with a
Controller implementation that does not support it can fail,
but attempting again without coded PHY scanning should
succeed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-05 12:25:17 +01:00
Emil Gydesen
57b35e1047 Bluetooth: TBS: Allow multiple callbacks for client
The TBS client callbacks are just informative so we
provide the information to multiple listeners.

To support this for the long strings, the function
handle_string_long_read was refactored.

This also allows for multiple users of the TBS client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:47 +01:00
Emil Gydesen
94e548120b Bluetooth: BAP: SD: Added missing bad code when using mod_src
When the encrypt state was changed via
bt_bap_scan_delegator_mod_src then we didn't set the bad
broadcast code correctly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:34 +01:00
Emil Gydesen
c49a058b9b Bluetooth: TBS: Fix type of uri in call_alloc
The function had marked the type as char *, but it was in fact
not a string but rather a uint8_t array.

Marked the type properly and added a cast when using it with
bt_tbs_remote_incoming.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:25 +01:00
Emil Gydesen
f500f7c22f Bluetooth: CAP: Fix dependency on BT_BAP_STREAM
The CAP commander used bt_audio_valid_ltv which required
BT_BAP_STREAM to be enabled, but the CAP Commander does not
need BT_BAP_STREAM to be enabled.

Moved the function to audio.c which is always compiled for
the CAP Commander, thus removing the requirement for
BT_BAP_STREAM and the accompanying bt_bap_stream.c file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:16 +01:00
Emil Gydesen
fff9c326c6 Bluetooth: TBS: Add UTF8 requirement to Kconfigs
The UTF8 implementions for both client and server
both use the utf8 API which require CONFIG_UTF8.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:24:07 +01:00
Emil Gydesen
b250754f5b Bluetooth: TBS: Fix type of uri in bt_tbs_valid_uri
The function had marked the type as char *, but it was in fact
not a string but rather a uint8_t array.

Marked the type properly and added a cast when using it with
strings.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 12:23:24 +01:00
Emil Gydesen
c37a48acbc Bluetooth: CAP: Revert order of CAP stream callbacks
Modify the CAP stream callbacks so that the application
callbacks are called before the CAP initiator.

This allows the application to abort/cancel a procedure
before we send out any future request.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-05 09:50:01 +02:00
Stine Åkredalen
c89bca6f3f Bluetooth: Mesh: Logic fix for recvd unseg msgs
Fixed transport layer logic causing excessive processing of
some unsegmented messages

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2024-09-04 06:54:10 -04:00
Emil Gydesen
b5ff2cc667 Bluetooth: AICS: Replace bools with atomic
Replace several bools in bt_aics_client with an atomic value.
Update how these values are modified so that we can better
prevent race conditions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-04 09:54:05 +02:00
Emil Gydesen
0e4e7628fd Bluetooth: CAP: Add check for streaming state when starting unicast
When calling bt_cap_initiator_unicast_audio_start on a set of streams
that are all in the streaming state we return early with -EALREADY.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-03 10:43:59 +02:00
Emil Gydesen
316a551ff1 Bluetooth: CAP: Remove check for ep in valid_unicast_audio_start_param
This allows the procedure to work for streams in the non-idle state,
e.g. we can start one of more streams in the codec configured
or even enabling state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-03 10:43:59 +02:00
Emil Gydesen
8b8f727761 Bluetooth: BAP: Add support for reconfiguring unicast group
This allows applications to modify the values set by an
existing unicast group, assuming that none of the streams in
the CIG has been connected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-03 10:43:53 +02:00
Troels Nilsson
63da4963a0 Bluetooth: Controller: Implement Secondary_Advertising_Max_Skip
Behaviour is unchanged for max_skip == 0

For max_skip > 0, use a slightly different calculation to ensure
we can pass LL/DDI/ADV/BV-28-C

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-09-03 10:43:20 +02:00
Troels Nilsson
e816a13b24 Bluetooth: Fix the host side not setting sec_adv_max_skip
Set sec_adv_max_skip

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-09-03 10:43:20 +02:00
Olivier Lesage
063991424c bluetooth: host: Ignore HCI err 0xC when setting own addr when initiating
Ignores "command disallowed" if the host privacy implementation tries
to change the device's random address while scanning or initiating.
This is not allowed by spec. It's caused by scan_update() in scan.c.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2024-09-03 10:42:56 +02:00