Fix BT_CTLR_ULL_HIGH_PRIO default value to equal
BT_CTLR_LLL_PRIO value if BT_CTLR_LOW_LAT is enabled, else
default ULL_HIGH to lower IRQ priority level in comparison
to LLL IRQ priority level. If BT_CTLR_ZLI is enabled,
BT_CTLR_ULL_HIGH_PRIO can default to a priority level value
of 0 and still be lower priority level than the LLL which
is placed at Zero Latency IRQ priority level (highest
priority in the CPU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As network_decode needs a target buffer for decoding, the max PDU length
must be checked to prevent overflow on the target buffer. When receiving
a proxy configuration message with excessive length, there's no previous
check for this.
Also pulls the NET PDU length defines out into net.h, so they can be
used when defining the target buffers.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix Tx Buffer Overflow caused by uninitialized node_tx
memory being used by ULL ISR context due to Compiler
Instructions Reordering in the use of MFIFO_ENQUEUE.
The MFIFO last index was committed before the data element
was stored in the MFIFO due to Compiler Instructions
Reordering.
This is fixed now by adding a Data Memory Barrier
instruction alongwith a compiler memory clobber.
Fixes#30378.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use of Data Memory Barrier instruction with memory clobber
in ARM Cortex M architectures is sufficient in the
controller implementation to keep compiler data access
instructions in order so that an ISR vectoring has memory
accesses in the correct order as intented by design.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Mark the option BT_FIXED_PASSKEY as an insecure option.
During Legacy pairing the passkey is used as encryption key, and
brute-forcing this is easy.
During LE Secure Connections the passkey is checked one bit at a time,
so when it is fixed the passkey can be deduced with series of pairing
attempts.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Bluetooth SMP protocol depends on the BT_ECC for the LE Secure
Connections pairing. Since this feature cannot be disabled we must
select this dependency.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix fixed passkey for legacy pairing. The pairing procedure fails
because the temporary key (TK) has not been set for this pairing
procedure.
Fix this by always requesting the legacy TK.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix misleading message in the bluetooth shell when the id-create
command returns en error code. In this case both failure and success
messages are printed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add options to control the behavior of the init command.
Option no-settings-load allows the user to create identities
with the id-create command after bt_enable() but before settings_load().
Option no-ready-cb allows the user to test using synchronous enable,
since this sometimes leads to different behavior of the stack.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Prevent the bt_rand function from being called before bt_enable.
Depending on the implementation of bt_rand this function cannot
be called before bluetooth has been initialized. With host supplied
crypto functions the HCI LE rand command is used for example.
The use case for calling bt_id_create before bt_enable is meant for
when the application has storage for the identity instead of the stack.
So we add the requirement that the application has to have storage
for the identity resolving key (IRK) in addition when the local
device is privacy-enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the default ULL_HIGH execution priority to be lower than
LLL execution priority to reduce Radio ISR service latency.
Also, default to Zero Latency IRQ for Radio ISR if enabled
in the kernel.
Fixes#29994.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ad_len parameter is not length of complete advertising data, but number
of bt_data structs passed to bt_le_per_adv_set_data - we pass only one.
Also memset target buffer before converting hex string so data shorter
than specified will be right-padded with zeroes instead of some
leftovers.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Fix the mayfly callee id for the rx_demux scheduling under
the LOW_LAT_ULL implementation. This could be causing
undefined mayfly execution behavior in nRF51x SoC.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the deprecated bt_conn_create_slave_le function.
This was deprecated in the 2.3.0 release.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Conform to Bluetooth Specification, if the LE_Scan_Enable
parameter is set to 0x01 and scanning is already enabled,
any change to the Filter_Duplicates setting shall take
effect. Disabling scanning when it is disabled has no
effect.
Fixes#31019.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in adding the state for Connection Parameter
Request being rejected where in Connection Parameter Request
Procedure state machine was prematurely reset before the
reject PDU was enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of ticks_to_offset value on
instantiation of new peripheral context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix repeated offsets in LE Connection Parameter Request PDU
due to rounding errors. Use tick units of connection
interval to calculate the offset units.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Parameter Request offset population
by introduction of explicit states waiting for the offset
calculations to complete in the ULL_LOW context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Update offset population by
introduction of explicit states waiting for the offset
calculation to complete in the ULL_LOW context.
Fixes#29636.
The problem was, in an encrypted connection the enqueued PDU
to be transmitted is encrypt in the prepare callback by the
hardware and swapped to a different buffer for transmission;
the deferred offset population did not reflect in the
transmitted PDU as it was filled in the cleartext buffer
while encryption completed into the encrypted buffer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix error introduced by pull request:
https://github.com/zephyrproject-rtos/zephyr/pull/31591
Zephyrs CMake extension function zephyr_library_sources_ifdef()
does not allow to use complex conditions to toggle if
sources should be included in build or not.
It allows to use only single variable as an input for
feature_toggle argument because it is double-expanded
in contition statement in the function.
In case there is a requirement that source file is included
when more complicated condition is true we have to fall-back
to reqular if() statement and zephyr_library_sources().
The fix is required because without it radio_df.c source
is never compiled. If DF functionality is enabled build
will fail because of missing functions implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix implementation to run local peripheral initiated control
procedure with instant in parallel with remote initiated
encryption procedure.
Relates to #28887.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If a PHY update is waiting for the instant to be reached and the master
starts the encryption procedure, store the pending PHY update procedure
and handle it simultaneously with the encryption setup.
This fix prevents the encryption setup from stalling and thereby timing
out after 40s, after which the master drops the link.
The ll_conn::llcp::encryption can not longer be unioned with the
ll_conn::llcp:phy_upd_ind as one would overwrite the other.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add conditional compilation on peripheral and central
specific control procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BIG Sync Terminate Command to generate Sync Established
event if Sync initiation is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added missing allocation of node rx buffer required for
generation of Broadcast ISO Sync Established.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The net_buf was never unref'ed when the host received an
ISO package that was a SINGLE.
Also adds a few additional debug messages.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
`iso send` may take an optional "count" parameter but the
number of optional arguments was incorrect.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The DF tests are implemented to be executed with nrf52_bsim platform.
The nrf52_bsim platform does not include Direction Finding Extenstion.
Due to that, radio_df.c compilation failed with error about missing
antenna configuration in DTS.
To solve the problem, I've changed nrf.cmake to include radio_df.c
file when CONFIG_BT_CTLR_DF is defined and CONFIG_SOC_SERIES_BSIM_NRFXX
is not definded.
Thanks to that any other platform is not affected. The file will not
build if there is no appropriate configuration or there are missing
features in a hardwared.
Unit tests have provided stub imlpementation or radio functionality.
If nrf52_bsim has implemented Direction Finding Extension, the
DF unit tests code will stil work and will not require additional
changes. Also content of the file is not affected by contional
compilation entries.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove ATT modifying the L2CAP channel state by unassigning the
the connection pointer on timeout.
Unassigning this pointer does not prevent the ATT channel from receiving
since bt_l2cap_recv does not inspect this pointer before calling the
channel receive function.
This prevented the disconnected callback from being called on the
channel after the channel had timed out, but since the disconnected
callback now handles this case this workaroun is no longer needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle ATT timeout on disconnected ATT channel.
When the ATT channel is disconnected with a pending request the ATT
timeout is canceled and the response processed with an error code.
However canceling of delayed work is not guaranted to succeed, e.g:
"Work queue thread has removed the work item from the queue but has not
called its handler"
This could lead to timeout handler being invoked after the disconnected
handler.
Fixes: #29098
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation error caused by use of wrong header file:
nrfx/hal/nrf_radio.h instead of hal/nrf_radio.h.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Coded PHY is only enabled by default if the application is using
BT_HCI_RAW.
Coded PHY is not needed in most applications.
By disabling Coded PHY, most applications will:
* Get smaller in terms of flash and ram usage
* Not get vurnerable to devices trying to switch to Coded and
thereby increasing power consumption.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fix compilation error if CONFIG_BT_CTLR_DF is not defined.
If DF was not enabled, there was missing CONFIG_BT_CTLR_DF_MAX_-
ANT_SW_PATTERN_LEN and undeclared symbol was found.
Split ll_df.h into two parts:
- ll_df.h that is generally includeable and allows to successfully
compile sources when DF is not enabled.
- ll_df_internal.h to be used in soucres that are compiled when
DF is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction Finding requires initalization of a set of registers
in Radio peripheral. Also it requires information about antenna
matrix unit that are provided by end user in DTS overlay.
Implemented initialization step is responsible for validation of
hardware information delivered by DTS and setting up DF related
registers in Radio.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add support for Direction Finding antenna configuration in
Nordic hal of Bluetooth controller.
Add handling of response for HCI_LE_Read_Antenna_Information
HCI command in controller (upper and lower link layer).
Handling of response to the command requires antenna matrix
configuration.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
After nrfx glue code was decoupled from nrfx sources, it is no longer
feasible to use those inclusions in the <nrfx/hal/nrf_*.h> form (there
is no point in adding the main directory of the hal_nordic module as
an include path solely for this reason). Remove then the nrfx/ part.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Fix size of L2CAP disconnect request buffer pool which did not include
the size of the L2CAP signal header.
Regression from: 3346aa4d39
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Defined 625 and 1250 as context specific interval common to ULL and LLL.
Checked with bluetooth sanity checks.
Fixes#23314.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Some proprietary protocols that reuse the Bluetooth LLCP logic requires
that the CPR interval has a valid range that differs from the Bluetooth
specification defined.
Vendor must implement the function (ull_vendor.h)
uint16_t ull_conn_interval_min_get(struct ll_conn *conn)
that returns the valid limit for the given connection.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>