Commit graph

21541 commits

Author SHA1 Message Date
Andries Kruithof
86ab272286 Bluetooth: Audio: add shell command for distribute broadcast code
Adds a shell command for the distribute broadcast code CAP procedure

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-12-12 16:23:22 +01:00
Tomasz Moń
9006780db4 usb: device_next: Update IAD first interface on init
IAD must be before the interfaces it associates and therefore there is
no need for the class to be in charge of updating the bFirstInterface.
Update IAD in common initialization code and remove the updates from
classes.

This fixes UAC2 instances where the IAD bFirstInterface is not 0, e.g.
when HID was used together with UAC2.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-12-12 16:22:49 +01:00
Li Long
4d178f664c modules: hostap: add tls_cipher param
Add tls_cipher param for client WPA3 enterprise suiteb-192.
Add parameter "-T" to specify tls_cipher:
Specify "-T 1": client use ECC P384.
Specify "-T 2": client use RSA 3K.

Signed-off-by: Li Long <li.long@nxp.com>
2024-12-12 11:09:15 +01:00
Måns Ansgariusson
7545e8d582 tracing: kernel: Add support for stopping workqueues
Adds tracing support for stopping workqueues.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2024-12-12 11:07:39 +01:00
Sebastian Panceac
f7bae12cef bluetooth: smp: Fix build warnings for central with OOB legacy only
Currently, there are build warnings that are triggered when building
for BT central and legacy OOB pairing only:
CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY=y
CONFIG_BT_CENTRAL=y

There was a PR that handled this issue in the past https://github.com/zephyrproject-rtos/zephyr/pull/74400.
Unfortunately, this PR even though it fixed the warnings it also
broke the BT peripheral and legacy OOB pairing only build:
CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY=y
CONFIG_BT_PERIPHERAL=y

https://github.com/zephyrproject-rtos/zephyr/pull/82552 was merged in
order to fix the issue with the peripheral build configuration.
Unfortunately, this PR reintroduced the warnings for BT central and
legacy OOB pairing.

This commit brings changes to make sure that both the BT central and
peripheral builds with OOB legacy pairing are buildable and
warnings free.

Also in this commit, a new build test case is added for the BT central
and legacy OOB pairing along the existing BT peripheral test case

Signed-off-by: Sebastian Panceac <sebastian.panceac@ext.grandcentrix.net>
2024-12-12 11:05:38 +01:00
Jukka Rissanen
228b271f01 net: Remove deprecated CONFIG_NET_PKT_BUF_DATA_POOL_SIZE
This removes the deprecated CONFIG_NET_PKT_BUF_DATA_POOL_SIZE.
User should either use CONFIG_NET_PKT_BUF_RX_DATA_POOL_SIZE or
CONFIG_NET_PKT_BUF_TX_DATA_POOL_SIZE depending of net packet type.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-11 21:32:29 +01:00
Jukka Rissanen
0e48ce20c5 net: Remove deprecated CONFIG_NET_TCP_ACK_TIMEOUT option
Use CONFIG_NET_TCP_INIT_RETRANSMISSION_TIMEOUT and
CONFIG_NET_TCP_RETRY_COUNT to control the total timeout at the TCP
level.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-11 21:32:02 +01:00
Krzysztof Chruściński
c7f400c9aa shell: backends: Do not use RTT backend with immediate logging
RTT backend can only be called from thread context and immediate
logging might lead to interrupt context use. Previously this limitation
was implied in different way and commit (c88a9ef27) got reverted.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-12-11 21:30:19 +01:00
Krzysztof Chruściński
ca4f2d94f8 Revert "segger: rtt: disable unsupported shell/log features"
This reverts commit c88a9ef272.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-12-11 21:30:19 +01:00
Jukka Rissanen
da148ab3bc net: dns: Close socket service properly from dispatcher
We need to close the socket service context when dispatcher is
unregistered.

