Commit graph

9523 commits

Author SHA1 Message Date
Andries Kruithof
bb3bab7a34 Bluetooth: Audio: implement the distribute broadcast code procedure
Implemenation of the distribute broadcast code CAP procedure, as well
as unittesting

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-11-25 21:52:53 +01:00
Emil Gydesen
96b487186f Bluetooth: ISO: Removed unused pool and funcs/macros
The iso_tx_pool was unused because all the functions
and macros that used it were unused.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-25 17:42:59 +01:00
Emil Gydesen
83677f551f Bluetooth: Shell: Set conn to NULL before bt_conn_le_create
bt_conn_le_create logs a warning if the provided conn is
non-NULL which was the case here. Simply set it to
NULL as it is a local variable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-25 14:41:14 +01:00
James Roy
72d34496dc subsystem: bluetooth: Fix uninitialized variable
Fix uninitialized sec_idx variables scanned by Coverity.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2024-11-23 15:29:03 +01:00
Vinayak Kariappa Chettimada
9df4b548ba Bluetooth: Controller: Ext Adv Auxiliary PDUs with ticks_slot_window
Add implementation for Extended Advertising Auxiliary PDUs
to use ticks slot window feature.

This will allow the periodic scheduling of AUX_ADV_IND PDUs
to drift upto 10 ms advertising delay minus the ticks_slot
time reservation of the AUX_ADV_IND PDU when overlapping
with other states/roles that cannot be moved around, to
avoid skipping them.

Having an active Extended Advertising simultaneously with
an ISO Synchronized Receiver or Connected ISO connection
will now have less ISO SDU loss when using 10 ms ISO
intervals.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-11-22 17:43:04 +01:00
Vinayak Kariappa Chettimada
b838b17755 Bluetooth: Controller: Introduce ticker reschedule with drift
Introduce ticker reschedule with drift so that role like
AUX_ADV_IND can start after overlapping states and roles
using time reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-11-22 17:43:04 +01:00
Vinayak Kariappa Chettimada
ec39d6257e Bluetooth: Controller: Fix to reschedule before overlap when yielding
Fix to reschedule before overlap and be collision resolved
in the next periodic interval for tickers using slot window
yield.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-11-22 17:43:04 +01:00
Johan Hedberg
30d1d0e526 Bluetooth: Host: Remove deprecated HCI driver API
Remove the deprecated HCI driver API which was provided by the hci_driver.h
header file. The deprecation happened in Zephyr 3.7, so the API can now be
removed for Zephyr 4.1.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-11-22 11:37:12 +01:00
Johan Hedberg
3063f18942 Bluetooth: Host: Remove unnecessary hci_driver.h includes
None of these files actually use anything from the hci_driver.h header
file.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-11-22 11:37:12 +01:00
Emil Gydesen
b4f3763c31 tests: Bluetooth: Audio: Use same recv_cb for all tests
This commit changes the BSIM tests to use the same recv callback
for all tests. The purpose of this is to reduce code duplication
and make it easier to maintain the tests.

This also changes the recv_cb so that in case of any error we log
the most recently received SDU, which should provide more
information about why a test failed in case of RX error.

PBP had to be updated a bit to support the audio_stream
struct.

Also modifies a check and log in bap_stream that was less than
helpful to determine if it was the stream or the endpoint that
was NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 14:47:49 +01:00
Omkar Kulkarni
95fff388ba Bluetooth: Mesh: Shell: Align commands
Aligns subnet bridge related commands according to conventions used for
rest of the shell commands. Also updates documentations to reflect the
change.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2024-11-21 14:46:31 +01:00
Alberto Escolar Piedras
4294814a23 Bluetooth: Controller: nRF: Support MDK 8.68
TASK_SHUTDOWN was deprecated in newer SOCs and now removed
in MDK 8.68 (nrfx 3.9.0)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-11-21 09:26:38 +01:00
Emil Gydesen
7a72280d01 Bluetooth: HAS: Change select UTF8 to depends on
Change the select to a depends on for the Kconfig options
for HAS and HAS_CLIENT.

