Commit graph

22128 commits

Author SHA1 Message Date
Make Shi
240ad5cedc bluetooth: avrcp: Add support for AVRCP browsing
- AVRCP SDP record updates for browsing channel
- L2CAP setup for AVCTP browsing channel, and add connect/disconnect
- Add SetBrowsedPlayer browsing command handling

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-08-26 09:32:21 +02:00
Make Shi
b923bde676 bluetooth: avrcp: provide an API for net buffer allocation
Add bt_avrcp_create_pdu() to allocate net_buf with protocol headroom.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-08-26 09:32:21 +02:00
Make Shi
895ba04b32 Bluetooth: AVCTP: Refactors the AVCTP to support multiple L2CAP PSMs
- This patch refactors the AVCTP layer to support multiple L2CAP PSMs
- Introduced bt_avctp_server structure for dynamic L2CAP server
  registration and new server register apis
- Added k_sem protected server list to support multiple AVCTP servers

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-08-26 09:32:21 +02:00
Emil Gydesen
62c8ca3498 Bluetooth: CAP: Shell: Print generated broadcast ID
Since the broadcast ID is generated at runtime, it is nice
to get it printed so that it can be shared.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 17:49:55 +02:00
Emil Gydesen
bfaa1169e8 Bluetooth: BAP: Shell: Print generated broadcast ID
Since the broadcast ID is generated at runtime, it is nice
to get it printed so that it can be shared.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 17:49:55 +02:00
Emil Gydesen
7ec51764d0 Bluetooth: BAP: Shell: Print broadcast ID and broadcast name when scanning
When scanning, the broadcast_scan_recv now prints the broadcast ID
and the broadcast name (if found). Without this, it is not possible
to use the shell to scan for an unknown broadcast ID or broadcast
name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 17:49:55 +02:00
Jonas Spinner
da75828459 net: gptp: fix clock accuracy description
Previously, the Kconfig option `NET_GPTP_CLOCK_ACCURACY_2_5MS` had a
incorrect description "1.5ms".

Signed-off-by: Jonas Spinner <jonas.spinner@burkert.com>
2025-08-25 17:49:39 +02:00
Mark Wang
3544546356 bluetooth: a2dp: implement the get_all_capabilities
From avdtp spec, the get_all_capablities should be used if the avdtp
version is v1.3, otherwise the get_capabilities should be used.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-08-25 13:31:55 +02:00
Mark Wang
d8f35a5baa bluetooth: sdp: add avdtp protocol
get the avdtp version through the bt_sdp_get_proto_param

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-08-25 13:31:55 +02:00
Emil Gydesen
c9e1725665 Bluetooth: GATT: ASSERT instead of LOG_DBG for write length check
In bt_gatt_write_without_response_cb there is a check for
write != length. However since the call to bt_att_create_pdu
should ensure that this is possible, this should never happen.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 11:39:42 +02:00
Emil Gydesen
04a15510a9 Bluetooth: ASCS: Use LOG_DBG when failing to alloc buffer for notification
Since there is a retry mechanism implement, this is not something
that the user needs to be warned about.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 11:39:42 +02:00
Emil Gydesen
d3ffdf4b24 Bluetooth: GATT: Modify some LOG_WRN/ERR to LOG_DBG
When an API function returns an appropriate error code,
LOG_DBG is better suited than LOG_WRN or LOG_ERR as the
caller can handle the return value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 11:39:42 +02:00
Emil Gydesen
ace3a60137 Bluetooth: ATT: Change LOG_ERR to DBG when failing to allocate buffer
For user-initiated requests like notifications, read and write
requests, there will be an error code, so there does not need to be
a generic LOG_ERR if these fail to be allocated.