Fixes #82652

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-11 21:29:21 +01:00
Jukka Rissanen
c110331507 net: dns: Avoid errors when DNS dispatcher is already registered
Skip error prints and extra DNS events if DNS dispatcher was already
registered.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-11 21:29:21 +01:00
Jukka Rissanen
efcfcfe292 net: dns: Fix the debug print when dispatcher fails
Depending on DNS type, print the output (mDNS vs DNS) correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-11 21:29:21 +01:00
Johan Hedberg
880384a20e Bluetooth: Host: SMP: Verify public key before usage
Add a separate test for public key validity. This needs to be done
synchronously so that we can respond with an early failure message to the
peer device.

Fixes #80218

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-12-11 21:29:08 +01:00
Jukka Rissanen
1f2595a456 net: wifi: shell: Remove obsolete subcmd settings from commands
If a shell command does not have a sub command, then the 3rd parameter
to SHELL_SUBCMD_ADD() macro should be set to NULL so that the help
will only print information specific to that command and not all
wifi commands.

Fixes #82633

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-11 21:28:17 +01:00
Emil Lindqvist
6dafb5f4a9 wifi: fix warning on wifi_ps_exit_strategy_txt
This commit fixes a warning when including wifi.h:
type qualifiers ignored on function return type

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2024-12-11 15:55:03 +00:00
Marcin Niestroj
a7ceb4723f net: l2: wifi: fix handling of missing 'ap_disable'
When calling wifi_ap_disable() API specific WiFi driver implementation was
checked whether 'ap_enable' was provided, instead of 'ap_disable'. Fix
that copy-paste error.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2024-12-11 15:54:18 +00:00
Pisit Sawangvonganan
23b6ab4699 bluetooth: shell: code formatting cleanup in host/shell
Re-ran `clang-format` for consistent styling, simplified
multi-line statements, and consolidated string concatenations
where applicable.
This is a non-functional change focused on code formatting.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-12-11 07:59:30 +01:00
Yishai Jaffe
59c7d5715b shell: add function to get device by name or label
Added shell_device_get_binding() that wraps device_get_binding() plus
device_get_by_dt_nodelabel() so that a shell can easily get a device by
its full name or label.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2024-12-11 07:58:50 +01:00
Luca Burelli
78ae035f89 llext: fix link order for weak syscall symbols
The weak syscall symbols generated by gen_syscalls.py are currently
compiled in the LLEXT subsystem library, which is then linked among all
other Zephyr libraries in an unspecified order. This can cause the weak
symbols to override the actual syscall implementations, leading to
undefined behaviour.

To fix this, the currently generated file is split in two elements:

- syscall_exports_llext.c contains the EXPORT_SYMBOL directives for all
  syscalls. This part can be compiled with the LLEXT library and linked
  among all other Zephyr libraries, and ensures all syscalls symbols
  are preserved by the linker.

- syscall_weakdefs_llext.c contains the weak definitions for all syscalls.
  This file is compiled in a separate library that is linked last, so
  that the weak symbols are only used if no other implementation is
  available.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-12-10 20:38:48 +01:00
Lyle Zhu
bb417dad1c Bluetooth: SDP: Notify result if error rsp is received.
In current implementation, the SDP response packet will be ignored if
the operation code is `BT_SDP_ERROR_RSP`. And the SDP transaction
request is done, but the application is not notified. And the pending
SDP transaction cannot be processed.

Notify application with empty buffer if the operation code is
`BT_SDP_ERROR_RSP`. And process the pending SDP transaction.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-12-10 20:38:30 +01:00
Lyle Zhu
f279f61551 Bluetooth: SDP: Correct record length of service att rsp
The discovered SDP record of service attribute transaction response
cannot notified correctly. There is an error returned from function
`get_record_len()`.

