Commit graph

21541 commits

Author SHA1 Message Date
Nicolas Pitre
c7467f0c65 ring_buffer: constify some arguments
Functions that don't modify content should have pointers to it marked
const.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-03-11 08:59:05 +01:00
Emil Gydesen
9d4cc4b49b Bluetooth: BAP: Add a set of suggested intervals to use with BAP
Add a selection of interval values that are suitable for BAP,
which will allow better coexistence between ISO and ACL,
for both broadcast and unicast. Some of these are defined
by the BAP spec, and some are defined by Zephyr, since they
do have a suggested value from BAP.

Samples and tests have been updated to use these new values.
Peripheral samples have also been updated with
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS so that the connection
parameters from the centrals aren't updated to something else
shortly after.

The shell has also been updated to use the LE Audio (BAP) values
if audio is enabled, and the audio.conf file has disabled automatic
updating of the connection parameters as the peripheral, as we rarely
(if ever) want to do that.

Due to the connection interval change, CI hit an issue
with test_bass_broadcast_code in test_main_client_sync, where
the reading of the long receive state did not finish before we
attempted to do another procedure, so the function was updated to have
a retry.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-11 08:58:51 +01:00
Lyle Zhu
1cfd624b3d Bluetooth: SDP: Notify upper layer if the response data len is 0
In current implementation, the SDP discovery complete event is not
notified when the response data length is 0.

Notify the discovery complete event if the response length is 0.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 21:49:41 +01:00
Thomas Deppe
4161ba2103 Bluetooth: Host: Fix Advertising Coding Selection as peripheral
Fix mistake in host implementation of Advertising Coding Selection.

The host should only try set the BT_LE_FEAT_BIT_ADV_CODING_SEL_HOST
when the observer role is enabled. If a broadcaster enables the
CONFIG_BT_EXT_ADV_CODING_SELECTION Kconfig option bluetooth will
fail to initialise.

Signed-off-by: Thomas Deppe <thomas.deppe@nordicsemi.no>
2025-03-10 21:31:12 +01:00
Lyle Zhu
ed45960870 Bluetooth: SDP: Fix the issue of not handling the next discovery req
The pending discovery request will not be handled in some cases.
The cases include,
- The received data length is not aligned with frame length
- The continuation status length is more than maximum value
- Total length of the response is less than the frame length
- Unknown operation code is received

There is also a case where the current discovery result was not
notified when processing the pending discovery request.
The cases include,
- Fail to send SDP request
- No tail room of received buffer to save the response data

Fix the issue by using the following steps,
- Notify the application that the discovery is done
- Process the pending discovery request

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 15:20:40 +01:00
Lyle Zhu
dcd8bcb88d Bluetooth: SSP: Reply a negative rsp if binding flags are mismatched
If the remote is in bondable mode, but the local is in non-bondable
mode, the local host shall respond to an IO capability request with
a negative response.

In current implementation, it does not check the bonding flags of the
both sides are consistent.

Fix the issue by checking the consistency of bonding flags of the both
sides. If they are not consistent, send a negative IO capability
response with the reason pairing not allowed.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 15:03:04 +01:00
Lyle Zhu
1408614fd2 Bluetooth: SSP: bt_conn_unref is missing if pairing is not accepted
The `conn` is found by using function `bt_conn_lookup_addr_br()`, it
should be released by calling `bt_conn_unref()`. But `bt_conn_unref()`
is missing in the case that the pairing is not accepted.

Release the `conn` by calling `bt_conn_unref()` before exiting the
function `bt_hci_io_capa_req`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 15:02:48 +01:00
Christoph Seitz
0e4cf09b55 net: sockets: Fix AF_PACKET sll_protocol in recvfrom
Convert the protocol value in return in recvfrom to
network byte order as expected.

Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
2025-03-10 15:02:38 +01:00
Lyle Zhu
0d36361b5d Bluetooth: SDP: Check data len consistency between total and received
Add fields `total_len` and `recv_len` to `struct bt_sdp_client`.

Save the total length of the response to `total_len`.
Save the received data length of the response to the `recv_len`.

Check the consistency between `total_len` and `recv_len` after all of
the response packets are received.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 08:58:38 +01:00
Alberto Escolar Piedras
ac24d2277e native FUSE FS access: Support any libC and fix random crashes
Split the fuse FS driver into 2 parts: A top built in the embedded side,
with the embedded libC, and a bottom built in the runner side with the
host libC.
The error returns are converted to match the host libC.

