Resume from cli->block.number instead of block 0,
so BLOCK_START matches the server's current block.
Blob client does not drop server due to this anymore.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Accept WAITING_FOR_CHUNK phase on resume
when server responds SUCCESS
(server's XFER_START idempotency path).
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Add function to get an instance pointer by index.
This works the same as bt_tbs_client_get_by_ccid except that
it uses the index instead of the CCID.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When calling bt_avrcp_ct_register_notification,
it sets ct->ct_notify[event_id].cb = cb.
In process_register_notification_rsp, it clears the callback
by setting ct->ct_notify[event_id].cb = NULL. However, when
the connection is disconnected, the callback
ct->ct_notify[event_id].cb is not set to NULL , causing
subsequent notification registrations to fail immediately with
an error because the callback pointer is still active.
Similarly, this issue also exists in the AVRCP TG.
Signed-off-by: Lu Jia <jialu@xiaomi.com>
Refactored the Stream End Point (SEP) callback mechanism to use a
unified bt_avdtp_sep_ops structure instead of individual function
pointers. This change consolidates the connected, disconnected, and
media_data_cb callbacks into a single operations structure. The stream
established callback should be called when the stream l2cap is
connected not the open cmd is finished.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
bt_mesh_suspend/resume now only re-enable provisioning bearers that
were previously active.
Adds internal bt_mesh_provisionee_suspend/resume APIs.
bt_mesh_suspend() now return -EBUSY if provisioning is active before any
suspend actions are performed.
Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
When proc_param->is_unicast_to_broadcast == false we should clear
the broadcast_to_unicast.broadcast_source instead of the
unicast_to_broadcast.broadcast_source.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the required_sec_level for struct bt_iso_chan and
all related automatic security machinery built around it
(iso_chan_connect_security, bt_iso_security_changed,
BT_ISO_STATE_ENCRYPT_PENDING and the CONFIG_BT_SMP checks
in iso.c)
Applications can just call bt_conn_set_security() on the
ACL connection before bt_iso_chan_connect() instead.
Fixes#104751
Signed-off-by: Vedant Malkar <vedantitsme@gmail.com>
Modify bt_ccp_call_control_server_get_bearer_provider_name to
store the bearer provider name in an output buffer, instead of just
providing the pointer.
The reason for this is to make the result thread safe, and
avoid the user/application having a direct pointer to
internal storage.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Currently the other of the ACL and CIS disconnect callbacks
depend on the order of the HCI events received. Since this
order is not specified by the core spec, it means that any
users/applications of ISO will need to wait for all CIS
disconnects callbacks and the ACL disconnect callback before
attempting to reuse any of them.
From an API perspective this is not ideal, and the API will
be much simpler if the order of ACL and ISO disconnect
callbacks were deterministic, regardless of the controller.
This change postpones the finalization of the ACL disconnect
until all the CIS associated with it has been disconnected.
This will also make the API more similar to e.g. the L2CAP
disconnect order.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new callback for when the broadcast source has been
created. This callback is useful for the application to
configure the periodic advertising with the BASE of the
broadcast source. Configuring and starting the
periodic advertising with the BASE at that point in time
may optimize how quickly the procedure can be completed.
A callback was chosen, rather than having the stack set
up the data itself, because that the application may
want to add additional data in the periodic advertising,
and thus the owner of the data should be the application,
and not the stack.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix OBEX abort response handling when no active client exists by
tracking the last executing client and its previous opcode.
- Add _last_client pointer to track the most recent executing client
- Add _pre_opcode to store the opcode before clearing _opcode
- Save client state before clearing opcode in all operation handlers
- Implement obex_get_last_client() to recover client context for abort
- Handle abort responses even when _active_client is already cleared
- Clear last client tracking on transport connect/disconnect
This ensures abort responses are properly delivered to the correct
client callback even if the operation has already completed.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add validation to detect and handle zero-length data elements during
SDP attribute parsing. When the parsed data element length is zero,
log a debug message and return early to avoid unnecessary processing.
This check is placed after parsing the data element length but before
the nesting level validation, ensuring that:
- Empty data elements are gracefully handled without errors
- The parser doesn't attempt to process or skip zero bytes of data
- Subsequent attribute parsing continues normally
This prevents potential issues when SDP records contain empty data
elements and improves parser robustness when handling malformed or
edge-case SDP attribute structures.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Move the nesting level check to occur after parsing the data element
length instead of before. This ensures that when the maximum nesting
level is exceeded, the parser can properly skip the nested data by
pulling the correct length from the buffer.
Previously, checking the nesting level before parsing the length meant
the parser would return early without consuming the nested data,
potentially causing parsing errors for subsequent attributes.
The updated logic:
- Parses the data element type and length first
- Checks if maximum nesting level is exceeded
- If exceeded, logs a warning and skips the data element entirely
- Otherwise, proceeds with recursive parsing as normal
This prevents buffer misalignment when deeply nested sequences are
encountered in SDP attribute records.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Fix SDP attribute parsing to properly handle nested sequences within
attribute values. Previously, when an attribute value itself contained
a sequence, the parser would not recursively parse the nested sequence,
potentially missing nested attribute data.
Add recursive parsing logic that:
- Detects if the current value buffer contains a sequence type
- Recursively calls sdp_attr_parse() with incremented nest level
- Properly handles nested sequence structures in SDP records
This ensures complete parsing of complex SDP attribute structures that
contain sequences within sequences, such as protocol descriptor lists
or service class ID lists with nested elements.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Extract common GOEP RFCOMM initialization logic into a separate function
to eliminate code duplication between accept and connect paths.
- Add new goep_rfcomm_init() function containing shared initialization:
* MTU calculation and validation
* Transport operations registration
* RFCOMM DLC configuration
* GOEP state setup
- Update goep_rfcomm_accept() to use the new init function
- Update bt_goep_transport_rfcomm_connect() to use the new init function
This refactoring reduces code duplication and ensures consistent
initialization behavior for both server (accept) and client (connect)
code paths.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Extract common GOEP L2CAP initialization logic into a separate function
to eliminate code duplication between accept and connect paths.
- Add new goep_l2cap_init() function containing shared initialization:
* MTU calculation and validation
* Transport operations registration
* L2CAP channel configuration
* GOEP state setup
- Update goep_l2cap_accept() to use the new init function
- Update bt_goep_transport_l2cap_connect() to use the new init function
This refactoring reduces code duplication and ensures consistent
initialization behavior for both server (accept) and client (connect)
code paths.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
This change ensure that TBS bearers promote dialing -> alerting
independently of GTBS. GTBS no longer blocks the state transitions,
promotion only waits for the bearer's own pending notifications to
clear, preserving notification ordering. GTBS continues to aggregate
the updated state correctly
Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
If we receive a control point notification with an ASE ID that
does not match any existing streams, i.e. audio_stream_by_ep_id
returns NULL, we should not continue by calling the subsequent
functions like unicast_client_notify_ep_config with a NULL stream.
A single notification may contain multiple ASE IDs; if any of them
are unknown, we can either reject the entire notification, or
we can ignore the specific ASE ID. For now, ignore the
specific ASE ID to do a best effort to continue with
any other changes.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove calls to atomic_clear_bit on reads. Even if a characterstic
is read while there is a pending notification, we shall
(as per the MCS spec) still send the notification.
There are 3 special cases for long (string) values, where we
need to know the difference between a changed value (pending
for notification), and a value that has changed since last
read. To support this, these 3 cases now have _DIRTY flags
to indicate that the values are dirty and must be read from
the beginning again.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix nRF54Lx DTM implementation when using GRTC. The Radio
start needs to be offset by a maximum ISR latency value that
is less than inter-frame switching, plus minimum counter
compare offset that can be set, plus minimum CPU latency to
set the counter compare register.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use clock startup time from devicetree.
Relates to commit 72dac165d8 ("Bluetooth: Controller: Use
OVERHEAD_XTAL_US from devicetree").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This file fails to compile since commit ef7b132bfd ("Bluetooth:
Classic: Fix initialization to support re-initialization"), which added
a LOG_ERR() invocation but didn't setup logging for the file.
Fixes#101810
Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Use the ZTESTABLE_STATIC macro to define symbols which need to be
accessible from ztests, instead of redefining STATIC which causes
trouble with some hals.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add support for CS IPT (Channel Sounding Inline PCT Transfer)
in the Bluetooth host stack.
Changes include:
* definition of new CS IPT HCI opcodes;
* handling of CS IPT control procedures;
* integration with existing CS infrastructure;
* necessary updates to public headers.
Signed-off-by: Aleksandr Mirlenko <aleksandr.mirlenko@nordicsemi.no>
Before this we have a memory leak in the prep_pool when reassembly fails
in :c:func:`att_exec_write_rsp`. Now on error the buffer is dequeued and
freed, as are remaining queued prepare buffers.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
Rename it to USB buffers so we can use it in host support without
confusion. Keep the UDC_* macros for now, we can deprecate and remove
them later.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The implementation only used the receive state's PA sync state
to determine whether to call the PA sync req or PA sync term req,
but that state does not include the syncing state.
Rather than using the receive state's PA sync state, we add a local
boolean to keep track of whether the PA sync was requested, so if
we receive a mod_src with PA sync == BT_BAP_BASS_PA_REQ_NO_SYNC then
we request a termination, even if the PA sync was not established yet.
Some cleanup in the mutex handling was also done as part of this.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make sure choice option name is not same as actual config option
that is enabling it. Use _SECURITY suffix for clarity of what
choice is actually about.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
CTS is missing the Local Time Information characteristic and this
commit adds the UUID and the full characteristic to its service.
The peripheral example has been updated as well to use this and
implement it on the example so it is easy to test it out.
Signed-off-by: Martin Moya <moyamartin1@gmail.com>
- Add kconfig for HCI event synchronous buf pool to allow vendors
to configure buffer count based on the application/host platform
requirements
Signed-off-by: Vinit Mehta <vinit.mehta@nxp.com>
Added support for elapsed time service (ETS). The service
is introduced currently with the experimental tag.
Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
The TBS spec only specificially disallows join for calls in
the incoming state. The Alerting and Dialing state in Zephyr
were disallowed, but that fails some TBS join tests.
Removed the (implicit) checks for alerting and dialing and
updated the state changer code to be more explicitly so that
all call states, except for incoming, is explicitly handled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor bt_tbs_set_uri_scheme_list to take a single string instead
of an array of URIs. This should not affect applications much
in any way (and may actually be easier to use), but simplifies
the implementation significantly, and reduces memory footprint.
Additionally it also make the client and server more similar
as bt_tbs_client_read_uri_list just returns it as a single
string as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_pacs_register would assert if e.g.
CONFIG_BT_PAC_SRC_NOTIFIABLE=y but param.src_pac = false.
Add checks for setting the attributes, only if the parameter
actually enables the characteristics.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Avoid dereferencing `stream` in the debug log message when checking
for invalid input parameters.
The previous log printed `stream->ep` and `stream->conn` inside a
combined NULL check, which could trigger static analysis warnings
about a possible NULL pointer dereference.
Align the implementation with the existing pattern used in the file
by logging a generic "Invalid stream" message instead.
No functional change.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
When starting adv via handover, we log the address used
for the advertising set for debugging purposes.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement the validation if there is exactly one GAP service
in GATT database.
The validation is performed as soon as the GATT database
is available and forbids to enable the Bluetooth if the configuration
is not compatible with the Bluetooth Specification.
The verification may be disabled by the user for better performance
or deliberate implementation that is not compliant with the
specification.
Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Set the unused argument of the name characteristic to NULL.
This removes the reference from GAP service to the hci_core.
Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Rename the DEVICE_NAME_GATT_WRITABLE_ kconfig options to
BT_DEVICE_NAME_GATT_WRITABLE_.
Rename DEVICE_APPEARANCE_GATT_WRITABLE_AUTHEN to
BT_DEVICE_APPEARANCE_GATT_WRITABLE_AUTHEN.
The old options are marked as deprecated.
Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Remove Generic Access Service implementation from gatt files and move it
into separate file in services directory.
The default service implementation can be disabled by the user in purpose
of providing the GAP implementation directly in the application.
Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Add check in valid_unicast_audio_start_param to verify
that the ep connection matches the member_conn.
Instead of declaring the endpoints in the unit tests, we
not define them in the mock unicast client and use the
discover function to get pointers.
This allows for a proper implementation of
bt_bap_unicast_client_has_ep as well as makes the tests more similar
to a normal application.
This change required a significant change in the unicast_stop
unit tests as well, which uncovered a small bug in the implementation.
The bug was fixed as part of this commit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There's no use of k_poll in the host stack anymore, so remove leftovers
and related definitions.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The Bluetooth Mesh code depends on k_poll, so it should have the
appropriate select statement in its Kconfig.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Update ll_data_path_tx_pdu_release() to have return -ENOTSUP
so that the node_tx is released using the fallback method to
use the MFIFO from LLL to ULL_HIGH context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>