For service attribute transaction response, only one attribute list
is returned. So the total record length is the buffer length. Return
buffer length directly from `get_record_len()` to fix the issue.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-12-10 20:38:20 +01:00
Jilay Pandya
1d7826c2ad bluetooth: host: conn.c fix Constant variable guards dead code issue
This commit replaces the assignment of IS_ENABLED(x) macros to
various variables with direct condition checking. This should fix the
coverity issue and also promotes more uniformity in code.

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2024-12-10 20:38:12 +01:00
Krzysztof Chruściński
d1bd45739a logging: frontends: stmesp: Move zephyr_custom_log.h to the unique path
Logging with STMESP frontend is using custom logging header feature.
Put that specific header file in a custom path which is added to the
build only if that logging frontend is used.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-12-10 20:37:22 +01:00
Kyra Lengfeld
519f888942 Bluetooth: Mesh: Fix gatt advertiser start in bt_mesh_resume
To signal to the mesh extended advertiser that a proxy advertisement is
started, `bt_mesh_adv_gatt_send()` is called in combination with
setting the `ADV_FLAG_PROXY` flag in adv_ext.c. This ensures that it
won't try to start the advertiser again, which would result in the
controller rejecting it.

Setting this flag outside adv_ext.c is not viable, and as such calling
`bt_mesh_adv_gatt_send()` should also be limited to the advertising
source code.

As it stand now, once we utilize the new commit priority for `h_commit`
calls such a recall of `bt_mesh_adv_gatt_send()` with following
rejection by the controller will happen.

Within the `bt_mesh_resume()` function we can confidently assume the
extended advertiser has already been started. As such we can call
`bt_mesh_adv_gatt_update()` instead of `bt_mesh_adv_gatt_send()`.

This change has been tested with both running relevant bsim tests after
rearranging in which order the settings of the subsystems are loaded via
`h_commit`, as well as a modified light switch sample, adding
`bt_mesh_resume/suspend` calls on buttons.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2024-12-10 16:22:45 +01:00
Krzysztof Chruściński
9d478d7675 logging: frontends: stmesp_demux: Add support for turbo logs
Add support for handling optimized short log messages (aka turbo logs).
There are 2 types of turbo log messages:
- No arguments. D16MTS is used for that on channel > 32768
- One numeric argument. DM16 followed by D32MTS is used.

Additionally, in order to be able to get source name for log messages
coming from owned by cpuapp co-processors (PPR and FLPR) there must
be a way of passing location of constant source data from PPR/FLPR to
cpuapp which handles ETR data. This method is added in the commit as
well. PPR/FLPR sends D32M during the boot with address of constant
source data section. Demultiplexer stores those addresses and it is
able to retrieve source name for log messages from PPR/FLPR.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-12-10 11:09:55 +01:00
Krzysztof Chruściński
752f8b0176 logging: frontends: stmesp: Add optimized short logs
Add 'turbo' logging feature. When enabled, short logs (no argument
or one numeric, 32 bit argument) are handled in a special way that
is much faster than the default one (5-10x faster). Additionally,
there is an option to remove all other logs from the system which
allows to not include almost any logging framework code in the
binary (~170 bytes of code is needed). It may be especially
valueable for memory constraint targets (ppr, flpr) where with
only 170 byte of code (+code for each log message) we can provide
limited formatted string logging support.

'Turbo' logging is using following to achieve that:
- logging strings are put into a memory section and additional
memory section is created which holds addresses of those strings.
Index in that array is used to identify a string (32 bit address
is encoded into a smaller number, 15 bits is more than enough).
This index is used for a STMESP register set (there are 2^16
available). So STMESP channel encodes string.
- Logging level is stringified and prepended to a string
- Source ID is encoded by using DM16 (so far not used).
- Log without arguments is written as DMTS16
- Log with one argumetn is written as DM16+DMTS32

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-12-10 11:09:55 +01:00
Krzysztof Chruściński
3f4739834f logging: Set frontend filters only when filtering enabled
Set initial filtering settings in the log core init only if
runtime filtering is enabled. It saves few bytes when runtime
filtering is off.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-12-10 11:09:55 +01:00
Pavel Vasilyev
c2488fdd30 bluetooth: buf: Add a callback for freed buffer in rx pool
The Bluetooth data buffer API currently lacks a mechanism to notify when
a buffer is freed in the RX pool. This limitation forces HCI drivers to
adopt inefficient workarounds to manage buffer allocation.