Also, before the host FUSE thread, which is asynchronous to Zephyr was
calling directly into the Zephyr filesystem code, which resulted quite
often if catastrophic failures or corruption of the Zephyr state.
This is now fixed by having the FUSE thread queue requests to a Zephyr
thread, which will be handled in the embedded side in a coherent way.
This adds a slightly noticeable overhead, but the performance is still
acceptable.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-08 15:26:29 +01:00
Rubin Gerritsen
65c7f1f269 Bluetooth: Controller: Kconfig: Add dependencies to ISO configs
The ISO configs set defaults based upon BT_ISO_MAX_CHAN and other
configs defined in `bluetooth/Kconfig.iso`.

By adding these dependencies the error messages resulting from
adding `CONFIG_BT_CTLR_PERIPHERAL_ISO=y` to a project configuration
file will become less confusing.

Now the build will output:
```
warning: BT_CTLR_PERIPHERAL_ISO (
defined at subsys/bluetooth/controller/Kconfig:976,
subsys/bluetooth/controller/Kconfig:984) was assigned the value 'y' but
got the value 'n'. See ...
```

Previously we would get:
```
warning: default value 0 on BT_CTLR_CONN_ISO_STREAMS
(defined at subsys/bluetooth/controller/Kconfig:993)
clamped to 1 due to being outside the active range ([1, 64])
```

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2025-03-07 20:35:45 +01:00
Jukka Rissanen
d955af4e62 net: dns: Join mDNS multicast group for resolving
If mDNS resolver is enabled but mDNS responder is not, then
mDNS multicast address group is not joined. This would prevent
the mDNS resolver to receive the responses. Fix this by
joining the mDNS multicast group if mDNS responder is not
enabled (because the responder will join the group itself).

Fixes #86477

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-07 20:28:03 +01:00
Mathieu Anquetin
7282ea08e9 net: dhcpv4: fix deadlock issue
There is a deadlock issue when calling stop using address conflict
detection. This is due to the fact that some net_mgmt events are fired
and trigger the dhcpv4_acd_event_handler() with lock held even if they
are of no interest for this callback.

Therefore, before acquiring the lock, make sure the event we received
is one we are expecting.

Also, do the same for dhcpv4_iface_event_handler().

Signed-off-by: Mathieu Anquetin <mathieu.anquetin@groupe-cahors.com>
2025-03-07 20:22:58 +01:00
Kiara Navarro
737133a6df mgmt: ec_host_cmd: remove response leftovers
Remove `res` variable since it was not used in any part of `rx_timeout`
function.

Signed-off-by: Kiara Navarro <knavarro@paltatech.com>
2025-03-07 20:21:02 +01:00
Guennadi Liakhovetski
57e8d5ecfb log: fix log_flush()
The logging thread is usually woken up by a timer, if the timer
period is longer than 10ms, log_flush() can iterate multiple times
needlessly, while waiting for the next timer. Instead wake up the
logging thread to let it flush the queue immediately. Besides a
hard-coded polling period of 10ms is too long for some applications,
make it a Kconfig parameter.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2025-03-07 20:20:00 +01:00
Carlo Kirchmeier
3d1370f094 net: http: Add compression support in HTTP server
Add compression support using the accept-encoding
header to the http server static filesystem resource.

Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
2025-03-07 20:19:44 +01:00
Lyle Zhu
1aa88f86b8 Bluetooth: SDP: Ignore the unexpected response
The response should not be handled if there is not a request has been
sent.

Ignore the response if the `session->param` is `NULL`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 20:18:51 +01:00
Lyle Zhu
86b765c0a9 Bluetooth: SDP: Ignore unsupported UUID
In current implementation, if the UUID of request is unknown, the
local variable `u` will not be updated, and the unknown UUID `u`
is used as the target to search it in the SDP record list. It may
result in irrelevant record being replied to the requester.

Ignore the unsupported UUID to fix the issue.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 20:18:31 +01:00
bac phan
7026f113d6 net: http: Add #ifdef guard file system in HTTP server
http_server_http2.c does not guard check if file system is available
or not before using file system api. This PR will add guard for that

Signed-off-by: bac phan <phanhaibac98@gmail.com>
2025-03-07 20:18:04 +01:00
Lyle Zhu
7ec9f58b66 Bluetooth: SDP: Fix the error if continuation length is not 0
When the continuation length is not 0, there is a reported error.

In current implementation, the total length is only valid only when
the frame is the first block of the SDP response. For following
continuous frame, the total length is 0.

