Fix missing sync_delay and transport_latency information in HCI
LE BIG Complete event.
Relates to commit 1a640e4711 ("Bluetooth: controller:
Included transport latency in LE_Big_Established").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect device address reported in the LE Periodic
Advertising Sync Established event when using Periodic
Advertiser List.
During Extended Scanning there can be an ADV_EXT_IND PDU
received between currently being received ADV_EXT_IND PDU
and AUX_ADV_IND PDU; if the one received between has an
address match then incorrectly the Periodic Synchronization
was established to the device whos AUX_ADV_IND PDU is being
received. Fix by storing the auxiliary context that has the
address match and compare with it when matching the SID in
SyncInfo of AUX_ADV_IND PDU being received prior to creating
the synchronization.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_LOW_LAT_ULL conditional compilation code by
decoupling it from BT_CTLR_LOW_LAT code.
BT_CTLR_LOW_LAT_ULL makes ULL execution context to tailchain
in comparison to continuously process in a while loop.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Since the PACS service is not part of the bt_bap API it should
not use the bt_bap prefix, and instead just be bt_pacs like the
rest of the PACS API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The code for checking for allocated BR/EDR PSMs was potentially resulting
in an integer overflow, due to doing a <= UINT16_MAX (0xffff) comparison
on a uint16_t variable. To avoid this, use a uint32_t variable internally.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Added a new function, bt_conn_is_type, that returns whether
the provided conn object is of the provided type.
This check is then used to ensure that the conn objects
supplied to other bt_conn function are of the right type.
The right type has also been documented for these functions.
This is an initial commit for a larger change in the BT Host,
as similar checks should be added to the L2CAP, GATT, ISO,
Audio and possibly Mesh APIs.
The type check could have been implemented by using the
bt_conn_get_info function, but that requires additional
function calls as well as memory allocation and copy.
Since bt_conn_is_type is designed to be widely used, it
was suited for its own function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Commit removes the double cdb node entry storing
into the settings if device was reprovisioned over
nppi interface.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
If BT_ISO_BROADCAST is enabled, then we shall support
at least 1 BIG and at most BT_EXT_ADV_MAX_ADV_SET since
each BIG requires its own advertising set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove START_PENDING flag, and replace with
bt_mesh_adv_is_empty_by_tag
not only make adv_ext.c more readable, but also enhancement
In previous implementation, after proxy started, will check
this flag, and when the flag is true, will direct stop proxy
and re-enter schedule, but has one problem, this flag set true,
but buf will be empty, such as when sending mesh relay messages
will for-each every sets, until find not-active, but also set
previous set START_PENDING flags, so will cause proxy advertising
started->stop->started.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The first why introduce ADV_FLAG_PROXY_START
see here(https://github.com/zephyrproject-rtos/zephyr/pull/58826)
The main core change is to mark ADV_FLAG_PROXY as moving to the last
enabled proxy instead of before.
But introducing the ADV_FLAG_PROXY_START flag seems meaningless.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Building bluetooth.shell.audio.only_gtbs with clang warns:
subsys/bluetooth/audio/tbs.c:1646:6: error: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (param->gtbs) {
^~~~~~~~~~~
subsys/bluetooth/audio/tbs.c:1667:9: note: uninitialized use occurs here
return ret;
^~~
subsys/bluetooth/audio/tbs.c:1646:2: note: remove the 'if' if its
condition is always true
if (param->gtbs) {
^~~~~~~~~~~~~~~~~
subsys/bluetooth/audio/tbs.c:1626:9: note: initialize the variable 'ret'
to silence this warning
int ret;
^
= 0
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
We have previously fixed an issue with shifting and
assigning the value without a cast, but coverity
is still complaining about aa[1] and aa[0] with:
"Casting narrower unsigned aa[1] to wider signed type
int effectively tests its lower bound."
Using the common function, sys_get_le24, should fix this issue.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Explicitly cast Kconfig option value to avoid truncation issue reported
by Coverity.
Fixes#84697
Coverity-CID: 487737
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit checks that ATT MTU value returned by `bt_gatt_get_mtu` is
greater or equal to 3 to prevent integer overflow.
Fixes#84693
Coverity-CID: 487743
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Ensure that ~(link.rx.seg) & SEG_NVAL doesn't result in 0.
Fixes#84804
Coverity-CID: 393090
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fixed the following issues:
1) Missing guard before accessing parameters
2) Fixed bad sizeof when resetting
3) Fixed several bad offsets when removing attributes
Added tests to verify that it works now.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When we receive a response from a server we do not have an
outstanding request with, we disconnect the connection
rather than just ignoring it.
The reason for this is that the remote server is
not ensuring correct ATT flow control, which means
that we cannot trust future responses from the
server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
psa_crypto_init was bounded to CONFIG_BT_HOST_CRYPTO_PRNG and
used to be called under prng_init. Updating the ifdef condition
and appropriating the function name for crypto init.
Also it is better to make sure psa_crypto_init called by host.
Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
This fixes out of scope IRQ lock key by using SEGGER_RTT_Write
version that locks the IRQ by itself.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add check that the command buffer claimed in `bt_le_create_conn_cancel`
is not `NULL`. Fixes a fault caused by providing the `NULL` buffer to
`bt_hci_cmd_state_set_init`.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Adds API for Advertising Coding Selection.
Introduces two new advertising options to configure the advertiser's
requirement concerning coding scheme when LE Coded PHY is configured.
While the Bluetooth v6.0 specification makes a distinction betweeen
preferred and required advertising PHY options, a simplification is
made to only expose the required PHY options. Inline with how LE Coded
PHY is implemented; this API will set both the primary and secondary
advertising PHY's to the same coding scheme.
The support is enabled by CONFIG_BT_EXT_ADV_CODING_SELECTION, and requires
a controller that selects CONFIG_BT_CTLR_ADV_EXT_CODING_SELECTION_SUPPORT.
Signed-off-by: Thomas Deppe <thomas.deppe@nordicsemi.no>
Building sample.bluetooth.tmap_central with clang warns:
subsys/bluetooth/host/iso.c:2194:6: error: variable 'rsp' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (!advanced) {
^~~~~~~~~
subsys/bluetooth/host/iso.c:2202:6: note: uninitialized use occurs here
if (rsp == NULL) {
^~~
subsys/bluetooth/host/iso.c:2194:2: note: remove the 'if' if its
condition is always true
if (!advanced) {
^~~~~~~~~~~~~~~
subsys/bluetooth/host/iso.c:2137:21: note: initialize the variable 'rsp'
to silence this warning
struct net_buf *rsp;
^
= NULL
subsys/bluetooth/host/iso.c:2295:6: error: variable 'rsp' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (!advanced) {
^~~~~~~~~
subsys/bluetooth/host/iso.c:2303:6: note: uninitialized use occurs here
if (rsp == NULL) {
^~~
subsys/bluetooth/host/iso.c:2295:2: note: remove the 'if' if its
condition is always true
if (!advanced) {
^~~~~~~~~~~~~~~
subsys/bluetooth/host/iso.c:2258:21: note: initialize the variable 'rsp'
to silence this warning
struct net_buf *rsp;
^
= NULL
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
The function may return a BT_GATT_ERR which is a negative
value that cannot be returned as uint8_t. Change the function
to use int instead and document the return values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The encryption functions should document the expect byte order of
inputs and the byte order of the outputs.
The sef and sdf functions were also using an older, and incorrect,
description of the input, as it only takes the LTK as per CSIP 1.0.0
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added warning to the BT_RECV_WORKQ_SYS description
to explain the dangers by using this option.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
There was a bug in pa_decode_base that would would spent time
parsing incoming BASEs and also update the receive
states, which caused some tests to fail.
This commit adds a simply check to verify that the BASE is
different before spending parsing the content and updating
the receive states.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Coverity was unhappy that
`struct ll_conn_iso_stream *cis = NULL;` was never assigned to
a non-NULL value, which is due to the assignment being
guarded by `#if defined(CONFIG_BT_CTLR_CONN_ISO)`.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Several advertising data function could return -1 in case of
errors, which could mess up the advertising data since they are
intended to increment a counter.
Instead of returning an error we use bt_shell_error to inform
the user and then just return with no data changes, so that if
any of them fails, the failing data is just omitted rather
than causing major issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix incorrect event_count use in CIG events when the next
CIG interval's prepare overlaps with the current CIG event.
Use separate event_count_prepare variable in ULL and copy
the value in LLL event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect elapsed events value when event prepare are
aborted in the pipeline. This can caused premature
supervision timeouts.
Relates to commit 247037bd3e ("Bluetooth: Controller: Fix
incorrect elapsed events value").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add verification of the parameter struct, so that it returns
-EINVAL if the values are invalid.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of using the bt_conn struct directly, only
access the field via the public API. This ensures that
changes to the struct won't affect PACS, unless it also
affects the public API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Workaround HCTO calculation for BabbleSIM due to need of
addition timeout value required to have anchor point sync.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect peripheral drift compensation when connection
events are overlapping and a PHY update causes the currently
used PHY to change.
Incorrect preamble to address that is calculated using
updated PHY was used causing supervision timeout.
Fixed by storing the PHY used in the current connection
event and using that for drift compensation calculation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix connection event busy check when peripheral role is
using minimal time reservation.
Peripheral and Central have a anchor point sync if the
Peripheral has successfully transmitted once to the Central.
Fixes commit cadef5a64f ("Bluetooth: Controller: Introduce
BT_CTLR_PERIPHERAL_RESERVE_MAX")'.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Recently I have had to debug issues with PSA and having
the returns values from PSA is very useful in order to
find the root cause of the issue.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
In https://github.com/zephyrproject-rtos/zephyr/pull/84268
the ability to use the controller for ECDH was removed from
the host.
This means that BT_CTLR_ECDH is now only useful when using
BT_HCI_RAW.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
In the function `bt_l2cap_br_server_register()`, the PSM cannot be
dynamic allocated. And only pre-set PSM is supported.
Improve the function `bt_l2cap_br_server_register()` to support the
dynamic PSM allocation if the passed PSM is zero.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
This is a follow-up to commit 12eee61533.
Explicitly enable "PSA_WANT_ALG_ECB_NO_PADDING" to select the AES ECB
mode that it is used in CMAC operation.
This is done because CMAC uses AES-ECB, so both AES and ECB must
be explicitly enabled. Previously it worked because Mbed TLS is
not currently performing any check internally on this and it's
just enabling ECB automatically.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The function used to write the value of the GAP Device Name
characteristic now ensure that the string passed to `bt_set_name` is
null terminated.
Also fix a wrong offset calculation.
The function used to write the value of the GAP Device Name
characteristic was returning an error when the offset + the length of
data to write was superior **or equal** to the maximum size of the
device name.
This caused the actual maximum device name size to be reduced by 1 byte.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
The PACS flags were incorrectly defined without
ATOMIC_DEFINE and then it treated the atomit_t as an
array with the atomic functions.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>