memset already clean the `buf`, don't need to set as NULL.
`avdtp_set_status` already set `req->status` based on `msg_type`,
don't need to check `msg_type` again.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
bt_a2dp_ep_info is used in bt_a2dp_discover, and the max
discovered endpoints' info are already given in seps_info
of bt_a2dp_discover_param, so use pointer to point to the
seps_info of bt_a2dp_discover_param.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
use two handler array to process cmd and response separately,
make the functions shorter and codes more readable.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Fix end time capture be on radio event end irrespective of
direction finding support. Let the timer clear use radio
end or radio phy end, for no direction finding or direction
finding support, respectively.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix single timer use end time capture from being disabled
as end time and timer clear use the same PPI.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix active mode extended scanning assert raised when calling
radio_tmr_start_us() due to stale radio_tmr_end_get() value.
Active mode extended scanning did not drop reception of
ADV_EXT_IND PDU when setup to receive ADV_SCAN_RSP PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_LOW_LAT_ULL dependency after changes in
commit 5119896c7d ("Bluetooth: Controller: Fix
BT_CTLR_LOW_LAT_ULL conditional code").
BT_CTLR_LOW_LAT_ULL is independent of BT_CTLR_LOW_LAT, where
the later prevents any ULL execution inside a radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit alignes the timeout value for allocating buffers within att
on the BT RX thread, making it consistent within att.c, see
bt_att_req_alloc.
We are inferring in many bt_gatt_* functions that if called from a BT RX
thread (which is inherently the case if called from a callback when
running a Bluetooth application), we don't block and instead return
-ENOMEM when the ATT request queue is full, avoiding a deadlock.
This promise is fulfilled within bt_att_req_alloc, where the timeout for
allocation of the request slab is set to K_NO_WAIT if we are on the BT
RX thread. Unfortunately, we break this promise in
bt_att_chan_create_pdu, where the timeout for allocation of the att pool
is still K_FOREVER and deadlocks can (and do) occur when too many
requests are sent yet the pool is depleted.
Note: Both req_slab and att_pool sizes are defined by
CONFIG_BT_ATT_TX_COUNT. If applications start getting -ENOMEM with this
change, they were at risk of such a deadlock, and may increase
CONFIG_BT_ATT_TX_COUNT to allocate the att pool for their requests.
Note: This possible deadlock has been flying under the radar, as
att_pools are freed when the HCI driver has sent it to the controller
(instead of when receiving the response, as it happens with req_slabs)
and due to the att_pool and the req_slab being both sized by
CONFIG_BT_ATT_TX_COUNT, and req_slab being allocated before and
returning -ENOMEM already if there is no space, it takes a more specific
situation to deplete the att_pool but not the req_slab pool at this
point.
Note: Ideally, we don't want functions to behave differently depending
on which thread they are running, and while this commit makes it more
consistent, it should be considered a workaround solution.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
The buffer allocation in conn.c will trigger warnings if we try to use
anything else than K_NO_WAIT for the timeout when called from within the
system workqueue.
The calls in l2cap.c and att.c which may pass non-zero timeouts already
have proper handling for failed allocations, so make sure we use K_NO_WAIT
to avoid unnecessary warnings from conn.c.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Simplify the defines calculating the minimum required ISO
PDU length and the buffer count.
Co-authored-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO Tx PDU buffer count required when SDU fragmentation
is used.
Rename BT_CTLR_CONN_ISO_SDU_LEN_MAX to
BT_CTLR_ISO_TX_SDU_LEN_MAX so the value is common to both
Broadcast and Connected ISO transmissions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename the internal BT_CTLR_ISO_TX_BUFFERS to
BT_CTLR_ISO_TX_PDU_BUFFERS correct represent the number
of actual ISO PDU buffers allocated in the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
* This variable default value has to be true, so that the
application can return false in the expired callback
Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
This updates the help text for the Kconfig option BT_MESH_WORKQ_SYS to
take into account the change made in PR #84282 which causes the host to
no longer return -ENOBUFS. Since the mesh will now instead block the
work queue, a note has been added about a potential consequence of this.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
Fix HCI command buffer allocation failure, that can cause
loss of Host Number of Completed Packets command.
Fail by rejecting the HCI Host Buffer Size command if the
required number of HCI command buffers are not allocated in
the Controller implementation.
When Controller to Host data flow control is supported in
the Controller only build, ensure that BT_BUF_CMD_TX_COUNT
is greater than or equal to (BT_BUF_RX_COUNT + Ncmd),
where Ncmd is supported maximum Num_HCI_Command_Packets in
the Controller implementation.
Relates to commit 81614307e9 ("Bluetooth: Add workaround
for no command buffer available")'.
Relates to commit 297f4f481f ("Bluetooth: Split HCI
command & event buffers to two pools").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove nested allocation of HCI command buffer so that one
less HCI command buffer is needed starting extended
advertising with privacy enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When scanning is started on bt_bap_broadcast_assistant_scan_start then
BAP_BA_FLAG_SCANNING flag for the broadcast assistant instance should
not be cleared.
Fixes#85937
Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
When `bt_le_oob_get_local` or `bt_le_ext_adv_oob_get_local` is called
and SMP is enabled, `bt_smp_le_oob_generate_sc_data` is called to
generate a Random Number and a Confirmation Value needed for OOB data.
These values are based on the device's public key.
The public key is generated only once when `bt_smp_init` is called.
If public key generation fails, the callback passed to `bt_pub_key_get`
is called with `pkey` set to NULL. The `bt_smp_pkey_ready` callback
gets called, but it doesn't release the `sc_local_pkey_ready` semaphore
thus leaving `bt_smp_le_oob_generate_sc_data` wait for semaphore with
`K_FOREVER`.
This commit replaces the semaphore with a conditional variable and
requests a public key again if the key is NULL thus solving 2 issues:
- handling the case where the callback was triggered notifying about the
completion of the public key request, but the key was not generated,
- handling the case where multiple threads trying to acquire the same
sempahore.
The timeout is used instead of K_FOREVER to avoid cases when callback
has never been triggered.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
In function `avdtp_send`, there is case that if the session->req is not
NULL, then the buf will be lost.
Release the allocated buffer by buffer allocated function when the buf
is failed to send.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
When the stream enters the idle state, some values were not
properly reset (e.g. the stream->ep).
Use the bt_bap_stream_detach function to clean up the stream.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix regression in scan aux release now that aux context is
retrieved from the node rx when supporting multiple chain
reception.
Relates to commit a8065926ac ("Bluetooth: Controller: Fix
to release aux context stored in node rx").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Commit removes weak attribute and renames some functions
in crypto_psa.c since there is no centralized distribution
of the PSA key ID in bsim tests and no necessity to
reimplement native mesh approach.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The unicast server does not need GATT caching and it was likely
incorrectly added earlier as a dependency.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of providing NULL for bt_gatt_notify_uuid we
iterate on the connection objects and ensure that we
properly truncate the notification based on each
connection's GATT MTU.
This ensures that we send the right size for all
connections.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a common function to get the maximum notification
size, instead of having multiple implementations of this.
Ideally this function should be moved to the GATT API,
but for now just implement it for LE audio and then move to
GATT later.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added missing documentation for
bt_ccp_call_control_client_discover.
Added missing handling of -ENOTCONN in the function as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The total attributes list bytes count is only used to check the tail
room of response buffer. And the remaining frame length is used to
copy data from receiving buffer.
It does not check whether the remaining frame length is consistent with
the total attributes list bytes count.
Add the checking to make sure the attributes list is complete. And it
is used to make sure the response buffer can be accessed safety.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Extends the API for Advertising Coding Selection.
The API is extended to set the Advertising Coding Selection
(Host Support) bit. With this feature, the primary and
secondary PHY can now explicitly report S=2 or S=8 coding
in the extended advertising report. Previously, the report
only indicated LE Coded regardless of whether S=2 or S=8
data coding was used. The API now sets the host support bit
and ensures that the advertising PHY coding scheme is
conveyed to the application via the scan callback.
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>
Add a missing break in supported_context_get, as it was not
intended to fallthrough to BT_AUDIO_DIR_SOURCE or default.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We need to make sure that within Zephyr different users of the PSA APIs
don't interfere with each other because of using the same numerical IDs
for persistent assets.
This takes care of the PSA key IDs when using persistent keys through
the PSA Crypto API.
See the comments in `<zephyr/psa/key_ids.h>` for more information.
This removes the recently-introduced Kconfig options that allowed changing
the base IDs subsystems were using for their persistent keys.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Added new Kconfig option set that allows the user to control the
presence of the following optional characteristics:
- Manufacturer Name String
- Model Number String
Depreacted the old configuration that can be deleted in the future
Zephyr releases.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Change allows performing ECDH operations through system workq. This is
done to allow reducing memory consumption by disabling the long workq on
small SoCs.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Fix to release aux context stored in node rx, and not in the
superior scan or sync context as the one in the superior scan
or sync context could be reset or have a different new aux
context when multiple advertising chain reception is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix assertion due to changes introduced to support multiple
advertising chain reception.
Auxiliary context association with the Periodic Sync context
was not cleared due to which when terminating a Periodic
Synchronization triggered an assertion check, under race
conditions, detecting that the auxiliary context was already
released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The BLE acronym is not an official description of Bluetooth
LE, and the Bluetooth SIG only ever refers to it as Bluetooth
Low Energy or Bluetooth LE, so Zephyr should as well.
This commit does not change any board or vendor specific
documentation, and the term BLE may still be used in those.
It will be up to the vendors to update it if they want,
since many of them are using the term BLE in their
products.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>