So, change the condition to `(total != 0 && frame_len > total)`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 20:16:38 +01:00
Alberto Escolar Piedras
78f800642a drivers/ethernet/eth_native_posix: Rename to eth_native_tap
Rename this driver to eth_native_tap, including renaming all its
options.
The old options remain until v4.4, but as deprecated.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-07 20:10:38 +01:00
Jukka Rissanen
0f90affcdf net: http: server: Select POSIX_C_LIB_EXT instead of FNMATCH
The CONFIG_POSIX_C_LIB_EXT will get support for fnmatch() function.
The old CONFIG_FNMATCH is deprecated.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-07 20:03:27 +01:00
Jukka Rissanen
33cf7dc78a net: http: server: The detail length of wildcard detail was wrong
The path length of the detail resource was not set properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-07 20:03:27 +01:00
Troels Nilsson
8373f19bc2 Bluetooth: Controller: Add tests covering ticker without remainder support
Update Kconfig to not select BT_TICKER_REMAINDER_SUPPORT for nrf54L

Add BSim tests to cover using a ticker without BT_TICKER_REMAINDER_SUPPORT
and expire info enabled

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-07 20:02:49 +01:00
Troels Nilsson
df67f4ec13 Bluetooth: Controller: Fix building ticker without remainder support
A few things were not flagged by CONFIG_BT_TICKER_REMAINDER_SUPPORT
that should have been; This caused building without it to fail

Initialize remainder to 0 where used with ticker_next_slot_get_ext(),
since it may not get set if remainder support is off

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-07 20:02:49 +01:00
Seppo Takalo
334b32d9f5 net: coap_client: Stop lifetime on piggybacked Ack
When we receive piggybacked Ack, it means that we have
received all information for this request.
There is no need to track exchange lifetime anymore.

Once we reset the internal request, it is free to be used
for the application. So if we only have few requests allocated,
it would be slow to send those as get_free_request() only
gives request structures that don't have a lifetime left.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-03-07 20:01:26 +01:00
Michal Piekos
81bf6e746e shell: fixes shell dead code issue
Move z_transport_buffer_flush(sh) to the scope of the while loop.

Coverity-CID: 399568

Signed-off-by: Michal Piekos <michal.piekos@wp.pl>
2025-03-07 20:00:27 +01:00
Luis Ubieda
c66d0d81c2 rtio: workq: Default workqueue to two threads with SPI/I2C/I3C
As to facilitate work items preemption, common for sensor read ops.

e.g:
- Sensor read (submitted through workqueue).
- SPI read (submitted through workqueue using default handler).

This requires at least 2 thread pools to allow SPI read to complete,
to then come back and complete sensor reading.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-03-07 20:00:18 +01:00
Théo Battrel
158870ec64 Bluetooth: Host: Use memset to initialize psa_mac_operation_t
In `db_hash_setup()` the state object for MAC operations was initialized
using `psa_mac_operation_init()`. This function was not always optimized
or inlined.

A way to reduce stack usage is to use `memset()` and set the object to
0. This is one of the option documented to initialize
`psa_mac_operation_t` object.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2025-03-07 19:59:24 +01:00
Maciej Baczmanski
6636adc706 openthread: Rework L2 configuration
- Add possibility to choose implementation of OpenThread L2 and
set it to Zephyr's by default
- Remove unused `OPENTHREAD_SECURITY_INTERNAL` Kconfig
- Add missing choice names for logging and coprocessor

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2025-03-07 19:59:07 +01:00
Cla Mattia Galliard
7d721ce63a net: icmp: Send replies with timeout K_NO_WAIT
This ensure system stays operational in icmp flood situation.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
647ca57234 net: lldp: Send replies with timeout K_NO_WAIT
This ensures system stays operation in lldp-flood situation.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
353e314fbf net: arp: Send replies with timeout K_NO_WAIT
This ensures system stays operational in arp-flood situation.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
19f192cfb5 net: net_context: Make use of timeout for sending
Use the newly added timeout in various send functions from within
net_context_sendto.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
5b89a5c4b8 net: add try variant with timeout for various send functions
Allows to send with different timeouts to not block caller in some
situations. Stable API is kept and just calls `try`-variant with a timeout
of `K_FOREVER`.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Emil Gydesen
1a6af2bfa6 Bluetooth: Audio: Modifed PAST checks to use public API
Use the recently added bt_le_get_local_features function as well
as bt_conn_get_remote_info to avoid using internal APIs to
check for PAST supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-07 19:58:23 +01:00
Emil Gydesen
4619611326 Bluetooth: Conn: Add const for conn in bt_conn_get_remote_info
The connection object is, and should not, be modified by the function.
Making it const makes it possible to do this simple operation
in functions that also won't change the conn object (i.e.
that uses `const`).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-07 19:58:23 +01:00
Emil Gydesen
44c5c1da3d Bluetooth: Host: Add API for reading LE controller features
The function supports reading multiple controller-based values.
It is effectively a copy of struct bt_dev_le but in a more
application-oriented definition.