However if the response or (indication) confirmation PDUs fail
to be allocated, these should still be logged as errors.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 11:39:42 +02:00
Emil Gydesen
00d4ab1c9c Bluetooth: Conn: LOG_DBG for buffer alloc fail
Use LOG_DBG rather than LOG_WRN, as that is an expected
scenario when using K_NO_WAIT (e.g. when sending
GATT notifications), and it is better for higher layers
to determine if this is indeed an error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-25 11:39:42 +02:00
Pavel Vasilyev
d59af08b19 bluetooth: host: gatt: Compile out att cmds for long write proc
`bt_att_recv`, which parses ATT PDUs, already contains code that
responds with `BT_ATT_ERR_NOT_SUPPORTED` if a given handler is not
implemented.

Therefore, `att_prepare_write_req` and `att_exec_write_req` handlers do
not need to explicitly return `BT_ATT_ERR_NOT_SUPPORTED` when
`CONFIG_BT_ATT_PREPARE_COUNT` is set to 0 and can be completely removed.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-25 09:13:22 +02:00
Tom Burdick
9c27d72922 rtio: Add a context pool
Adds a context pool that can be used when a number of threads may be
dynamically created to use with RTIO. While the pool has a small cost to
it, the cost of verifying a statically declared kobject likely makes it
worth avoiding dynamically allocating these with the typical
kobject_alloc method. Instead this arena style pool of objects can be
used where the kobject validation uses the gperf hash created at build
time.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-08-22 16:45:53 +02:00
Pavel Vasilyev
50928fc517 bluetooth: host: remove bt_ prefix from internal functions
Remove the bt_ prefix from internal functions to avoid confusion when
reading code.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-22 14:50:38 +02:00
Pavel Vasilyev
dfe05dd0d7 bluetooth: host: prefix API functions with bt_
Prefix API functions of a module with bt_ to avoid confusion when
reading code.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-22 14:50:38 +02:00
Pavel Vasilyev
c21e613fa9 bluetooth: host: mark internal functions and variables as static
Mark functions and variables as static when not used outside a unit.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-22 14:50:38 +02:00
Jun Lin
b30d2ac07c ec_host_cmd: shi: npcx: change log level for some error messages
It was observed in a project that when an error transaction occurs,
printing the error message can delay resetting the SHI state machine and
initializing the output buffer, which may cause the subsequent
transaction to fail, especially during stress tests involving heavy host
command communication.
This commit changes some error log level from ERR to DBG to prevent the
condition above from happening.
Also change the default debug level for the SHI driver to LOG_LEVEL_ERR.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2025-08-22 12:37:17 +02:00
Lyle Zhu
de0b53578a Bluetooth: SDP: Fix ssa discovery issue caused by setting range
If the range of the service search attribute request is set and the
start of the range is not 0x0000, the response data of the request is
not valid. It is caused by the data element sequence has not be added
to response data. The client cannot parse the response data properly.

The root cause of this issue is that the total length of service
record will be added only when adding the first attribute of service
record.

Fix the issue by reset the `state.last_att` and `state.last_att_index`
if the index of current record is not same with `state.current_svc`.

And do not update `state.last_att`, `state.last_att_index`, and
`state.current_svc` in the function `select_attrs()`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-22 12:36:09 +02:00
Lyle Zhu
bb159e9d08 Bluetooth: SDP: Fix issue that RX buf is used for others discovery
In current implementation, the received buffer is incorrectly used for
other SDP discover requests.

Release the RX buffer when the SDP discovery is done. And allocate the
new RX buffer from the pool of the new SDP discovery request.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-22 12:36:01 +02:00
Robert Lubos
faa507ef6c net: Fix misc Kconfig style issues in networking area
Fix misc Kconfig style issues in networking area.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-08-21 20:12:48 +02:00
Peter Mitsis
fedbe50b20 portability: cmsis: Base Event Flags on k_event
Updates the implementation of the osEventFlags APIs to use
Zephyr kernel events instead of polling.