This is an effort to reduce the number of selects used by
LE Audio.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
c4fbe38219 Bluetooth: BAP: Depend on BT_PER_ADV_SYNC instead of select
Change the select of BT_PER_ADV_SYNC and BT_EXT_ADV to
depends on. This is an effort to reduce the use of
select for Kconfig options.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
4c86a5cc8d Bluetooth: BAP: Depend on BT_PAC_{SNK,SRC} instead of select
Modify ASCS and BAP Broadcast sink to depend on the PAC options
instead of selecting them.

Since Kconfig does not support "depends on X if Y",
a select for PAC_{SRC,SNK} is used depending on
ASCS_ASE_{SRC,SNK}.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
c0f86011cb Bluetooth: BAP: Depend on BT_ISO_SYNC_RECEIVER instead of select
The BAP Kconfigs option now depends on
BT_ISO_BROADCASTER instead of selecting it.

This is an effort to reduce the use of select in LE Audio.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
d22c7b0cf2 Bluetooth: BAP: Depend on BT_ISO_BROADCASTER instead of select
The BAP_BROADCAST_SOURCE Kconfig option now depends on
BT_ISO_BROADCASTER instead of selecting it.

This is an effort to reduce the use of select in LE Audio.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
9b653540b8 Bluetooth: BAP: Use def_bool instead of select for BT_AUDIO_RX/TX
Remove the selects and use  def_bool for BT_AUDIO_RX and
BT_AUDIO_TX.

This is part of an effort to reduce select in Kconfig.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
df6b5981bf Bluetooth: Audio: depends on GATT instead of select
Modify the Kconfig options to depend on the GATT
features rather than selecting them.

This is part of an effort to reduce the amount of
selects we use in LE Audio.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Emil Gydesen
6f86adbc0d Bluetooth: BAP: Use def_bool instead of select for BT_BAP_UNICAST
Remove the selects from BT_BAP_UNICAST_SERVER and BT_BAP_UNICAST_CLIENT
and use a def_bool for BT_BAP_UNICAST.

This is part of an effort to reduce select in Kconfig.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-21 09:19:47 +01:00
Valerio Setti
516886be1b mbedtls: MBEDTLS_ENTROPY_POLL_ZEPHYR default on if MBEDTLS_ENTROPY_C
As long as MBEDTLS_ENTROPY_C is enabled, Mbed TLS needs to
poll some entropy source to gather data that will then be
processed by CTR/HMAC-DRBG modules. This means that in most
of the cases, once MBEDTLS_ENTROPY_C is enabled then also
MBEDTLS_ENTROPY_POLL_ZEPHYR needs to be enabled. This was
done manually until now, as the long list of samples/tests
demonstrate.

This commit solves this dependency by defaulting
MBEDTLS_ENTROPY_POLL_ZEPHYR to on as soon as
MBEDTLS_ENTROPY_C is set. As a consequence, all manual
enablement of MBEDTLS_ENTROPY_POLL_ZEPHYR in samples/tests
are removed.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-11-20 15:59:40 -05:00
Håvard Reierstad
b38773f14b Bluetooth: Mesh: Use net xmit params for bridge
Makes sure that the Network Transmit state is used when using a Subnet
Bridge.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-11-19 10:12:19 -05:00
Håvard Reierstad
665a555e75 Bluetooth: Mesh: Use relay bufs/pool for brg_cfg
Adds support for using relay buffers and advertising set for the subnet
bridge feature, even if the relay feature is disabled.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-11-19 10:12:19 -05:00
Lingao Meng
b54f49cb8c Bluetooth: Mesh: Fix proxy advertising set sending Mesh messages
When start to sending proxy advertising, will also process in
send_pending_adv, but the bt_mesh_adv_get_by_tag will directly return
buffer from bt_mesh_adv_queue or bt_mesh_relay_queue, which case
mesh messages sent on different sets, can cause peer replay attack.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-11-19 09:51:51 -05:00
Jens Rehhoff Thomsen
b478ffe2ef Bluetooth: host: Fix bug in disconnected handling
When disconnected only the first empty slot in the disconnected_handles
array should be updated.

Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
2024-11-19 09:50:41 -05:00
Alberto Escolar Piedras
a785548df6 bluetooth: CTS: Fix includes to avoid build error with some libCs
Remove unnecessary include in header and source file.