It was chosen to keep the features as an array rather than a
64-bit value, as the comparison macros work on arrays and that
there already exists new bits > 64 in the core spec which is not
yet supported by Zephyr.

It is being smoke tested in a generic GATT client test,
as the individual values may depend on several Kconfig options.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-07 19:58:23 +01:00
Aleksandr Khromykh
e075e08195 Bluetooth: Mesh: remove api prefix for static functions
Commit removes api prefix for static functions
in crypto psa.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-03-07 19:58:10 +01:00
Povilas Selevicius
37ddeb459c net: coap_client: expose has_ongoing_exchange function
The coap_client has a static/internal function, has_ongoing_exchange(),
which can be an useful addition to the public API. This would provide
a mechanism to determine when it is safe to close a socket gracefully.

Signed-off-by: Povilas Selevicius <povilas.selevicius@quadigi.com>
2025-03-07 19:52:22 +01:00
Utsav Munendra
2b48ef62ba portability: cmsis: Implement osThreadJoin using Zephyr k_thread_join
Bugfix previous `osThreadJoin()` implementation where a thread which
exited with `osThreadExit()` could not be joined upon by other threads.

Signed-off-by: Utsav Munendra <utsavm@meta.com>
2025-03-07 19:51:50 +01:00
Jordan Yates
7ab8e27e26 net: lib: sntp: async query API
Add a variant of the SNTP API that does not block while waiting for a
response from the SNTP server. Instead it takes advantage of
`CONFIG_NET_SOCKETS_SERVICE` to read the response asynchronously when
the response is received.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-03-07 19:51:40 +01:00
Jordan Yates
5178835677 net: lib: sntp: extract query send logic
Extract the SNTP query send logic out of `sntp_query` so that it can be
used by functions that don't synchronously wait for the response.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-03-07 19:51:40 +01:00
Noah Olson
b2e29fe0d7 net: tcp: fix ECONNREFUSED not reported by zsock_connect
When a TCP connection is refused during zsock_connect, errno is set
to -ENOTCONN, but errno should be set to -ECONNREFUSED. This change
causes the ECONNREFUSED status to be propagated from tcp_in to
net_tcp_connect, which eventually causes errno to be set
to -ECONNREFUSED.

Signed-off-by: Noah Olson <noah@wavelynx.com>
2025-03-07 19:48:10 +01:00
Tom Hughes
6c79dab929 toolchain: Add indirection for compiler warnings
In order to support new toolchains that are not compatible with
gcc/clang (e.g., IAR), we need to add a level of indirection for
the name of warnings.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-03-07 19:47:30 +01:00
Lyle Zhu
c0f7aefe55 Bluetooth: BR: Support limited discoverable mode
Add a Kconfig BT_LIMITED_DISCOVERABLE_DURATION to set the timeout for
limited discoverable mode.

Add a argument `limited` to function `bt_br_set_discoverable()` to
support the limited discoverable mode.
When enabling discoverable mode with `limited` is true, both write
LIAC and GIAC to controller and set the bit 13 of COD in function
`bt_br_set_discoverable()`. And start a delay worker with the timeout
CONFIG_BT_LIMITED_DISCOVERABLE_DURATION to disable the discoverable
mode.
When disabling discoverable mode, only set GIAC to controller and
clear bit 13 of COD.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 19:46:53 +01:00
Mark Wang
37ae587b64 bluetooth: avdtp: move the buf as callback parameter
if saving buf to another variable, usually the ref/unref
needs to be used. change to pass the buf as one parameter
of callback

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
0d253c5b45 bluetooth: a2dp: clean few unused codes lines
memset already clean the `buf`, don't need to set as NULL.
`avdtp_set_status` already set `req->status` based on `msg_type`,
don't need to check `msg_type` again.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
935fdd2147 bluetooth: a2dp: improve the readability
add more blank lines before or after the code block {}

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
e531295515 bluetooth: a2dp: optimize bt_a2dp_ep_info
bt_a2dp_ep_info is used in bt_a2dp_discover, and the max
discovered endpoints' info are already given in seps_info
of bt_a2dp_discover_param, so use pointer to point to the
seps_info of bt_a2dp_discover_param.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00