bt_bap_unicast_group_reconfig did not properly set the fields
related to CONFIG_BT_ISO_TEST_PARAMS nor packing.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the CIG parameters of the unicast group (SDU intervals, transport
latencies, framing, packing and, when CONFIG_BT_ISO_TEST_PARAMS is
enabled, the flush timeouts and the ISO interval) as well as the
has_been_connected state to struct bt_bap_unicast_group_info, so that
applications can retrieve all relevant information about a group.
The framing is stored internally using the ISO values, and is converted
back to the BAP QoS configuration values when reported.
The existing bsim tests for bt_bap_unicast_group_get_info have been
expanded to verify the new values, including for a group with
asymmetric parameters and for a reconfigured group.
Assisted-by: Copilot coding agent
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The ep->unicast_group was never assigned and thus
has_been_connected was never set for the BAP unicast groups.
Change to use the stream->group instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
CONFIG_BT_FIXED_PASSKEY, bt_passkey_set() and BT_PASSKEY_INVALID were
deprecated in commit 82cfb5a056 ("Bluetooth: Host: Deprecate
BT_FIXED_PASSKEY"), released in Zephyr 4.3, in favour of the app_passkey
callback gated on CONFIG_BT_APP_PASSKEY. Two releases have passed, so
remove them.
The replacement covers what the option did: an application that returns a
constant from bt_conn_auth_cb.app_passkey gets a fixed passkey, and one
that returns BT_PASSKEY_RAND gets a Host generated one, which is what
BT_PASSKEY_INVALID was used to fall back to.
DISPLAY_FIXED() could only ever be true with a fixed passkey configured,
so the four conditions using it reduce to the JUST_WORKS test they were
already OR'd with. Likewise the two branches in get_io_capa() that
upgraded the reported capability when a fixed passkey was set collapse to
the values they already returned otherwise; the CONFIG_BT_APP_PASSKEY
block above them covers that case for the replacement API. Behaviour is
therefore unchanged for anyone not enabling the removed option.
Drop the accompanying build warning and the hardened.csv entry, both of
which existed only to steer users away from the option.
Fixes: #36005
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Assisted-by: Claude:claude-opus-5
The playback_speed_param value was not used to correct
adjust the position while in the playing or state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The UART monitor backend sends every byte with uart_poll_out(). At
common UART rates this blocks the Bluetooth host while HCI traffic
and logs are serialized.
Add an opt-in interrupt-driven mode that buffers complete monitor
records and drains them from the UART interrupt handler. Record
fragments are copied in with ring_buf_put_ptr() and published with a
single ring_buf_commit(), so a record is either fully present in the
buffer or absent. This matters on panic: the panic handler flushes
only complete records before switching to polling, keeping the
stream parseable. Only the header-inline zero-copy ring buffer API
is used, so the option does not need to select RING_BUFFER.
A record that does not fit is dropped whole and reported through the
existing drop counters. Counts already consumed into a dropped
record's header are restored, keeping the accounting exact across
consecutive drops, and counts exceeding the 8-bit header field carry
over to the next record. Both kinds of loss previously also affected
the RTT backend, which shares this code.
Polling output remains the default and the panic-mode fallback,
since interrupts may no longer run during panic handling. It is also
the runtime fallback when the monitor UART driver lacks interrupt
support, since SERIAL_SUPPORT_INTERRUPT only guarantees that some
driver has it. The option depends on !LOG_MODE_MINIMAL because
minimal logging has no panic hook to flush buffered output.
Measured on nrf52dk/nrf52832 and xg24_rb4186c with a peripheral
flooding GATT notifications and the monitor sharing the 115200 baud
console UART: polling caps throughput at 5.9-6.6 KB/s, slows a paced
25 notifications/s workload to 15/s and blocks the producing context
~6 ms per large record (10-line printk burst: 58-65 ms). The
interrupt-driven mode restores radio-limited throughput (41 KB/s)
and the nominal paced rate, with the same burst at 0.8-1.3 ms. The
trade-off is load shedding: under sustained overload ~87% of
full-size ACL records are dropped (and accounted), while small
records such as Number of Completed Packets events keep flowing.
Unit tests cover contiguous and wrapped records, failed
reservations, zero-length fragments and exact-fit records; an
integration test runs the real producer/ISR path against the
emulated serial-test UART, covering drain, buffer-full drops with
accounting, and wrap-around consistency. The Bluetooth init test
builds the interrupt-driven path with the deferred log backend,
since tests default to minimal logging. Builds also pass with
polling UART and RTT.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The L2CAP server is now registered when the upper layer registers AVDTP
callback, which is a more appropriate time since AVDTP cannot function
when the upper layer doesn't register callback to enable the AVDTP
function.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
The AVDTP event handlers are now registered when the application
registers its A2DP callback, which is a more appropriate time since
A2DP cannot function when the application doesn't register a callback
to enable the A2DP functionality.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Remove CONFIG_BT_MESH_BLOB_IO_FLASH_WITH_ERASE and
CONFIG_BT_MESH_BLOB_IO_FLASH_WITHOUT_ERASE. There is no replacement: the
BLOB IO Flash module stopped reading them in Zephyr 4.3 and instead
queries the erase capability at runtime through
flash_params_get_erase_cap(), so both options have been no-ops since
then. The enclosing "if BT_MESH_BLOB_IO_FLASH" block is kept for
BT_MESH_BLOB_IO_FLASH_WRITE_BLOCK_SIZE_MAX.
Deprecated in Zephyr 4.3.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Remove the CONFIG_BT_CTRL_ADV_ADI_IN_SCAN_RSP compatibility symbol,
which only selected the renamed CONFIG_BT_CTLR_ADV_ADI_IN_SCAN_RSP. The
CTLR-spelled option and its users in ull_adv_aux.c are untouched.
Deprecated in Zephyr 4.3.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Remove the CONFIG_BT_CONN_TX_MAX Kconfig option and its only in-tree
user, the SiWx91x SoC configdefault. No C code has read the symbol since
it was deprecated, so it had no effect on any build; the number of
pending TX buffers with a callback follows CONFIG_BT_BUF_ACL_TX_COUNT,
which was already both the default and the range floor of the removed
option. The SiWx91x default of 15 matched that SoC's
BT_BUF_ACL_TX_COUNT default, so behaviour is unchanged there too.
Deprecated in Zephyr 4.2.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Remove the CONFIG_BT_DIS_MANUF and CONFIG_BT_DIS_MODEL string options,
together with the BT_DIS_MANUF_DEPRECATED_USED and
BT_DIS_MODEL_DEPRECATED_USED helper symbols whose only purpose was to
detect their use. Use CONFIG_BT_DIS_MANUF_NAME /
CONFIG_BT_DIS_MANUF_NAME_STR and CONFIG_BT_DIS_MODEL_NUMBER /
CONFIG_BT_DIS_MODEL_NUMBER_STR instead.
With the helper symbols gone, the two characteristic bools no longer
need their "depends on !*_DEPRECATED_USED" guards and are
unconditionally default y again, and the #if/#elif ladders in dis.c
collapse to the non-deprecated branch.
Deprecated in Zephyr 4.1.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
This fixes a leak for the following scenario:
A bonded peer connects via undirected adv set while directed connectable
extended advertisement runs on the same identity.
The enhanced connection complete is cached, not yet processed and the
undirected set is terminated, which clears the `BT_ADV_ENABLED` flag.
During processing of the cached enhanced connection complete event, the
`find_pending_connect()` function then finds the directed set instead of
the undirected set (as until now there was no distinction of the
advertising set type in the lookup function). This leads to a
reservation leak, as the directed set is not terminated (but the
`BT_ADV_ENABLED` flag is cleared).
This commits adds the advertising set context to the
`bt_hci_le_enh_conn_complete()` and `find_pending_connect()` functions,
so that the correct advertising set is used for the lookup.
Note: This change has been locally tested with a test case created by AI
that reproduces the above scenario.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
oacp_command_decode() accepted the op code unconditionally while
oacp_proc_validate() handles it under a Kconfig guard. Both answer Op
Code Not Supported, so guard the decode arm to match, the way Create,
Delete and Write already are.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
oacp_ind_send() appended the Checksum Value based on the requested op
code alone, but validation only fills the response buffer on success.
Every error path therefore pulled four bytes from an empty buffer,
panicking with assertions enabled and reading stale stack without them.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
CONFIG_BT_AUTO_PHY_UPDATE was deprecated in Zephyr 4.3 in favour of the
role-specific BT_AUTO_PHY_CENTRAL and BT_AUTO_PHY_PERIPHERAL Kconfig
choices, which also allow picking which PHY is preferred. Remove it as
part of the 4.5 deprecation removal cycle.
All C code and all in-tree samples and tests were already migrated to
the role-specific options when the deprecation was introduced, so only
the remaining Kconfig references need dropping. Since the deprecated
symbol lost its "default y if !BT_USER_PHY_UPDATE" in 4.3, it has been
unset in every in-tree configuration ever since, which makes each of
these references dead code today:
- The BT_AUTO_PHY_PERIPHERAL choice loses its "default
BT_AUTO_PHY_PERIPHERAL_2M if BT_AUTO_PHY_UPDATE" entry and keeps
falling through to _NONE, as it already did.
- BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM loses the always-false
"BT_AUTO_PHY_UPDATE=y" disjunct of its "default 6" condition, which
now reads exactly as it already evaluated: BT_AUTO_DATA_LEN_UPDATE=y
&& BT_CTLR_LLCP_CONN < 4.
- The STM32WB0 SoC defconfig set BT_AUTO_PHY_UPDATE=n, which had no
effect on either role, and is simply dropped.
This keeps the change behaviour-neutral. Two pre-existing quirks are
deliberately left alone rather than fixed here, since they are policy
changes for their respective maintainers and not part of removing a
deprecated symbol: the local procedure context count no longer reaches
6 via automatic PHY update, and the STM32WB0 series follows the
BT_AUTO_PHY_CENTRAL default of _2M for central-role connections.
The BT_BUF_CMD_TX_COUNT help text is updated to name the replacement
choices.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Instead of assigning the individual callbacks at read time,
they are now all assigned at once. The main reason for this
is to be able to handle notifications that come, that use the
same callbacks, before any reads have been done. Notifications
would otherwise have been missed, if the application did not
perform a read first.
The CONN_CB functions were just moved to avoid needing function
prototypes.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for getting the remote bearer tech.
Also slightly modified the test of the CCP samples
to properly catch issues (e.g. we disconnect on error,
and now we check for disconnect as the samples may reconnect
and thus have false positives).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_avdtp_connect() and bt_avdtp_l2cap_accept() store the connection
pointer in the session, and only then initialize session->sem_lock.
The connection pointer is what makes the session visible to other
contexts, and the upper layer clears the whole session structure when
it is reused, so between the two the session can be reached with a
zero-initialized semaphore.
Initialize the semaphore before the session is published, while the
global lock is still held.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_avdtp_register_sep() calls bt_avdtp_set_state_lock() while holding
the global avdtp_sem_lock, i.e. it takes avdtp_sem_lock and then
sep->sem_lock. The command handlers use the opposite order: they run
with sep->sem_lock held and take avdtp_sem_lock when queuing the
response for transmission (avdtp_send_rsp() -> avdtp_send_common()).
Registering an endpoint while signalling is in progress can therefore
deadlock.
The endpoint has not been added to the `seps` list at that point, so no
other context can reach it. Set the state without taking sep->sem_lock.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The BIP transport disconnected callbacks for the Cover Art Target and
Controller unreference tg->conn and ct->conn without clearing the
pointers. The API functions in this file rely on a conn == NULL check
to detect that the Cover Art channel is not connected, so after a
transport disconnect these checks pass with a dangling pointer. Since
connection objects are recycled, the stale pointer may also end up
aliasing an unrelated live connection.
Use bt_conn_drop(), which unreferences the connection and clears the
pointer, keeping the not-connected checks in the API functions sound.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace manual for loops iterating over fixed-size arrays with the
ARRAY_FOR_EACH macro for consistency with the rest of the codebase.
The following loops are converted:
- mce_mas_select(): iterate mce_mas_instances[index]
- mse_mas_select(): iterate mse_mas_instances[index]
- mse_mns_find(): iterate mse_mns_instances
Signed-off-by: Can Wang <can.wang@nxp.com>
The GetMessage operation was missing required application parameters
in its validation macro. According to the MAP specification, the
Attachment and Charset parameters are mandatory for GetMessage
requests.
Add BT_MAP_APPL_PARAM_TAG_ID_ATTACHMENT and
BT_MAP_APPL_PARAM_TAG_ID_CHARSET to GET_MSG_REQUIRED_AP to ensure
these parameters are validated by has_required_app_params().
Signed-off-by: Can Wang <can.wang@nxp.com>
The MCE MAS connect commands could allow multiple connections to the
same MAS instance ID to be established, leading to resource conflicts.
Fix this by checking if a connection to the requested instance ID
already exists before allocating a new MCE MAS instance in both
bt_map_mce_mas_rfcomm_connect() and bt_map_mce_mas_l2cap_connect()
shell commands.
The MSE MAS accept callbacks could allow multiple connections of the
same transport type (RFCOMM or L2CAP) to be established for a single
MAS instance.
Fix this by validating both the PSM and RFCOMM channel in the accept
callbacks and rejecting duplicate connection attempts.
Signed-off-by: Can Wang <can.wang@nxp.com>
For client roles (MCE MAS and MSE MNS), remove the dedicated
*_cb_register() functions and pass the callback pointer directly
to rfcomm_connect() / l2cap_connect() calls, matching the pattern
used by the PBAP and BIP client APIs.
For server roles (MCE MNS and MSE MAS), rename *_cb_register() to
*_register(). The new function both stores the callback table and
registers the instance with the underlying OBEX server. The
accept() callbacks no longer register callbacks per-connection;
callers must invoke *_register() once before registering the
transport server.
Add shell commands `map mce mns register` and `map mse mas
register`, and update the shell documentation accordingly.
Signed-off-by: Can Wang <can.wang@nxp.com>
Add checks for `BT_DEV_READY` flag in Bluetooth Classic (BR/EDR) API
functions to prevent operations before the Bluetooth stack is fully
initialized.
The following functions now return `-EAGAIN` if called before the stack
is ready, including functions `bt_br_discovery_start()`,
`bt_br_set_connectable()`, `bt_br_set_discoverable()`, and
`bt_br_write_eir()`.
For the function `bt_conn_create_br()`, it returns `NULL` if the stack
is not ready.
The changes prevent potential issues from attempting BR/EDR operations
before the controller and host are properly initialized.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
When the Distributor updates itself, the Firmware Update Server defers
its apply callback until the distribution reaches the Confirm step. The
callback may reboot the device, or call bt_mesh_dfu_srv_applied() and
return. An application that installs the image asynchronously and calls
bt_mesh_dfu_srv_applied() later left the distribution stuck: by then
dfu_confirmed() had returned with the Distribution Phase at Applying
Update, and nothing re-entered it.
Notify a co-located Firmware Distribution Server from
bt_mesh_dfu_srv_applied() so a deferred apply can complete the
distribution without a reboot. dfu_confirmed() skips its own transition
when the notification already completed the distribution, so an apply
that finishes inside the callback still reports Completed once.
Assisted-by: Claude:claude-opus-4.7
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Add a .start model callback to the DFD Server that resumes the
self-update confirm step after reboot. When the DFD Server wakes
up in APPLYING_UPDATE phase (restored from settings), the start
callback:
1. Finds the co-located DFU Server; if it is still in APPLYING
phase, calls bt_mesh_dfu_srv_applied() to transition it to
IDLE so it responds to Firmware Update Information Get with
the new FWID.
2. Calls bt_mesh_dfu_cli_confirm() to resume polling targets
for their updated firmware image.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
When the Distributor is also a DFU target of its own distribution
(self-update), applying the firmware immediately upon receiving the
Update Apply message would reboot the device before it can complete
the confirm step for other targets.
Defer the apply callback on the DFU Server when the Update Start
originated from a local address (self-update detected via
bt_mesh_has_addr). The DFD Server triggers the deferred apply after
the distribution reaches a terminal state (completed or failed).
In the DFU Client confirmed() callback, treat the self-target as
successful even though it hasn't ACKed the Firmware Update Check
message yet — it can't respond because apply was deferred.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The persistence refactoring introduced store_state() calls for the
APPLYING phase, but the error paths in apply_rsp_sent() incorrectly
store state instead of erasing it when transitioning to IDLE:
- When apply prerequisites are missing (no callback or invalid idx),
the phase resets to IDLE but store_state() persists an IDLE phase
that will be rejected on restore. Use erase_state() instead.
- When the application apply callback fails, same issue.
- When handle_cancel() resets the phase to IDLE, the previously
persisted APPLYING state is not erased, causing stale state to
survive across reboots.
Replace store_state() with erase_state() on all paths that transition
to IDLE, and add erase_state() in handle_cancel().
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Introduce a __packed struct dfu_srv_persistent_state for storing
the DFU Server update state to flash, instead of persisting the
runtime srv->update substruct directly. The store and restore
functions now explicitly marshal/unmarshal each field.
This decouples the on-flash binary layout from the runtime struct,
making it safe to extend or reorder the runtime struct in the future
without breaking previously stored data. The approach matches the
pattern already used by the DFD Server persistence.
The new packed struct is binary-compatible with the existing runtime
layout, so no settings migration is needed.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Add bt_mesh_dfu_cli_restore() to put the DFU client into the applied
state with a valid inputs pointer after reboot. Called from
dfd_srv_settings_set() when recovering the Applying Update phase.
This allows bt_mesh_dfu_cli_confirm() to succeed post-reboot, which
is required for the confirm step to poll targets and complete the
distribution.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Persist distribution parameters and target list in the DFD Server
when entering the Applying Update phase. Erase persisted state at
terminal phases (Idle, Completed, Failed) to prevent re-triggering
after subsequent reboots. This is the only phase that needs recovery
after reboot for self-update resume.
The slot pointer is resolved in dfd_srv_start() because the slot
settings subtree may load after model settings during initialization.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
MshDFUv1.0 Section 6.1.3.6 requires the Firmware Update Server to
respond to a Firmware Update Apply message with status Success and
phase Applying Update when its Update Phase state is Verification
Succeeded or Applying Update (idempotency). The response phase is
always Applying Update in the SUCCESS case.
Section 7.1.2.6 defines the removal rules for the Apply Firmware On
Target Nodes procedure: a Target whose Firmware Update Additional
Information state is not 0x03 (i.e. stays provisioned) that responds
with the Update Phase field set to Applying Update is kept in the
Active Update Receivers state, meaning the Apply step completed
successfully for that Target. The subsequent Refresh Target Nodes
Status procedure (Section 7.1.2.8) is responsible for verifying that
the Target eventually reaches phase Idle.
On the client side, ack any target that answers SUCCESS + APPLYING
during STATE_APPLY, not only the self-target. Previously the response
was dropped without acking the broadcast, so the broadcast retried
Update Apply until timeout and then failed the target with
BT_MESH_DFU_ERR_INTERNAL, wasting ~10 s before the Confirm step could
start. Retrying is also pointless because the Update Apply message is
idempotent (Section 6.1.3.6): further retries cannot change the SUCCESS
+ APPLYING response.
On the server side, split the Firmware Update Status send callback
handling by error type. A start-of-send error (buffer alloc, cancel,
...) means no segments were transmitted; revert the phase to
Verification Succeeded so a client retry is accepted as a fresh apply
per Section 6.1.3.6 "Apply firmware". An end-of-send -ETIMEDOUT means
segments were transmitted but no segment ack was received; a
spec-compliant client that received any complete copy of the SUCCESS
+ APPLYING response has treated it as terminal for the Apply step and
will not retry Update Apply, so proceed with the apply so our state
matches what the client believes. Any other end-of-send error still
reverts the phase. If the client did miss the response and does retry,
the retry hits handle_apply's idempotent APPLYING-phase branch.
Update test_cli_stop's APPLYING case to match: it now expects
BT_MESH_DFU_SUCCESS + PHASE_APPLYING instead of the obsolete
INTERNAL failure outcome.
Assisted-by: Claude:claude-opus-4.7
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
hci_num_completed_packets() appends the TX contexts to conn->tx_complete
without any locking, while tx_notify_process() pops them with interrupts
locked. The list is therefore only safe as long as the producer cannot
be preempted by the consumer, which is not something the list itself
guarantees.
Append with the same lock the consumer uses.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The startup banner made it hard to tell which controller an image is
running against. The line was labelled "Firmware", the fw_variant 0x00
string was the generic "Standard Bluetooth controller", and the only
manufacturer shown was the one on the "HCI: version" line, which is the
Bluetooth company identifier of whoever wrote the controller and reads as
if it identified the stack.
Label the line "Controller" and include the manufacturer on it. Print
"Zephyr Bluetooth Controller" when the controller reports the standard
variant together with The Linux Foundation company identifier, which is
what the Zephyr controller responds with. The meaning of the fw_variant
values is unchanged, since 0x00 is also reported by other conforming
controllers, both in-tree (ESP32) and out of tree. Rename the fw_variant
0x01 string to "Vendor specific Bluetooth Controller" and update the
sample output in the shell documentation to match.
Fixes: #80679
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-fable-5
The SDP client allocates the receive buffer from the application
provided pool with K_FOREVER, in sdp_client_discover() while holding
the session lock, and in the L2CAP alloc_buf callback which
sdp_client_connected() also calls with the lock held.
Both run in the Bluetooth workqueue, which is the same context that
releases these buffers once a discovery completes, so waiting for a
buffer there cannot make progress. It also blocks any other user of the
session for as long as the pool stays empty.
Allocate without waiting. Both call sites already handle the allocation
failure by disconnecting the SDP channel, and the L2CAP layer handles
alloc_buf() returning NULL, so the assert on the returned buffer is
dropped.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
num_phys was used to size the command buffer, and became dead when
commit 2ea9605380 ("Bluetooth: Host: core: Use bt_hci_cmd_alloc()")
made the buffer be allocated without a length.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Same as the previous commit, for the remaining variables in conn.c and
l2cap.c that are only ever read by an __ASSERT().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
These variables exist only to be checked by __ASSERT_NO_MSG(), which
compiles out when CONFIG_ASSERT is disabled, leaving them set but never
read. GCC builds do not show this since Zephyr passes
-Wno-unused-but-set-variable, but clang and arcmwdt enable the warning
at warning level 1.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_smp_le_oob_generate_sc_data() returns directly when k_condvar_wait()
times out, without unlocking pub_key_gen.lock. k_condvar_wait()
re-acquires the mutex before returning, on timeout as well as on
signal, so the mutex is left locked forever.
Any subsequent public key generation callback then blocks whichever
context runs it indefinitely, since pub_key_ready_notify() takes the
same mutex with K_FOREVER.
Unlock the mutex before returning on the timeout path.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
When a bonded device reconnects and the receive state has changed
while the bonded device was offline, then per the BASS specification
the Scan Delegator shall send a notification with the receive state.
Previous implementation did this too by simply sending the notification
for all receive states regardless of whether the reconnected device
was bonded or not.
Some minor changes to prevent race conditions were also done.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
BAP_UNICAST_CLIENT_ASE counts are per connection, and not reflect
the actual number of streams that may exist in a group. Changed to
use CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT * @ which does
reflect that exactly. The reason why it needs to be multiplied by 2,
is that CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT refers to the
number of CIS, and we may have twice as many BAP streams (as they
unidirection, and CIS may be bidirectional).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ATT Write commands from change unware client shall be ignored.
Previously ATT request opcode was used for request but 0 for command
when passed to att_write_rsp() which was not updated when refactored
to perform_write() which expects ATT opcode for all operations.
Also rename req to op in struct write_data to better describe what
is being keep there now.
This was affecting GATT/SR/GAS/BV-05-C qualification test case.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The CAP unicast audio start and stop procedures consist of several
subprocedures, and applications may need to know when each of these have
completed, e.g. to reconfigure the unicast group after the streams have
been codec configured but before they are QoS configured.
Add new callbacks to bt_cap_initiator_cb for each subprocedure of the
unicast audio start and unicast audio stop procedures. The callbacks are
only called if at least one request was sent to a CAP acceptor as part of
the subprocedure, so that subprocedures that are skipped because all
streams are already in the requested state do not trigger a callback. To
support this a new subproc_initiated field has been added to the common
procedure struct, which is reset whenever a new subprocedure is set.
The unit tests have been extended to verify both that the callbacks are
called when the subprocedures are performed, and that they are not called
when the subprocedures are skipped, and the BSIM CAP initiator unicast
test now waits for the new callbacks as part of the start and stop
procedures.
Assisted-by: Copilot:claude-opus-4.5
Co-authored-by: Thalley <2520413+Thalley@users.noreply.github.com>
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Starting from QoS was not properly tested in the unit tests, and
thus did not catch a bug in the actual procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new shell command `spp rls` to allow testing of the RFCOMM Remote
Line Status (RLS) functionality through the SPP shell interface.
The command accepts optional error type parameters (overrun, parity, or
framing) to simulate serial port errors. When no parameter is provided,
it sends a no-error status.
The implementation uses the newly added `bt_rfcomm_send_rls_cmd()` API
to send RLS commands on the active SPP connection.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>