Fixes #92899

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2025-08-21 20:11:57 +02:00
Vinayak Kariappa Chettimada
4ec8980022 Bluetooth: Controller: Fix BT_CTLR_ADV_ADI_IN_SCAN_RSP
Fix to rename BT_CTRL_ADV_ADI_IN_SCAN_RSP to
BT_CTLR_ADV_ADI_IN_SCAN_RSP.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 17:13:30 +02:00
Ayman Elfayoumi
48689343dc Bluetooth: Simplify le_adv_update() function
Closes #94549
Removed vestigial d and d_len variables from le_adv_update()
and replaced them with a single bt_ad wrapper. This simplifies
the function while maintaining identical functionality.

Signed-off-by: Ayman Elfayoumi <aelfayoumi2@gmail.com>
2025-08-21 17:05:51 +02:00
Pavel Vasilyev
bcdd74d815 bluetooth: host: gatt: destroy key after hash calc completes
To generate the GATT Database Hash characteristic, the function
`db_hash_setup` is called. It allocates an entry for the AES key that will
be used in the CMAC calculation. Next, `db_hash_update` is called to feed
all GATT database entries into the hash. Finally, `db_hash_finish`
produces the resulting hash.

However, the AES key entry allocated in `db_hash_setup` was not being
destroyed after the hash generation completed. This caused a memory
leak, eventually leading to the error `PSA_ERROR_INSUFFICIENT_MEMORY`
(`-134`).

This commit fixes the issue by destroying the allocated AES key after
the GATT Database Hash calculation is complete, by calling
`psa_destroy_key` in `db_hash_finish`.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-21 15:46:48 +02:00
Vinayak Kariappa Chettimada
7f0ba00095 Bluetooth: Move BT_BUF_EVT_DISCARDABLE_ to Host Kconfig
Move BT_BUF_EVT_DISCARDABLE_ to Host Kconfig, as this is
not used by the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 13:07:20 +02:00
Vinayak Kariappa Chettimada
41505da49a Bluetooth: Missing Kconfig depends for BT_BUF_EVT_DISCARDABLE_
Missing depends on !BT_HCI_RAW for HCI Discardable Events
count and size.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 13:07:20 +02:00
Vinayak Kariappa Chettimada
3a8738179a Bluetooth: Controller: Fix assertion on BIG terminate sync
Fix assertion on BIG terminate sync and due to not receiving
terminate control procedure when there are no free buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 13:07:20 +02:00
Emil Gydesen
8b6162aec3 Bluetooth: GMAP: Add requirement for Broadcast assitant for BGS
As per GMAP 1.0.1, the BGS role now requires support for the
BAP Broadcast Assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-21 11:10:23 +02:00
Jordan Yates
3b7a797d2d lorawan: services: swap select to depends on
Switch the selects on `LORAWAN_FRAG_TRANSPORT` to `depends on`. `select`
should only be used for simple symbols without dependencies themselves.
Mixing `depends on X` and `select X` on different symbols is the primary
cause of Kconfig dependency loops.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-08-21 06:52:11 +02:00
Charles Hardin
0fe091bc46 net: dns: fix the bounds conditions on the failures and error returns
The loop condition is not the count of the actual tries since the
continue or breaks can occur on the loop and thus a failure count
can falsely match a loop count even when a query is outstanding.

This can be seen when a dual stack resolve is used for IPv4 and IPv6
that has two fds to be used and the interface has only gotten an
IPv6 address. The failures on the IPv4 will indicate a 1 and the break
on the tried attempt on the IPv6 will break the loop on a 1.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-08-21 01:43:59 +02:00
Olivier Lesage
90113e68ea bluetooth: host: Combine main and sub mode CS step options
Not all combinations of main mode and sub mode are valid, so to make it
harder to select incorrect parameters, the main mode and sub mode
enums are combined into one.