gmtime_r() is an extension to the C library, and therefore one
needs to explicitly ask for its prototype to have it exposed.
This is done by defining _POSIX_C_SOURCE so let's do so.

These two changes fix build errors with some libCs.
Tested with pico, newlib, minimal and the host glibc.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-11-18 19:29:32 -05:00
Zihao Gao
1b8ad2cf40 Bluetooth: AVRCP: allow to parse unit info resposne.
Add AVRCP handler for UNIT INFO responses.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
498f81e45f Bluetooth: AVCTP: add error handling for fragmented message.
Fragmented AVCTP message is not supported now. Therefore
A error message is printed.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
5d322350b4 Bluetooth: AVCTP: check buffer length before use.
The buffer length shall be validated before extracting
Transaction ID and C/R field.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
3e2244d634 Bluetooth: AVRCP: fix bitfield issue.
The bit order can be incorrect when use bit field definition.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
9af026dcbf Bluetooth : AVRCP: allow to receive an AVRCP message.
This patch received an AVRCP message and remove timeout timers.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
4c932b4b80 Bluetooth: AVCTP: allow to receive an AVCTP message.
This patch received an AVCTP message and forward to the
upper layer, e.g., AVRCP.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
e0f1fb0bb6 Bluetooth: Shell: add command to obtain unit info
This patch allow to acquire the unit info of the remote device.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
3d9cf59fdd Bluetooth: AVRCP: allow to create and send AVRCP unit message
This patch defines the message format for AVCTP unit message.
This is the first out of the four types of commands and can be
used by the CT to obtain the unit info from the TG device.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
3a045fbeea Bluetooth: AVCTP: allow to create and send AVCTP message
This patch defines the message format for general AVCTP.
They would be further called by AVRCP layer.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
36acb89803 Bluetooth: AVRCP: add shell tools for AVRCP functions.
Only the basic functions for establishing an AVCTP connection
are provided at this stage.
An BR/EDR ACL connection is necessary before AVRCP function.
Register callbacks before utilizing AVRCP.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
4e0dc39e71 Bluetooth: AVRCP: Add SDP attributes.
This patch add SDP records for both CT and TG role.

The SDP attribute would be registered according to the configuration.

OBEX and Browsing commands are optional and yet not supported.

SDP registration is implemented at AVRCP level to simplify the
workload of the upper layer. We assume the App can have limited
knowledge on SDP structures.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
70b415dab6 Bluetooth: AVRCP: Implemation of AVRCP.
This patch implementing avrcp.c
New Kconfig BT_AVRCP is provided to enable this layer.
BT_AVRCP_TARGET and BT_AVRCP_CONTROLLER are then
provided to enable one of the two roles independently.
avrcp.h shows the APIs for the upper layer.

Only connection and disconnection interfaces are provided in this patch.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Zihao Gao
27f71b044a Bluetooth: AVCTP: Implementation of AVCTP.
This patch implementing avctp.c
New Kconfig BT_AVCTP is provided to enable this layer.
avctp_internal.h shows the APIs for the upper layer, i.e., AVRCP.

Only connection and disconnection interfaces are provided in this patch.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-11-18 13:19:07 -05:00
Ludvig Jordet
1f9baa3ac3 Bluetooth: Host: Refactor legacy adv creation
This fixes #78721 which was introduced in PR #44686, which changed (and
renamed) `adv_new_legacy`/`adv_get_legacy` to return an existing
`bt_dev.adv` if it existed. This caused a problem, where the existing
adv then would be used to start advertising, and if this fails (because
the adv is already advertising, for instance), `bt_le_adv_start` would
erroneously delete the adv, making the host lose the context for the adv
which still is advertising.

Before PR #44686, this would not happen, because `bt_le_adv_start` would
return early when `adv_new_legacy` returned `NULL` and never reach the
delete call.