HCI drivers face two suboptimal options:

- Blocking calls: Use bt_buf_get_rx with K_FOREVER, which blocks the
  execution context until a buffer becomes available.
- Polling: Repeatedly call bt_buf_get_rx with K_NO_WAIT, which increases
  CPU load and reduces efficiency.

This commit introduces a callback mechanism that is triggered each time
a buffer is freed in the RX pool. With this feature, HCI drivers can:

- Call bt_buf_get_rx with K_NO_WAIT.
- Wait for the callback notification if a NULL buffer is returned,
  avoiding unnecessary polling.

The new callback improves efficiency by enabling event-driven behavior
for buffer management, reducing CPU overhead while maintaining
responsiveness.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-12-10 11:09:36 +01:00
Jukka Rissanen
027760b6d4 net: if: Replace asserts by proper runtime checks
The asserts were not proper here, replace those by runtime
checks as the functions can be called from applications and
asserts are not meant for error checking.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-10 11:09:25 +01:00
Jukka Rissanen
692310d68c net: websocket: Remove assert call
Remove the useless assert as it is not needed at all here.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-10 11:09:25 +01:00
Jukka Rissanen
1e15eec64f net: vlan: Remove useless assert
The assert is not needed and it was in wrong place anyway.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-10 11:09:25 +01:00
Jukka Rissanen
2416cde90e net: trickle: Remove useless asserts
Replace asserts by runtime checks as the APIs can be used
from applications.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-10 11:09:25 +01:00
Gang Li
e73bc712cc net: wifi: add "bandwidth" parameter to "wifi ap enable" command
Add "bandwidth" parameter to "wifi ap enable" command.
Add "ht_capab" and "vht_capab" parameters to "wifi ap config" command.

Signed-off-by: Gang Li <gang.li_1@nxp.com>
2024-12-10 11:09:09 +01:00
Pisit Sawangvonganan
0156a322b1 bluetooth: host: hci_core: fix num_handles assignment
Replaced `sys_cpu_to_le16(1)` with a direct `1` assignment to the
`cp->num_handles` (uint8_t) field to avoid truncation to `0x00` on
big-endian architectures.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-12-10 11:08:15 +01:00
Fin Maaß
5d2068f491 logging: log_output: move partly unused code
move code, that is only needed for one case
to that case.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-10 08:06:25 +01:00
Fin Maaß
1d4249dea6 logging: remove part for when gmtime_r is not available
now that CONFIG_POSIX_C_LANG_SUPPORT_R will
add a custom implementation for gmtime_r() if that
is not provided by the toolchain, we can simply depend on
that, instead of using out own.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-10 08:06:25 +01:00
Fin Maaß
fc50427f3e logging: backend: net: add missing dependency
add missing dependency of NET_SOCKETS to LOG_BACKEND_NET.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-10 08:06:25 +01:00
Lyle Zhu
69d415c9ce Bluetooth: SSP: Improve BR SC only mode
Actively disconnect the connection with error code `BT_HCI_ERR_AUTH_FAIL`
when the notified link key type is not `BT_LK_AUTH_COMBINATION_P256` in
BR SC only mode.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-12-10 05:39:10 +01:00
Lyle Zhu
2424bfd869 Bluetooth: BR: improve br_sufficient_key_size
Currently, the minimum value of encryption key size is
`BT_HCI_ENCRYPTION_KEY_SIZE_MIN`.

