Commit graph

9523 commits

Author SHA1 Message Date
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
Félix Piédallu
d9d5043667 Bluetooth: Controller: Use BT_LLL_VENDOR_* to selectively build LLL
CONFIG_SOC_COMPATIBLE_* is not configurable but CONFIG_BT_LLL_VENDOR_* is.

This allows an alternate LLL to be built on nordic and OpenISA chips.

Signed-off-by: Félix Piédallu <felix@piedallu.me>
2024-09-03 10:42:48 +02:00
Junho Lee
fe24cac70b Bluetooth: Mesh: Clarify log to run out of retransmission attempt
The logs for retransmission attempts for sending segments and ack
retransmission attempts for receiving segments were the same, making it
difficult to distinguish between them. This can be solved by adding
information to the log of ack retransmission.

Signed-off-by: Junho Lee <tot0roprog@gmail.com>
2024-09-03 10:41:52 +02:00
Pavel Vasilyev
2f02474448 bluetooth: host: adv: Release buf if failed to set addr
The `bt_id_set_adv_own_addr` function itself tries to allocate a buffer
for the command and it failes due to lack of buffers, it returns error.
However, the `le_ext_adv_param_set` function doesn't handle the error
properly and keeps its own allocated buffer.

This commit releases the allocated buffer.
Partially fixes mesh in #77241.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-09-02 12:30:18 -04:00
Simen Eilevstjønn
2c64fe7f37 Bluetooth: Implemented new DIS characteristics
Implemented new DIS characteristics:
    - UDI for medical devices
    - IEEE 11073-20601 Regulatory Certification Data List
    - System ID

Also fixed buffer overflow bug when assigning too long DIS string literals

Signed-off-by: Simen Eilevstjønn <simen.eilevstjonn@laerdal.com>
2024-09-02 12:00:52 +02:00
Aleksander Wasaznik
2f86faffba Bluetooth: Host: Minor doc and rename for LE remote feature exchange
Rename `BT_CONN_AUTO_FEATURE_EXCH` to `BT_CONN_LE_FEATURES_EXCHANGED`,
and add some comments for readability.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-09-02 11:50:25 +02:00
Vinayak Kariappa Chettimada
b505942897 Bluetooth: Controller: nrf54L15bsim: Use NRF_GRTC
Use NRF_GRTC in nrf54l15bsim board builds.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
125f39758d Bluetooth: Controller: nRF54Lx: Use SW_SWITCH_SINGLE_TIMER
Use SW_SWITCH_SINGLE_TIMER for nRF54Lx so that fast ramp
can be used, and hence support assymmetric PHYs in ACL
connections.

nRF54Lx radio domain does not have second timer instance
to efficiently implement software switch unless a second
time is used from a different power domain needed use of
PPIB for the double buffered switch timer compares.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
e642aa3513 Bluetooth: Controller: nRF54Lx: Use nrfx interface for bsim use (4/4)
Use nrfx interface for register access with sideeffects to
facilitate bsim use.

Remove CMSIS interface use, was replaced with nrf_grtc,
nrf_dppic and nrf_ppib interface in previous commit.

4 part commits:
1. Add nrf_grtc interface.
2. Remove CMSIS interface use.
3. Add nrf_grtc interface, once missing bsim port available.
4. Remove CMSIS interface use, replaced by bsim port.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
da6bd08df0 Bluetooth: Controller: nRF54Lx: Use nrfx interface for bsim use (3/4)
Use nrfx interface for register access with sideeffects to
facilitate bsim use.

4 part commits:
1. Add nrf_grtc interface.
2. Remove CMSIS interface use.
3. Add nrf_grtc interface, once missing bsim port available.
4. Remove CMSIS interface use, replaced by bsim port.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
d5e75ce755 Bluetooth: Controller: nRF54Lx: Use nrfx interface for bsim use (2/4)
Use nrfx interface for register access with sideeffects to
facilitate bsim use.

Remove CMSIS interface use, was replaced with nrf_grtc
interface in previous commit.

4 part commits:
1. Add nrf_grtc interface.
2. Remove CMSIS interface use.
3. Add nrf_grtc interface, once missing bsim port available.
4. Remove CMSIS interface use, replaced by bsim port.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
24465ec160 Bluetooth: Controller: nRF54Lx: Use nrfx interface for bsim use (1/4)
Use nrfx interface for register access with sideeffects to
facilitate bsim use.

4 part commits:
1. Add nrf_grtc interface.
2. Remove CMSIS interface use.
3. Add nrf_grtc interface, once missing bsim port available.
4. Remove CMSIS interface use, replaced by bsim port.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
f39c27bc95 Bluetooth: Controller: nRF54Lx: Review rework GRTC support
Review rework GRTC support for nRF54Lx SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
10a466f31f Bluetooth: Controller: nRF54Lx: Support Radio fast ramp up
Add support for Radio fast ramp up for nRF54Lx SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00
Vinayak Kariappa Chettimada
55813ad95b Bluetooth: Controller: nRF54Lx: Use NRF_GRTC for radio scheduling
Use NRF_GRTC, Global real-time counter, instead of NRF_RTC.

NRF_GRTC is present in a different power domain in the SoC.
Also, NRF_GRTC provide microsecond resolution timing units,
in the future use of NRF_TIMER for packet timer can also be
replaced.

Use of NRF_RTC would keep Radio power domain ON in addition
to already ON NRF_GRTC's power domain, hence switch to using
NRF_GRTC on nRF54Lx SoC to have lower power consumptions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-30 11:47:15 -04:00