Now the user chooses any valid option in enum bt_conn_le_cs_mode.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-08-20 16:30:57 +02:00
Emil Gydesen
31a3315d61 Bluetooth: BAP: Replace bt_bap_iso with bt_iso_chan for streams
Modify the struct bt_bap_stream to have a direct reference to the
bt_iso_chan, rather than having a reference to the parent
bt_bap_iso.

This change will allow users to more easily and directly access
the bt_iso_chan, instead of getting the reference via
bt_bap_ep_get_info.
Additionally, this allows users to access the bt_iso_chan for
streams that are not codec configured, and thus not have a
bt_bap_ep reference.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-20 13:46:02 +02:00
Emil Gydesen
25247fa401 Bluetooth: ISO: Expose CIG_ID, CIS_ID, BIG_Handle and BIS_Number
Expose the IDs, handles and numbers of CIGs, BIGs, CISes and BISes
via the ISO info struct. This information may be needed by higher
layer (such as the Basic Audio Profile (BAP)) or used as indexes
for arrays in the application layer.

The location of the CIG_ID, CIS_ID, BIG_Handle and BIS_Number
are moved to the location struct inside of struct bt_conn_iso
instead of being stored directly in it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-20 13:46:02 +02:00
Emil Gydesen
6b1fafb660 Bluetooth: ISO: Change bis_id to bis_number
Modify the bis_id in struct bt_conn_iso to be bis_number
and correctly initialize it for both the broadcaster and
the sync receiver.

The field is currently unused and the term bis_id does not
exist in the core spec. The BIS Index was renamed to BIS
Number in Core 6.1, and thus the Zephyr code base will
reflect that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-20 13:46:02 +02:00
Jamie McCrae
db8f991c77 kconfig: Use $(...) instead of ${...} for getting variables
Updates this to comply with the Zephyr Kconfig recommendations

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-08-20 12:05:41 +02:00
Dmitrii Sharshakov
b98e7f501f pm: fix NULL pointer dereference with stats
Fix null pointer dereference in pm_system_suspend

Fixes #89228

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2025-08-20 02:17:20 +02:00
Tim Pambor
e3a99bd625 shell: backend: Default to poll mode for uart_native_pty
The interrupt-driven UART API is emulated via polling on native_sim,
which introduces additional overhead. Defaulting to poll mode improves
performance by avoiding this emulation cost.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-08-19 19:14:21 +02:00
Seppo Takalo
6cdae490e3 net: lwm2m: Suppress many LOG_ERR() that are not fatal
Suppress many LOG_ERR() messages from LwM2M registry
that are not necessary runtime errors.

Libraries and applications should be able to do following
without causing LOG_ERR to be produced:

* Checking existence of object, resource or resource instance
  using lwm2m_engine_get_res(), lwm2m_engine_get_res_inst()
  or path_to_objs(). These are only exposed in internal header.
* Delete object instance or resource instance without checking
  if it exits.

As there is no public API to check existence of some path,
application is much easier to write in a way that it directly
calls just lwm2m_get...(), lwm2m_set...(), lwm2m_delete...()
and trust the return code of -ENOENT.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-19 19:13:59 +02:00
Kapil Bhatt
f48a66121a net: zperf: Improve UDP multicast upload
UDP multicast uploads did not produce zperf-compatible server stats,
so the client waited for and tried to decode a non-existent reply,
causing “Unexpected response flags” and misleading
“LAST PACKET NOT RECEIVED!!!” output.

This change treats multicast as client-only: after sending
the negative-id FIN it does not wait for or decode server stats,
Instead transmits the FIN a few times to help receivers detect test end.
The shell prints a clear “Statistics (client only)” summary for multicast
and suppresses the error when client stats are valid.