Add a new Kconfig `BT_BR_MIN_ENC_KEY_SIZE`. It is used to set the
specific minimum encryption key size.
The default value is `BT_SMP_MIN_ENC_KEY_SIZE`. And it can be
configured if `BT_SMP_SC_ONLY` is not enabled.

Use `CONFIG_BT_BR_MIN_ENC_KEY_SIZE` as minimum encryption key size in
`br_sufficient_key_size`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-12-09 15:11:52 +01:00
Johan Carlsson
f756d0d2bd usb-c: pe: set correct sink/src ready state.
policy engine errors were unconditionally setting the state back
to sink ready. this fix sets the correct state based on the current
power role.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
2024-12-09 15:11:39 +01:00
Johan Carlsson
9b021bc8e1 usb-c: add PE_SRC_Disabled support.
with this fix the pd stack works with type-c devices that does not
respond to pd.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
2024-12-09 15:11:39 +01:00
Johan Carlsson
cae67312d1 usb-c: ignore VDM messaged when using PD 2.0
according to PD 2.0 sepecification VDM should be ignored
if not supported.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
2024-12-09 15:11:39 +01:00
Johan Carlsson
0fa9ef8b07 usb-c: clear cache cc_voltage variable.
when not clearing cc_voltage the type-c current limit
will only be reported on the first plug in.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
2024-12-09 15:11:39 +01:00
Andries Kruithof
dd75fc39c3 Bluetooth: Audio: add bt_ prefix when registering logging module
Add the bt_ prefix when registering logging for the media_proxy module,
to be consistent with what the other modules in bluetooth/audio do
Note that the bap_usb module shall not have the bt_ prefix

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-12-09 15:10:57 +01:00
Tomas Choat
bc3748ce60 net: lib: ptp: fix cpp compilation errors
Compilation errors in ptp library when using C++ compiler.
First error is due to 'class' keyword being reserved in C++
and 'class' is used as a variable name in ptp library.
Second error is due to a flexible array member in a struct
is not placed at the end.

Signed-off-by: Tomas Choat <trc@ixys.no>
2024-12-09 15:10:28 +01:00
Tomas Choat
7541742002 net: lib: ptp: Assert statements inverted
The asserts always fail because the condition is inverted.
This patch fixes the condition to verify the socket
is lower than PTP_SOCKET_CNT.

Signed-off-by: Tomas Choat <trc@ixys.no>
2024-12-09 15:10:28 +01:00
Tomas Choat
b3505fbaa6 net: lib: ptp: Fix bidir time adjustment
When the offset is larger than 1 second, the time
adjustment should still be allowed to be bidirectional.
Casting the offset to an unsigned value after the
subtraction will allow the adjustment to be bidirectional.

Signed-off-by: Tomas Choat <trc@ixys.no>
2024-12-09 15:10:28 +01:00
Tomas Choat
ecfc44469c net: lib: ptp: fix follow up msg bug
When sending follow up messages, the pre send function
does not insert the correct time stamp in the message.
Issue is fixed by calling the pre send timestamp function.

Signed-off-by: Tomas Choat <trc@ixys.no>
2024-12-09 15:10:28 +01:00
Emil Gydesen
3e0c08caec Bluetooth: CAP: Fix log warning for meta pointer
Fixes the following warning:
<wrn> cbprintf_package: cbprintf_package_convert:
  (unsigned) char * used for %p argument. It's recommended
  to cast it to void * because it may cause misbehavior in
  certain configurations. String:"%s: meta %p len %zu" argument:1

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-12-09 09:50:12 +01:00
Bjarki Arge Andreasen
59779ebe4b pm: policy: event: use uptime ticks
Update events to use uptime ticks, which is a monotonic clock which
in the same res as kernel ticks. This makes comparisons simple and
removes the complexity of dealing with wrapping counter values.

The wrapping is particularly problematic for events since this makes
it quite complex to track if an event has occured in the past, or
will occur in the future. This info is needed to know if an event
has actually been handled or not.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-12-09 03:55:52 +01:00