Commit graph

10,339 commits

Author SHA1 Message Date
Aleksandr Khromykh
9016127872 bluetooth: mesh: fix always resuming from the first block
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>
2026-03-09 11:17:53 -05:00
Aleksandr Khromykh
e7f25460db bluetooth: mesh: fix resuming blob server before it comes suspended state
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>
2026-03-09 11:17:53 -05:00
Emil Gydesen
957175f267 Bluetooth: TBS: Add bt_tbs_client_get_by_index
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>
2026-03-09 11:11:36 -05:00
Lu Jia
f36da9cb7d bluetooth: avrcp: Fix AVRCP notification failure
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>
2026-03-09 14:08:14 +01:00
Mark Wang
48f0e505b3 bluetooth: classic: avdtp: fix the early callback of stream established
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>
2026-03-09 14:04:20 +01:00
Stine Åkredalen
5dfc1b82a4 bluetooth: mesh: Fix bearer suspend/resume state
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>
2026-03-06 09:55:02 +01:00
Emil Gydesen
c97c0366e3 Bluetooth: CAP: Handover: Fix clearing wrong broadcast_source
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>
2026-03-05 16:09:04 +01:00
Vedant Malkar
86ff87ff81 Bluetooth: ISO: remove required_sec_level
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>
2026-03-05 11:15:32 +00:00
Emil Gydesen
f5f9a0e0f3 Bluetooth: CCP: Modify get_bearer_provider_name to use output buffer
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>
2026-03-04 14:34:10 +00:00
Emil Gydesen
d0dae06458 Bluetooth: Host: Make ACL/CIS disconnect order deterministic
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>
2026-03-04 14:30:00 +00:00
Emil Gydesen
0c354b1573 Bluetooth: CAP: Handover: Add broadcast_created callback
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>
2026-03-04 13:35:48 +01:00
Lyle Zhu
d3e7a8300a bluetooth: classic: obex: fix abort response handling for last client
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>
2026-03-03 19:13:18 +00:00
Lyle Zhu
9db318da9a Bluetooth: Classic: SDP: Add zero-length data element check
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>
2026-03-03 17:57:11 +01:00
Lyle Zhu
85bbfef282 Bluetooth: Classic: SDP: Fix nesting level check timing
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>
2026-03-03 17:57:11 +01:00
Lyle Zhu
f9e21462e2 Bluetooth: Classic: SDP: Fix parsing of nested sequences
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>
2026-03-03 17:57:11 +01:00
Lyle Zhu
7f8064f5bc bluetooth: classic: GOEP: refactor RFCOMM initialization
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>
2026-03-03 13:27:25 +01:00
Lyle Zhu
5103438833 bluetooth: classic: GOEP: refactor L2CAP initialization
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>
2026-03-03 13:27:25 +01:00
Alex Ciascai
e575733f4d bluetooth: tbs: fix Dialing -> Alerting transition handling for PTS VRC
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>
2026-03-03 11:17:18 +01:00
Emil Gydesen
f04042714d Bluetooth: BAP: Unicast Client: Handle unexpected ASE IDs
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>
2026-03-03 11:15:45 +01:00
Emil Gydesen
6eb77788af Bluetooth: MCS: Dont discard notifications on read
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>
2026-03-03 11:11:03 +01:00
Vinayak Kariappa Chettimada
53d053359a Bluetooth: Controller: nRF54Lx: Fix DTM when using GRTC
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>
2026-03-02 15:44:30 -08:00
Vinayak Kariappa Chettimada
8f77fc6e08 Bluetooth: Controller: nRF5x: Tune counter compare minimum and latency
Tune counter compare minimum and latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-03-02 15:44:30 -08:00
Vinayak Kariappa Chettimada
5e2e989cdc Bluetooth: Controller: Use clock startup time from devicetree
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>
2026-03-02 15:44:30 -08:00
Thomas Hebb
86b9ebadc6 bluetooth: classic: did: Set up logging
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>
2026-03-02 10:49:56 +01:00
Alberto Escolar Piedras
c77d74fa7d Bluetooth: Classic: Shell: Use ZTESTABLE_STATIC instead of STATIC
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>
2026-02-27 11:50:41 +01:00
Emil Gydesen
49bb9e2034 Bluetooth: ISO: Fix bad sys_get for {c,p}_latency
The fields in the HCI events are 24-bits but were treated
as 16-bit values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-02-26 21:24:34 +00:00
Aleksandr Mirlenko
c26eda3b71 bluetooth: host: add support for CS IPT procedures
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>
2026-02-26 16:53:17 +00:00
Kyra Lengfeld
354e3cb040 Bluetooth Host: Fix memory leak in ATT prep_pool
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>
2026-02-26 12:36:03 +01:00
Shay Gi
fa321c1c2d Bluetooth: Fix typo of supervision
Fixed typos in code of "supervison" to supervision.

