There is a change (commit no.: 93d0eac834) that if
the `ref` of sending buf is not 1, the error code
`-EINVAL` will be returned from bt_conn_send_cb.
It causes the RFCOMM functionality cannot work
properly.
Remove the ref operation from the buf to be sent
to fix the issue.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
When validating the parameters for broadcast reception start some
return statements were missing, they have been added, as well as
proper initialisation of a variable
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
If we are merging subgroup and BIS codec configuration data
for a codec other than LC3, then we just append them, but
did not properly update the length.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The 3-byte value suits the assigned number much better,
and also allows for less memory copies when getting and
setting the values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the "stream" part of the value and functions to
better fit with the name in the assigned numbers document.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
View buffers are now also a limited resource. Acquire them before
attempting to pull data. `CONFIG_BT_CONN_FRAG_COUNT` should be tuned on
a per-application basis to avoid this.
A possible optimization, that was present before, is to not create a
frag when the original buffer fits the controller's HCI size.
I prefer deferring this optimization to a future patchset.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
We can get rid of the view pool for SDU segments :)
We have to make the code slightly more complex :'(
The basic idea is always giving the original SDU buffer to `conn.c` for it
to pull ACL fragments from.
In order to do this, we need to add the PDU headers just-in-time.
`bt_l2cap_send_pdu()` does not add them before putting the PDU on the queue
anymore. They are added by `l2cap_data_pull()` right before the data leaves
`l2cap.c` for `conn.c`.
We also have to inform `conn.c` "out of band" of the real L2CAP PDU size so
it doesn't fragment across segment boundaries. This oob is the new `length`
parameter to the `.pull()` method.
This is the added complexity mentioned above.
Since SDU segmentation concerns only LE-L2CAP, ISO and Classic L2CAP don't
need this extra logic.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
We don't need the TX thread anymore.
Generalizing the pull-based architecture (ie. `tx_processor`) to HCI
commands makes it possible to run the whole TX path from the the system
workqueue, or any workqueue really.
There is an edge-case, where we call `bt_hci_cmd_send_sync()` from the
syswq, stalling the system. The proposed mitigation is to attempt to drain
the command queue from within `bt_hci_cmd_send_sync()`.
My spidey sense tingles however, and it would be better to just remove the
capability of calling this fn from the syswq. But doing this requires
refactoring a bunch of synchronous procedures in the stack (e.g. stack
init, connection establishment, address setting etc), dragging in more
work. I will do it, but in a later patch.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This API replaces `bt_l2cap_send()` and `bt_l2cap_send_cb()`.
The difference is that it takes the `struct bt_l2cap_le_chan` object
directly instead of a connection + CID.
We need the channel object in order to put the PDU on the TX queue. It
is inefficient to do a search for every PDU when the caller knows the
channel object's address and can just pass it down.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The current TX pattern in the host is to try to push a buffer through all
the layers up until it is ingested by the controller.
Since sending can fail at any layer, we need error-handling and separate
retry logic on pretty much all layers. That logic obscures the "happy path"
for people trying ot understand the code.
This commit inverts the control, in a way that doesn't require changing the
host or HCI driver API (yet):
Layers don't send buffers synchronously, they instead put their buffer in a
private queue of their own and raise a TX flag on the lower layer. Think of
it as a `READY` interrupt line that has to be serviced by the lower layer.
Sending is now non-blocking, rate depends on the size of buffer pools.
There is a single TX processing function. This can be thought as the
Interrupt Service Routine that will handle the `READY` interrupt from the
layers above.
That `tx_processor()` will then attempt to allocate enough resources in
order to send the buffer through to the controller. This allocation logic
does not block.
After acquiring all the resources, the TX processor will attempt to pull
data from the upper layer. The upper layer has to figure out which buffer
to pass to the controller. This is a good spot to put scheduling or QoS
logic in the upper layer.
Notes:
- user-facing API for tuning QoS will be implemented in a future patch
- this scheme could (and probably will) be extended to upper layers (e.g.
ATT, L2CAP CoC segmentation).
- this patch removes the `pending_no_cb()` memory optimization for
clarity/correctness. It might get re-implemented after a stabilization
period. Hopefully with more documentation.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Instead of allocating segments/fragments and copying data into them, we
allocate segments as "views" (or slices) into the original buffer.
The view also gives access to the headroom of the original buffer, allowing
lower layers to push their headers.
We choose not to allow multiple views into the same buffer as the headroom
of a view would overlap with the data of the previous view.
We mark a buffer as locked (or "in-view") by temporarily setting its
headroom to zero. This effectively stops create_view because the requested
headroom is not available.
Each layer that does some kind of fragmentation and wants to use views for
that needs to maintain a buffer pool (bufsize 0, count = max views) and a
metadata array (size = max views) for the view mechanism to work.
Maximum number of views: number of parallel buffers from the upper layer,
e.g. number of L2CAP channels for L2CAP segmentation or number of ACL
connections for HCI fragmentation.
Reason for the change:
1. prevent deadlocks or (ATT/SMP) requests timing out
2. save time (zero-copy)
3. save memory (gets rid of frag pools)
L2CAP CoC: would either allocate from the `alloc_seg` application callback,
or worse _steal_ from the same pool, or allocate from the global ACL pool.
Conn/HCI: would either allocate from `frag_pool` or the global ACL pool.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
`bt_conn_send_cb` used to allocate a TX context (K_FOREVER).
Instead, we now put the context in the userdata of the buffer.
This means that now this fn will never block and always succeed since the
tx_queue is a FIFO (infinite size). It just puts the buf on the queue.
The metadata is stored safely in there until we have acquired all the
necessary resources to send it to the controller without failing: TX
context and controller buffer.
I.e. when `bt_conn_process_tx` is called, that's when a TX context is
try-allocated and the contents of `buf->userdata` is moved into it.
The buffer is now ready to be sent to the lower layer.
`bt_conn_process_tx` will return -EWOULDBLOCK if it's not able to acquire a
TX context, this PR modifies `bt_conn_prepare_events` to respond to this by
also waiting on the TX context pool.
Unfortunately, this increases the required userdata size for any buffers
handed to `bt_conn_send_cb`. This will be fixed in a later commit.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
If the new encryption state is the same as the old one, there's no point in
doing additional processing or callbacks. Simply log a warning and ignore
the HCI event in such a case.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Update the native controller to the new HCI driver API. The devicetree
node is placed under existing `radio` nodes, which seemed like the most
intuitive option.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Add support for HCI drivers which use the newly defined HCI driver API.
Since Zephyr (currently) only supports a single HCI driver instance,
boards are expected to indicate the instance using a new devicetree
chosen property `zephyr,bt_hci`.
In order to maintain compatibility with not-yet-converted drivers the
code has been placed behind `#if DT_HAS_CHOSEN(zephyr_bt_hci)`
conditionals.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
https://github.com/zephyrproject-rtos/zephyr/pull/72674 fixed
a bug where this configuration did not work.
Now that this configuration is tested, we should mark it
as supported.
The timeout check that was present in the code before
was useless and was not working because the check was
run before a default timeout of 0 was converted to a timeout.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
ull_adv_sync_pdu_set_clear does pretty much everything, causing
it to be very complex and awkward to use. In addition, it only handles
a single PDU, meaning callers have to handle the chain.
It has been replaced with simpler, more complete functions for handling
the relevant operations
Fixed issues include:
- Fragmentation of adv data over HCI is now decoupled from PDU
fragmentation, fixing HCI/DDI/BI-13-C, LL/DDI/ADV/BV-26-C and
LL/DDI/ADV/BV-55-C
- Adding BigInfo now preserves the PDU chain
- Enabling periodic advertising with ADI on would sometimes fail
due to insufficient space in a single PDU to add ADI
Signed-off-by: Troels Nilsson <trnn@demant.com>
Use the compatible kconfig option so that for the simulated
nRF54L15 we build the same code as for the real platform.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
For the Nordic HW, the BT_CTLR_DATA_LEN_UPDATE_SUPPORT
does not require CCM HW enabled, hence support Data Length
Update if Encryption Support is disabled.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In some nRF54 devices, DATAWHITEIV was renamed to
DATAWHITE,
and the CRCCNF SKIADDR field was renamed OFFSET.
The nrf HAL hid this change internally,
so let's use it so we don't need to ifdef these
in the Bluetooth Controller HAL code.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add preliminary support for nRF54L15 SoC. This commit does
not support Controller Random Number Generation and
Controller Cryptography (AES-128 encryption) commands, nor
does it support encrypted connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use NRF_RTC and NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk instead
to prepare towards using configurable use of RTC and Radio
hardware defines.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add unit tests to cover explicit LLCP error code check and
cover the same in the Controller implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A Host shall consider any error code that it does not
explicitly understand equivalent to the error code
Unspecified Error (0x1F).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce BT_CTLR_CRYPTO_SUPPORT so that preliminary port to
support nRF54L15 SoC can be upstreamed without encryption
support.
ENTROPY_GENERATOR now selected when BT_CTLR_CRYPTO enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit adds host support for the Path Loss Monitoring
feature see Bluetooth Core specification, Version 5.4,
Vol 6, Part B, Section 4.6.32.
Limited logic is required, just adding a wrapper around the
HCI command and callback for HCI event.
Add new zone - BT_CONN_LE_PATH_LOSS_ZONE_UNAVAILABLE, to
convert 0xFF path loss to a useful zone.
Add new Kconfigs and functionality to the bt shell.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
The existing code in the cap_stream.c that handled the
check before calling CAP initiator unicast functions
seemingly did not work for x86 targets such as native_sim
or native_posix.
Modified the check so that IS_ENABLED is used directly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The simulated targets support the same power levels as the
real targets. Let's correct the kconfig dependencies
accordingly.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Make `struct arch_esf` compulsory for all architectures by
declaring it in the `arch_interface.h` header.
After this commit, the named struct `z_arch_esf_t` is only used
internally to generate offsets, and is slated to be removed
from the `arch_interface.h` header in the future.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Fixes issue where PB GATT Server will drop
advertising device name if optional provisioning
URI is not provided.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Adds, removes and modifies includes in all LE audio
files.
Fixes any found spelling mistakes as well.
Fixes a few places where incorrect types were used.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The flash_area_erase has been replaced with flash_area_flatten,
allowing code to work with devices that do not provide
erase callback.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
APIs for enabling and disabling the scanner may take larger time than
expected and scheduling of the lpn state machine is affected by it.
Since these type of latencies are factored into timeouts and scheduling
times, we need to call scan enable/disable APIs after scheduling the
next event time for LPN state machine to be more accurate.
Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
Removes the CIS connection establishment from bt_bap_stream_start
and move the behavior to a new funciton bt_bap_stream_connect.
This has 2 advantages:
1) The behavior of bt_bap_stream_start is much more clear and more aligned
with the spec's behavior for the receiver start ready opcode.
2) It is possible to connect streams in both the enabling
and the QoS configured state with bt_bap_stream_connect as
per the spec. This allows us to pass additional PTS test cases.
To implement this new behavior, samples and tests have been updated.
The CAP Initiator implementation has also been updated
to accomodate for the change in BAP, but the CAP
initiator implementation should work the same for application, except
that it's now possible to do unicast start on ASEs in any order
(https://github.com/zephyrproject-rtos/zephyr/issues/72138).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When reading the error message:
"ASSERTION_FAIL: command opcode 0x0c03 timeout with err -11" it may not be
obvious what is wrong with their setup unless you are very familiar
with HCI.
This commit adds some more documentation to make this more obvious.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Removes the requirement that CAS is found on the remove
device for ad-hoc sets. This makes the CAP API more
versatile as it allows applications to use it with
remote non-CAP devices.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
PR #72475 disabled default enabling of most Mbed TLS features.
This means that:
- CONFIG_MBEDTLS_CIPHER_AES_ENABLED needs to be manually enabled
when required;
- CONFIG_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC does not need to
be (almost) always added because there is no default RSA
key-exchange enabled, so PSA can be built without RSA support.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
The function is useful for application to lookup set
members from bt_conn pointers, e.g. when iterating on
connected devices.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Currently calls to these two functions fail unnecessarily when
CONFIG_BT_SMP is disabled. This fix allows identity resets
without having the BT_SMP stack enabled. The primary use case
is enabling random mac address rotation for privacy in memory
constrained SOCs. Fixes#73313
Signed-off-by: Patrick Patel <ppatel@micro-design.com>
Fix missing validation of Connection Update Ind PDU. Ignore
invalid connection update parameters and force a silent
local connection termination.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The cap_initiator unicast_stop shell command had the wrong
minimum parameter count (as it defaults to all).
Some indentation had also gone wrong for it in the
documentation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The driver isn't currently buildable due to "west blobs" support never
having been added for hal_telink. Furthermore, even if the blob
dependency is manually made available it turns out the code has
bitrotten to the point where it doesn't build anymore. This situation
has continued for several years without anyone taking action, so I think
it's safe to assume this is unmaintained and should be removed.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.
Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.
Updated the includes path of in-tree sources accordingly.
Most of the changes here are scripted, check the PR for more
info.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Before this commit, the following bugs were present:
- When `CONFIG_BT_FILTER_ACCEPT_LIST` was set, connection establishment
was cancelled upon RPA timeout. This required the application
to restart the initiator every RPA timeout.
- When `CONFIG_BT_FILTER_ACCEPT_LIST` was not set, the RPA was not updated
while the initiator was running.
This commit unifies the RPA timeout handling for both these cases.
Upon RPA timeout the initiator is cancelled and restarted when
the controller raises the LE Connection Complete event.
The workqueue state is checked when restarting the initiator to prevent
it being restarted when the timeout is hit.
Corresponding test cases have been added to ensure that this
feature works.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Expectation: After calling `bt_disable()` it is possible to
use the Bluetooth APIs as if `bt_enable()` was never called.
This was not the case for `bt_id_create()`, it was not possible
to set the default identity. This prevented an application
developer to restart the stack as a different identity.
Keys also need to be cleared to avoid the following pattern:
1. Pair two devices
2. Central calls `bt_disable()` and `bt_enable()`.
The central will now generate a new identity address.
3. Connect the two devices.
4. Re-establish encryption. Now the central will try to use
the previously used keys. The procedure will fail
because the peripheral does not have any keys associated
with the new central address.
The API documentation is updated accordingly.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
implement a2dp.c and avdtp.c
add a2dp related Kconfig:
BT_AVDTP_RTP_VERSION, BT_A2DP_SOURCE and BT_A2DP_SINK
a2dp_codec_sbc.c/h are used to provide some APIs to get
A2DP SBC codec information. (like: channel num).
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
The notify handle in the BAP broadcast assistant did not handle
conn == NULL properly, and neither did delayed_bap_read_handler.
Add better NULL checks, which also fixes a coverity issue.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Increasing the adv latency range to the minimum valid
ReceiveDelay value, 10ms. 4ms might be small for some
target systems.
Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
The BR Keys cannot be scanned by function
bt_foreach_bond.
Add function bt_foreach_bond_br for br.
The function bt_foreach_bond_br will be
called by bt_foreach_bond if the BR is
enabled.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Implement a function bt_audio_get_chan_count that takes an enum
bt_audio_location and returns the number of channels in that value.
This PR fixes#69617
(https://github.com/zephyrproject-rtos/zephyr/issues/69617)
Signed-off-by: Babak Arisian <bbaa@demant.com>
Get the preferred QoS settings via bt_bap_ep_get_info()
Therefore no need to use the internal header file to get it.
This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/72359
Signed-off-by: Ping Wang <pinw@demant.com>
Allocate the GPIOTE channels that the Bluetooth Controller needs to use
with the dedicated function provided by the nrfx_gpiote driver instead
of using hard-coded indexes of these channels, as now, when the driver
supports multiple GPIOTE instances, it would be much more difficult to
properly inform the driver which channels should be reserved.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The BIG handle for an ISO sync receiver is provided by the host. The
valid range is [0x00..0xEF], and this requires the controller to allow
non-consecutive handle numbering. This means that even if only one sync
set is supported, a BIG handle of ex. value 2 must be supported.
As the code uses indexing and range checking directly by handle, this
needs to be changed. Introducing the handle index, which sequnces the
handles such that index = 0 is always the "first handle", regardless
of value.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Instead of selecting legacy MBEDTLS symbols, use corresponding
PSA_WANT ones when possible (note: some legacy symbols do not
have a PSA correspondance).
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Now that support for all PSA_WANT symbols is in place, we can
enable MBEDTLS_USE_PSA_CRYPTO when MBEDTLS_PSA_CRYPTO_C is
enabled as well.
Note: this commit also moves USE_PSA_CRYPTO out of CRYPTO_C
dependency in config-tls-generic.h because TLS/DTLS/X509 modules
of MbedTLS can rely on *any* implementation of PSA crypto APIs
not only the MbedTLS one. TFM is for example an alternative
to this.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Support for using Link Time Optimization (LTO) when
building application with open source Bluetooth Low
Energy Controller. This reduces code space usage.
Current Memory Usage at the time of this PR (hci_ipc):
BT_CTLR_OPTIMIZE_FOR_SPEED:
Memory region Used Size Region Size %age Used
FLASH: 260112 B 256 KB 99.22%
RAM: 60136 B 64 KB 91.76%
SRAM1: 0 B 64 KB 0.00%
IDT_LIST: 0 B 32 KB 0.00%
BT_CTLR_OPTIMIZE_FOR_SIZE:
Memory region Used Size Region Size %age Used
FLASH: 232292 B 256 KB 88.61%
RAM: 60128 B 64 KB 91.75%
SRAM1: 0 B 64 KB 0.00%
IDT_LIST: 0 B 32 KB 0.00%
BT_CTLR_OPTIMIZE_FOR_APP_DEFAULT:
Memory region Used Size Region Size %age Used
FLASH: 232292 B 256 KB 88.61%
RAM: 60128 B 64 KB 91.75%
SRAM1: 0 B 64 KB 0.00%
IDT_LIST: 0 B 32 KB 0.00%
BT_CTLR_LTO:
Memory region Used Size Region Size %age Used
FLASH: 221484 B 256 KB 84.49%
RAM: 60120 B 64 KB 91.74%
SRAM1: 0 B 64 KB 0.00%
IDT_LIST: 0 B 32 KB 0.00%
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove legacy LL optimize for speed dependency required to
support encryption feature in Controller where crypto was
performed in highest priority ISRs to setup encryption in 3
radio events (this now requires 5 radio events in split LL).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
These are safety checks to guard against silent data corruption. The
implementation currently does not clobber bufs, but soon it will. The
bufs will be zero-copy segmented and fragmented, which involves
overwriting already-sent contents with headers for the next fragment.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Changes the parsing of boolean input parameter "PolicyApply"
to DFD start command to use shell boolean parse library.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Add a new option to split off the building of the HCI layer of the
controller. This layer is not needed by the controller unit tests, and
becomes problematic with the planned change to use devicetree for HCI
drivers.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Changes the log level from ERR to DBG for element_model_recv for the
following cases:
- Element does not have the appkey for incoming message.
- Element does not have destination address for incoming meesage.
When the received message is for a group address, element_model_recv
is called for all elements on the device. One or more elements may contain
a model that is subscribing to this address. If more than one element
contains the same model. but they do not all share the same application
key as the incoming message is encrypted with, or they do not all
subscribe to the same group address, then the log will show error
message for these elements, which is misleading.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Ensure that in LLCP reference to node_rx is cleared when
retention is NOT used, to avoid corruption of node_rx later
re-allocated
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
In case a CPR is intiated but rejected due to CPR active on
other connection, rx nodes are leaked due to retained node not
being properly released.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The ISO API and implementation have existed in Zephyr
for several years, and while not fully qualified, stable
or tested yet, it's not experimental anymore (and have
not been for a long time).
This commit removes any references to it being experimental
and instead defines it as unstable by setting the version to
> 0.1.0. 0.8.0 is being used as the initial version, as that
is what other unstable modules was defined to have as their
initial version if they were not stable (>= 1.0.0).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If bt_conn_set_state(conn, BT_CONN_DISCONNECTED) is called
while the connection is already disconnected, this triggers
a warning. This is likely to happen when bt_conn_cleanup_all
is called as part of bt_disable.
Added the state check to avoid unnecessary warnings in the log.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for bt_disable in the ISO implementation.
This involves clearing all information related to states
in the controller, such as the BIGs and CIGs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since the CSIP API expects a set member struct for nearly all
functionality, the reference to the full set member (along with
the CAS specific CSIS) should be given to the application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit upgrades the LE audio API and implementation
from experimental to unstable.
LE Audio have existing for quite a few years in Zephyr
and is not going anywhere, but at the same time it still
has significant effort remaining before it can be
considered stable.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When CONFIG_USB_DEVICE_STACK=n then the sine wave
generator was enabled, which caused build errors.
This commit fixes those errors and also adds the
nRF5340 as a build target for the USB tests.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The mic_state is a guarded field in event_done_extra where it was
accessed outside of its guard.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The default stack size of RFCOMM DLC is 256.
The default value is sufficient for basic operation.
If more stack space is used (such as call function printk)
in context of callback disconnected of RFCOMM DLC, the
default stack size is not sufficient.
Add a configuration BT_RFCOMM_DLC_STACK_SIZE to configure
the RFCOMM DLC stack size.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
To avoid the case that CONN_TX is available but RFCOMM_TX is
unavailable, set the default value of BT_RFCOMM_TX_MAX to
BT_CONN_TX_MAX.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The maximum data length of event packet is 255 for BR/EDR.
Such as the data length of event Remote Name Request
Complete is 255.
Set BT_BUF_EVT_RX_SIZE to 255 to avoid error "Not enough
space in buffer" from bt_hci driver.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The callback is only ever called when we received a
notification from the BASS server that the receive state is
removed, which cannot contain an error code.
Thus it does not make sense for the callback to have an
error code.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
For vendor datapaths that do not use a netbuffer to write SDUs
into, the callee of sdu_write currently has to keep track itself
of how much data has been written to the current SDU; This is wasteful
since ISOAL already keeps track of that. Add an sdu_written parameter
to the callback to inform the callee how much has been written to the
current SDU already so the callee can write using the correct offset
Signed-off-by: Troels Nilsson <trnn@demant.com>
This function was used to shortcut HCI for combined host + controller
builds. It doesn't provide much value and adds complexity to the HCI
driver interface, so just remove it. This means vendor-specific HCI
commands is now the only way for the host to access the same
information.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Enabling vendor-specific extensions also implies support for vendor
events, so a separate Kconfig option for that is unnecessary.
One small additional thing this requires is the use of the
__maybe_unused annotation, since there's no-longer a single Kconfig
option that the controller hci.c can use to know that the vendor event
helper symbols are needed.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
The naming of these two options was problematic, since it's both of them
are about vendor extensions, even though one has _EXT in the name and
the other doesn't. Just merge one option into the other. This has a
slight overhead on the controller side of enabling some more vendor
features if BT_HCI_VS is enabled, but that should hopefully be
acceptable.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Add support for receiving audio data from e.g. a PC
over USB and LC3 encode it before sending it
on BAP audio streams.
This refactores the entire TX path, as it has moved
from only support the sine wave generator, to also
supporting USB.
The encoding and sending of data is now in it's own
thread, instead of relying on the system workqueue thread
and k_work items.
Several other refactors have taken place to reduce lines
of codec (such as the introduction of the bap_foreach_stream
function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Calling bt_disable in system workqueue context while BLE connected may
lead to calling wait_for_tx_work in this context. Fix check in code to
avoid assertion failure.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
When using the CAP initiator shell AC commands, the channel
allocation were not done correctly, leading to cases where
we attempted to set e.g. 2 LEFT streams for the same device.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make `bt_hci_cmd_send_sync` return `-EACCES` when receiving
`BT_HCI_ERR_CMD_DISALLOWED`.
Update some tests that were expecting `-EIO` when
getting `BT_HCI_ERR_CMD_DISALLOWED`.
Add a warning in `set_random_address` when getting that new error. This
is done in case someone try to set a new random address while legacy
advertising, scanning or initiating is enabled. This is illegal behavior
according to the Core Spec (see Vol 4, Part E 7.8.4).
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Derive BT_CTLR_ISO_TX_BUFFER_SIZE from BT_ISO_TX_MTU to have
optimal Controller memory allocations.
BT_CTLR_ISO_TX_BUFFER_SIZE can be set lower than
BT_ISO_TX_MTU in which case upper layer can send fragmented
SDU to the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename struct bt_hci_iso_data_hdr to bt_hci_iso_sdu_hdr, and
struct bt_hci_iso_ts_data_hdr to bt_hci_iso_sdu_ts_hdr.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In ull_disable, it is imperative that the callback is set up before a
second reference counter check, otherwise it may happen that an LLL done
event has already passed when the disable callback and semaphore is
assigned.
This causes the HCI thread to wait until timeout and assert after
ull_ticker_stop_with_mark.
For certain compilers, due to compiler optimizations, it can be seen
from the assembler code that the callback is assigned after the second
reference counter check.
By adding memory barriers, the code correctly reorders code to the
expected sequence.
Signed-off-by: Morten Priess <mtpr@oticon.com>
I got some feedback about confusion as to why the bt_addr types are not
packed. This commit adds a note about it.
This commit also adds a check for the alignof of the structs to verify
the statement 'their members are bytes or byte arrays' to thoroughly
prove that the struct is effectively as-if packed.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
MBEDTLS_PSA_CRYPTO_C and MBEDTLS_USE_PSA_CRYPTO are 2 different
things and the former should not automatically enable the
latter. The reson is that the user might want the MbedTLS
PSA crypto toolbox to be built, but at the same time he/she
does not want TLS/DTLS (and other intermediate modules such
as PK, MD and Cipher) to use PSA APIs.
For this reason this commit introduces a new Kconfig option
named CONFIG_MBEDTLS_USE_PSA_CRYPTO to enable the corresponding
build symbol. By default USE_PSA_CRYPTO is disabled. It is
only explicilty enabled in tests/samples that were previously
setting CRYPTO_C (since in those cases USE_PSA was set).
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Implement LL_ASSERT_INFO1 and LL_ASSERT_INFO2 for triggering assertions
with parameter information provided for vendor core dump.
Adds Kconfig CONFIG_BT_CTLR_ASSERT_VENDOR by which the new LL asserts
map to BT_ASSERT_VND macros, which shall be implemented in the
debug_vendor_hal.h of the platform. If not enabled, LL_ASSERT_INFO will
map to existing BT_ASSERT_MSG with parameters printed.
Add use of LL_ASSERT_INFO2 where ull_ticker_stop_with_mark() result may
assert.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When building ISO applications on a device that has the host
and controller on the same core, the application developer
shouldn't have to set controller specific configurations.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
net_buf_alloc(K_FOREVER) can now fail (if run from the syswq). Propagate to
the caller instead of asserting.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The `BT_DEBUG_*` Kconfig symbols have been deprecated for more than 2
versions, remove them.
Update code that was still using them.
Remove the Bluetooth specific `Kconfig.template.log_config_bt` and use
`Kconfig.template.log_config_inherit` from the logging subsystem
instead, now that the legacy symbols can be removed.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Add the CAP commander reception start procedure which starts reception
on one or more CAP acceptors
With the implementation of broadcast reception start procedure we also need
some mockups for unit testing
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
When calling bap_broadcast_assistant add_pa_sync, it should only
set the BIS index field as optional parameters and not to whatever
is in the BASE.
If setting BIS index which the BASE does not support, then the
command should be rejected.
This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/70835
Signed-off-by: Ping Wang <pinw@demant.com>
When calling bap_broadcast_assistant add_pa_sync, it should only
set the BIS index field as optional parameters and not to whatever
is in the BASE.
If setting BIS index which the BASE does not support, then the
command should be rejected.
This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/70835
Signed-off-by: Ping Wang <pinw@demant.com>
The bt_cap_common_discover function relied on a global variable
used to indicate that a discovery was in process.
This global variable prevented multiple discoveries to take place
on multiple ACL connections, where the intention was to stop
multiple discoveries on the same ACL.
This has been fixed by moving the variable into the
struct bt_cap_common_client, so that it applies per
connection, rather than a global check.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moved the busy flag and the GATT paramters to the
individual CSIP Set Coordinator instances.
This allows to use multiple instances in parallel,
and thus in turn allow CAP to do things in parallel.
This commit has been done with minimal amount of changes,
even if there are multiple pieces of code that could likely
be refactored to be better.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Callback was always called with NULL conn. Now it is called with proper
pointer or NULL conforming to description.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
As documented in bt_le_scan_update(), the host may start scanning
automatically for various reasons.
Until now scanning was only done on 1M PHY, making it impossible
to use auto-connect/sync establishment if the advertiser was using
Coded PHY as its primary PHY.
Auto-connection would never work. Sync establishment would work if
the scanner was started by the application.
This commit fixes this by instructing the controller to scan on
both 1M and Coded PHY if the controller supports Coded PHY.
The application may see increased power consumption as a result
of this change as the controller may now spend 2*scan_window
listening for advertising packets.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Use reschedule margin as minimum ticks_slot when ticker with
reschedule expires. This will ensure not too many unreserved
tickers expire in close proximity that can lead of pile up
of CPU processing time and eventually causing timeout
callbacks to be delayed. This mitigate possible LL asserts
due to overhead in start of radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable use of ticker slow window yield feature under mesh
usecase. This is make sure scan window either slides within
is window or skips to next interval so that it does not
lead to advertising event being skipped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix short prepare preempt timeout start, such that if there
are any normal prepare before a short prepare in the
pipeline, then find the short prepare and start its preempt
timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add prepare pipeline assertion checks to detect faults
like stopping preempt timeout without prior start. Also,
check if the preemptor param is correct when preemption
is performed. Check that the prepare pipeline is not
infinitely looping.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add assertion check for use of scan aux context so that
scan aux context is not assigned again while there is
already an existing LLL scheduling in use by the scan
context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_EARLY_ABORT_PREVIOUS_PREPARE to setup new
shorter preempt timeout irrespective of whether there
is a previous prepare enqueued in the prepare pipeline.
Relates to commit d573951f0d ("Bluetooth: Controller:
Revert back early abort of previous prepare").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit updates models metadata API to simplify the usage and
removes the metadata pointer in health server model context.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
When in the BAP unicast server role, at least PAC sink
or PAC source shall be set.
In order to fulfill this new requirement, a few other Kconfig
options had to be changed to a `depends on` from `select` to
avoid recursive Kconfig requirements. This change may require
some applications to update their configurations according
to the migration guide.
The change from `select` to `depends on` is ideal anyhow
as that is the recommended way to add dependencies.
This can checked via the combined BT_PACS Kconfig value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When building ISO applications on a device that has the host
and controller on the same core, the application developer
shouldn't have to set controller specific configurations.
Without this change the samples iso_receive and iso_broadcast
will fail to run on NRF52 series devices as the samples
try to set up two streams but the controller is configured
to support only one.
Controller unit tests that were previously only enabling the
controller specific ISO configurations now also enable the
top-level ISO configurations to ensure that the default
stream count is properly configured.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Add USB out support for the BAP shell, so that decoded LC3
data can be sent to the host (e.g. a PC).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The volume controller always set the busy flag in
bt_vcp_vol_ctlr_set_vol, where it should only set it
if the GATT operation succeeds.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Send a `READ_MAX_ADV_DATA_LEN` command to the controller at the
initialization of the host to fetch the maximum advertising data length
the host can accept.
This is done because even if the Zephyr controller provide the
`CONFIG_BT_CTLR_ADV_DATA_LEN_MAX` Kconfig symbol, other controllers may
not have such Kconfig symbol. So this is a way for the host to be more
controller-agnostic and provide useful feedback to the users.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
In most cases these were defined as 1. Saving one byte for the rest
doesn't really justify the added complexity that comes with these
options. Removing them also simplifies the interface between HCI
transports/drivers and the host stack, which in turn helps pave the way
for having HCI as a proper Zephyr driver API.
Fixes#71907
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Commit adds using host\controller based random number
generator instead of zephyr driver.
No mesh dependency anymore on zephyr system
random driver.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This function is used in many places, but just by reading its
name it is not obvious why it is needed.
By adding some documentation it will hopefully become a bit more
clear that this function is mainly used for auto connection
establishment.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This line was clearly intended to check for the value returned by
ad_init(). The ad_len is unsigned, so checking for a negative value
showed up in a recent Coverity run (no GitHub issue for it yet).
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Update the documentation of `BT_CTLR_ADV_DATA_CHAIN` Kconfig symbol to
say that it's only supported in *non-connectable* extended advertising.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
We can (and do) open multiple channels with a single L2CAP command. If the
remote doesn't support dynamic channels at all, then it sends back a
REJECT_RSP.
We only destroyed the first channel that matched the command PDU
identifier. Fix that and remove all channels that match.
Also add a test that verifies the patch.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>