I have refactored this to make responsibilities a bit more clear:
`adv_create_legacy` now does 1 thing: create an ext adv and assign as
the legacy advertiser. This mirrors `bt_le_adv_delete_legacy` which does
the opposite. I have implemented error codes to match the behavior that
PR #44686 was made to implement.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2024-11-18 13:16:27 -05:00
Håvard Reierstad
68361eacfa Bluetooth: Host: Fix unsafe ccc cast
Changes the implementation of `bt_gatt_is_subscribed` to use the
attribute read method instead of casting the user data pointer when
extracting the CCC Attribute Value.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-11-16 15:56:57 -05:00
Håvard Reierstad
43149c1056 Bluetooth: host: refactor bt_gatt_is_subscribed
Refactors `bt_gatt_is_subscribed` by changing a CHECKIF to an if
statement to avoid undefined behavior if CHECKIFs are "disabled".
Uses sizeof(a uint8_t) instead of 1 to avoid magic numbers.
Initializes `properties` to 0 to avoid undefined behavior.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-11-16 15:56:57 -05:00
Andries Kruithof
f1f78682d9 Bluetooth: Audio: API for the distribute broadcast code procedure
Define the API for the distribute broadcast code CAP procedure

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-11-16 15:27:10 -05:00
Adam Cavender
a68a0a4a5b bluetooth: host: Update FAE table type for HCI commands
Update FAE table type from array of uint8_t to int8_t. From Vol 6.0,
Part B, section 2.4.2.52: "The ChFAE field contains the per-channel
mode-0 FAE table of the local Controller. Every per-channel mode-0
FAE value is represented by an 8-bit signed integer"

Signed-off-by: Adam Cavender <adam.cavender@nordicsemi.no>
2024-11-16 15:27:04 -05:00
Chris Friedt
9504034733 sys: util: use BITS_PER_BYTE macro instead of the magic number 8
Obviously, everyone knows that there are 8 bits per byte, so
there isn't a lot of magic happening, per se, but it's also
helpful to clearly denote where the magic number 8 is referring
to the number of bits in a byte.

Occasionally, 8 will refer to a field size or offset in a
structure, MMR, or word. Occasionally, the number 8 will refer
to the number of bytes in a 64-bit value (which should probably
be replaced with `sizeof(uint64_t)`).

For converting bits to bytes, or vice-versa, let's use
`BITS_PER_BYTE` for clarity (or other appropriate `BITS_PER_*`
macros).

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-11-16 15:22:35 -05:00
Troels Nilsson
fa3bfa5453 Bluetooth: Controller: Add margin to ISOALs time offset
To ensure payloads are delivered in time for the first subevent
in framed BIS, ISOAL now enforces a (configurable) margin of
the calculated time offset

Without this margin, it has been observed that a broadcaster
can end up consistently missing the first subevent in every third
event in a 7.5 ms ISO with a 10 ms SDU interval

The margin is a conservative 2 ms by default, but can likely be
set a lot lower for most implementations and HWs

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-11-16 15:08:59 -05:00
Emil Gydesen
8703381764 Bluetooth: Host: Add conversion macros from ms to various units
Add conversion macros from milliseconds to various units.
The purpose of these macros is to make it more clear/easier
for users to set and read values using milliseconds rather
than the various BT units which may be in 0.625, 1.25 or 10ms
units.

This is especially useful when comparing related values using
different units, such as advertising interval (0.625ms units)
and periodic advertising interval units (1.25ms units).

Users will have to be aware that these macros can provide slightly
different values than what is provided, if the provided values
do not match the units.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-16 14:06:03 -05:00
Pisit Sawangvonganan
c120ffb31d bluetooth: shell: avoid multiple strlen calls
Add `len` to store the result of `strlen(addr_arg)` to avoid
multiple calls to `strlen` within the `for-loop` in
`cmd_scan_filter_set_addr`.
While the performance impact may be minimal in a shell context,
storing `strlen(addr_arg)` in `len` ensures a single call,
making the code more predictable and consistent.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-11-16 13:50:58 -05:00
Emil Gydesen
c32210b003 Bluetooth: Host: ID: Log resolve list conflicts
In case of conflicts when calling bt_id_find_conflict
there was no way to easily determine what conflicted.

This is a rare occurance, but has happened when testing
against PTS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-11-16 13:43:59 -05:00
Mahesh Mahadevan
d9bfdaf996 bluetooth: kconfig: Remove deprecated config
Remove deprecated Kconfig BT_MESH_PROV_DEVICE

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-11-13 19:08:29 -08:00