Signed-off-by: Shay Gi <s02998491@gmail.com>
2026-02-26 12:32:14 +01:00
Johann Fischer
7158c64690 include: drivers: usb: rename UDC buffer to USB buffer
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>
2026-02-24 16:01:21 -06:00
Emil Gydesen
dd72c4c711 Bluetooth: BAP: SD: Fix issues with pa sync requests
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>
2026-02-24 15:35:54 +01:00
Szymon Janc
7f044f0a00 Bluetooth: GATT: Fix writable appearance Kconfig choice name
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>
2026-02-23 17:00:16 +00:00
Martin Moya
996feaea91 bluetooth: services: cts: Add local time information characteristic
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>
2026-02-23 16:58:13 +00:00
Vinit Mehta
0d387be9b6 bluetooth: host: add kconfig for evt synchronous buffer pool
- 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>
2026-02-23 11:35:42 +00:00
Dipak Shetty
cae71714de bluetooth: services: add Elapsed Time Service support
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>
2026-02-20 13:30:34 +01:00
Emil Gydesen
12c30e526a Bluetooth: TBS: Allow join in alerting/dialing state
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>
2026-02-20 10:11:46 +01:00
Emil Gydesen
dd4a01af48 Bluetooth: TBS: set_uri_scheme_list single string instead of array
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>
2026-02-20 10:10:38 +01:00
Emil Gydesen
796ac63086 Bluetooth: PACS: Add missing checks before assert in register
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>
2026-02-20 10:09:15 +01:00
Gaetan Perrot
951f8d48b0 bluetooth: audio: bap_stream: Fix possible NULL dereference
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>
2026-02-19 10:04:50 -06:00
Emil Gydesen
b438540a09 Bluetooth: CAP: Log ADV address when starting via handover
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>
2026-02-19 10:00:26 -06:00
Radosław Koppel
1fa8739af7 Bluetooth: Host: Conn: Add GAP service validation
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>
2026-02-19 09:58:49 -06:00
Radosław Koppel
9f33889066 Bluetooth: gap_svc_default: Set user_data for name characteristic to NULL
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>
2026-02-19 09:58:49 -06:00
Radosław Koppel
95e9f27939 Bluetooth: gap_svc_default: Update attribute len checking in write_name
Remove offset form the attribute length checking as the offset
is tested before to be 0.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
2026-02-19 09:58:49 -06:00
Radosław Koppel
233495d234 Bluetooth: gap_svc_default: Add BT_ prefix to DEVICE_xxx_GATT_WRITABLE_
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>
2026-02-19 09:58:49 -06:00
Radosław Koppel
e5258ed86d Bluetooth: Host: Extract GAP service from GATT
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>
2026-02-19 09:58:49 -06:00
Emil Gydesen
f4492d04e0 Bluetooth: CAP: Add missing NULL checks in acceptor_register
Add missing NULL check for `param` and `svc_inst`

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-02-19 12:51:41 +01:00
Emil Gydesen
309b5b3c01 Bluetooth: CAP: Add ep conn check in unicast audio start
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>
2026-02-17 10:31:09 +01:00
Johan Hedberg
dd37a250b1 Bluetooth: Host: Remove leftover k_poll related code
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>
2026-02-16 09:03:09 -06:00
Johan Hedberg
39a428c5d9 Bluetooth: Mesh: Add missing select for POLL
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>
2026-02-16 09:03:09 -06:00
Vinayak Kariappa Chettimada
c4a4937d9f Bluetooth: Controller: Update ll_data_path_tx_pdu_release()
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>
2026-02-16 11:08:16 +01:00