Unicast behavior is unchanged.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-08-19 14:16:05 +02:00
Emil Gydesen
e6d6578d96 Bluetooth: CAP: Add missing check for abort in the started cb
bt_cap_initiator_started did not have a check for aborted like
all the other callbacks, which could cause the procedure to
continue even if it was aborted.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-19 14:15:48 +02:00
Tamás Kiss
c9087bce75 logging: fix dictionary mode for dropped messages on rtt backend
With the dictionary feature enabled, the RTT backend would still print
the "messages dropped" message as a string instead of the binary format.
Fix that by calling the correct process function when dictionary mode
is enabled.

Signed-off-by: Tamás Kiss <tmik@demant.com>
2025-08-19 13:03:03 +02:00
Keith Packard
302b192dd9 tests/kernel: Avoid C library calls from interrupt handlers
On arm64, GCC feels free to use floating point registers for essentially
anything unless we build with -mgeneral-regs-only. After the FPU gets used
in an interrupt handler, interrupts are disabled as there's no place to
save the registers during a nested exception. As the C library may be built
separately without this flag, we cannot use any of its functions or risk
having nested exceptions fail.

Switch printk usage to k_str_out and stick to (mostly) Zephyr internal
functions to ensure nested interrupts work correctly.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-08-18 22:01:08 +02:00
Pavel Vasilyev
818e18eacb bluetooth: host: Use critical section when making channel ready to send
A public API call that sends ACL data — for example, `bt_gatt_notify` —
can be invoked from a preemptive thread context. This API, in turn,
calls the `raise_data_ready` function, which adds an L2CAP channel to
the `l2cap_data_ready` list.

The atomic variable used to create a critical section around
`l2cap_data_ready` did not work, because a preemptive thread can be
pre-empted at any time. This means that regardless of the `atomic_set`
result, we cannot trust it — the thread could be preempted after the
call, and the atomic variable state could be changed (specifically by
the TX processor in this case). The same issue applies to
`bt_conn_data_ready`, which is called next.

When making an L2CAP channel ready for sending data, we need to use a
critical section when appending a channel to the `l2cap_data_ready`
list. The same applies to the `conn_ready` list.

Since cooperative threads can only be rescheduled explicitly, we must
ensure there are no rescheduling points when accessing either the
`l2cap_data_ready` or `conn_ready` lists.

For `l2cap_data_ready`, this occurs in `get_ready_chan`, which is called
from `l2cap_data_pull`, which in turn is called by the TX processor. For
`conn_ready`, it occurs in `get_conn_ready`, which is also called from
the TX processor. Both functions have no rescheduling points when
working with their respective lists, so they do not require a critical
section.

This change removes the atomic variables previously used to create a
critical section for both lists, as they were ineffective. Instead,
`k_sched_lock`/`k_sched_unlock` are used where code may be executed from
a preemptive thread context. The `sys_slist_find` function is used to
check whether a channel or connection is already in the corresponding
list.

Fixes #89705

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-18 16:05:48 +02:00
Henrik Brix Andersen
faecad66c7 retention: bootmode: remove unused log module
Remove unused log module from the bootmode retention module.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-08-18 16:00:37 +02:00
Lyle Zhu
2df8578c7a Bluetooth: Classic: SDP: Improve SDP discovery response
In current implementation, the attribute of the registered SDP record
will not be included in responding packet if the attribute data length
is more than the MAX payload size(`MIN(SDP_MTU, sad->sdp->chan.tx.mtu)
- sizeof(struct bt_sdp_hdr)`). And it causes the failure of ssa or sa
discovery.

Improve the SDP server to support the case by extending the
continuation state length. A 4 bytes space is extended to store the
attribute offset.

In this way, the attribute can be transmitted in segments according
to the reaming space of the responding buffer.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-18 11:57:23 +02:00
Kai Cheng
99243afec0 Bluetooth: PNP: add pnp product id interface and tool
add pnp product id interface and tool for HID profile

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2025-08-18 10:55:19 +02:00
Kai Cheng
82fd0b898a Bluetooth: PNP: add pnp vendor id interface and tool
add pnp vendor id interface for hid feature.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2025-08-18 10:55:19 +02:00