Commit graph

18898 commits

Author SHA1 Message Date
Martin Jäger
f13791d5ba canbus: isotp: use flags for configuration in isotp_msg_id
The previous design with dedicated bits in the structure required a
user to explicitly set each bit.

Using one flags variable allows to extend the features more easily
in the future and avoids breaking existing code.

This change is particularly useful for the FDF and BRS flags required
for CAN-FD support.

See also previous similar change for the CAN driver in
f8a88cdb27

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-09-07 09:43:56 +02:00
Emil Gydesen
592da93644 Bluetooth: CAP: Add minimum metadata len req for CAP
CAP requires setting the streaming context in the metadata,
which requires 4 octets of metadata, so the metadata for
CAP must be greater than or equal to 4.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-07 09:42:46 +02:00
Xudong Zheng
7188f925f9 logging: fix timestamp scaling with 64-bit timestamp
In default_get_timestamp(), sys_clock_tick_get() is returned when
CONFIG_LOG_TIMESTAMP_64BIT=y. The timestamp frequency should reflect this.

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2023-09-06 17:23:59 +02:00
Rick Talbott
774da57db9 shell: Add shell command command rem
Added the shell comment command.

Signed-off-by: Rick Talbott <richard.talbott1@t-mobile.com>
2023-09-06 14:02:38 +02:00
Anders Storrø
01a6ecb6bf Bluetooth: Mesh: Send od priv proxy with devkey
According to the mesh 1.1 spec, section  4.4.14.1: “. The access layer
security on the On-Demand Private Proxy Client model shall use the
device key of the node supporting the On-Demand Private Proxy
Server model.“

This commit alters the API and implementation to reflect this.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-06 13:05:14 +02:00
Bjarki Arge Andreasen
c2647ff24b subsys/modem/backend: Correct async UART backend close
The backend currently returns the pipe closed event immediately
after calling uart_rx_disable() which is not the correct behavior.
the pipe closed event should be called when the UART_RX_DISABLED
event is raised by the UART driver.

With this fix, back-to-back open/close/open... will work as
expected, where before the second open would often fail since
the UART was not actually disabled yet.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-06 09:35:34 +02:00
Pavel Vasilyev
d36b7f4de0 Bluetooth: Mesh: Fix Solicitation RPL PDU Server compilation
A pointer to the key struct should be passed after the PSA support has
been added.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-06 09:35:10 +02:00
Pavel Vasilyev
2a472b8b47 Bluetooth: Mesh: Fix Opcode Aggregator Server compilation
Remove ifdef around `srcs` and let linker exclude it when Opcode
Aggregator Client model is not enabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-06 09:35:10 +02:00
Théo Battrel
8bd36fc589 Bluetooth: Host: Fixes SMP issues
If the bonding information has been cleared before pairing had a chance
to complete (probably by the application), indicate this by setting an
appropriate log message.

Also check that keys exist before calling `bt_keys_store`.

Fixes #59788 and #61465

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-09-06 09:35:01 +02:00
Johann Fischer
ad498aa550 usb: device: hid: remove CONFIG_USB_HID_PROTOCOL_CODE
Kconfig option USB_HID_PROTOCOL_CODE, deprecated in v2.6,
is finally removed.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-09-05 16:16:56 +02:00
Ren Chen
6bceb45176 usb: hid: Call the report proto callback function when the reset occurs
This commit changes the protocol callback function is invoked if the HID
protocol changed due to reset.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2023-09-05 16:15:58 +02:00
Gerard Marull-Paretas
95cac89b4e ipc: rpmsg_service: s/device.h/init.h
Because module uses init.h APIs (SYS_INIT), not device.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-05 12:01:01 +02:00
Mariusz Skamra
dd3cffcd20 Bluetooth: audio: Fix bt_audio_codec_cfg_get_chan_allocation_val return
This fixes bt_audio_codec_cfg_get_chan_allocation_val return value that
shall be 0 in case of success.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-05 10:06:09 +02:00
Mariusz Skamra
856b8cb5e9 Bluetooth: audio: Fix pointer value assignment
This fixes data pointer that was never set because wrong pointer
assignment.
It's regression introduced in:
b4af917ad0

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-05 10:06:09 +02:00
Vinayak Kariappa Chettimada
f6bf73de83 Bluetooth: Controller: Use NRF_CCM HEADERMASK for ISO PDU encryption
Use NRF_CCM HEADERMASK register to use correct Additional
Authentication Data (AAD) from ISO PDU header.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-05 10:04:57 +02:00
Kamil Piszczek
42c904526b bluetooth: host: convert conn address on identity resolution
Fix an issue in the CCC configuration when the Peripheral device
maintains two or more distinct connections on different identities
with the same peer. The issue occurs when the local device performs
the pairing and the bonding procedure on a connection associated
with one of the Bluetooth identities. During the identity resolution,
the peer address field in the CCC descriptor is converted from the
RPA-type address to the Identity Address. However, the destination
address on the remaining connection objects associated with other
Bluetooth identities is not converted. Due to this, their CCC
configuration is reset and GATT indications and notification fail
to be sent even if the Central device subscribed to them.

Added necessary code to iterate over all connection objects during
the identity resolution phase and aligned their destination address
from the RPA-type to the Identity Address.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-09-04 18:41:48 +02:00
Vinayak Kariappa Chettimada
96c12650e8 Bluetooth: Controller: Fix timestamp to use CIS reference anchor point
Fix timestamp calculation to use CIS reference anchor point
instead of incorrectly used CIG reference anchor point.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-04 18:22:24 +02:00
Damian Krolik
49fb5f0a1a nvs: replace CRC with better hash function for lookup cache
NVS lookup cache currently uses CRC8/16 as a hash function
to determine the cache position, which is not ideal choice.
For example, when NVS lookup cache size is 512 and 256
subsequent NVS IDs are written (that is, 0, 1.., 255), this
results in 128 cache collisions.

It is better to use a dedicated integer hash function. This
PR uses one of the 16-bit integer hash functions discovered
with https://github.com/skeeto/hash-prospector project. The
hash function was additionally tested in the context of NVS
lookup cache using simple NVS ID allocation patterns as well
as using real device NVS dump.

Also, add a test case to verify that the hash function is
not extremely bad.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2023-09-04 18:21:20 +02:00
Fabio Baltieri
5f0efb94fa modem: modem_chat,modem_cmux: fix mismatched CONTAINER_OF
Add a missing k_work_delayable_from_work to go from k_work to
k_work_delayable.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-04 16:54:56 +02:00
Prashanth S
05fe627d79 drivers: interrupt-controller: Add VIM Interrupt Controller support
Add TI VIM (Vectored Interrupt Manager) interrupt controller support.
VIM is a TI specific custom interrupt controller for ARM cores.
In J721E soc, VIM aggregates interrupts to Cortex R5 cores.

TRM for J721e https://www.ti.com/lit/zip/spruil1
File: spruil1c.pdf
VIM: section 6.3.3.6

Signed-off-by: Prashanth S <slpp95prashanth@yahoo.com>
2023-09-04 10:53:09 +02:00
Carles Cufi
8c748fd005 kernel: Modify the signature of k_mem_slab_free()
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.

The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);

has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);

The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.

All in-tree uses of the function have been adapted.

Fixes #61888.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-09-03 18:20:59 -04:00
Laczen JMS
cb19fc7a91 nvs: remove unused return code in nvs_sector_close
Fixes #61644

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2023-09-02 15:10:09 +02:00
Emil Gydesen
68a4d0f6c5 Bluetooth: BAP: Broadcast Source: Modify when enabling state is set
Modify when the BT_BAP_EP_STATE_ENABLING state is set during
bt_bap_broadcast_source_start.

The reason why the state is now set before the call to
bt_iso_big_create, is to handle the case where the BIG
created event actually happens and is handled (by another
thread) faster than the state change is done, which could
cause an invalid state check if the streaming state is
attempted to be set before the enabling state.

Since the events from the controller may be handled by a
different thread, we should not assume that this function returns
before the event is handled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-01 17:45:07 +02:00
Rubin Gerritsen
faee29c229 Bluetooth: Shell: Only print valid ISO data
The application gets notified about both valid and invalid data.
As data arrives every SDU interval, we would like to only print the
valid data to avoid the shell being flooded with logs.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-09-01 17:44:39 +02:00
Dmytro Semenets
8b33da03f3 fs: shell: littlefs: add support of block devices
For flash device, littlefs should be located at the partition.
Current implementation of the fs shell is hardcoded for the flash device
and the compilation fails if STORAGE_PARTITION isn't defined in the
device tree.
Add options for block dev support. This allows to mount littlefs on the
block device from the shell, and also removes the compile time
dependency on STORAGE_PARTITION, if CONFIG_FS_LITTLEFS_BLK_DEV is set.

Fix mounting of littlefs blk device. lfs_mount stucks in case when the
read/prog buffer less than SDMMC block size, because it can cause memory
corrupt, for example, look into function 'card_read_blocks' how it writes
data to read buffer in case when buffer isn't aligned. With default
config we have 32 bytes in the read buffer but trying to write
'block_size' to it and get memory corrupt, the same issue will be in
case when the read buffer is aligned.

This is an incremental improvement, ideally, someone should implement
selection of the storage dev from the shell args.

Co-authored-by: Mykola Kvach <mykola_kvach@epam.com>
Signed-off-by: Dmytro Semenets <dmytro_semenets@epam.com>
2023-09-01 17:44:15 +02:00
Andrei Emeltchenko
db7dced87c net: wifi_utils: Add missing break
Add missing break statement.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-01 16:37:34 +02:00
Alberto Escolar Piedras
9c0b12947e tests: interrupt util: Fix for native/posix targets
This utility header was accessing directly the interrupt
controller HW models, but those are not an interface one
can expect to not change, or to be avaliable in different
targets.
Instead we change it to use the APIs we have a contract
about, that is, the ones all POSIX arch boards are
expected to provide.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-01 09:54:27 +02:00
Emil Gydesen
76e35635b6 Bluetooth: Audio: Rename codec qos framing
Rename BT_AUDIO_CODEC_QOS_[UN]FRAMED to
BT_AUDIO_CODEC_QOS_FRAMING_[UN]FRAMED and give a name
to the enum, which is then used by the
struct bt_audio_codec_qos.

The rename was needed as we had a codec_qos initializer of the
same name, so the values were renamed to avoid duplicated
macro names.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-01 09:54:18 +02:00
Jukka Rissanen
8c573d6142 net: shell: Print user friendly network interface name
If network interface name support is enabled, print the name
when showing network interface data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 14:43:36 +02:00
Jukka Rissanen
7aa4904b5a net: socket: Change SO_BINDTODEVICE to use interface name
Make sure we use the network interface name (if configured)
instead of device name when binding to certain network
interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 14:43:36 +02:00
Jukka Rissanen
05b7eda618 net: Add name support to network interface
If CONFIG_NET_INTERFACE_NAME is enabled (default is y), then
system will automatically set a user friendly name to the network
interface like eth0, wlan0 etc.
Application can change the interface name if needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 14:43:36 +02:00
Gerard Marull-Paretas
68552f0c4c ipc: rpmsg_service: add missing init.h
File was using SYS_INIT without including init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-31 14:43:08 +02:00
Fabio Baltieri
56b4225126 logging: fix few mismatched CONTAINER_OF
Fix few mismatched CONTAINER_OF, few missing pointers to the first
element, one explicit casting.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-31 14:08:31 +02:00
Krzysztof Chruściński
cebd140bee logging: log_output: Add optional tid formatting
Add option to prefix log message with thread ID or thread name.
Align tests and add test case to the log_output test.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-08-31 14:08:19 +02:00
Krzysztof Chruściński
70dce83f14 logging: Add option to store tid in the log message
Add Kconfig LOG_THREAD_ID_PREFIX option which allows storing
thread id in the log message and process it as message prefix
(as id or thread name).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-08-31 14:08:19 +02:00
Morten Priess
ef5d0fd291 Bluetooth: controller: Fix ISO Transmit Test Mode parameters
Fix incorrect use of Max_SDU_Size and SDU_Interval parameters in
ISO Transmit Test Mode code.

Fixes EBQ test LL/CIS/PER/BV-08-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-31 10:34:14 +02:00
Mariusz Skamra
b4af917ad0 Bluetooth: audio: Change bt_audio_codec_cfg_get_val return value
This changes bt_audio_codec_cfg_get_val function to return the data
length found. Otherwise, this function gives no information about the
returned data length.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-31 10:21:07 +02:00
Fabio Baltieri
8450eec4a3 bluetooth: mesh: fix few mismatched CONTAINER_OF
Fix few mismatched CONTAINER_OF, one missing k_work_delayable_from_work
and few that should be pointing at the first elemnet.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-31 10:20:31 +02:00
Jukka Rissanen
7d3dabf07b net: wifi: Properly namespace public APIs
The twt and ps helper functions were not namespaced (were missing
wifi_ prefix).

Also change wifi_get_twt_... to more logical wifi_twt_get...
like the other twt prefixed functions and wifi_get_ps... to
wifi_ps_get... like the other ps prefixed functions.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 10:20:07 +02:00
Daniel DeGrasse
b2172a97d8 sd: clean up sizes of some SD data fields
Clean up sizes of some SD data fields, as the max value of these fields
is limited by the SD specification

Specifically, the limits are as follows:
num_io: 0-7, 3 bits (SDIO only)
relative_addr: 16 bits (SDMMC/MMC)
block_size: 12 bits (Max of 2KB, uint16_t used)
sd_version: 8 bits (currently at version 3)
card_speed: 8 bits (could potentially be reduced in size)

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-08-31 10:19:37 +02:00
Dominik Ermel
1c7b069853 mgmt/MCUmgr/grp/img: Reduce logic in img_mgmt_slot_to_image
Makes img_mgmt_slot_to_image image number independent and moves
it to header file as static inline.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-31 10:19:15 +02:00
Dominik Ermel
fe08ed65c0 mgmt/MCUmgr/grp/img: Simplify img_mgmt_get_unused_slot_area_id
Simplified and made CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER
independent.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-31 10:19:15 +02:00
Dominik Ermel
58b22bc4a9 mgmt/MCUmgr/grp/img: Improvement in image erase logic
The erase logic has been switched to using img_mgmt_get_opposite_slot
and the img_mgmt_get_other_slot has been removed.
The commit adds CONFIG_MCUMGR_GRP_IMG_ALLOW_ERASE_PENDING Kconfig
options, default set to n, that allows to make pending slot
erasable. The option only allows erase on pending slot that
is not revert slot.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-31 10:19:15 +02:00
Dominik Ermel
21c3263b95 mgmt/MCUmgr/grp/img: Reduce logic in img_mgmt_active_slot
Make img_mgmt_active_slot independent from
CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER for MCUboot swap type
algorithms.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-31 10:19:15 +02:00
Dominik Ermel
5739f2c6da mgmt/MCUmgr/grp/img: Switch to using img_mgmt_get_next_boot_slot
The commit modifies image list command operations to use
img_mgmt_get_next_boot_slot instead of directly relying of
MCUboot flags.
The function is now used, also, by img_mgmt_slot_in_use to
figure out whether queried slot is in use.
The commit introduces two new Kconfig options
 MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_SECONDARY
 MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_ANY
that allow users to enable confirming non-active images slots.
The MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_SECONDARY is y
by default to keep original behavior of logic that accidentally
allowed confirming secondary slot.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-31 10:19:15 +02:00
Dominik Ermel
81e98d2487 mgmt/MCUmgr/grp/img: Add img_mgmt_get_next_boot_slot
The commit adds functions:
 img_mgmt_get_next_boot_slot
 img_mgmt_get_opposite_slot

to simplify obtaining information on next boot slot.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-31 10:19:15 +02:00
Mads Winther-Jensen
f0c10d0332 Bluetooth: controller: Implement ISO link quality for CIS streams
Added optional support for read ISO link quality command.
Added link quality member in struct ll_iso_stream_hdr.

Signed-off-by: Mads Winther-Jensen <mdwt@demant.com>
2023-08-30 17:51:26 +02:00
Troels Nilsson
8ff4585270 Bluetooth: Controller: Check for duplicate handles in le_set_ext_adv_enable
If there are duplicate handles the Controller shall return the
error code Invalid HCI Command Parameters (0x12)

Fixes a failure in the EBQ test LE/AdvExt/Req-01 (part of the Ellisys
quality test suite)

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-30 15:18:16 +02:00
Riadh Ghaddab
5eaace1c01 ipc_service: static_vrings: fix num_desc return value
currently when no enough memory is found a (1 << (-1)) value is returned
instead of 0.
Fix this by returning 0 and simplify log2 computation

Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
2023-08-30 14:44:51 +02:00
Anders Storrø
8bb7a280eb Bluetooth: Mesh: Support for comp data page 129
Adds support for composition data page 129.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-30 14:14:49 +02:00
Troels Nilsson
d3f386d52b Bluetooth: Controller: Fix some incorrect asserts on connection
Fixes some incorrect assertions in ull_adv.c on connection establishment

Note that the usual checks using adv->lll.conn doesn't work here,
since ull_periph_setup() NULLs the lll's conn structure pointer
before stopping the ticker

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-30 13:48:59 +02:00
Bjarki Arge Andreasen
b4cf54b8c3 subsys/modem: Add modem modules
This PR adds the following modem modules to the subsys/modem
folder:

- chat: Light implementation of the Linux chat program, used to
        send and receive text based commands statically created
        scripts.

- cmux: Implementation of the CMUX protocol
- pipe: Thread-safe async data-in/data-out binding layer between
        modem  modules.

- ppp: Implementation of the PPP protocol, binding the Zephyr PPP
       L2 stack with the data-in/data-out pipe.

These modules use the abstract pipes to communicate between each
other. To bind them with the hardware, the following backends
are provided:

- TTY: modem pipe <-> POSIX TTY file
- UART: modem pipe <-> UART, async and ISR APIs supported

The backends are used to abstract away the physical layer, UART,
TTY, IPC, I2C, SPI etc, to a modem modules friendly pipe.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-08-30 13:48:51 +02:00
Gerard Marull-Paretas
4c86dbd4a6 logging: backends: adsp_hda: add missing init.h, device.h
File was using device.h/init.h API without including respective headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-30 11:54:48 +02:00
Gerard Marull-Paretas
528a6f5e79 logging: frontend_dict_uart: add missing init.h
File is using SYS_INIT, from init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-30 11:53:21 +02:00
Gerard Marull-Paretas
04ef8ca509 debug: gdbstub: s/device.h/init.h
File was not using any device.h API, but init.h (SYS_INIT).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-30 11:52:49 +02:00
Gerard Marull-Paretas
6ca6cff9c8 lorawan: services: add missing init.h
File was using SYS_INIT, from init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-30 11:37:53 +02:00
Daniel DeGrasse
06984353bf sd: ensure card variables are initialized in sd_ops
Ensure card CSD and CID variables are initialized in sd_ops functions
for reading card CSD and CID data.

Fixes #59562

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-08-30 11:37:04 +02:00
Robert Lubos
d8a96b1be0 net: sockets: tls: Implement TLS_DTLS_CID option
Add TLS_DTLS_CID socket option, which enables to use the Connection ID
extension for the DTLS session.

The option provides control of the use of CID with the `setsockopt()`
function. The value provided can disable, enable, and control whether to
provide a CID to the peer. It uses a random self CID (if told to provide
one to the peer) unless TLS_DTLS_CID_VALUE set previously.

Add TLS_DTLS_CID_VALUE to get or set the CID sent to the peer, if any.

Add TLS_DTLS_PEER_CID_VALUE to get the CID value provided by the peer,
if any.

Add TLS_DTLS_CID_STATUS to determine if CID used, and whether
bidirectional or one way.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
2023-08-30 11:36:51 +02:00
Gerard Marull-Paretas
b97bfa91f3 ipc: ipc_service: backends: rpmsg_static_vrings: add missing init.h
SYS_INIT was used without including init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-30 10:41:20 +02:00
Tom Finet
2b8762a438 bt: fix bt_l2cap_chan_send_sdu to return total bytes sent
bt_l2cap_chan_send_sdu previously returned the number of bytes sent
in the last sent sdu buf fragment or 0 if the buf has only
one fragment. bt_l2cap_chan_send_sdu now returns the total data
bytes sent from the buf.

Signed-off-by: Tom Finet <tom.codeninja@gmail.com>
2023-08-30 10:23:05 +02:00
Fabio Baltieri
a16f1cee4a bluetooth: host: fix few mismatched CONTAINER_OF
Fix a bunch of mismatched CONTAINER_OF, few missing
k_work_delayable_from_work conversions but also many
bt_l2cap_le_chan/bt_l2cap_chan and few others.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:22:37 +02:00
Thomas Ebert Hansen
00c5edd411 Bluetooth: controller: Fix LLCP enc. execution ctx
rp_enc_state_wait_ltk_reply() is executed in thread context, so
it is not allowed to move the encryption state machine forward.

Defer LTK reply handling to next prepare event by introducing a continue
state.

Update the unit test to reflect this, and remove the TODO that actually
said there was an issue in the first place.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2023-08-30 10:22:15 +02:00
Fabio Baltieri
d1504ff66f mcumgr: fix few mismatched CONTAINER_OF
Fix a missing first element reference in a CONTAINER_OF.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:22:00 +02:00
Fabio Baltieri
ece5380490 net: fix few mismatched CONTAINER_OF
Fix few mismatched CONTAINER_OF, few missing k_work_delayable_from_work
and a missing reference to the array first element.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:21:31 +02:00
Jakub Rzeszutko
14b1d0283c shell: make ascii filtering optional
Added configuration parameter to toggle shell ascii filtering
feature.

Fixes #59048

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2023-08-29 19:22:16 +03:00
Gerard Marull-Paretas
997ee481a1 usb: host: core: add missing init.h
File was using SYS_INIT without including init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 16:13:19 +01:00
Carlo Caione
4b713dc2e8 ipc_service: static_vrings: Fix misnamed define
VRING_ALIGNMENT was renamed to MEM_ALIGNMENT but it was forgotten in one
place. Fix it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-08-29 16:28:27 +02:00
Morten Priess
6985e6262f Bluetooth: controller: Add memory barrier to ticker transactions
Prevent compiler optimizations from changing the order of assignments in
the ticker API transactions. This could cause lost operation requests
and unexpected behavior under certain race conditions.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-29 16:14:50 +02:00
Emil Gydesen
86fd899bbf Bluetooth: PACS: Fix a couple of issues in PACS notify handling
There were a few issues in the way that PACS handled notifying:
1) A couple of dangling pointers (fixed by declaring some
   `static const struct bt_uuid`
2) Some wrong Kconfig guards were used

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-29 16:14:42 +02:00
Martin Jäger
7f7201f79b canbus: isotp: replace internal z_timeout with k_timer
The use of private APIs z_add_timeout() and friends is not recommended.

With this commit, usual kernel timer APIs are used.

Fixes #61738

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-08-29 16:14:35 +02:00
Georges Oates_Larsen
b25ea4742e net: conn_mgr: Rename connectivity monitor
The connectivity monitoring subfeature of conn_mgr is currently also
named conn_mgr, which is confusing.

This commit renames it to conn_mgr_monitor, or conn_mgr_mon for short,
for clarity.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-08-29 16:13:37 +02:00
Georges Oates_Larsen
2e762836d5 net: conn_mgr: binding get/set flag
Add a helper allowing connectivity implementations to more easily access
connectivity flags on connectivity bindings.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-08-29 16:13:37 +02:00
Georges Oates_Larsen
49a7798c30 net: conn_mgr: binding lock/unlock
Adds conn_mgr_binding_lock/conn_mgr_binding_unlock, which connectivity
implementations can call to lock or unlock the passed in connectivity
binding.

This allows connectivity implementations to safely make direct accesses
to binding data from outside conn_mgr_conn_api callbacks, and should
allow cleaner, more robust connectivity implementations to be written.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-08-29 16:13:37 +02:00
Georges Oates_Larsen
6d2ce0b30b net: conn_mgr: Create separate connectivity implementation API.
Splits many definitions from conn_mgr_connectivity.h off into their own
header, conn_mgr_connectivity_impl.h

conn_mgr_connectivity.h now focuses solely on user/application-facing
APIs, and conn_mgr_connectivity_impl now contains all functions, utils,
definitions intended for use by connectivity implementations, including
conn_mgr_if_get_binding, which is now available for use by connectivity
implementations.

This lays the foundation for allowing connectivity implementations
easier and safer access to their internal state through internal APIs.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-08-29 16:13:37 +02:00
Troels Nilsson
8a2a2bd613 Bluetooth: Controller: Add trpa cache for BT_CTLR_SW_DEFERRED_PRIVACY
Adds a target RPA known unknown cache; it fulfills a similar function
to the existing peer RPA cache, used for scanning of directed
advertisements

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-29 16:13:22 +02:00
Gerard Marull-Paretas
0aac6cfb75 usb: device_next: add missing init.h
Some files were using SYS_INIT, from init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 14:35:29 +01:00
Gerard Marull-Paretas
3970694674 sensing: sensor_mgmt: s/device.h/init.h
File was not using any device.h API, but init.h (SYS_INIT).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 12:17:24 +01:00
Gerard Marull-Paretas
8cf63ff367 net: lib: zperf: add missing init.h
File was using SYS_INIT without including init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 12:17:15 +01:00
Gerard Marull-Paretas
59946f16ca bluetooth: audio: s/device.h/init.h
File was not using any device.h API, but init.h (SYS_INIT).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 11:54:36 +01:00
Gerard Marull-Paretas
aa4ebc1f63 mgmt: ec_host_cmd: simulator: s/device.h/init.h
File is not using any device.h API, but init.h (SYS_INIT).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 11:54:19 +01:00
Gerard Marull-Paretas
fc45b3f2dd rtio: add missing init.h include
File was using init.h API without directly including the header.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 11:29:37 +01:00
Anders Storrø
3183ff3ff5 Bluetooth: Mesh: Add buf size check in comp p1 get
According to mesh 1.1 spec (4.4.1.2.2 Composition Data state):
“If the complete list of models does not fit in the Data field, the
element shall not be reported.“

The implementation of bt_mesh_comp_data_get_page_1 does
not consider this, and further it will assert the device if the passed
buffer is to small.

This commit adds a check that prevents populating passed buffer
if the full element entry wont fit in the buffer.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-29 12:17:42 +02:00
Carlo Caione
6ae34c9176 ipc_service: static_vrings: Fix buffer sizing
We are returning an off-by-one number of buffers in some circumstances,
fix the calculation.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-08-29 10:26:59 +02:00
Emil Gydesen
71b1591337 Bluetooth: CAP: Remove qos from start_stream_param
Remove the qos field from
bt_cap_unicast_audio_start_stream_param as it was not used.

The QOS values are set when creating the unicast group,
and not when starting the streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-29 10:22:43 +02:00
Rodrigo Peixoto
7e44469dcc zbus: improve the way of storing observers
ZBus stores observers in two ways: statically using a list and dynamically
using a memory slab. Both present limitations. Static observers work only
for channel definition. The dynamic observers rely on a memory slab that
forces the user to manage its size to avoid issues with adding
observers. This commit fixes the static allocation problem by using the
iterable sections for allocating observation data and replacing the VDED
execution sequence since now it is possible to prioritize static observer
execution. All the runtime observers are dynamically allocated on the heap
instead of a specific memory pool.

BREAK changes (only internal, not APIs):

* ZBus channel metadata changed. Remove the observers' static array
pointer. Rename the `runtime_observers` pointer to `observers`. Add
`observer_start_idx` and `observer_end_idx`;
* Change the VDED execution sequence. The position (on definition time),
the priority in conjunction with the lexical order, is considered for
static post-definition time observers. At last, the runtime observer
follows the adding sequence;
* Replace the `CONFIG_ZBUS_RUNTIME_OBSERVERS_POOL_SIZE` with
`CONFIG_ZBUS_RUNTIME_OBSERVERS`.

New APIs:

* New iterable section iterators (for channels and observers) can now
receive a user_data pointer to keep context between the function calls;
* New `ZBUS_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, _enable)` and
`ZBUS_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _queue_size, enable)` that
enable developers define disabled observers. They need to be enabled
during runtime to receive notifications from the bus;
* `ZBUS_CHAN_ADD_OBS` macro for adding post-definition static observers of
a channel.

Important changes:

* Move the ZBus LD file content to the `common-ram.ld` LD file. That was
necessary to make ZBus compatible with some Xtensa and RISCV boards.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2023-08-29 10:18:55 +02:00
Fabio Baltieri
7b59e34a22 mgmt: mcumgr: drop few redeclared/shadowed variables
Drop few redeclared variables, fixes some:

settings_mgmt.c:454:30: error: declaration of ok shadows a previous
local [-Werror=shadow]
  454 |                         bool ok;
      |                              ^~
settings_mgmt.c:436:14: note: shadowed declaration is here
  436 |         bool ok = true;
      |              ^~

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-28 17:17:24 +02:00
Emil Gydesen
6ccd112c56 Bluetooth: Audio: Refactor bt_audio_codec_cfg to flat arrays
Refactor the bt_audio_codec_cfg to use flat arrays to store
metadata and codec specific configurations.

The purpose of this is to make it easier to copy the data
between layers, but also to support non-LTV data for non-LC3
codec configurations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-28 15:56:53 +02:00
Fredrik Danebjer
32b00dd6f4 Bluetooth: Audio: Make BSIM tests for PACS notify functionality
Added a BSIM tests for PACS notification functionality. This test
tests that all optional notifies are working, as well as verifying
that a disconnected subscribed client will be notified on reconnect.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-08-28 15:56:26 +02:00
Fredrik Danebjer
2ebbc7b130 Bluetooth: Audio: Make PACS notify bonded clients on reconnect
This fix allows PACS to notify bonded clients, that were disconnected
when a characteristic with notify property was changed, are being
reconnected.

This fix also implements a defer work so to not block the bt rx
thread during auth callbacks. All other notify calls are for
consistency and style also moved to use the defer work.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-08-28 15:56:26 +02:00
Fredrik Danebjer
4c94056f74 Bluetooth: Audio: Make PACS optional notify actually optional
Added Kconfig options to make the various PACS characteristics that are
optionally notifiable selectable as notifiable. Selecting a
characteristic as notifiable will make it so for all pacs instance on
the device.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-08-28 15:56:26 +02:00
Nick Ward
2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Alberto Escolar Piedras
fd27bed45e cmake/toolchain: Support LLVM source profiling/coverage for native boards
Add a a new source coverage for native builds
and new kconfig choice of COVERAGE mode to select which:
* COVERAGE_NATIVE_GCOV: what we had until now with native builds
* COVERAGE_NATIVE_SOURCE: a new LLVM source coverage mode
* COVERAGE_GCOV: the old COVERAGE_GCOV (embedded gcov data generation).

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-28 10:35:21 +02:00
Fabio Baltieri
ec71be5d9d drivers,subsys: fix few missing k_work_delayable_from_work
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.

This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.

Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-28 10:12:21 +02:00
Konrad Derda
1d7d4f308c net: icmpv6: allow multiple handlers
This change allows to register additional handlers for ICMPv6 so the
user can handle some of the messages between they are handled by the
ICMPv6 module in Zephyr by returning NET_CONTINUE.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-08-28 08:24:31 +01:00
Robert Lubos
43015032b4 net: tcp: Fix corner case with closed listener
There was a corner case which was not handled well in a scenario, when
listening socket was closed during an active handshake with a new
client.

When a listening socket is closed, the accept callback is cleared on the
TCP context. If this happened during a handshake with a new client, i.
e. before final ACK from the client was processed, this lead to a
context leak, as application did not take ownership of the connection
(i. e. had no means to close it).

Fix this, by proactively closing the connection at the TCP level when no
accept_cb is available. Instead of ignoring the fact that no accept_cb
is available, the TCP stack will now enter TCP_FIN_WAIT_1 state and
proceed with a graceful teardown of the connection.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-08-27 07:35:34 -04:00
Robert Lubos
d5252cb5de net: sockets: Fix getsockname()
getsockname() did not work properly on bound sockets, as it verified
whether the socket has an active connection before retuning result. This
is not correct, as socket after bound may not have a connection yet.

Fix this, by verifying that local_addr on an underlying net_context is
set, to determine whether socket has a local address assigned, before
returning result.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-08-27 07:35:34 -04:00
Daniel Leung
169f505226 xtensa: add support for dc233c SoC for QEMU
This adds SoC and board configs to support the dc233c core
that is available on QEMU. This core has more features than
sample_controller, such as MMU support.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-26 16:50:40 -04:00
Georgij Cernysiov
f15508d505 net: lib: coap: refactor client init path options
* Renamed 'coap_client_init_path_options' to
  'coap_packet_set_path'
* Moved into 'coap.c'
* The function is public now

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-08-25 13:15:12 +02:00
Georgij Cernysiov
afbfdc5bd7 net: lib: coap: fix path and query options init
Fix options initialization for path and query
when a final segment is one character long.

For example, "a/b" inits path as ["a"] instead
of expected ["a", "b"]. The same applies to
query option. The "a/abc?a&b"  options won't
contain "b".

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-08-25 13:15:12 +02:00
Jamie McCrae
55527d8733 mgmt: mcumgr: Add settings management
Adds a settings management group to MCUmgr which allows for
manipulation of the zephyr settings from a remote device.
Includes callback hooks to secure access from an application.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-25 10:54:06 +01:00
Noah Luskey
e71840ed69 net: wifi_mgmt: Fix size calculation for net_mgmt info
net_iface_status is larger than scan_result, causing
net_iface events to be dropped due to info exceeding
NET_EVENT_INFO_MAX_SIZE.

Signed-off-by: Noah Luskey <LuskeyNoah@gmail.com>
2023-08-25 10:52:14 +02:00
Robert Lubos
6e1a205819 net: sockets: Fix connected datagram socket packet filtering
The previous patch to address race condition on STREAM sockets had a
side effect on DGRAM socket, where net_context_recv() is not only
installing recv callback, but also registering a connection at net_conn
level. Doing so before setting remote address first (which is done in
net_context_connect()) had an impact on the connected DGRAM socket
operation, which now accepted packets from any remote peer, and not only
the one socket was connected to.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-08-25 10:31:19 +02:00
Andreas Müller
d9bd2d2ff4 net: icmpv6: check for type < 128 rather than code < 128
ICMPv6 messages with type < 128 are error messages, where we should not
send back another error. The meaning of the code depends on the type.

Signed-off-by: Andreas Müller <andreas.mueller@husqvarnagroup.com>
2023-08-25 10:31:10 +02:00
Pavel Vasilyev
4fc1734917 Bluetooth: Mesh: Remove bt_mesh_beacon_priv_random_get as unused
This function is not used anywhere.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-24 22:09:57 +01:00
Pavel Vasilyev
8799286990 Bluetooth: Mesh: Don't compile priv_random if Priv Beacons not enabaled
This should fix unused variable issue when compiled with -Werror.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-24 22:09:57 +01:00
Seppo Takalo
40dd0c1fa0 tests: lwm2m: Add bootstrap tests into RD client tests
Add bootstrap and few corner cases into RD client tests
to improve code coverage.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-24 22:07:32 +01:00
Seppo Takalo
37f145a2d9 net: lwm2m: Ensure string termination when reading empty data
When resource data length is set to zero, we still need to
ensure that string reading will return an empty string.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-24 22:07:32 +01:00
Jamie McCrae
497b6eb44e retention: Drop prefix/checksum code if not used
Will exclude the code for prefix and checksum functionality if none
of the entries on a device make use of these features, saves ~816
bytes when both features are excluded.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-24 20:44:02 +02:00
Dominik Ermel
535278a3ba mgmt/MCUmgr/grp: Add missing const in mgmt_handler definitions
Make mgmt_handler definitions static const for shell and stat
groups.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-24 15:52:49 +02:00
Alberto Escolar Piedras
9eeb78d86d COVERAGE: Fix COVERAGE_GCOV dependencies
CONFIG_COVERAGE has been incorrectly used to
change other kconfig options (stack sizes, etc)
code defaults, as well as some samples behaviour,
which should not have dependend on it.

Instead those should have depended on COVERAGE_GCOV,
which, being the one which adds special code and
temporary RAM storage for embedded targets,
require changes to many features.

When building for the native targets, all this was
unnecessary.

=> Fix the dependency.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-24 15:36:31 +02:00
Gerard Marull-Paretas
9c961571a2 modules: cmsis: move glue code to modules/cmsis
The CMSIS module glue code was part of arch/ directory. Move it to
modules/cmsis, and provide a single entry point for it: cmsis_core.h.
This entry header will include the right CMSIS header (M or A/R).

To make this change possible, CMSIS module Kconfig/CMake are declared as
external, allowing us to add a new Zephyr include directory.

All files including CMSIS have been updated.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-08-24 13:20:21 +02:00
Juha Heiskanen
ea84ef55da mcumgr: img_mgmt_client: Fix Image upload max data length
MCUmgr client upload max data payload length was missing
Transport layer CRC + 16bit lenght. Full net buf packet was
possible to send but receiver side it was blocked because there
was not space for calculate CRC and length.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-08-24 12:57:10 +02:00
Mariusz Skamra
f69d83aedf Bluetooth: vocs: Retry sending notification on error
Retry sending notification was not sent due to e.g. lack of
buffers currently available.

Fixes: #57456
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Mariusz Skamra
de11c129fb Bluetooth: aics: Retry sending notification on error
Retry sending notification was not sent due to e.g.
lack of buffers currently available.

Fixes: #57452
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Mariusz Skamra
54b958af29 Bluetooth: vcp_vol_rend: Retry sending notification on error
Retry sending notification was not sent due to e.g. lack of
buffers currently available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Mariusz Skamra
26110d5a1b Bluetooth: micp_mic_dev: Retry sending notification on error
Retry sending notification was not sent due to e.g. lack of
buffers currently available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Morten Priess
cdbcdb8e14 Bluetooth: host: Fix endianness in hci_le_remove_iso_data_path
Add missing endianness conversion of handle sent over HCI.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-23 18:47:06 +02:00
YuLong Yao
716e3a17c1 net: wifi: shell: remove duplicate ap item
Remove two duplicate ap in wifi menu

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-08-23 16:08:51 +01:00
Sachin D Kulkarni
0467fb89ba net: wifi: Enhance help text for NET_L2_WIFI_MGMT
Changed Add to Enable in help text to convey the intended use of the
Kconfig NET_L2_WIFI_MGMT.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
419ffa54a7 net: wifi: Validate scan parameters
Add defensive check to validate scan command parameters.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
2c039026eb net: wifi: Add scan command option to print help
Add a scan command option to print the help text for the scan command.
This is to facilitate ease of using the command (since now there are
many different options added to the scan command).

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
b572e8216a net: wifi: Add scan extension for specifying channels
Add scan extension to allow limiting the scanning to specific channels.
Only 20 MHz channel specifications are allowed presently.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
01e167988c net: wifi: Add scan extension for limiting scan results
Add scan extension to allow limiting the scan results to a user defined
maximum number. This parameter is intended to return results with the
best RSSI. It cannot be counted upon to limit the scan times since the
Wi-Fi chips might have to scan all the channels to find APs with the
best RSSI values across all channels.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
5c399c2d17 net: wifi: Add scan extension for filtering SSIDs
Add scan extension to scan only for specific SSIDs.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
6328fda702 net: wifi: Add scan extension for passive channel dwell times
Add scan extension to control scanning time spent on channels where
passive scanning is used.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
3c130b138f net: wifi: Add scan extension for active channel dwell times
Add scan extension to control time spent on active scan channels.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
ee6c81896d net: wifi: Added scan extension support for frequency bands
Added scan extension to support scanning individual Wi-Fi bands or
combinations thereof.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
add1d15bee net: wifi: Modify option and argument for scan type
Modify the way the scan type option is passed to the wifi scan command.
This makes it flexible to add more scan options.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Mariusz Skamra
fc215282bc Bluetooth: audio: tbs_client: Fix missing discovery complete event
This fixes missing Fix bt_tbs_client_cb.discover call that has been
observed when CONFIG_BT_TBS_CLIENT_CCID was disabled. In such case the
discovery proces was not finished from application point of view,
as the callback was not called.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-23 15:44:07 +02:00
Mariusz Skamra
2b27b4ebe0 Bluetooth: audio: tbs_client: Subscribe to all required notifications
This removes odd `subscribe` parameter from bt_tbs_client_discover
function parameters list. As the API user enables specific
CONFIG_BT_TBS_CLIENT_* option, the client implementation should
subscribe to the characteristic notifications so that the user receives
the value updates.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-23 15:44:07 +02:00
Morten Priess
83fcbfd0be Bluetooth: controller: Fixes for CIS Central error handling
- Fix masking for no coded phy
- Allow ISO_Interval < SDU_Interval for framed mode
- Change BT_HCI_ERR_INSUFFICIENT_RESOURCES to
  BT_HCI_ERR_CONN_LIMIT_EXCEEDED.
- Prevent starting same CIS twice
- Cancel an initiated CIS creation procedure if terminated before
  sending CIS_IND.
- Implement canceling of local CC procedure. Respond to CIS_RSP with
  REJECT, if canceled after CIS_REQ was sent.
- Introduce state CIG_STATE_INITIATING for central, to keep track of
  initiating CIS connection, in transition between CONFIGURABLE and
  ACTIVE.

Fixes EBQ test /HCI/CIS/BC-03-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-23 14:45:24 +02:00
Mariusz Skamra
c563e7a1b8 Bluetooth: mesh: Fix uninitialized variable error
This fixes the error below:

main.c: In function ‘bt_mesh_provision’:
main.c:173:17: error: ‘node’ may be used uninitialized in
	       this function [-Werror=maybe-uninitialized]
  173 |                 bt_mesh_cdb_node_del(node, true);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-23 14:44:48 +02:00
Florian La Roche
5727503489 style: move ALWAYS_INLINE to the beginning to resolve compiler warnings
With gcc from the zephyr sdk and -Wold-style-declaration is giving this
output:
zephyr/arch/arm/core/aarch32/cortex_a_r/fault.c:101:1: warning:
  'inline' is not at beginning of declaration [-Wold-style-declaration]
  101 | static void ALWAYS_INLINE
                    z_arm_fpu_caller_save(struct __fpu_sf *fpu)
      | ^~~~~~

I searched to all of the source code to find these further occurances
where inline is not at the beginning of a function declaration.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
2023-08-23 14:44:23 +02:00
Emil Gydesen
271004adb1 Bluetooth: CAP: bt_cap_initiator_started called without unicast support fix
The bt_cap_initiator_started may be called in cap_stream_started_cb,
even if there is no unicast support. Added a guard for
CONFIG_BT_BAP_UNICAST to avoid calling an unlinked function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-23 14:43:43 +02:00
Christopher Friedt
e6c6d82a00 shell: date_service: conditionally include posix/time.h
When compiling for ARCH_POSIX, include `time.h` rather than
`posix/time.h`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-23 10:06:00 +02:00
Bi Jian
bc7205ebd3 Bluetooth: ISO: Fix invalid conn type check
The bt_conn_lookup_handle will check ISO type, if check failed, the
iso will be NULL and return.

Signed-off-by: Bi Jian <bi_jian@qq.com>
2023-08-22 18:11:54 +02:00
Alberto Escolar Piedras
392769e425 BT mesh: Rename shadow variables
Rename shadow variables found by -Wshadow

After e38fc6de8a
was merged, this cause CI failures.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-22 15:14:32 +02:00
Daniel Leung
e38fc6de8a cmake: enable -Wshadow partially for in-tree code
This enables -Wshadow to warn about shadow variables on
in tree code under arch/, boards/, drivers/, kernel/,
lib/, soc/, and subsys/.

Note that this does not enable it globally because
out-of-tree modules will probably take some time to fix
(or not at all depending on the project), and it would be
great to avoid introduction of any new shadow variables
in the meantime.

Also note that this tries to be done in a minimally
invasive way so it is easy to revert when we enable
-Wshadow globally. Source files under modules/, samples/
and tests/ are currently excluded because there does not
seem to be a trivial way to add -Wshadow there without
going through all CMakeLists.txt to add the option
(as there are 1000+ files to change).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
c32e28d079 usb: host: fixes shadow variables
This fixes a shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
b819a00b06 storage: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
93677ef58f settings: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
842a65914f net: lwm2m: ignore -Wshadow for cbor type header file
There are a few structs, unions, and enums where -Wshadow would
complain. Since names being the same are intentional, we need
to tell compiler to ignore -Wshadow for those names.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
2b09426fca net: zperf: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
5395ddfeb2 lorawan: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
8bfdb23a08 logging: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
8cdcf1a8cb ipc: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung
f02d40017f fs: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Thomas Ebert Hansen
8ae2eb53dc Bluetooth: controller: Handle invalid enc. pause
Reject LL_PAUSE_ENC_REQ while the ACL is associated with a CIS that is
created.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2023-08-22 10:53:47 +02:00
Sjors Hettinga
a8b03b7b93 net: tcp: Restructure the close FIN sequence
When the application closes the connection, it enters the FIN1 state.
Restructure this sequence to RST on data received after the application
has closed the socket.
Next to that deal with packets that contain both data and a FIN flag.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-22 10:00:14 +02:00
Mariusz Skamra
d28f180473 Bluetooth: audio: ascs: Move metadata validation to stack
As the metadata has to be validated anyway, let the initial vaidation of
metadata to be done in ASCS. The application can still reject the
metadata, but the length validation and supported type validation can be
performed by the stack.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-22 09:59:53 +02:00
Christopher Friedt
4a095bb34b net: sockets: support fionbio and fionread
The `ioctl()` interface is already supported by the network
subsystem but there was no `zsock_` interface available for it.

Add the `zsock_ioctl()` syscall.

Implement two somewhat commont ioctl requests for socket
file descriptors; namely

- `FIONBIO` set non-blocking I/O mode
- `FIONREAD` get the number of available bytes

In the process, added `net_pkt_ip_proto_hdr_len()`

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt
501c56cce7 net: socketpair: support for fionbio
Support for setting non-blocking mode via `ZFD_IOCTL_FIONBIO`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt
e0ac4eb5cd net: sockets: socketpair: support querying bytes available
In order to get a semi-accurate assessment of how many
bytes are available on a socket prior to performing a read,
BSD and POSIX systems have typically used

`ioctl(fd, FIONREAD, &avail)`

We can support this in Zephyr as well with little effort, so
add support for `socketpair()` sockets as an example.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt
1fa2ea1c82 net: sockets: tcp: split recv_stream into immediate and timed
Previously, if a net_context had multiple packets already in
the receive queue, and a call to zsock_recvfrom() was made with
a buffer large enough to receive content from multiple packets,
only the content from a single receive buffer would be received.

Since zsock_recvfrom() is a system call, which has a
non-negligible overhead, it makes sense to receive as many bytes
as possible per system call.

Add zsock_recv_stream_immediate() as a shorthand for
"fill this receive buffer with as many bytes as possible without
blocking". Allow nullable buffer parameters so that we can also
have a shorthand for "count how many bytes are immediately
available".

With minor refactoring, zsock_recv_stream_timed() is a simple
wrapper around zsock_recv_stream_immediate() that handles timing
and error conditions.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Benjamin Cabé
d22e08c067 pm: Fix unused-parameter warnings
Added a few missing ARG_UNUSED

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-21 17:15:56 +02:00
Morten Priess
250c6f5829 Bluetooth: controller: Prevent slot reservation update for JIT scheduler
When using the JIT scheduler (CONFIG_BT_CTLR_JIT_SCHEDULING), doing
ticker updates which only change the slot reservation, will fail.

For compatibility, the updates to ull.ticks_slot are preserved, as some
link layer implementations use this to predict collisions.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:54 +02:00
Morten Priess
8b98a93623 Bluetooth: controller: Modify reason for local CIS_TERMINATE procedure
When executing a local CIS_TERMINATE procedure, the reason sent to the
host must be changed to match the perspective of the initiator.

According to BT Core 5.4 Vol 4, Part E, section 7.1.6, the disconnect
reason must be BT_HCI_ERR_LOCALHOST_TERM_CONN for a local disconnect.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Morten Priess
42a108aad3 Bluetooth: controller: Prevent assert in ll_conn_iso_stream_get_by_acl
Do not assert in case of race conditions or asymmetric CIS
create/release. There are cases where ll_conn_iso_stream_get_by_group
legally returns NULL, and this should just cause for-loop continuing to
next iteration.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Morten Priess
44cdd881f4 Bluetooth: controller: Introduce CIS LLL flush states
To keep track of requested/pending CIS LLL flushing, change 'flushed'
binary state to 'flush' with states NONE, PENDING and COMPLETE.

This enables CIS teardown to know that a CIS already has a pending LLL
flush, and ULL does not need to initiate it.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Morten Priess
856e555b51 Bluetooth: controller: Fix HCI ISO header RFU bit masking
Mask out RFU bits in HCI ISO header to prevent set RFU bits leaking into
length values.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Dawid Niedzwiecki
63af3c00e9 mgmt: ec_host_cmd: add SPI SMT32 backend
Add support for SPI host command backend for STM32 chips family.

Unfortunately, the current SPI API can't be used to handle the host
commands communication. The main issues are unknown command size sent
by the host(the SPI transaction sends/receives specific number of bytes)
and need to constant sending status byte(the SPI module is enabled and
disabled per transaction). Thus the SPI backend includes basic SPI STM32
driver adjusted to host command specification.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-08-21 15:11:21 +02:00
Alperen Sener
2fe4493564 Revert "bluetooth: mesh: increase mesh scan window"
This reverts commit dbb0b30bdd.

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2023-08-21 11:48:36 +02:00
Carles Cufi
3f0d7012a6 Bluetooth: controller: Check minimum sizes of adv PDUs
While the maximum sizes were already correctly checked by the code, the
minimum sizes of the PDUs were not. This meant that PDUs smaller than
the minimum required length (typically 6 bytes for AdvA) were
incorrectly forwarded up to the Host.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-08-21 10:48:26 +01:00
Andrei Emeltchenko
2bf4ab625a shell: Set right SERIAL_INIT_PRIORITY if ACPI enabled
Set correct SHELL_BACKEND_SERIAL_INIT_PRIORITY if ACPI is enabled.
Otherwise when enabling SHELL using menuconfig, etc serial backend is
not working.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-08-21 10:55:52 +02:00
Anders Storrø
41addf67a9 Bluetooth: Mesh: Add ext timeout in PB for OOB I/O
Adds separate extended protocol timeout of 120 sec in provisioning
implementation when OOB method Input or Output is used. This
complies with recommendation in the mesh 1.1 protocol spec (5.4.4).

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-21 10:55:43 +02:00
Jamie McCrae
5c88d45544 treewide: mgmt: mcumgr: Change "ret" to "err" for SMP version 2
This is a stable API treewide change changing the newly introduced
"ret" response to "err" as it was overlooked that the shell_mgmt
group already used "ret" to return the exit code of the command
and this created a collision. Since SMP version 2 was only recently
introduced, there should not be any public implementations of it
as of yet, but the original function has been kept and marked as
deprecated.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-21 10:18:50 +02:00
Jamie McCrae
0001d01bfe mgmt: mcumgr: Allow additional cbor states for encoding
Allows selecting more than the default number of encoding states.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-21 10:12:06 +02:00
Jamie McCrae
8de70bc294 mgmt: mcumgr: transport: udp: Fix non-automatic start
Fixes a stray ifdef which causes a build failure if the automatic
UDP start Kconfig is not enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-21 10:11:50 +02:00
Emil Gydesen
a954157752 Bluetooth: BAP: Fix reset internal BASS state values on remove
A few fields of the internal state were not properly reset by
scan_delegator_rem_src.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-18 10:13:54 +02:00
Rubin Gerritsen
569d988585 Bluetooth: ISO: Don't call LE Create Conn Cancel on ISO disconnect
When calling `bt_iso_chan_disconnect()` while the channel is
connecting, the host should simply use HCI Disconnect.

Note: For the peripheral it is not allowed to call HCI Disconnect
on a CIS after it has accepted the CIS request, but before it has
received the CIS established event. The implementation in this
commit does not fix this case. In that case the controller will
return an error code.

Also, this commit does not handle the events following the
HCI Disconnect correctly.
In this particular case, two events are raised by the controller.
See Core_v5.4, Vol 6, Part D, Figure 6.51.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-18 10:13:36 +02:00
Grant Ramsay
07b2731de5 shell: Increase the default shell stack size for 64bit
The default stack size is too small on 64bit.
Some standard shell commands cause stack overflow

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-08-18 10:13:12 +02:00
Grant Ramsay
625cd1d1e3 net: ip: Make NET_QEMU_NETWORKING a named choice
Naming this choice allows setting a default value in defconfig.

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-08-18 10:13:12 +02:00
Anas Nashif
c8a9e445bb Bluetooth: BT_OTS_OACP_CHECKSUM_SUPPORT implies CRC support
BT_OTS_OACP_CHECKSUM_SUPPORT requires CRC to be enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 08:52:16 +03:00
Anas Nashif
ccba6d4143 mcumgr: do noy rely on CRC being enable, imply CRC in Kconfig
CRC is now disabled by default, so use imply to enable it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 08:52:16 +03:00
Anas Nashif
65e97fb03a retention: do noy rely on CRC being enable, imply CRC in Kconfig
CRC is now disable by default, so we need to enable it for retention
subsys.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 08:52:16 +03:00
Anders Storrø
254ee94fc0 Bluetooth: Mesh: Remove conflicting shell OOB func
Removes redundant mesh shell OOB implementation that makes
existing command implementation fail. Alters capabilities
CB to print provisionee caps.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-17 16:50:28 +02:00
Pavel Vasilyev
065e7571eb Bluetooth: Mesh: Fix usage of Identity and NRPA adv options for proxy
Both options are kind of mutually exclusive and can't be used together.
Also, USE_IDENTITY is used for debug purpose and could be useful when
debugging Private Proxy as well. Since CONFIG_BT_MESH_DEBUG_USE_ID_ADDR
is not allowed to be used in production, it is fine to use it for
Private Proxy advertisements as well.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-17 16:49:27 +02:00
Aleksandr Khromykh
2cdacb3fa8 tests: Bluetooth: Mesh: add cfg mesh with mbedtls PSA to bsim CI
Commit adds configuration for mesh with mbedtls PSA
to CI BabbleSim tests as well as emulation of
the Internal Trustable Storage(ITS) based on Zephyr's
settings to run in parallel environment.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-08-17 15:14:19 +02:00
Yong Cong Sin
3337c15707 tracing_user: let user implementation to do everything
Let's just let the user implementation to its things, like
checking, locking and stuff.
The tracing_user.c now just acts as a glue.

Moved previous implementation to its sample, and cleaned up
headers.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-08-17 15:13:17 +02:00
Emil Gydesen
1f9990fbd5 Bluetooth: Shell: Set newest conn as default_conn for central
When dealing with multiple connections in the shell as the central,
it is more often than not the newest connection you want
to interact with.

The behavior for the peripheral remains unchanged.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-17 13:11:14 +02:00
Daniel Leung
e3ecca5784 bluetooth: fixes shadow variables
Massaging code to fix shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-17 13:00:09 +02:00
Mariusz Skamra
1ff7b49a3a Bluetooth: audio: ascs: Remove redundant check
This removes redundant state check that is covered below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Mariusz Skamra
8dcec59115 Bluetooth: audio: ascs: Fix ASE state transition due to CIS link loss
This fixes ASE state transition to QoS Configured state that shall be
done autononously when CIS has been terminated due to link loss.

As per ASCS v1.0:
"If the server detects link loss of a CIS for an ASE in the Streaming
state or the Disabling state, the server shall immediately transition
that ASE to the QoS Configured state. Link loss of a CIS for an ASE in
any state other than Streaming or Disabling shall not cause a
transition of the ASE state machine."

Fixes: #60669
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Lukas Woodtli
3b4e54e39e net: coap: Add function to check for block option in message
The added function allows to check if a descriptive block
option was already added to a message.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 17:06:41 +02:00
Lukas Woodtli
e13e90914a net: coap: Add function for removing block transfer option
In some cases the options of a CoAP message are reused for
block transfer. Then the block header needs to be updated.
The current approach is to remove the old block option and
add an updated one.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 17:06:41 +02:00
Lukas Woodtli
6277a3904a net: coap: Add function for removing CoAP options
The provided function allows to remove a CoAP option in a
message. This is useful for reusing parts of a message.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 17:06:41 +02:00
Andrei Emeltchenko
451c4779c8 fs: ext2: Fix dereference before NULL check
It does make sense to dereference after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-08-16 15:04:48 +02:00
Andrei Emeltchenko
5d05b41b6a fs: ext2: Correct structure initialization
Correct structure initialization for ext2_lookup_args structre.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-08-16 15:04:48 +02:00
Andrei Emeltchenko
7d4c84b8a8 fs: ext2: Fix buffer overun
Rearrange check to make sure we do not access inode_pool[MAX_INODES].

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-08-16 15:04:48 +02:00
Andrei Emeltchenko
4170eb2433 fs: ext2: Remove comparing unsigned < 0
Remove never true comparisons for ext2.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-08-16 15:04:48 +02:00
Bi Jian
243516e6e5 bluetooth: audio: fix code comments error
Added PB_Flag 0b10:The ISO_SDU_Fragment field contains a complete SDU.

Signed-off-by: Bi Jian <bi_jian@qq.com>
2023-08-16 15:04:28 +02:00
Parthiban Nallathambi
2c4fb882bb modbus: use macro for function code for input register
use MODBUS_FC04_IN_REG_RD for input register reading function code 4.

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2023-08-16 14:58:47 +02:00
Magdalena Kasenberg
7bf502d806 Bluetooth: Audio: Fix missing setting of data and meta len
A recent refactor of bt_audio_codec_cap to flat arrays missed setting
data_len and meta_len fields.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-08-16 14:48:11 +02:00
Lukas Woodtli
038351ad26 net: lwm2m: Cleanup unnecessary code
The reply callback doesn't need to handle the case when the
code of the reply is 'continue' (2.31). In that case the callback
is not executed until the last block is transmitted.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 13:04:11 +02:00
Lukas Woodtli
2f6c0d7ca3 net: coap: Improve the handling of CoAP response code 'continue'
When using block-wise transfer, call the reply callback only when
the last block arrived.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 13:04:11 +02:00
Andreas Chmielewski
7df43f1ce3 net: lwm2m: Added support Conn Monitoring object version 1.3
This adds support for Coverage Enhancement Level.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-08-16 13:03:45 +02:00
Juha Heiskanen
be492db27b net: lwm2m: Fix race condition on Firmware object
Fix possible race conditions when state and results are written
by locking the registry, so a first write does not cause Notify
message to be send too early.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-08-16 13:03:07 +02:00
Sjors Hettinga
81650746f7 net: socket: Make the send timeout configurable
When the protocol layer like TCP is blocking transmission, the socket
layer will attempt and wait for a maximum amount of time before returning
with an ENOBUFS error.
This change allows to set the maximum waiting time from the configuration
file instead of using a fixed 10 second value.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-16 10:30:33 +02:00
Anders Storrø
e588e488e8 Bluetooth: Mesh: Unassign elem addr on comp unprov
Unassigns all element addresses when unprovisioning the composition
data.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-16 10:25:18 +02:00
Henrik Eriksen
b8564ac33e bluetooth: audio: csip: Unlock Non-bonded devices immediately.
Qualification test CSIS/SR/SP/BV-03-C [Lock Timeout]

Specification: Coordinated Set Identification Service Revision v1.0.1
Section 5.3.1.1.

When the server and the client are not bonded and they disconnect when
the value of the Set Member Lock characteristic is set to Locked, the
server shall set the value of the Set Member Lock characteristic to
Unlocked immediately after the disconnection.

Signed-off-by: Henrik Eriksen <heri@demant.com>
2023-08-16 10:25:11 +02:00
Henrik Eriksen
5a18f0dda7 bluetooth: audio: micp: Wrong error response for invalid Mute Value.
Qualification test MICS/SR/SPE/BI-01-C [Invalid Mute Value]

Specification: Microphone Control Service Revision v1.0 Section 3.1.1

If the client writes a value of Disabled or RFU to the Mute
characteristic, the server shall return an ATT Error Response with the
ATT error code Value Not Allowed (0x13) as defined in Assigned Numbers.

Signed-off-by: Henrik Eriksen <heri@demant.com>
2023-08-16 10:24:53 +02:00
Seppo Takalo
cb42c9b6bb net: lwm2m: Add delay also to exec callbacks
Bootstrap executable cause socket to be closed, so
it requires some delay for Ack to be send out as well.
Similarly, add small delay for Update trigger, so the
possible Ack goes out before the actual update message.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-16 10:21:46 +02:00
Seppo Takalo
01dab8690a net: lwm2m: Do not immediately close connection at Bootstrap
When BOOTSTRAP FINNISH message was received, it caused
engine to immediately switch to BOOTSTRAP_TRANS_DONE state
which then closed the connection.
Ack packet was still on the send-queue so it never got send before close().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-16 10:21:46 +02:00
Seppo Takalo
a13af44c7a net: lwm2m: All state changes should go through set_sm_state()
Some state changes were do by directly writing into
client.engine_state variable, followed by call next_event_at(0);
This causes hard-to-find side effects.

Refactor all state transitions to use set_sm_state() to have better
control for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-16 10:21:46 +02:00
Seppo Takalo
68b1fc8478 net: lwm2m: Wake up engine on pause/resume
Engine wake-up call was missing from pause/resume APIs
which caused delay.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-16 10:21:46 +02:00
Rubin Gerritsen
76dad61bf3 Bluetooth: Shell: Add value handle to notification print
This makes it possible to see what service the notification corresponds
to.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-15 21:56:07 +00:00
Rubin Gerritsen
e9d0340a99 Bluetooth: Shell: Fix the command bt adv-data
The command did no longer set the user specified data if the user
specified more than 1 AD field.

We were using the return value of ad_init() to set the number
of AD fields. This did not take into account the number of
existing data fields. By chance this usually returned 1.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-15 21:54:56 +00:00
Tobias Frauenschläger
6a7656ba48 net: tcp: Set correct source IP address when connecting
In case a TCP connection should be established with a specific source
IP address (e.g., by calling bind() prior to connect() on the socket),
we have to actually place the address in the outgoing packet.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-08-15 21:54:25 +00:00
Morten Priess
ed92ea94e8 Bluetooth: controller: Defer ticker stop after start
To prevent failure stopping a ticker node after starting it within the
same ticker_job execution (queued operations), defer the stopping until
after start. This will sequence the operations correctly and prevent
failures.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-15 21:54:00 +00:00
Morten Priess
fa61a047a6 Bluetooth: controller: Fix CIS Central FT calculation
For config CONFIG_BT_CTLR_CONN_ISO_RELIABILITY_POLICY, set
CIG_Sync_Delay fixed as high as possible, and calculate FT by iteration.
This favors utilizing as much as possible of the Max_Transport_latency,
and spreads out payloads over multiple CIS events (if necessary).

Add exit with cleanup as ll_cig_parameters_commit may fail after
creating new CIG/CIS instances.

Fixes issue #59605.
Fixes EBQ test HCI/CIS/BI-12-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-15 21:52:18 +00:00
Henrik Brix Andersen
1b3d1e01de canbus: isotp: convert SF length check from ASSERT to runtime check
Convert the ISO-TP SF length check in send_sf() from __ASSERT() to a
runtime check.

Fixes: #61501

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-08-15 10:08:23 -07:00
Emil Gydesen
53502cb417 Bluetooth: Audio: Make codec_cap const
There is no reason why the capabilities
should be modified by the stack after registration,
nor any reason why a the unicast client application
needs to modify the reported remote capabilities, so
all have been marked as const.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-15 11:14:29 +00:00
Emil Gydesen
aa990ae6dc Bluetooth: Audio: Refactor bt_audio_codec_cap to flat arrays
Refactor the bt_audio_codec_cap to use flat arrays to store
metadata and codec specific capabilities.

The purpose of this is to make it easier to copy the data
between layers, but also to support non-LTV data for non-LC3
codec capabilities.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-15 11:14:29 +00:00
Mariusz Skamra
76e17857e8 Bluetooth: audio: vocs: Refactor bt_vocs object
This adds refactor of bt_vocs object that is common interface for client
and server commands. As the bt_vocs_client is significantly larger than
bt_vocs_server the memory usage is not optimized when bt_vocs has an
union of those. Thus RAM consumption has been minimized by using
CONTAINER_OF macro to reference either to bt_vocs_client or
bt_vocs_server instance that bt_vocs is a member of.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-14 18:10:32 +00:00
Mariusz Skamra
e84d76f90b Bluetooth: audio: vocs: Fix missing instance type checks
The VOCS API uses `bt_vocs` object to reference both client and server
instance. This adds missing instance type checks to avoid invalid API
usage.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-14 18:10:32 +00:00
Pavel Vasilyev
ad0ea14b2f Bluetooth: Mesh: Add delay for Proxy Service registration
When settings_load() is not called from system workqueue, but still
called from a cooperative thread, rescheduling during the settings
loading can wake up system workqueue and try to register the Mesh
Proxy Service, which can not be allowed yet. This is the case for bsim
tests.

Postpone registering the service with some small timeout.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-14 18:09:54 +00:00
Mariusz Skamra
d74b9eb6b9 Bluetooth: audio: tbs: Fix possible buffer overflow
This fixes possible buffer overflow that may happen when `buf->len`
equals `buf->size` while adding null terminator.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-14 18:09:31 +00:00
TOKITA Hiroshi
90ffecdf2b fb: cfb: Remove unused value
The `desc` value in cfb_framebuffer_clear is not used.
Removed it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:59 +00:00
TOKITA Hiroshi
4681e0e1a4 fb: cfb: Remove sanity check for unused value
Remove needless sanity check

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:59 +00:00
TOKITA Hiroshi
330acf53d1 fb: cfb: remove font existence check on initializing
The font existence is checked at the time of linking,
The check at initialization is no longer necessary.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:12 +00:00
TOKITA Hiroshi
916b5ce799 fb: cfb: add font existence check at link time
Inject assert statement to linker script to check font existence.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-08-14 18:08:12 +00:00
Pavel Vasilyev
f997dc3842 Bluetooth: Mesh: Keep Composition Data Page 128 if RPR Server is present
According to section 4.2.2.4, Compositiion Data page 128 shall be
present if the node supports Remote Provisioning Server (section
4.2.2.4).

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-14 13:35:19 +00:00
Pavel Vasilyev
9122c514ab Bluetooth: Mesh: Use NRPA for private proxy advertisements
According to sections 7.2.2.2.4 and 7.2.2.2.5 of MshPRTd1.1v20,
when starting Private Node Identity or Private Network Identity, the
node shall use either RPA or NRPA and the advertising address. The
address shall be regenerated when Random field is regenerated.

Use BT_LE_ADV_OPT_USE_NRPA options to make advertiser generate and use
NRPA on every start of advertising Private Node Identity or Private
Network Identity.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-14 13:35:11 +00:00
Emil Gydesen
db2624def4 Bluetooth: BAP: Remove scan and PA sync from broadcast sink
This removes the scanning and PA sync capabilities from the
broadcast sink implementation, moving the responsibility of this
to the application layer.

The reason for this is to add more flexibility and choice to the
upper layers, while simplifying the Broadcast Sink implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:34:26 +00:00
Emil Gydesen
5b888c361d Bluetooth: BAP: Shell: Remove use of broadcast sink scan API
The broadcast sink scan API is no longer used by the BAP
shell, which handles everything related to PA sync and scan
itself now.

It has also been made easier to sync to a broadcast
source by simply using create_broadcast_sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:34:26 +00:00
Emil Gydesen
09116e1100 Bluetooth: Shell: Add selected_per_adv_sync
Add support for selecting a periodic advertising
sync object for use. This will also be available outside
the scope of bt.c via the extern declaration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:34:26 +00:00
Emil Gydesen
4f966de74b Bluetooth: CAP: Add cap stream send and tx sync
Add bt_cap_stream_send and bt_cap_stream_get_tx_sync for
CAP streams

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Emil Gydesen
8600356f98 Bluetooth: BAP: Add bt_bap_stream_get_tx_sync
Add bt_bap_stream_get_tx_sync to get the ISO tx info from a BAP
stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Emil Gydesen
e882847cf3 Bluetooth: BAP: Add can_send field to bt_bap_ep_info
This makes it easier to check if a stream, or ep, can send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Rubin Gerritsen
5e44f2761b Bluetooth: ISO: Fix HCI SDU length sent to controller
Fixes a race condition that could occur if the TX queue was read out
before iso_has_ts was set. In that case, the provided buffer is of
wrong length.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-11 09:12:12 +02:00
Mariusz Skamra
73be1430b2 Bluetooth: gatt: Fix setting actual error in notify_cb
This fixes return error from notify_cb function that was never set up.
As the result, the functions like bt_gatt_notify_cb and bt_gatt_indicate
returned invalid error when failed to send notification.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-10 16:01:01 +03:00
Fabio Baltieri
a534169ed4 input: rename callback define macro to INPUT_CALLBACK_DEFINE
Looking back at the current INPUT_LISTENER_CB_DEFINE api naming, it
feels like it's a bit overloaded. Rename it to a simpler
INPUT_CALLBACK_DEFINE.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-10 08:15:10 +00:00
Daniel Leung
5bc08ae3c6 net: rename shadow variables
Renames shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:43 +00:00
Daniel Leung
565c5d476e shell: rename shadow variables
This renames shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung
7c91228896 ztest: rename shadow variables
This renames the shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Andries Kruithof
ca6adf1364 Bluetooth: controller: some arguments are unsigned instead of int
There are some calls to ull_adv_aux_pdu_set_clear that are set to 0
but the argument is actually unsigned. This PR replaces the '0'
with '0U'

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-08-10 08:13:43 +00:00
Robert Lubos
cc77f2749c net: context: Remove shadowing variable in net_context_recv()
Remove the shadowing ret variable and fix a bug that was related to
its existence - the shadowing ret variable was assigned with -ETIMEDOUT
which was supposed to be retuned by the function, but was not because
the ret variable at the function scope was left intact.

Also remove the unneded goto unlock; jump (assigning the error code is
the last operation before unlocking the mutex anyway).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-08-09 20:01:39 -04:00
Jani Hirsimäki
83ea1e26a2 net: l2: ppp: ppp uart usage fixed
This fixes 3 issues that came within PR #59124 for ppp uart usage.

Earlier start/stop of ppp was done at enable() but that
was removed in PR #59124. Now putting enable/disable() back and
putting start/stop there.
Additionally, there was a double ppp carrier ON when NET_EVENT_IF_DOWN.
For that net_if_carrier_on/off is set in uart ppp.c driver.
Also, maybe worth to be mentioned that after PR #59124 there is no
ppp carrier off when lcp is disconnected, for workaround that change,
application should use ppp dead/running events.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2023-08-09 16:07:46 +00:00
Bruno Mendes
2510e1979b debug: arc: expose thread relinquish cause
When a thread is preempted on ARC, caller-saved registers
are saved on the stack automatically (RIRQ) or manually
by the kernel ISR (FIRQ).
Exposing the thread's relinquish cause hints the debugger
that it can read more or less register values.

Signed-off-by: Bruno Mendes <bd_mendes@outlook.com>
2023-08-09 16:06:57 +00:00
Ingar Kulbrandstad
d36697ac53 Bluetooth: Mesh: Fixed OP_AGG_SRV dependency of OP_AGG_CLI
The OP_AGG_SRV is dependent that the OP_AGG_CLI is add
for the OP_AGG_SRV to work. Moved the define of OP_AGG_CLI
so it will call op_agg_send without the OP_AGG_CLI.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-08-09 18:15:32 +03:00
Ingar Kulbrandstad
eafa2bb81b Bluetooth: Mesh: Fixed shell call to metadata-encode
The call to metadata-encode call in code and documentation
does does not match. Because the shell call in the documentation
looks correct the shell call in the code has been changed by
removeing the double metadata request.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-08-09 18:14:41 +03:00
Al Semjonovs
dee493d311 ztest: Fix test statistics reporting
Flaky tests give innacurate test summary indicating a misleading
passing test suite.  Add new status for flaky tests.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-08-09 07:38:22 -04:00
Morten Priess
d21e3e3514 Bluetooth: controller: Fix CIS offset equivalent calculation
First implementation had a math error where the offset would be the
remainder from division (modulo). It should have been an ISO interval
minus the remainder. Refactored to not use modulo.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:40:52 +00:00
Aleksander Wasaznik
8e5fd3990f Bluetooth: Host: Explicitly ignore return value of auth latch
Fixes a coverity-reported issue by explicitly ignoring the return value
of the cas-operation. The return value is the old value, but we are not
interested in it in the situation when we just want to initialize a
value if it is in the uninitialized state.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/60474

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-08-09 08:33:47 +00:00
Morten Priess
b0ab952ffe Bluetooth: controller: Prevent ULL stuck in semaphore
In certain scenarios, the semaphore sem_ticker_api_cb may be taken
during attempt to complete a synchronous ticker operation such as start
or stop, but is never released via ull_ticker_status_give. This could
happen if ticker temporarily runs out of ticker operation slots for any
ticker client.
The consequence of ULL stuck waiting in semaphore is anything from
allocation assertions to watchdog timeouts.

This commit also sets a timeout on ull_disable calls, which relies on
the disable callback being invoked from 'done'. Invocation of 'done' is
mandatory, and code shall not allow that not to happen, but to avoid
hiding the real cause, the semaphore now has a timeout which causes
assertion in the location the issue occurred.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:33:34 +00:00
Morten Priess
3ad58fde71 Bluetooth: controller: Introduce vendor ticker operations for ULL_LOW
Allow vendor configuration of addition ticker user operations for
TICKER_USER_ID_ULL_LOW.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:33:04 +00:00
Morten Priess
e1f4452798 Bluetooth: controller: Use mayfly_is_running() in csrand_get()
Check mayfly_is_running() to determine use of blocking- or non-blocking
version of lll_csrand, instead of k_is_in_isr().
As mayflies run in ISR context for Nordic platform, change will have no
impact on Nordic configuration.

For vendors using META_IRQ mayflies, implementation will now prevent
blocking and reduce latencies and jitter in soft-realtime code.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:32:55 +00:00
YuLong Yao
959e0e829d net: wifi: shell: fix parameter description error
command `wifi ap enable` not have SSID LENGTH parameter, remove it.

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-08-08 13:28:12 +00:00
Anas Nashif
37da312439 Revert "ztest: Fix test statistics reporting"
This reverts commit 2af5ac8fbb.

Failures are not being captured correctly now:

 - PASS - [test_c_lib.test_strtoul] duration = 0.001 seconds
 - PASS - [test_c_lib.test_strxspn] duration = 0.001 seconds
 - FAIL - [test_c_lib.test_that_fails] duration = 0.002 seconds
 - PASS - [test_c_lib.test_time] duration = 0.001 seconds
 - PASS - [test_c_lib.test_tolower_toupper] duration = 0.001 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-07 15:40:24 -04:00
Mykyta Poturai
d7241b0a2c fs: littlefs: use uintptr_t instead of int for dev_id
dev_id is used as a pointer at the end of the call chain, so passing it
as an int makes no sense and can cause crashes if the pointer and int
types have different sizes. For example, if we have 64-bit pointers on
a board, the higher part of dev_id will be removed due to an type cast.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-08-07 17:45:22 +00:00
Daniel Mangum
775a8e8c8d net: sockets: use DTLS in NET_SOCKETS_TLS_MAX_APP_PROTOCOLS
Updates NET_SOCKETS_TLS_MAX_APP_PROTOCOLS Kconfig option description to use
DTLS instead of DTL.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-08-07 11:27:33 +02:00
Troels Nilsson
70f62adbde Bluetooth: Controller: Fix bug in read_codecs_v2()
The loop for copying the vendor specific codecs was using num_std_codecs
instead of num_vs_codecs

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-07 11:27:13 +02:00
Seppo Takalo
321db8561d net: lwm2m: Restructure LwM2M Kconfig menu
* Create submenu for protocol versions.
  Like LwM2M 1.0 vs 1.1. Object versions.
* Create submenu for engine features.
  Containing all engine tweaks that are not directly from
  protocol specification.
* Create submenu for all memory tuning options.
  For example maximum number of certain objects, buffer
  sizes, etc.
* Order all objects by object ID and show the ID in
  title.
* When multiple options depend on same feature, group
  them under if <option> ... endif. Preferably directly
  after the selection itself.
* Move IPSO and uCIFI menuentries one sublevel up.
* Drop deprecated entries to bottom.

No functional changes, just clean up of Kconfig menu.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-07 11:26:47 +02:00
Konrad Derda
409b15c7ce net: event: provide complete information about the prefix in events
At the moment, NET_EVENT_IPV6_PREFIX_ADD and NET_EVENT_IPV6_PREFIX_DEL
events provide provide information about an address without its length
and lifetime.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-08-07 11:25:40 +02:00
Florian Grandel
01ba923bb2 tracing: segger-sysview: fix display formatting
Fixes several minor display errors in the Segger SystemView output:
* Off-by-one error in some trace ids.
* Add missing syscall trace id.
* Displays easier to read syscall function names.
* Fixes syntax error in k_timer_start output.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-08-06 07:44:06 -04:00
Tomasz Moń
0ab14d94b8 usb: device: Fix transfer slot leak without callback
Log transfer status and release transfer semaphore regardless if user
provided transfer completion callback or not. This fixes transfer slot
leak when transfer without callback completes.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-08-04 22:54:17 +00:00
Dmitry Lukyantsev
34a966f219 doc: Fix a typo
Fix a typo in the spelling of "current".
Add "current" to spelling.txt.

Signed-off-by: Dmitry Lukyantsev <dmitrylu@google.com>
2023-08-04 21:18:43 +00:00
Jonathan Rico
4433ff7154 Bluetooth: l2cap: add debug print for EATT
Add debug print when a buffer intended for ECRED is segmented
unnecessarily.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
2bbda0fbe4 Bluetooth: att: allocate RSP buffer from same channel as REQ
Using a different channel for responding to a request is forbidden by spec.

The allocator was especially flawed as it iterated over all the EATT
channels to find one w/ a big enough MTU, but the sending was still done
over the same channel as the REQ.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
e195ae2d09 Bluetooth: att: re-use REQ buf for RSP
This to ensure we don't fail to send a response and never get an ATT
TIMEOUT due to ACL TX buffer starvation caused by other users of the stack.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
828be80986 Bluetooth: att: use a dedicated metadata struct for RSP PDUs
The ATT module has provisions to queue a packet/buffer for sending later if
it can't send it right away. For example if the conn.c tx context
allocation fails.

This unfortunately doesn't work if the buffer can't get allocated in the
first place, or if the ATT metadata can't also be allocated.

The metadata is allocated from a global pool set to the same number as
conn.c TX contexts. That can lead to a situation where other users of ATT
manage to queue a bunch of buffers (e.g. the app spamming GATT
notifications), depleting the number of ATT metadata slots so that none are
available.

When none are available, and we receive an ATT REQ, we try to allocate one,
fail, and drop the buffer (!). That pretty much guarantees an ATT timeout.

As a workaround for this, use a per-channel metadata slot, that is only
used for completing transactions.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
ad36d0d9cc Bluetooth: att: log address on timeout
This is useful in multilink scenarios, especially since there is not user
callback when the ATT channel times out.

Adding a user-facing callback should ideally also be done, but just logging
the address already provides useful insight.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
32f719122e Bluetooth: att: return INSUFFICENT_RESOURCES on PDU alloc failure
Easier to debug that way.

Ideally we'd have more error codes/logging instead of just returning
UNLIKELY for most errors.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Sjors Hettinga
8cd5d6f267 net: tcp: Log the steps in the collision avoidance
To allow insighed into the correct functioning of the collision avoidance,
log the internal values and function calls.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-04 15:05:17 +02:00
Sjors Hettinga
5b640ec9db net: tcp: Implement TCP new Reno collision avoidance
To avoid a TCP connection from collapsing a link, implement a collision
avoidance algorithm. Initially TCP new Reno is implemented for its
simplicity.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-04 15:05:17 +02:00
Jamie McCrae
4b9dddcd3a mgmt: mcumgr: grp: os_mgmt: Add force parameter to reset command
Adds the force parameter to the reset command which is now
provided to the callback hook (if enabled).

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-04 12:17:07 +02:00
Jamie McCrae
9023a8e14f mgmt: mcumgr: grp: stat_mgmt: Use zcbor decode bulk function
Uses the zcbor decode bulk function instead of manually parsing the
array in the function to reduce duplicated code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-04 10:44:29 +02:00
Jamie McCrae
8616e6ac01 mgmt: mcumgr: grp: os_mgmt: Use zcbor decode bulk function for echo
Uses the zcbor decode bulk function instead of manually parsing the
array in the function to reduce duplicated code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-04 10:44:29 +02:00
Franciszek Zdobylak
1eb104795e fs: ext2: Use disk structs to access data on disk
This commits changes how data on the disk is accessed. There are disk
structures which are packed and their fields are stored in little endian
byte order. To use data in the program structures it has to be translated
from little endian to cpu endianness.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
984bdab456 fs: ext2: update how memory is allocated in ext2
- `ext2_file` and `ext2_dir` merged into one struct and allocated from
  dedicated slab
- `ext2_inode` allocated from dedicated slab
- `ext2_disk_dentry` allocated from heap (because their size is not
  constant)
- `ext2_bgroup` and `ext2_disk_superblock` statically allocated

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
1f62d99e7e fs: ext2: Update memory writes
Fix the behavior when data should be written to storage device. Now all
writes are done directly to disk_access layer (where it might possibly
be cached).

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
b3eec79f5b fs: ext2: Interpret s_errors field in superblocks
Added funtion that takes specified action when file system corruption is
detected. Possible actions are: do nothing, make mount point read-only,
panic.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
dfd845b131 fs: ext2: fix blocks and inodes handling
Changes:
  - Added few assertions to check if some assumptions are correct
  - Fix removing blocks during trucate and inode removal
  - Clear entry in inode table after inode has been removed

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
b814246764 fs: ext2: create correct file system in mkfs
Changes:
  - Add fs::sync function
  - Make correct file system in mkfs
  - Add few assertions to ensure that all assumptions are correct

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
d18a0d5872 fs: ext2: impl fs_sync
Introduce fs_sync function

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
655fd6f4bb fs: ext2: implement rest of directory operations
Introduced functions:
  - opendir
  - readdir
  - closedir

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
666404538c fs: ext2: implement rename
Introduce fs_rename function.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
f793e0b3c3 fs: ext2: implement unlink
Introduce fs_unlink function.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
685682ff49 fs: ext2: implement fs_truncate
Introduce fs_truncate function.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
a87cc6c0b6 fs: ext2: File operations
Introduced functions:
  - read
  - write
  - seek
  - tell

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
def5e7dad2 fs: ext2: implement fs_stat
Introduce fs_stat function.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
64da407ea5 fs: ext2: create dir and file operations
Introduced functions:
  - open
  - close
  - mkdir

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak
1eccf55102 fs: ext2: Implementation of basic operations
Included operations:
  - mount
  - unmount
  - mkfs
  - statvfs

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Al Semjonovs
2af5ac8fbb ztest: Fix test statistics reporting
Flaky tests give innacurate test summary indicating a misleading
passing test suite.  Add new status for flaky tests.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-08-03 11:08:47 -04:00
Herman Berget
b0e9cb3f48 Bluetooth: Host: Use RPA as responder address if BT_PRIVACY=y
When a PAwR sync connects to a PAwR advertiser and CONFIG_BT_PRIVACY
is enabled a Resolvable Private Address will be used. Use that
as responder address instead of the identity address to match what
the central sees.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-08-03 13:18:27 +02:00
Troels Nilsson
0a2d538c2b Bluetooth: Controller: Remove separate done memq
The separate done memq was introduced to handle the old LLCP
stalling processing of the rx queue; This is no longer an issue with
the new LLCP, so we can remove it

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-02 16:39:45 +02:00
Donatien Garnier
e4bcd6b92c Bluetooth: Host: Check connection status before sending credits
Upon receiving a L2CAP PDU, only send credits back if the L2CAP channel
hasn't been disconnected. The recv() callback called from
l2cap_chan_le_recv() can trigger a disconnect, which would cause an
assert failure when attempting to send credits back.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-08-02 14:06:40 +02:00
Sjors Hettinga
6783848b8f net: ppp_l2: Make prio of PPP TX thread configurable
The PPP TX thread handles the transmission of packets at PPP layer.
Make it's priority configurable, so it's priority can be configured higher
then higher protocol layers.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-02 14:04:55 +02:00
Sjors Hettinga
cb31883e1b net: tcp: Make priority of TCP work queue configurable
The TCP work queue is handles all TCP transmission and maintenance tasks.
Make it's priority configurable, so it can be configured to a lower
priority than the lower level network layers to avoid it consuming all
net_bufs before handing over execution to the lower layer network layers.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-02 14:04:55 +02:00
Seppo Takalo
838ab80bca net: coap: Use 64bit timestamps
Use 64bit timestamps from k_uptime_get() so they don't
roll over during the expected device lifetime.

Fixes #60826

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 15:40:04 +02:00
Seppo Takalo
518bbc1303 net: lwm2m: Refactor RD client to be tickless
Call RD client service only when there is state transitioning.
Remove periodic 500 ms timer.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Seppo Takalo
2da8844d19 net: lwm2m: Add support for non-periodic services
Engine now allows registering service callbacks that are
called only once on a given timestamp.
This allows tickless services to be developed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Seppo Takalo
1dfa711167 net: lwm2m: Create socketpair that can wake up zsock_poll()
Allow socket-loop to wake up immediately, if there are changes,
instead of waiting for zsock_poll() to timeout.
This change makes engine more reactive and removes
hard coded timeout from zsock_poll().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Mariusz Skamra
d511ef44ed Bluetooth: audio: tbs: Refactor service definition macro
This removes code duplications by unifying GTBS and TBS service
definition macros.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-01 11:58:56 +02:00
Mariusz Skamra
49fefcfddf Bluetooth: audio: tbs: Fix List_Item_Length value in CCL
This fixes setting invalid List_Item_Length in Current Calls List.
The fix complements 9c7ef8e.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-01 11:58:39 +02:00
Lars Knudsen
96bc04f7ac shell: Fix faulty error check in bt shell
bt_addr_le_to_str returns a length of bytes needed
for string conversion, not an error code.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-07-31 19:39:26 +00:00
Jonathan Rico
a7cf7eb393 Bluetooth: l2cap: change connected cb call condition for ECRED
This was recently refactored (in #58440). But it introduced a bug in which
some channels were connected but not the whole list asked for by the peer.

In that case, `result` will not be `SUCCESS` but we still want to call the
`connected` callback as the peer will consider those channels to be
connected when we send the response.

The symptom is that EATT channels are being instantiated, but not
considered connected (ie. usable by the stack).

Also introduce a test that has asymmetric channel resources (5 on central
vs 2 on peripheral) to reproduce the bug.

Fixes #60212

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-07-31 19:39:09 +00:00
Jonathan Rico
8f3e0fdc02 Bluetooth: att: fix bt_eatt_count()
Make `bt_eatt_count()` return what it says on the tin, ie. the number of
channels that are actually connected.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-07-31 19:39:09 +00:00
Rafał Kuźnia
edc21bd50c ipc: fix icmsg-me maybe-uninitialized compile warning
The sent_bytes variable was not initialized in all possible execution
branches before return.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2023-07-31 17:04:14 +02:00
Seppo Takalo
c8ac3070cc net: sockets: socketpair: Allow statically allocated socketpairs
When the target board does not have heap by default, allows
statically reserving the space for required socketpairs.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-07-31 14:49:05 +02:00
Sjors Hettinga
1f3cb08fdc net: tcp: Remove trigger of send_data_timer when window full
Likely this trigger of the send_data_timer was an alternative for the
function that has been filled in by the ZWP transmission.
At the moment this timer has the potential to cause spurious
retransmissions that can degrade the throughput of the network stack.
Second to that it can accelerate the retransmission process, quickly
running to the number of retransmissions, causing a connection failure.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-07-31 14:05:58 +02:00
Jamie McCrae
a0a9539d02 mgmt: mcumgr: grp: Fix error translation function indent
Fixes lines not being indented and looking like a single blob

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-31 12:49:36 +02:00
Emil Gydesen
0081ecd626 Bluetooth: ISO: Add advanced broadcast ISO parameters
Add support for setting advanced broadcast ISO parameters
using the ISO test commands. This allows the host to set
ISO parameters that the controller normally would handle.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Emil Gydesen
5a66daa94d Bluetooth: ISO: Add broadcast RTN check in valid_chan_io_qos
The RTN value range for broadcast is more limited than
connected ISO.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Emil Gydesen
63aca8d868 Bluetooth: ISO: Add advanced unicast ISO parameters
Add support for setting advanced unicast ISO parameters
using the ISO test commands. This allows the host to
set ISO parameters that the controller normally would
handle.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Jamie McCrae
588f6acbd5 mgmt: mcumgr: grp: img_mgmt: Fix not checking write bounds
Fixes an issue whereby the data packets were not checked to ensure
that the client has not attempted to write more data than the size
that was provided in the original upload packet.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-31 10:43:54 +02:00
Jamie McCrae
9422fc6e20 mgmt: mcumgr: grp: img_mgmt: Fix not checking image upload size
Fixes an issue whereby upload image size would not be checked in
the first packet of an upload, which would allow an image to be
uploaded until it reached the point of it being too large to
fit anymore.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-31 10:43:54 +02:00
Jamie McCrae
097c568c81 mgmt: mcumgr: grp: fs_mgmt: Fix wrong error checking
Fixes an issue with not properly checking error responses.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-31 10:43:28 +02:00
Sjors Hettinga
e14935ec6c net: tcp: Avoid partial ACK canceling retransmission timer
At any ack, the retransmission timer was cancelled. This means when an ACK
is only partially acknowledging pending data, followed by a packet loss,
the connection ended in a deadlock eventually timing out.
By checking if there is any pending data for transmission before canceling
the retransmission timer, there is no risk of this lock-up any more.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-07-31 10:09:05 +02:00
Théo Battrel
ff54350ef0 Bluetooth: Host: Remove 'Experimental' flag of EAD
Nordic Semiconductor has been testing the feature extensively on its CI.
The tests includes the sample data and the PTS tests.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-07-28 17:48:16 +02:00
Grant Ramsay
e98fa4e590 canbus: isotp: Enable TX padding by default if RX padding is required
It would be strange to enforce padding for other bus participants but not
use it yourself. This default suggests the likely proper usage, although
it is not a hard dependency

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-07-28 09:08:20 +00:00
Grant Ramsay
42dcc4e57f canbus: isotp: Fix ISO-TP padding config usage
ISOTP_ENABLE_TX_PADDING makes the device transmit frames with TX padding.
ISOTP_REQUIRE_RX_PADDING ensures other devices on the bus use TX padding,
by rejecting non-padded RX frames

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-07-28 09:08:20 +00:00
Florian Grandel
a4cd5cee40 drivers: ieee802154: consistent high res timestamps
The IEEE 802.15.4 API and networking subsystem were using several
inconsistent timestamp resolutions and types. This change defines all
timestamps with nanosecond resolution and reduces the number of
available types to represent timestamps to two:
* `struct net_ptp_time` for PTP timestamps
* `net_time_t` for all other high resolution timestamps

All timestamps (including PTP timestamps) are now referred to a
"virtual" local network subsystem clock source based on the well-defined
types above. It is the responsibility of network subsystem L2/driver
implementations (notably Ethernet and IEEE 802.15.4 L2 stacks) to ensure
consistency of all timestamps and radio timer values exposed by the
driver API to such a network subsystem uptime reference clock
independent of internal implementation details.

The "virtual" network clock source may be implemented based on arbitrary
hardware peripherals (e.g. a coarse low power RTC counter during sleep
time plus a high resolution/high precision radio timer while receiving
or sending). Such implementation details must be hidden from API
clients, as if the driver used a single high resolution clock source
instead.

For IEEE 802.15.4, whenever timestamps refer to packet send or receive
times, they are measured when the end of the IEEE 802.15.4 SFD (message
timestamp point) is present at the local antenna (reference plane).

Due to its limited range of ~290 years, net_time_t timestamps (and
therefore net_pkt timestamps and times) must not be used to represent
absolute points in time referred to an external epoch independent of
system uptime (e.g.  UTC, TAI, PTP, NTP, ...).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Florian Grandel
69212bb169 doc: drivers: ieee802154: radio API
Improves the documentation of the IEEE 802.15.4 radio API.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Johann Fischer
aecb1ca2e7 usb: device: move the content of usb_msc.h to implementation file
The usb_msc.h header does not provide any API. The content is only
used by the MSC implementation for the current USB device stack and
is not required for any use of MSC by the application.
The content has no proper namespace and must not be reused for
anything else in (new) USB support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-28 07:09:48 +02:00
Juha Heiskanen
d77a657526 mgmt: smp: MCUmgr Client support
MCUmgr client basic implementation for support Image and OS grpup
commands.

Image Group:
* Image state read/write
* Image Upload secondary slot
* Image Erase secondary slot

OS group:
* Reset
* Echo service, disabled by default

Opeartion's are blocked call and cant't call inside worker queue.
IMG and OS need to be SMP client object for transport.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-07-27 14:35:43 +02:00
Juha Heiskanen
5797e4241e mgmt: smp: SMP Client enabler
SMP client support for generate request and handling
response message.

Updated SMP transport for send request.

Added API for register SMP transport.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-07-27 14:35:43 +02:00
Jamie McCrae
8ecedf2dfb mgmt: mcumgr: grp: img_mgmt: Fix renamed define
Fixes an issue whereby a define was renamed in one place but not
another.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-27 11:16:04 +02:00
Rubin Gerritsen
88f161778a Bluetooth: Controller: Kconfig: Move BT_LL_SW_SPLIT specific configs
These configs are very tied to the BT_LL_SW_SPLIT implementation,
so it makes sense that these are only visible when that link layer is
used.

For the ones that may be used by other controllers in the future,
a dependency has been added.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-07-27 10:20:55 +02:00
Troels Nilsson
c0649ef694 Bluetooth: Controller: Fix truncation of adv. data
Truncation of advertising data has to be done at a PDU
boundary; Including only part of a PDUs advertising data is
not allowed

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-27 10:20:18 +02:00
Troels Nilsson
e0370f5439 Bluetooth: Controller: Stop following aux ptr if DATA_LEN_MAX is hit
If the aux scanner already has CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX
advertising data, there is no point in following an aux ptr -
instead flush the data and produce an incomplete report

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-27 10:20:18 +02:00
Jakub Rzeszutko
bdeb62d116 shell: fix possible negative indexing
Fixes #60808

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2023-07-27 10:20:04 +02:00
Gerard Marull-Paretas
a05371d353 pm: state: allow disabling certain power states
In some platforms it may be desirable to disable certain CPU power
states, for example, because they have extra requirements not available
on all boards/applications. Because `cpu-power-states` are defined at
SoC dts file levels, the only way to achieve that now was by re-defining
`cpu-power-states` property in e.g. a board file. With this patch, one
can now selectively set `status = "disabled";` to any power state and it
will be skipped by the PM subsystem.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-26 16:49:00 +02:00
Gerard Marull-Paretas
68452bd4cc pm: device_runtime: allow calling pm_device_runtime_get from ISRs
pm_device_runtime_get() uses a semaphore to protect resources.
pm_device_runtime_get() blocked forever until obtaining the lock, making
it unusable from contexts where blocking is not allowed, e.g. ISRs. With
this patch, we give the chance to use the function from an ISR by not
waiting on the lock and returning -EWOULDBLOCK instead. If device is
suspending (from a previous put_async() operation) the same value is
returned as we can't wait either.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-26 16:48:51 +02:00
Johann Fischer
7bfec37247 usb: device: clarify the impact of Kconfig option USB_COMPOSITE_DEVICE
Effectively, this option changes code triple in device descriptor.
Although the name is misleading, renaming it would again lead
to negative user experiences. Instead, clarify what the option does
and always select it where it is required.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-26 14:37:15 +02:00
Jamie McCrae
7ca7f5a39c mgmt: mcumgr: Use MCUboot bootutil file instead of outdated copy
Uses the MCUboot bootutil image.h file directly instead of an
outdated copy which resides in the zephyr tree.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-26 14:32:20 +02:00
Johann Fischer
e6bfc7f868 usb: fix common misspellings in USB support
Fix common misspellings in USB device next and host.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-26 10:46:01 +02:00
Jordan Yates
5be8664e8d pm: device: add driver init helper
Adds a helper function for initializing devices into the expected power
state, through the devices `pm_device_action_cb_t`. This eliminates code
duplication between the init functions and the PM callback.

The expected device states in order of priority are:
 * No power applied to device, `OFF`
 * `zephyr,pm-device-runtime-auto` enabled, `SUSPEND`
 * Otherwise, `ACTIVE`

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-26 08:16:44 +00:00
Girisha Dengi
75547dd522 soc: arm64: Add agilex5 soc folder and its configurations
Add Agilex5 soc folder, MMU table and its configurations for
Intel SoC FPGA Agilex5 platform for initial bring up.
Add ARM Cortex-a76 and Cortex-a55 HMP cluster type.

Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
Signed-off-by: Girisha Dengi <girisha.dengi@intel.com>
2023-07-25 16:58:01 +00:00
Robert Lubos
b2314c8362 net: if: Add functions to loop over IPv4/IPv6 addresses
Add new net_if API functions which allow to loop over all valid
IPv4/IPv6 addresses assigned to the interface and execute a callback
function on them.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-25 14:18:54 +02:00
Jordan Yates
6edab1f050 Revert "pm: device: add driver init helper"
This reverts commit 84016c1cd3.
2023-07-25 14:17:11 +02:00
Robert Lubos
30382daf88 net: wifi_shell: Add user input validation for SSID and PSK
When parsing user input for "wifi connect" and "wifi ap enable"
commands, the SSID and PSK lengths were not verified. It's better to
detect invalid connect/AP enable parameters early, so that help text can
be printed, instead of letting wifi_mgmt command to fail.

For WIFI_SECURITY_TYPE_SAE, follow the Linux convention of limiting the
size to 128 bytes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-25 14:16:17 +02:00
Robert Lubos
a22f7e777b net: dhcpv4: Accept unicast replies
Some DHCPv4 servers do not respect BROADCAST flag set on DHCP Discover,
replying with unicast packet, making it impossible to obtain DHCP
address by Zephyr in such cases.

RFC1542 chapter 3.1.1 makes the following statement about the BROADCAST
flag:
    This addition to the protocol is a workaround for old host
    implementations.  Such implementations SHOULD be modified so
    that they may receive unicast BOOTREPLY messages, thus making
    use of this workaround unnecessary.  In general, the use of
    this mechanism is discouraged.

Making it clear that being able to process unicast replies from the DHCP
server is not only an optional behavior, but a recommended solution.

Therefore, introduce a support for unicast DHCPv4 in Zephyr. To achieve
this, add additional filtering rule at the IPv4 level - in case DHCPv4
is enabled, there is an active query and the packet is destined for the
DHCPv4 module, let it through for the DHCPv4 module to process,
regardless of the destination IP address.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-25 14:15:45 +02:00
Jonathan Rico
0a8bbbda4a Bluetooth: adv: add USE_NRPA advertising option
Allows the application to force the use of an NRPA.

This is applied regardless of any other roles running (ie scanner) or
advertising type.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-07-25 10:47:37 +02:00
Alperen Sener
dbb0b30bdd bluetooth: mesh: increase mesh scan window
Increaing mesh scan window in order to reduce the number
of messages colliding into scan window end which happens
every 30ms currently. Increasing the window to 3000ms in
order to improve performance.

Keeping 30ms window only for legacy advertiser support.

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2023-07-25 09:23:12 +02:00
Grant Ramsay
e439b5e56d canbus: isotp: Fix context buffer memory leaks
Ensure context buffers are free'd when errors occur

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-07-25 09:15:13 +02:00
Daniel Leung
287916c71e logging: sys_t/catalog: fix unaligned access
When copying parameters into payload buffer, it is possible
that after copying a string over, the pointer to buffer is
no longer aligned on 4 or 8 bytes. And some toolchains may
decide to treat the copy as aligned since the values being
copied are 4 or 8 bytes. This results in unaligned memory
access and hardware exception. So change the copy to memcpy
to avoid potential unaligned access.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-25 09:14:17 +02:00
Troels Nilsson
00f3e44689 Bluetooth: Controller: Fix missing endianness conversion in scan_enable
Both duration and period are uint16 and thus require endianness conversion

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-25 09:14:02 +02:00
Andrzej Kuros
a04a059ccc net: ieee802154_radio: add attribute getter API
The `attr_get` method is added to the ieee802154_radio to allow
reading of driver specific attributes of given device.

The enum `ieee802154_attr` provides common extension pattern
allowing to extend the attribute set.

Accessor function `ieee802154_radio_attr_get` is provided.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
2023-07-25 09:13:41 +02:00
Jordan Yates
84016c1cd3 pm: device: add driver init helper
Adds a helper function for initializing devices into the expected power
state, through the devices `pm_device_action_cb_t`. This eliminates code
duplication between the init functions and the PM callback.

The expected device states in order of priority are:
 * No power applied to device, `OFF`
 * `zephyr,pm-device-runtime-auto` enabled, `SUSPEND`
 * Otherwise, `ACTIVE`

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 09:13:16 +02:00
Nicolas Pitre
d1a50e540b subsys/usb: move to timepoint API
Remove sys_clock_timeout_end_calc() usage.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Nicolas Pitre
bd3ed97230 subsys/net: zperf_udp_uploader: Remove sys_clock_timeout_end_calc() usage
The initial goal was to remove sys_clock_timeout_end_calc(). However,
several related issues have been fixed as well.

First this:

    int64_t print_interval = sys_clock_timeout_end_calc(K_SECONDS(1));
    /* Print log every seconds */
    int64_t print_info = print_interval - k_uptime_ticks();

    if (print_info <= 0) {
        [...]
    }

The above condition will simply never be true.

Then there is lots of back-and-forth time conversions using expensive
base-10 divisions for each loop iterations which is likely to impact
performance.

Let's do the time conversion only once outside the loop and track
everything in terms of ticks within the loop. Also the various timeouts
are open-coded based on the absolute uptime tick so to sample it only
once per round. Using sys_timepoint_calc() and sys_timepoint_timeout()
would have introduced additional uptime tick sampling which implies the
overhead of a downstream lock each time for no gain. For those reasons,
open coding those timeouts bears more benefits in this particular case
compared to using the timepoint API.

Then this:

    secs = k_ticks_to_ms_ceil32(loop_time) / 1000U;
    usecs = k_ticks_to_us_ceil32(loop_time) - secs * USEC_PER_SEC;

The above should round down not up to work accurately. And the usecs
value will become garbage past 1.2 hour of runtime due to overflows.

And no need to clamp the wait period which is on the microsec scale
using the total duration argument being on the millisec scale. That's
yet more loop overhead that can be omitted. The actual duration is
recorded at the end anyway.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Nicolas Pitre
7238b48182 subsys/net: zperf_tcp_uploader: move to timepoint API
Remove sys_clock_timeout_end_calc() usage.
While at it, remove dead last_print_time variable.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Nicolas Pitre
603cdaa032 subsys/net/lib/socket: move to timepoint API
Remove sys_clock_timeout_end_calc() usage and custom timeout_recalc().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Nicolas Pitre
13d68185d5 subsys/net: move to timepoint API
Remove sys_clock_timeout_end_calc() usage.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Nicolas Pitre
a7b3584745 subsys/zbus: move to timepoint API
Remove sys_clock_timeout_end_calc() usage as well as custom
_zbus_timeout_remainder().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Nicolas Pitre
52e2f83185 kernel/timeout: introduce the timepoint API
This is meant as a substitute for sys_clock_timeout_end_calc()

Current sys_clock_timeout_end_calc() usage opens up many bug
possibilities due to the actual timeout evaluation's open-coded nature.

Issue ##50611 is one example.

- Some users store the returned value in a signed variable, others in
  an unsigned one, making the comparison with UINT64_MAX (corresponding
  to K_FOREVER) wrong in the signed case.

- Some users compute the difference and store that in a signed variable
  to compare against 0 which still doesn't work with K_FOREVER. And when
  this difference is used as a timeout argument then the K_FOREVER
  nature of the timeout is lost.

- Some users complexify their code by special-casing K_NO_WAIT and
  K_FOREVER inline which is bad for both code readability and binary
  size.

Let's introduce a better abstraction to deal with absolute timepoints
with an opaque type to be used with a well-defined API.
The word "timeout" was avoided in the naming on purpose as the timeout
namespace is quite crowded already and it is preferable to make a
distinction between relative time periods (timeouts) and absolute time
values (timepoints).

A few stacks are also adjusted as they were too tight on X86.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Mariusz Skamra
c2402a4368 Bluetooth: att: Make bt_att_chan_create_pdu static function
This fixes missing `static` function specifier.
The bt_att_chan_create_pdu is not called outside of att.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-24 09:09:58 +00:00
Mariusz Skamra
0fa7c01adc Bluetooth: att: Remove unused bt_att_free_tx_meta_data function
This function seems to unused thus can be safely removed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-24 09:09:44 +00:00
Anders Storrø
878d15cf94 Bluetooth: Mesh: Align handling of seg_ack to spec
Updates the handling of incoming seg ack messages to comply with
the mesh protocol specification, section 3.5.3.3.2 and section
3.5.3.3.3.

Previous implementation did not restart the retransmission timer unless
the incoming ack contained at least one segment newly marked as
acknowledged. According to the spec, the timer should be restated
regardless. The implementation depends on the retransmission
timer to end the transmission early if there was no more retransmission
attempts. Checks have been added to ensure that this now happens
immediately.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-07-24 09:07:59 +00:00
Lucas Mathias Balling
b8546150a3 Bluetooth: Controller: Added ISO CH feature bit check in le_create_cis
Check that the Isochronous Channels (Host Support) feature bit is set
before creating a CIS.

Signed-off-by: Lucas Mathias Balling <lutb@demant.com>
2023-07-24 09:06:32 +00:00
Vinayak Kariappa Chettimada
63f718f9b8 Bluetooth: Controller: Fix coverity issue 318648
[Coverity CID: 318648] Explicit null dereferenced in
subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Fixes #59002.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-24 09:05:06 +00:00
Emil Gydesen
bf153e576b Bluetooth: CCP: Fix coverity issue for current_inst == NULL
In discover_next_instance coverity did not consider the
ASSERT and warns about possibly dereferecing current_inst
which could be NULL. Modifed the code slightly to make
Coverity happy.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-21 10:54:01 +00:00
Jamie McCrae
ee5c9b2629 mgmt: mcumgr: grp: img_mgmt: Add image data written callback
Adds an optional callback upon image data being written, can be
used for syncing or timeout purposes.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-20 14:55:46 +00:00
Jamie McCrae
6c541e1af0 mgmt: mcumgr: Add event ID index callback function
Adds a function which gets the callback ID index of a given
event ID.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-20 14:55:46 +00:00
Flavio Ceolin
ddd2bc94e2 bt: mesh: shell: Fix possible buffer overflow
Fix possible overflow in rpr_scan_report.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Flavio Ceolin
e55af04e65 bt: audio: shell: Fix possible buffer overflow
Check the size of the search argument in cmd_media_set_search
before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Flavio Ceolin
02e70f509f bt: audio: shell: Fix possible buffer overflow
Check the size of the search argument in cmd_mcc_send_search_raw
before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Flavio Ceolin
fbd56fd920 bt: host: Fix possible buffer overflow
Check in bt_conn_le_start_encryption if the given
ltk fits in bt_conn.ltk before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Robert Lubos
51726f3648 net: l2: ieee802154: shell: Validate address on input
Associate command handler did not validate the provided address length.
In result, if provided address string was longer than the expected
extended address size, strncpy() would not NULL terminate the buffer,
which could lead to unexpected behavior in parse_extended_address(), as
it expects NULL terminated string.

Fix this by validating the length of the provided address string before
parsing.

Additionally, make parse_extended_address() return the parsing result,
so that it can be detected when provided extended address has incorrect
format.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-20 10:47:39 +00:00
Magdalena Kasenberg
6135ae0fa0 bluetooth: audio: ascs: Fix Codec Config initiated by server
The Codec Specific Configuration Parameters provided by server was
not copied at bt_ascs_config_ase. Detected by PTS in BAP/USR/SCC PTS
test cases, because no LTV values appeared in ASE Codec Configured
notification.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-07-20 10:46:55 +00:00
Jamie McCrae
ecfbabd213 mgmt: mcumgr: Make SMP version 2 to legacy error lookup extensible
Replaces the manual lookup function with a lookup function which
is provided when registering MCUmgr handlers which can be used to
find the function to translate error codes, allowing out of tree
MCUmgr handlers to provide error translation handlers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-20 10:35:14 +00:00
Gerard Marull-Paretas
e1eedd1a9f pm: require pm_state_set/pm_exit_post_ops
Any system supporting PM must now implement
pm_state_set/pm_exit_post_ops. Before this change any platform could
enable CONFIG_PM=y, even though it did nothing, ie, no power savings at
all.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-20 10:33:00 +00:00
Gerard Marull-Paretas
3d2194f11e pm: introduce HAS_PM
Add a new Kconfig option that has to be selected by SoCs providing PM
hooks. This option will be now required to enable CONFIG_PM. Before this
change, CONFIG_PM could always be enabled, regardless of SoC providing
any kind of low-power support.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-20 10:33:00 +00:00
Gerard Marull-Paretas
26bf349ab1 pm: drop HAS_NO_PM
Remove HAS_NO_PM option, in preparation for a new HAS_PM option
(inverted logic).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-20 10:33:00 +00:00
Chen Caidy
0635e2690e net: gptp: fix announce message byte order
Linuxptp report UTC offset is 9472 seconds, is a byte order issue,
The right value is 37. Also fixed offset_scaled_log_var byte order.

Signed-off-by: Chen Caidy <chen@caidy.cc>
2023-07-19 21:42:05 -04:00
Chen Caidy
413eceeddb net: gptp: fix follow_up message correction_field
According to IEEE802.1AS Table 11-6 and 10.6.2.2.9,
802.1AS using peer-to-peer delay mechanism, two-step clock,
Grand master clock should keep this correction_field as zero.

Signed-off-by: Chen Caidy <chen@caidy.cc>
2023-07-19 21:42:05 -04:00
Chen Caidy
762df873b4 net: gptp: fix follow_up message timestamp
According to IEEE802.1AS 11.4.4.2.1, we need fill
preciseOriginTimestamp as syncEventEgressTimestamp.

In this follow_up message, prec_orig_ts need to filled
from net_pkt_timestamp(sync) for best accuracy. state machine
is software trigger with insufficient precision.

After this change, a grand master endpoint sync accuracy
increase from 3.5ms to 580ns with mimxrt1050_evk board.

Signed-off-by: Chen Caidy <chen@caidy.cc>
2023-07-19 21:42:05 -04:00
Stine Åkredalen
e5fcca6e99 Bluetooth: mesh: Update default values for transport SAR configuration
Updated SAR default values to align with the latest mesh 1.1 drafts,
and relevant Bsim tests.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-07-19 11:07:07 +00:00
Anas Nashif
b7ec7ec638 debug: thread_analyzer: use printk by default
When enabling thread analyzer, use printk by default. Otherwise logging
subsystem is enabled which might not be desired.

Fixes #59919

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-07-19 11:06:04 +00:00
Tomasz Moń
e47fc45c4d usb: audio: correctly report internal delay
Every USB device must buffer isochronous data for at least 1 frame in
order to remove packet jitter within a frame. USB Specification Revision
2.0 describes necessary buffering in 5.12.5 Data Prebuffering. USB Audio
1.0 specification mentions buffering in 3.4 Inter Channel Synchronization.

Set bDelay to 1 instead of 0, because bDelay 1 is both the minimum
allowed value and matches the actual device behavior.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-07-19 08:27:00 +02:00
Emil Gydesen
bbbc28a0ba Bluetooth: CAP: Always register BAP callbacks with CAP callbacks
Modified bt_cap_stream_ops_register to always register BAP callbacks
to ensure that the callbacks are always forwarded (unless later
overwritten by the application...)

The CAP Initiator Unicast will still register the callbacks itself,
to ensure that the unicast procedures still work even if
bt_cap_stream_ops_register was never called.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:11:12 +00:00
Emil Gydesen
a2ceded56f Bluetooth: ASCS: Update ISO QOS based on BAP QOS
When a CIS is established for the peripheral, then not all
QOS values are completely valid as they are simply missing
from the CIS established event. This commit updates the
missing fields based on the QOS settings provided by the
BAP Unicast Client during QoS Configuration of the endpoint.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:09:51 +00:00
Tristan Honscheid
ce3d0af183 emul: Don't panic if matching emul can't be found
When initializing emulators for devices registered on an emulated bus,
Zephyr will assert if a matching emulator for the device cannot be
found. This feels overly restrictive --there may be cases where we still
want to build a driver for testing even without an emulator and drivers
should be able to handle situations where there is no device emulator
present (the I2C/SPI transactions will simply fail and the driver never
becomes ready).

This commit removes the assert and replaces it with an warning message if
no matching emulator is found.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-18 11:09:08 +00:00
Mariusz Skamra
c09c4181cf Bluetooth: audio: tbs_client: Minor Kconfig refactor
This intoduces dedicated Kconfig option to enable TBS client,
that makes the configuration more intuitive.
While configuring GTBS only, the user does not have to explicitly set
the BT_TBS_CLIENT_MAX_TBS_INSTANCES to 0 to disable the TBS client
functionality.
This adds also `tbs_only_client` test case to test the TBS only build
option.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:06:57 +00:00
Mariusz Skamra
650a0d8331 Bluetooth: audio: tbs_client: Separate GTBS from TBS instances
This improves the code readability and reduces flash usage a bit by
spliting up GTBS from other TBS instances in bt_tbs_server_inst
structure, so that some of the code could be conditionally compiled
out.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:06:57 +00:00
Mariusz Skamra
9fa4543994 Bluetooth: audio: ascs: Defer ASE state transition
This adds handling of ASE control point operations in separate thread
so that the notifications of ASE state changes are sent from non-BT
thread. This ensures bt_gatt_notify_cb to be blocking waiting for
available buffers to send the notifications.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:05:03 +00:00
Mariusz Skamra
03d296d546 Bluetooth: audio: ascs: Remove unused variable
The `ops` variable is unused, thus can be removed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:05:03 +00:00
Carlo Caione
1fcb929108 ipc_service: open-amp: Add __ASSERTs on cache alignment
Add some asserts to warn the user about unaligned VDEV status area,
VRINGs and buffers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-18 11:04:46 +00:00
Carlo Caione
9752cbe045 ipc_service: open-amp: Align VRINGs
This patchset is doing three things:

1. It is fixing the bogus algorithm to find the optimal number of
   descriptors for a given memory size.

2. It is changing values for VDEV_STATUS_SIZE and
   IPC_SERVICE_STATIC_VRINGS_ALIGNMENT to better align to a usual cache
   line size.

3. RX/TX VRINGs are now correctly aligned to MEM_ALIGNMENT (and cache
   line alignment).

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-18 11:04:46 +00:00
Emil Gydesen
bdd83e7239 Bluetooth: CAP: Shell: Add support for specific audio configs
Add CAP shell commands for starting specific audio configurations
based on the BAP specification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:04:25 +00:00
Emil Gydesen
b140b70a17 tests: CAP: Add testing of all audio configs
Add test cases to test all audio configurations with
all presets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:04:03 +00:00
Kyra Lengfeld
c607179cc4 Bluetooth: Controller: Add missing nRF53x Tx Power Kconfig
This commit adds missing tx power config options for nRF53x SoCs, as
well as the missing Radio defines for nRF53x SoCs.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-07-17 21:41:08 +00:00
Chaitanya Tata
7a6288a871 net: l2: wifi: Fix printing of TWT parameters
Use the macro to print to handle for cases where shell context is NULL,
this is possible because in this net management event handler shell
context is not passed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-17 13:21:39 +00:00
Anders Storrø
0e35bbbfd2 Bluetooth: Mesh: Add missing CBs for cfg_cli msg
Adds callback API for the following config client status messages:
- Composition data status
- Model publication status
- SIG model subscription list
- Vendor model subscription list
- Netkey list
- Appkey list
- SIG model app list
- Vendor model app list
- Key refresh status
- Heartbeat publication status
- Heartbeat subscription status

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-07-17 10:13:14 +00:00
Emil Gydesen
388af8fda4 Bluetooth: BAP: Remove stream->dir field
The BAP stream object should not have a dir field. The
dir field should be stored in the EP only (to avoid having two
fields storing the same value, causing possible issues).

The field was removed, and the places that use it has been updated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-14 16:48:41 +00:00
Emil Gydesen
983864e4d8 Bluetooth: BAP: Shell: Add support for multiple TX streams
Add support for transmitting on multiple streams, e.g.
with the simple `send` command or with the sine generator.

This extends the start and stop sine to take a "all"
paramter to start sending on all streams.

This also fixes an issue with the seq_num when multiple
streams are transmitting, since the timing may get delayed
which then delays the seq_num which are then scheduled too late.
The fix here is to only use the timer for the inital sequence
number when starting to send the sine way, and then increment it
per TX.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-14 16:47:42 +00:00
Dominik Ermel
ebaa145818 mgmt/MCUmgr/img: Fix build issue with slot0_ns_partition
The commit fixes build issue when building for two application
images in board that does not have slot0_ns_partition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-07-14 17:49:02 +02:00
Dominik Ermel
cb4aa46faf mgmt/MCUmgr/img: Fix img_mgmt_get_other_slot
Fix conditional compilation within img_mgmt_get_other_slot,
where CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER has been
incorrectly checked and #endif incorrectly placed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-07-14 17:48:40 +02:00
Carles Cufi
5824e95b1e Bluetooth: Host: Introduce BT_CONN_PARAM_ANY
Some controllers support additional connection parameter ranges
beyond what is described in the specification. Enabling this new option
allows the application to set any value to all connection parameters.
Tbe Host will perform no limits nor consistency checks on any of the
connection parameters (conn interval min and max, latency and timeou).
However, the Host will still use numerical comparisons between the
min and max connection intervals in order to verify whether the
desired parameters have been established in the connection.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-07-14 09:40:52 +00:00
Dawid Niedzwiecki
c590c5c1ee mgmt: ec_host_cmd: add suppressing commands
Add a feature to suppress commands. The suppressed commands are not
logged on the command reception.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-14 09:38:20 +02:00
Robert Lubos
c15e3d448c net: conn_mgr: Create conn_mgr thread dynamically
Statically created threads with K_THREAD_DEFINE() are launched only
after the SYS_INIT phase. This does not play well with NET_CONFIG
library, which may block during SYS_INIT until network interface
is UP and RUNNING.

In order to be able to connect to L2 network and thus mark the
network interface as running and unblock NET_CONFIG, we need to be
able to run conn_mgr thread during SYS_INIT. This can be achieved,
by starting the thread dynamically during SYS_INIT phase, instead
of relying on static thread creation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-14 09:37:37 +02:00
Robert Lubos
cc81dca556 net: if: Fix if_ipv4_get_addr() locking
net_if_lock() should be called only after iface pointer is verified not
to be NULL, otherwise we can end up dereferencing NULL pointer in
certain corner cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-14 09:37:14 +02:00
Alberto Escolar Piedras
913920a06f ztests: Enable native specific functionality with embedded libCs
When building with the native simulator instead of attempting to
call directly to the host libC, use the trampolines provided
by the runner.
In this way we can build this code even if we are building
Zephyr with an embedded C library.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-13 07:44:11 -04:00
Alberto Escolar Piedras
9be7b59b4a ctf tracing: native/host backend: Refactor to support embedded C libraries
Split this tracing backend in a top and bottom to enable
building it with embedded libCs with the native simulator.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-13 05:47:08 -04:00
Mariusz Skamra
1ca75e3b6e Bluetooth: audio: ascs: Fix invalid memset of QoS parameters
This fixes invalid memset of QoS parameters that may happen if Config
Qos operation is requested on ASE in QoS Configured state. In such case
if the requested parameters have been rejected, the ASE QoS parameters
shall remain unchanged (were memset instead). Otherwise, the stack shall
send QoS Configured state notification with cleaned up parameters (all
zero's) which was not done.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-13 09:23:24 +02:00
Dawid Niedzwiecki
cf3b0381ae mgmt: ec_host_cmd: fix init of npxc shi backend
Make sure not to access not assigned pointer at the begining of the
initialization.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-13 09:21:08 +02:00
Jordan Yates
83b1a983a9 net: lib: tls_credentials: earlier initialisation
The TLS credentials libraries are purely software constructs with no
external dependencies, run them immediately after the kernel setup to
allow other initialisation functions to add credentials without the
requirement to run in the back half of the `APPLICATION` priority.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-12 14:50:09 +02:00
Anders Storrø
8c7ffac4a6 Bluetooth: Mesh: Fix err in mod_app_list packing
Fixes erroneous packing/unpacking of model app list messages
in the configuration client and server. According to the mesh 1.1
protcol spec (4.3.1.1) two app indexes shall be packed in a 3 octet
interleaved format. The current implementation packs them in 4 octets.

This commit also provide a helper function for unpacking key indexes
as public API to facilitate future config model callback API.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-07-12 14:37:23 +02:00
Emil Gydesen
b9c16c9cdd Bluetooth: ISO: Add comment for peripheral SDU size
Adds a comment stating the state of the peripheral SDU size
and why it is being assigned the PDU size on CIS established.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-12 14:36:28 +02:00
Fabio Baltieri
a22fbfd1eb input: add some basic debugging utilities
Add two input subsystem options: one for dumping input events, one for
triggering input reports from the shell.

The two are independent from each other, so dumping can be enabled on
any application that has no shell, but if the shell command is present
logging can be toggled on and off with a shell command.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-12 10:53:04 +00:00
Jamie McCrae
566fd8cb7c retention: Allow disabling mutex support
Changes the Kconfig option to allow disabling mutex support, this
is to allow other Kconfig options to disable the feature.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-12 11:51:30 +02:00
Dawid Niedzwiecki
b04692b747 mgmt: ec_host_cmd: add user callback for a new command
Add a user possibility to set a callback for receiving a new function.
It allows instant performing some actions, that need to be done before
context switch.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Dawid Niedzwiecki
b6a3254d8b mgmt: ec_host_cmd: verify a command before passing it to handler
Verify validity of a received command before passing it to the general
handler.

It allows performing some actions, right after receiving the command.
The context switch is not needed. Such feature may be needed for
overloaded system, where instant reboot is required.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Dawid Niedzwiecki
1b6d6fb135 mgmt: ec_host_cmd: add function to signal a new command
Add a function to signal a new host command by a backend.

Use a function instead of giving semaphore, because it allows more
actions on rx event, common for all backends.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Dawid Niedzwiecki
7a479eec0d mgmt: ec_host_cmd: save result of IN_PROGRESS command
Add a config to save the final result of a last host command that has
sent EC_HOST_CMD_IN_PROGRESS response. To get the final result use the
ec_host_cmd_send_in_progress_status function.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Yong Cong Sin
7fba7d3957 shell: mqtt: fix uint32_t compared against 0
Fix unsigned compared against 0 reported by coverity check.
CID: 321096

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2023-07-11 18:21:46 +00:00
Lingao Meng
75cfa34481 Bluetooth: Mesh: Discard iv update 1 0 --> 1 1
According spec, for the same iv index, iv update flag
should trans to false, when iv update procedure complete.

When local environment has attack-node
to store old network beacon(1,1), and re-send same
network beacon(1,1) after 192hours, will cause whole
bluetooth mesh network broke.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-07-11 18:19:27 +00:00
Alperen Sener
4e83af0dd9 Bluetooth: Mesh: Fix OOB info and URI hash in scan report message
OOB information should be in little endian in scan report messages.
URI hash should be retrieved as it is from unprovisioned device beacon
and encoded likewise into scan report messages like we do for UUID.

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2023-07-11 18:18:48 +00:00
Mariusz Skamra
36f35f8335 Bluetooth: audio: ascs: Fix possible ASE leak
This fixes possible ASE leak in bt_ascs_config_ase in case
ascs_ep_set_codec function returns an error.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:51 +02:00
Mariusz Skamra
abf6fc37d0 Bluetooth: audio: ascs: Remove redundant ase_cleanup function
This removes redundant ase_cleanup function, as bt_ascs_release_ase
can be called instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:43 +02:00
Mariusz Skamra
0af2a75a7e Bluetooth: audio: ascs: Refactor ASE Disable handler
This removes code duplicates.
ASE Disable operation handler has been refactored by providing the
`rsp` pointer as one of the function parameters. ascs_cp_rsp_add is
not called from ase_disable explicitly, so the contents of the
response buffer are not changed in case the ase_disable is called
from non control point context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:43 +02:00
Mariusz Skamra
2abdeab768 Bluetooth: audio: ascs: Refactor ASE Release handler
This removes code duplicates.
The ASE Release operation handler has been refactored by moving the state
validation check to the ase_release function body and providing the
`rsp` pointer that is later filled. ascs_cp_rsp_add is not called from
ase_release explicitly, so the contents of the respons buffer are not
changed in case the ase_release is called from non control point context
e.g. `disconnected` callback.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:43 +02:00
Chaitanya Tata
69a144210e net: wifi: Add support to handle Wi-Fi NM's in Wi-Fi management
Check if a network interface is managed by a network manager before
falling back to offload API.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-11 14:55:30 +02:00
Chaitanya Tata
38fc560f21 net: wifi: Introduce Wi-Fi network managers
This introduces support for Wi-Fi network managers in Zephyr. The
motivation is for the Wi-Fi management layer to work with both
Network managers and offloaded Wi-Fi drivers. The device driver
decides which one to use.

network manager : Apps -> Wi-Fi Mgmt -> Network Manager -> Wi-Fi
interface

offloaded       : Apps -> Wi-Fi Mgmt -> Wi-Fi offloaded interface

Support for multiple network managers has been added, each device can
choose its own network manager and there can be mix and match:

  wlan0 - Offloaded
  wlan1 - Network manager 1
  wlan2 - Network manager 2

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-11 14:55:30 +02:00
Chaitanya Tata
a132487fec net: wifi: Move Wi-Fi ops to a separate struct
Decouple interface and Wi-Fi APIs, Wi-Fi APIs are common independent of
Wi-Fi offload or implemented natively (This is preparation for
introducing Native Wi-Fi).

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-11 14:55:30 +02:00
Mykola Kvach
d0472aae7a soc: arm64: add Renesas Rcar Gen3 SoC support
Add files for supporting arm64 Renesas r8a77951 SoC.
Add config option CPU_CORTEX_A57.

Enable build of clock_control_r8a7795_cpg_mssr.c for
a new ARM64 SoC R8A77951.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-07-11 11:17:41 +02:00
Keith Packard
40bc3ec346 subsys/net: Increase management stack size for thread local storage
The management thread *barely* fits in 768 bytes of stack; when thread
local storage is in use and TLS variables are also allocated from the same
region, this stack can overflow.

Increase to 800 bytes to leave plenty of room for TLS variables.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-07-10 15:11:15 +02:00
Jamie McCrae
c9a4764c10 mgmt: mcumgt: smp: Fix not checking returned status
Fixes not checking if a zcbor operation was successful.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-10 12:04:40 +02:00
Florian Grandel
4b66680477 net: l2: ieee802154: simplify/fix ACK procedure
Removes redundant ACK state from `struct ieee802154_context` and
simplifies the ACK procedure.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
27bfe68204 net: l2: ieee802154: mgmt: improve association procedure spec compliance
This change introduces test coverage for association request and
response. Based on this coverage, several closely related issues were
found in the association process which cannot be split into separate
changes without breaking the build.

Most notably did the associate and disassociate net_mgmt commands send
already encoded IEEE 802.15.4 MPDUs to L3 rather than L2. L3 treated
them as payload and made L2 wrap them with another LL header/footer
which produced invalid packets.

The tests also enforce better aligment of the association process with
the IEEE 802.15.4-2020 standard:

* Association requests now ask for ACK as required by the standard. The
  fake driver was enhanced to produce ACK packages when requested.
* macPanId and macCoordinator* MAC PIB attributes are set in the right
  order for improved filtering of association responses.
* The coordinator may decide not to assign a short address to the end
  device even when associated. This is now supported.
* The coordinator may or may not use a short address. Coordinators
  choosing not to support short addresses are now supported.
* Updating the association will now remove any previously added short
  address from the hardware filter.
* The short address may no longer be changed by the user while
  associated to a PAN. Only the coordinator is allowed to allocate short
  addresses.
* Validation of outgoing and incoming association request/response
  packets is improved.

All changes are documented by pointers into the spec.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
3d54e975a7 net: l2: ieee802154: association address parsing
Fixes an off-by-one bug in the parsing routine of the coordinator
address when associating via shell command.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
389f6ac81a net: l2: ieee802154: endianness of PAN ID
Fixes an endianness bug in PAN ID assignment.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
d7d5a53f36 net: l2: ieee802154: mgmt: improve input validation
Input validation of some of the IEEE 802.15.4 net_mgmt commands was
incomplete and/or inconsistent. This change introduces a consistent
approach to input validation that is easier to follow.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
d452ef9863 net: l2: ieee802154: correctly calculate macResponseWaitTime
Calculates macResponseWaitTime and applies it to the association
process.

As the timing calculation re-uses symbol period calculations and other
PHY timing constants previously introduced, these are now shared as
utility functions.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
4edf46d86c net: l2: ieee802154: radio: fix radio utils naming
The IEEE 802.15.4 stack defines radio API helpers that provide
simplified and encapsulated access to radio API features.

These helpers were missing the `_radio_` infix. This infix is introduced
to clearly distinguish between MAC and PHY concerns. While PHY features
may be shared between L2 implementations (including the functions
concerned here), this is not true for MAC features.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
3aa668f3ca net: l2: ieee802154: introduce IEEE 802.15.4-2020 association type
The IEEE 802.15.4-2020 standard introduces an association type field to
support fast association, see sections 6.4.3 and 7.5.2. We do not yet
implement fast association but we introduce the flag to make this
obvious.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Florian Grandel
415351f46a net: l2: ieee802154: frag configuration
Minor simplification in the definition of IEEE 802.15.4 Kconfig packet
fragmentation configuration.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-10 09:29:10 +02:00
Marcin Gasiorek
5894bec82f net: pkt_filter: Introduce additional hooks for pkt_filter
The additional hooks provide infrastructure to construct
rules on another network stack levels. Main benefit of this
approach is packets are pre-parsed and e.g. IP filter is
easier to implement. These hooks are equivalent of prerouting
and local_in in linux's netfilter.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-07-10 09:27:47 +02:00
Jamie McCrae
fbacedaef8 mgmt: mcumgr: grp: shell_mgmt: Fix issue with unset variable
Fixes an issue where a variable was used without being correctly
set by other parts of the code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-10 09:26:19 +02:00
Mariusz Skamra
bc710a49f1 Bluetooth: audio: unicast_server: Do not store metadata if rejected
This moves copying of parameters after application return value
validation so that the metadata is not stored if rejected.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-07 19:03:55 +00:00
Vinayak Kariappa Chettimada
a2ebec5c64 Bluetooth: Controller: Fix coverity issue 318807
[Coverity CID: 318807] Dereference before null check in
subsys/bluetooth/controller/ll_sw/ull_iso.c

Fixes #59514.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-07 19:01:04 +00:00
Emil Gydesen
275c86d399 Bluetooth: BAP: Shell: Merge the unicast and broadcast stream structs
Merging the two structs cleans up significant amount of code
and makes it easier to expand later.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Emil Gydesen
d17cde46d1 Bluetooth: BAP: Shell: Improve handling of PSN when sending
Previously the calculation of the PSN was done using
just a timer. This would not work correctly when
attempting to send multiple packets in a single SDU
interval (e.g. to enqueue 2 or more).

Previously we only ever attempted to send 1 packet in
the `sent` callback but scheduling the work item. However
in the case that the `sent` callback was called twice
before the work item had been triggered (possible due
to the priority of the RX thread being higher than the
system workqueue thread). This has been modified so that
if we can enqueue more packets in the lc3_audio_send_data
function, we re-enqueue the work item. We re-enqueue rather
than sending multiple in a single call to avoid blocking
other items on the system workqueue from being scheduled.
This could cause possible missed intervals (if other workqueue
items are processed), but it should be OK from a ISO perspective,
and the new PSN calculator handles this much better.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Emil Gydesen
06dc36d268 Bluetooth: BAP: Shell: Fix formatting in lc3_audio_send_data
Some formatting was not compliant with the coding style.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Emil Gydesen
d02a215a14 Bluetooth: BAP: Shell: Add support for TX retry when sending sine
Modify lc3_audio_send_data to be triggered on a delayable
k_work so that we can retry it with a delay if it fails for whatever
reason.

This also moves the calculation of the seq_num closer
to when it is used, which makes sense as it is based on
a timed calculation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Mateusz Kapala
5b44ebe159 bluetooth: host: smp: Add bondable flag overlay per connection
The current API for changing the bondable mode uses the global flag.
With Zephyr support for multiple Bluetooth identities, the API for
changing the bondable mode should be more fine-grained.
The bondable requirements of one identity should not have an impact on
another identity which can have a different set of requirements.
This change introduces function to overlay bondable flag per
connection.

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2023-07-07 14:55:29 +03:00
Pavel Vasilyev
8fc22e14a9 Bluetooth: Mesh: Remove TODO file is outdated
Remove TODO file is outdated.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-07-07 10:51:10 +02:00
Pavel Vasilyev
2bf61ee8d6 Bluetooth: Mesh: Restructure Kconfig options
Current structure of Bluetooth Mesh Kconfig options is quite messy.
This makes impossible to understand which configuration belongs to
which feature. Especially when using interactive Kconfig interface, like
menuconfig or guiconfig.

This commit restructures the options grouping them by protocol layer
they belong to (Network, Transport, Access, etc.), or specific feature
(LPN, Friend, Proxy, Relay, etc.), or implementation (Advertiser, Shell,
Persistent storage). Amount of supported keys, subnets, group addresses
and labels are grouped under Capabilities menu. Generic options that
don't fall to any category are kept at the root menu. For better
visibility, if a specific feature or layer has more than 1 option, they
are hidden under menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-07-07 10:51:10 +02:00
Dawid Niedzwiecki
40924edec2 mgmt: ec_host_cmd: fix checking command version
The sizeof is used in a wrong way which causes incorrect checking a
version of a command. Use NUM_BITS instead.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-07 09:22:13 +02:00
Dawid Niedzwiecki
521f0ba4f8 mgmt: ec_host_cmd: clear response buffer every command
The response buffer has to be cleared every command not to pass
unintended content e.g. response from a previous command, or stack
content.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-07 09:22:13 +02:00
Dawid Niedzwiecki
f2d6e0f660 mgmt: ec_host_cmd: set max response every command
Update the response buffer size, passed to a command handler, every
command, since a backend could change it in runtime.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-07 09:22:13 +02:00
Aleksandr Khromykh
9b4d080419 Bluetooth: Mesh: add shell statistic commands
Commit adds commands to get and to clear
the frame statistic.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-07-07 09:20:33 +02:00
Aleksandr Khromykh
7199425792 Bluetooth: Mesh: add statistic module
PR adds the statistic module to estimate frame handling.
The module helps to understand the ratio of
the received\relayed\dropped\transmited frames.
That shows the efficiency of the current configuration\implementation.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-07-07 09:20:33 +02:00
Emil Gydesen
3f2daa256c Bluetooth: BAP: Fix issue with pa sync and ID in broadcast_sink_create
The broadcast_id and the pa_sync fields should be set before calling
broadcast_sink_add_src as broadcast_sink_add_src will those values to
compare against other receive states.

The function was also missing a call to broadcast_sink_cleanup
for the newly allocated sink in case there was an error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 09:20:23 +02:00
Pieter De Gendt
a21c8f0281 logging: cmake: Remove duplicate source entry
log_cache.c was listed twice for zephyr_sources_ifdef.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-07-07 09:20:11 +02:00
Morten Priess
12ef3453c6 Bluetooth: controller: Fix CIG state overwrite in parameters_commit
The CIG state variable is set to CIG_STATE_CONFIGURABLE, but then
cleared by memcpy from configuration cache. Set state after memcpy.

Fixes EBQ test /HCI/CIS/BI-10-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-07-07 09:19:27 +02:00
Morten Priess
016774a06b Bluetooth: controller: Fix link_tx overwrite at Central CIS creation
In the case where memq_deinit in LLL flushing ends up with the free
link being the link provided by the CIS instance, and pointed to by
lll.link_tx_free, the free counter data in the link element is
overwritten during central CIS creation.

This has the effect that when starting the next CIG, there will suddenly
be 0 links available, and controller fails assertion.

By saving- and restoring the lll.link_tx before and after CIS
configuration cache copying, the free counter is intact.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-07-07 09:19:27 +02:00
Weiwei Guo
631dce5866 net: ethernet: add PTP multicast default MAC address
All except peer delay message in PTP protocol use multicast MAC
address is 01:1b:19:00:00:00

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-07-05 12:35:34 +00:00
Troels Nilsson
c7627cab29 Bluetooth: Controller: Fix a couple of compiler warnings
Remove set but unused enable variable

Flag sync_iso_create_get() function

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-05 12:34:23 +00:00
Troels Nilsson
287eb04d6f Bluetooth: Controller: Don't report when AUX_ADV_IND is not received
An advertising report must not be generated unless the AUX_ADV_IND
has been received (for ADV_EXT_IND with an auxptr)

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-05 12:34:23 +00:00
Troels Nilsson
813c9104fa Bluetooth: Controller: Handle unsupported coded phy in ull_scan_aux
Use CONFIG_BT_CTLR_PHY_CODED to flag out coded phy code

Don't schedule a scan for coded phy when it is not supported

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-05 12:34:23 +00:00
Emil Gydesen
5fa793fa9d Bluetooth: Modify stream_ops->stopped to be called on leaving streaming
When a stream leaves the streaming state the `stopped` callback
will now be called, similar to how the `started` callback works.

This ensures that `stopped` is always called and not just when
the CIS disconnects.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-05 12:34:01 +00:00
Alberto Escolar Piedras
56dc20eb1d Kconfig: Tidy up dependants of NATIVE_APPLICATION
So they depend or select on the right NATIVE_BUILD
instead of NATIVE_APPLICATION.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Robert Lubos
e1964b8a82 net: wifi: shell: Fix unsafe pointer casts
parse_number() helper function accepts long * pointer or the output,
however in several places, an address of a variable of incompatible
type was passed to the function (for example an address of a bool
variable was cast to (long *) and provided to the function). This
could cause memory overwrites or other unexpected behaviour.

Fix this, by defining a helper variable of type long, and use it with
the parse_number() function. Only after successful parsing, the value is
then assigned to the proper destination.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-05 11:17:42 +02:00
Seppo Takalo
aaa9cedf18 net: lwm2m: Update next event timestamp on PMAX change
When PMAX value is changed, it should update all events.
I believe there is a bug that caused the code only to update
events that are ongoing (to be send).

Now if PMAX changes, next event timestamp is recalculated.

Fixes #59397

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-07-05 11:16:06 +02:00
Arkadiusz Kozdra
82d8f09de1 bluetooth: host: track connection type enum
The enum used for connection types gets named bt_conn_type to guard
against accidental usage of generic integers with relation to it.

The added default case in several switch statements avoids warnings
against unhandled enum values.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Arkadiusz Kozdra
0885416b60 bluetooth: host: add checks for connection types
Fail gracefully if an HCI event of one type arrives for a handle of a
different connection type.  The requested types are currently based on
what fields are used, not on the usage context, in order to keep every
correct use so far still working.

A warning is logged if the connection identified by the handle does not
match the requested connection type.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Arnaud Pouliquen
85fe3c45fd ipc_service: rename virtio_xxx static functions
The "virtio_" prefix is used by the open-amp library API.
Rename local functions using "ipc_virtio_" prefix to avoid
function redefinition.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2023-07-05 09:15:08 +02:00
Mariusz Skamra
7c21a9c189 Bluetooth: ascs: Make sure idle state can be always read
Instead of waiting for ase_buf to be available, the read of an
ASE in IDLE state can be handled without using ase_buf.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-05 09:14:37 +02:00
Mariusz Skamra
12c89edc39 Bluetooth: ascs: Fix return without state change nor response
This fixes missing control point status and ASE status change, when
failed to disconnect the CIS. As the server may, but does not have to
disconnect the CIS, the operation should not be considered as failed
when it happens.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-05 09:13:45 +02:00
Aleksandr Khromykh
25bfbb1caf Bluetooth: Mesh: instantiate cdb and core keys
PR instantiates cdb and core keys to prevent scenario
when key is changed over cdb API and gets new ID but
core still operates with old ID(potentially invalid).

Known issue the keys will be desynchronized
during\after key refresh procedure.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-07-04 11:01:47 +00:00
Szymon Czapracki
42a402abe3 bluetooth: audio: Rework PACS notify system
This commits eliminates the old way of
pacs notifications, replacing k_work with
simple bt_gatt_notify.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-07-04 11:00:38 +00:00
Emil Gydesen
b20ef863cd Bluetooth: OTS: Add explicit ignore of ret error when reset dir_list
When doing the bt_ots_dir_list_reset_anchor we now explicitly ignore
the return value of bt_gatt_ots_obj_manager_first_obj_get
to fix a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-04 09:30:01 +02:00
Carles Cufi
9e0e2be765 Bluetooth: controller: Fix indent in calls to ticker_stop()
Follow-up from #59602.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-07-03 16:56:26 +00:00
Mateusz Kusiak
4337675436 Bluetooth: Controller: Ignore ticker_stop() return value
Cast ticker_stop() calls to void where return value is not checked.
This is to satisfy coverity and indicate that return value is not
important.

Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
2023-07-03 16:14:34 +02:00
Florian Grandel
0341d67625 net: l2: ieee802154: readability: one-letter names
This change replaces one letter variable names with considerable
variable spans by much more readable alternatives that ease code
maintenance and help human reviewers to catch semantic errors.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel
0d5eba7900 net: l2: ieee802154: readability: f_ctx -> frag_ctx
The f_ctx variable renamed in this change has a considerable variable
span. This makes the code hard to read as the variable name is neither
defined in the IEEE 802.15.4 standard nor can it be deduced from the
variable name.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel
805ca4dde6 net: l2: ieee802154: readability: ar -> ack_requested
The 'ar' abbreviation has a well defined meaning in IEEE 802.15.4 which
is NOT the meaning of the local "ar" variable being renamed in this
change (see the comparison to the actual MHR ar field in this change
set).

To avoid confusion, a non-abbreviated variable name is introduced
instead.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel
06df0d4a7d net: l2: ieee802154: readability: af -> address_field
The 'af' abbreviation is nowhere standardized in IEEE 802.15.4 and makes
the source code unnecessarily hard to read. It is replaced by a readable
long name.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel
a7338b33d5 net: l2: ieee802154: readability: LL header length
Several distinct naming conventions existed within the IEEE 802.15.4
stack wrt header length. This change converges to a single naming
convention, the one that is less ambiguous and already most used.

The change also makes the distinction between L2 (link layer/LL) header
length and 6LoWPAN fragmentation header length to avoid confusion.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel
48456d32d5 net: l2: ieee802154: rename comp to has_pan_id
This change is in preparation for the newer frame version's more
complex compression algorithm that may compress both, the source
and the destination PAN independently.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Florian Grandel
0ce47c7a8d net: l2: ieee802154: readability: buf -> pkt_buf
This change renames buf to pkt_buf in one very specific instance to
distinguish the packet buffer from the frame buffer which is kept in the
same local scope. In all other instances the meaning of "buf" should be
obvious from context, not so here, though

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-03 14:09:32 +00:00
Vinayak Kariappa Chettimada
bc60619b90 Bluetooth: Controller: Fix coverity issue 248393
[Coverity CID: 248393] Explicit null dereferenced in
subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Fixes #58942.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 13:43:46 +02:00
Vinayak Kariappa Chettimada
7366dfd1cc Bluetooth: Controller: Fix coverity issue 318804
[Coverity CID: 318804] Copy-paste error in
subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Fixes #59512.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:34:30 +02:00
Vinayak Kariappa Chettimada
80632b50c7 Bluetooth: Controller: Fix coverity issue 318644
[Coverity CID: 318644] Unused value in
subsys/bluetooth/controller/ll_sw/ull_central_iso.c.

Fixes #58999.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:33:22 +02:00
Vinayak Kariappa Chettimada
41cfe217b2 Bluetooth: Controller: Fix coverity issue 318626
[Coverity CID: 318626] Unintended sign extension in
subsys/bluetooth/controller/ll_sw/ull_adv_iso.c.

Fixes #58984.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:32:47 +02:00
Emil Gydesen
915a649392 Bluetooth: CSIP: Add missing input validation for csis_int_by_handle
The bt_csip_set_coordinator_csis_inst_by_handle did not check the input
parameters and could call lookup_instance_by_handle with handle == 0
which triggers an ASSERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:27 +02:00
Emil Gydesen
11b12ae905 Bluetooth: MICP: Return if AICS inst count is 0
In the prepare_aics_inst the loop
should not run if the count is 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:04 +02:00
Emil Gydesen
92d612e79d Bluetooth: VCP: Return if VOCS/AICS inst count is 0
In the prepare_aics_inst and prepare_vocs_inst the loops
should not run if the count is 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:04 +02:00
Emil Gydesen
3d53a75180 Bluetooth: BAP: Shell: Register CAP callbacks if CAP initiator
If we are use the shell as a CAP initiator, then we need to
register the stream callbacks for the CAP streams as well, as
CAP will use the BAP callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:48 +02:00
Emil Gydesen
f1a3b7d7e2 Bluetooth: CAP: Add null check for free_conn
When populating the conns array in
bt_cap_initiator_codec_configured, coverity did not like just
having the __ASSERT, so modified the checks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:30 +02:00
Emil Gydesen
4e15a09083 Bluetooth: BAP: Filter PA data duplicates by default
When syncing via the broadcast sink or the scan delegator
it makes more sense to filter on duplicates, as the expected
data rarely changes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:13 +02:00
Emil Gydesen
c6632d65d8 Bluetooth: BAP: Shell: Add runtime config of recv_stats_interval
The internval of how often we report
receive stats can now be configured via the cmd_recv_stats
command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:11:57 +02:00
Emil Gydesen
6e066b4683 Bluetooth: BAP: Shell: Improve recv statistics
Add more information when we print the recv every 100th
packet, and remove all per-recv printing.

This also resets all information on stream start. This does,
however, no properly support multiple streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:11:57 +02:00
Emil Gydesen
49a70aa1bb Bluetooth: TMAP: Add TMAP shell module
Add simple TMAP shell module that supports the TMAP
discovery.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:10:51 +02:00
Emil Gydesen
43ef100a22 Bluetooth: TMAP: Make callback const
The callback should not be modified by the stack,
and should thus be const.

Also fixes a missing include of conn.h.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:10:51 +02:00
Georges Oates_Larsen
ad6fdaf2c2 net: conn_mgr: Bulk convenience functions
To further reduce the need for networking boilerplate in applications,
provide bulk versions of net_if_up, net_if_down, conn_mgr_if_connect,
and conn_mgr_if_disconnect that affect all available / eligible ifaces
at once.

Since it is not intuitive whether these functions should affect ifaces
which conn_mgr is ignoring, these functions take an argument that allows
this to be specified by the application.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen
b65613e79c net: conn_mgr: Support Auto-Down
To reduce the amount of boiler-plate needed in applications, this commit
grants conn_mgr the ability to automatically take ifaces that have given
up on connecting into the admin-down state.

Tests adjusted as appropriate.

This behavior can be disabled globally by disabling
NET_CONNECTION_MANAGER_AUTO_IF_DOWN, or disabled per-iface using the
CONN_MGR_IF_NO_AUTO_DOWN flag.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen
f3d75c4c65 net: conn_mgr: Support Auto-Connect
To reduce the need for boilerplate in application code, conn_mgr now
supports an auto-connect feature on all ifaces with connectivity
bindings.

conn_mgr will automatically call conn_mgr_if_connect on any iface with a
connectivity binding that enters the admin-up state, unless the newly
added CONN_MGR_IF_NO_AUTO_CONNECT flag has been set for that iface.

Also adjust automated tests to account for and take advantage of this
behavior.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen
8785a9f424 net: conn_mgr: Minor fixes
- Add missing event sleep after taking all ifaces up in
  test_connect_disconnect.
- Add missing event sleep after resetting ifaces in conn_mgr_conn_before
- Fix typo in comment for internal state flags.
- Add missing NET_MGMT_EVENT_BIT to conn_mgr_connectivity event
  definitions.
- Missing net_mgmt.h include in conn_mgr_connectivity.h
- Split conn_mgr_conn iface reset into network and state resets, before
  and after event sleep, so that triggered events do not corrupt the
  state reset.
- Reduce SIMULATED_EVENT_DELAY to 100ms to avoid timeouts on real-time
  targets.
- Use macro for simulated event wait times.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-06-30 16:10:23 +02:00
Emil Gydesen
cd78331c23 Bluetooth: Shell: Only print PAST peer if there is one
Only print the "PAST peer" string if there is an actual
PAST peer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:08:17 +02:00
Aleksander Wasaznik
e61ac77119 Bluetooth: Shell: Restore missing bt_addr_le_to_str in scan_recv
This restores a line of code that was accidentally deleted in
5580cb4391. This fixes an uninitialized
`le_addr` getting printed and producing garbage output in the scan
results.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-30 16:07:44 +02:00
Jai Arora
cf0ff30b53 bluetooth: ots: Fix bt_ots_init paramter struct naming
Patch to rename struct bt_ots_init to struct bt_ots_init_param
to avoid duplicating the name bt_ots_init.

Fix for issue#45968

Signed-off-by: Jai Arora <infolinesoni@gmail.com>
2023-06-30 16:06:08 +02:00
Emil Gydesen
69f7fd9cb2 Bluetooth: Audio: Rename bt_codec to bt_audio_codec_{cap, conf, data}
Rename the bt_codec struct to bt_audio_codec_conf or
to the new struct bt_audio_codec_cap.
Rename the bt_codec_data to bt_audio_codec_data.

The purpose of this is to split the codec specific configuration
and codec capabilities into seperate structs, as they do not
reflect the same values, or used for the same purpose.

This commit depends on the preset macros workings on either
type of struct (for now), but will be modified in future updates.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 12:39:50 +02:00
Marcin Niestroj
40d2240226 net: context: set default offloaded iface during net_context_get()
Set default offloaded interface during net_context_get() call, so that
net_context_recv() can be called before net_context_connect(). There is
already an assumption about using default network interface, so this should
not be harmful.

Fixes: 2c75070360 ("net: sockets: tcp: Fix possible race between
  connect/recv")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-06-29 21:08:05 +02:00
Mariusz Skamra
17223f136f Bluetooth: audio: Fix metadata length checks
This fixes metadata length checks for BT_AUDIO_METADATA_TYPE_EXTENDED
and BT_AUDIO_METADATA_TYPE_VENDOR that should be at least 2 bytes long.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:58 +02:00
Mariusz Skamra
db5767e50f Bluetooth: audio: Accept empty CCID list in audio metadata
The CCID list can be empty, as the Assigned Numbers is not strict
regarding it's minimum length.

Fixes: #59666
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:58 +02:00
Emil Gydesen
a32ba627ce Bluetooth: BAP: Shell: Improve printing of the BASE
Add offsets for each layer in the BASE and add printing
of the presentation delay.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:06:46 +02:00
Mariusz Skamra
7b94d57b32 Bluetooth: unicast_client: Drop ISO PDUs if ASE is not in streaming state
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The client shall indicate first it's readiness to receive the ISO Data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:31 +02:00
Mariusz Skamra
9694e85614 Bluetooth: ascs: Drop ISO PDUs if ASE is not in streaming state
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The server shall indicate first it's readiness to receive the ISO Data
by calling bt_bap_stream_start that triggers state transition from
Enabling to Streaming state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:31 +02:00
Emil Gydesen
f4550dbda8 Bluetooth: TBS: Guard check for MAX_TBS_INSTANCES
Add check for CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 1 before
comparing inst_cnt, as otherwise it was always false which
caused a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:06:14 +02:00
Ajay Parida
69fead1998 net: mgmt: Support for forced Passive scan
Default scan mode is Active. User can force the scan mode to passive
through Kconfig option or using 'passive' option from shell.
Using either of this option will override regulatory settings and
forces all scan channels to be passive only.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-29 21:05:41 +02:00
Emil Gydesen
c627164d28 Bluetooth: CSIP: Shell: Fix discover_members
The cmd_csip_set_coordinator_discover_members did not properly
handle the members_found and addr_found values.

It has been modified to run through all known values
before scanning, and set the value appropriately.

This also fixes a minor bug where err = 0 was missing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:05:02 +02:00
Vinayak Kariappa Chettimada
96c076b9c1 Bluetooth: Controller: Add LL_ASSERT_OVERHEAD define
Add LL_ASSERT_OVERHEAD define to reuse the assertion check
related to increase in actual EVENT_OVERHEAD_START_US value.

Introduce Kconfig option to permit radio event be skipped
when increased prepare callback latencies are measured,
instead of assertion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
5aae5d2583 Bluetooth: Controller: Fix Connected ISO for aborted prepare
Fix Connected ISO implementation to correctly handle SN,
NESN and payload_count when prepare callback is aborted due
to CPU overhead related latencies.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
ae679bc9ff Bluetooth: Controller: Move EVENT_OVERHEAD_START_US verbose assertion
Move the EVENT_OVERHEAD_START_US verbose assertion to each
state/role LLL implementation so that correct state/role
that is delayed is conveyed in the assertion message.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
3c34163908 Bluetooth: Controller: Add -ECANCELED on return from lll_preempt_calc
Add -ECANCELED on return from lll_preempt_calc so that
assert check can be placed in the prepare callbacks of the
state/role implementations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
ac8499550d Bluetooth: Controller: Fix use of pre-programmed PPI
Fix to not use pre-programmed PPI when NRF_TIMER0 is not
used as the radio event timer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:48 +02:00
Vinayak Kariappa Chettimada
cfcbe5d68e Bluetooth: Controller: Remove redudant header file includes
Remove redundant header file includes, introduce radio used
resources header file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:48 +02:00
Vinayak Kariappa Chettimada
019f88ec21 Bluetooth: Controller: Fix CIS failed to be established
Fix CIS create implementation to consider CIG events with
laziness before the new CIS in an already active CIG is
made active.

Previous laziness value of the CIG events is determined and
at the CIG event where the new CIS event_count is calculated
the lazy_active value determined is decremented from the
total lazy value.

Without this fix, event_count of the new active CIS events
where incorrect, causing CIS create resulting in fail to be
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:27 +02:00
Vinayak Kariappa Chettimada
6da521c9b6 Bluetooth: Controller: Fix offset_min_us be >= PDU_CIS_OFFSET_MIN_US
Fix calculation that ensured cis_offset_min_us being >=
PDU_CIS_OFFSET_MIN_US.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:27 +02:00
Vinayak Kariappa Chettimada
bd9cee0a9f Bluetooth: Controller: Inherit BT_ISO_TX_MTU value
Inherit BT_ISO_TX_MTU value for BT_CTLR_ISO_TX_BUFFER_SIZE.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 10:06:19 +00:00
Pavel Vasilyev
4256472fbf Bluetooth: Mesh: Reduce BT_L2CAP_TX_MTU for mesh to 33
Since the acl mtu for mesh is reduced to 37 in PR #59004, there is no
need in BT_L2CAP_TX_MTU to be longer than 33 bytes for mesh.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-29 10:05:03 +00:00
Théo Battrel
cd264b21e4 Bluetooth: Host: Abort pairing if disconnected
If disconnection has been triggered in between the security update and
the call to `smp_pairing_complete` we need to abort the pairing.

The disconnection may have been triggered by `bt_unpair`, in that case
the keys will have been erased and it will lead to an assertion to
continue as if nothing happened.

To resolve this issue, at the beginning of `smp_pairing_complete` the
`status` is set to `BT_SMP_ERR_UNSPECIFIED` if there is no connection.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-29 10:04:41 +00:00
Jarno Lämsä
7ae4e24728 net: lib: lwm2m: Use int16_t for signal strength
The signal strength for the connectivity monitor was
defined as int8_t, however this was too small for
LTE RSRP values, which has range [-140,-44].

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-06-29 10:04:14 +00:00
Theo Gasteiger
b9d46b5483 Bluetooth: Audio: Encrypted BISes cause MPU FAULT
When enabling BIS encryption, a MPU fault will occur.

Signed-off-by: Theo Gasteiger <gatcode@wdw.one>
2023-06-29 10:01:16 +00:00
Jarno Lämsä
419fa3ca6a net: lib: coap: CoAP client, multiple request handling
Use only single thread for handling polling of the sockets.
Each client will have only 1 active socket which to poll.
Each client can have multiple simultaneous requests ongoing.
The client only has one buffer for receiving and one buffer for sending.
Therefore the messages are reformed when resending.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-06-28 15:19:34 +02:00
Florian Vaussard
2eb7433f5b net: if: do not remove the solicited-node multicast address if used
Two different IPv6 addresses can have the same solicited node multicast
address, for example when they are derived from the same EUI-64
interface identifier during the auto-configuration process. For example,
an interface with a physical address 70:07:12:34:56:78 can have the
following:
- link-local address FE80::7207:12FF:FE34:5678
- global unicast address 2001🔢::7207:12FF:FE34:5678

Both addresses will have the same solicited-node multicast address
FF02::1:FF34:5678. Currently, if one removes the global unicast address,
the solicited-node multicast address is also removed, leaving the
link-local address out of the solicited-node multicast group. This
breaks some protocols like Neighbour Discovery.

Count how many times the solicited-node multicast address is used and
remove it only if it is not shared by any other unicast address.

Fixes #59683

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-06-28 06:51:21 +00:00
Florian Vaussard
56e0d8eef3 net: if: split the search loop of net_if_ipv6_addr_rm()
First search for a match, then perform the removal outside the loop.
There is no functional change but this prepares for some future changes.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-06-28 06:51:21 +00:00
Florian Vaussard
59880738f5 net: if: prepare net_if_ipv6_addr_rm() for future changes
Move the creation of the multicast solicited node address outside the
loop. There is no functional change but it prepares for some future
changes.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-06-28 06:51:21 +00:00
Tommi Kangas
f124c0d06a net: lib: coap: Use zsock_ functions
Use Zephyr internal zsock_ calls to remove dependency
to NET_SOCKETS_POSIX_NAMES.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2023-06-28 06:49:59 +00:00
Aleksandr Khromykh
4d4886c056 Bluetooth: Mesh: remove unnecessary mbedtls options from mesh
Unnecessary mbedtls config option has been removed from
ble mesh KConfig.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-28 06:48:52 +00:00
Emil Gydesen
a46fb81449 Bluetooth: BAP: Shell: Set default_stream on configured
Instead of setting the default_stream when we initiate
the configure operatio, we set it when it has succeded.

In case that the codec configure fails, the stream should
not really be considered configured as the default.

This also ensures that the default_stream is set when
using the CAP shell commands.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-28 06:48:32 +00:00
Matthias Breithaupt
04ce5b9e58 mgmt: hawkbit: remove NET_SOCKETS_POSIX_NAMES dependency
Currently, it is not possible to use hawkbit with code that requires
POSIX_API to be set due to the dependency on NET_SOCKETS_POSIX_NAMES.
Since a lot of other code has already been moved to `zsock_`, this
commit does the same for hawkbit.

Co-authored-by: rojedag <r.ojeda@vogl-electronic.com>
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
2023-06-28 06:32:45 +00:00
Seppo Takalo
6050a10f8b net: lwm2m: Allow setting string to zero length
Lwm2m firmware object have defined a write of zero length
string as a cancel operation.
So allow lwm2m_set_opaque(path, NULL, 0);

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-27 12:18:35 +00:00
Mariusz Skamra
b3259e5bf5 Bluetooth: ascs: Fix possible ASE stuck in releasing state
It may happen that CIS is scheduled in the future and did not started
yet once accepted. When ASE goes to Releasing state in such case
the ISO has to be disconnected, because otherwise ASE will stuck in
releasing state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-27 12:17:56 +00:00
Emil Gydesen
379ee55ee0 Bluetooth: BAP: Shell: Move audio_send_work above clear_lc3_sine_data
Since clear_lc3_sine_data references audio_send_work, it must
be declared before the clear_lc3_sine_data function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:17:47 +00:00
Chaitanya Tata
a71bff7f49 net: wifi: Fix power save timeout data type
This should be an unsigned integer. Also, add a comment to explain this
feature.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-27 12:17:26 +00:00
Emil Gydesen
82e5eba817 Bluetooth: BAP: Fix bt_bap_scan_delegator_find_state
The bt_bap_scan_delegator_find_state did not properly return the
correct receive state due to confusing return value of the
iterator function.

Modify it to use a simple bool.

This fixes all issues with "Failed to find receive state for sink"
when using the Broadcast Sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:16:50 +00:00
Emil Gydesen
2b74450544 Bluetooth: CSIP: Update CSIP duplicate rank search
In the CSIP Set Coordinator verify_members we verify that
all members have unique ranks.

This was done as part of the initial loop, but it is
more efficient to do this as a separate loop as we can reduce
the number of items to compare, as well as guarding this properly
by !zero_rank.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:16:12 +00:00
Emil Gydesen
ac8dc34911 Bluetooth: CAP: Shell: Fix type in cmd_cap_initiator_unicast_stop
"starteds" should be "started".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:15:36 +00:00
Emil Gydesen
feaae8b104 Bluetooth: BAP: Shell: Only register scan delegator callbacks once
If the callbacks are registered more than once, the linked list
causes an infinite loop.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:15:19 +00:00
Emil Gydesen
2901e7cd59 Bluetooth: BAP: Shell: Fix assistant broadcast code
Fixes 2 issues:
1) The broadcast code would only ever get the first value, even if
the command specified up to 16 values.
2) The broadcast code is not just hex values, so hex2bin does not make
sense, and strlen + memcpy is much simpler.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:15:01 +00:00
Emil Gydesen
addc8a538a Bluetooth: BAP: Shell: Stop scan on broadcast found
When the broadcast assistant have found the expected broadcast
source it should stop scanning.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:14:34 +00:00
Emil Gydesen
acc59cfc9a Bluetooth: BAP: Shell: Add missing addr print in broadcast assistant
The shell_print was meant to print the address of the broadcast
source along with the broadcast_id.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:14:15 +00:00
Emil Gydesen
dd0db3f7d6 Bluetooth: BAP: Shell: Fix broadcast assistant bad code print
The bad code field should only be printed when there is an actual
bad code, otherwise it just prints all-0s.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:13:46 +00:00
Emil Gydesen
7993f2001e Bluetooth: BAP: Shell: Fix missing NULL check for cmd_list
stream may be NULL when we check for stream->conn.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:13:30 +00:00
Sean Madigan
2c3dd0122e bluetooth: controller: kconfig: Move BT_CTLR_SCAN_SYNC_ISO_SET
Move BT_CTLR_SCAN_SYNC_ISO_SET to Kconfig from Kconfig.ll_sw_split
This means it can be used by other controllers and alligns with location
of other iso configs - e.g. BT_CTLR_SYNC_ISO_STREAM_COUNT

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2023-06-27 12:12:20 +00:00
Emil Gydesen
e99b8f3433 Bluetooth: BAP: Shell: Fix missing src_id in mod_src
The src_id was never set in
cmd_bap_broadcast_assistant_mod_src.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-26 16:14:42 +02:00
Dawid Niedzwiecki
c8c149dce8 mgmt: ec_host_cmd: add logging system
Add a native way to log Host Command communication.

Use Zephyr logging system to do it. Use debug and normal levels.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-06-26 16:13:42 +02:00
Dawid Niedzwiecki
159f56d57e mgmt: ec_host_cmd: use one command to send response
Use one common function to send Host Command response. It allows
handling all response types within one function.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-06-26 16:13:42 +02:00
Chaitanya Tata
5aced7130d net: wifi: Use only Wi-Fi interfaces
As this is Wi-Fi shell use only Wi-Fi interfaces, if none are found
fail.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 16:12:32 +02:00
Chaitanya Tata
91b5b4424c net: wifi: Add support to get and set Wi-Fi as default interface
Add a configuration option to set Wi-Fi as default interface and also
add an API to get first available Wi-Fi interface.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 16:12:32 +02:00
Chaitanya Tata
7987098497 drivers: wifi: Register Wi-Fi architecture type
Identify the Wi-Fi capability to the networking stack and also the type
of Wi-Fi (Native vs Offloaded), this helps identifying Wi-Fi interfaces
that can be used by applications.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 16:12:32 +02:00
Chaitanya Tata
2606ba445b net: l2: Add support to identify Wi-Fi interfaces
Wi-Fi is based on L2 Ethernet, so, all drivers are registered as
Ethernet L2, but in order to distinguish true Ethernet and Wi-Fi
devices, add a L2 type within Ethernet.

Also, handle offloaded net devices that also offload Wi-Fi.

This approach is better than adding a new Wi-Fi L2 as that would mean
invasive changes which are unnecessary.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 16:12:32 +02:00
Emil Gydesen
5a4c9a2112 Bluetooth: BAP: Unicast client shall support 0 or > 1 endpoints
As per table 4.2 in BAP v1.0.1, the BAP unicast client shall
support at least 2 (> 1) endpoints in either direction if it
supports that direction.

Since Kconfig does not support such requirements (0 || > 1),
this is done using a BUILD_ASSERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-26 12:40:39 +00:00
Emil Gydesen
9d3f594432 Bluetooth: BAP: Shell: Print received broadcast code
Print the received broadcast code as the scan delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-26 12:39:16 +00:00
Seppo Takalo
dc7fbc5d2e net: lwm2m: Fix pause and resume on non-closed sockets
Pause and resume functionality was written into assumption
that sockets are closed before resuming.

With use new options CONFIG_LWM2M_RD_CLIENT_STOP_POLLING_AT_IDLE
or CONFIG_LWM2M_RD_CLIENT_LISTEN_AT_IDLE this is not always true.
Fix the state machine, so that on those cases, sockets are not
closed and resume is always similar like from the QUEUE mode.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-26 12:37:13 +00:00
Seppo Takalo
5c1228770e net: lwm2m: Add support for X509 certificates
Add support for using X509 certificates.
Default settings use ECDSA certificates with SHA256 hash.

When different settings are required clients should overwrite
struct lwm2m_ctx->load_credentials() and
struct lwm2m_ctx->set_socketoptions()

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-26 12:35:29 +00:00
Marek Pieta
6bbd6d3794 mcumgr: img_mgmt: Fix unused "status" variable warning
Changes aligns ifdefs to fix compilation warnings related to unused
"status" variable.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-06-26 12:31:05 +00:00
Chaitanya Tata
8042218948 net: wifi: Add a message for unsolicited TWT tear down
This is for TWT tear down by AP.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
a3ab624f5d net: wifi: Add a demarcation print
This helps see the response status and details separately.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
3be7265737 net: wifi: Fix tear down messages
TWT tear down is a synchronous call, so, once it returns the operation
is done.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
97bd70fa05 net: wifi: Disable trigger in TWT quick setup
Most AP's are not sending proper HE triggers or stopping triggers after
sometime, so, change the default to non-triggered based TWT.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
456859a65d net: wifi: Do TWT checks only for setup
For tear down the checks doesn't make any sense, as TWT flow is already
established.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Mariusz Skamra
93abc2ad76 Bluetooth: att: Reset ATT timer when retrying on security error
If the remote responds with and security related error the stack tries
to increase the security level to satisfy the remote permissions.
This fixes missing ATT timer reset on security related ATT Error
Response as the ATT operation is considered as complete.

< ACL Data TX: Handle 0 flags 0x00 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x0084
        TMAS: Role
> ACL Data RX: Handle 0 flags 0x02 dlen 9
      ATT: Error Response (0x01) len 4
        Read Request (0x0a)
        Handle: 0x0084
        Error: Insufficient Authentication (0x05)
          TMAS: Role
           Error code: 0x05
< ACL Data TX: Handle 0 flags 0x00 dlen 6
      SMP: Security Request (0x0b) len 1
        Authentication requirement: Bonding, No MITM, SC, No Keypresses
= bt: bt_att: ATT Timeout

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:55:17 +02:00
Théo Battrel
a996159362 Bluetooth: Host: Fix connection reference leak
If connection reference is acquired from `bt_conn_lookup_addr_le` but
`bt_gatt_ccc_cfg_is_matching_conn` return false the connection was not
unreferenced properly. This commit fix the issue by unreferencing the
connection if the condition is false.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-24 18:55:04 +02:00
Mariusz Skamra
d72c17684c Bluetooth: tbs_client: Fix possible NULL pointer dereference
This fixes notification callback that can be called with NULL conn
parameter when peer is being unpaired.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Mariusz Skamra
6f0dc490e7 Bluetooth: vocs_client: Remove unused subscribe_cnt variable
This removes unused subscribe_cnt from bt_vocs_client.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Mariusz Skamra
a7231a4ca4 Bluetooth: aics_client: Remove unused subscribe_cnt variable
This removes unused subscribe_cnt from bt_aics_client structure.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Mariusz Skamra
5452ef378f Bluetooth: tbs_client: Remove unused subscribe_cnt variable
This removes unused subscribe_cnt from bt_tbs_instance.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Yuval Peress
10be3a1263 rtio: Implement a NO_RESPONSE flag for SQEs
When added, the SQE's completion will not generate a CQE.
Fixes #59284

Signed-off-by: Yuval Peress <peress@google.com>
2023-06-23 12:31:09 -04:00
Yuval Peress
8e5cae7fa3 ztest: Allow 'before' functions to run in privilaged mode
When writing a test suite, it's more common to want the 'before'
hook to run in privilaged mode, even when the test is run in userspace.
Reconfigure ztest to first run the test thread callback in privilaged
mode and only enter userspace after the test rule and suite's 'before'
functions ran.

Signed-off-by: Yuval Peress <peress@google.com>
2023-06-23 12:30:46 -04:00
Florian Grandel
c88a9ef272 segger: rtt: disable unsupported shell/log features
The RTT backend of the shell does not support several of the more
advanced terminal features. This commit proposes to inactivate these
features by default when RTT is selected as shell backend.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-23 14:42:41 +02:00
Emil Gydesen
192e425b90 Bluetooth: Host: Add NULL check for addr in unpair
unpair may be called from bt_unpair where addr is NULL.
One such case is the `bt clear all` shell command which
calls bt_unpair with addr = NULL, and the addr is just forwarded
to unpair which does not check for NULL.

bt_unpair allows for the addr to be NULL to clear all, but only
if SMP is enabled.

Modified the checks in bt_unpair to increase readability
and ensure that unpair is not called with NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-23 09:21:35 +02:00
Florian Grandel
a94877b8b1 drivers: ieee802154: cc13/26xx_subg: improve CSMA/CA compliance
Switch the driver to the soft CSMA/CA algorithm as an intermediate
compromise for improved standard compliance (namely expontential
backoff) until true hardware support can be implemented by chaining
radio commands.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-23 09:20:55 +02:00
Alberto Escolar Piedras
b4b2eaae35 ztests: Build POSIX arch extra functionality only if possible
The extra ztest functionality for the posix arch
requires the host libC. Disable it if we are
building with an embedded libC.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-06-23 09:05:00 +02:00
Mariusz Skamra
9ef019d28d Bluetooth: tmap: Fix TMAS characteristic permissions
This fixes TMAS characteristic permissions.
The characteristic shall have no security related
permissions as per TMAP_v1.0.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-22 16:31:18 +02:00
Pavel Vasilyev
c214ec3cf4 Bluetooth: Mesh: Fix dead code issue when getting node id state
Refactor the function to avoid dead code.

Coverity-CID: 321153
Fixes #59527

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-22 12:34:23 +02:00
Pavel Vasilyev
a16bcd291d Bluetooth: Mesh: Avoid NULL pointer dereference in shell utils
bt_mesh_elem_find can return NULL.
This also gets rid of VLA in bt_mesh_shell_mdl_print_all.

Coverity-CID: 321075
Fixes #59522

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-22 12:34:23 +02:00
Emil Gydesen
8cd0758bdf Bluetooth: Shell: Move scan filter to function
Move the scan filter to a new function so that it may
be reused by other shell modules.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 12:28:12 +02:00
Emil Gydesen
3ede93f166 Bluetooth: BAP: Shell: Fix missing clear of txing_stream
If the stream is stopped or released, we did not clear the
txing_stream which is what would stop the sine from being
attempted to being sent.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 12:27:14 +02:00
Emil Gydesen
d9082cd5b4 Bluetooth: ASCS: Fix bad size of metadata_backup
The metadata_backup used the codec config size instead of
the metadata size.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 12:26:41 +02:00
Emil Gydesen
17ea3546d3 Bluetooth: BAP: Shell: Fix endianess of broadcast_id in adv data
The broadcast ID was encoded as big instead of little endian
in the advertising data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 06:16:23 -04:00
Emil Gydesen
c0d842bb55 Bluetooth: BAP: Shell: Remove duplicate increment of seq_num
The seq_num in lc3_audio_send_data was updated twice:
Once when calling get_next_seq_num and once at the end
of the function.

This increased the sequence numbers too fast, and made
TX not worker properly.

Modified to only use get_next_seq_num.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 06:16:11 -04:00
Théo Battrel
c5623c641a Bluetooth: Host: Check that conn is not NULL
In `gatt.c`, the function `bt_gatt_ccc_cfg_conn_lookup()` was not
checking that `conn` was not NULL. That leaded to a NULL pointer
dereferences later in `bt_conn_is_peer_addr_le`.

Fix by checking that `conn` is not NULL.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-22 06:15:54 -04:00
Andrey Borisovich
23b3cae1b1 inte_adsp: ipc: prevent ipc message send during Device power transition
When CONFIG_PM_DEVICE is enabled IPC Device may be during power transition
during a call to intel_adsp_ipc_send_message function.
Changed signatures of intel_adsp_ipc_send_message and its sync version
to return int and negative error codes on error.
On attempt to send IPC message during Device power transition
-ESHUTDOWN error code is returned, on busy state -EBUSY.
Updated all function references.

Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
2023-06-22 06:14:57 -04:00
Emil Gydesen
6815d9f720 Bluetooth: MCC: Shell: Format IDs as 64-bit (llu)
Fix formatting of the OTS object IDs to the proper
formatting.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 06:05:57 -04:00
Emil Gydesen
8d15cf2829 Bluetooth: CAP: Shell: Handle -ECANCELED error code specifically
If the procedure was called, we print a more specific string
to let the user know that there was not an actual issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 09:54:59 +00:00
Emil Gydesen
c2a730edc7 Bluetooth: Shell: Also parse Broadcast Name as a valid name
In the case that the advertising data has both a device name
and a broadcast name, whichever one comes first will be used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 08:14:28 +00:00
Lucas Tamborrino
d8332d1de5 debug: coredump: flash partition: Use K_NO_WAIT when in ISR
This code is meant to run in the context of a exception.
Most architectures will fail the asertion made in z_impl_k_sem_take()
when timeout is not K_NO_WAIT.

This commit ensures K_NO_WAIT is used when arch_is_in_isr() is true.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-06-21 16:06:06 -04:00
Aleksandr Khromykh
10ef3b46d8 Bluetooth: Mesh: fix provisionee public key usage
Provisionee shall fail if provisioner sent public key
identicall to OOB public key back.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-21 16:49:54 +02:00
Armin Brauns
3bef10f398 net: ip: always cancel IPv6 DAD when address is removed
If the address was removed immediately after being added (e.g. because the
interface MAC address is changed on boot), it would remain in the DAD timer
list.

In one scenario, the DAD timeout would eventually fire, causing the
now-removed address to be modified, potentially causing issues that way.

In another scenario, if the interface was immediately brought back up
again with a different link-local address, this new address would reuse the
first address slot on the interface. Starting the DAD process for this new
address would lead to the same address slot being added to the DAD timer
list a second time, causing an infinite list and associated lockup during
iteration.

Always remove the address from the DAD timer list when it is removed from
the interface, not just when DAD fails.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-06-21 16:07:21 +02:00
Troels Nilsson
7c6eb242a9 Bluetooth: Fix endianness handling for ext scan reports evt_type
evt_type is 16 bits and thus requires endianness conversion over HCI

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-06-21 16:06:36 +02:00
Kamil Gawor
82bff62276 ipc: icmsg: Align naming for buffers
This remanes send_buffer to tx_buffer to be
consistent with Rx buffer naming and with
mbox naming.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2023-06-21 15:56:02 +02:00
Kamil Gawor
b7f14ee94f ipc: icmsg: Improve packets reception
This improves packet reception and fix an issue
where packets bigger than internal Rx buffer
were silently dropped. In current solution
local data coping for reception is not needed.
User gets direct pointer to shared memory which
allow to efficient receive as much data as was sent.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2023-06-21 15:56:02 +02:00
Vinayak Kariappa Chettimada
8c7140a9c0 Bluetooth: Controller: Fix BT_CTLR_CENTRAL_SPACING to ticks conversion
Fix missing BT_CTLR_CENTRAL_SPACING in microseconds to ticks
conversion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-21 14:49:36 +02:00
Jamie McCrae
6877ad413f mgmt: mcumgr: smp: Allow preventing command execution via hook
Adds status checking to the command status hook which allows an
application to inspect a request and, optionally, reject it.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-21 13:24:12 +02:00
Jamie McCrae
0b6077443d mgmt: mcumgr: grp: img_mgmt: Add optional mutex lock support
Adds an optional Kconfig that adds mutex locks to image management
group functions, this prevents collision between multiple threads
and/or transports.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-21 13:24:01 +02:00
Jordan Yates
6271f2fa56 net: if: default NET_IF_LOWER_UP at compile time
The `net_if` layer should not be forcing `NET_IF_LOWER_UP` to be set on
all interfaces at runtime. Because `net_init` runs relatively late by
default, this is overriding any control the driver itself may have
performed using `net_if_carrier_on/off`.

Initialise this bit at compile-time instead. As the structure is already
being initialised, this doesn't increase any footprints.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-06-21 09:35:49 +00:00
Seppo Takalo
95cef5f3ab net: lwm2m: Ensure string termination
When writing string data to resources which are string types,
we should count in the terminating character into the data length.

Corner cases exist where LwM2M resource type is opaque but
lwm2m_get_string() or lwm2m_set_string() are used to read/write
the data. We must ensure string termination on those case, but
terminating character must not be stored in the engine buffer
or counted in the data length as this might be considered
as part of the binary data.

Fixes #59196

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-21 10:42:31 +02:00
Emil Gydesen
8b9815aff6 Bluetooth: IAS: Fix alert level loop
The loop was supposed to set the alert level to the highest
value by any device. The loop, however, only made sense if
CONFIG_BT_MAX_CONN > 1.

It has been modified to start from [0] instead of [1] and
the initial condition was modified.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-21 09:34:49 +02:00
Luca Fancellu
38a43b0eec net: config: Add VLAN identifier as network initial configuration
Add a new Kconfig parameter NET_CONFIG_MY_VLAN_ID as initial network
configuration to enable users to set VLAN identifier at startup.

Add a new setup_vlan(...) function to setup the VLAN identifier in
the device, the call have an effect only when NET_CONFIG_MY_VLAN_ID
is above zero.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-06-21 09:32:41 +02:00
Gerard Marull-Paretas
48b201cc53 device: make device dependencies optional
Device dependencies are not always required, so make them optional via
CONFIG_DEVICE_DEPS. When enabled, the gen_device_deps script will run so
that dependencies are collected and part of the final image. Related
APIs will be also made available. Since device dependencies are used in
just a few places (power domains), disable the feature by default. When
not enabled, a second linking pass will not be required.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
1ebd76ed51 pm: add prompt to DEVICE_DEPS_DYNAMIC
The option can now be set by projects. This change will also allow to
make it dependent on a future CONFIG_DEVICE_DEPS option.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
319fbe57e1 device: s/HAS_DYNAMIC_DEVICE_HANDLES/DEVICE_DEPS_DYMAMIC
Rename the Kconfig option to be in line with recent renamings in device
handles/dependencies.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
5982d83e2a device: s/struct device.handles/struct device.deps
Rename struct device `handles` member to `deps`, in line with previous
renamings in the device API.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
4eb406e093 device: s/DEVICE_HANDLE/DEVICE_DEPS/
Rename multiple internal device macros to use the DEVICE_DEPS naming, so
that it is clear they belong to the device dependencies APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
e5f82cb5dc device: hide DEVICE_HANDLE_SEP/ENDS
These macros are used internally by the device dependencies functions.
There's no need to expose them publicly, so prefix them with Z_ and add
them under INTERNAL_HIDDEN docs section.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Jamie McCrae
3e71797ba2 mgmt: mcumgr: grp: img_mgmt: Fix missing define
Fixes a missing define which causes a build failure.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-20 15:14:19 +02:00
Alberto Escolar Piedras
e59f6a8135 portability cmsis_rtosv2: Check return of k_mem_slab_init()
Instead of trusting blindly that k_mem_slab_init()
will succeed, let's check it, and handle failures
appropriately.
Otherwise, a buffer of garbage will be passed
around, leading to misterious failures later on.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-06-20 10:45:33 +00:00
Emil Gydesen
1f1e51ad6b Bluetooth: Shell: Fix typo in disconnected
A callback function had a typo where disconencted should
have been disconnected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-20 10:44:07 +00:00
Aleksandr Khromykh
a13157f997 Bluetooth: Mesh: fix missed old encryption in dfu metadata
PR fixes the old internal encryption api usage
for dfu metadata.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-20 10:10:19 +02:00
Aleksandr Khromykh
327eb119b6 Bluetooth: Mesh: add tf-m support for ble mesh
This PR adds ability to build mesh with tf-m psa
for platforms those support tf-m.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-19 15:04:17 +02:00
Michał Grochala
5ac063d793 bluetooth: controller: Fix build with BT_HCI_VS_EXT disabled.
Fixing error: undefined reference to 'vs_set_min_used_chans'
when building with 'BT_HCI_VS_EXT' option disabled.

Signed-off-by: Michał Grochala <michal.grochala@nordicsemi.no>
2023-06-19 11:02:14 +02:00
Aleksandr Khromykh
a322e4d20d Bluetooth: Mesh: clarification about adv local identity
BT_ID_DEFAULT is hardcoded in mesh. Added clarification about
the necessity of another local identity allocation for BLE
if it coexists with mesh.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-19 11:01:30 +02:00
Saravanan Sekar
bdb26cfe02 net: mqtt: close tcp socket after websocket_disconnect
websocket_disconnect api does not closes mqtt's tcp socket, so
tcp socket must be closed after done.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2023-06-19 09:18:45 +01:00
Saravanan Sekar
3c9f3b7849 net: websockets: do not close tcp socket in websocket
The websocket_connect api expects connected tcp socket, do not close
the user supplied socket so that the caller can re-use it if needed.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2023-06-19 09:18:45 +01:00
Victor Chavez
bee43bd972 logging: Fixed BLE backend buffer size independent of MTU
The BLE backend has a bug that when the MTU size is less than
the buffer the notification always fails and does not allow
to flush the buffer.

This fix checks for the MTU size of the current connection
and adjusts it. In addition, the buffer size is no longer
settable by the user and depends on the transmission size
of MTU set with CONFIG_BT_L2CAP_TX_MTU.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-06-19 08:38:08 +02:00
Florian Grandel
f32fae07f2 net: l2: ieee802154: fix endianness bug
The PAN ID in IEEE 802.15.4 frames is little endian while in the
IEEE 802.15.4 context it is kept in CPU byte order.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
267db64f39 net: l2: ieee802154: fix acknowledgment procedure
The ACK procedure had the following issues:

- MAC commands were not acknowledged.

- When the package is a broadcast package the package must not be
  acknowledged.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
7571be3261 net: l2: ieee802154: deprecate NET_L2_IEEE802154_ACK_REPLY
Acknowledgment is mandatory if legitimately requested by the package's
"ACK requested" flag. The L2 layer will have to ensure that compliant
ACK packages will always be sent out automatically as required by the
standard.

For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option is
therefore being deprecated.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
f96b620d12 net: l2: ieee802154: properly handle TX HW capabilities
The existing calls to ieee802154_radio_send() and soft MAC ACK handling
were inconsistent and/or not properly integrated with more recent
radio driver capabilities as CSMA/CA and ACK in hardware.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
1ee4d3ed77 net: l2: ieee802154: document L1/L2 sep. of concerns
The method ieee802154_radio_handle_ack() does not belong to the
PHY/radio layer but to the L2 layer. It is a callback called from the
radio layer into the L2 layer and to be implemented by all L2 stacks.
This is the same pattern as is used for ieee802154_init(). The
'_radio_' infix in this function is therefore confusing and
conceptually wrong.

This change fixes the naming inconsistency and extensively documents
its rationale.

It is assumed that the change can be made without prior deprecation of the
existing method as in the rare cases where users have implemented custom
radio drivers these will break in obvious ways and can easily be fixed.

Nevertheless such a rename would not be justified on its own if it were
not for an important conceptual reason:

The renamed function represents a generic "inversion-of-control" pattern
which will become important in the TSCH context: It allows for clean
separation of concerns between the PHY/radio driver layer and the
MAC/L2 layer even in situations where the radio driver needs to be
involved for performance or deterministic timing reasons. This
"inversion-of-control" pattern can be applied to negotiate timing
sensitive reception and transmission windows, it let's the L2 layer
deterministically timestamp information elements just-in-time with
internal radio timer counter values, etc.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
ffcae5f029 net: l2: ieee802154: separate CCA and retransmission
The IEEE 802.15.4 standard clearly separates clear channel assessment
from retransmission. This separation of concern was not represented in
the current channel access vs. retransmission implementation which
resulted in considerable duplication of code and logic.

This change removes the duplication of logic and encapsulates the
resulting functions in a private API that may only be used from within
Zephyr's native L2 layer.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
5827066ca9 net: l2: ieee802154: radio: fix csma/ca algorithm
The CSMA/CA algorithm had multiple issues:

- Timing of backoff periods depends on the PHY's symbol rate and other
  PHY-specific settings. We introduce a preliminary solution that works
  with current drivers. A fully standard-compliant long-term solution
  has already been conceptualized but requires further pre-conditions,
  see #50336 (issuecomment-1251122582).

- We enforce the condition defined in the standard that macMinBe must be
  less than or equal macMaxBe.

- According to the standard a CSMA/CA failure should lead to immediate
  abortion of the transmission attempt, no matter how many
  retransmissions have been configured.

- The number of retransmissions was off by one. It is now used as
  defined in the standard algorithm.

- Retransmissions are only allowed when acknowledgement is requested in
  the packet.

- prepare_for_ack() has side effects and must be called before each
  retransmission.

We also replace variables by constants where possible.

The function was renamed as it represents unslotted CSMA/CA and does not
support other CSMA/CA modes. These may be introduced in the future.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
f08b70549f net: l2: ieee802154: radio: fix aloha algorithm
The ALOHA algorithm had two minor implementation errors:

- The number of retransmissions was off by one.

- Retransmissions are only allowed when acknowledgement is requested
  otherwise it is to be assumed that the transmission was successful.

- prepare_for_ack() has side effects and must be called before each
  retransmission.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
6bfa52afe5 net: l2: ieee802154: fix CSMA/CA configuration ranges
The allowable ranges of several CSMA/CA-related settings were not
conforming to the standard, see IEEE 802.15.4-2020, section
8.4.3.1, table 8-94 (MAC PIB attributes). This change fixes the ranges.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Ingar Kulbrandstad
ce3317d03e Bluetooth: Mesh: Updated ACL configuration settings
Setting default value for BT_BUF_ACL_TX/RX_SIZE and
BT_CTLR_DATA_LENGTH_MAX to 37, as this will process the
incoming data the most efficient way.
When GATT is enable BT_BUF_ACL_RX_SIZE does not have to be 73,
as this will just give segmented messages for the public keys
exchange during provisioning.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-06-17 08:06:16 -04:00
Pavel Vasilyev
47e3c5386a Bluetooth: Mesh: Add option to disable Label UUIDs recovery
After adding support for virtual addresses with collision (where two
Label UUIDs have the same virtual address), the format of the data in
the persistent storage with the Label UUIDs which a model is subscribed
to or publishes to has been changed. The recovery code is added and the
Label UUIDs will be recovered by picking first Label UUID matching to
the virtual address in the subscription list or model publication. This
options can disable the recovery code and save some flash if the
recovery is not required (e.g. virtual address support wasn't enabled
before this option was added, or the devices were unprovisioned before
upgrading to the version with this option).

Making this option as deprecated to be able to drop support of this
option and remove the recovery code eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 08:00:55 -04:00
Pavel Vasilyev
648378b292 Bluetooth: Mesh: Add full virtual addresses support
This commit adds the following features related to virtual addresses
support:
- Allows to store Label UUIDs which virtual addresses collide;
- Allows to decrypt messages encrypted with a virtual address with
collision;
- Allows to publish a message to a specific Label UUID to avoid virtual
addresses collision by adding a pointer to Label UUID to
struct bt_mesh_msg_ctx and struct bt_mesh_model_pub;
- Allows to differentiate Label UUIDs in the model's Subscription List
by storing all subscribed UUIDs in struct bt_mesh_model.uuids field.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 08:00:55 -04:00
Pavel Vasilyev
1956b06ecc Bluetooth: Mesh: Don't poll friend when sending over loopback
When LPN sends a segmented message to itself, it unnecesseraly polls
Friend. Since Friend doesn't receive this message, the segmented message
transmission will eventually fail (send end callback will return error),
while the message will actually be passed to the access layer.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 08:00:55 -04:00
Théo Battrel
37cac7f2e2 Bluetooth: Host: Use custom API for Bluetooth settings
This commit wrap the `settings_set_one` and `settings_delete` functions
in `bt_settings_store_one` and `bt_settings_delete`. By doing that the
Bluetooth settings can be managed in a single place.

This commit also introduce a new API to manage Bluetooth storage with
`bt_settings_store_*` and `bt_settings_delete_*` functions. Each
Bluetooth settings key have their own store and delete functions. Doing
that so custom behavior for key can be done if necessary.

This change is motivated by a need of keeping track of different
persistently stored settings inside the Bluetooth subsystem. This will
allow a better management of the settings that the Bluetooth subsystem
is responsible of.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-17 07:58:07 -04:00
Daniel Leung
e734911c96 ztest: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
c1d9dc4f18 rtio: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
c51d80fd40 random: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
1e1ab38bf0 net: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
cacefd4c33 mgmt: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
057ceb1408 logging: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Ajay Parida
041201b0d1 net: wifi_mgmt: Reject TWT setup till IP address is configured
If a user tries to enable TWT too early in the connection, then we might
enter TWT sleep even before DHCP is completed, this can result in packet
loss as when we wakeup we cannot receive traffic and completing DHCP
itself can take multiple intervals. Though static ip address can be
assigned too. Reject TWT till Wi-Fi interface has
a valid IP address.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-17 07:56:17 -04:00
Gerard Marull-Paretas
b617f03439 bluetooth: controller: rv32m1: configure debug pins in DEBUG_INIT
The debug pins were configured in a board specific file, however, the
subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h file
already contains board-specific pins, meaning there's no need to split
the information in 2 places. Move the GPIO configuration calls to the
DEBUG_INIT() macro in the controller debug header.

Note that in the future, Devicetree should be used to provide a
hardware-agnostic debug module.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-17 07:50:21 -04:00
Morten Priess
3cecb92e53 Bluetooth: controller: Fix CIS peripheral conditional offset_min
When config BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START is enabled, the
minimum accepted offset value in the CIS_REQ is the minimum defined by
the spec.
Add define CIS_MIN_OFFSET_MIN with value 500 us, as defined in the Core
spec. The previously used value of 400 us was incorrect.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-06-17 07:48:01 -04:00
Bjarki Arge Andreasen
22152915ab drivers/gsm_ppp: Update existing modules to use PPP L2
This commit replaces the workarounds spread around the
drivers and subsystems with the updated PPP L2
interface.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-06-17 07:46:21 -04:00
Bjarki Arge Andreasen
df88664864 subsys/net/ppp: Make NET L2 PPP use net_if properly
Currently, the L2 PPP subsystem is not using the network
interface subsystem appropriately. Here are the issues:

1. net_if_up hidden away internally in net L2 PPP
2. net_if_down not used at all...
3. net_if_carrier_on / off is not used, a workaround is
   used instead, which results in duplicated code
4. L2 PPP does not listen for network events, instead
   it needs the workaround callbacks from drivers.
5. The carrier_on workaround is delegated to a complex
   and broken sys work queue item.

This commit fixes all above issues. net_if_up/down and
net_if_carrier_on/off now work as expected. workaround
for carrier_on/off has been removed.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-06-17 07:46:21 -04:00
Aleksandr Khromykh
29895d8275 Bluetooth: Mesh: refactor mesh to use both tinycrypt and psa based crypto
A mesh key type has been added to be able to choose the different
key representation for different security libraries.
The type as well as some functionality related to Mesh key
management has been added as a public API.
If tynicrypt is chosen then keys have representation
as 16 bytes array. If mbedTLS with PSA is used then keys are
the PSA key id. Raw value is not kept within BLE Mesh stack
for mbedTLS. Keys are imported into the security library
and key ids are gotten back. This refactoring has been done
for the network(including all derivated keys), application,
device, and session keys.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-17 07:46:03 -04:00
Guangfu Hu
335278d60a sensing: initial sensor list and enumerate each sensor
Implement sensing_init():
	1) create sensors from device tree
	2) sequence sensors following node dependency ordering rule generated by
	   Zephyr DTS
	3) initial each sensor, includes:
		a) creating sensor connection between reporter and client,
		b) calling sensor init callback,
		c) setting sensor state
Implement sensing_open_sensor():
	1) malloc connection from reporter to application
	2) bind connection
Implement sensing_close_sensr():
	1) unbind connection
	2) free connection from reporter to application
Implement sensing_set_config():
	1) call set_interval
	2) cann set_sensitivity
Implement sensing_get_config():
	1) call get_interval
	2) call get_sensitivity

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
2023-06-17 07:43:25 -04:00
Zhang Lixu
25ca09ea01 sensing: phy_3d_sensor: add phy_3d_sensor skeleton
Add the sensor phy_3d_sensor skeleton in Sensing Subsystem.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-06-17 07:43:25 -04:00
Zhang Lixu
685160b4bf sensing: add Sensing Subsystem skeleton
Add Sensing Subsystem skeleton.

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-06-17 07:43:25 -04:00
Emil Gydesen
118a68518a Bluetooth: Shell: bt connect-name should only attempt connectable
The auto-connect by name did not verify that the found device
was connectable before attempting to connect.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-17 07:38:40 -04:00
Pavel Vasilyev
c301ed07ca Bluetooth: Mesh: Regenerate private beacon even when disabled
Even if PRB state is disabled, PRB can still be sent over GATT if Proxy
Privacy parameter is enabled. In such case PRB won't be regenerated.
To keep the privacy of the network, PRB should be regenerated when sent
over GATT regardless of PRB state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Pavel Vasilyev
dfb8bcaf38 Bluetooth: Mesh: Fix Proxy Privacy parameter support
According to section 6.7, upon connection Proxy Server shall determine
value of Proxy Privacy parameter (sections 6.5 and 7.2.2.2.6). Depending
on that, it will either send Secure Network Beacon or Private Beacon to
Proxy Client, but never both.

Proxy Privacy parameter is determined by GATT Proxy, Node Identity
states and their private counterparts (section 7.2.2.2.6). Since
non-private and private states are mutually exclusive, it is enough to
only check either Private GATT Proxy state or Private Node Identity
state of any known subnet for which the state is currenty enabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Pavel Vasilyev
c952cf4818 Bluetooth: Mesh: Fix binding between proxy related states
Fix binding between GATT Proxy, Node Identity and their private
counterpart states according to sections 4.2.45.1 and 4.2.46.1
accordingly. When non-private state is enabled, the private counterpart
is disabled. The reverse binding prohibits change of non-private state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Pavel Vasilyev
2d13329eca Bluetooth: Mesh: Store Private GATT Proxy state persistently
State should be stored persistently.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Jonathan Rico
931a089e2c Bluetooth: host: invalidate the RPA when starting legacy adv
This fixes the failure to use a resolvable private address in this
scenario.

1. call `bt_le_oob_get_local`, will generate and mark RPA as valid
2. start connectable adv w/ IDENTITY bit
3. start connectable adv w/o IDENTITY
4. RPA is not set (in `bt_id_set_private_addr`) because RPA
   is still marked as valid

When EXT_ADV is enabled and the controller supports it, a different code
path is taken that doesn't have this issue.

Unconditionally invalidating the RPA when starting advertising works around
this issue.

Fixes #56326

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-06-17 07:36:58 -04:00
Alberto Escolar Piedras
8444343511 usb: device: class: rndis: Fix for 64bit platforms
Instead of assuming pointers are 32bits wide,
cast them to the appropriate pointer arithmetic type.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-06-17 07:36:36 -04:00
Donatien Garnier
cf0350e021 Bluetooth: Host: Re-order LE L2CAP connection accept procedure
Currently, when an incoming dynamic LE L2CAP connection is requested by
a peer, the connected() callback provided by the user is raised
*before* a L2CAP_LE_CREDIT_BASED_CONNECTION_RSP is sent back to the
peer.
In some cases the user will start sending data in the connected()
callback which would be received too early by the peer.
This commit fixes this behavior by making sure the connected() callback
is raised only after the connection response has been sent to the peer.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-06-17 07:33:11 -04:00
Florian Grandel
b224a099fd net: l2: ieee802154: standardize RSSI value
The RSSI value in net_pkt (net_pkt_cb_ieee802154.rssi) was used
inconsistently across drivers. Some drivers did cast a signed dBm value
directly to net_pkt's unsigned byte value. Others were assigning the
negative value of the signed dBm value and again others were offsetting
and stretching the signed dBm value linearly onto the full unsigned byte
range.

This change standardizes net_pkt's rssi attribute to represent RSSI on
the RX path as an unsigned integer ranging from 0 (–174 dBm) to 254 (80
dBm) and lets 255 represent an "unknown RSSI" (IEEE 802.15.4-2020,
section 6.16.2.8). On the TX path the rssi attribute will always be
zero. Out-of-range values will be truncated to max/min values.

The change also introduces conversion functions to and from signed dBm
values and introduces these consistently to all existing call sites. The
"unknown RSSI" value is represented as INT16_MIN in this case.

In some cases drivers had to be changed to calculate dBm values from
internal hardware specific representations.

The conversion functions are fully covered by unit tests.

Fixes: #58494

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 07:16:32 -04:00
Théo Battrel
363676764a Bluetooth: Host: Fix wrong ID being stored
Fix an issue causing a wrong Bluetooth identity value to be stored. It
was happening because the `bt_dev.id_count` was incremented after the
settings being stored.

To fix this, `bt_dev.id_count` is now incremented right before the ID
creation and is decremented if the ID creation failed.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-16 07:57:46 -04:00
Mingjie Shen
b2c00ec032 net: utils: fix offset used before range check
This use of offset 'i' should follow the range check.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-06-16 05:46:05 -04:00
Maxim Adelman
ecf2cb5932 kernel shell, stacks shell commands: iterate unlocked on SMP
call k_thread_foreach_unlocked to avoid assertions caused
by calling shell_print while holding a global lock

Signed-off-by: Maxim Adelman <imax@meta.com>
2023-06-15 05:55:56 -04:00
Jamie McCrae
1edc8cc762 mgmt: mcumgr: grp: img_mgmt: Fix using signed values
Fixes wrongly using signed values for slot and image number when
listing images.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-14 13:47:08 -04:00
Ajay Parida
6002061efe net: wifi_mgmt: Pass address instead of value as pointer
Fix for not getting expected event information at application.
net_mgmt_event_notify_with_info() expects the address
not the value as pointer.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-13 08:28:43 -04:00
Jamie McCrae
5f9737f482 mgmt: mcumgr: fs_mgmt: Fix duplicate bool ok variables
Fixes wrongly declaring duplicate local variables that already
exist and hiding the previous variables definitions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-13 07:10:43 -04:00
Emil Gydesen
7bce75bd0d Shell: Add missing long long type in shell_strtoull
shell_strtoull used a unsigned long instead of a unsigned
long long to store the result in stroull, so the return
value may have been truncated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-13 07:08:04 -04:00
Juha Heiskanen
d6c85c2f59 net: coap: CoAP reply handler fix
Fix corner case when client RX request with same token than
own request where it wait responses.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-06-13 07:06:08 -04:00
Pavel Vasilyev
8902de75eb Bluetooth: Mesh: Print UUID with correct endianess
bt_uuid_str expects UUID in little endian while UUID encoded into
unprovisioned mesh beacon is encoded in big endian. sys_memcpy_swap will
change endianess of uuid so that bt_uuid_str can be used.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-13 07:05:21 -04:00
Pavel Vasilyev
21b5d423e8 Bluetooth: Mesh: Fix printing UUID log message
CONFIG_BT_MESH_PROV_DEVICE_LOG_LEVEL_INF may not be present while
CONFIG_BT_MESH_PROV_DEVICE_LOG_LEVEL is always present.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-13 07:05:21 -04:00
Tomasz Moń
ae6c856128 usb: device: class: rndis: Limit response length
Prevent potential buffer overflow when encapsulated response is more
than CONFIG_USB_REQUEST_BUFFER_SIZE. Log error and truncate response if
USB control transfer request buffer is not large enough.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-06-13 07:02:49 -04:00
Emil Gydesen
bb81b42861 Bluetooth: TBS: Ensure that inst exist when notifying terminate
When calling the `terminate_call` the `inst` would always be NULL
as we had just terminated the call that we attempted to look up.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-13 07:00:02 -04:00
Florian Grandel
d451895907 net: l2: ieee802154: fix buffer pointer ref
The uncast reference caused a cbprintf() warning on the console.

Fixes: #59125

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-13 06:58:57 -04:00
Florian Grandel
8d8faae3e7 net: l2: ieee802154: shell: fix printing ext addr
A bug was introduced in one of my earlier commits: The shell does no
longer print the full extended address. Fixes the issue.

Fixes: #59125

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-13 06:58:57 -04:00
Florian Grandel
378f0dd29d net: lib: zperf: fix kernel panic due to invalid thread prio
Compiling an application with CONFIG_NET_ZPERF=y leaving
CONFIG_ZPERF_WORK_Q_THREAD_PRIORITY at its default value would
systematically cause a kernel panic during thread initialization.

The Kconfig variable is NUM_PREEMPT_PRIORITIES by default. Application
threads may not define a priority lower than NUM_PREEMPT_PRIORITIES - 1,
though.

This change limits zperf's thread priority to a valid range. It does not
change the default value as it makes sense to default the thread
priority to the lowest possible value (which is NUM_PREEMPT_PRIORITIES)
but Kconfig does not allow for arithmentic. So the combination of
CLAMP() plus the Kconfig default will ensure min priority plus limit the
range to valid values no matter what has been defined as priority in
Kconfig.

Fixes: #59141

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-13 06:58:15 -04:00
Robert Lubos
8287e56fa3 net: context: Verify that laddr was set before use in connect
In previous patch fixing this issue, I've missed the fact that offloaded
drivers would not set the context->local address, which resulted in a
regression, where the previously introduced assert would hit in
offloaded cases. Not setting laddr is not a problem in case of
offloading, as it's only used in net_tcp_connect() which would not be
reached in this case.

Therefore I propose to remove previous patch to get rid of regression.
As an alternative fix, verify the laddr just before use, so that it is
only checked when native net stack is in use.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-12 14:03:04 -04:00
Robert Lubos
ad33d03dce Revert "net: context: Fix ambigous pointer check in net_context_connect()"
This reverts commit 22b889e3b4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-12 14:03:04 -04:00
Chaitanya Tata
1b7ef97c31 net: l2: ethernet: Fix IPv6 Kconfig
Function net_if_ipv6_addr_rm is only defined for NATIVE_IPV6.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-12 07:40:43 -04:00
Vinayak Kariappa Chettimada
fc210a8cee Bluetooth: Controller: Fix disable all advertising sets
BlueZ stack in Linux distributions use disable all
advertising sets when advertising is turned off.

Add missing implementation to support disabling all
active advertising sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-12 07:28:25 -04:00
Vinayak Kariappa Chettimada
05aabdc6d9 Bluetooth: Controller: Rework internal header includes
Rework internal header files to not have includes, rather
have the required includes in the c source files.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-12 06:20:24 -04:00
Carles Cufi
22f73992b2 Bluetooth: Rework the HCI header set
In order to have clean, self-contained HCI headers that do not have any
dependencies towards the Host or any other part of the system (except
types), reorganize the headers in the following way:

- Split out the macros and structs from hci.h to a new hci_types.h
- Merge the existing hci_err.h into the new hci_types.h

Fixes #58214.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-12 06:20:24 -04:00
Lars Knudsen
a7254b85e1 shell: Fix BT verbose scan logging
Fix endianness printout of values.

Handle service data output with initial UUID.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-06-11 05:08:08 -04:00
Emil Gydesen
7712f81171 Bluetooth: CAP: Shell: Add cmd_cap_initiator_unicast_cancel
Add cmd_cap_initiator_unicast_cancel to call the cancel
function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:39 -04:00
Emil Gydesen
e9c1be88ca Bluetooth: CAP: Add Initiator cancel procedure
Add function to cancel any current proecedure. This is useful
in cases where the connection to one or more acceptors is lost
or if some acceptor does not respond to our requests for whatever
reason.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:39 -04:00
Emil Gydesen
65c2f8ef37 Bluetooth: BAP: Release stream on codec config if requested
An ASCS endpoint may go into either the idle or codec configured
state when a stream is released. However since we have such a high
coupling between audio streams and endpoints, we need to consider
the endpoint as having been released (i.e. gone to the IDLE state).

This is handled by a boolean state variable for now, but we may
want to consider a more generic approach where streams and
endpoints may be less coupled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:15:37 -04:00
Emil Gydesen
f3f8380296 Bluetooth: BAP: modify when ASCS disconnects the CIS
When an audio stream in a bidirectional CIS is released,
it should not disconnect the CIS if there is still a stream
for the opposite direction streaming. Only if both streams
are not in a streaming state, should ASCS attempt to disconnect
the CIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:15:37 -04:00
Emil Gydesen
bc89eabfdd Bluetooth: BAP: Remove bad log error from bt_audio_valid_codec
There was a LOG_ERR from debugging.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:14:12 -04:00
Emil Gydesen
1a3fd597a8 Bluetooth: ISO: Log status as hex instead of decimal
Log status values in events as hex instead of decimal
to make it easier to compare to the spec and hci_err.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-09 14:16:15 -04:00
Lars Knudsen
fb408077df shell: Fix shell_vfprintf when vt100 is disabled
Without this fix, for every call to shell_vfprintf,
a prompt string and vt100 codes are printed too,
resulting in mangled log output.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-06-09 11:44:49 -04:00
Emil Gydesen
028e0a3c8d Bluetooth: Shell: On disconnect set new default_conn
When a device disconnects we previously just unref'ed it and
set default_conn = NULL. However, if we are connected to mulitple
devices, it makes sense to set the default_conn to one of the
other connections.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-08 11:50:34 -04:00
Emil Gydesen
f282ce90cc Bluetooth: MPL: Modify parse_search to use bt_data_parse
Modify the implementation of parse_search to use a
net_buf_simple and bt_data_parse to parse the LTV
search structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-08 11:49:58 -04:00
Carles Cufi
c0c2c6e35c Bluetooth: Host: Set valid default for secondary adv phy
Set the secondary advertising PHY to a valid value when using
legacy advertising through the LE Set Extended Advertising Parameters
command.

Fixes #57885.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-08 09:33:30 -04:00
Nathan Olff
685476d7e0 tracing: sysview: implement SEGGER_SYSVIEW_APP_NAME
Implement APP_NAME define in Kconfig for Segger SystemView module.
Use APP_NAME in Systemview initialization function

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2023-06-08 06:51:03 -04:00
Nathan Olff
833a228db4 tracing: sysview: implement RTT channel selection through KConfig
Implement Kconfig value for selecting the RTT channel to be used
by Segger SystemView

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2023-06-08 06:51:03 -04:00
Vinayak Kariappa Chettimada
466f3e8e70 Bluetooth: Controller: Fix cis_offset_min to have additional margin
As the coarse tick of ACL prepare and CIG prepare jitter by
+/- 1 tick, hence when initially scheduling the CIG place it
with enough margin so that cis_offset_min calculated when
there already exists a CIG can be larger than peer's
cis_offset_min being negotiated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:50:41 -04:00
Vinayak Kariappa Chettimada
4195ba5870 Bluetooth: Controller: Fix read ISO Tx Sync for Broadcast ISO
Fix missing read ISO Tx Sync for Broadcast ISO feature.

Co-authored-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:48 -04:00
Vinayak Kariappa Chettimada
48f6411416 Bluetooth: Controller: Fix Broadcast ISO interval unit
Fix incorrectly stored Broadcast ISO interval in
microseconds instead of storing in 1.25 ms units.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:48 -04:00
Vinayak Kariappa Chettimada
52c5ce97d4 Bluetooth: Controller: Update BT_CTLR_ISOAL_SN_STRICT help text
Update BT_CTLR_ISOAL_SN_STRICT help text.

Co-authored-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:25 -04:00
Vinayak Kariappa Chettimada
5f38c4ba71 Bluetooth: Controller: Fix Tx ISO SDUs dropped due to strict SN check
Introduce a Kconfig BT_CTLR_ISOAL_SN_STRICT to relax the Tx
ISO Data SDUs being dropped due to strict check of sequence
numbers in ISOAL, i.e. dropped when ISO Data SDUs are
delayed from upper layer with respect to the current
payload number in the ISO radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:25 -04:00
Vinayak Kariappa Chettimada
54aa6f1075 Bluetooth: Controller: Fix ISOAL sink create role for ISO Receiver
Fix ISOAL sink create role for ISO Receiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 12:25:31 +02:00
Pavel Vasilyev
242c8f1c77 Bluetooth: Mesh: Avoid undefined behavior in bit shift in blob_cli.c
block_size_log can be 0x20 which will shift 1 by 32 bits which will
cause undefined behavior. Adding ULL to 1 is an option but this will add
little bit more code when debug option is enabled. So simply print the
logarithmic value.

Coverity-ID: 316387
Fixes #58951

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-08 04:11:29 -04:00
Théo Battrel
cfd368fef1 Bluetooth: Host: Fix GATT server handling of CCC
GATT server was not doing enough check before udpating the CCC.

For example, a non-bonded client could update the CCC of a bonded client
by spoofing his address.

This fix the issue by dissociating the CCC configuration of a bonded and
a non-bonded peer. To do that, a new field is added to the CCC config:
`link_encrypted`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-08 04:10:58 -04:00
Lingao Meng
b6fc474777 Bluetooth: Mesh: Fix unable sent mesh message
In PR (#58723) has introduce another bug, that,
the flag ADV_FLAG_PROXY set before actually enabled.

When ctx:: BT RX call schedule_send will atomic_test_and_clear
ADV_FLAG_PROXY, but at this time, the proxy advertising will
not at advertising state, maybe in update params or set adverting
data phase,

so that, call bt_le_ext_adv_stop will nothing, and then call
k_work_reschedule --> send_pending_adv(at this time, the proxy
advertising actually enabled, but the upper layer clear proxy flags),
cause latest advertising unable start, because unable in advertising
state to update params(-EINVAL).

Fixes: #58721

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-06-08 04:09:04 -04:00
Robert Lubos
22b889e3b4 net: context: Fix ambigous pointer check in net_context_connect()
Coverity reported, that laddr pointer used in net_context_connect()
could be passed as NULL to net_tcp_connect() where it could be
dereferenced. This is because the actual setting of laddr to a valid
address structure was only done after
net_sin/sin6_ptr(&context->local)->sin/sin6_addr verification.

In practice though, the aforementioned pointer verification would always
pass, as the bind_default() guarantee that the context->local address is
set to an unspecified address (if it hasn't been set earlier).

Therefore refactor the code a bit: replace the pointer verification
with NET_ASSERT - only to assure that we can catch regression in case
for any reason the behavior of bind_default() changes. This should also
ensure that Coverity no longer reports that laddr is NULL when reaching
net_tcp_connect().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 19:43:20 -04:00
Robert Lubos
233524f471 net: ieee802154_mgmt: Fix memcpy to uninitialized pointer location
As since commit bff6a5c, params.dst.ext_addr is no longer assigned with
the ctx->coord_ext_addr pointer, but a endianness swap is included, it
should be assigned with a proper buffer before the memcpy.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:12:18 -04:00
Robert Lubos
f9a818cc56 net: websockets: Fix implicit type conversion Coverity warning
Coverity reported potential issues with implicit signed/unsigned type
conversions and potential problems with this. Fix this, by casing the
byte-shifted data variable to uint64_t type explicitly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:11:46 -04:00
Robert Lubos
e5aa433f87 net: lwm2m: Fix pointless variable assignment
Coverity reported that assigning ret = 0 is pointless, as in any
scenario (loop continues or ends) the ret variable is overwritten
anyway, w/o using the assigned value. Therefore remove the needless
assignment.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:07:09 -04:00
Robert Lubos
479036165c net: lwm2m: Fix possible out-of-bound access when creating FW object
obj_inst_id should not be used directly to index the instance array, as
the instance ID is not tightly bound to the maximum instance count and
can exceed this value, causing out-of-bound access.

Therefore, perform some extra validation when choosing the array index
for the object instance to make sure we stay in the array bounds, or
return an error if there's no more room for more object instances, in a
similar way it's done for Security object.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:06:52 -04:00
Robert Lubos
e96f1d7b47 net: lib: coap: Fixed unchecked send return value in CoAP client
The retransmission attempt in CoAP client library did not verify the
send result.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:06:29 -04:00
Robert Lubos
7deabaa77b net: tcp: Fix possible double TCP context dereferencing
In case TCP connection is being closed from the TCP stack, due to for
instance retransmission timeout, the stack should also switch the TCP
state to CLOSED. Otherwise, there was a risk of dereferencing the TCP
context twice, for example if the application was in active socket
send(), and tried to reschedule data transmission.

Additionally, make sure that the TCP_CLOSED state handling is a no-op
state - otherwise, there is a risk that if packets keep incoming before
the application dereferences the TCP context on its side, TCP stack
will incorrectly dereference the context for the second time from
within due to current TCP_CLOSED state logic.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-06 11:11:22 -04:00
Mariusz Skamra
a84ecc2f96 Bluetooth: audio: tbs_client: Remove GATT subscriptions upon disconnection
As long as we do not have NVS support in TBS, the subscriptions shall be
removed once ACL is disconnected to avoid potential crash on
reconnection, as the subscription parameters might be not valid anymore.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-06 11:10:10 -04:00
Mariusz Skamra
2d593a1e8d Bluetooth: audio: tbs_client: Fix missing cleanup
This fixes repeated attempt to bt_tbs_client_discover that failed
because srv_inst->current_inst was not cleared during previous discovery
process. The issue seen in case the GATT Read CCID returned an error.
The code has been factored out to separate helper function.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-06 11:10:10 -04:00
Mariusz Skamra
6656d33a90 Bluetooth: audio: tbs_client: Fix possible override of GATT read parameters
This fixes missing guard access to GATT read parameters.
The code checks `busy` flag and returns an error in case there's ongoing
GATT Read operation already.

Fixes: #58425
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-06 11:10:10 -04:00
Mark Oude Elberink
67dd58418f net: mqtt-sn: fix port in mqtt-sn debug message
The port we are connecting to is stored in network byte order,
thus, we need to convert it to the CPU's byte order before logging

Signed-off-by: Mark Oude Elberink <mark@oude-elberink.de>
2023-06-06 09:40:52 -04:00
Armin Brauns
fdde5bd7ef net: tcp: populate context's local address for incoming connections
`local_addr` would only be initialized if `context->local->sin*_addr` was
non-null. However, since `context` is a fresh context object, `local_addr`
always remains at its initial value of `INADDR_ANY`, which is propagated to
the context by `net_context_bind()`.

By populating `local_addr` using the TCP endpoint, `getsockname()` now
returns the correct local address.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-06-06 09:40:36 -04:00
Seppo Takalo
a1cfe983b6 net: lwm2m: Allow overiding of default socket behaviour
In order to support external IP stacks that might have Connection
ID support, the LwM2M engine should allow client to bypass default
behaviour.

New set_socketoptions() callback added into client context
that allows overriding all socket opetions. This is called
after a socket is opened, but before the connect() is
called. This cannot be combined with load_credentials() callback
on all platforms as for example nRF91 requires modem offline
when credentials are written. This would cause socket to be closed
as well.

Second change is that we allow fine tuning of what we do with
socket handle when QUEUE mode is enabled and engine enters idle
state.

First option would be to close the socket. That would cause
TLS Alert(Close Notify) to be send. This is a band choice if
LTE modem was already in PSM or eDRX power saving mode.

Second option would be to delay socket closing until we
are going to send LwM2M update. There TLS Alert is also send,
but most probably lost due to NAT mapping timed out. This
is a best choice for LTE modem with DTL session cache enabled.

Two new options are to keep socket open, and either stop listening
or just keep listening. Both of these options work fine when
we have DTLS Connection ID support.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-06 09:40:16 -04:00
Nirosharn Amarasinghe
ff89e98cc6 Bluetooth: controller: Release missing / lost SDUs for framed PDUs
-- Implemented reporting of lost / missing SDUs for framed PDUs. This
   should result in SDUs being released when only framed padding PDUs or
   error PDUs are received.
-- Removed unused configuration params structure, storage and linked
   APIs.
-- Reduced default logging level to INF instead of DBG.
-- Included debug logging messaged for framed consumption.
-- Removed separate latency_unframed and latency_framed and replaced
   with a common sdu_sync_const as they are mutually exclusive for each
   sink.
-- Restricted framed time stamp calculation only to situations where all
   dependent information is available.
-- Corrected SDU sequence numbering to release starting at zero.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Nirosharn Amarasinghe
40dde5b7bd Bluetooth: controller: fix time-wrapping of cig_ref_point
Time wrapping was omitted at some points. These were corrected or
clarified.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Nirosharn Amarasinghe
0398d8ddf6 Bluetooth: controller: Release SDU as missing if RX only unf. padding
Based on interpretation of Clarification Errata ES-22876 Request for
Clarification - Recombination actions when only padding unframed PDUs
are received, it was decided that an SDU should be released as "Missing"
when only padding PDUs are received for any SDU.
- https://bluetooth.atlassian.net/browse/ES-22876

This change will also assist streaming in the Common Central design
where the central was found to send only padding PDUs before streaming
starts.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Robert Lubos
2e0b0af44e net: lwm2m: Fix lwm2m_socket_start() error handling
In case lwm2m_socket_start() internal error, it should only do cleanup
on the socket, i. e. call lwm2m_socket_close(), not lwm2m_engine_stop().
The latter resets the entire lwm2m_context, which results in removal of
active observations.

This should not be done, as it collides with the RD client logic, where
connection resumption may skip the full registration phase, in result
not notifying the server that it should restart the observations.

At the same time, the RD client should clean the lwm2m_context when it's
done trying to update the registration and proceeds with regular
registration/bootstrap in the network error handler. In that case, only
the socket was closed, so the lwm2m_context needs to be reset
separately.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-06 06:51:34 -04:00
Emil Gydesen
c764c34232 Bluetooth: BAP: Improve handling of ASCS notification error
If the num_ase == 0xff then it is a special case that needs to be
handled like if num_ase == 0x01.

If there is an error with ase_id = 0x00 then the error cannot
be translated to a specific stream, so the callbacks may now get
NULL for the stream object.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-06 09:35:16 +02:00
Théo Battrel
7d9fe3d0b1 Bluetooth: Host: Fix GATT Store on Write
When CCC or CF store on write is disabled and the other one is enabled,
leading to the delayed store being enabled. This cause the value of the
corresponding `n` selected option to not be stored at all.

To fix this, the checks to know if we need to store the CCC or the CF,
happening at the disconnection, are now ensuring that the CCC or the CF
are stored even if the one of them does not enable store on write.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-05 13:54:37 -04:00
Emil Gydesen
6652eb7be8 Bluetooth: Shell: Update framing and packing checks in cmd_cig_create
The checks are now less generic and avoids a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 10:50:11 -04:00
Emil Gydesen
07f986b2e8 Bluetooth: BAP: Remove lower check in BT_BAP_BASS_VALID_OPCODE
Remove the lower check (BT_BAP_BASS_OP_SCAN_STOP) in
BT_BAP_BASS_VALID_OPCODE as it is always used on unsigned
variables, so no point in check if it is lower than 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 10:49:29 -04:00
Dominik Ermel
f9ebb72a9f nvs: Fix missing nvs_ate.part init in nvs_add_gc_done_ate
Add initialization.

Fixes #58691

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-06-05 10:49:15 -04:00
Emil Gydesen
1b9645c6a6 Bluetooth: BAP: Broadcast assistant add idx check for read recv state
Add check for the index in the function itself, as well as where
we call it internally, to ensure that we do not attempt to access
invalid indexes of broadcast_assistant.recv_state_handles.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 10:48:45 -04:00
Mariusz Skamra
0f44fac75c Bluetooth: audio: has: Fix conditional check
This fixes missing `CONFIG_*` prefix.
The `BT_HAS_PRESET_CONTROL_POINT_NOTIFIABLE` option is already guarded
with `BT_HAS_PRESET_SUPPORT`, so it has been removed from `depends on`
condition.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-05 16:24:18 +02:00
Mariusz Skamra
21599a6b14 Bluetooth: audio: has: Fix building with preset support disabled
This fixes regression causing compilation errors seen when the
code is built without preset support (BT_HAS_PRESET_COUNT = 0).

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-05 16:24:18 +02:00
Dominik Ermel
5cdfeffea1 nvs: Fix writing uninitialized nvs_ate.part on close
nvs_sector_close has not been initializing nvs_ate.part, before
writing it to flash.

Fixes #58699

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-06-05 08:33:34 -04:00
Emil Gydesen
192a236c0f Bluetooth: TBS: Added assert in discover_next_instance for inst lookup
Added assert when looking up the next instance, as the caller of this
function should ensure that the index is correct before calling
discover_next_instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:33:16 -04:00
Emil Gydesen
ba7fde1bae Bluetooth: Audio: Shell: Fix use of IN_RANGE when MIN is 0
If the minimal value of an IN_RANGE is 0, then it is
a useless check, and the cases have been modified to
not use IN_RANGE. This also fixes some coverity issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:32:43 -04:00
Emil Gydesen
4e1020e742 Bluetooth: BAP: Fix bad check in audio_stream_qos_cleanup
The check was a && but should have been an ||. Fixed by moving
the check to a new if statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:32:27 -04:00
Emil Gydesen
bff6eca6d4 Bluetooth: TBS: Add missing NULL check when notifying terminate
When notify_app is called for BT_TBS_CALL_OPCODE_TERMINATE
we did a lookup on the call index, but never did a NULL check
before dereferecing it.

This does not fix the issue that the instance will always
be NULL in this case, as we have terminated the call so
we cannot possibly look up the call afterwards.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:32:03 -04:00
Emil Gydesen
738e23efb8 Bluetooth: TBS: Fix copy of friendly name
The friendly copy always assumed that the friendly name could
fit in memory, which could cause overflows. Fixed by using
utf8_lcpy as that not only ensures that the copy is truncated
to fit in memory, but also ensures that it is null terminated
and truncated in a way that supports multi-byte UTF8 characters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:31:46 -04:00
Aleksander Wasaznik
a4e7b53d4b Bluetooth: Host: Fix bt_addr_from_str for str starting with ':'
The previous implementation would read from `addr->val[0]` before it was
initialized if the input string started with a colon ':'.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-05 08:31:06 -04:00
Emil Gydesen
09c1d412af Bluetooth: ASCS: Add missing return check for bt_conn_get_info
We never checked the return value before accessing the
returned information.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:30:10 -04:00
Anders Storrø
e4c7ce3316 Bluetooth: Mesh: Remove unintentional dbg string
Remove debug string that accidentally got merged to
the mesh shell cfg file.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-06-05 08:29:14 -04:00
Emil Gydesen
b49d981e36 Bluetooth: BAP: Unicast client add stream->conn checks
Add checks for the stream->conn before we attempt to use it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:07:28 -04:00
Jamie McCrae
942fc8517f mgmt: mcumgr: grp: fs_mgmt: Fix unchecked return value
Fixes a coverity issue whereby a return value was not checked.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-05 07:06:37 -04:00
Emil Gydesen
9c13b85665 Bluetooth: OTS: Fix offset maximum range check
If offset is only 32-bit, then it can never be > UINT32_MAX,
so added another conditional that only if the type (off_t) is
larger than 32-bit, we perform the maximum value check.

off_t is not a standard type and thus the size of it is poorly
defined, and are just defined as a signed integer type.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:06:19 -04:00
Emil Gydesen
7435c66972 Bluetooth: IAS: Fix coverity issue with IAS client lvl check
The check compared the levels against < BT_IAS_ALERT_LVL_NO_ALERT
which of course does not make sense given than the lvl_u8 is an
unsigned value that can never be < BT_IAS_ALERT_LVL_NO_ALERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:59 -04:00
Emil Gydesen
448bb4ca55 Bluetooth: Audio: Shell: Use unsigned long long for OTS IDs
Use unsigned long long and shell_strtoull to get the ID of
OTS objects, as unsigned long may not be able to store all 48
bits.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:20 -04:00
Emil Gydesen
de3e709b50 Shell: Add shell_strtoull
Add a shell_strtoull function that works similar to
shell_strtoul except that it calls strtoull instead
of strtoul.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:20 -04:00
Emil Gydesen
578acd8cee Bluetooth: Shell: Ensure scan_filter.addr is null terminated
Ensure that scan_filter.addr is NULL terminated by only copying
the sizeof the buffer -1 and then always setting the last byte to
\0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:00 -04:00
Robert Lubos
0ae7812f6b net: dns_sd: Prevent dead code in query parsing
The number of buffer provided was verified in the final else block of a
long validation sequence. It would never be executed though, as one of
the conditions before would always evaluate to true.

As the number of buffers provided verification appears to be significant
in this case, as the buffers are referenced during other validations,
move this check at the beginning of the sequence instead. This also
eliminates the dead-code problem.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-03 04:13:46 -04:00
Pirun Lee
5ba418c442 Bluetooth: OTS: Fix coverity issue
Fixed issue Coverity CID: 316293 https://github.com/zephyrproject-rtos/zephyr/issues/58518

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2023-06-02 18:57:44 -04:00
Pavel Vasilyev
24bd211d77 Bluetooth: Mesh: Avoid dead code in access
Use if-else-endif construction to avoid dead code.

Coverity-CID: 316484, GitHub issue #58539

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
2b3175f2fa Bluetooth: Mesh: Avoid divizion by zero when chunk_size is zero
Avoid divizion by zero when chunk_size is zero.

Coverity-CID: 316406, GitHub issue #58531

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
ee548488cc Bluetooth: Mesh: Drop PENDING_RESET flag without checking it
Just drop PENDING_RESET flag without checking it.

Coverity-CID: 316394, GitHub issue #58530

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
617154f9d5 Bluetooth: Mesh: Avoid undefined behavior when block_size_log is 0x20
Use ULL suffix to promote the type of the shift operand to uint64_t to
avoid undefined behavior when block_size_log is 32.

Coverity-CID: 316387, GitHub issue #58528

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
395f250ef8 Bluetooth: Mesh: Check return value in blob server
Ignore return value of bt_mesh_model_send().

Coverity-CID: 316126, GitHub issue #58506
Coverity-CID: 316272, GitHub issue #58517
Coverity-CID: 316430, GitHub issue #58533
Coverity-CID: 316567, GitHub issue #58549

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Carlo Caione
9930c346af pm: policy: Selectively compile on "zephyr,power-state" compatible
Coverity is complaining:

      CID 316017:  Control flow issues  (NO_EFFECT)
  >>> This less-than-zero comparison of an unsigned value is never true.
  148      for (size_t i = 0; i < ARRAY_SIZE(substate_lock_t); i++) {

This is a false positive but we can still optimize the code and making
coverity happy by simply avoiding compiling the offending code when no
power states are defined into the DT.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-06-02 18:56:39 -04:00
Emil Gydesen
208908e293 Bluetooth: Audio: Shell: Fix long/int32_t value checks
In places where we verify that the value of the long
variable does not exceed the limits of int32_t, we do
actually not need to compare the values if the two
types are the same size, which is often the case for
32-bit systems.

This fixes a variety of coverity reported issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-02 18:56:17 -04:00
Emil Gydesen
1767621f6f Bluetooth: Shell: Change strcpy to strncpy for addr copy
When copying the address in cmd_scan_filter_set_addr we now
use strncpy to not copy more bytes than what fits. This
should already have been fixed with a check earlier in the
function, but coverity still complains.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-02 18:52:20 -04:00
Florian Grandel
4375962399 net: l2: ieee802154: document non-standard ACK feature selection
For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option must
automatically be active if the radio driver does not AUTOACK and inactive
otherwise. No user interaction is required.

Future changes will deprecate this option and replace it by a standard
compliant automatic mechanism.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-02 18:47:59 -04:00
Florian Grandel
1e2133ffa7 net: l2: ieee802154: document non-standard channel page selection
The IEEE 802.15.4 standard does not specify a "Sub-GHz" option.
Therefore this option will be deprecated in the foreseeable future.

Rationale: Selecting PHYs and frequency bands is abstracted by the
concept of channel pages (see IEEE 802.15.4-2020, 10.1.3).

Radio drivers may expose additional configuration options that
specify the low level frequency band, operating mode and other
PHY-specific parameters. Such parameters should be exposed on a driver
instance level, e.g. via devicetree or as runtime options of the driver.
PHY-specific attributes derived from driver settings (e.g. available
channels) can then be announced to L2 w/o the user having to be aware of
any implementation details of the specific PHY.

Future changes will introduce the necessary infrastructure to define
channel pages and other PHY-specific configuration options to
replace this option. New drivers should therefore not rely on this
option.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-02 18:47:59 -04:00
Robert Lubos
16fa99a887 net: coap: Validate token length in coap_header_get_token()
In theory, coap_header_get_token() should only be used on already parsed
packets, and coap_packet_parse() would detect an invalid token length in
a packet. Coverity however complains about possible out-of-bound access,
as in theory the function can return token length up to 15. Therefore
add an extra validation of the token length within the function, to
avoid out-of-bound access due to programming errors and to make Coverity
happy.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-02 15:13:41 -04:00
Krzysztof Chruściński
6718869658 logging: log_output: Fix for Coverity issue 316014
Log level is stored on 3 bits thus in theory it can be set to 7
and yet accepted levels are up to 4 thus Coverity complains.
Adding assert that prevents use of levels above 4.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-06-02 15:07:08 -04:00
Krzysztof Chruściński
314fb05166 logging: log_output: Fix for Coverity issue 316019
Adding missing casting.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-06-02 15:07:08 -04:00
Jordan Yates
bf3872a05c lorawan: initialise data structures earlier
Now that `lorawan_init` only initialises data structures and does not
start the stack or communicate with a physical device, run the init as
soon as possible. This allows `lorawan_register_downlink_callback` to
be called much earlier by other init functions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-06-01 13:44:16 -04:00
Théo Battrel
3937b25dd6 Bluetooth: Host: Fix GATT delayed store
When `CONFIG_BT_SETTINGS_DELAYED_STORE` is enabled (by default it is),
the local GATT server will delay the write to flash of the CCC and CF
values. The delay is defined by `CONFIG_BT_SETTINGS_DELAYED_STORE_MS`.
If a disconnection happen before that delay, the `bt_gatt_disconnected`
will reschedule the delayed store operation. But that operation will not
happen before `bt_gatt_disconnected` is complete, at this moment, the
CCC and CF values will have already been cleared.

To fix this issue, the delayed store operation is now done during the
`bt_gatt_disconnected` function.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-01 14:58:39 +02:00
Lingao Meng
5f9ac54e2f Bluetooth: Mesh: Fix unable sent mesh message
When proxy advertising enabled, but at same time, the
connection event report, will cause `ADV_FLAG_PROXY` not
set, so cb `connected` will not be process, cause mesh message
unable to sent.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/58721

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-06-01 04:52:45 -04:00
Flavio Ceolin
4f29930e4c pm: Fix cpus active count
Only set a cpu as active (on pm subsystem) when the cpu is effectively
initialized. We cannot assume on pm subsystem that all cpus were
initialized since when the option CONFIG_SMP_BOOT_DELAY is used cpus are
initialized on demand by the application.

Note that once cpus are properly initialized the subystem is able to track
their status.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-06-01 10:05:31 +02:00
Jordan Yates
c61818b065 Bluetooth: host: hci_core: handle additional error code
Some Bluetooth controllers (Nordic Softdevice) now use
`BT_HCI_ERR_INSUFFICIENT_RESOURCES` to signify when advertising sets
cannot be created, instead of the old `BT_HCI_ERR_CONN_LIMIT_EXCEEDED`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-06-01 10:04:46 +02:00
Emil Gydesen
0229dad6d2 Bluetooth: Host: ISO: Fix issue with removing central data paths
On CIS disconnect, the central will clear all data paths.

However hci_le_remove_iso_data_path will fail if attempting to remove a
data path that has not been setup, so if only the CTLR_TO_HOST
direction was set, and the HOST_TO_CTLR bit was set, the
function returned an error and never attempted to clear the other
direction.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-01 10:04:36 +02:00
Emil Gydesen
e31713de27 Bluetooth: Controller: ISO: Fix issue with removing peripheral data paths
On CIS disconnect, the peripheral will clear all data paths.

However ll_remove_iso_path will fail if attempting to remove a
data path that has not been setup, so if only the CTLR_TO_HOST
direction was set, and the HOST_TO_CTLR bit was set, the
function returned an error and never attempted to clear the other
direction.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-01 10:04:36 +02:00
Gerard Marull-Paretas
49ec35fe5e testsuite: group all test-related APIs under 'testing'
Before this change we had 2 top-level Doxygen entries for Testing APIs:

- Zephyr tests
- Zephyr testing suite

This patch creates a single top-level group to contain ZTest and FFF
extensions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-31 14:39:29 -04:00
Rander Wang
59b054fdd6 coredump: Add memory wirte pointer fo intel ADSP memory window backend
The buffer_output interface is called a few times during one core dump,
so we need to maintain a memory write pointer to prevent data overwriting.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2023-05-31 14:38:58 -04:00
Johann Fischer
02129e90d8 net: buf: fix data ref_count offset in generic_data_ref()
This patch fixes commit b70f92e570
("net: buf: keep memory alignment provided by k_heap_alloc and k_malloc").
One-line was overlooked in the above patch and may result in a
cloned net_buf using a data block that has already been freed.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-31 10:01:40 -04:00
Robert Lubos
fa5b706871 net: websocket: Implement websocket_recv_msg timeout
Although websocket_recv_msg function accepts timeout parameter, the
functionality was rather limited, allowing only to either work in
non-blocking manner, or to block indefinitely. Any timeout value
other than -1 (forever) ended up in non-blocking operation.

This PR fixes this by implementing a basic timeout mechanism, built on
top of poll(). For now on, only timeout of 0 will result in non-blocking
operation, any other timeout will make the function block for the
specified amount of time.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-31 11:07:10 +02:00
Morten Priess
5db51d3679 Bluetooth: controller: Fix reconfiguring of CIG and CISes
Up until now, it has not been possible to reconfigure a CIG and its
CISes after initial configuration, without first removing the CIG.

With this commit, le_set_cig_parameters allows the following
reconfiguration operations in configuration state:
- Set new CIG configuration parameters on existing CIG
- Iteratively configure single CIS (of more CISes)
- Increment number of CISes via multiple configuration calls
- Keep handle- and CIS_ID relation

Changes:
- Pass handles in le_set_cig_parameters from ll_cig_parameters_commit
  via output variable.
- Implement CIG state variable instead of 'started', with states
  IDLE/CONFIGURABLE, ACTIVE and INACTIVE.
- Implement ll_conn_iso_stream_get_by_id for easier access to specific
  CIS.

This fixes the following CIS Central EBQ tests:
- HCI/CIS/BI-10-C
- HCI/CIS/BI-11-C
- HCI/CIS/BI-13-C
- HCI/CIS/BV-05-C

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Morten Priess
3fd1fbeff8 Bluetooth: controller: Validate parameters for CIG configuration
Parameter checking updates for passing HCI/CIS/BI* EBQ tests.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Morten Priess
03faaa9e45 Bluetooth: host: Fix hci_le_remove_iso_data_path direction parameters
The path_dir variable of BT_HCI_OP_LE_REMOVE_ISO_PATH must be bitflags,
with the following meaning:
- BIT(0) : DIR_HOST_TO_CTLR
- BIT(1) : DIR_CTLR_TO_HOST

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Morten Priess
acd83ad794 Bluetooth: controller: Fix ll_remove_iso_path direction parameter
According to the Core spec, the direction parameter passed to this function
should be bitfields, i.e.:
- BIT(0) : DIR_HOST_TO_CTLR
- BIT(1) : DIR_CTLR_TO_HOST

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Krzysztof Kopyściński
67a33ed1a0 Bluetooth: Mesh: fix Random value generation for Private Beacons
In `private_random_update`, when first beacon is advertised, there could
be a case when uptime is less then interval * 10s
(`priv_random.timestamp` is equal to 0 for first beacon). Then, Private
Random value will not be generated and will be set to all zeros.

New Private Random must also be generated  before Random Interval
expires, when KR or IVU flags are changed. Reset timestamp to 0 on
`bt_mesh_beacon_update` to generate new Random value.

Do not generate new private random if it won't be used (Private Beacon
state is not enabled).

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-05-30 06:30:25 -04:00
Lukasz Mrugala
fe3f5816b8 testsuite: Docstring typo fix
Word 'platform' misspelled as 'platorm'.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2023-05-29 14:34:33 -04:00
Robert Lubos
e6fc53b399 net: sockets: tls: Allow to interrupt blocking accept() call
In order to allow the TLS accept() call to be interrupted, it should
release the top-level TLS socket mutex before blocking. As the
underlying TCP accept() makes no use of TLS resources, and has its own
mutex protection, it should be safe to do so.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-29 14:34:03 -04:00
Robert Lubos
76b74f007f net: sockets: Fix accept() not being interrupted on close()
The accept() so far would block with mutex held, making it impossible to
interrupt it from another thread when the socket was closed.

Fix this, by reusing the condvar mechanism used for receiving. It's OK
to use the same routine, as underneath accept() is monitoring the same
FIFO as recv().

Additionally, simplify k_fifo_get() handling in accept() - as the
waiting now takes place on condvar, it can be used in a non-blocking
manner. Blocking accept() call should not reach this place if there's no
new incoming connection waiting on the FIFO.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-29 14:34:03 -04:00
Marco Argiolas
49436dc453 net: lib: lwm2m: add missing #include to lwm2m_rd_client.h
Definition for 'struct lwm2m_ctx' was missing and build warnings were
generated.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-05-29 04:57:18 -04:00
Anas Nashif
c0469e6bbd ztest: deprecate old ztest API
Deprecate old ztest APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-28 11:35:12 -04:00
Pieter De Gendt
d4e11a173b debug: Make stack sentinel incompatible with MPU stack guard
The MPU stack guard can move the start address of a thread stack.
Don't allow both options to be enabled at the same time.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-05-27 06:29:27 -04:00
Vinayak Kariappa Chettimada
c23c5f39e7 Bluetooth: Controller: Cleanup Periodic Adv Channel Map Update
Remove redundant code and cleanup Periodic Advertising
Channel Map Update implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-26 14:57:22 -04:00
Madhurima Paruchuri
a19d905cc4 USB-C: genVIF: Cleanup and add support to pick static data from input
Removed few VIF properties which are being hardcoded
Updated the script to parse source VIF XML and add information to
the output
Added optional Kconfig option to configure custom source VIF XML path
Cleaned up the code

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-05-26 13:54:43 -04:00
Dawid Niedzwiecki
53525bb9c5 mgmt: ec_host_cmd: add support for IN_PROGRESS status
The IN_PROGRESS status is a specital status that can be sent during
handling a host command. Synchronous backends don't support it, so
an additional check is required.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Dawid Niedzwiecki
66d8e27c34 mgmt: ec_host_cmd: add a function to send response
A function to send Host Command response is needed for commands that
that sends IN_PROGRESS status or doesn't return e.g. perform reboot.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Dawid Niedzwiecki
a2b9c56ee5 mgmt: ec_host_cmd: fix checking usage of handler buffer
The usage of RX handler buffer was checked incorrectly.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Robert Lubos
2c75070360 net: sockets: tcp: Fix possible race between connect/recv
Installing recv callback with net_context_recv() after
net_context_connect() left an opening for a possible race - in case the
server send some data immediately after establishing TCP connection, and
Zephyr did not manage to install the callback on time, the data would be
lost, corrupting the stream.

This can be avoided, by installing the recv callback before the
connection is triggered. As net_context_recv() called w/o timeout only
registers the callback function, it should have no negative impact. The
only change on the TCP side is when the connection is closed - in case
TCP is in connect stage, do not call the recv callback (before this
change it'd be NULL at that point).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-26 09:55:13 -04:00
Rubin Gerritsen
9e617bdd86 Bluetooth: KConfig: Enable ISO CTLR features if host has enabled them
This ensures that when running a combined host + controller build, the
ISO features in the controller are enabled automatically.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-05-26 09:51:09 -04:00
TOKITA Hiroshi
476a5f57fd fb: cfb_shell: correct invert command implementation
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
 with the tile")

Remove the cfb_invert_area() calling.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-05-26 09:49:25 -04:00
TOKITA Hiroshi
75904f0d19 fb: correct invert_area image calculation
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
with the tile")

Fixed not enough consideration when the drawing area height
is eight lines or less.
Simplify to XOR calculation.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-05-26 09:49:25 -04:00
TOKITA Hiroshi
92efbeeec6 fb: cfb_shell: Add draw rect command
Add the `draw rect` command to execute the `cfb_draw_rect()` API.

This command render rectangle.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
59a6092849 fb: cfb: Add cfb_draw_rect() API
Add cfb_draw_rect() API for rendering rectangle.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
182c55f69f fb: cfb_shell: Add draw line command
Add the `draw line` command to execute the `cfb_draw_line()` API.

This command render line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
ea42b0dc9d fb: cfb: Add cfb_draw_line() API
Add cfb_draw_line() API for rendering line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
39c8288bab fb: cfb_shell: Add draw point command
Add the `draw point` command to execute the `cfb_draw_point()` API.

This command render single dot.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
9def1258a0 fb: cfb: Add cfb_draw_point() API
Add cfb_draw_point() API for rendering dot.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
Johann Fischer
32668dc7fd usb: device_next: allow string descriptor index to be updated
Support for multiple instances of a class implementation,
and the ability to register an instance to a configuration
at runtime, requires a mechanism to add a string descriptor
and update its index based on the total number of descriptors.

We also need to handle some special string descriptors like
Product or Serial Number provided by the application.
Marked as such by using specific macros, these descriptors
can be sorted out by the stack and the device descriptor
indexes are updated automatically.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
8a8e9e1dfe usb: device_next: implement usbd_class_shutdown()
Implement marked as TODO usbd_class_shutdown().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
9a4ed741d6 usb: device_next: use specific macros for string descriptors
Add and use specific macros for manufacturer, product, and
serial number string descriptors.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
7e2d359e8f usb: device_next: use dlist instead of slist for descriptors list
While this does not provide much of an advantage yet,
it will allow us to add descriptors and assign an index
more easily in the next commit.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
07ef9aaed4 usb: device_next: allow selection of alternative USB device context
When we enable USBD shell support with samples like cdc_acm or mass,
there would be another USB device context besides the one provided
by the shell. This patch introduces a new command to select an
alternate context to be used by USBD shell commands.

Also fix the type where "add" command should be "remove".

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
c34ad3114c usb: device_next: allow reuse of string descriptor nodes
If we try to reuse a string descriptor node, the content will
be corrupted because the device stack assumes it is still ASCII7
encoded. Add a flag to indicate that a descriptor node contains
UTF16LE encoded content.

And while we are at it, add a flag to indicate that the SN string
should not be obtained from the hwinfo API.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
291b5a7ec3 usb: device_next: check if another context is initialized
There may be more than one context using the same device, for example,
if the shell module is enabled. Check if another context that uses
the same device is initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
99d2c2f6dd usb: device_next: do a little more cleanup on shutdown
At the shutdown of USB device stack we have to cleanup and
remove all registered class instances and string descriptors
from a configuration.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
2a4d6810db usb: device_next: remove foobaz interface from common shell code
Foobaz interface will be renamed and added as a standalone part
to serve as an API example in a subsequent commit.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Jarno Lämsä
05e0b31fa8 net: lib: coap: Add an asynchronous coap client
The coap client takes requests and provides responses
asynchronously to callback given in a request.
Currently supports only 1 request at a time.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-05-26 09:44:50 -04:00
Fredrik Danebjer
7457bcf0a2 Bluetooth: Audio: Make HAS optional notify characteristics optional
Added Kconfig options to make HAS characteristics that has notify as
optional property selectable and thus optional. These settings are
global, meaning that a chosen notify property will be used for all
registered has instances.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-05-26 09:09:06 -04:00
Emil Gydesen
527591a766 Bluetooth: BAP: Fix off-by-one in shell cmd add_broadcast_id
The arguments in the shell start from [1] as [0] is the command
itself.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 09:08:42 -04:00
Andrei Emeltchenko
75637bd44a bluetooth: audio: Fix buffer overflow
Add missing return preventing memcpy() with buffer overflow.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-26 09:08:23 -04:00
Jamie McCrae
d2eed56f4f mgmt: mcumgr: grp: os_mgmt: Fix issue and add xtensa
Fixes an issue with a missing else as part of a condition and adds
xtensa.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
c052a9f4eb mgmt: mcumgr: Disable legacy Kconfigs if legacy mode is disabled
It does not make sense to control configuration of legacy
options if legacy mode is diabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
7225ba0788 mgmt: mcumgr: grp: os_mgmt: Change select to imply for reboot
OS management's reset is optional, therefore only imply reset
instead of selecting it, so it can optionally disabled if not
needed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
aff663dd2f mgmt: mcumgr: smp: Expand ver to version and limit version
Expands a bitfield name from nh_ver to nh_version so it is more
obvious what it is. Also changes the version that goes into the
response to indicate what the maximum supported version of the
protocol is for a device

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Robert Lubos
966eff642f net: sockets: Fix recv() not being interrupted on close()
In case recv() call was waiting for data, and the socket was closed from
another thread, the recv() call would not be interrupted, causing the
receiving thread to be blocked indefinitely.

Fix this, by signalling the condvar the recv() call is waiting on
close(). Additionally, close will now set the socket into error mode,
with EINTR as the error condition, allowing the blocked calls to
recognise that the call was interrupted, and return a proper error code
on the event.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-26 09:05:12 -04:00
Alberto Escolar Piedras
0ae060d174 drivers: Console: Move all posix arch boards to same driver
All posix arch boards are required to provide the same
tracing/print API.
So, instead of having a different driver for native_posix and the
bsim boards, let's have a common one which uses this API.
This in turn results in the printk strings being printed in
the same underlaying backend as before with individual drivers.

A part from this, the native_posix console driver was a full
backend for the now long gone Zephyr console shell
(named legacy_shell from 527256501f
until it was retired in fd0b7f7767).
The whole input handling in this driver was dead code
(since 140a8d0c8a)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-26 12:57:41 +02:00
Emil Gydesen
19c2bd28a4 Bluetooth: BAP: Unicast client optimize long notify reads
Optimize the read procedure when receiving long notifications
by storing the already notified data in the buffer if the
client instance is not already busy. If it is busy we have
no way to store it, and will just need to read the entire thing
later.

This also modifies when we reset the ATT buffer. Instead of reseting
when we want to use it, we reset it when we are done using it.
The reason for this is to avoid making state checks before calling
long_ase_read to determine whether it should reset the buffer
or not.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
870d8b350a Bluetooth: BAP: Add support for long ASE notifications
Add support for long notifications ASE notifications
by doing a long read if the notification has length of
the maximum MTU.

This behavior is currently not defined by the BAP spec,
so may not work with all devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
e8ade2356a Bluetooth: BAP: Add unicast client and server write long support
Add support for long writes for the unicast client and server.
This reuses the ATT buffer for long reads.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
486ea06fcb Bluetooth: BAP: Rename BAP uni cli read buf to att_buf
att_buf is more generic and makes more sense when we
also want to use it for long writes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
36170e2a84 Bluetooth: TBS: Fixed missing guard of handle_string_long_read
The function is optionally used by the module, and should be
guarded to avoid compiler warnings about unused functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:54:58 -04:00
Emil Gydesen
5109c941f2 Bluetooth: Audio: Add TBS client TX buffer count requirement
After removing the high default for MCS, it was discovered that
the TBS client requires a significant amount of buffers to work
properly as well. Added the requirement as a build assert that
depends on which optional TBS client features are enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:54:58 -04:00
Emil Gydesen
5c3241ca5b Bluetooth: MCS: Remove requirement for TX_BUF_COUNT
A recent change in MCS significantly reduced the requirement
of L2CAP_TX_BUF_COUNT and should now work with any value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:54:58 -04:00
Flavio Ceolin
313fca2b7a bt: audio: Avoid hiding outer parameter
cap_stream is re-declared inside a for loop in
bt_cap_initiator_qos_configured.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-26 05:51:42 -04:00
Jamie McCrae
7e23e73bc1 mgmt: mcumgr: transport: udp: Rework transport
This reworks the UDP transport to resolve some issues with object
interactions and streamlines the code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 10:22:42 +02:00
Dominik Ermel
9cc6a7f060 mgmt/MCUmgr/grp/img: Fix possible missing failure check
No reason to continue zcbor encoding of slot information for image
list when already failed at encoding version.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:53 +02:00
Dominik Ermel
2f53e7af43 mgmt/MCUmgr/grp/img: DirectXIP flag pending slot as permanent
Image list should also flag pending slot as permanent.
This follows the image list for swap configuration where slot
confirmed for next boot is marked as permanent.
The difference is that in DirectXIP mode it is still possible
to erase slot marked as pending and permanent, before restart
happens.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:28 +02:00
Dominik Ermel
1847540663 mgmt/MCUmgr/grp/img: Remove leftover header img_mgmt_impl.h
The header has been replaced with img_mgmt_priv.h.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:05 +02:00
Jamie McCrae
0cce365c4f mgmt: mcumgr: fs_mgmt: Add other access hooks and minor fixes
Adds callback checks to other fs_mgmt group file access functions
which allows for file access control, and moves where the callback
is triggered for uploads and downloads to prevent getting the
callback multiple times for the same file. The callback struct has
been modified so applications using the previous signature will
need to be updated.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 10:20:39 +02:00
Lars Knudsen
79c48edcb9 shell: Use SDU sent callback in bap shell
Use the bt_bap_stream_ops sent callback and not a timeout
while streaming the sine tone in the bap shell to avoid
jitter when the shell is busy.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-05-25 16:36:54 -04:00
Gerard Marull-Paretas
9a145e52a0 pm: policy: add support for events
Events in the power-management policy context are defined as any source
that will wake up the system at a known time in the future. By
registering such event, the policy manager will be able to decide wether
certain power states are worth entering or not.

Events will bypass the ticks argument received by the policy manager if
they occur earlier.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-25 16:29:40 -04:00
Gerard Marull-Paretas
c8cd40f5ae pm: policy: clarify latency units and clarify private members
Latency is always specified in microseconds, so apend `us` to the
relevant variables. Also, make it clear that latency request structures
are private (they are just exposed publicly to allow static allocation).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-25 16:29:40 -04:00
Emil Gydesen
4f3cfe5cd1 Bluetooth: TMAP: Fixed bad size when copying UUIDs
In both instances the sizeof returned the size of the
array, rather than the specific uuid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 16:27:26 +02:00
Emil Gydesen
4bd3452245 Bluetooth: CSIP: Add guard for accessing svc_insts[>1]
Added a guard before attempting to access
svc_insts[cur_inst->idx + 1], as that code can only ever be value
if CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES > 1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 16:27:26 +02:00
Emil Gydesen
083125d5fa Bluetooth: CSIP: Fix warning of unused rank variables
Guarding code that uses __ASSERT with IS_ENABLED seemingly
does not work, and still gives unused variables (rank_1 and
rank_2). Modified the guard.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 16:27:26 +02:00
Emil Gydesen
e0b84798c9 BluetootH: Audio: Split CAP broadcast start API
Split the CAP initiator broadcast start API into a create
and a start. This will allow users to create the broadcast source
without starting it immediately, making it possible to get the
BASE etc. without an active advertising set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 08:26:33 +00:00
Aleksander Wasaznik
92fcd9ef40 Bluetooth: Host: Add L2CAP seg_recv API
This is an alternative API for the L2CAP receive functionality. It
allows an application the receive L2CAP segments directly and manage
credits explictly. The API is guarded by an experimental kconfig option.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/57485

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-05-24 13:15:14 -04:00
Carlo Caione
6f3a13d974 barriers: Move __ISB() to the new API
Remove the arch-specific ARM-centric __ISB() macro and use the new
barrier API instead.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-24 13:13:57 -04:00
Florian Grandel
a2c6bb9f1c net: l2: ieee802154: move variable declaration to start of block
Variable declarations are moved to the beginning of the block in
which they are visible to ensure consistency with the remainder
of the code base.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
26041dc32b net: l2: ieee802154: fix typos
A few security-related constants contained typos which are
fixed in this change.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
ee079495d5 net: l2: ieee802154: enc-only security level removed from spec
The encryption-only security level has been removed from the
spec, see IEEE 802.15.4-2020, 9.4.2.2 Security Level field.

The standard provides the following explanation (ibid):

"This security level is deprecated and shall not be used in
implementation compliant with this standard. Devices that
receive frames with security level 4 shall discard them, as
described in 9.2.4. The counter mode encryption and cipher
block chaining message authentication code (CCM) used allows
trivial changes to the underlaying encrypted data unless
data authenticity is provided, thus using data confidentiality
only is not useful. In the case of TSCH mode, security level 4
allows higher security level frames to be downgraded to
security level 4 frames."

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
0a2d8522e9 net: l2: ieee802154: simple address mode removed from spec
See IEEE 802.15.4-2020, 7.2.2.11 Source Addressing Mode field and
7.2.2.9 Destination Addressing Mode field, table 7-3: The
previously deprecated "Simple addressing mode" was removed
from the spec.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
ea6a55afad net: l2: ieee802154: zero-copy encryption
Currently the insertion of an authentication tag requires a memcpy() call
and breaks encapsulation.

This change removes the need for memcpy() and improves the encapsulation
by calculating and reserving the required headspace early on while
keeping insertion where it belongs in the outgoing security procedure.

This is also a preparation for improved standard compliance of the
outgoing security procedure which is scheduled for a later commit.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
315394eb53 net: l2: ieee802154: consistently name authtag length
The naming of variables and arguments containing the authentication
tag length was inconsistent:

* Naming inconsistency between header "length" vs. authtag "size"
  in the same API calls
* "Tag" rather than "Auth[orization ]Tag" in external API calls
  which is too generic from a compliance and readability viewpoint.

This is in preparation to zero-copy authentication support.

Almost all call sites will be subject to required structural changes
later on so no relevant git blame noise/history loss will be introduced
by this naming change in the long run.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
32e1213b0c net: l2: ieee802154: improve inline documentation
Over time, some non-standard concepts and extensions were introduced
into the stack (in KConfig, in drivers, in the internal API and into the
implementation) which makes introduction of additional standard-
compliant extensions like TSCH (and others) unnecessarily difficult.

To introduce extensions like TSCH it is required for the IEEE 802.15.4
stack to become more structurally aligned with the standard again which
will be the focus of some of the upcoming preparatory changes.

One way to check and prove standard compliance is to reference the
standard from within the source code. This change therefore introduces
inline references to the IEEE 802.15.4-2020 standard wherever possible.
Deviations from the standard are documented with TODO or deprecation
labels to be addressed in future changes.

In the future, new code introduced to the IEEE 802.15.4 stack should
be documented and reviewed for standard-compliance to avoid further
divergence. Most importantly:
* MAC/PHY configuration (via net mgmt, radio API, devicetree or
  KConfig) should always be directly linked to well-defined MAC/PHY
  PIB attributes if visible to the MAC API or the end user.
* Net management/shell/radio API commands should have a documented
  reference to the corresponding MLME action from the standard.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Emil Gydesen
6b004e267e Bluetooth: Audio: Fix missing reset of receiver_ready for unicast client
The unicast client did not properly clear the receiver_ready flag
when going out of the streaming or enabling state. This caused
incorrect behavior when attempting to restart streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-24 16:41:47 +02:00
Emil Gydesen
699ccbac41 Bluetooth: Audio: Remove bad LOG_ERR from bap_stream
There was a debugging LOG_ERR that should not have
been merged.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-24 16:41:28 +02:00
Piotr Pryga
622299b1c5 Bluetooth: controller: Move DF feat selection to LL_SW_SPLIT KConfig
The BT_CTLR_DF_SUPPORTED KConfig was a wrapper for DF related features
set that are supported by Zephyr's BLE Controller. At the same time the
KConfig is used by Host in compound build to enable BT_DF. That makes
the whole thing a bit coupled with Zephyr's controller.
External implementations of controller must provide same feature set
as Zephyr's Controller or there will be an error during build.

The PR moves the Zephyr's Controller DF supported features set to
Kconfig.ll_sw_split, where it is included only when BT_LL_SW_SPLIT
is selected. BT_CTLR_DF_SUPPORTED is now a top DF_SUPPORTED KConfig
option that enables possibility to select actual DF features.
That allows to select individual set of DF features by any controller
implementation and makes possible to enable BT_DF and build selected
DF Host features.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2023-05-24 16:41:21 +02:00
Silviu Petria
5096aa1c00 Bluetooth: Audio: Add TMAS and two TMAP samples
Add implementation of the Telephony and Media Audio Service, as well as
two sample applications.

tmap_central reflects a smartphone implementing the Unicast Media Sender
and Call Gateway TMAP roles.

tmap_peripheral reflects an earbud implementing the Unicast Media
Receiver and Call Terminal TMAP roles.

Upon connection, tmap_central starts an audio stream using CAP Initiator
APIs.

CCP, MCP and VCP are discovered and used to send example commands.

Future improvements: 2-earbud support, add TMAP Broadcast roles,
update with new CAP Acceptor/Commander APIs as they become available

Signed-off-by: Silviu Petria <silviu.petria@nxp.com>
2023-05-24 16:39:38 +02:00
Qipeng Zha
7aa618d288 logging: trigger log process once reach threshold
atomic_inc(&buffered_cnt) return previous count of log messages,
should use current count to compare with threshold config value.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Signed-off-by: Qipeng Zha <qipeng.zha@intel.com>
2023-05-24 05:06:11 -04:00
Nils Ruf
97c1d05dec net: allow UDP missing checksum by default
According to RFC768 UDP packets with zero checksum are allowed with IPv4.
Enable this by default.
For example, some routers use zero checksum in DHCP packets.

Signed-off-by: Nils Ruf <nils.ruf@endress.com>
2023-05-23 22:09:47 +02:00
Rodrigo Peixoto
caf68d9485 zbus: remove POSIX arch iterable sections restriction
Zbus iterable sections config in Kconfig unnecessarily excluded POSIX
architectures. Remove the constraints and adjust the sample YAML file to
enable that.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2023-05-23 22:09:33 +02:00
Jamie McCrae
56f66334b0 mgmt: mcumgr: grp: fs_mgmt: Fix cmake selection
Fixes an issue whereby mbedtls will not be included if tinycrypt
is included in the build.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 18:00:53 +02:00
Fabio Baltieri
b9ea2c2705 build: downgrade the no optimization ztest error to warning
The current approach of failing the build on ztest with no optimization
broke coverage builds, and generally raised some concerns about being
too aggressive.

Downgrade the error to a warning and rework the option to inhibit the
warning, while also dropping it automatically for POSIX (that are not
really affected by stack size) and coverage run (that always runs with
no optimization).

Will reconsider this down the road if we still see issues filed for the
tests broken with no optimization and no further tuning.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-23 14:51:24 +00:00
Jamie McCrae
2e4c3f1da9 mgmt: mcumgr: grp: fs_mgmt: Change insecure warning
Changes the warning from being text in Kconfig for filesystem
management as a whole to being a cmake warning which is displayed
if the user has not enabled file access hooks with a link to the
documentation on how to set them up.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 16:36:38 +02:00
Jamie McCrae
1d6ee8da5f mgmt: mcumgr: Change from mcumgr to MCUmgr
Fixes the name of the system.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 16:36:38 +02:00
Dawid Niedzwiecki
aa0c0727b4 mgmt: ec_host_cmd: add config to create a dedicated thread
Add a config to decide if a new dedicated thread for Host Command is
created during initialization.

If not, the ec_host_cmd_task has to be called by another thread to
handle host commands.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-23 16:19:53 +02:00
Pavel Vasilyev
e51a909343 Bluetooth: Mesh: Shell: fix vnd model pub command
The command at most takes 11 args. argc = num of args + 1 (command
name) => 12. We substruct 3 from argc (cmd name, mod id, addr). This
gives argc = 9 when all args are provided for vendor model.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-23 13:03:18 +02:00
Andries Kruithof
253818ebea Bluetooth: controller: move bn scope from filescope to lll-scope
The scope for the burst number for tx and rx is currently at module
level in both lll_central_iso.c and lll_peripheral_iso.c
 This PR puts the scope to the lll level

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-05-23 12:56:07 +02:00
Fabio Baltieri
f5830f3c3f ztest: error out when building tests with no compiler optimizations
Many tests are known to fail when built and no compiler optimizations.
Add a CMake check to error out when building a ztest based test with no
optimization, ask not file issues about it but also adds an opt-out
option to bypass the error for tests are actually designed to work in
this setup.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-22 12:25:43 -04:00
Florian Grandel
ca6d552bbb net: l2: ieee802154: fix payload handling
The current implicit MAC payload length algorithm (based on
an otherwise irrelevant footer pointer) produces invalid
(non-standard) values for beacon and command frames.

This change produces standard-conforming MAC payload length
values and simplifies access to payload length.

It would have been possible to fix the current footer pointer
based approach but there are arguments in favor of the new
approach:
- The footer pointer is used nowhere in the current code
  base and makes length calculations rather non-obvious.
- The new approach does not use more memory and is easier
  to understand and use.
- This change is a first step to support of IEEE 802.15.4
  information element (IE) support. At a later stage the
  distinction between MAC payload length and frame payload
  length will be introduced and become relevant to
  distinguish between header and payload IEs. At that point
  the current implicit length calculation algorithm will
  break down anyways.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
4fcdfab7d9 net: l2: ieee802154: fix beacon filtering
The current IEEE 802.15.4 stack would not accept beacons
unless hardware filtering was active.

This change fixes the bug.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
c5fc0e5577 net: l2: ieee802154: shell: release event cb
The shell command calling the IEEE 802.15.4 scanning procedure
did not properly release its net management event callback.

This change fixes the memory leak.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
cb5ea0ec83 net: l2: ieee802154: always revert channel/pan after scan
Active and passive scanning requires the channel and PAN to
be set temporarily.

This change ensures that the temporary configuration will
be reverted even when the scan is aborted due to an error.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
8eec8441cd net: l2: ieee802154: release consumed frames
Beacon and command frames are consumed by the IEEE 802.15.4
stack internally and should therefore be released before
returning control to the generic net stack.

This change fixes the resource leak.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Jonathan Rico
202d2ed005 Bluetooth: host: clarify the behavior of BT_PRIVACY
This makes it explicit that enabling `BT_PRIVACY` will make the device
_use_ private addresses.

The device can still resolve RPAs when `BT_PRIVACY=n`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-22 15:26:55 +02:00
Krzysztof Kopyściński
61cf1bb9e4 Bluetooth: Mesh: fix SRPL clearing
If len=0 then `primary` address should be cleared.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-05-22 15:26:17 +02:00
Krzysztof Kopyściński
38c925308b Bluetooth: Mesh: fix Proxy Solicitation build without CONFIG_BT_SETTINGS
`bt_mesh_settings_store_schedule` should be called only when
CONFIG_BT_SETTINGS is enabled.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-05-22 15:26:07 +02:00
Emil Gydesen
d770e2af13 Bluetooth: Audio: Remove BT_CODEC_MAX_DATA_LEN > 0 checks
The minimal value of BT_CODEC_MAX_DATA_LEN is 1, so it
is always > 0.

Includes to audio.h in shell bt.c was removed as audio.h
should only be included if BT_AUDIO=y.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:25:54 +02:00
Emil Gydesen
71af6c0c6b Bluetooth: Audio: Remove CONFIG_BT_CODEC_MAX_METADATA_LEN
The Kconfig option was not used anywhere besides some checks
that should have checked against CONFIG_BT_CODEC_MAX_DATA_LEN
instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:25:54 +02:00
Matthias Breithaupt
d2163bc0b9 net: DHCPv4: Add option callback
In certain scenarios, it may be necessary to get values of additional
options from the application layer. With this patch, this can be
accomplished by registering a callback with the DHCP client.

This change has been tested using the posix build in qemu.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
2023-05-22 15:25:40 +02:00
Emil Gydesen
37aad05883 Bluetooth: BAP: Shell: Remove superfluous call to discover_cb
The call to discover_cb did not add any value as we already
print the error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
3074c72d79 Bluetooth: BAP: Move endpoint discovery to new callback
Add a new endpoint callback that is used to report the found
ASEs during BAP discovery, rather than calling
the discovery callback with optional values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
1c304d9d23 Bluetooth: BAP: Move pac record discovery to new callback
Add a new pac_record callback that is used to report the found
PAC records during BAP discovery, rather than calling
the discovery callback with optional values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
5d498d78ad Bluetooth: BAP: Remove bt_bap_unicast_client_discover_params
Remove the BAP unicast client specific discover parameter struct.
This make the BAP discover work more similar to the other
profiles.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
ffca5f9b2f Bluetooth: BAP: Remove dir from BAP discovery parameters
The direction has been moved to a function parameter instead,
and we keep a local copy of the value in the stack instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
1199e46e0b Bluetooth: BAP: Remove num_eps from BAP discover params
The field is not required and is no longer used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
0b10498fb1 Bluetooth: BAP: Remove num_caps from BAP discover params
The field is not needed and no longer used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
11f5f3b080 Bluetooth: BAP: Move uni cli discov err to callback
Move the err field from the discover parameters to
the callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
39406a4843 Bluetooth: BAP: Move uni cli discover callback
Move the unicast client discover callback from the
parameters to the callback structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Jamie McCrae
ea6d326ab4 mgmt: mcumgr: grp: img_mgmt: Remove unused file
Removes a file that provided unimplemented and unused functions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:25:05 +02:00
Jamie McCrae
fbd5415ca2 mgmt: mcumgr: grp: fs_mgmt: Fix not checking offset
Fixes an issue whereby the user supplied offset was not checked if
it was provided or not.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:24:48 +02:00
Jamie McCrae
c95b8ff831 mgmt: mcumgr: grp: img_mgmt: Remove useless hash variable
Removes a hash variable that was set then never used.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:21:41 +02:00
Wojciech Slenska
db7803b60e shell: shell_cmds: added prompt commands
Added command for enabling/disabling shell prompt.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-05-22 12:03:03 +02:00
Vinayak Kariappa Chettimada
b726b5e62a Bluetooth: Controller: Fix BT_CTLR_SW_SWITCH_SINGLE_TIMER feature
Fix BT_CTLR_SW_SWITCH_SINGLE_TIMER to correctly disable the
PPI group used to switch radio Tx/Rx. The issue was
uncovered when adding coverage in BabbleSim test.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-22 12:02:02 +02:00
Vinayak Kariappa Chettimada
9eb931836b Bluetooth: Controller: Prepare to replace HAL_RADIO_ENABLE_ON_TICK_PPI
Prepare to replace HAL_RADIO_ENABLE_ON_TICK_PPI with
independent use of HAL_RADIO_ENABLE_TX_ON_TICK_PPI and
HAL_RADIO_ENABLE_RX_ON_TICK_PPI.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-22 12:02:02 +02:00
Vinayak Kariappa Chettimada
f8f01a07ff Bluetooth: Controller: Use NRF_RADIO_TXRX_END_EVENT
Use NRF_RADIO_TXRX_END_EVENT instead of EVENTS_END in the
Controller HAL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-22 12:02:02 +02:00
Michael Trimarchi
b4bac3d7f1 modbus: cancel the server_work in modbus disable
Allow to periodically initializes/disables the modbus interface.
Switch from modbus line discipline to serial and switch back to modbus.
This can be required when the serial is shared by two sensors

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
2023-05-22 10:50:20 +02:00
Gerard Marull-Paretas
dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Mariusz Skamra
f5d4e9e0db Bluetooth: audio: ascs: Fix conn object being unreferenced prematurely
This fixes invalid conn unref that happens in ACL disconnected callback
context. When the ACL disconnects, the implementation waits for CIS to
be disconnected if connected. If the client won't disconnect the
CIS, the implementation initiates the disconnection by itself, from
delayed work context. Thus the ACL conn object has to be remained at
that time because it indicates whether the ASE object is in use or not.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Mariusz Skamra
3aea893ca5 Bluetooth: audio: ascs: Fix repeated ops->released callback call
Once the ACL disconnects, the implementation releases the related
endpoints. The ops->released callback is called once ASE enters IDLE
state, thus there is no need to call it explicitly.
This fixes repeated ops->released callback call.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Florian Grandel
51108a9ce4 net: l2: ieee802154: test: /w and /wo sockets
This change splits the IEEE 802.15.4 test into two separate
test profiles, one with and one without sockets enabled to ensure
that both configurations work correctly.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 08:06:14 +00:00
Florian Grandel
e6c4109e94 net: l2: ieee802154: expose implicit frame assumption
The current IEEE 802.15.4 stack assumes that drivers will
not provide more than one fragment in incoming packages.

This change exposes and enforces the pre-existing assumption
made by the implementation.

So far this is not a limiting restriction as MPDUs with more
than 127 bytes are not supported yet. It will probably have to
be changed as soon as larger payloads (as allowed by PHYs
introduced more recently into the spec) might want to allocate
smaller fragments.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 08:06:14 +00:00
Florian Grandel
66bd007f30 net: l2: ieee802154: security: properly clean up previous session
When changing IEEE 802.15.4 security settings or setting security
to 'none' then the previous session must be cleaned up to avoid
resource leaks.

This change introduces proper clean-up of the security session.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 08:06:14 +00:00
Mariusz Skamra
8c3568f213 Bluetooth: audio: mcs: Fix endianess issues
This fixes missing endianess conversions in mcs.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-19 19:53:02 +00:00
Mykola Kvach
99661137bb fs: littlefs: add ability to build little fs without flash map
LittleFS may be used not only for Flash devices, we can use it for
block devices too.

Add possibility of building LittleFS for case when
CONFIG_FLASH_MAP and CONFIG_FLASH_PAGE_LAYOUT are disabled.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-05-19 15:53:29 +02:00
Mykola Kvach
ba4ad699e0 fs: littlefs: remove dependency on flash map from FILE_SYSTEM_LITTLEFS
LittleFS may be used not only for Flash devices, we can use it for block
devices too. So, I have changed dependency rules and remove dependency
on flash map from FILE_SYSTEM_LITTLEFS.

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-05-19 15:53:29 +02:00
Mateusz Kapala
15bd8b256f bluetooth: host: Fix NULL pointer dereference in bt_conn_auth_cb_overlay
There is a check in bt_conn_auth_cb_overlay function which validates
if content of the callback structure is correct, but there is no
NULL-check on the structure pointer itself, which could result in
NULL pointer dereference.

It should be possible to set the callback structure pointer to `NULL`
using bt_conn_auth_cb_overlay function if the application requires
ex. Just Works pairing for one Bluetooth identity and global
callbacks are configured for advanced pairing scheme (like Passkey
Display) for other Bluetooth identity.

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2023-05-19 09:40:21 +02:00
Ajay Parida
d47021b2f9 net: shell: Fix for PS timeout param type.
Param type is set to correct type for power save timeout.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-18 15:14:31 -04:00
Mariusz Skamra
84fd596062 Bluetooth: audio: mcs: Offload notifications to system work queue
This implements the deferring of characteristic value notifications to
be sent from system work queue thread context. Notifications issued from
Bluetooth Rx thread might not be sent if there are no L2CAP Tx buffers
available, as the operation is non-blocking to prevent deadlock while
waiting for free buffers.
The same operation issued from other thread context is blocking,
meaning that the thread waits until L2CAP Tx buffers become available.
Thus it's guaranteed the notifications will be sent.

With this patch, the control point operations become blocking until the
control point response is sent. Meaning there might be only one
pending operation waiting for completition. This might be further
improved by queuing the operations if needed.

Fixes: #57444
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-18 13:35:57 +00:00
Mariusz Skamra
94853e310a Bluetooth: audio: mcs: Fix unused functions warning
This guards functions called only if CONFIG_BT_OTS is enabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-18 13:35:57 +00:00
Jamie McCrae
a476eeb8ec mgmt: mcumgr: grp: os_mgmt: Use new error for invalid format
Uses the new error system to report an error if the user provides
an invalid format for the OS info command.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-18 13:31:19 +02:00
Dawid Niedzwiecki
7efc8938eb mgmt: ec_host_cmd: update checking the handler buffer
The general handler may provide buffers for a backend. Use ranges to
check if the provided buffer is used, because the backend may shift the
beginning of the buffer to make space for preamble.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
0a17aa8605 mgmt: ec_host_cmd: add autoinit config
Add a separate config to enable autoinitialization of the host command
subsystem, called by the chosen backend.

It allows setting the chosen backend without autoinit.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
4064a41ce2 mgmt: ec_host_cmd: follow clang format
Edit some source files to follow the clang format.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
3d8a5c7e5c mgmt: ec_host_cmd: make host command structure available
The application code may need inside information about the host command
e.g. the thread id. Add a function that returns the main host command
structure which contains such data.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
PawelX Dobrowolski
0bff695d2c coredump: Intel ADSP memory window backend
For debug usage is added backend for memory window.
Coredump is being dumped in raw data. It needs to be converted to
ACSII for later analysis. Data is written to telemetry slot
in memory window which is a space where is located all debbug
information.

Signed-off-by: PawelX Dobrowolski <pawelx.dobrowolski@intel.com>
2023-05-17 14:10:49 -04:00
Fredrik Danebjer
f3fdb1f96f Bluetooth: Audio: Make VCS optional notify characteristics optional
This change makes VCS Volume Flag characteristic Notify property
optional and selectable through Kconfig.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-05-17 19:26:54 +02:00
Andrei Emeltchenko
303a0af68f net: tcp: Make sure we shift by less then bit width
Shifting "timeout <<= conn->zwp_retries" by more then 63 bits results in
undefined behaviour.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-17 19:26:44 +02:00
Tomasz Moń
7ba5ecf451 usb: device_next: report medium error on Mass Storage failed writes
End Write command with Medium Error / Write Error when underlying disk
write or sync fails.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-05-17 11:45:45 +02:00
Tomasz Moń
3532c2563a usb: device_next: accept padded Mass Storage CDBs
Universal Serial Bus Mass Storage Specification For Bootability requires
that device shall accept Bulk-Only-Transport bCBWCBLength of 12 for all
commands documented in the specification. Allow padding for commands
documented in Bootability specification, but leave others intact.

This fixes Request Sense on Windows 11 which previously failed due to
bCBWCBLength being 12 instead of 6.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-05-17 11:45:45 +02:00
Dominik Ermel
ac38411e2e mgmt/MCUmgr/grp/img: Rework image list to support DirectXIP
Image list will only report active flag for active image and pending
flag for other slot, but only if image in that slot has higher
version than currently running image.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-17 09:47:54 +02:00
Krishna T
b7cabb72fa net: wifi: Fix typo in event
Wrong macro was copied, this causes the event to fail.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 11:41:43 -04:00
Krishna T
2c129609d0 net: context: Set priority based on DSCP
If a socket has DSCP set then the packets from the socket should also be
marked with appropriate priority in case traffic classes are used in
networking stack.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 13:21:25 +02:00
Krishna T
10f3ca2e1d net: wifi: Add an event for disconnect complete
This is needed for applications that rely on WPA supplicant being
in disconnected state before issue subsequent commands (e.g., issue scan
immediately after disconnect fails, until disconnect is completed).

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 13:21:10 +02:00
Vinayak Kariappa Chettimada
9ff23ed029 Bluetooth: Controller: Fix Central CIS SN/NESN for skipped events
Fix Central CIS SN and NESN for skipped events during CIS
setup. It is possible that CIG event may overlap the ACL or
other events at the CIS create instant, and hence have non
zero lazy value during the CIS setup events until CIS is
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-16 13:20:15 +02:00
Vinayak Kariappa Chettimada
3b3d53f09e Bluetooth: Controller: Fix CIS offset_min for dissimilar interval
Fix CIS offset_min calculation to consider that ACL interval
and ISO interval can be dissimilar and the offset value has
to be compensated for the latency until the instant at which
the offset is used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-16 13:20:15 +02:00
Vinayak Kariappa Chettimada
22e67eac6e Bluetooth: Controller: Fix sn on Peripheral CIS event abort
Fix SN value on Peripheral CIS event abort. Adjust the SN
value based on the burst number such that the ISO data where
transmitted as normal.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-16 13:20:15 +02:00
Andrei Emeltchenko
2c0fcdf22b bluetooth: shell: Add missing return
Avoid invalid bit shift by adding return.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-16 12:08:06 +02:00
Yuval Peress
7153157f88 rtio: Add support for multishot reads
- Introduce multishot reads which remain on the SQ until canceled

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-15 10:10:12 -04:00
Yuval Peress
2c30920b40 rtio: add cancel support
- Add a new API `rtio_sqe_cancel` to attempt canceling a queued SQE
- Add a new syscall `rtio_sqe_copy_in_get_handles` which allows getting
  back the SQE handles generated by the copy_in operation so that they
  can be canceled.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-15 10:10:12 -04:00
Emil Gydesen
c66f210f6b Bluetooth: BAP: Broadcast source fix idle state
The idle state was never set, thus providing a poorly
implemented state machine. Updated the code so that unused
code was removed and so that the idle state is properly set.

Optimized the way that a state is set for all endpoints
for a broadcast source with a new function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-15 15:26:14 +02:00
Sjors Hettinga
a28a656aa0 net: tcp: Avoid double acknowlegding retransmitted data
In the FIN_WAIT_1 any incoming data is dropped, but anknowledged. Add a
check to see if the data is already acknowleged to prevent double
acknowledging of the data and bringing the acknowlegde counter out of
sync. When the acknowledge counter gets out of sync, the connection will
never properly terminate any more.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-05-15 15:25:51 +02:00
Vinayak Kariappa Chettimada
354226022e Bluetooth: Controller: Fix peer ISO feature support check
Fix peer ISO feature support check, by using feature support
bit instead of whether locally supported bit value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-15 13:38:38 +02:00
Vinayak Kariappa Chettimada
0249006813 Bluetooth: Controller: Use swapped role specific features bit
Use swapped role specific features bit to calculate features
usable by local device, on feature exchange procedure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-15 13:38:38 +02:00
Vinayak Kariappa Chettimada
fe53891788 Bluetooth: Controller: Fix Central ISO establish assertion failure
Fix Central ISO assetion failure on being established due to
regression in commit a53d89450a ("Bluetooth: controller:
fixing CIS establish flow for refactored LLCP") that
required changes due to Create CIS LLCP being refactored.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-15 13:38:38 +02:00
Herman Berget
93f36d4bff Bluetooth: Host: Fix double conversion of phy
The phy was converted both when reading from the event
and when reading from the sync, leading to incorrect
value in the synced callback.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-15 13:10:29 +02:00
Emil Gydesen
6862884f87 Bluetooth: BAP: Broadcast sink fix interval to timeout calc
The calculation in interval_to_sync_timeout did not take into
account that the periodic advertising sync interval was in units
of 1.25ms, and not ms.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-15 10:53:54 +00:00
Gerard Marull-Paretas
a8b36ffb4d bluetooth: mesh: use STRUCT_SECTION_ITERABLE_ARRAY
STRUCT_SECTION_ITERABLE cannot be used with arrays, because of
preprocessor tokenization issues.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-15 18:52:07 +09:00
Jamie McCrae
f59b857f6a mgmt: mcumgr: smp: Convert functions to function pointer array
Converts the list of functions for registering an MCUmgr SMP
transport from function arguments to a single list which contains
the function pointers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 10:23:35 +02:00
Jamie McCrae
6f5b974949 mgmt: mcumgr: Add command result codes (ret)
Adds a new map to responses that command handlers can use to
return result codes of functions themselves, unrelated to SMP
error codes. This is achieved by adding an optional "ret" map
which contains a 16-bit "group" and 16-bit "rc" error code,
this map will not be included if the "ret rc" is 0 (which
implies success).

In order to allow this, a new version of the protocol has been
which can be indicated for use by setting a bit in the header.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 09:27:16 +02:00
Lukas Woodtli
fb924e2b62 net: lwm2m: Handle CONTINUE in registration message
The continue code is not considered an error in case of
block-wise transfer.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
73fb4e73a8 net: lwm2m: Handle CONTINUE response and send new block
After sending a CoAP block and receiving the CONTINUE response
code the next block is sent.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
49f8d08f98 net: lwm2m: Split message into blocks for sending
Add functionality that creates blocks from a big payload body.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
3707a0d229 net: lwm2m: Provide buffer for block transfer
Allow to use a buffer for the complete message body if block transfer is
enabled. This buffer is used when serializing the message. For sending
the message the body is split into blocks.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
12de4018ef net: coap: Add function for getting BLOCK1 option
The function gets the the BLOCK1 option from a received message
and extracts the block number, block size and has-more flag from
it.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
db480169a0 net: coap: Add function for inserting block option for sending
The function adds a block option to a CoAP message. If the message
is a request the BLOCK1 option is added. Otherwise (response) the
BLOCK2 option is added.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Dawid Niedzwiecki
65bd27246f mgmt: ec_host_cmd: fix node chosen strings
Update the backend device node chosen strings.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-15 09:16:53 +02:00
Emil Gydesen
07f32b732a Bluetooth: ASCS: Add support for long writes
Add support for long writes to the control point
to handle e.g. metadata that's larger than the MTU.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
8c4908b3f2 Bluetooth: ASCS: Add support for long read
Increase the size of the ase_buf to support
the maximum size of the Codec Configuration
and Metadata.

The ase_buf is not also guarded by a semaphore, so no
more than one thread will use it at any time. This is
needed as ase_status_changed can be called from multiple
threads.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
572055e205 Bluetooth: Audio: Add long read support to BAP unicast client
Add support for long read by adding a read_buf and store
the data when long data is being read.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
892819ede8 Bluetooth: Audio: ASCS ASE discover by UUID added
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
be781b2a56 Bluetooth: Audio: PACS context discover by UUID added
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
ec1b2a1844 Bluetooth: Audio: PAC discover by UUID added
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs, and that we need
to do a long read on the PAC records anyhow, and that
cannot be done with the read by type/UUID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
ba19bf3d96 Bluetooth: Audio: Add unicast_client struct
Add a new struct unicast_client to hold all the conn-specific
data for the Unicast Client implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
3ff3d8db2c Bluetooth: PACS: Set PACS read_buf size to BT_ATT_MAX_ATTRIBUTE_LEN
The maximum size of the characteristic is BT_ATT_MAX_ATTRIBUTE_LEN.
The previous size limited the size of the characteristic to
the maximum possible MTU, thus not utlizing support for the
Read Long procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
3d4622b4d4 Bluetooth: PACS: Fix bad __ASSERT condition
__ASSERT(true will never be triggered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
5a28d80893 Bluetooth: PACS: Removed unused conn arg from get_pac_records
The `conn` argument was not used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
98adaf0811 Bluetooth: PACS: Add read_buf_sem
Add a semaphore to guard the read buf. The reason for this
is that the read buf is populated from either the BT RX
thread, or the workqueue thread. The semaphore ensures
that both threads will never have attempted to
add any data to the buffer at the same time.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Erik Brockhoff
5ca6724664 Bluetooth: controller: adding release of rx/tx nodes retained in LLCP
On connection clean-up release nodes held by LLCP. These are released
in two steps, first on LLCP terminate (in local/remote) by moving
to rx/tx_node_release chains, and then on conn_cleanup_finalize
nodes are released back to appropriate mem-pool/queue.
Rename abort functions to refer to terminate.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Erik Brockhoff
eece00e4b0 Bluetooth: controller: updating TX node pre-alloc store mechanism
Instead of using the node ref used for TX ack for storing a TX node
pre-allocated in case of NTF RX node availability delay, introduce a
separate store to TX node. This to avoid misunderstanding on clean-up
in terminate flow.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Erik Brockhoff
a53d89450a Bluetooth: controller: fixing CIS establish flow for refactored LLCP
Latest modification to LLCP removed 'monitoring' of cis->established
flag in LLCP, relying instead on signal through ULL.

For this to work properly the signal must also be generated, so this is
introduced. Note - checking of cis->established flag could be removed
if caller ensures only calling once (on establish condition)

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Erik Brockhoff
998512f59b Bluetooth: controller: use RX node piggy-back for NTF when possible
When possible re-use the already allocated RX node for notifications.
Store (retain) RX node and Link element on RX if NTF could occur.
Pass link element to LLCP (ull_cp_rx()) together with RX node.
New RX node type RETAIN introduced to signal retention

When no RX node is available allocate one and hold off TX on procedures
until such time that a node is available for NTF.

In case waiting for NTF buffer avail is needed, allocate and store TX
node to use for TX once NTF becomes available.

CIS Established (incl. timeout handling) is now handled entirely as a
specific event driven by ull_conn_iso - ie removal of procedure check
of cis->established and cis->expire, as this is doubling mechanism
in the conn_iso context.

Unit test and helpers updated to handle new node type.
Function ull_cp_release_ntf() was used only in unit test, so moved to
helper context.
Updating release_ntf to handle the fact that with piggy-backing in test
context the node used for NTF can be from two different memory pools

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Ajay Parida
e70bb70651 net: wifi_mgmt: Support to provide raw scan data
Support to provide raw beacon and probe response data
to registered application.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-12 10:50:21 +00:00
Gerard Marull-Paretas
d0e58ad0a6 device: use iterable sections
Use iterable sections to handle devices list. This simplifies devices
implementation by using standard APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
f0db892d7b toolchain: add trailing _ to iterable section name
Add a trailing _ to the section iterable name. This is useful, for
example, to implement numeric sorting like this:

SORT(.z_device_LEVEL_?_)
SORT(.z_device_LEVEL_??_)

Without the trailing _ it would not be possible to use the ?? wildcard
without triggering into trigraphs issues, because linker-defs.h header
is included in C files as well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
13f87494bb shell: device_service: remove levels command
While it may be useful in some contexts, this information can be
obtained at compile time. Removing this command allows to migrate the
device infrastructure code to standard iterable sections, done later.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Ravi Dondaputi
0889ceaa4e net: wifi: Display MFP info in scan results
Display MFP info in scan results.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-05-12 11:57:13 +02:00
Dominik Ermel
a763454c0b mgmt/mcumgr/grp/img: No MCUboot flags setting in DirectXIP
It is no longer possible to select image for test or confirm
when MCUboot has been configured for DirectXIP.
MCUboot flags, in image trailer, are now ignored in DirectXIP
mode allowing to use entire slot for image upload.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Dominik Ermel
0a5c4aba52 mgmt/mcumgr/grp/img: No upload for MCUboot in single app mode
Image management is now disabled by default if MCUboot
is configured for single application mode.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Dominik Ermel
87efe30b3a mgmt/mcumgr: Use boot_set_next to set image for test or confirm
The commit adds img_mgmt_set_next_boot_slot function which uses
boot_set_next, from MCUboot/bootutil, to set application slot
for next boot.
The img_mgmt_set_next_boot_slot is intended to replace
img_mgmt_state_confirm and img_mgmt_state_set_pending.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Dominik Ermel
2244974dd6 mgmt/mcumgr: Add img_mgmt_active_slot() and img_mgmt_active_image()
The commit adds img_mgmt_active_slot() which allows to get
active (running) slot for given application image.
Added img_mgmt_active_image() allows to get number of image running
on current MCU core.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Mariusz Skamra
12d8a0d178 Bluetooth: id: Keep RPA as bt_addr_t
There is no need to store the RPA in bt_addr_le_t structure, as the
bt_addr_le_t.type is unused anyway. Both bt_rpa_create and
bt_id_set_adv_random_addr take bt_addr_t as parameter.
Saves 1 byte of address type.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-12 10:55:50 +03:00
Mariusz Skamra
88c20b9cdd Bluetooth: id: Fix uninitialized RPA
This fixes uninitialized RPA value for BT_ID_DEFAULT.
The regression has been introduced in
8d6b206064.
As the result, the private address was not created and the advertising
was started with 00:00:00:00:00:00 address.
In case of the other advertising ID's, those are initialized
from id_create context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-12 10:55:50 +03:00
Balaji Srinivasan
491628ae06 Bluetooth: host: Fix dangling reference in service changed
The bt_gatt_indicate() expects its parameters to remain valid while the
indicate procedure is active. But the `sc_range` variable was local to
the function. It is assigned to the `data` field and passed on to
bt_gatt_indicate(). The memory associated with `sc_range` goes out of
scope as soon as the function returns thereby breaking the contract of
the API. This dangling reference will lead to undefined behavior.
This is now fixed by making the `sc_range` array static and further
making it an array of arrays, as the sc_range may have different values
for each connection.

Found as violation of MISRA C:2012 and CERT DCL30-C by sonarcloud.

Signed-off-by: Balaji Srinivasan <balaji.srinivasan@nordicsemi.no>
2023-05-12 09:55:53 +03:00
Erik Brockhoff
b49ce8febe Bluetooth: controller: fixup HCI LE Create CIS 'parameter' checks
BT Core Spec states that feature exchange should be initiated if
not already performed. So in this case initiate feature exchange
and 'abort' enqueued CIS create if peer doesn't support CIS peripheral
feature

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Erik Brockhoff
105621bdce Bluetooth: controller: Only generate ntf on host initiated feature exch
Only generate notification when feature exchange was initiated by host

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Erik Brockhoff
c1b5aaecf8 Bluetooth: controller: confirm central role on CIS Create
Confirm that the 'requesting connection' is acting as central

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Johann Fischer
2dbccf0654 usb: device_next: do not set alternate 0 for non-existent interfaces
A request to set alternate zero for a non-existent interface
would succeed because of the inappropriate order of checks.
Move the check if the desired alternate is the same as the
current one after the check if interface exists.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Johann Fischer
aa5b6db0f4 usb: device_next: correct return type of get/set alternate value helper
Correct the return type of the helper function to get/set
current interface alternate value.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Johann Fischer
e3b17aa5ed usb: host: improve robustness of descriptors print
Check that the length of the packet is at least the size of
the descriptor head. Otherwise there may be unpleasant side effects.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Andrei Emeltchenko
a4341bbc2c bluetooth: audio: Fix logical check
I imagine that expression (req != 0 || req != 1) is always true. Fix
it changing '||' to '&&'.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-11 13:29:46 +02:00
Georges Oates_Larsen
62168b659e net: conn_mgr: connect/disconnect adjustments
Rather than raise error on connect if iface is down, just take the iface
up.

Rather than raise error on disconnect if iface is down, just ignore the
disconnection request.

Adjust tests and documentation accordingly.

This should make the API easier to use for applications and is more in
line with the original L2 agnostic connectivity RFC.

Also replace some instances of net_if_flag_is_set with
net_if_is_admin_up, which is cleaner and identical in function.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
068dc8ba6f net: conn_mgr: Simplify DAD handling
The current method for handling DAD directly tracks a DAD state for each
iface.

This does not reflect the fact that each individual IP has a separate
DAD state.

This also does not align with the logic in conn_mgr_initial_state, which
instead uses net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...).

Thus, the current approach falsely reports IPv6 ready when DAD adds
the link_addr, and also fails to report IPv6 ready if DAD is disabled.

This commit removes DAD tracking completely, and relies solely on
net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...), fixing both
problems, and simplifying the event tracking.

For consistency, slight modifications to IPv4 handling as well.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
74ba47bed0 net: conn_mgr: Fire events only on connectivity gain/loss
Currently, conn_mgr fires L4_CONNECTED and L4_DISCONNECTED events for
every individual iface that gains or loses connectivity.

After this commit, these events are only fired when the first iface gains
connectivity, and the last iface loses connectivity, respectively.

This is so that applications can rely on conn_mgr as a simple way to
track whether connectivity is available.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
b6897c211a net: conn_mgr: Ignore ifaces and L2s
Adds a flag to allow ifaces and L2s to be ignored.

This is so that applictions have better control over what ifaces they
want connectivity management for.

Enabling the flag forces conn_mgr to consider the iface
unready.

Also increase NET_CONNECTION_MANAGER_PRIORITY default value from 0 to 1
so that applications can register SYS_INIT callbacks that fire just
before conn_mgr initializes. This allows ignored ifaces to be configured
before conn_mgr starts, if needed.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
6cda221c53 net: conn_mgr: refactor event logic
In preparation for altering the conditions under which conn_mgr
fires NET_EVENT_L4_CONNECTED and NET_EVENT_L4_DISCONNECTED,
refactor the event logic without changing its behavior.

These changes do not alter the behavior of conn_mgr. They merely change
how that behavior is expressed so that it is easier to understand, and so
that upcoming changes are easier to implement.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
7afca97f9e net: conn_mgr: Add thread-safety
Current implementation does not prevent the net_mgmt thread from
preempting during state change handling and generating more
state changes. Add a mutex to protect internal state of conn_mgr

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
ad7e0d3712 net: conn_mgr: Rename flags
Rename internal flags for clarity

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
41d6a9bcec net: conn_mgr: relocate if_get_binding
Relocate conn_mgr_if_get_binding to conn_mgr_private.h so that it
can be used by test suites.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
716c19f7ef net: conn_mgr: Reorganize files
Since conn_mgr is a subsystem rather than a library, relocate it
directly into subsys/net rather than subsys/net/lib/

Rename header files to better match their function.

Remove net_ prefix from conn_mgr types, API, and files, since it is
unnecessary.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Vinayak Kariappa Chettimada
7eaf577772 Bluetooth: Controller: Fix Peripheral CIS supervision timeout
Fix premature Peripheral CIS supervision timeout due to
corrupted trx_performed_bitmask value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Vinayak Kariappa Chettimada
875349047e Bluetooth: Controller: Fix Peripheral CIS receive window size
Fix peripheral CIS receive window to consider that the
peripheral ACL could drift at the instant the CIS is being
established.

Hence add additional EVENT_TICKER_RES_MARGIN_US as receive
window length.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Vinayak Kariappa Chettimada
9338ecc5b8 Bluetooth: Controller: Fix Central CIS scheduling precision
Fix Central CIS offset scheduling to microsecond resolution
precision. CIS offset calculation was missing the ACL event
remainder value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Johann Fischer
71d9b0d5ff usb: device_next: add CDC ECM class implementation
Add CDC Ethernet Control Model class implementation for the
new experimental USB device support based on the existing
implementation subsys/usb/device/class/netusb/function_ecm.c.

The implementation forms virtual ethernet connection between
USB host and USB device and requires two corresponding MAC
addresses, one for the virtual interface on the device side,
and other for the host which is described by a string descriptor.
With upcoming changes it should also possible to use a real
ethernet controller as media access on the device side.

CDC ECM implementation supports multiple instances which are
specified using DT. The number of instances is limited by the
number of endpoints on the controller, two to three should usually
be possible.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 11:26:54 +02:00
Nithin Ramesh Myliattil
8d6b206064 subsys/bluetooth/host: Make rpa same for adv sets with same id
Add check to see if RPA is already generated for adv sets
with same id. If generated use the same address for all adv sets
with same id else create new RPA.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2023-05-11 08:31:24 +00:00
Emil Gydesen
563b66bc29 Bluetooth: BAP: Shell: Broadcast assistant compiler warning fixes
Fixes a few compiler warnings from the BAP Broadcast Assistant
shell modules.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-11 10:15:10 +02:00
Vinayak Kariappa Chettimada
a2a2b86665 Bluetooth: Controller: Fix uninitialized CIG num_bis member variable
Fix uninitialized CIG num_bis member variable on CIG Remove.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 10:05:55 +02:00
Emil Gydesen
117f6295d1 Bluetooth: BAP: Broadcast source validate subgroup count in create
Add proper validation check for the number of subgroups
attempted to be added to the broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-11 10:05:41 +02:00
Emil Gydesen
afd4161a84 Bluetooth: BAP: Broadcast start add missing NULL check for adv
Added missing NULL check for the advertising set pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 17:54:12 +02:00
Emil Gydesen
926219156b Bluetooth: Audio: Shell: Add preset copy functions
Add common preset copy functions for unicast streams and
broadcast sources.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 15:27:46 +02:00
Emil Gydesen
4d43101fa7 Bluetooth: Audio: Shell: Make broadcast source generic
Implement profile-agnostic broadcast source and broadcast
stream structs, similar to the unicast stream struct.

The purpose of these are to be able to use the same structs
for multiple profiles such as BAP, CAP and TMAP.

Since only the BAP shell implements broadcast support at this
moment, the changes are minimal, but makes it easier to implement
broadcast support for other profile shells.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 15:27:46 +02:00
Flavio Ceolin
942b99a322 usb: audio: kconfig: Fix experimental feature
select EXPERIMENTAL for experimental option.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-10 11:41:50 +02:00
Flavio Ceolin
9b1da61d6a lwm2m: kconfig: Fix experimental feature
select EXPERIMENTAL for experimental option.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-10 11:41:50 +02:00
Robert Lubos
ff0fd2d7a7 net: iface: Improve thread safety of net_if_ipv*_maddr_* functions
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Robert Lubos
45cb3f9813 net: if: Improve LL address access thread safety
As `net_if_get_link_addr()` returns a pointer to the link layer
structure, some extra protection is needed to prevent its contents from
being changed while accessed. Using the mutex lock associated with an
interface should do the trick.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Robert Lubos
838a94288e net: if: Rework interface locking
Instead of having a single global mutex, covering, in most cases
unrelated, access to all network interfaces, introduce a separate mutex
for each network interface.

Wherever interface function operates on an individual interface context
data, use local mutex protection instead. The global mutex remains only
to protect access to shared resources (IPv4/6 context pool, timer lists
etc.).

Finally, rework the timer expiry handlers, to prevent interface
functions from being called while the global lock is held (the global
mutex has to be held when iterating over the timer list, as lists are
not thread safe). The reason for this is to avoid possible deadlock
scenario. The global mutex is sometimes being locked, while inside
interface function (protected by a local mutex), so if it was allowed
the other way as well, a deadlock could occur.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Emil Gydesen
5ce5940ac5 Bluetooth: CSIP: Fix issue with ordered access without lock char
Fixed issue when performing the ordered access procedure on
a set of devices where none had the lock characteristics.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
41fd5b80df Bluetooth: CSIP: Add missing and fix Set Coordinator set info
The set info returned by the Set Coordinator did not contain
information about the lockable state. Furthermore the
set info was not properly initiated, as it was missing the
rank, which was set somewhere else.

This commit adds the lockable state to the set info.
This commit removes the rank from internal structure,
and uses a reference to the set info instead, and only
store the rank there.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
f3259daa8a Bluetooth: CSIP: Fix Set Member set size and rank param validation
The set size and rank validation did not allow setting e.g.
rank = 2 and set_size = 0, which should be allowed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
3f8daa6762 Bluetooth: CSIP: Add support for optional characteristics
Whenever a CSIS instance is registered with
bt_csip_set_member_register we now properly check if the
set size, rank and lock characteristics should be present.
If not, then remove them from the service declaration.

It is done this way, as it is easier (read: possible) to
remove characteristics from the service declarations,
than it is to add the optional characteristics, as the
optional characteristics may be present in some CSIS
instances, but not in others.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
8ae46910c8 Bluetooth: CSIP: Avoid multiple conn CBs registers
The bt_csip_set_member_register function would register
the connection, and connection auth info, callbacks for
each CSIS instance, which could give errors when/if the
callbacks are called too many times. In any case, they
should not be registered multiple times.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Georgij Cernysiov
464f6f6438 net: l2: ethernet: lldp: prevent slist corruption
LLDP start timer is executed when iface is up
at startup, then once more when iface up event
is received.

When iface is up before net_lldp_init call, then multiple
entries are added to the lldp_ifaces related to the
same iface.

That leads to continuous loop execution within
lldp_tx_timeout.

This commit checks if lldp tx_timer_start is set and
doesn't append new entry into the slist.
The tx_timer_start is set at startup and reset on
down event.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-05-10 16:54:44 +09:00
Emil Gydesen
8c2df1bfd5 Bluetooth: BAP: Add return error for sink cb register
Since the provided callback can be NULL which would
break things, add a check and a return value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 16:54:10 +09:00
Emil Gydesen
70b88378f9 Bluetooth: BAP: Limit broadcast sink streams to proper max value
The number of streams for a broadcast sink is maximum 31,
or the maixmum number of BIS we support.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 16:53:56 +09:00
Tom Burdick
ea8930bd78 rtio: Cleanup the various define macros
Reworks the zephyr macros and pools to be objects in their own right. Each
pool can be statically defined with a Z_ private macro. The objects can
then be initialized with an rtio instance statically.

This cleans up a lot of code that was otherwise doing little bits of
management around allocation/freeing and reduces the scope those functions
has to the data it needs.

This should enable sharing the pools of sqe, cqe, and mem blocks among rtio
instances in a future improvement easily.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Tom Burdick
e4b10328b4 rtio: Use mpsc for submission and completion queue
Rather than the rings, which weren't shared between userspace and kernel
space in Zephyr like they are in Linux with io_uring, use atomic mpsc
queues for submission and completion queues.

Most importantly this removes a potential head of line blocker in the
submission queue as the sqe would be held until a task is completed.

As additional bonuses this avoids some additional locks and restrictions
about what can be submitted and where. It also removes the need for
two executors as all chains/transactions are done concurrently.

Lastly this opens up the possibility for a common pool of sqe's to
allocate from potentially saving lots of memory.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Vinayak Kariappa Chettimada
92f0b5490c Bluetooth: Controller: Fix uninitialized ticks_slot in CIS create
Fix use of uninitialized ticks_slot value in calculation of
cis_offset_min when creating CIS. Calculate the ticks_slot
value earlier when committing the CIG parameters.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:31 +02:00
Vinayak Kariappa Chettimada
9c95dce9a4 Bluetooth: Controller: Fix incorrect use of rx buffer in Tx ISR
Do not enqueue node rx buffers for generating invalid ISO
data from Tx ISR while supplying the node rx buffer to
Radio. This causes node rx pool corruption and also MIC
failures in the central ISO LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
038c89b2c9 Bluetooth: Controller: Remove redundant CIS encryption code
Remove redundant unused CIS encryption related code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
0777583ca1 Bluetooth: Controller: Fix peripheral ISO data ack mechanism
Fix peripheral ISO data ack mechanism to correctly update
the SN when PDUs fail to be received.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
0b27981f94 Bluetooth: Controller: Do not disconnect all CIS on MIC failure
Fix implementation to not disconnect all CIS when one
connection has MIC failure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
8a376a747e Bluetooth: Controller: Use strict cis_offset_min when CIG is active
When there is an active CIG for a new CIS create, then use
strict cis_offset_min/cis_offset_max so that the new CIS
is scheduled inside the active CIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 15:04:32 +02:00
Ajay Parida
7f9ba751e9 net: wifi_mgmt: Handle ps command error
Failure of setting ps param is handled with error string
at user/ app level.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
49e6b0c256 net: shell: Code cleanup for ps related commands
Setting ps_mode and ps_timeout related changes handled
in single power save op.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
bdef1bad78 net: wifi_mgmt: Configure ps wakeup mode
'ps_wakeup_mode' is used to set the wake up interval
to either 'dtim or 'listen_interval'. By default the
sta wakes up every dtim interval.
With 'ps_wakeup_mode' set to 'listen_interval' sta
will wake up for every listen interval period configured.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
68403669c6 net: wifi_mgmt: Configure listen interval
listen interval is the time periods the STAs may be in idle
without listening beacons.
By default STA wakes up for every DTIM period.
If listen interval based power save is used
STA uses configured listen interval period(default 10
beacon intervals) to wake up.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Dmitrii Golovanov
63fc307404 tests: ztress: Extend ZTRESS_EXECUTE() description
Add more details on the number of thread contexts possible
for ZTRESS_EXECUTE().

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-09 08:47:53 -04:00
Dmitrii Golovanov
130652efbd tests: ztest: ztress: Fix out-of-bounds at ztress_execute
Fix ztress_execute() out-of-bounds in case it is called with timer
and for maximum number of threads allowed (CONFIG_ZTRESS_MAX_THREADS).

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-09 08:47:53 -04:00
Mahesh Rao
d3010aae80 subsystem: sip_svc: Add SDM mailbox specific shell
Add shell based on sip_svc subsystem to access the SDM mailbox in
EL3 layer using ASYNC sip_svc request.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-05-09 08:46:50 -04:00
Mahesh Rao
dc9dc3d044 subsystem: sip_svc: Add ARM SiP SVC subsystem
Introduce a new SiP SVC subsystem to provide ARM Silicon Provider based
supervisory call services. SiP SVC service provides the capability to
send SMC/HVC call from kernel running at EL1 to hypervisor/
secure monitor firmware running at EL2/EL3 and also added SiP SVC shell
commands to exercise the service.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-05-09 08:46:50 -04:00
Jamie McCrae
aaed91ec4f mgmt: mcumgr: grp: img_mgmt: Only verify image if hash is valid
Prevents verifying the image has been uploaded successfully using
the hash provided at the start of the upload if the hash is not
the correct length of an SHA256 hash.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-09 14:29:05 +02:00
Herman Berget
688f5baded Bluetooth: Host: Fix warning from the logging subsystem
Cast `dhkey` to `void*` to avoid a warning from the logging subsystem:
```
<wrn> cbprintf_package: (unsigned) char * used for %p argument.
It's recommended to cast it to void * because it may cause misbehavior
in certain configurations
```

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-09 14:28:49 +02:00
Pavel Vasilyev
1fdf283531 Bluetooth: Mesh: Remove outdated RPL entries in settings work item
This allows to move flash operations from the context that triggered
IVI update to the mesh settings work item that runs on the system
workqueue. After this change, the outdated RPL entries will be removed
in the setting work item triggered by store_pending function in
mesh/settings.c. This is required to for a case where the mesh settings
work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-09 13:03:38 +02:00
Troels Nilsson
c743edaaa6 Bluetooth: Controller: Fix endianness handling for DID/SID struct
Bitsets across byte boundaries does not work properly for big-endian;
Converted to use two uint8's instead

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-05-09 13:03:28 +02:00
Vinayak Kariappa Chettimada
81c9795023 Bluetooth: Controller: Set Broadcast ISO related supported cmd bits
Set Broadcast ISO related HCI Read Supported Commands bits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 11:30:41 +02:00
Ajay Parida
bdec033889 net: shell: Display TWT response details
Show TWT response parameters details.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 09:24:30 +02:00
Krishna T
2b48c92742 net: wifi: Fix TWT interval
As we are using a generic validation function for limits, due to data
type mismatch the check for TWT interval overflow and fails.

Fix the data type and accordingly the maximum value in the help.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-09 16:24:10 +09:00
Aleksander Wasaznik
bb1ede6a9b Bluetooth: Use bt_addr_eq
Refactor. Using `bt_addr_eq` instead of `bt_addr_cmp`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-05-09 09:23:52 +02:00
Xudong Zheng
79c4c82baf logging: change log_output_timestamp_to_us() to take log_timestamp_t
If CONFIG_LOG_TIMESTAMP_64BIT is enabled, the timestamp will be 64-bit

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2023-05-08 16:57:02 -04:00
Emil Gydesen
68d1d7d1b4 Bluetooth: Audio: Shell: Add broadcast assistant add broadcast_id
Add command to add a source by the broadcast ID. This will
initiate scanning for the broadcast ID, making it unnecessary
for the user to keep track of both the broadcast ID, the SID
and the address, and just focus on the (properly) known
broadcast ID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
d97b0e1ea9 Bluetooth: Audio: Shell: fix missing opt arg for assistant scan_start
The command has an optional parameter that could not be used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
ed2d30e382 Bluetooth: Audio: Shell: cmd_bap_broadcast_assistant_broadcast_code use hex
The cmd_bap_broadcast_assistant_broadcast_code used decimal, instead
of hex, for the broadcast code, making it a lot harder to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
f24e9d9fcd Bluetooth: Audio: Shell: Print BIS Sync as hex
Since the value is a bitfield, printing it as hex makes it easier
to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
8a3aa4c289 Bluetooth: Audio: Shell: Remove name from bap_broadcast_assistant_scan_cb
The callback does not have the advertising data, so the name
would always just be empty.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
1ef2ce40d6 Bluetooth: Audio: Add PA sync broadcast shell commands
Add shell commands to add a PA sync as a broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a180c013db Bluetooth: Audio: Modify broadcast_id prints/logs to use 24-bit
Always print/log the 24-bits (as hex) of the broadcast ID to better
use it with e.g. the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
f2ce934209 Bluetooth: Audio: Add additional logging to broadcast assistant
Adds additional logging, as well as making the API param checks
more similar.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
043241d6fa Bluetooth: Audio: Broadcast Assistant: Fix subscribe issue
If starting the discovery procedure multiple times, the
subscribe function returns -EALREADY which needs to be handled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
fa70c86cd6 Bluetooth: Audio: Add common audio shell print commands to audio.h
Move common audio shell print functions into audio.h.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a431f5235b Bluetooth: Audio: Move the decode_base functionality to a public function
Moved the implementation of the pa_decode_base to a public
function, and modified it to return better error codes.

The implementation was moved to be publically
accessible, rather than internal in the Broadcast Sink,
as e.g. a Broadcast Assistant need to be able to decode the
BASE too. This wil also allow an application to decode it
itself, if it so wanted to.

This also adds a log module for the audio.c file, as logging
would otherwise not be supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
e23a5234a1 Bluetooth: Audio: Make broadcast assistant params const
Make the add and mod source parameters `const`, as well
as the broadcast code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
4e5a3b9e79 Bluetooth: Audio: Broadcast Assistant: Verify PAST support
Verify that PAST would be possible before providing
BT_BAP_BASS_PA_REQ_SYNC_PAST as the PA sync value to the
Scan Delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a6bd893d55 Bluetooth: Audio: Make pa_sync boolean
Make the `pa_sync` field of the
bt_bap_broadcast_assistant_add_src_param and
bt_bap_broadcast_assistant_mod_src_param to boolean
instead of uint8_t, as it represents a boolean value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Herman Berget
1f43e126a8 Bluetooth: Host: Fix setting missing params in create connection v2.
The adv_handle and subevent were always set to 0.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-08 11:24:25 +02:00
Dmitrii Golovanov
4694b15605 net: pkt: Fix possible NULL dereference at net_pkt_cursor_operate()
Fix possible NULL dereference at net_pkt_cursor_operate() and
resolve 'Dereference after null check' warnings from the Coverity
static code analysis.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-08 17:40:41 +09:00
Fredrik Danebjer
da25ed53d0 Bluetooth: audio: Add paired_ep to endpoint info
Added paired_ep to bt_bap_ep_get_info, which would allow to check
whether an endpoint is paired with another endpoint, this would
indicate that its coupled to a bidirectional iso.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-05-08 10:25:07 +02:00
Piotr Jasiński
e010dcee5d net: update tfm dependency for psa
TFM is not the only provider for PSA API, which means
the PSA config shouldn't depend only on it.

Signed-off-by: Piotr Jasiński <piotr.jasinski@nordicsemi.no>
2023-05-08 10:23:18 +02:00
Emil Gydesen
4421b80dd1 Bluetooth: ASCS: Fix receiver_ready on state change
The receiver_ready field can only be set while in the enabling
state, and is a requirement to go into the streaming state.

If for any reason we go into a state that is not enabling
or streaming, then the receiver_ready field should be
cleared, as the circumstances are changed.

This also fixes an issue where if the CIS disconnects,
then we go from the streaming state to the
qos configured state, without clearing it, causing
incorrect behavior if we attempt to connect the streams
again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 09:59:44 +02:00
Marek Pieta
8df81737e0 mcumgr: img_mgmt: Let image version comparison use build number
Change allows using build number in image version comparison.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-05-08 09:59:19 +02:00
Marek Pieta
ce18ed05d1 mcumgr: img_mgmt: Fix check for upgrade-only
Change fixes check for upgrade-only to ensure that the the new image
version is greater than version of the currently running image.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-05-08 09:59:12 +02:00
Pavel Vasilyev
177e9b93bf Bluetooth: Mesh: Add API to store model's user data in settings work
Mesh models may have a data that needs to be stored persistently.
Currently, the models should call bt_mesh_model_data_store and the store
will happen in the calling context. Most likely that it will be called
in BT RX thread as this is the context from which model's opcodes
handlers are called. Thus, the thread will be blocked until the store is
finished.

Another issues is that some models may have states that changes
frequently. Triggering the store on every state change may wear out
flash. Therefore, the models need to implement some postpone mechanism
to reduce the flash wear out.

The mesh stack has already implemented the mechanism of deferred store
with its own settings. The models could use it instead of implementing
their own mechanism.

In combination with the mesh settings workqueue, the models can store
their data without blocking the stack work.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-08 09:58:21 +02:00
Pavel Vasilyev
e33a4ace0f Bluetooth: Mesh: Use separate workq for storing mesh settings
Currently mesh settings are stored in the system workqueue context.
Most of other stack functionality, such that advertisements (incl
relay), loopback, transport sar, beacons transmission, etc. is also
processed in the system workqueue context. When a massive amount of
data needs to be stored and in particularly when page erase needs to
be triggered by GC of NVS subsystem to allocate flash pages, the
execution of the stack (and other functionality that uses the system
workqueue) will be blocked until storing is finished. For example,
right after the provisioning of a erased device, a node may not be
responsive for up to 400ms before it can continue sending messages.
The waiting time may increase if there is a GATT connection in the
mean time.

When write or erase operation is triggered, the flash driver waits for
Bluetooth controller to allocate a time needed to perform the operation.
During the whole operation, the context from which the operation was
triggered is put to sleep. This allows other threads to run until
Bluetooth controller finds the time for the flash driver. In other words,
every settings_save_one or settings_delete should be considered as
rescheduling points.

Considering this, Bluetooth mesh can use another thread to store its
settings, thus releasing the system workqueue for other tasks including
the operation of the stack itself.

The consistency of the data to be stored is guaranteed by the current
implementation where the data is copied to another struct before calling
settings_save_one. The pending flag of a particular module is dropped in
settings.c before starting to store the corresponding data. Thus, if
during the sleep the node receives a message that triggers a change in a
module which data is currently being stored, the pending flag will be
restored and the new change will be stored eventually.

Having this option enabled including with the partial erase, will make
the node more responsive in the described situations.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-08 09:58:21 +02:00
Emil Gydesen
8d24d506b3 Bluetooth: Audio: Shell: Move audio defines to audio.h
The generic BT shell header, bt.h, contained quite a few things
related to audio, which should be put in the audio.h shell header
file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-05 16:17:59 +02:00
Vinayak Kariappa Chettimada
c01cd1c482 Bluetooth: Controller: Review rework changes for multiple CIS support
Assorted review rework changes for multiple CIS support
implementation commits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
94821ef04c Bluetooth: Controller: Preliminary multiple peripheral CIS support
Updated nRF5 Series LLL implementation to support multiple
peripheral CIS establishment from peer central devices.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
3306f3160f Bluetooth: Controller: Central multiple CIS using advanced scheduling
Central multiple CIS create implementation using advanced
scheduling to find the active CIG events and calculate the
CIS offset to be used in the LL_CIS_REQ PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
2007967553 Bluetooth: Controller: Use Conn ISO prepare latency to check timeout
Use accumulated connected ISO LLL prepare callback latencies
to check supervision timeout.

Also use the accumulated connected ISO LLL prepare callback
latencies to adjust SN and NESN values.

Connection establishment can cause short prepare callbacks
inserted before Connected ISO group prepare callbacks, that
cause the Connected ISO group prepare callbacks being
cancelled while being in prepare pipeline. Hence, it is
necessary to accumulate prepare callback latencies wherein
ticker callbacks are executed but prepare callbacks are
cancelled in the prepare pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
ef8b05e83a Bluetooth: Controller: Preliminary Central multiple CIS support
Implementation of preliminary Central with multiple CIS
create support in Lower Link Layer. Uses a simple CIS
offset calculation that works when ACL are created with
connection interval that is multiple of CIG ISO interval.
Each ACLs are offset using BT_CTLR_CENTRAL_SPACING hence
having the same CIG sync delay values for all the ACLs.
Advanced Scheduling to setup CIS in any order of ACL and
CIS combination, ACL placed anywhere in timeline and CIS
creation will come therein will be implemented in later
Pull Requests.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
5152672d06 Bluetooth: Controller: Include remainder when calculating cis_offset
Include ticker expire remainder value when calculating the
cis_offset to acheive fine timing in scheduling the CIG
radio events relative to its associated ACL radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
e09c2ddf7a Bluetooth: Controller: Use ticker_start_us for Central and ISO setup
Use the ticker_start_us() interface for Central and Central
ISO setup to acheive fine timing for the first expire
timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
4e65cae32a Bluetooth: Controller: Ticker first expire with remainder
To acheive microsecond or fine timing for first expire
timeout, pass remainder value of the coarse tick to a new
ticker_start_us() interface. The new interface is available
with BT_TICKER_EXT feature enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
285649c894 Bluetooth: Controller: Fix implementation of CIS Null PDU Indicator use
Fix implementation of CIS Null PDU Indicator use to meet the
BT Specification statement, that, if the source of the data
fails to provide a payload in time for a CIS subevent, then
the link layer shall transmit a CIS Null PDU instead.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9ccf70fd27 Bluetooth: Controller: Extended Advertising using ticker expire info
This is re-introduction of Extended, Periodic Advertising
and Broadcast ISO using ticker expire info feature to get
the aux, sync and BIG offsets.

Relates to commit 714d74b77b ("Bluetooth: controller: Use
new ticker feature to get offsets").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
6a1a93e587 Revert "Bluetooth: controller: Use new ticker feature to get offsets"
This reverts commit 714d74b77b.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9cada37d9b Bluetooth: Controller: Add BT_TICKER_EXT_EXPIRE_INFO Kconfig
Add BT_TICKER_EXT_EXPIRE_INFO Kconfig.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
52615afcf1 Bluetooth: Controller: Remainder and Lazy depends on match get
Ticker remainder and lazy get depends on match get interface
provided by BT_TICKER_NEXT_SLOT_GET_MATCH.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
e912a6589a Bluetooth: Controller: Remove redundant Kconfig range and default
Remove redundant range and default for BT_CTLR_ADV_AUX_SET
when supporting BT_CTLR_ADV_PERIODIC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
08c1b1749a Bluetooth: Controller: Fix BT_TICKER_NEXT_SLOT_GET select
Fix BT_TICKER_NEXT_SLOT_GET select, to depend on
BT_CTLR_SCHED_ADVANCED.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9600c94c4b Bluetooth: Controller: Fix BT_TICKER_EXT BT_TICKER_LOW_LAT dependency
BT_TICKER_EXT is not supported with BT_TICKER_LOW_LAT.
Remove redundant select of BT_TICKER_EXT for
BT_CTLR_ADV_EXT.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
3fb90bb601 Bluetooth: Controller: Group depends on together in Kconfig file
Group depends on clauses together in the Kconfig.ll_sw_split
file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Emil Gydesen
2a2f067333 Bluetooth: HAS: Add missing memset of read params
The missing memset caused invalid chan_opt when EATT was
enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-05 11:26:11 +02:00
Maurits Fassaert
42507c69c2 storage: flash_map list partition labels
Add the labels from the device tree fixed flash partitions
as a column to the flash_map list shell command.

Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
2023-05-05 10:02:19 +02:00
Herman Berget
a947af8ac3 Bluetooth: Host: Fix PHY translation from HCI
HCI events use different values for the PHYs than the GAP macros.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-04 20:50:58 +02:00
Erik Brockhoff
44df982d0b Bluetooth: controller: disallow enc start/pause when CIS established
Start/pause encryption should not be initiated on ACL with CIS
established (BT Core Spec 5.4, Vol 6, Part B, Sect. 5.1.3)
Adding test for the added procedure peek function

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-04 10:47:37 +02:00
Kumar Gala
b07be57875 logging: Use TYPE_SECTION macros for log dynamic
Clean up log_dynamic to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Kumar Gala
bae0a5b8b6 logging: Use TYPE_SECTION macros for log const
Clean up log_const to utilize macros for handling sections.

Update database_gen.py to match naming convention change.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Jonathan Rico
7d1a5f5554 Bluetooth: iso: use BT_ISO_SDU_BUF_SIZE()
Use BT_ISO_SDU_BUF_SIZE() instead of calculating manually.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
Jonathan Rico
fb10381328 Bluetooth: iso: use kconfig for userdata size
Use BT_CONN_TX_USER_DATA_SIZE when defining pools of buffers that will go
through `bt_conn_send_cb()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
Jonathan Rico
e460847b60 Bluetooth: host: don't fragment ISO if len <= MTU
MTU doesn't count against the ISO and ISO data headers.

Then a config with CONFIG_BT_ISO_TX_MTU ==
CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE should not fragment SDUs over HCI.

Also set the TS_Flag bit if a timestamp is present.

Fixes #56749

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
romain pelletant
75dd2c9904 net: lwm2m: use path as block context retrieval
Replace block context retrieval using object path instead of token.
Update block context structure
Fix issue #57165

Signed-off-by: romain pelletant <romain.pelletant@fullfreqs.com>
2023-05-03 10:01:37 +02:00
Herman Berget
bf4e3fe2a4 Bluetooth: Host: Fix sync subevent cmd length
The subevents were not considered in the length of the command.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-02 16:56:01 +02:00
Nikolay Agishev
0d8292ab6b ARC: Add HS4x support
Minimal HSDK4xD support

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-05-02 16:54:24 +02:00
Hunter Searle
898a59eb80 Shell: Edit shell to store/retrieve return values
This change to the shell API enables the user to retrieve the
return code of the most recently run shell command. This is
useful both for users wanting specific information beyond the print
statements in a command, but especially for automated users
that prefer a simple return code to parsing human readable text.
This was tested using all default shell commands, as well as
eeprom, flash, and i2c, where specific errors could be forced.
In all cases, the correct return value was returned by the new
retval command.

Signed-off-by: Hunter Searle <hsearle@xes-inc.com>
2023-05-02 16:52:21 +02:00
Emil Gydesen
66f8ab5a28 Bluetooth: BAP: Add specific error code for stopping stopped sink
If the broadcast sink is already stopped (i.e. the streams have
all been disconnected), then we can return a more useful
error code than EINVAL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-02 09:35:11 -05:00
Jordan Yates
8e603d091c Bluetooth: controller: Kconfig TX power dBm
Adds a Kconfig symbol which contains the default controller TX power
directly in dBm. This allows code to directly display/use the configured
power, instead of having to manually iterate over all the
`BT_CTLR_TX_PWR` options.

```
  LOG_INF("BT controller configured for %ddBm TX power",
          CONFIG_BT_CTLR_TX_PWR_DBM);
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-05-02 10:12:23 +02:00
Yuval Peress
3fd0a1508b rtio: fix bug in mempool release API
It was previously assumed that the 'sys_mem_blocks' struct would maintain
information about contiguous blocks allocated so the release API only
took the starting address. This led to an issue where allocating 2+
blocks would end up with a memory leak because any block not being the
first would never be released.

Add the buffer length as an argument so the correct number of blocks can
be released. Also, ammend the tests to match and verify.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-01 09:26:06 -05:00
Paul He
322f5ad4ef storage: flash_map: shell: fix error 'sh' undeclared
Some of `shell` were missed to be updated with `sh`.

Signed-off-by: Paul He <pawpawhe@gmail.com>
2023-04-30 12:48:55 -05:00
Robert Lubos
d15f8e6337 net: shell: Print new flags with the net iface command
Print new NET_IF_IPV6_NO_ND and NET_IF_IPV6_NO_MLD flags when
the "net iface" command is used.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
ee1271f23c net: openthread: Disable ND/MLD for OpenThread interfaces
OpenThread networks do not use ND or MLD as they have their own set of
protocols to cover this functionality. So far, the use of OpenThread
with Zephyr relied on disabling those protocols support statically with
Kconfig, which prevented OT interfaces from being used along with other
IPv6 interfaces.

With the new network interface flags, it's now possible to disable ND
and MLD on individual interfaces, therefore disable them for OT
specifically.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
c349d53150 net: if: Add possibility to disable MLD per interface
Add new network interface flag, which allows to disable Multicast
Listener Discovery protocol from being used on the interface. This
allows to interfaces that do not support ND (like OpenThread) to
coexist with other IPv6 interfaces.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
c43c408783 net: if: Add possibility to disable ND per interface
Add new network interface flag, which allows to disable Neighbour
Discovery protocol from being used on the interface. This allows to
interfaces that do not support ND (like OpenThread) to coexist with
other IPv6 interfaces.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Pavel Vasilyev
1113c2efd4 Bluetooth: Mesh: Store device key candidate asynchronously
This allows to move flash operations from the context that triggered
storing device key candidate to the mesh settings work item that runs
on the system workqueue. This is required to for a case where the mesh
settings work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-29 12:24:28 +02:00
Pavel Vasilyev
f3085ab95d Bluetooth: Mesh: Move storing of new prov data to settings work item
This allows to move flash operations from the context that triggered
bt_mesh_provision or bt_mesh_reprovision to the mesh settings work item
that runs on the system workqueue. This is required to for a case where
the mesh settings work item is running on a separate thread instead of
the system workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-29 12:24:28 +02:00
Emil Obalski
169d8fafdc ipc: icmsg: Add mutual exclussion access to shmem
If the icmsg backend is sending the data from many
contexts, the send buffer must be accessed only by one
context at a time. Ensure that by adding mutex when
sending.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Emil Obalski
52e203f800 ipc: Remove internal API for clearing shared memory
Clearing of shared memory by one side of the communication
is no longer required after
commit 0620cb1fe1
("ipc: ipc_service: icmsg: Increase reliability of bonding")
was merged.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Stine Åkredalen
80158c1428 doc: Bluetooth: Mesh: update proxy solicitation docs
Updated related docs. Small fix in mesh/Kconfig and shell.rst.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-04-28 20:37:45 +02:00
Krishna T
30efd04060 net: Make net_mgmt queue timeout configurable
This helps us work with low queue depth of network management queue in
case the we have high rate events.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/56595 .

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-04-28 10:35:27 -05:00
Aleksander Wasaznik
67d6011851 Bluetooth: hci_raw: Fix a LOG_ERR message
The LOG_ERR was printing the wrong variable. `type` always has the value
`BT_BUF_H4` here, so there is no point in printing it.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-28 10:33:18 -05:00
Aaron Massey
07ee466591 emul: Migrate all emulation use to use DT_HAS_
Remove all enabling of CONFIG_EMUL_.* in favor of automatically enabling
peripheral emulators based on the compatible string presence in the device
tree and the one true CONFIG_EMUL.

Zephyr has long since moved to a model of enabling drivers based on the
presence of their associated IC's compatible string in the final devicetree
overlay. There is no reason that emulators can't align in just the same
way, and probably ought to to remove superfluous enabling of configs.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-04-28 08:37:33 -05:00
Herman Berget
5893606187 Bluetooth: Host: Use a valid disconnect reason
"Unspecified Error" is not a disconnect reason allowed by spec.

Fixes #56989

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 14:50:11 +02:00
Mariusz Skamra
292bf966be Bluetooth: audio: ascs: Make use of bt_bap_stream_reset
This deduplicates a code a bit by reusing existing bt_bap_stream_reset
function to unbind and detach the stream object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-28 14:49:25 +02:00
Mariusz Skamra
197e20e3c2 Bluetooth: audio: ascs: Remove redundant sessions pool
This removes redundant bt_ascs structure pool that held the list of
ases per connection. The memory usage can be reduced by moving the conn
reference to bt_ascs_ase structure. This change reduces flash and RAM
memory usage.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-28 14:49:16 +02:00
Herman Berget
d7218fe359 Bluetooth: Host: Add support for receiving connections while synced
The PAwR sync can receive a connection request from the PAwR
advertiser and become peripheral.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 11:00:48 +02:00
Herman Berget
c961e2c212 Bluetooth: Host: Add support for initiating connections from PAwR
This is known as the Periodic Advertising Connection Procedure.

The PAwR advertiser can initiate a connection to a synced device and
become the central.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 11:00:48 +02:00
Morten Priess
5b6198403c Bluetooth: controller: Fixes for CIG with two CISes and separate ACLs
Prevent referencing inactive CISes by clearing state variables
after teardown. This was seen as necessary when having CISes on
different ACLs, and disconnecting ACLs in random order.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-04-28 10:07:46 +02:00
Sam Hurst
0056249a13 usb-c: Add USB-C Subsystem Source PD Support
Add USB-C Power Delivery Source Support to USB-C
Subsystem

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
cb9a250579 usb-c: Refactor soft reset code
Refactor soft reset code

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
3851d3648d usb-c: Properly detect reception of first AMS message
Detect and flag the reception of the first AMS mesage

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
d1cf8148cc usb_c: Transmit Error are not Protocol Errors
Transmit errors must be treated differently than Protocol Errors.
This change sets a flag that informs the stack of a Message
Transmit error.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Emil Gydesen
5076476cf5 Bluetooth: BAP: Fix missing remove of streams from slist
In the broadcast sink when the streams disconnected (without
the PA disconnecting), the streams were not properly
removed from the sink's list of streams. This allowed
the same stream to be added to the list twice, which
would cause a infinite loop as the stream would
point to itself as the next.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-27 20:19:58 +09:00
Jacob Siverskog
6cefad338b Bluetooth: BAP: Shell: Fix NULL pointer dereference
Make sure 'state' is valid.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2023-04-27 20:18:55 +09:00
Ajay Parida
a004a85ccf net: shell: Check connection & capabilities in any TWT operation
Connection status & AP capabilities checked before any TWT operation
is initiated.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-27 09:52:00 +02:00
Herman Berget
e745439c40 Bluetooth: Host: Fix periodic sync reassembly
The reassembly buffer for periodic sync was not initialized
if the sync was established via PAST.

Move the initialization of the reassembly buffer to a common place.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Herman Berget
95bc5cf8e5 Bluetooth: Host: Add support for PAwR Sync
Adds API for Periodic Advertising with Responses - Scanner:
 - Synchronize to a PAwR train
 - Choose which subevents to synchronize to
 - Receive advertising reports from subevents
 - Send responses

The support is enabled by CONFIG_BT_PER_ADV_SYNC_RSP, and requires
a controller that selects CONFIG_BT_CTLR_SYNC_PERIODIC_RSP_SUPPORT.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Herman Berget
9021e2f438 Bluetooth: Host: Add support for PAwR Advertiser
Adds API for Periodic Advertising with Responses - Advertiser:
 - Configure parameters
 - Receive subevent data requests
 - Set subevent data
 - Receive response reports

The support is enabled by CONFIG_BT_PER_ADV_RSP, and requires
a controller that selects CONFIG_BT_CTLR_ADV_PERIODIC_RSP_SUPPORT.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Dmitrii Golovanov
560b777fa8 net: dhcpv4: Fix NULL dereference at dhcpv4_create_message()
Fix dhcpv4_create_message() dereferenced NULL return value from
net_pkt_alloc_with_buffer() in case of no memory available.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-26 20:07:04 +02:00
Dominik Ermel
00f1639e38 mgmt/mcumgr: Fix image erase returning MGMT_ERR_EMSGSIZE
In case when CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR=n then
the image erase command would incorrectly return MGMT_ERR_EMSGSIZE,
even though no such error occurred.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-26 18:15:40 +02:00
Dmitrii Golovanov
f7331e0d66 net: ipv4: Fix fragmented packet NULL dereference possible
Fix net_ipv4_send_fragmented_pkt() dereference of NULL return value
from net_pkt_get_data() possible with non contiguous packet data.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-26 14:34:23 +02:00
Jonathan Rico
ece481d560 Bluetooth: host: att: clear ATT_PENDING_SENT
The ATT_PENDING_SENT flag was still not being cleared in all cases.

Also reset `data->att_chan` when not able to send on a given channel.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Jonathan Rico
2809bace65 Bluetooth: host: l2cap: send only 1 credit
The API doesn't allow the stack to make any guarantees about the number of
available buffers that the app has.

Only send 1 credit at a time, as that is the only guarantee the stack can
give to the peer.

We can send MTU/MPS's worth of credits once we have acquired an SDU buffer
from the application (that is, on the first PDU of the SDU). Though we
still have to cap that to the buffer size we have just acquired.

------

The testcase added here shows a scenario where the relationship
between the number of credits and the number of available buffers does not
hold true any more:

In this test, the app only has one buffer in its pool.

The central will queue SDUs that are bigger than the stack's
buffers (so the user allocator is necessary) but lower than the
channel's MTU.

The device receiving the SDU keeps a reference to the buffer before
returning from the `recv` callback. It releases that reference after a
small delay.

The central will still have credits, so it will queue another SDU, but the
peripheral will not be able to receive the next SDU (as the allocator will
fail) and will close the channel.

To see the test fail, just revert the `l2cap.{c,h}` changes.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Jonathan Rico
6cdb82cb59 Bluetooth: host: l2cap: trigger SDUs that get lost in limbo
Turns out the [first bugfix] was too naive: there is a case where resuming
all channels will not work on all queued SDUs, and the work handler will
give up and wait for the next sent SDU instead of trying to resume again.

This happens when the number of credits and conn contexts is very low for
the amount of data to send.

Always reschedule with a delay to avoid that situation.

[first bugfix]: https://github.com/zephyrproject-rtos/zephyr/pull/50476

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Anas Nashif
6388f5f106 xtensa: use sys_cache API instead of custom interfaces
Use sys_cache instead of custom and internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-26 07:31:22 -04:00
Ryan McClelland
b19c8fc3bc net: ip: net_shell: fix double-promotions warnings
Double promotion warnings are generated with the flag -Wdouble-promotion

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-04-26 12:58:36 +02:00
Kumar Gala
0090ad718a net: Fix build issues with arm-clang
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:

	Error: L6218E: Undefined symbol
	net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
	(referred from ethernet.o).

Fix by adding ifdef protection around promisc code.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-25 19:59:06 +02:00
Ajay Parida
5c023fbbb9 net: wifi_shell: Updated TWT flow id range
TWT flow id is of 3 bit value(maximum mnumber of flows
supported is 8). Flow id range limited to 0 to 7.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-25 12:21:35 +02:00
Mariusz Skamra
d384ef4e57 Bluetooth: audio: ascs: Fix handling arrayed parameters
This fixes loop over arrayed metadata/cc parameters. The paramaters have to
be pulled from the buffer, because in case the ASE_ID is invalid or in
invalid state, the next loop iteration would read invalid data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-25 12:21:23 +02:00
Emil Gydesen
303bcfdcb7 Bluetooth: Shell: Add testcases for AUDIO_RX and TX disabled
Add configurations where CONFIG_BT_AUDIO_TX and CONFIG_BT_AUDIO_RX
are disabled.

Fixes issues found in the BT shell implemented caused by these
configurations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Emil Gydesen
2c5a249fdd Bluetooth: BAP: Add guard before accessing qos->latency
The qos->latency is not available for broadcast sink-only
builds.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Emil Gydesen
32e8392400 Bluetooth: BAP: Move TX guard to not cover verify funcs
Move the BT_AUDIO_TX guard so that it does not cover the
verification functions for valid_codec and qos, as they
are also relevant for receivers to verify what remote
devices send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Dmitrii Golovanov
6ec39dca6b net: ZWP timeout explicit type on bit shift calculation
Fix tcp_send_zwp() retransmission timeout calculation to avoid sign
extension on bit shift operation: the uint16_t value was implicitly
promoted to 32-bit signed type with sign extension to uint64_t.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-25 12:19:45 +02:00
Pawel Osypiuk
4b7f156403 IPC: rpmsg: Changed method of checking bounded endpoints
Initially that was checked by presence of name and now is changed
to check the flag.

Signed-off-by: Pawel Osypiuk <pawelosyp@gmail.com>
2023-04-24 15:45:09 +02:00
Hein Wessels
2689e16670 net: sntp: support building without NET_SOCKETS_POSIX_NAMES
Fixes the compiler error that occurs when attempting to build
the SNTP library with CONFIG_NET_SOCKETS_POSIX_NAMES=n, while
using native_posix.

Closes #57133

Co-authored-by: Chris Friedt <cfriedt@meta.com>
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-04-24 09:23:17 -04:00
Krzysztof Kopyściński
0a55ec8d52 Bluetooth: Mesh: Add callback for received beacons
This adds callbacks for Secure and Private Network Beacons.
SNB callbacks are called after `secure_beacon_authenticate` ends
with success, and Private Beacon callback after Private Beacon
payload is decrypted succsessfully.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-24 13:36:12 +02:00
Mariusz Skamra
81532bf5f0 Bluetooth: audio: ascs: Remove ascs_cp_rsp_add function redundant param
This removes opcode from ascs_cp_rsp_add function parameters and moves
response buffer initialization to be done in Control Point write
function context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-24 13:34:59 +02:00
Mariusz Skamra
9ec93b5bd5 Bluetooth: audio: ascs: Fix using magic numbers
Use defined values instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-24 13:34:59 +02:00
Sihyun Noh
3788ce3b8b fs: change fatFS initialization to match littleFS.
Mounting the disk in a global function can lead to an issue
where fatFS cannot be mounted due to it not being registered beforehand.
To solve this problem, fatFS is now initialized in POST_KERNEL,
just like the littleFS initialization function.
fatfs_init must be called before attempting to mounte the disk.

Signed-off-by: Sihyun Noh <awake_noh@naver.com>
2023-04-24 13:34:12 +02:00
Pavel Vasilyev
c4fa085ec4 Bluetooth: Mesh: Add async API for Large Comp Data Client
Add asynchronous API for Large Composition Data Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Pavel Vasilyev
b99d4dbce2 Bluetooth: Mesh: Use bt_mesh_msg_ackd_send API in LCD Client
Use bt_mesh_msg_ackd_send API in LCD Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Pavel Vasilyev
60e874472c Bluetooth: Mesh: Use BT_MESH_MSG_CTX_INIT_DEV macro in LCD Client
Use BT_MESH_MSG_CTX_INIT_DEV macro in LCD Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Aleksander Wasaznik
2091144c51 Host: ATT: Use bt_att_is_enhanced everywhere
Refactoring. All occurences of `atomic_test_bit((.*)->flags,
ATT_ENHANCED)` are replaced with `bt_att_is_enhanced($1)`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
af5103bdc3 Bluetooth: ATT: Set correct MTU for EATT L2CAP channel
The EATT MTU in Zephyr is static. We know it at channel creation time,
so we should communicate the MTU as part of channel creation.

Side note: With this approach, it should no longer be neccessary or
useful to do a channel reconfigure.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
3de6f7c99d Bluetooth: ATT: Move setting of initial MTU to att_chan_new
The L2CAP MTU can and should be set already during the channel setup.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
a2dc61a465 Bluetooth: ATT: MTU min instead of cap
The previous approach with `cap_eatt` was flawed. It would overwrite
`le_chan->tx.mtu`, losing its true value. (It is supposed to be the
L2CAP MTU as reported by the remote side.)

The previous approach worked out for UATT because the locally triggered
exchange always carries the remote MTU in the response, so we did not
need to keep track of the remote MTU.

But, unlike the UATT MTU exchange, the L2CAP reconfigure only exchanges
the MTU in one direction. If the remote does the first reconfigure, we
would correctly cap the ATT MTU to our local MTU. But, we would
incorrectly store this as the remote's MTU. When we then increase our
local MTU using `bt_eatt_reconfigure`, we correctly set and send our
MTU.  But we have an incorrect notion that the remote MTU is the value
that we ourselves limited. And mistake would incorrectly limit the
negotiated ATT MTU locally.

The simplest solution is to not mess with `le_chan->tx.mtu` and just
calculate the ATT MTU like Spec intended.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
fa9d41f39b Bluetooth: Host: Add helper bt_att_is_enhanced
This is a refactor. Hopefully, it makes the code easier to maintain.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
d4d0956516 Bluetooth: ATT: Split BT_ATT_MTU for UATT/EATT
This is a refactor. There is no behavioral change because
`BT_LOCAL_ATT_MTU_UATT` is `BT_LOCAL_ATT_MTU_EATT + 2` is
`BT_ATT_BUF_SIZE` is the old `BT_ATT_MTU`.

The old `BT_ATT_MTU` was wrong for EATT bearers. EATT MTU is two bytes
less because of ECRED overhead.

Instead of the old `BT_ATT_MTU`, we define one for each bearer type. We
also define the max of them to use as a convenience for allocating
buffers that fit either.

To avoid confusion, 'LOCAL' has been added to the name. This is to
differentiate it from what the spec calls 'ATT MTU', which is a
negotiated property. (It is the minimum of the two side's local ATT
MTU.)

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
46646452fe Bluetooth: L2CAP: Add missing req_mtu assert in l2cap_ecred_conn_req
There is an assert that `req_psm` is the same for all channels in the
same connection request because HCI requires this. The same is true for
`req_mtu`. This adds the obviously missing assert.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
3148389695 Bluetooth: ATT: Introduce bt_att_mtu
This is a refactoring, only visible inside `att.c`.

Give the expression `chan->chan.tx.mtu` the name `bt_att_mtu`. Use it
when the intention is to get the ATT MTU property of a channel.

This is done in preparation a more complex expression for `bt_att_mtu`,
since the expression currently incorrect. The fix will come in a later
commit in the same PR.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Dominik Ermel
783f8666fc mgmt/mcumgr: Add zcbor_map_decode_bulk_reset utility function
The function should be used to reset map decoding state
between calls to zcbor_map_decode_bulk, while using the same map
for different buffers.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:49 +02:00
Dominik Ermel
4878eebebb mgmt/mcumgr: Add missing initialization of internal state
There was missing initialization for found member of
zcbor_map_decode_key_val structure.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:49 +02:00
Dominik Ermel
a48e6b926c mgmt/mcumgr: Fix failure to confirm active image not reported
Due to broken logic in img_mgmt_state_confirm failure to confirm
was not reported to caller.
If hooks were enabled confirmation event would be passed regardless
whether it has been successful.

Fixes #56617

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:09 +02:00
Jamie McCrae
4cdfa7bdd5 retention: Add optional mutex disablement
Adds an optional Kconfig to disable use of mutexes in the
retention subsystem.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
5e8b067364 dfu: mcuboot_shell: Add command to enter serial recovery
Adds a command which can be used to enter mcuboot's serial recovery
mode when the retention subsystem is enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
7e11b6392b retention: Add boot mode system
Adds a boot mode system which allows for redirecting the boot
target of a device depending upon the state of a retained value.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
64f4404481 retention: Add retention system
Adds a retention system which builds on top of retained_mem
drivers to allow partitioning of areas and data integrity with
magic header prefixes and checksum of stored data.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
c8a0e8c598 mgmt: mcumgr: grp: img_mgmt: Remove dummy header
The dummy header was an opt-in feature to allow testing without a
real image but since we support testing on Qemu in CI which
supports flash partitions, there isn't a need for this option. Not
being deprecated as Kconfig would only have been used as part of
CI, not user applications.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-21 16:33:30 +02:00
Dawid Niedzwiecki
7f7e48e66e mgmt: ec_host_cmd: create chosen string per backend
Create strings to set the chosen node per backend. It is done for
better clarity.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-21 16:29:59 +02:00
Dawid Niedzwiecki
1d62002bba mgmt: ec_host_cmd: update configs naming
Just use better namings for the buffer sizes configs.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-21 16:29:59 +02:00
Emil Gydesen
5ab585d1af Bluetooth: ASCS: Log missing fields of qos_pref
Added logging of the pref_pd_min and pref_pd_max field.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 16:29:08 +02:00
Dominik Ermel
d4ab079cd9 mgmt/mcumgr: Add zcbor_map_decode_bulk_key_found utility function
Function allows to check whether given key has been found
during map decoding with zcbor_map_decode_bulk.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-21 16:28:34 +02:00
Emil Gydesen
4b8574d7b1 Bluetooth: BAP: Shell: Fix bad arg to CAP acceptor ad data
The data array was using the wrong index.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 16:23:27 +02:00
Mariusz Skamra
f35959a261 Bluetooth: ascs: Fix ASE Control Point PDU length validation
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.

ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
length operation if the total length of all parameters written by the
client is not equal to the total length of all fixed parameters plus
the length of any variable length parameters for that operation"

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 13:01:42 +02:00
Mariusz Skamra
3b57b2014c Bluetooth: audio: ascs: Fix invalid Response_Code in notification
This fixes sending proper Response_Code in ASE Control Point
notification in case the client initiates Receiver Start/Stop Ready
operation on Sink ASE.
The response that shall be sent according to the specification is
"Invalid ASE direction", while the implementation sent "Invalid ASE state"
instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 12:55:46 +02:00
Johann Fischer
75ab9f81e3 usb: device: fix control endpoint handling with MPS of 8 bytes
The possible control endpoint MPS for USB 2.0 FS devices is
8, 16, 32, or 64 bytes. Typically, USB2.0 compliant devices support MPS
up to 64 bytes, and we have not had the need to support other MPS.

This patch implements a mechanism to fall back to the minimum allowed
MPS when a controller is likely a USB 1.1 compliant device and does
not support control endpoint MPS of 64 bytes.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-21 12:45:57 +02:00
Emil Gydesen
8e7757275e Bluetooth: BAP: Guard bt_bap_stream_send with CONFIG_BT_AUDIO_TX
Modify the guard of bt_bap_stream_send to use the
CONFIG_BT_AUDIO_TX.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 09:40:39 +02:00
Emil Gydesen
3d877338e6 Bluetooth: BAP: Fix missing guards of sent and recv in uni cli
The unicast client did not properly guard the sent and recv
callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 09:40:39 +02:00
Theo Gasteiger
ce2ac63953 Bluetooth: Fix CONFIG_BT_CTLR_DEBUG_PINS_CPUAPP compile error
Fix appcore compile error when enabling CONFIG_BT_CTLR_DEBUG_PINS_CPUAPP.

Signed-off-by: Theo Gasteiger <gatcode@wdw.one>
2023-04-20 16:10:42 +02:00
Kumar Gala
caea9dc196 logging: Use TYPE_SECTION macros for log strings
Clean up log_strings to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:52:07 +02:00
Kumar Gala
301d0c4712 net: buf: cleanup net_buf_pool use of iterable section
Cleanup linker scripts for net_buf_pool section to use the linker
script related iterable section macros.

Also replace _net_buf_pool_list with macro's instead to complete
iterable section usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:50:04 +02:00
Emil Gydesen
fa95a7add2 Bluetooth: BAP: Add missing Broadcast source param checks
Several input parameter checks were missing in the BAP broadcast
source API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-20 10:47:10 +02:00
Martin Rieva
ddf518e706 Bluetooth: Shell: Extend the shell output of scan data
Add verbose output of scan data to output all received data types as
hex values. This is turned off by default and can be toggled using
the bt scan-verbose-output <on|off> command.

Signed-off-by: Martin Rieva <mrrv@demant.com>
2023-04-20 10:32:55 +02:00
Pieter De Gendt
7de95b76a6 net: lib: dns: mdns_responder: Fix ipv4/ipv6 address handling
This commit simplifies the arguments for sending dns responses
and fixes an issue where both the ipv4 and ipv6 member of a header
union were accessed.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Pieter De Gendt
292bb97f0d net: lib: dns: mdns_responder: Simplify setup_dns_addr
The setup_dns_addr function packet argument can be reduced to
a socket address family.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Pieter De Gendt
e5b52ac034 net: lib: dns: dns_sd: Improve debug prints
Duplicate logging prints make it hard to find the origin.
This commit does a cleanup of the debug messages printed.

Also change the level of an invalid record to debug as this
is out of our control.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Kumar Gala
eec299c130 pm: Use TYPE_SECTION macros for pm_device_slots
Clean up pm_device_slots to utilize TYPE_SECTION macros for handling
sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:15:29 +02:00
Wojciech Slenska
c3575fbd2e net: sockets: fix POLLOUT for offloaded iface
For offloaded iface net_tcp_get is never called, so context->tcp
is always NULL. In that case net_tcp_tx_sem_get will return wrong pointer.
For pollout k_poll will be called with NULL semph,
which cause HardFault.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-04-19 17:15:12 +02:00
Kumar Gala
47cf00058e fb: cfb: Use TYPE_SECTION macros for cfb_fonts
Clean up cfb_fonts to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:54 +02:00
Emil Gydesen
754a5da2ff Bluetooth: MICP: Shell: Add missing "mic_dev" for MICP cmds
The MICP Microphone Device commands were missing the proper
role name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 17:14:30 +02:00
Emil Gydesen
12e82347b4 Bluetooth: BAP: Shell: Scan Delegator prefer past by default
Change the default value of past_preference to true, to prefer
PAST by default when using the scan delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:55:09 -04:00
Emil Gydesen
66af395726 Bluetooth: BAP: Broadcast source fix invalid data pointer
When copying the stream specific codec configuration data,
the value pointer in the bt_data struct was not properly
updated, causing possible invalid data access.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:54:53 -04:00
Emil Gydesen
80bf8c0f7d Bluetooth: CAP: Add missing NULL checks for CAP broadcast start
Add missing checks for param and adv.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:54:37 -04:00
Emil Gydesen
dda3703755 Bluetooth: CAP: Add missing NULL check for unicast_audio_update
The bt_cap_initiator_unicast_audio_update function was missing
NULL and 0 checks for input parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 10:00:45 +02:00
Gerard Marull-Paretas
1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Vinayak Kariappa Chettimada
4b90d01398 Bluetooth: Controller: Fix cis_offset_min used in CIS Create Response
Use the minimum supported cis_offset_min considering that
ACL radio event does not overlap with CIG event. Use the
calculated maximum of local and remote cis_offset_min in the
Response PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-19 03:47:19 -04:00
Øyvind Rønningstad
31c10f5fe1 lwm2m_senml_cbor_encode.c: Manually edit whitespace
since it crossed the 100 column cutoff, even after clang-format.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad
d0c278af78 lwm2m_senml_cbor: Regenerate code files using zcbor 0.7.0
and the _regenerate.sh script.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad
e9eb61bd14 lwm2m_senml_cbor: Update the regenerate script and the patch file
Do patch file application before clang-format.
Add copyright to generated files using the --file-header option in zcbor.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Kumar Gala
6b5139c4bb shell: Convert to using iterable sections
Convert handling of shell_root_cmds, shell_subcmds, and
shell_dynamic_subcmds to use iterable section macros.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-18 12:48:16 +02:00
Georges Oates_Larsen
7c4397ae79 net: conn_mgr: connectivity API
Allows L2s to declare generic association/connection routines
that can be bound by name to ifaces.

Allows L2-agnostic control over connectivity/association for
iface that support it.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-04-18 09:31:53 +02:00
Aleksandr Khromykh
e7f1856143 Bluetooth: Mesh: add experimental support mbedtls psa
Commit adds experimental support mbedtls psa as crypto
backend for ble mesh. It were run only on bsim tests.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Aleksandr Khromykh
77c72aa67b Bluetooth: Mesh: get rid of host dependency for dh key for mesh
Commit gets rid of host dependency to generate DH key.
Mesh uses its own function for it that has synchronous
behavior and correct endianism. It simplifies the provisioning
state machine since it doesn't require waiting for the host HCI
handler.
Also, it removes hidden cross-dependency between BLE Mesh and
SMP in the aspect of competition for the same DH key
(https://github.com/zephyrproject-rtos/zephyr/issues/23292)

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Aleksandr Khromykh
3f08bd335f Bluetooth: Mesh: split crypto on seclib dependent and independent parts
Commit splits mesh crypto module on security library dependent
and independent parts.
Independent part includes security toolbox implementation.
Dependent part includes security algorithms usage based on
API third party security library.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Daniel Nejezchleb
663b684fea net: socket: fix hanging net contexts
Calls put instead of unref on net contexts
in the socket accept function.
Mere unref didn't subtract the reference
count of net context which leaves
it in used state. This situation happens
in case of accepting already
closed connection.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-04-17 15:12:41 +02:00
Daniel Nejezchleb
ee720b5412 net: socket: asynchronous connect
Added a feature of socket connect
being asynchronous. If socket is set
to nonblock with O_NONBLOCK flag,
then connect() is non-blocking aswell.
App can normally poll the socket to
test when the connection is established.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-04-17 11:35:20 +02:00
Johann Fischer
0ad1eef4b7 usb: device: Revert "fix possible deadlock in usb_transfer_sync()"
This reverts commit cd7461495f,
introduced to fix possible deadlock as result of changes in
commit f206170c65
("usb: device: Do not call callback when transfer is cancelled")
which is now reverted.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-17 11:30:48 +02:00
Nickolas Lapp
81e4934ebd usb: device: Revert "Do not call callback when transfer is cancelled"
This reverts commit f206170c65
introduced as workaround for nRF USBD device controller in PR
https://github.com/zephyrproject-rtos/zephyr/pull/16193.

This commit may be reverted due to changes made in
commit e326c58399
("usb: device: Do not cancel transfers on suspend").

Signed-off-by: Nickolas Lapp <nickolaslapp@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-17 11:30:48 +02:00
romain pelletant
eab19663a9 net: lwm2m: add callback for send confirmation
Issue #52328

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-04-17 11:29:14 +02:00
Vinayak Kariappa Chettimada
64b4c6ddbd Bluetooth: Controller: Fix Adv PDU RAM usage for direction finding
Fix Advertising PDU size calculation when direction finding
feature is enabled and PDU fragment count includes the
maximum CTE PDU chained. Fix removes redundant PDU count
included for Extended Advertising. Only Periodic advertising
PDUs chain CTE requires number of additional PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-17 11:22:00 +02:00
Rubin Gerritsen
19547e815b Bluetooth: Increase HCI CMD buffer size when ISO Central is used
When ISO Central is enabled it is allowed to configure many CISes at
once. For this a large command buffer is needed. This is also tested
by HCI/CIS/BI-05-C.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-04-17 10:18:27 +02:00
Kenny Johansson
353e5f2577 net: tcp: Fix IPv6 TCP MSS issue
Fixes #56657, incorrect TCP MSS calculation for IPv6.

Previously the supported MSS would incorrectly returned as the MTU if it
was less than the MTU, probably to account for the case where
the network interface MTU check returns 0.

New behaviour is to return the supported MSS as MTU minus header length,
using default MTU for this calculation if network interface MTU check
returns 0.

Signed-off-by: Kenny Johansson <wirehell@gmail.com>
2023-04-17 10:17:09 +02:00
Krzysztof Kopyściński
0d5c33b045 Bluetooth: Mesh: Fix recovery of WAITING_FOR_START BLOB Server state
If device running BLOB Server called `bt_mesh_blob_srv_recv`,
but rebooted before it received `XFER_START` message from BLOB Client,
it was wrongly "recovered" into Suspended phase, which would lead to
Server try to resume transfer on `XFER_START`. It would not be possible,
because `srv->state.xfer` was not set with acual values yet.

Set phase again to BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START, which will
allow to accept new transfer.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-17 10:15:56 +02:00
Stine Åkredalen
938c59c063 ztest: mock: fix failed test printed message.
Corrected printed message on failing test with expected or received
NULL pointer in ztest_check_expected_data.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-04-14 12:39:52 -04:00
Erik Brockhoff
3cb42157c4 Bluetooth: controller: removing (invalid) ASSERT on invalid PDU
A case of an invalid PDU was seen leading to a hit on this ASSERT, ie
this COULD happen. Refactoring of the state handling re. expectedness
in remote vs local request machines combined with ensuring the local
request machine ceases to expect PDUs when remote procedure 'takes over'

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-04-14 14:03:55 +02:00
Vinayak Kariappa Chettimada
2579690be7 Bluetooth: Controller: Fix connection update window offset data type
Fix regression in refactored LLCP using uint16_t instead of
uint32_t in storing the win_offset_us value. This caused
connection update to fail with incorrect window offset being
used to schedule the connection radio events.

Regression since commit e1c2c36f56 ("Bluetooth: controller:
llcp: set refactored as default").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-14 12:57:00 +02:00
Gerard Marull-Paretas
a86ad87d84 shell: add missing blank line after declaration
Fix checkpatch compliance issue by adding a blank line after
declaration.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
404b2ba474 shell: signal is a reserved identifier use sig instead.
Rule 21.2 "A reserved identifier or macro name shall not be declared"

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
b2d442ee87 shell: fix MISRA 5.7 violations on struct tm
s/struct tm *tm/struct tm *t/ to fix MISRA 5.7 rule violation
(uniqueness of tag identifiers).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Kumar Gala
c7c8ea6a45 logging: Fix build issues with arm-clang
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Fixes #56630
Fixes #56628

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-14 06:04:11 -04:00
Keith Packard
0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Andrei Emeltchenko
37575def5f mgmt: Fix comparing usigned < 0
Fix type from size_t to ssize_t.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-04-13 11:05:47 -04:00
Kumar Gala
d3b3a4f293 bluetooth: audio: Only build code if BT_CONN is enabled
The audio code utilizes BT_CONN so ensure its only built if
CONFIG_BT_CONN is set.  This is to fix a build issue we see
with arm-clang for:

sample.bluetooth.broadcast_audio_source

which fails to link since bt_conn_get_info is missing.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-13 16:13:52 +02:00
Vinayak Kariappa Chettimada
6551630c2c Bluetooth: Controller: Fix window offset calculation
Fix window offset calculation which is missing the radio
rx ready delay timing be subtracted because the connection
offset from the start of the radio for scan window to the
end of the ADV_IND PDU includes the radio rx ready delay
timing, where as the determined window offset by advanced
scheduling calculates the offset from the ticks_at_expire
of the scan window to an active central connection's
ticks_at_expire.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
9d5ecd5bc9 Bluetooth: Controller: Use remainder in win_offset_us calculation
Update Advanced Scheduling implementation to use remainder
value in precisely calculating the connection request window
offset in microseconds.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
205406820f Bluetooth: Controller: Move rx chain delay use into prepare_connect_req
Move the use of rx chain delay value used to calculate the
window offset into lll_scan_prepare_connect_req() instead of
current two places, one for legacy and other for extended
connection setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
d1d58de94c Bluetooth: Controller: Match Central roles for BT_CTLR_CENTRAL_SPACING
Find and match only Central role ticker when applying the
BT_CTLR_CENTRAL_SPACING value.

Use the EVENT_TICKER_RES_MARGIN_US value as +/- jitter
margin when ticker advanced scheduling is used to group
radio events.

When using CONFIG_BT_CTLR_CENTRAL_SPACING, do not add the
+/- jitter to the ticks_slot.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Nirosharn Amarasinghe
11ce28f8f7 Bluetooth: controller: Consideration for SDU interval in fragmentation
Included consideration for the packet sequence number and time stamps
together with the SDU interval in matching the event for fragmentation
of SDUs to unframed PDUs.

Implemented:
-- Increase in kconfig limit of BT_CTLR_ISO_TX_BUFFERS to allow full 32
   buffers to be available for LL/CIS/PER/BV-39C
-- ISO-AL microsecond time wrapping exposed to be used externally to
   adjust incoming Group Reference Points and Time-stamps where required
-- Function that handles adjustment of payload number according to
   incoming SDU exposed for external use to allow next payload number to
   be accessed by ISO transmit tests
-- Changed internal fragmentation source identification parameter from
   the source structure pointer to the source handle so that only the
   source handle needs to be used for external calls

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-04-13 16:09:39 +02:00
Maurits Fassaert
6bfb663167 shell: backends: add SHELL_BACKEND_RTT_BUFFER option
This new configuration option, SHELL_BACKEND_RTT_BUFFER, allows selecting
an alternative buffer for the Shell's RTT backend. By default buffer 0 is
used, which conflicts with the default logging subsystem RTT backend
buffer.
This option is the counterpart to the logger's LOG_BACKEND_RTT_BUFFER.

Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
2023-04-13 11:43:28 +02:00
Pavel Vasilyev
8dd24bf9c3 Bluetooth: Mesh: Restore PRB state after reboot
Add missing code for restoring Private Beacon state after reboot.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Pavel Vasilyev
95d6e66ec3 Bluetooth: Mesh: Don't process PRB when mesh-1.1 disabled
Private Beacons are mesh-1.1 feature and without mesh-1.1 spec enabled,
the node shall not process such beacons.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Pavel Vasilyev
c36fdf251f Bluetooth: Mesh: Allow sending SNB and PRB in parallel
Private Beacons and Secure Network Beacons are not mutually exclusive by
spec. This means both beacons can be sent simultaneously. For both
beacons spec defines their own observation intervals and related
parameters, which means we need to monitor both beacons types
separately.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Kumar Gala
0686476310 bluetooth: Fix compiler warning with arm-clang
Since we enable -fshort-enums for arm-clang we get the following
warning:

subsys/bluetooth/mesh/pb_adv.c:139:40: warning: cast to smaller
integer type 'enum prov_bearer_link_status' from
 'void *' [-Wvoid-pointer-to-enum-cast]

Fix this by first casting to an int to grow the size of the type.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-12 16:03:11 -04:00
Jiapeng Li
2568ab661d canbus: isotp: fix single frame state machine stuck issue
it is too late to set ctx->state to ISOTP_TX_WAIT_FIN after send_sf
because send_state_machine could be called just between `send_sf` and
`ctx->state = ISOTP_TX_WAIT_FIN;`  in extremely case. like below:
```c
	ret = send_sf(ctx);
	-> send_state_machine (irq handler)
	ctx->state = ISOTP_TX_WAIT_FIN;
```
it will cause isotp_send never return.

Signed-off-by: Jiapeng Li <mail@jiapeng.me>
2023-04-12 17:45:04 +02:00
Seppo Takalo
1dd9d514f1 net: lwm2m: Move utility functions from engine
Some utility functions belong to lwm2m_util.c.
Block contexts belong to lwm2m_message_handling.c

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-12 17:44:37 +02:00
Fredrik Danebjer
7e416c8ec0 Bluetooth: audio: csis: Fix Big Endianness for RSI generation
This changes so that generation of RSI now uses LE arrays instead of
uint32 words. Both input and output of rsi and sih genration now uses
LE. This also fixes the generation of RSI for BE systems, which
wasn't working.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2023-04-12 17:44:29 +02:00
Gerard Marull-Paretas
cb067800b4 ztest: mock: fix UNNECESSARY_INT compliance issue
Fix checkpatch issue: UNNECESSARY_INT: Prefer 'unsigned long' over
'unsigned long int' as the int is unnecessary

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 16:42:29 +02:00
Gerard Marull-Paretas
4863c5f05b sys/util: extend usage of DIV_ROUND_UP
Many areas of Zephyr divide and round up without using the DIV_ROUND_UP
macro. Make use of it, so that we make use of a tested system macro and
at the same time we make code more readable.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 16:42:29 +02:00
Gerard Marull-Paretas
a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Jiapeng Li
9d47a3f6d9 mgmt: mcumgr: grp: fs_mgmt: set .upload flag in file_access_data
minor fix, set .upload true if uploading

Signed-off-by: Jiapeng Li <mail@jiapeng.me>
2023-04-12 14:25:14 +02:00
Vinayak Kariappa Chettimada
51a7de2beb Bluetooth: Controller: Fix BIG handle when operation cancelled by Host
Fix the BIG handle in the HCI LE BIG Sync Established event
when BIG Create Sync operation is cancelled by Host.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-12 13:10:39 +02:00
Mariusz Skamra
13341a3e7e Bluetooth: audio: ascs: Fix missing ISO state check
This fixes missing ISO connection state check, as there might be no ISO
connection when Receiver Stop Ready has been received. This might happen
on ASE state transition from Enabling to Disabling.
Without this check the code asserts in ascs_disconnect_stream_work_handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-12 13:05:20 +02:00
Aleksandr Khromykh
4b5be77531 Bluetooth: Mesh: check buffer tailroom before relaying proxy message
PR adds checking proxy buffer tailroom before adding
a relayed message. That prevents potential proxy trash attacks.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-12 13:04:56 +02:00
Anders Storrø
fc49ad3ac6 Bluetooth: Mesh: Shell: Align parameter docs
Aligns Bluetooth mesh shell parameter documentation to use the
same syntax, abbrevations and formating.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-04-12 13:04:42 +02:00
Anders Storrø
1026ec5b38 Bluetooth: Mesh: Shell: Change pub cmd period arg
Changes the implementation and documentation in config client shell
command for Config Model Publication Set and Config Model Publication
Virtual Address Set to accept period resolution and period steps as
separate arguments to make it more user friendly.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-04-12 13:04:42 +02:00
Robert Lubos
afaf4cddd2 net: sockets: tls: Implement handshake timeout
Currently, the handshake operation could only be fully blocking or
non-blocking. This did not play well if SO_RCVTIMEO was set for DTLS
server, as the recv() call where the blocking handshake was used, could
block indefinitely, ignoring the timeout parameter. Fix this, by
allowing for the handshake operation to timeout.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
9082d4b98e net: sockets: tls: Implement TLS/DTLS socket TX/RX timeout
As the underlying socket operations for TLS/DTLS are now non-blocking,
it's no longer possible to rely on the underlying socket timeout
handling. Instead, implement SO_RCVTIMEO/SO_SNDTIMEO at the TLS socket
layer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
81be0f6d73 net: sockets: tls: Switch DTLS to use non-blocking socket operations
As for TLS, switch to use non-blocking operations on underlying socket.
This is a bit tricker for DTLS, as there were not truly blocking bio
(binary input/output) function for DTLS, as timeout had to been
implemented. It is possible though to implement non-blocking mbedTLS bio
function instead, and handle timeout outside of mbedTLS context, which
has been done in this commit.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
ee48ddc205 net: sockets: tls: Switch TLS to use non-blocking socket operations
Switch TLS sockets to use non-blocking socket operations underneath.
This allows to implement the socket blocking outside of the mbedTLS
context (using poll()), and therefore release the mutex for the time the
underlying socket is waiting for data. In result, it's now possible to
do blocking TLS RX/TX operations simultaneously from separate threads.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
96e14ba91f net: sockets: tls: Implement ZFD_IOCTL_SET_LOCK handling
Implement ZFD_IOCTL_SET_LOCK so that TLS socket layer gets access to the
mutex protecting socket calls.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Théo Battrel
b48a69023a Bluetooth: Logging: Make BT_LOG and BT_LOG_LEGACY hidden symbols
Make `BT_LOG` and `BT_LOG_LEGACY` hidden Kconfig symbols.

They should not be used by the user to configure the Bluetooth logging
system. If the user want to completely disable Bluetooth logging, they
should use `BT_LOG_LEVEL_OFF=y`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-04-12 10:23:04 +02:00
Krzysztof Kopyściński
1993c5facd Bluetooth: Mesh: Link Close without success should fail NPPI procedure
When we receive `RPR_OP_LINK_CLOSE` message with reason other than
`SUCCESS` we should fail NPPI refresh procedure, not complete it.
Dropping `COMPLETE` flag will result in calling `reprovision_fail`
in `prov_link_closed`, not `reprovision_complete`.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-12 10:22:27 +02:00
Luca Fancellu
e25d484b6f net: ip: Kconfig for TCP packet allocation timeout
TCP packet allocation timeout is currently 100ms, but there are cases
where it is not enough and as a side effect, the kernel internals are
printing some errors on the log before retrying again, create a
Kconfig parameter to be able to tune this value.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-04-12 10:22:12 +02:00
Johan Hedberg
a6e5755da8 Bluetooth: Fix clearing sent_cmd pointer when allocating event buffer
We should clear the bt_dev.sent_cmd pointer after using it to allocate a
new HCI event buffer in the bt_buf_get_cmd_complete() function.
Otherwise, there is a risk of reusing the same stored net_buf for
multiple consecutive HCI events in case the controller sents duplicate
or invalid event packets.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-04-11 16:57:37 +02:00
Gerard Marull-Paretas
0ebe14beb4 sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +02:00
Emil Gydesen
d2d3c49f39 Bluetooth: Audio: Shell: BAP scan delegator term sync cmd
Added command to terminate the PA sync as the scan delegator.
This can also be used to cancel any pending PA syncs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
65bbc3673e Bluetooth: Audio: Add bis_sync_req scan delegator callback
Add callback to notify the application about which
BIS it should sync to when requested by the Broadcast
Asssitant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
56d0947c92 Bluetooth: Audio: Add broadsink sink create
Add support to create a broadcast sink from a PA sync, rather
than using the broadcast sink scan functions.

This allows for the scan delegator implementation to
autonoumsly add broadcast sinks.

This refactors how the broadcast sink uses flags, to
ensure thread safetyness.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
7b9ddc24c0 Bluetooth: Audio: Integrate scan deletagor and broadcast sink
This integrates the Scan Delegator functionality with the
Broadcast Sink functionality. The Broadcast Sink will
automatically update the receive state for the PA and BIG
sync values, based on state of the Broadcast Sink.

Similarly, a request to terminate the BIG or PA sync from
a Broadcast Assistant will terminate the Broadcast Sinks'
PA or BIG syncs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
df490ea222 Bluetooth: Audio: Add Scan Delegator receive state iterate functions
Add bt_bap_scan_delegator_foreach_state and
bt_bap_scan_delegator_find_state to support finding
specific receive states.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
fe75a41134 Bluetooth: Audio: Remove enc_state from scan_delegator_set_bis_sync_state
The field is added/modified by bt_bap_scan_delegator_add_src
and bt_bap_scan_delegator_mod_src. This makes it easier
to modify the BIG sync state, without worrying about
the encryption state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
76002eb025 Bluetooth: Audio: Add cmd_bap_scan_delegator_rem_src
Add the cmd_bap_scan_delegator_rem_src to remove
receive state sources locally as the Scan Delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
43dd0f884e Bluetooth: Audio: Add cmd_bap_scan_delegator_mod_src
Add cmd_bap_scan_delegator_mod_src to modify a BASS
receive state source as the scan delegator in the
shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
d35c5540c3 Bluetooth: Audio: Add cmd_bap_scan_delegator_add_src
Add command for the scan delegator to add a source
locally based on a PA sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
60da9747c8 Bluetooth: Audio: Scan delegator mod source added
Add function for the scan delegator to modify the metadata
of a receive state locally.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
0005b85e16 Bluetooth: Audio: Fix issue with subgroup metadata for scan delegator
The scan delegator attempted to put the subgroup pointer into the
metadata data, instead of the metadata.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
315aa4dcd8 Bluetooth: Audio: Add BASS server sync test case
Add a test case that tests the scan delegator and
broadcast assistant features when the scan delegator
syncs to a PA without being asked to by the
broadcast assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
f0668550b8 Bluetooth: Audio: Fix bug in bis_syncs_unique_or_no_pref
The check did not work when aggregated_bis_syncs
was 0. Also modfied the function to be more readable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
781e6fc691 Bluetooth: Audio: Support local add_source for scan delegator
Add support for adding a source from the scan delegator itself.
This is useful if e.g. the broadcast sink syncs to a PA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
c1836e80da Bluetooth: Audio: Fix issue with bt_bap_scan_delegator_remove_source
The bt_bap_scan_delegator_remove_source failed due to invalid length,
as the buffer supplied to scan_delegator_rem_src should not
contain the opcode.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
42f1868189 Bluetooth: Audio: Move requested_bis_sync from recv_state to internal
The requested_bis_sync value is not part of the BASS receive
state. Moving the field makes it possible to use the
recv_state struct in more situations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
32cfcb9257 Bluetooth: Audio: Add scan delegator broadcast code callback
Add a callback that is called when the broadcast
assistant supplies a broadcast code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
b37985a898 Bluetooth: Audio: Remove PA sync handling from scan_delegator
The scan delegator will no longer be responsible for
handling the actual synchronization of the periodic
advertisers, and will offload this to higher layers.

The reason for this, is that scanning is a global state,
and should be avoided autonousmly by the stack. The
application is much better suited for handling this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
b99d989420 Bluetooth: Audio: Add receive_state_updated for scan delegator
Add the receive_state_updated callback for the scan delegator.
This callback will be called whenever a receive state is updated
by any means, giving the upper layers the option to always know
the latest changes.

This commit also refactors the name used for the internal
receive state (which contains additional information), for
the sake of readability.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
3348ed76be Bluetooth: Audio: Remove autonomous BIS sync from scan delegator
The Scan delegator will rely on upper layers calling
bt_bap_scan_delegator_set_bis_sync_state instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
ab1fd85c9e Bluetooth: Audio: Refactor scan delegator set sync state
The bt_bap_scan_delegator_set_sync_state has been refactored
to bt_bap_scan_delegator_set_bis_sync_state, as it will,
going forward, only be used to set the BIS sync states,
and not the PA sync state. The PA sync state will, in a future
commit, but autonousmly handled by the scan delegator
based on the PA sync callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
93045467b4 Bluetooth: Audio: Remove testing guard for scan delegator set sync state
The set sync state will be used for upper layers to set the BIS
sync state. This is due to the fact that the scan delegator cannot
automatically get this information from the ISO layer, unlike
the PA sync state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
e275e0f713 Bluetooth: Audio: Make scan delegator recv state const in API
Since the data is informative only, the struct should be
const.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
6bbda2cbfd Bluetooth: Audio: Add Scan Delegator dependency for Broadcast Sink
Per the BAP specification, if the Broadcast Sink role is
supported, then the Scan Delegator shall also be supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Yuval Peress
dbb470ea7a rtio: Add a managed memory pool for reads
- Introduce a new Kconfig to enable mempool in RTIO
- Introduce a new RTIO_DEFINE_WITH_MEMPOOL to allocate an RTIO context
  with an associated memory pool.
- Add a new sqe read function rtio_sqe_read_with_pool() for memory pool
  enabled RTIO contexts
- Allow IODevs to allocate only the memory they need via rtio_sqe_rx_buf()
- Allow the consumer to get the allocated buffer via
  rtio_cqe_get_mempool_buffer()
- Consumers need to release the buffer via rtio_release_buffer() when
  processing is complete.

Signed-off-by: Yuval Peress <peress@google.com>
2023-04-10 18:34:43 -04:00
Yuval Peress
80d70b4e96 rtio: Add cqe per each sqe in transaction
Update the policy such that every completed sqe has a parallel cqe.
This has the primary purpose of making any reads in the sqe visible
to the consumer (since they might have different buffers).

Signed-off-by: Yuval Peress <peress@google.com>
2023-04-10 18:34:43 -04:00
Kumar Gala
c09e8fae23 twister: Use pyelf to extract symbol information
For ztest twister would parse the symbol information that was
generated as part of the build (zephyr.symbols).  However the format
of the zephyr.symbols files is highly dependant on the toolchain.

Move to using pyelf to parse the symbol information directly from
zephyr.elf instead so that this works regardless of toolchain.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 18:37:52 +02:00
Marcin Niestroj
850ed72214 Bluetooth: logging: don't imply LOG_FUNC_NAME_PREFIX_*
By default there is only CONFIG_LOG_FUNC_NAME_PREFIX_DBG=y enabled. When
both Bluetooth (CONFIG_BT=y) and logging (CONFIG_LOG=y) subsystems are
enabled, then other CONFIG_LOG_FUNC_NAME_PREFIX_{INF,WRN,ERR}=y options are
pulled in as well using an 'imply' Kconfig command indirectly from
`CONFIG_BT_LOG`. This behavior was introduced recently as part of
commit af01a0f313 ("Bluetooth: Logging: Move all logging symbols
together") with no explicit reason provided.

Pulling in LOG_FUNC_NAME_PREFIX_* options automatically with (CONFIG_BT=y
&& CONFIG_LOG=y) blows up flash usage. As an example of downstream project
(nRF52840-based, with Bluetooth and WiFi connectivity), it increases flash
usage from 473668 bytes to 487856 bytes. This seems "only" 3% difference,
but this is actually a lot when there is no good reason why this happens.
Downstream users quite often compare flash sizes of subsequent Zephyr
releases and this 3% footprint increase might be a blocker at some point.
Additionally, it is not trivial to find the root cause of footprint
increase for most (non-expert) users.

The reason why there is so much footprint overhead because of
CONFIG_LOG_FUNC_NAME_PREFIX_*=y is because each function in the
codebase (be it Zephyr or downstream application) that contains logging
macros (LOG_{DBG,INF,WRN,ERR}()) is bloated because the function name has
to be included in the output image.

Remove 'imply LOG_FUNC_NAME_PREFIX_*' commands from 'menuconfig BT_LOG'
option, so that flash usage does not increase too much. Those logging
options are not enabled by other subsystems, so Bluetooth should not be an
exception here.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-04-08 12:34:07 +02:00
Kumar Gala
5c4d184016 emul: Use STRUCT_SECTION macros for emul devices
Clean up emulator code to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 12:33:54 +02:00
Pavel Vasilyev
0d7c7eb4c9 Bluetooth: Mesh: Remove incorrect opcode check in RPR Client
RPR Client doesn't send RPR_OP_LINK_REPORT and therefore it can't wait
for it using ack ctx. It should have been RPR_OP_PDU_OUTBOUND_REPORT
to cover a case where Outbound PDU transmission failed. But in this case
the link status will be non equal to BT_MESH_RPR_SUCCESS (see pb_error in
rpr_srv.c) and the link state will be set to idle. And the client will
reset the link together with ack ctx.

When bearer user (provisioner.c) sends an Outbound PDU, it uses the
callback (see bt_mesh_prov_send in provisioner.c) to send a next PDU,
but it doesn't check the error code even though it is provided through
the callback. Therefore calling the callback with error code would
require error handling in provisioner.c.

With ordinary provisioning PB-ADV doesn't call the callback in case of
error, but closes the link by timeout if doesn't receive ACK (see
prov_send_adv in pb_adv.c). PB-GATT always calls the callback with
error code 0 once the PDU is transmitted (see buf_send in pb_gatt.c).

Thus this change aligns RPR Client implementation with other bearers.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-07 13:38:36 +02:00
Szymon Janc
a7eee34339 Bluetooth: Host: Fix legacy OOB pairing as central
When central is sending SMP Pairing Request is it unknown if
pairing will be legacy or LE SC so set OOB flag if any OOB
data is present and assume to peer device provides OOB data
that will match pairing type.

This was affecting following qualification test cases:
SM/CEN/OOB/BI-01-C
SM/CEN/OOB/BV-01-C
SM/CEN/OOB/BV-03-C
SM/CEN/OOB/BV-09-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-04-07 13:36:41 +02:00
Krishna T
1e6e20f667 net: wifi: Log failure reason for AP mode
In case AP mode is not supported log the failure reason clearly.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-04-07 13:35:28 +02:00
Siddharth Chandrasekaran
cd116b22b5 mgmt/osdp: Clear secure channel base key from stack
Secure Channel Base Key (SCBK) is a secret key used to derive the session
keys used to encrypt and decrypt OSDP packets. Secure coding practice
requires us to clear such sensitive data from stack once we are done
needing it. This patch addresses this issue.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
814433d433 mgmt/osdp: Make sure we decrypt atleast one block
OSDP secure channel message blocks are terminated with a 0x80. This means
that even for zero length messages, we would have at least one block of
encrypted data to decrypt (since message blocks are rounded up to the next
16 byte boundary). The current length assertion checks for 16 byte
alignment but a malicious peer could send a specially crafted packet with
zero length blocks. Fix this issue by adding check for length == 0 case.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
0effd82b7a mgmt/osdp: discard secure channel if KEYSET is ACKed in plaintext
HID readers are responding to a KEYSET command with an ACK in plaintext
instead of using the current session keys to acknowledge this command
(which is the reasonable thing to do as the command itself was received
encrypted with the old key). Since the spec doesn't say anything about
this, both methods are technically correct.

Make changes to CP so it allows ACKs in plaintext for KEYSET command in
particular and make the PD implementation do this too as it makes the code
look cleaner there (perhaps HID did it for the same reasons :D).

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
a1edd3e74d mgmt/osdp: phy: Allow non-conformant, 0 length, encrypted data blocks
If command or reply has no data, PD "should" use secure message types
SCS_15 or SCS_16. But some PD seem to not implement this correctly. We
will be tolerant towards those faulty implementations.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
1648e86f4b mgmt/osdp: Rework secure channel key management
OSDP command KEYSET is used to set the secure channel base key for all
connected PDs. This key is then used to derive the session keys for each
secure channel session. When the app wants to set the this key, it has
to issue a command and then both the CP/PD has to be notified of this
change so they can store this key in a non-volatile medium for future
operations across power cycles.

The current implementation of OSDP had limited support for key
management. This patch adds all the bells and whistles needed to handle
keyset command/event in the CP/PD application.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
431cac80f4 mgmt/osdp: sc: Restructure loop to avoid a bunch of -1s
Hoisting a `length--` helps simplify a lot of code which has ad-hoc -1s
in a  bunch of places. Also, fix some formatting issues and remove
unnecessary log lines.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Wojciech Slenska
df98af0c23 shell: backends: telnet: init structure before first function call
Struct sh_telnet should be initialised before first function call.

Right now there is a possibility that telnet_accept function will
be called before memset.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-04-07 13:24:32 +02:00
Dawid Niedzwiecki
4ef47888ef ec_host_cmd: add UART backend
Add a new backend for Host Commands that uses UART. The backend bases
asynchronous UART API.

The UART backend is mainly used by FPMCU.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-07 13:05:59 +02:00
Dawid Niedzwiecki
7490adcd2a ec_host_cmd: update Kconfig help message
The help messages for max request/response SHI sizes were adjusted only
for NPCX, update it.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-07 13:05:59 +02:00
Emil Gydesen
3d3e692190 Bluetooth: Audio: Add missing null checks in mpl
There were a missing NULL check for the track segment in
paused_state_command_handler when performing the segment
operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
695f85e29d Bluetooth: Audio: Add MCC verification of read object IDs
Add check to verify that the object IDs we receive from
the server are valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9c129c5bc7 Bluetooth: Audio: MCC memset discover params for included
The discovery parameters may contain values from previous
discovery calls. The simply and future proof solution to
this is to simply memset it before using it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
b7c2629a6f Bluetooth: Audio: Add value_handle check to MCC subscribe cb
If the subscribed callback is called with value_handle = 0,
then it should not be treated as a subscription complete.

This will happen when bt_mcc_discover_mcs is called, as
reset_mcs_inst unsubscribed to all characteristics before
discovering again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9e823184e2 Bluetooth: Audio: Add value check for bt_mcc_set_playing_order
Add check for the (playing) order value, to verify that is it
a valid value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9ebad924ac Bluetooth: Audio: Add input validation for bt_mcc_send_search
Add validation of the search pointer and len value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
e7770a6a7e Bluetooth: Audio: Add BT_MCS_VALID_OP
Add the BT_MCS_VALID_OP macro to verify MCS opcodes for
both the MCC and MCS implementations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
32cd16cfac Bluetooth: Audio: Add BT_MCS_VALID_OBJ_ID
Add macro BT_MCS_VALID_OBJ_ID to verify the OTS Object
ID before attempting any OTS operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
67acec1d6f Bluetooth: Services: Add macro for verifying OTS object ID
Add BT_OTS_VALID_OBJ_ID which verifies if an object ID
is valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Seppo Takalo
1c6a853528 net: lwm2m: Default lifetime is also a minimum accepted lifetime
If server or bootstrap writes a lifetime value less than
configured default lifetime, client will automatically overwrite
the value with default one.

This gives better control for the application where client
behaviour is fine tuned on the Kconfig, but default values
from bootstrap server cannot be fine-tuned.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:15:04 -05:00
William MARTIN
e121ea28d9 canbus: isotp: Allow to override ISOTP_FIXED_ADDR_* constants
This patch allow to use isotp use_fixed_addr feature
with CAN identifier which not match SAE J1939 format.


Signed-off-by: William MARTIN <william.martin@power-lan.com>
2023-04-06 19:43:02 +02:00
TOKITA Hiroshi
47f14d6375 fb: cfb_shell: support area inverting
Extend the invert command to run cfb_invert_area when given four arguments.
Make a change to invert the screen immediately in case of run invert
without arguments.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
e2c946536e fb: cfb_shell: Add draw text command
Add the `draw text` command to execute the `cfb_draw_text()` API.

The command is similar to the `print` command. The difference is
`draw text` can render to coordinate that is not on tile boundaries.
The command is not run `cfb_framebuffer_clear()`,
So it allows rendering appendiceal with keeping already drawn image.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
7068587505 fb: cfb: support inverting with coordinates that do not align with the tile
Improve `cfb_invert_area()` able to invert even at a coordinate
not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
5634691d8c fb: cfb: Add cfb_draw_text() API
Add cfb_draw_text() API for rendering text.
It is similar to cfb_print(), the difference is cfb_draw_text() accepts
coordinate that is not on tile boundaries and don't wrap the line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
ca5de12503 fb: cfb: support drawing to any coordinates
Implements dot-by-dot font rendering to make cfb_print() able to
draw text even at a coordinate that is not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
b4965d672b fb: cfb: add const modifier for argument of cfb_print
cfb_print does not modify either address and contents of
the pointer that is pointing drawing text.
Thus, it can add a const modifier.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
6663b558fa fb: cfb: Restore inverted framebuffer to make able to reuse
cfb_framebuffer_finalize() invert the framebuffer, and it still
leave as inverted after executing the function.

It restores the framebuffer at the end of the cfb_framebuffer_finalize()
for the continued drawing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
Dölker Kim
3e5cca196c fb: cfb: fix cfb_framebuffer_clear() implementation
dev and clear_display parameter are unused and only
the framebuffer was cleared. A condition which calls
cfb_framebuffer_fanalize when clear_display is
true is implemented. Then not only the buffer,
but  buffer and display are cleared.

Signed-off-by: Dölker Kim <KDoelker@baumer.com>
2023-04-06 18:52:21 +02:00
Emil Gydesen
4bb8b2523f Bluetooth: shell: Guard adv_opt with CONFIG_BT_BROADCASTER
The advertising options are only valid if we are a
GAP broadcaster.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-06 15:37:30 +02:00
Seppo Takalo
3a241592b5 net: lwm2m: Remove lwm2m_path_to_string
This function had only one use in SenML CBOR formatter and it
contained some specific tweaks, so move the function to be a
static member of that module.

Fixes #53674

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 15:37:21 +02:00
Vinayak Kariappa Chettimada
8c3c33a970 Bluetooth: Controller: Fix compile error due to missing DF include
Fix compile error due to missing Direction Finding header
file include.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-06 12:57:20 +00:00
Tomasz Moń
59f33a6019 shell: uart: Fix wait for DTR before TX
Fail compilation when incorrect configuration is detected, i.e. when
SHELL_BACKEND_SERIAL_CHECK_DTR is set but UART_LINE_CTRL is not set.

Use periodic timer to wait for DTR instead of waiting in uart callback
to prevent blocking caller workqueue and/or sleeping in ISR.

DTR check was only ever supported with interrupt driven backend so add
appropriate depends on to Kconfig.

Fixes: e9f238889b ("shell: uart: Add waiting on DTR signal before
sending data")
Fixes: #47120
Fixes: #54705

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-04-06 14:21:57 +02:00
Seppo Takalo
567b2510b8 net: lwm2m: Allow stopping while paused
When LwM2M engine is paused, stop functionality just
marks the intent and when we resume, it will send the
de-registration if that was requested.
Otherwise it will stay in SUSPENDED state until resumed
and then goes into ENGINE_DEREGISTERED -> IDLE.

This also removes the blocking loop from lwm2m_rd_client_stop().
It does not need to block because lwm2m_rd_client_start()
is already checking if client is in IDLE.

Fixes #56254

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:21:49 +02:00
Kumar Gala
804af856f8 bluetooth: Fix linking issues with armclang
Various bluetooth tests fails to link because bt_le_ext_adv_set_data
can't be resolved.  Solve this by adding a check CONFIG_BT_EXT_ADV
around use of bt_le_ext_adv_set_data.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-05 19:32:34 +02:00
Robert Lubos
162c0f64c2 tests: net: websocket: Fix test execution on 64-bit platforms
Instead of passing the test parameters to the websocket function, by
casting the pointer to integer (which may not work on 64-bit platform
due to int/pointer size mismatch), let the test allocate a file
descriptor, and initialize it with test context. The tested functions
expect a file descriptor as an argument anyway, so it's a more intuitive
approach.

The conditional test code within WS implementation can retrieve the test
context by using FD APIs to obtain the object represented by the FD.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-05 15:01:50 +02:00
Kamil Kasperczyk
6fe83ea810 logging: Changed log template to consider default log level
Added using LOG_DEFAULT_LEVEL kconfig option in log module
template for assigning the default log level to newly created
module instance, instead of assuming always INFO level.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2023-04-05 13:47:06 +02:00
Pieter De Gendt
6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Keith Packard
3f3224d880 subsys/net: Labels cannot be applied to declarations
C only permits labels on statements, not declarations.  Separate the
declarations from the assignments so that the labels can target
statements instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-05 10:38:34 +02:00
Anas Nashif
ef1a589f61 ztest: add macro for custom testcase result
Some cases, especially those dealing with faults need to inject output
manually, so provied a macro for special case.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Jakub Rzeszutko
336c0ed98f shell: fix assert when bypass mode is set
For the duration of the bypass function shell sets the command context.

Fixes: #51637

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2023-04-05 10:03:11 +02:00
Manuel Arguelles
09dd8c74ae littlefs: translate error code when mount fails
When lfs mount fails and there is no formatting requested, the return
code must be translated to errno before being passed to the application
layer.

Additionally, only log a warning that the FS will be formatted, when the
system is not read-only.

Fixes #56378

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-04-04 18:22:10 +02:00
Pavel Vasilyev
62191ba8fd Bluetooth: Mesh: Add async API to Private Beacon Client
Add asynchronous API to Private Beacon Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-04 14:32:57 +02:00
Pavel Vasilyev
3a2dc591d4 Bluetooth: Mesh: Use bt_mesh_msg_ackd_send API in Private Beacon Cli
Replace duplicate code in Private Beacon client with
bt_mesh_msg_ackd_send API.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-04 14:32:57 +02:00
Emil Gydesen
856a20bcc6 Bluetooth: Add missing dependency for PAST feature
The PAST sender needs to support periodic advertising
and the PAST receiver needs to support periodic advertising
sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 14:31:17 +02:00
Emil Gydesen
f3af19618b Bluetooth: BAP: Shell: Add check for uuid sizes
The check is very unlikely to be needed, but fixing
warning about assigning ARRAY_SIZE to an uint8_t value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 14:30:34 +02:00
Kumar Gala
762b109179 shell: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 13:47:14 +02:00
Hein Wessels
8735d0f653 logging: support custom timestamp formatting
This feature adds support for using a custom function to format
the timestamp used for all logging backends. When the kconfig
option LOG_OUTPUT_FORMAT_CUSTOM_TIMESTAMP is set the custom
formatting function will always be used.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-04-04 13:41:17 +02:00
Emil Gydesen
6dface9947 Bluetooth: Audio: Add select BT_GATT_DYNAMIC_DB for audio services
Many/most LE Audio services are dynamically registered,
but have been enabled without BT_GATT_DYNAMIC_DB.

Add select BT_GATT_DYNAMIC_DB for the services. Select
was used instead of depends on to make it simpler
to enable them.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 13:36:26 +02:00
Mariusz Skamra
05540b2c4d Bluetooth: audio: iso: Remove code duplicates
This removes duplicated code related to bap iso binding/unbinding.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:36:17 +02:00
Mariusz Skamra
9cddbabc6f Bluetooth: audio: endpoint: Remove redundant conditional
This fixes redundant check, as CONFIG_BT_BAP_UNICAST_CLIENT
enables CONFIG_BT_BAP_UNICAST.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:36:08 +02:00
Mariusz Skamra
92d6b78fe6 Bluetooth: audio: Introduce helper BT_AUDIO_RX(TX) flags
This adds new hidden compilation flags that indicate whether the
implementation is configured to be able to receive/transmit audio data.
The flags are profile agnostic to loosen dependencies between
modules/services.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:35:56 +02:00
Jamie McCrae
e00cf28001 mgmt: mcumgr: grp: fs_mgmt: Improve upload and download performance
This vastly increases the performance of file transfers using the
fs_mgmt group over MCUmgr by allowing the file handle to remain open
between commands instead of having to open, feek, read/write then
close the file handle for each invocation.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-04 11:51:43 +02:00
Victor Chavez
649570ebc4 logging: Fixed BLE backend when used alone
There was a bug in the BLE backend when it was the only enabled
backend. Instead of using the API `log_backend_activate` to
activate the backend, the logger requires the first time to be
enabled with `log_backend_enable`.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-04-04 08:53:25 +00:00
Radoslaw Koppel
61ce27a12e ipc: ipc_service: Remove the race condition from bonding
This commit removes the possible race condition when notifying
the bonding request.
When the race condition appears there is possibility that
one of the cores would never send notification for bonding.
This change makes it sure that the notification would be sent
at least once.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2023-04-04 10:30:47 +02:00
Victor Chavez
a18aa915ce logging: Added BLE Backend Service
Added a new logger backend to recieve data over a BLE
notification characteristic.
The characteristic is based on the UUID from the Nordic connect SDK
service NUS, which allows to have a UART shell over BLE.
The idea behind this, is that this logger can be used directly
with the NRF apps or any other BLE UART terminal app.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-04-03 15:17:57 +02:00
Emil Obalski
5143db540c ipc: Fix icmsg deregister functionality
This change fixes the deregister functionality for
icmsg backend. There are two changes:

Memory access layer was not initialized properly
when the endpoint was registered again. This lead to
memory fault when attepmt to write to the buffer was
done.

Mbox driver was initialized before memory access layer
was initialized. This could lead to race condition
where immediately after the mbox driver was initialized,
the receiving work is scheduled due to pending interrupt.
In that case an attempt to read from garbage address will
occur.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-03 11:29:08 +02:00
Tom Burdick
a539d9c904 rtio: Add transceive op
Adds the transceive op which is needed for full SPI support. Notably
in RTIO transceive is expected to be a balanced buffer pair of the same
length and have non-null tx/rx bufs.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Tom Burdick
912e7ff863 rtio: Add callback op
Adds a callback op to RTIO enabling C logic to be interspersed with
I/O operations. This is not safe from userspace but allowable in kernel
space.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Tom Burdick
bb72809326 rtio: Add tiny write op
When sending small buffers out it makes sense to copy rather than
reference to avoid having to keep the small buffer around for the
lifetime of the write request.

Adjusts the op numbers to always be +1 from the previously defined op
id making it easier to re-arrange if needed in the future.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Daniel Leung
8dda1fe154 pm: mark pm_device_runtime_auto_enable as boot function
When demand paging is enabled, only a minimal set of functions
are available at boot. Anything not marked as boot functions
would not be loading in memory at boot which would result in
page faults when jumping to those functions. However, at early
boot, demand paging has not been enabled yet. So we need to
mark necessary functions as boot functions so they are placed
in the correct linker section where they are loaded at boot.

Fixes #56414

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-31 14:31:52 -04:00
Théo Battrel
ff10a9cf23 Bluetooth: Host: Remove unnecessary guarding
Remove unnecessary guarding. With `BT_DEBUG` removed, those conditions
were not needed anymore.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-31 14:01:33 +02:00
Kumar Gala
b9a63b805e lwm2m: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 14:01:24 +02:00
Szymon Czapracki
33bf1fa0c6 Bluetooth: audio: Expand AICS API
This commit adds new API functions for AICS
Setting automatic/manual only gain modes
Setting mute disabled
Use new functions in btp.vcp

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-03-31 09:20:15 +02:00
Kumar Gala
b4d4e30e9b bluetooth: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 09:19:16 +02:00
Kumar Gala
19b6b1fb30 dns: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 09:19:09 +02:00
Tom Burdick
f09685e1ac shell: Provide runtime power management toggling
Adds a device pm_toggle shell command which calls pm_runtime_device
functions put and get to toggle the runtime power state.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-30 17:33:22 -04:00
Mariusz Skamra
fc54859645 Bluetooth: audio: ascs: Handle ascs_ase_read with NULL conn
If the callback is called with NULL conn, just return ASE Idle state
value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-30 13:48:22 +02:00
Mariusz Skamra
f38c2633e7 Bluetooth: ascs: Remove redundant ase_id check
The ASE_ID is assigned locally via preprocessor macro, thus it's ensured
to be valid.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-30 13:48:22 +02:00
Emil Gydesen
630f6a7d82 Bluetooth: BAP: Store biginfo data in broadcast_sink->codec_qos
Store information from the biginfo in a
broadcast_sink->codec_qos struct, and add a reference to that struct
when syncing, so that the stream->qos contains a valid struct
with properly initialized information.

This also adds a guard for the codec_qos.latency as that
is not set nor used by the broadcast sink (as it is
not available).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-30 10:40:13 +00:00
Emil Gydesen
114e45eb2a Bluetooth: BAP: Broadcast Sink BASE contains presentation delay
The presentation delay is now properly stored in
the BASE struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-30 10:40:13 +00:00
Théo Battrel
9b8b58c70b Bluetooth: Logging: Remove BT_DEBUG
Remove Kconfig symbol `BT_DEBUG`. It was not useful anymore with the
previous logging updates.

Replace it, where it was used, by the file local debug symbol.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-30 10:40:01 +00:00
Jordan Yates
db3d51bb7d pm: device_runtime: add zephyr,pm-device-runtime-auto
Add the `zephyr,pm-device-runtime-auto` flag to `pm.yaml` and
`struct pm_device`.

This flag is intended to signify to the boot system that device runtime
PM should be automatically enabled on the device after the init function
has run.

Only run `pm_device_runtime_auto_enable` function on a device if
initialisation succeeded. This prevents actions being run on devices
that are not ready.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-29 12:21:13 -04:00
Szymon Janc
ee48754af3 bluetooth: host: Fix checking if LTK is present
conn->le.keys are set on-demand when actual security action happens and
it is possible that permission check needs to happen before those.

This fix regression in following qualification test cases:
GAP/SEC/AUT/BV-23-C
L2CAP/LE/CFC/BV-25-C
L2CAP/ECFC/BV-32-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-29 15:54:47 +00:00
Szymon Czapracki
6fd7b3bac6 bluetooth: audio: Fix TBS call stale state
This commits fixes a call staying in dialing state
after originate.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-03-29 15:52:32 +00:00
Manuel Arguelles
884e6b98f4 debug: arm64: add FPU context offset in thread info
When FPU is enabled for Arm64, the saved_fp_context must be tracked by
thread info to visualize correctly the FPU context of threads.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-03-29 09:28:57 -04:00
Dominik Ermel
fcef8bb781 mgmt/mcumgr/img_mgmt: Fix upgrade accepting equal version
As name suggest upgrade only should allow image upgrades onlu, but due
to greater or eqal sign used in version comparison, upgrade actually
also accepted current version.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-29 11:31:19 +02:00
Jamie McCrae
0cf14d5ae9 mgmt: mcumgr: transport: shell: Add optional input expiration
Adds an optional feature that can be used to time out a partially
received MCUmgr packet over the shell interface. Prior to this
change, if a header was received, then the whole shell would be
unavailable until the module is rebooted or additional full MCUmgr
packet was sent.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-29 11:30:55 +02:00
Jordan Yates
c6191858c3 pm: device_runtime: PM unsupported is not an error
Returning an error code when PM is not supported for a device only makes
writing drivers harder, as instead of checking for failures with `< 0`,
they also need to check for `-ENOTSUP`.

From the point of view of a driver, an `-ENOTSUP` return value is
equivalent to success, as if the device it is trying to turn on doesn't
support PM, by definition it is already enabled. This is equivalent to
the API behaviour when `CONFIG_PM_DEVICE_RUNTIME=n`.

Whether a device supports PM or not can still be determined at runtime
by inspecting the return code of `pm_device_runtime_enable` if
necessary.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-28 17:36:32 -04:00
Jordan Yates
2ef95ecd8f pm: device_runtime: balanced power domain operations
Only run `pm_device_runtime_put` on the dependent domain if the original
claim operation succeeded. This fixes unbalanced operations when running
```
pm_device_runtime_get(dev);
pm_device_runtime_put(dev);
```
On a device that does not have PM enabled but does have a power domain.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-28 17:36:16 -04:00
Szymon Janc
8fe734c7ac bluetooth: host: Add common helper for checking LTK presence
Both L2CAP and GATT have same requirements with regards to error code
on no encryption when LTK is or isn't present.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-28 16:15:58 +00:00
Szymon Janc
dc1ca29ca0 Bluetooth: host: Fix ATT error code on GATT authentication procedure
“Insufficient Encryption” shall be returned only if link is not
encrypted and proper LTK is present, otherwise “Insufficient
Authentication” shall be used.

Core Specification 5.4 Vol. 3 Part C 10.3.1

"If neither an LTK nor an STK is available, the service
request shall be rejected with the error code
“Insufficient Authentication”.
Note: When the link is not encrypted, the error code
“Insufficient Authentication” does not indicate that
MITM protection is required.
If an LTK or an STK is available and encryption is
required (LE security mode 1) but encryption is not
enabled, the service request shall be rejected with
the error code “Insufficient Encryption”."

This was affecting GAP/SEC/AUT/BV-11-C qualification test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-28 16:15:58 +00:00
Mariusz Skamra
6ba2839f6f Bluetooth: audio: ascs: Unbind endpoint in idle state
This moves duplicated bt_bap_iso_unbind_ep function call to
be handled when ASE enters BT_BAP_EP_STATE_IDLE state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
4d1f9973ed Bluetooth: audio: ascs: Fix double bt_bap_stream_detach call
This fixes possible double bt_bap_stream_detach() function call.
The bt_bap_stream_detach() called from ascs_ep_set_state
state BT_BAP_EP_STATE_IDLE handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
a6cdb12572 Bluetooth: audio: bap_stream: Remove reference to conn internals
This removes the usage of conn internal API in bap_stream.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
1abee09a8b Bluetooth: audio: Fix declaring conn type object in header file
The fact of having such extern in iso_internal.h forces the source files
that include this header to include conn_internal.h. This breaks the
encapsulation of conn object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
43d8e92bdd Bluetooth: audio: ascs: Fix ISO server listen incorrect behavior
This fixes incorrect behavior of ISO server listen that was not handling
the case of two endpoints sharing the same CIS/CIG and the endpoints
belonging to different connections.

Fixes: #51552
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
58de595c70 Bluetooth: audio: ascs: Register ISO server on ASCS init
This moves the ISO server registration to bt_ascs_init.
When the ASCS gets cleaned up (the callbacks are unregistered), the ISO
server gets unregistered.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
08aedc66dd Bluetooth: audio: ascs: Make use of SYS_SLIST_FOR_EACH_CONTAINER_* macros
This cleans up the code a bit by replacing the occurences of
SYS_SLIST_FOR_EACH_NODE with SYS_SLIST_FOR_EACH_CONTAINER(_SAFE)
so that the explicit CONTAINER_OF() usage is not needed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
710103db1d Bluetooth: iso: Add bt_iso_server_unregister function
This adds function that unregisters previously registered ISO server.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
f5b31c21a9 Bluetooth: audio: ascs: Fix Response_Code for mandatory opcodes
This fixes invalid Unsupported Opcode Response_Code that
happened to be sent in ASE Control Point notification
as the response to operation initiated with Mandatory opcode
to support.
When the Unicast Server callbacks are not registered, every
operation that is initiated by client will fail with
Unspecified Error instead.

Fixes: #56139
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
e9a878c072 Bluetooth: audio: ascs: Fix ASE leak if codec config failed
This fixes ASE that is not returned to pool when Codec Config
operation failed. The ASE is allocated in Codec Config operation
context. With this fix, if the operation failed to complete,
the ASE is returned back to the pool, so that it can be allocated
again by this or other client.

Fixes: #56138
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
5909a00a00 Bluetooth: audio: ascs: Minor refactor of ASE allocation
This removes redundant bt_ascs_ase_get_from_slab function and moves it's
functionality to ase_new(). It's sane, because the ASE shall be
allocated from ase_new() function context only.
bt_ascs_ase_return_to_slab() has been renamed to ase_free() to follow
the naming convention. Furthermore, few logs have been fixed/added.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
ee754fd020 Bluetooth: audio: ascs: Remove redundant check
The ID is ensured to be valid before ase_new() function is called, as
the client request is already validated.
On the other hand, if function is called from server initiated procedure
context, the assert shall occur as it indicates stack issue.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
31aa555890 Bluetooth: audio: ascs: Cleanup ASCS on callback unregister
This adds cleanup of ASCS that is called when upper layer unregisters
it's callbacks. Without callbacks registered, the service is unusable.
The ASE's that were in non-idle state stay in this state, because the
implementation returns an error on every operation that is performed by
the client. The cleanup added moves all the ASE's to idle state.

Fixes: #56111
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Krzysztof Kopyściński
3322bdce10 Bluetooth: Mesh: fix blob_cli.c build with Clang
There should be logic OR, not bitwise OR in update_missing_chunks.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-28 15:06:44 +02:00
Krzysztof Kopyściński
fc2dcc4665 Bluetooth: Mesh: save stream mode in io_open()
Mode affects access to flash aread for `block_start`. When mode is set
to `BT_MESH_BLOB_READ` function return early, and because
`BT_MESH_BLOB_READ = 0` this is default behaviour. For write flash area
must be erased to allow driver to write there new data - bits can only
be pulled down, so overwrite will not be permitted.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-28 15:06:44 +02:00
Andreas Chmielewski
357181be23 net: lwm2m: Add is_suspended() routine
Add is_suspended() routine to have control over the rd client from the
outside whether it is suspended.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-03-28 15:06:15 +02:00
Théo Battrel
9c69f29d0d Bluetooth: Logging: Deprecate BT_DEBUG_LOG
Deprecate Kconfig symbol `BT_DEBUG_LOG`. With the new `BT_LOG` having
the same effect, `BT_DEBUG_LOG` is not useful anymore and shouldn't be
used.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-28 10:33:24 +02:00
Théo Battrel
af01a0f313 Bluetooth: Logging: Move all logging symbols together
Move all Kconfig symbols related to Bluetooth logging into the newly
created `Kconfig.logging`. The logging symbols are now grouped by into a
menu "Bluetooth logging". Closely related symbols are grouped with each
others. For example, audio related logging symbol are found behind a
submenu "Audio" inside the "Bluetooth logging".

The deprecated logging symbols have also been moved in a submenu of
"Bluetooth logging", it's easier to avoid them so.

Behavior of the Bluetooth logging system:

When `LOG` symbol is selected, if Bluetooth is enabled (`BT` symbol
selected), the Bluetooth logging is enabled.

If the user does not set any log level, the Bluetooth logging symbols
will inherit the log level of `BT_LOG_LEVEL`. If the user does not set
the level of `BT_LOG_LEVEL`, the default log level will be the one
defined by the logging subsystem. Which currently is `LOG_LEVEL_INF`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-28 10:33:24 +02:00
Alexander Svensen
674e23820f sd: Return ret if error in sdmmc_spi_read_cxd
- Check OCR when sending CMD58, reject if 0

Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
2023-03-28 09:23:47 +02:00
Aleksandr Khromykh
9011a067f2 Bluetooth: Mesh: split rpr cli ack ctx for provisionning and scanning
PR adds 2 acknowledgment contexts to RPR client to handle
scanning and provisioning in parallel.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-03-27 13:20:33 +00:00
Chris St John
1c0ade0051 Bluetooth: Audio: fix possible overflow in BASE LTV decode
Consistently process BIS data, codec data and codec metadata.
Range check count of data received so that buffer overflow cannot occur.

Signed-off-by: Chris St John <chris_st._john@bose.com>
2023-03-27 09:49:58 +02:00
Daniel Nejezchleb
6898094111 net: shell: Fix shell freeze
Adds clean up after failed ping from shell,
so it does not freeze the output.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-03-25 07:49:18 -04:00
Chris Friedt
ff2efd7ae5 net: socket: socketpair: remove experimental status
Socketpair functionality has matured enough to be used in a
consistent way now regardless of architecture or platform,
even on `native_posix`.

Remove the experimental status to reflect that.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-25 07:05:53 -04:00
Vinayak Kariappa Chettimada
ae5b424a2b Bluetooth: Host: Fix handling of incomplete data status adv reports
When receiving extended advertising reports with incomplete
data status, it is not necessary to mark for recovering from
currently assembled fragments, but rather drop them and
start a fresh assembly of subsequently received extended
advertising reports.

Timing changes in the Controller cause Periodic Advertising
PDUs AUX_SYNC_IND + AUX_CHAIN_IND to be placed between
primary channel ADV_EXT_IND and AUX_ADV_IND. This causes the
Controller to generate alternating incomplete and complete
data status reports, exposing the Host bug that is fixed in
this commit.

Relates to commit ba09a252ec ("bluetooth: host: refactor
bt_hci_le_per_adv_report data reassembly").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 17:36:32 +00:00
Emil Gydesen
dd5e476f86 Bluetooth: Audio: Shell: Add CAP Acceptor Set Member AD data
Add automatic adding of the CAP Acceptor Set Member AD data.

This also moves the CAP Acceptor service data into the
cap_acceptor.c shell implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-24 17:35:11 +00:00
Fabio Baltieri
5b36b4fa16 input: add a longpress device
Add an input device to take input key events as an input and generates
short press or long press devices as output.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-24 13:48:28 +00:00
Vinayak Kariappa Chettimada
b161c7fca4 Bluetooth: Controller: Fix ticker to reduce RTC min compare offset
Fix ticker to explicitly trigger worker when ticks_to_expire
is less than or equal to elapsed time.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 12:10:37 +01:00
Vinayak Kariappa Chettimada
925066ae1f Bluetooth: Controller: Continuous scan with ticks_slot_window
Use ticks_slot_window for continuous scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 11:32:42 +01:00
Vinayak Kariappa Chettimada
852b3e9e17 Bluetooth: Controller: Reschedule unreserved ticker with slot window
Update ticker implementation to reschedule unreserved ticker
that use ticks_slot_window.

This will avoid unreserved ticker from continuously
overlapping with reserved tickers. And the change is
required to reduce processing overheads before reserve
ticker timeout callback executes.

Unreserved tickers with ticks_slot_window will always yield
to any colliding reserved or unreserved tickers.

The implementation moves unreserved tickers (no ticks_slot
value, in this case continuous scan window) to end of a
colliding reserved/unreserved ticker so that reserved
tickers (like central role) do not have high overheads due
to unreserved ticker's prepare (scanner) be preempted
everytime before reserved ticker's prepare (central).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 11:32:42 +01:00
Emil Gydesen
b7e265265d Bluetooth: BAP: Do not allow start op when CIS is connecting
When the CIS is connecting we should not allow sending the
receiver start ready command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-24 09:17:07 +01:00
Anders Storrø
09a32928aa Bluetooth: Mesh: RPR cli @ mod elem 0 check
Add check to the Remote Provisioning Client model init call
that verifies that the model is located at the root element.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-03-23 15:43:29 +01:00
Johann Fischer
ad81b3b797 drivers: udc: move transfer status to buffer info structure
This allows us to get the result of synchronous transfer without
any hacks, just from the net_buf structure.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-03-23 10:08:03 +01:00
Emil Gydesen
6fc8ca7863 Bluetooth: iso: Add misisng bt_conn_unref in error cases
The ISO hci_le_cis_req event handler was missing
calls to bt_conn_unref and bt_iso_cleanup_acl to properly
clearn up the reference counters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Emil Gydesen
7ec4a6a19e Bluetooth: host: df: Add missing bt_conn_unref in error cases
Added missing bt_conn_unref where bt_conn_lookup_handle is
called, but where the function returns without providing the
conn pointer to the caller.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Emil Gydesen
317bd5af30 Bluetooth: Host: Missing unref for PAST sync_info
When we supply the conn pointer of the remote device that
provides the PAST information, we do a lookup on the
conn_handle using bt_conn_lookup_handle which takes a
reference count. This count is never dereferenced again.

This commit adds calls to bt_conn_unref to ensure that we
do not keep the reference count after the function
returns.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Jonathan Rico
c84fdfe438 Bluetooth: controller: fix kconfig dependency
BT_TICKER_EXT is being selected undiscriminately, but it's a Zephyr
controller feature.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-22 21:20:22 +01:00
Franciszek Zdobylak
3ff1e97367 fs: Fix Kconfig formatting
- use tabs instead of spaces in indentation
- use 2 spaces instead of tab in help message

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-03-22 13:52:07 +01:00
Szymon Janc
1ebb49eeee bluetooth: ascs: Fix NULL pointer dereference in ascs_ase_read
"The (ATT attribute read) callback can also be used locally to
read the contents of the attribute in which case no connection
will be set."

This means that callback may be called with NULL conn. Since
for ascs_ase_read NULL conn object have no meaning just return
error.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-22 13:51:58 +01:00
Mariusz Skamra
b8d441842a Bluetooth: audio: ascs: Add cleanup function
This adds ascs_cleanup() function guarded by ZTEST_UNITTEST. The purpose
of it is to clean up the ASCS between the tests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-22 11:39:18 +01:00
Omkar Kulkarni
a5057e96d1 bluetooth: mesh: Do not skip PDU forwarding on ADV
Fixes a bug where goto statement results into network layer skipping
the forwarding of unicast message on the ADV bearer, if the message
gets succesfully sent on the GATT bearer. This is undesirable. Node
has no knowledge of which external entity has which unicast address.
It may be possible that Proxy node can deliberately add unicast
addresses of other nodes to the whitelist to receive some traffic
for sniffing.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2023-03-22 11:38:51 +01:00
Magdalena Kasenberg
57784df5f0 LE Audio: Refactor server ASE callbacks to return rsp object
From now app layer is able to return explicit response code and
reason that will appear in ASE Control Point notification.

Fixes issues of ASCS/SR/SPE/BI-(07/08/09)-C PTS test cases, where
PTS was receiving wrong response codes and reasons.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-03-22 11:38:37 +01:00
Troels Nilsson
714d74b77b Bluetooth: controller: Use new ticker feature to get offsets
Updated the 3 places in extended advertising where the ticker was
previously inquired about the expiration of another ticker ID in a
separate mayfly (adv_aux, adv_sync and adv_iso). It will now use the
new ticker feature where another ticker IDs expiration info will be
added to the callback.

Channel map updates are now handled in ticker_cb and applied immediately
if the ticker is not running

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-03-22 08:57:37 +00:00
Troels Nilsson
e990ab941d Bluetooth: controller: Add option for ticker to return expiration info
It is now possible (via the extended ticker interface) to ask for
expiration information for another ticker ID to be returned in the
ticker callback. This utilises the extended ticker interface and a
callback function with a different context to keep the current ticker
interface as unchanged as possible.

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-03-22 08:57:37 +00:00
Pavel Vasilyev
08f4a82038 Bluetooth: Mesh: Remove deprecated health API
Deprecated Health client and server API has been deprecated for two
releases: 3.2.0 and 3.3.0.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-22 09:35:01 +01:00
Ahmed Moheb
fac21b3616 tests: bluetooth: host: Add UT for bt_pub_key_gen()
Unit test project for bt_pub_key_gen().
This is part of subsys/bluetooth/host/ecc.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Ahmed Moheb
3c76bd06e4 tests: bluetooth: host: Add mocks for ecc.c
Add required mocks to be able to compile/test /bluetooth/host/ecc.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Théo Battrel
483126f492 Bluetooth: Host: Move new bt_data functions to data.c
Move newly added `bt_data_get_len` and `bt_data_serialize` from `ead.c`
to `data.c`.

Also, removed unnecessary include of `zephyr/kernel.h`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-21 18:17:52 +00:00
Robert Lubos
dc8f023098 net: ipv6: Fix Kconfig dependencies when native IPv6 is disabled
In case native IPv6 is disabled, Kconfig entries related to native IPv6
stack should not be enabled. Otherwise, circular dependencies can be
created if native stack is disabled, as in case of recent changes in
NET_IPV6_RA_RDNSS option (where a dependency for a native stack module
was enabled).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-21 18:11:06 +00:00
Théo Battrel
a693b9b33b Bluetooth: Host: Add Encrypted Advertising Data
Create a new Bluetooth library and add Encrypted Advertising Data to it.

Encrypted Advertising Data is a new feature from the Bluetooth Core
Specification 5.4. It provides a way to communicate encrypted data in
advertising, scan response and EIR packets. To do that it introduce a
new advertising data type called `Encrypted Advertising Data`. Also, it
introduce a new characteristic called `Encrypted Data Key Material`,
this provides a way to share the key material.

The library add two main functions `bt_ead_encrypt` and
`bt_ead_decrypt`.

Two helper functions are added to `bluetooth.h`. `bt_data_get_len` and
`bt_data_serialize`, the first one allow the user to get the total size
of a set of `bt_data` structures; the second one generate a spec
compliant bytes array from a `bt_data` structure. The last one is useful
because `bt_ead_encrypt` take as input those kind of bytes array.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-21 13:39:09 +02:00
Vinayak Kariappa Chettimada
643723479f drivers: flash: nRF: Move sync ticker to Subsys Bluetooth Controller
Move the SoC Flash nRF sync ticker implementation into
Bluetooth Controller Subsystem folder, as internal headers
are included.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-21 12:33:32 +01:00
Vinayak Kariappa Chettimada
b9f9f1ba9c Bluetooth: Controller: Refactor CMakelists.txt for consistency
Refactor the Bluetooth Controller's CMakelists.txt to
consistently use zephyr_library_sources_ifdef() and
zephyr_library_include_directories_ifdef().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-21 12:33:32 +01:00
Mariusz Skamra
fef4c4e7ea Bluetooth: audio: ascs: Fix ASE release from QoS configured
This fixes ASE release from QoS configured state.
The `ops->released` callback was not called and the `bt_ascs_ase`
was not returned to the pool, because `stream` object was already
detached.

Fixes: #55900
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:38:16 +01:00
Mariusz Skamra
1ece7a6779 Bluetooth: audio_ ascs: Fix possible dereference of free'd ASE
This fixes possible dereference of free'd bt_ascs_ase object.
The ASE without ISO connection that goes to Releasing state will be
automously transitioned to Idle state. Thus, the `ase` object might not
be vaild anymore.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:38:16 +01:00
Mariusz Skamra
14bd189f00 Bluetooth: ascs: Fix ASE Codec Config PDU length validation
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.

ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
 length operation if the total length of all parameters written by the
 client is not equal to the total length of all fixed parameters plus
 the length of any variable length parameters for that operation"

Fixes: #55747
Fixes: #55748
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:37:40 +01:00
Joel Guittet
b6df4ec388 hawkbit: check mcuboot header version
Checking mcuboot header version prior to use the content of the header
structure.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2023-03-21 09:35:26 +01:00
Joel Guittet
a3d7fdafd6 hawkbit: fix memory issue with mcuboot_img_header size
Fix a memory issue when calling boot_read_bank_header the length should be
the size of `struct mcuboot_img_header`.
Fixes #54459.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2023-03-21 09:35:26 +01:00
Emil Gydesen
c97fa8fda3 Bluetooth: Audio: CAP initiator streamline procedure states
Add new helper functions to increase readability and to
ensure correctness when aborting procedures.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
3186fce98e Bluetooth: Audio: Shell: Use same streams and group for BAP and CAP
Use the same unicast streams and group for the BAP and CAP
shell commands. This results in maximum flexibility, as well
as the niceness of use from CAP, as well as less memory usage.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
3ab925ecef Bluetooth: Audio: CAP Initiator handle unexpected ASE changes
When performing the CAP Unicast Start procedure, the remote
server(s) may change the state of the ASE before the procedure
is complete.

If the state change is unexpected, we stop the procedure and
call the callback, and then the caller can decide what to
do after that (presumably call the stop procedure for the
streams that may be setup).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
90537df38a Bluetooth: Audio: Add CAP unicast stop shell command
Add shell command for the CAP unicast stop procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
9ce647ba79 Bluetooth: Audio: Implement CAP unicast stop procedure
Implements the CAP unicast stop procedures, which is used
to stop (either disable or release) multiple streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
67925d397a Bluetooth: Audio: Add CAP unicast update shell command
Add shell command for the CAP unicast update procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
f7f69b6ff0 Bluetooth: Audio: Implement CAP unicast metadata update
Implement the CAP unicast metadata update procedure.

The procedure lets an application update the metadata of one
or more CAP streams in a single function call, while also ensuring
that the provided metadata follows the requirement from CAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
6866cd30e8 Bluetooth: Audio: Add support for CAP unicast start in shell
This modifies the audio.c shell module to support
multiple connections.

This adds support for the cap_initiator unicast-start command,
which supports multiple endpoints on multiple devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
b71f9f2702 Bluetooth: Audio: Implement CAP unicast audio start
Implement the CAP unicast start procedure, which
will put one or more CAP streams from the idle state
to the streaming state, across or more ACL connections.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Fabio Baltieri
9889e8e20a input: move the listener section in common-rom
Move the input listener section declaration in common-rom-misc.ld
instead of using a custom input.ld file. This seems to be the common
practice for upstream iterable sections and seems to solve a
compatibility issue where the section was getting allocated incorrectly
on esp32 based platforms.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-20 12:56:18 -07:00
Krzysztof Chruscinski
369ffb4929 hal_nordic: Add protection against resource conflict (take 2)
Commit will be squeezed once agreement is reached.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Krzysztof Chruscinski
5af49c1e35 hal_nordic: Add protection against resource conflict
Add check in CMake files to prevent resource overlap for
TIMER0, TIMER1, RTC0.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Krzysztof Chruscinski
9a73b9c80d hal_nordic: Change scheme for RTC and TIMER reservation
In general, RTC and TIMER driver implements counter API but there
are exception when those peripherals are used in a custom way
(e.g. for system timer or bluetooth). In that case, system must
prevent using counter based on a reserved instance. Previously,
it was managed by Kconfig options but that cannot be maintained
when switching to devicetree configuration of the counter driver.

A new approach removes Kconfig options and instead adds static
asserts in the files which are using direct peripherals. Those
asserts check if given node is not enabled in the device tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Robert Lubos
66ae9153a6 net: sockets: Fix SO_SNDTIMEO handling
The TX timeout configured with SO_SNDTIMEO on a socket did not work
properly. If the timeout was set on a socket, the TX would work as if
the socket was put into non-blocking mode. This commit fixes this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Robert Lubos
616797c429 net: sockets: Add helper function for recalculating remaining timeout
The timeout recalculation logic was duplicated across several routines,
therefore it makes sense to make a helper function out of it,
especially, that the same functionality would be needed for the send
routines.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Robert Lubos
e67374e47a net: tcp: Rework TCP SO_RCVBUF/SO_SNDBUF option handling
SO_RCVBUF option processing at the TCP level was broken. The option
value was only checked once, when the TCP context was allocated. This
made little sense, as at this point the option would not even get a
chance to have custom value. If the user modified the option after the
socket (net_context) was created, it had no effect on the TCP operation.

This commit fixes this, by checking the option value whenever new packet
is processed, so that the configured window size is updated at the TCP
level before we report it in the TCP ACK. In order to achieve this,
introduce a new helper function, to refresh the configured window sizes,
to avoid bloating `tcp_in()` even further.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Sebastian Panceac
2e7c02bef6 Bluetooth: pairing: OOB: Separate LE SC OOB from legacy OOB logic
Some systems can support only legacy OOB pairing while others only
LE SC OOB pairing.

The existent API function "bt_set_oob_data_flag" was removed.

Two new API functions were added:

 * "bt_le_oob_set_legacy_flag" to signal that legacy OOB pairing is used
 * "bt_le_oob_set_sc_flag" to signal that LE SC OOB pairing is used

The code will now advertise the presence of OOB flag depending
on the type of pairing method(SC vs legacy)

Signed-off-by: Sebastian Panceac <sebastian.panceac@ext.grandcentrix.net>
2023-03-20 16:13:18 +01:00
Krzysztof Kopyściński
8194c34669 Bluetooth: Mesh: allow user to define BLOB ID for bt_mesh_dfu_cli_send
User can now use self-defined BLOB ID for transfer instead of using
random one each time. This allows to send multiple FW Update Start
messages with same BLOB ID, for example to resume previous one.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Krzysztof Kopyściński
b0e91368a2 Bluetooth: Mesh: fix FW Update procedure recovery on on DFU Server side
If device rebooted while in `BT_MESH_DFU_PHASE_TRANSFER_ACTIVE` phase
we should not recover into it, but set `BT_MESH_DFU_PHASE_TRANSFER_ERR`
instead. It's because we no longer remember which block is currently
transfered so new FW Update Start must be received and transfer
restarted.

If device rebooted while in `BT_MESH_DFU_PHASE_VERIFY_OK` it means
we didn't manage to apply image before reboot. We should enter
`BT_MESH_DFU_PHASE_VERIFY_FAIL` phase, which will allow to verify it
again and possibly apply. This is with agreement to specification
regarding receiving FW Update Start when FW is already received.

This commit also alligns handle_start with specification: when
FW is already received, we should set phase to
`BT_MESH_DFU_PHASE_VERIFY`, send Status message, then proceed to Verify.
Previously, `verify` was called before sending status, so status
contained phase set to `BT_MESH_DFU_PHASE_VERIFY_OK` or
`BT_MESH_DFU_PHASE_VERIFY_FAIL`. This would prevent DFU Client
enter refresh procedure.

`blob_recover` also expects BT_MESH_DFU_PHASE_TRANSFER_ERR now.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Krzysztof Kopyściński
51ff3e630b Bluetooth: Mesh: Do not transfer FW to targets in Verify Phase in DFU
These targets already received FW so there is no point to transfering
it again. What's more, these targets will not accept transfer and will
be dropped by DFU Client. If FW is already received DFU Client should
skip transfer and proceed to refresh procedure.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Emil Gydesen
b011c1e36c Bluetooth: BAP: Add missing Unicast client CB NULL check
Add missing check before calling unicast_client_cbs->release.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-20 13:38:33 +01:00
Krishna T
36c46afbb9 net: zperf: Make Zperf worker thread stack size configurable
All stack sizes should be configurable for memory adjustements.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 10:20:00 +00:00
Krishna T
d6e54a417a net: zperf: Make Zperf worker thread priority configurable
This helps us test impact of scheduling on traffic.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 10:20:00 +00:00
Emil Gydesen
c8e1b1e264 Bluetooth: Audio: Move audio shell to audio directory
Move all audio related shell implementations to the
audio directory, to use the same structure as Mesh.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-20 09:53:34 +01:00
Georges Oates_Larsen
3c6b7dc35a net: dummy L2 for offloaded ifaces
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-03-20 09:53:25 +01:00
Krishna T
5e6c733006 net: wifi: Use a macro for TWT wake interval
Remove the magic number 255, esp. now that we support 262.144ms.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Krishna T
65aae9cbfb net: wifi: Use micro seconds for precision for TWT intervals
In order to take granular input use micro seconds as input for TWT
intervals, this helps us in providing inputs such as 65.28ms without the
need of using floating points.

This also expands the TWT wake interval range to 262.144ms, earlier as
we want to use uint8, limited to 256ms.

Also, remove the units from the variable names, this is unnecessary and
also avoids doing breaking changes.

Update release notes as this is a breaking change, both type and
variable names are changed.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Aleksander Wasaznik
20d747815d Bluetooth: Shell: Remove ad-hoc CHAR_SIZE_MAX
Remove ad-hoc `CHAR_SIZE_MAX` in favor of `BT_ATT_MAX_ATTRIBUTE_LEN`.
The maximum size of an attribute is the same as the maximum size of a
characteristic.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-20 09:51:24 +01:00
Aleksander Wasaznik
6b6178be30 Bluetooth: Shell: Make gatt notify more general
Make `gatt notify` take the source handle and the data to send.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-20 09:51:24 +01:00
Dominik Ermel
abb93d4089 fs: Prevent mounting file system re-using private data
The commit changes the fs_mount to not allow mounting same system,
with the same private data pointer, at two different mount paths.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-20 09:51:10 +01:00
Tom Burdick
610d307fa0 rtio: Properly track last sqe in the queue
The pending_sqe logic to track where in the ring queue the concurrent
executor had left off was slightly flawed. It didn't account for starting
all sqes in the queue and ending back up at the beginning.

Instead track the last SQE in the queue, from which the next one in the
queue will the one to start next.

If we happen to sweep the last known SQE in the queue, reset it to NULL
so the next time prepare is called we start at the beginning of the queue
again.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-17 12:49:57 -05:00
Tom Burdick
3353342e5f rtio: Add transactional submissions
Transactional submissions treat a sequence of sqes as a single atomic
submission given to a single iodev and expect as a reply a single
completion.

This is useful for scatter gather like APIs that exist in Zephyr already
for I2C and SPI.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-17 12:49:57 -05:00
Vinayak Kariappa Chettimada
de9579f297 Bluetooth: Controller: Implement CIS abort_cb to flush tx/rx
Implement a custom abort_cb callback to perform Tx and Rx
flush and adjust the SN/NESN values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:07:09 +01:00
Vinayak Kariappa Chettimada
0d54ca8761 Bluetooth: Controller: Fix ull_prepare_dequeue for skipped events
Fix ull_prepare_dequeue to not skip events when preempt
does not match the event in the head of the prepare queue.
The head of the prepare queue does not match when
ull_prepare_dequeue has put the head of the queue to the
last of the queue when it is calling lll_resume interface.
This happens when there is already an active event which
needs a preempt timeout to be setup and there is another
non-resume event in the pipeline which now becomes the
head. The fix ensure to restore the order of the events
if a preempt timeout was to be setup.

Currently ull_prepare_dequeue loops through all events
before stopping at the original way the queue was. This is
not efficient and is a scope for improvement in future.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:06:54 +01:00
Vinayak Kariappa Chettimada
ceaddc81db Bluetooth: Controller: Fix connected ISO time reservation calculation
Fix Connected ISO time reservation that was missing the
event start and end overhead values.
Fix missing event end overhead values in ACL connection
time reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:06:32 +01:00
Morten Priess
00c9580914 Bluetooth: controller: Fix offset for CIG with CISes in different ACLs
Calculate CIS offset of secondary CIS(es) using CIG reference point.
This fixes issue with e.g. two CISes associated with separate ACL
connections.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-03-17 16:06:18 +01:00
Morten Priess
b8c7506681 Bluetooth: controller: Keep CIS/CIG instances until ll_cig_remove
This commit enables having multiple CIS/CIG setups/connects and
teardowns in sequence.

- For central, cig->lll.num_cis is initialized to cis_count and
  untouched until ll_cig_remove. The value shall indicate number of
  allocated instances, to ensure correct CIG traversal.
- Keep CIG/CIS instances for central until ll_cig_remove
- Initialize CIS instance state vars in ll_cis_create, similar to the
  peripheral flow.
- In ll_cig_remove, always release streams and CIG instance. Do not
  remove paths, as this is done from host at bt_iso_chan_disconnected.
- Remove unsued cis_count member in ll_conn_iso_group.
- Use correct function ull_iso_lll_ack_enqueue at LLL flush to have
  data path respected.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-03-17 16:06:18 +01:00
Andries Kruithof
4215854956 Bluetooth: controller: remove refs to LLCP_LEGACY after rebase
Some recent PRs included conditional compilation for
KCONFIG_BT_LL_SW_LLCP_LEGACY, which must be removed.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
e6a3def17b Bluetooth: controller: remove dependency for slot reservation
The slot reservation code is only valid for the refactored LLCP;
a guard was in place to ensure that it was not compiled in for
legacy controller code. This commit removes this guard

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
729c3e3d83 Bluetooth: controller: remove code related to advanced scheduling
This commit removes the code related to advanced scheduling from
ull_sched.c, since this code only works for the legacy controller.
Implementing advanced scheduling for the refactored LLCP is tracked
in its own issue

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
f6172f3159 Blueotooth: controller: removed delayed notification code
The code that was added for delaying notifications to the host,
which was only implemented for legacy controller, is removed
in this commit

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
2ada005d7c Bluetooth: controller: removing legacy LLCP code
This commit removes the legacy LLCP code including the
Kconfig option
It also updates the babblesim tests, and removes the
tests for the legacy controller

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Emil Gydesen
70e4e73998 Bluetooth: BAP: Shell: Fix problems with codec and qos config
The copying from the presets to the stream codec and qos
structs were not done in a way that worked. Fixed by doing
a more proper and deeper copy.

This also fixes a small issue with using the wrong
default preset.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 14:19:42 +01:00
Pavel Vasilyev
cf5ea49d23 Bluetooth: Mesh: Fix registering GATT Proxy service after reboot
After commit 3486f133e9
GATT Proxy service registration is broken because it is registered from
settings_load() in mesh_commit(). Because mesh_commit() is called before
sc_commit() is called in gatt.c, bt_gatt_service_register() can't be
called yet.

Use k_work to postpone the service registration.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-17 14:19:15 +01:00
Andrei Emeltchenko
e5091db1ad bluetooth: audio: Fix using wrong function check
Correct function check before calling it.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-17 14:18:57 +01:00
Emil Gydesen
d0b0bb43d3 Bluetooth: BAP: Remove BT_BAP_UNICAST_CLIENT_PAC_COUNT
The BT_BAP_UNICAST_CLIENT_PAC_COUNT is there due to a merge conflict
gone wrong. Removed again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 14:18:48 +01:00
Vinayak Kariappa Chettimada
1f52e70fe2 Bluetooth: Controller: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values, when computing and comparing
against unsigned variables.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Vinayak Kariappa Chettimada
9b3a3ee79b Bluetooth: Controller: Add additional LE Channel Selection tests
Add additional custom LE Channel Selection #2 tests to cover
event and subevent mapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Vinayak Kariappa Chettimada
c3e6edd402 Bluetooth: Controller: Remove redundant use of local variable
Remove redundant use of local variable chan_idx in the
lll_chan_iso_subevent() function.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Henrik Møller
86757f5ae5 Bluetooth: controller: Fix channel selection
For ISO-subevents channel selection must use remap table always
-regardless of channel is a mapped or unmapped channel.

Signed-off-by: Henrik Møller <heml@demant.com>
2023-03-17 11:48:26 +01:00
Emil Gydesen
64143fc881 Bluetooth: BAP: unicast released callback only after CIS disconnect
Ensure that the stream released callback is only called after
the CIS has disconnected. Since the ACL disconnect event
may come before the CIS disconnect event, we use the
unicast_client_ep_idle_state in the unicast_client_reset
function to use the existing state verification, and only
after both the ACL and CIS has disconnected, we
finalize the reset of the stream and call the released
callback, assuming that the CIS can be disconnected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:31:06 +01:00
Emil Gydesen
bb43c05dc8 Bluetooth: ISO: Set missing CIS disconnecting state
The BT_ISO_STATE_DISCONNECTING was never set when the
CIS was actually in the disconnecting state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:31:06 +01:00
Emil Gydesen
38095f8818 Bluetooth: BAP: Shell: Delete uni group when all streams released
Previously we assumed only a single stream, and deleted
the unicast group on the first stream released.

Now we wait for all the streams to be released before
deleting the group.

This still assumes that all streams are initiated by us
as the client, and will not work if using the
BAP unicast client and server role concurrently.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:58 +01:00
Emil Gydesen
cf737b510e Bluetooth: BAP: Remove bad LOG_ERR from unicast client
Remove a bad LOG_ERR that should never have been merged.

Added the valuet that was logged to the debug log statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:17 +01:00
Emil Gydesen
ed1cc603a7 Bluetooth: BAP: Fix bad ASSERT in ASCS disconn stream handler
The conditions of the assert were incorrect compared to the
text, and caused an assert to happen when it shouldn't.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:09 +01:00
Kumar Gala
831bd2f841 armclang: fix compiler warnings with isprint()
We get compile warnings of the form:

drivers/console/uart_console.c:508:8: error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint returns an int, change check to an explicit test against
the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-17 09:30:01 +01:00
Gregory Shue
5623f54a35 fff: Add fff_extensions.h, RETURN_HANDLED_CONTEXT()
Add supplementary header <zephyr/fff_extensions.h>.  Add macro
to fff_extensions.h for simplifying definition of custom fake functions
needing call-unique information for producing desired output data.
When an array of custom fake context structures is defined and
the return field within the first structure instance is registered
with the standard SET_RETURN_SEQ() macro of FFF, the
RETURN_HANDLED_CONTEXT() macro provides the inverse logic to
recover the context structure for this called instance. The body of
the custom fake handler is provided to the RETURN_HANDLED_CONTEXT()
macro for appropriate execution and access to the custom fake
parameters.

A test suite is also provided to verify macro implementation and
illustrate usage. It is at:
zephyr/tests/subsys/testsuite/fff_fake_contexts/

This code was verified by:

1. (Pass) west build -p always \
            -b unit_testing tests/subsys/testsuite/fff_fake_contexts/ && \
         ./build/testbinary
2. (Pass) west build -p always \
            -b native_posix tests/subsys/testsuite/fff_fake_contexts/ && \
         ./build/zephyr/zephyr.exe
3. (Pass) ./scripts/twister -p unit_testing \
            -T tests/subsys/testsuite/fff_fake_contexts/
4. (Pass) ./scripts/twister -p native_posix \
            -T tests/subsys/testsuite/fff_fake_contexts/
5. (Pass) cd doc && build html-fast

Fix #55246

Signed-off-by: Gregory Shue <gregory.shue@legrand.com>
2023-03-16 13:43:33 -04:00
Pavel Vasilyev
3e14c13d8d Bluetooth: Mesh: Use default provisioning protocol timeout in RPR Client
The timeout used upon opening the link with the server relates to the
PB-Remote Link Open procedure, but not to the whole provisioning
procedure. For the provisioning procedure, the timeout should be at
least 60 seconds as explained in section 5.4.4.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Pavel Vasilyev
e9a20cc3b6 Bluetooth: Mesh: Restart timer after sending PDU to RPR Server
This commit fixes an issue where the RPR Client gets stuck after sending
PDU to RPR Server (even with segmented flag), but doesn't hear anything
back from the server.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Pavel Vasilyev
3a0fa866e4 Bluetooth: Mesh: Fix timeout handling on link opening in RPR Client
This commit fixes an issue, where the RPR Client gets stuck forever
until reboot if it doesn't receive Link Status or Link Report message
when openinig the remote provisioning link.

The RPR_CLI_LINK_OPEN flag was used to control the remote provision link
and protect against receiving an unexpected message, but it didn't cover
a case when neither of messages were received from the RPR Server.
cli->link.state only changes by Link Status or Link Report message and
is set to BT_MESH_RPR_LINK_IDLE when opening the link. Therefore, when
the RPR Client's timer timed out, the client didn't reset its internal
states.

This commit adds an additional state to cover this intermediate state
when the client initiated the link opening but didn't receive any
response.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Tomáš Beneš
14138d4a34 Bluetooth: Controller: Add coexistence implementation
To enable Bluetooth controller coexistence feature, there is
implementation of ticker task, which aborts any ongoing radio events
during assertion of the grant pin. This solves the co-existence issue
in the role of the subordinate transceiver.

Signed-off-by: Tomáš Beneš <tomas@dronetag.cz>
2023-03-16 14:37:55 +01:00
Vinayak Kariappa Chettimada
947ef4c96b Bluetooth: Controller: Remove redundant EVENT_IFS_US in BIS timing
Remove redundant EVENT_IFS_US used in Control PDU timing
calculation. The BIG radio event ends with Control Subevent
and hence there is no need to add EVENT_IFS_US at the end
of the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-16 13:39:03 +01:00
Vinayak Kariappa Chettimada
ca44b34994 Bluetooth: Controller: Fix ISO Sync Receiver reception abort
Fix ISO Sync Receiver PDU reception to enqueue towards ULL
any PDUs that where received before the BIG event in
unreserved timespace is aborted due to overlap with other
radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-16 13:38:48 +01:00
Jonathan Rico
169270e911 Bluetooth: host: downgrade select log messages
In the case of a constrained system that uses dynamic channels (ie, not
much initial credits), the user's log would be flooded with those three
messages.

This is not really an error per se as the stack will handle it properly and
reschedule the sending of the buffers as soon as more credits arrive.

Thus downgrading the severity of
- the l2cap messages, as they are only compiled when dynamic channels are
enabled
- the conn message. Reporting the error belongs in the upper layers.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-16 12:56:48 +01:00
Luca Fancellu
6748d588ab net: zperf: allow TCP receiver to handle multiple connections
Currently the zperf_tcp_receiver can handle only one TCP connection
each time, modify the code to poll and handle multiple connections.

Take the occasion to unify the bind and listen part of the code
between ipv4 and ipv6 part using a structure introduced to handle
the multiple connections.

Now in case the zsock_recv fails, we can't stop every connection
and fail through the error label, so just print the error message
and report the failure through the callback.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-03-16 12:56:10 +01:00
Luca Fancellu
d485ef0231 net: zperf: Reduce the scope of input address variables
Reduce the scope of in4_addr_my and in6_addr_my pointer variables
that are currently global, but they are used only inside
tcp_receiver_thread.

Take the occasion to fix a typo in one error message.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-03-16 12:56:10 +01:00
Emil Gydesen
ac5e4fea90 Bluetooth: Audio: Unicast Client Log more of QoS pref
Add logging of some missing fields of the QoS preference
we receiver from the unicast server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 12:55:50 +01:00
Mariusz Skamra
871db2d277 Bluetooth: Move bt_data_parse to dedicated source file
This moves bt_data_parse function outside of hci_core.c.
Having it in separate file makes unit testing easier as the
function do not use kernel objects, thus can be used in unit tests
without a need for adding any mocks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-16 11:46:36 +01:00
Emil Gydesen
61559bfe3a Bluetooth: Audio: Explicit stream type of unicast client group stream
Make it more explicit that the streams that the value covers are CIS
and not BAP streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 11:46:20 +01:00
Wolfgang Puffitsch
b525db221c Bluetooth: controller: Avoid the use of weak functions for ISO data path
Avoid the use of weak functions and call the respective functions only
if vendor-specific data path is supported. The weak dummy functions
will not implement the desired behavior anyway. This change makes it
explicit that these functions need to be implemented by the vendor.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2023-03-16 11:46:05 +01:00
Emil Gydesen
f7cf252a8c Bluetooth: Audio: Add special handling of release cp notification
When releasing a stream as the unicast client, we may get
either the ASE state notification with state idle or
the control point notification first. If we get the
ASE state notification first, we pretend we get the
CP notification first, and call the release callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
88644a775c Bluetooth: Audio: Shell: Add unicast client operation callbacks
Add the unicast client operation callbacks to the shell, simply
printing the values sent by the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
68fa04788a Bluetooth: Audio: Add unicast client cp notify callbacks
Add callbacks for control point notifications sent by the
unicast server. These will allow the upper layers to know
if and why a specific operation failed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
a2057cde3c Bluetooth: Audio: Fixed naming of invalid length ASCS response
The "Invalid Length" response code was called truncated,
which does not match the spec definition.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Nirosharn Amarasinghe
b1fe487bb1 Bluetooth: controller: Release of padding PDUs for framed production
Implemented:
-- Released framed padding PDUs when data received in SDUs for a given
   event do not fully utilise BN.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-03-16 09:17:19 +01:00
Kumar Gala
0342deb5d9 Bluetooth: Mesh: Fix compiler warning
When building with an LLVM toolchain get the following warning:

bluetooth/mesh/pb_adv.c:774:4: error: expression which evaluates to zero
treated as a null pointer constant of type
'void *' [-Werror,-Wnon-literal-null-conversion]
                        PROV_BEARER_LINK_STATUS_SUCCESS);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by adding a cast to (void *).

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-16 09:15:38 +01:00
Anders Storrø
ce3557a958 Bluetooth: Mesh: Add SAR srv persistence storage
Adds persistent storage for SAR server RX and TX set cmd parameters.
Also ensures that SAR RX and TX parameters are set back to default values
upon reset of the mesh device.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-03-15 15:20:35 +01:00
Andrei Emeltchenko
7e63be14c3 bluetooth: shell: Fix NULL dereference
Fix NULL dereference when dereferencing txing_stream, which was used
instead of default_stream.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-15 15:03:12 +01:00
Jun Qing Zou
aae379f245 net: mqtt: Debug logging of pointers
Cast pointer to `void *` for `%p` parameter.
Otherwise lots of warnings in the log like below:

 `<wrn> cbprintf_package: (unsigned) char * used for %p argument.
 It's recommended to cast it to void * because it may cause
 misbehavior in certain configurations. String:"%s: (%p): >>
 length:0x%08x cur:%p, end:%p" argument:3`

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-03-15 15:02:47 +01:00
Vinayak Kariappa Chettimada
11ad5bf92c Bluetooth: Controller: Inherit BT_ISO_TX_BUF_COUNT value
Inherit BT_ISO_TX_BUF_COUNT value when BT_ISO is enabled
to set BT_CTLR_ISO_TX_BUFFERS count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-15 08:49:42 -04:00
Vinayak Kariappa Chettimada
c22f40a358 Bluetooth: Controller: Fix max PDU len radio config for BIS Ctrl PDUs
Fix missing radio configuration that limits the maximum PDU
len on reception to consider that Control PDU can be larger
than the max PDU size in the BIS parameters.
Use dedicated PDU buffer for transmission and reception of
BIG Control PDUs so that it is independent of maximum ISO
PDU length which can be less than BIG Control PDU length.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-15 08:49:42 -04:00
Mariusz Skamra
0b7a335864 Bluetooth: ascs: Fix uninitialized stream object
This fixes "Conditional jump or move depends on uninitialised value(s)"
error seen in valgrind.
The stream object that is allocated by application has to be initialized
as it may contain invalid data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 11:38:11 +01:00
Mariusz Skamra
b5465825f1 Bluetooth: ascs: Remove duplicated logic
The ase_stream_add does the same job as bt_bap_stream_attach that is
called right below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 11:38:11 +01:00
Ludvig Samuelsen Jordet
53091c5056 Bluetooth: Mesh: Fix confusing DFU slot doc
The word "valid" is already in use to mean slots that return true for
`bt_mesh_dfu_slot_is_valid`, whereas `bt_mesh_dfu_slot_foreach` iterates
over all added slots.

Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
2023-03-15 11:19:18 +01:00
Mariusz Skamra
5862c8263b net: buf: Factor out net_buf_simple to separate source file
This moves net_buf_simple related code to separate source file.
Having those in separate file makes unit testing easier as simple
network buffers do not use kernel objects, thus can be used
in unit tests without a need for adding any mocks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 10:50:16 +01:00
Mariusz Skamra
4a1d0782cb net: buf: Fix using incorrect logging macro
As there is dedicated NET_BUF_SIMPLE_* logging macros set,
NET_BUF_SIMPLE_DBG shall be used in this place instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 10:50:16 +01:00
Emil Gydesen
5704b83ea7 Bluetooth: Audio: Shell: Add location to cmd_config
Add support for setting the location value
(BT_CODEC_CONFIG_LC3_CHAN_ALLOC) in the codec configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
a02a1c19a1 Bluetooth: Audio: Shell: Refactor set_preset
The function is now called get_named_preset and only
returns a named preset. The QoS parameter handling
has been moved to a new function, cmd_stream_qos,
which can be used to set specific QoS for a stream.

The get_named_preset does also no longer set the default
preset, and cmd_preset must be used for that now.

This means that a function like cmd_config no longer
has any side effects, thus making it easier to set up
multiple streams with different presets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
b9a4deb429 Bluetooth: Audio: Shell: Replace hacky metadata handling
The hacky handle_metadata_update that copied the metadata to
a variable, since stream->codec->meta could not be modified,
has been replaced with a proper solution now that
stream->codec->meta can be modified.

It still only supports settings the streaming context, but
it is much easier to expand now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
2638a04214 Bluetooth: Audio: Shell: Make BAP shell presets constant
Make the BAP shell presets constant. This reflects more
what they represent, and make it not only possible, but also
easier, to modify the individual streams QoS and Codec
configurations, without affecting other streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
3588706d1a Bluetooth: Audio: Shell: Rename streams to unicast_streams
The streams array only contained unicast streams, and
the name should reflect that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Jonathan Rico
b23c330c63 Bluetooth: host: shrink bt_l2cap_le_chan size
Most of this struct is bookkeeping for the dynamic channels.
This isn't needed for e.g., a simple peripheral using GATT.

With a peripheral_hr build for nrf52840dk_nrf52840, we save
280 bytes of RAM.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-15 09:11:33 +01:00
Stig Bjørlykke
6862fdea1a net: dns: Check existing DNS servers before reconfigure
In dns_resolve_reconfigure() check if the DNS servers already exist
before cancel all ongoing queries. This will solve an issue with
getaddrinfo() returning DNS_EAI_CANCELED when receiving a retransmitted
DHCP offer and when receiving a IPv6 Router Advertisement.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-03-14 12:27:15 -04:00
Ajay Parida
43bd60a13a net: wifi_mgmt: Send TWT sleep status event to app
Send TWT sleep status(sleep/awake) event to the apps registered
for event.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-14 10:49:30 +01:00
Tomasz Bursztyka
8c89566993 subsys/disk: No need of runtime intialization for disk access part
Mutex and double-linked list can be statically initialized.

This removes a little bit of boot time overhead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-03-13 18:34:40 +00:00
Vibhor Meshram
4684006f1b Bluetooth: Audio: Remove "Input" from MICP naming
Removed "Input" from Microphone Input Control Profile.
Release notes kept unchanged.

Signed-off-by: Vibhor Meshram <vibhor69meshram@gmail.com>
2023-03-13 18:34:09 +00:00
Emil Gydesen
e80eca0239 Bluetooth: Audio: Shell: Add automatic receiver ready for server
When a stream for a sink ASE goes into the enabled
state we automatically execute the receiver start ready
operation as the unicast server.

This makes the shell easier to use as the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-13 14:04:33 +01:00
Aleksander Wasaznik
6648da731b Bluetooth: Host: SMP Keypress Notification
Add experimental support for SMP Keypress Notification.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-13 14:04:25 +01:00
Emil Gydesen
4fbabc14c5 Bluetooth: Audio: Shell: Fix bug with txing_stream and bap send
The bap send command would set txing_stream but the
pointer would never be reset.

The txing_stream is mainly to handling the start_sine,
so only {start|stop}_sine commands now sets this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-13 14:02:41 +01:00
Nicola Ochsenbein
eba73727ee modules: fs: Add reentrant zephyr support
This commit enables zephyr to configure the FatFs FF_FS_REENTRANT
option and support fs actions from multiple threads.
CONFIG_FS_FATFS_REENTRANT enables the option and provides zephyr
mutex wrappers.

Signed-off-by: Nicola Ochsenbein <Nicola.Ochsenbein@husqvarnagroup.com>
2023-03-13 11:58:57 +01:00
Michal Ciesielski
43c08d5c3f lwm2m: Fix multi res inst, create flags and post write callback for SWMGMT
The multi resource and create flags were reversed, meaning that resources
were defined as multi resource but weren't being created by default. That
doesn't reflect the LWM2M Software Management, which specifies which
objects can be multi resource and which are mandatory.

The post write callbacks were assigned to the validate callbacks.

Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
2023-03-13 11:58:29 +01:00
Julien D'Ascenzio
f76bfa5712 nvs: use NVS cache in write and gc functions
NVS cache was used only in read function. This commit add the usage of
NVS cache in write and gc functions.

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2023-03-13 09:21:22 +00:00
Julien Vermillard
a9349fe74d net: lwm2m: Typo in LWM2M_IPSO_TIMER description
Changed description to "IPSO Timer Support" in place of "Light Control
Support"

Signed-off-by: Julien Vermillard <julien@vermillard.com>
2023-03-11 08:46:22 +02:00
Lingao Meng
81847a57ff Bluetooth: Host: Refine assert message
Add opcode information for cmd timeout assert,
since BT_DBG usually not show in real product,
however we can't see any information just from
assert message.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-03-10 11:39:05 +01:00
Andries Kruithof
02eac5cbc2 Bluetooth: controller: fix compile error when VS cmds disabled
When vendor specific commands are disabled by setting
BT_HCI_VS=n the host still calls bt_read_static_addr,
but that function is not compiled in, resulting in a
build error.
Fixed by moving the code in controller/hci/hci.c
outside of the conditional compile

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-10 09:39:23 +01:00
Vidar Lillebø
ca3d0c8ee9 mbedtls: Remove dependency on MBEDTLS_BUILTIN for MBEDTLS_DEBUG
Allows using MBEDTLS_DEBUG functionality when not using MBEDTLS_BUILTIN.

Signed-off-by: Vidar Lillebø <vidar.lillebo@nordicsemi.no>
2023-03-10 09:30:32 +01:00
Erik Brockhoff
1028cab11e Revert "Bluetooth: controller: use RX node piggy-back for NTF when possible"
This reverts commit 6dbc446342.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-10 09:30:23 +01:00
Erik Brockhoff
a40434748c Revert "Bluetooth: controller: fixing CIS establish flow for refactored LLCP"
This reverts commit 1d8acfe5fa.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-10 09:30:23 +01:00
Krzysztof Chruscinski
68955ebdb6 logging: Increase package size limit to 2047
Package length was previously stored on 10 bits which limited
package size to 1023 bytes. Descriptor which contained package
length field had one unused bit which can be used to increase
package length field to 11 bits doubling the maximum package
length.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Krzysztof Chruscinski
a5979dcfa1 logging: Log warning and drop too big message
When packacge exceeds the limitation warning log is printed
and message is dropped.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Krzysztof Chruscinski
24ad096232 logging: Renamed internal defines to get rid of 2 suffix
Some internal macros were still using 2 suffix which comes from
time when there was v1 and v2. Cleaning up by removing the suffix.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Mariusz Skamra
f2d43cf0ac Bluetooth: ascs: Fix missing list initialization
This fixes missing initialization of active ASE list.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-09 17:23:46 +01:00
Pavel Vasilyev
6810e669e1 Bluetooth: Mesh: Reschedule dedicated relay adv sets immediately
Reschedule dedicated relay adv sets immediatey after finishing
advertising of the previous relay message. This allows a node to
relay messages as fast as possible when Relay Retransmit Count state
is zero using less relay adv sets.

When Relay Retransmit Count state is non-zero, the delay doesn't do
anything as the time between pushing a relay message to the host and
triggering adv_sent callback will be greater than this delay. In this
case the relay adv set will send a next message immediately.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-09 17:21:39 +01:00
Andrei Emeltchenko
c574bfcfd2 bluetooth: audio: Fix NULL dereference before NULL check
Fixes NULL dereference before NULL check for conn.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-09 17:21:26 +01:00
Emil Gydesen
bdbfcb12ca Bluetooth: Audio: Unicast stream start fix
The unicast client would attempt to send the
receiver start ready opcode to the server for
source ASEs before the CIS was connected, which
is a spec violation.

The code has been refactored to set a boolean,
and then send the receiver start ready opcode on
CIS connection instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-09 17:21:14 +01:00
Pavel Vasilyev
4a59107fc7 Bluetooth: Mesh: Fix compilation issue in access.c
This fixes compilation errors of BabbleSim tests generated by gcc-12
when MOD_REL_LIST_SIZE is zero.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-09 16:02:21 +01:00
Jonathan Rico
da97ab6ee8 Bluetooth: host: gatt: respect BT_GATT_ENFORCE_SUBSCRIPTION
A subscription check was still being done in the
gatt_notify_multiple_verify_params() fn, regardless of the value of
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION.

This could lead to getting this warning if BT_GATT_NOTIFY_MULTIPLE is
enabled, and the notifications not being sent to unsubscribed peers.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-09 11:49:34 +01:00
Szymon Janc
6ca2dac6a3 bluetooth: controller: Fix build with BT_HCI_VS_EXT disabled
[216/319] Building C object zephyr/subsys/bluetooth/controller/
  CMakeFiles/subsys__bluetooth__controller.dir/hci/hci.c.obj
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:
   In function 'hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459:17:
   warning: implicit declaration of function 'vs_set_min_used_chans';
   did you mean 'll_set_min_used_chans'? [-Wimplicit-function-declaration]
 5459 |                 vs_set_min_used_chans(cmd, evt);
      |                 ^~~~~~~~~~~~~~~~~~~~~
      |                 ll_set_min_used_chans
....
zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../
  ../../../arm-zephyr-eabi/bin/ld.exe: zephyr/subsys/bluetooth/controller/
  libsubsys__bluetooth__controller.a(hci.c.obj): in function
   `hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459: undefined
   reference to `vs_set_min_used_chans'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-09 11:49:14 +01:00
Mariusz Skamra
50d21999fe Bluetooth: ascs: Fix bt_ascs_ase missing cleanup
Once the bt_ascs_ase is taken from the mem_slab, it has to be memset to
override the junk data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-09 09:45:52 +00:00
Andy Ross
d20ab8c609 subsys/pm: Use correct timeout API
The z_set_timeout_expiry() function is a wrapper provided in the
timeout subsystem that has some corrections for timelicing.  But the
suspend code doesn't care; by definition there are no active threads
that might be timeslicing at the point where the OS is suspending.
Use the lower-level timer driver API instead.

(z_set_timeout_expiry() is also about to disappear)

Signed-off-by: Andy Ross <andyross@google.com>
2023-03-09 09:21:12 +01:00
Sebastian Arnd
3cd58c29bf net/lib: mqtt_sn: Fix MQTT-SN IPv6 Support and assertation in Example
1. `zsock_socket()` gets the right packet familiy.
2. `inet_pton()` returns 1 on success.

This should address #55193.

Signed-off-by: Sebastian Arnd <sebastianarnd@gmail.com>
2023-03-09 09:20:53 +01:00
Ajay Parida
ce4a809751 net: wifi_mgmt: Updated TWT setup response status
Display message updated for TWT setup response.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-08 15:33:30 +01:00
Chris Friedt
79d4107beb net: http: define http service and resource iterable sections
Provide a means of declaring zero or more HTTP services, each
with zero or more static HTTP resources.

Static HTTP resources are those which have fixed paths[1] which
are known prior to system initialization. Some examples of
static http resources would be

* a forwarder from '/' to '/index.html'
* a REST endpoint with fixed path '/api/foo' and detail
  pointing at some implementation-specific function
* a Javascript file in string form with fixed path '/js/util.js'
* a 'construction' image with path '/res/work.png'
* a gzip-compressed 'Hello' HTML file at '/hello.html'

Without describing in any detail how static HTTP resources are
organized or served by any given HTTP server, we can describe
what static resources exist on a system in a common way that
does not require any optional facilities (e.g. filesystem) and
relies only on addressable memory.

Additionally, for the purposes of simply allowing others
to implement custom HTTP servers in a consistent way, or
benchmarking implementations, or having a consistent testsuite
to use across multiple implementations, it is helpful to have
a common method to declare HTTP services and static resources
for Zephyr.

[1] https://en.wikipedia.org/wiki/URL

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-08 13:57:13 +00:00
Emil Gydesen
72d80b74be Bluetooth: Audio: Move stream_reset before released callback
In the unicast client we should reset the stream before calling
the released callback. This is so that we can reuse the stream object
in the released callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-08 11:07:40 +01:00
Emil Gydesen
136191e936 Bluetooth: Audio: Fix return value for VOCS invalid location
If the location was invalid, we return 0 instead of
an error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-08 11:07:00 +01:00
Mariusz Skamra
cf7bfc406c Bluetooth: audio: Remove redundant forward declaration
This removes redundant bt_bap_ep declaration, as the structure is
defined right below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-08 11:06:51 +01:00
Mariusz Skamra
cb1d36afca Bluetooth: audio: ascs: Remove unused includes
This removes unused includes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-08 11:06:36 +01:00
Tomasz Moń
5bd0f5ea8b usb: device_next: msc: handle MODE SENSE(10) command
USB Mass Storage Specification for Bootability requires MODE SENSE(10)
command. MODE SENSE(6) and MODE SENSE(10) generally access the same data
but differ in the maximum allocated length and LLBAA support. However
there is no point in extracting common handling because there no mode
pages are supported now.

Fail MODE SENSE requests if asking for anything other than supported
page codes (to which the essentially hardcoded response is valid).

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-08 10:53:55 +01:00
Mariusz Skamra
1a0e7fa57a Bluetooth: audio: ascs: Remove reference to conn internals
This removes using conn internal API in ASCS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-07 18:19:08 +01:00
Emil Gydesen
e36caf48b7 Bluetooth: Audio: Rename audio shell commands to bap
Change the shell commands from "audio ..." to "bap ...".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
26f8db4c61 Bluetooth: Audio: Rename stream.h -> bap_stream.h
Renamed the file to better match what it contains.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
099c13846e Bluetooth: Audio: Fix minor bt_audio -> bt_bap issues
Several places used the bt_audio prefix where it shouldn't.
Also moved the BAP documentation to its own file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
e2765d7bd5 Bluetooth: Audio: Rename bt_audio_iso to bt_bap_iso
Rename the internal bt_audio_iso struct and API to bt_bap_iso

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
271ff1d1a3 Bluetooth: Audio: Add new bap_lc3_preset and move macros
Added a new header file bap_lc3_preset.h which contains
the definitions of the LC3 (pre)sets defined by the
BAP spec.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
3326863267 Bluetooth: Audio: Rename bt_audio_ep to bt_bap_ep
Rename the bt_audio_ep struct and API to bt_bap_ep
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
4224b45838 Bluetooth: Audio: Rename bt_audio_unicast_group to bt_bap_...
Rename the bt_audio_unicast_group API to bt_bap_unicast_group
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
77853f43f2 Bluetooth: Audio: Rename bt_audio_stream to bt_bap_stream
Rename the bt_audio_stream API to bt_bap_stream
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
e0fc612c93 Bluetooth: Audio: Rename bt_audio_unicast_client to bt_bap_...
Rename the bt_audio_unicast_client API to bt_bap_unicast_client
and move the API to bap.h

Also adds the _bap_ infix to the bt_unicast_client functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
be42429f90 Bluetooth: Audio: Rename bt_audio_broadcast_source to bt_bap_...
Rename the bt_audio_broadcast_source API to bt_bap_broadcast_source
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
06d00ff5f9 Bluetooth: Audio: Rename bt_audio_broadcast_sink to bt_bap_...
Rename the bt_audio_broadcast_sink API to bt_bap_broadcast_sink
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
eeae1f096a Bluetooth: Audio: Rename bt_audio_unicast_server to bt_bap_...
Rename the bt_audio_audio_server API to bt_bap_unicast_server
and move API to bap.h.

This also adds the _bap_ infix for bt_unicast_server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
7fc051967f Bluetooth: Audio: Add bap prefix to BAP internal files
All internal files that implement BAP now has the
bap_ prefix.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Mariusz Skamra
e33705f64c Bluetooth: audio: ascs: Remove unused variable
This fixes compiler unused variable error

warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
  461 |         struct bt_ascs_ase_status *status;

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-07 15:54:58 +01:00
Tomasz Moń
4c97dd546a usb: device_next: msc: STALL OUT when waiting for reset
Mass Storage Class allows device to either silently discard OUT endpoint
data after receiving invalid CBW or to STALL the OUT endpoint (and keep
it STALLed regardless of host clearing halt) until Reset Recovery.

Switch from silently discarding to STALL in order to allow host realize
that device waits for Reset Recovery without transferring complete OUT
data.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-07 15:48:40 +01:00
Emil Gydesen
736ec47fb3 Bluetooth: Audio: Add ASCS delay for CIS disconnect
While both the server and client are allowed to terminate
the CIS when a stream is released, it is, per the BAP spec,
the client's responsibilty. This commit modifies it so that
the client will actually get a chance to do its responsibilty
by adding a small delay before our ASCS disconnects the CIS.

The CIS disconnection has kept with a delay, rather than
removed, in case that the Unicast Client is not properly
performing it's responsibility.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 11:12:40 +01:00
Vinayak Kariappa Chettimada
c7835e239f Bluetooth: Controller: Remove mesh low lat bsim test workaround
Remove mesh loopback group test workaround introduced in
commit 2a9cd8ffb1 ("Bluetooth: Controller: Add
EVENT_OVERHEAD_START_US when enabling states").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-07 11:12:23 +01:00
Vinayak Kariappa Chettimada
55c4084c8b Bluetooth: Controller: Fix scan window value corruption
Fix scan window value corruption due to modification of
stored ticks_window value when enabling continuous scan.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-07 11:12:23 +01:00
Emil Gydesen
59a9f8a3b0 Bluetooth: Audio: Add reason to BAP stream stopped callback
Forwards the reason parameter from the ISO disconnect to
the stream stopped callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 09:44:20 +01:00
Emil Gydesen
e75fc5e318 Bluetooth: Audio: Remove pac_cache from unicast_client
Removes the unused pac_pache from the unicast_client.

This moves the storing of the PAC records (in the form of
struct bt_codec) from the stack to the upper layers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 09:44:10 +01:00
Alberto Escolar Piedras
f6273e9cb5 Thread analyzer: Prevent on POSIX ARCH
The thread analyzer cannot be really used with the
POSIX architecture.

As:
* Code takes 0 simulated time to execute.
  So the analyzer will report 0 cycles being used.
* The stack allocated by Zephyr is not actually used
  (except for a tiny part used by the arch code itself
  to do a bit of thread bookkeeping).
  The POSIX architecture uses a separate stack
  (from an underlying Linux pthread) which Zephyr is blind
  about. So the thread analyzer is going to only report
  a tiny stack utilization.

Prevent users from selecting them together to avoid confusion.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-07 09:44:59 +02:00
Fabio Baltieri
3386e96515 input: add input subsystem
Initial commit introducing the input subsystem into Zephyr.

Includes the input_event data structure, the input_report_* APIs, an
iterables sections based subscription API and two operation modes:
synchronous, where the listeners are called directly, and asynchronous,
where the listeners are called in a dedicated thread.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-06 11:47:32 -08:00
Erik Brockhoff
1d8acfe5fa Bluetooth: controller: fixing CIS establish flow for refactored LLCP
Latest modification to LLCP removed 'monitoring' of cis->established
flag in LLCP, relying instead on signal through ULL.

For this to work properly the signal must also be generated, so this is
introduced. Note - checking of cis->established flag could be removed
if caller ensures only calling once (on establish condition)

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 17:08:42 +01:00
Krzysztof Kopyściński
392f95705c tests: bluetooth: mesh: add Proxy Solicitation to shell
This adds commands to advertise Solicitation PDUs, configure
On-Demand Private Proxy and manage Solicitation PDU RPL.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
d0995541fb Bluetooth: Mesh: add implementation for Proxy Solicitation
This is initial implementation of Proxy solicitation procedure.
This includes:
- support for sending and receiving Solicitation PDUs
- On-Demand Private Proxy functionality (Server and Client) controlling
  behaviour of node after receiving Solicitation PDU
- Solicitation PDU RPL Configuration (Server and Client), which manages
  Replay Protection List for Solicitation PDUs.

Proxy Solicitation allows to enable advertising of Proxy service on node
by sending Solicitation PDUs. These PDUs are not part of Mesh messages;
instead, these are non-connectable, undirected advertising PDUs with
their own format, containing Proxy Solicitation UUID.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michal Narajowski
d95fe3f52b Bluetooth: Mesh: Add support for Models Metadata Page 128
This patch adds for handling Models Metadata Get Page 128.

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
007bca7b63 Bluetooth: Mesh: Add Composition Data Page 1 to shell
Add parsing of Composition Data Page 1 and enable it's support.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
29f07abc89 Bluetooth: Mesh: Add Composition Data Page 1
Composition Data Page 1 contains information about relations between
models. Implementation saves relations into array of tuples
{ptr to base, ptr to extension, relation type} on model initialization
and uses this information to construct Composition Data Page 1.

Appropriate structures and methods were added to API, allowing user to
parse all received data into Composition Data Page 1 formats:
Composition Data Page 1 Element, Model Item, Model Extension Item.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
0bd0071e4a Bluetooth: Mesh: Add Opcodes Aggregator models to shell
- Add entry for client and server in composition data.
- Add Client commands to aggregate and send messages.

MESH/SR/AGG/BV-02-C requires more key slots.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
da5195ea97 Bluetooth: Mesh: Add support for Opcodes Aggregator models
Includes Opcodes Aggregator Server and Client. To use Opcodes Aggregator
client features with some client model, that client should support async
API.

Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Pavel Vasilyev
d46480c36b Bluetooth: Mesh: Add shell commands for Private Beacon Client
Add shell commands for Private Beacon Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
f9b19010ed Bluetooth: Mesh: Private Beacons
Adds support for private beacon sending and receiving.

Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
b5d6733d53 Bluetooth: Mesh: Add Transport SAR Configuration models to shell
Add Transport SAR Configuration models to shell.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
dd59a45c65 Bluetooth: Mesh: Transport SAR Configuration
Add support for:
- SAR Configuration Client and Server models
- Transport SAR configuration states
- Using SAR Transmitter/Receiver states in segmentation
and reassembly process.

Bsim tests fixes:
- Fix failing replay attack test. The replay attack test doesn't
consider retransmission attempts at the transport layer. When
retransmission happens, SeqNums get increased and the test logic
doesn't work anymore. The simplest fix would be to disable
retransmissions at the transport layer.
- Add device synchronization API to synchronize transport va test.
Device configuration may take different time on transmitter and
receiver. Add synchronisation barrier between devices.
- Fix msg_frnd test. Timing in transport sar behavior has been
changed, which affected test_friend_msg test. Now acknowledgments
are sent much faster and this needs to be considered in the test.
- Fix unicast_low_lat test. Increase number of retransmission
attempts when long segmented message is sent.
- Reduce timeout in kr_old_key test.
- Relax SAR RX state configuration in DFU and BLOB tests.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
8a60dfcd51 shell: Add Large Composition Data Server
- Adds Large Comp Data Server and Client
- Defines some dummy metadata for Health Server

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
df65592d94 Bluetooth: Mesh: Add support for Large Composition Data models
- Adds Large Composition Data Server and Client definitions
- Adds Client API definition
- Adds Health Server Metadata definition
- Refactors Composition Data processing (as a Server) to use common
 methods with Large Comp Data Server

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Stine Akredalen <stine.akredalen@nordicsemi.no>
Co-authored-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
f7f3241628 Bluetooth: Mesh: Shell support for remote provisioning
Adds commands in the mesh shell for remote provisioning client
operation, including scanning, provisioning and reprovisioning.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
3c185e1764 Bluetooth: Mesh: Remote provisioning
Adds remote provisioning models rpr_srv and rpr_cli, and exposes them as
a bearer for the provisioning process.

The remote provisioning models provide the following features:
- Remote provisioning of new devices, using a remote provisioning server
  as a proxy.
- Reprovisioning of existing devices, generating a new device key and
  changing addresses and composition data.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
85431fd69e Bluetooth: Mesh: Add composition data page 128
Composition data page 128 represents the new composition data after a
composition refresh procedure. The implementation stores the old
composition data (before applying a DFU or similar), and uses that as
page 0 if present. As the device has already rebooted by the time page
128 becomes active, its active composition data is page 128, while the
backed up data is the "old" data, which should be shown as page 0.

Co-authored-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
417d328796 Bluetooth: Mesh: DFU and BLOB models in shell
Adds conditional support for the BLOB and DFU models in the mesh shell.
Additionally creates a dummy BLOB stream for testing.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
b054ae364d Bluetooth: Mesh: DFD Server model
Adds support for the Device Firmware Distribution Server model from Mesh
Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
529860e72b Bluetooth: Mesh: DFU models
Adds DFU models from the Mesh Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
4302b568cc Bluetooth: Mesh: BLOB models
Adds support for the BLOB Models from Mesh Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Aleksandr Khromykh
ffddd9ffc0 Bluetooth: Mesh: enhanced provisioning authentication
Implementation of the enhanced provisioning authentication (EPA)
that is based on SHA256 and HMAC security algorithms.
OOB authentication mandates EPA usage.

Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Aleksandr Khromykh
5ffae6486b Bluetooth: Mesh: add mesh 1.1 global config option
All mesh 1.1 features are gathered behind a KConfig options.
Default is disabled.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
1b77e8bbf1 Bluetooth: Mesh: Add Model Receive testing callback
Add a callback similar to net_recv that notifies the application when a
message is received in access layer. This is is useful for testing
purposes (especially automated testing).

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
1c731c714c Bluetooth: Mesh: Refactor bt_mesh_model_recv
Pass only msg context as it is the only thing used from net_rx.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
08f0d1c742 Bluetooth: Mesh: Add a flag for DevKey-only based models
This prevents a Configuration Client from binding an app key to a model
that only supports DevKey-based security.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
7f1b296a0c Bluetooth: Mesh: Do not relay message rejected by Transport layer
Mesh Profile Specification Errata 11341

3.6.4.3 Message error procedure
When the Upper Transport layer receives a message that is not
understood, then the message shall be ignored.
A message that is not understood includes messages that met one or more
conditions listed below:
• The Transport Control message opcode is unknown by the receiving node.
• The Transport Control message size for the Transport Control opcode
is incorrect.
• The Transport Control message parameters contain values that are
Prohibited

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
62aad07968 Bluetooth: Mesh: Check for duplicates in friend queue
Mesh Profile Specification Errata 11302

Section 3.5.5.

When a Friend node receives a message that is destined for a Low Power
node (i.e., the destination of the message is a unicast address of an
element of the Low Power node or in the Friend Subscription List), and
the TTL field has a value of 2 or greater, then the message shall be
processed as follows: If the Friend Queue already contains a message
with the same SEQ and SRC fields as in the received message, or if the
SRC field of the received message is a unicast address of an element of
the Low Power node, then the message shall not be stored in the Friend
Queue. Otherwise, the TTL field value shall be decremented by 1, and
the message shall be stored in the Friend Queue.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
ee3e93148e Bluetooth: Mesh: Change IV Update duration requirement for new nodes
Mesh Profile specification errata 11627

Section 3.10.5:
When a node is added to a network, the node is given an IV Index.
If the node is added to a network when the network is in Normal
operation, then it shall operate in Normal operation for at least
96 hours. If a node is added to a network while the network is in
the IV Update in Progress state, then the node shall be given the
new IV Index value and operate in IV Update in Progress operation
without the restriction of being in this state for at least 96 hours.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
fa107b4b54 Bluetooth: Mesh: Set minimum publish period
Mesh Profile Errata 11392

Section 4.4.3.2.1 Current Fault state:

When the value of a Health FastPublish Period Divisor state is non-zero,
and a Current Fault Fault Array (see Section 4.2.15.1) for at least one
Company ID contains records, an unsolicited Health Current Status
message set to the value of that Company ID and the FaultArray field
containing a sequence of faults representing a sequence of faults in the
Current Fault Fault Array (see Section 4.2.15.1) shall be published
every number of seconds as defined by the value of the Publish Period
divided by the value represented by the Health Fast Period Divisor
state, or every 100 ms (the minimum Publish Period value whichever
is greater.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
91fa9194f0 Bluetooth: Mesh: Fix Heartbeat Pub/Sub Count/Period Log calculation
Mesh Profile Specification Errata 11737 specifies that
Period/Count Log value 0x11 is not defined Log field
transformation in Table 4.1.

Errata 11737 adds value 0x11 to Log field transformation
table with 2-octet value equal to 0x10000 which does not fit into
two octets. This patch changes period calculation to 32-bit precision.
There is also a special case for publication count. If the
log value is equal to 0x11 then the publication count value
should be 0xfffe. When sending Hearbeat Publication Status
message we should return the same value as the one received
in Publication Set so we have to add a case in hb_pub_count_log().

Co-authored-by: Alperen Sener <alperen.sener@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Dave Lacerte
96c8d16986 net: lwm2m: Add IPSO voltage sensor object
Add support fot the IPSO voltage sensor object

Signed-off-by: Dave Lacerte <lacerte.dave@hydroquebec.com>
2023-03-06 12:34:22 +01:00
Marc Lasch
072a5da433 net: lwm2m: Register callback for firmware update cancel
Allow to register a callback function which is called when a firmware
update is canceled by the cancel command.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2023-03-06 12:33:12 +01:00
Arkadiusz Kozdra
f5bf1cddda bluetooth: host: Check bounds on num_completed_packets event
If an event with corrupted length arrives, the extra check makes the
handler return early to avoid reading data out of bounds.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-03-06 11:16:42 +01:00
Erik Brockhoff
6dbc446342 Bluetooth: controller: use RX node piggy-back for NTF when possible
When possible re-use the already allocated RX node for notifications.
Store (retain) RX node and Link element on RX if NTF could occur.
Pass link element to LLCP (ull_cp_rx()) together with RX node.
New RX node type RETAIN introduced to signal retention

When no RX node is available allocate one and hold off TX on procedures
until such time that a node is available for NTF.

In case waiting for NTF buffer avail is needed, allocate and store TX
node to use for TX once NTF becomes available.

CIS Established (incl. timeout handling) is now handled entirely as a
specific event driven by ull_conn_iso - ie removal of procedure check
of cis->established and cis->expire, as this is doubling mechanism
in the conn_iso context.

Unit test and helpers updated to handle new node type.
Function ull_cp_release_ntf() was used only in unit test, so moved to
helper context.
Updating release_ntf to handle the fact that with piggy-backing in test
context the node used for NTF can be from two different memory pools

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 09:35:10 +01:00
Erik Brockhoff
80426ddbed Bluetooth: controller: removed unused code
LLCP data struct member fex.sent was set but not used so remove

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 09:35:10 +01:00
Emil Gydesen
835352c2bb Bluetooth: Shell: Add indication of default_conn in connections cmd
When doing "bt connections" the currently selected ACL (default_conn)
is now indicated with a "*" making it easier to determine which
of the connections is currently selected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-06 09:34:36 +01:00
Lucas Dietrich
c7f9eafeec net: http: Make http_client.c compile with CONFIG_NET_SOCKETS_POSIX_NAMES=n
Use internal constant ZSOCK_POLLIN instead of POLLIN to
 make the http_client source file compile without error with
CONFIG_NET_SOCKETS_POSIX_NAMES disabled.

 Fixes #55423

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2023-03-05 08:51:25 -05:00
Wojciech Slenska
6272ba2d5c shell: added function shell_use_vt100_set
Added function to enable/disable vt100 commands.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-03-04 18:36:39 +01:00
Wojciech Slenska
bbd428fd63 shell: shell_cmds: added vt100 commands
Added command for enablig/disablig vt100 shell commands.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-03-04 18:36:39 +01:00
Dmytro Semenets
e169f7cc12 subsys/storage/flash_map: remove unnecessary includes
Those files includes soc.h header which exists not for all boards.
soc.h consists soc-depended defenitions and need to be included by
soc-depended sources

Signed-off-by: Dmytro Semenets <dmytro_semenets@epam.com>
2023-03-03 15:34:59 +01:00
Ajay Parida
55ed46ff6d net: wifi_mgmt: Updated TWT setup response status
Updated TWT setup response status. Removed un-necessary
error strings, enum and values updated as per f/w.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-03 12:43:43 +01:00
Martin Sollie
e94c33d530 logging: add support for 64 bit timestamps with Linux format
Combining CONFIG_LOG_OUTPUT_FORMAT_LINUX_TIMESTAMP and
CONFIG_LOG_TIMESTAMP_64BIT results in a wrong timestamp, as the
Linux timestamp format print call assumes a 32 bit variable for
the seconds. Fix it by using a different print format for 64 bit
timestamps.

Fixes: #55372

Signed-off-by: Martin Sollie <ms@aziwell.no>
2023-03-03 11:36:14 +01:00
Jamie McCrae
533e312359 mgmt: updatehub: Change Kconfig select to depends on
Changes Kconfig symbols to depend on symbols rather than selecting
them, this avoids a cmake dependency loop.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Jamie McCrae
31201a7f61 mgmt: hawkbit: Change Kconfig select to depends on
Changes Kconfig symbols to depend on symbols rather than selecting
them, this avoids a cmake dependency loop.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Jamie McCrae
c3bfe7a6ba dfu: Change FLASH_MAP and STREAM_FLASH from select to depends on
This fixes a cmake dependency loop when selecting
CONFIG_MCUBOOT_IMG_MANAGER.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Chris Friedt
f923441146 lib: posix: move fnmatch from lib/util to lib/posix
The `fnmatch()` function is specified by POSIX and should be
a part of `lib/posix`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-03 17:40:14 +09:00
Vinayak Kariappa Chettimada
afd4346965 Bluetooth: ISO: Fix BT_ISO_TX_MTU range
In the Bluetooth Core Specification, the minimum
ISO_Data_Packet_Length is 0x0001, hence fix the
BT_ISO_TX_MTU range to allow a minimum value of 1.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-03 09:19:19 +01:00
Tom Burdick
3998f9f898 rtio: Shareable lock-free iodevs
By using an mpsc queue for each iodev, the iodev itself is shareable across
contexts. Since its lock free, submits may occur even from an ISR context.

Rather than a fixed size queue, and with it the possibility of running
out of pre-allocated spots, each iodev now holds a wait-free mpsc
queue head.

This changes the parameter of iodev submit to be a struct containing 4
pointers for the rtio context, the submission queue entry, and the mpsc
node for the iodevs submission queue.

This solves the problem involving busy iodevs working with real
devices. For example a busy SPI bus driver could enqueue, without locking,
a request to start once the current request is done.

The queue entries are expected to be owned and allocated by the
executor rather than the iodev. This helps simplify potential
tuning knobs to one place, the RTIO context and its executor an
application directly uses.

As the test case shows iodevs can operate effectively lock free
with the mpsc queue and a single atomic denoting the current task.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-03 09:18:09 +01:00
Jordan Yates
30dbaa83f7 logging: backend_uart: handle PM on panic
Handling panicking while in an ISR. Instead of attempting to call
`pm_device_get` for each character, ensure that the hardware is enabled
when `log_panic` is called.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-03 09:17:49 +01:00
Jordan Yates
997dce97bf logging: backend_uart: handle runtime PM
Allow the log_backend_uart char_out implementation to integrate with
'Device Runtime Power Management'.

Without using runtime PM, it is impossible for the application to manage
the power state of a UART instance, given that any module in the
application could theoretically LOG_* or printk at any point in time.

This removes the need to manually call `pm_device_state_set` when the
lowest power states must be reached, while still allowing log messages
to be output.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-03 09:17:49 +01:00
Michał Barnaś
e0fbd35fc0 usbc: explicitly declare sizes of state machines arrays
The asserts in the USB-C stack functions were causing compilation
errors when asserts were enabled in Kconfig.
This was caused because the asserts checked if the functions
parameters were within limits specified by the state machine arrays.
At the position of these asserts, these arrays were only declared
without specifying the size of them, what prohibited the asserts from
knowing the size of arrays and checking if specified value is within
limit of it.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-03-03 09:17:11 +01:00
Jeroen van Dooren
1be74ac6d7 net: dns: prevent crash on nullptr as callback
When a query is done, the query isn't set to NULL.
This can cause a nullptr exception in invoke_query_callback().

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-03-02 21:58:07 -05:00
Aleksander Wasaznik
5233fe5fb9 Bluetooth: Host: Log incomplete adv reports
This gives our users some indication of why they are not receiving
long advertisements.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-02 21:19:16 +01:00
Emil Gydesen
8333b12da7 Bluetooth: Host: Add ACL NULL check for ISO conn info
If getting the conn info of an ISO channel, the ISO channel may
not yet have an ACL connection, so we cannot get the
ACL source and destination addresses from the ACL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 17:57:17 +01:00
Simon Frank
5d9db9dc65 fb: cfb: cfb_shell command to set font kerning
Using `struct shell *shell` would be more consistent but triggers CI
check on MISRA rule 5.7 "A Tag name shall be a unique identifier"

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
Simon Frank
b50838c66f fb: cfb: add API to set font kerning
Font kerning was used but it was not possible to change it.
Also, font_idx was set to zero twice in init.

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
JP Sugarbroad
6d4266a451 usb: device: msc: support larger devices
Track LBA rather than byte offset in order to simplify the code and
support devices larger than 4GiB.

Signed-off-by: JP Sugarbroad <jpsugar@amazon.com>
2023-03-02 13:51:37 +01:00
Vinayak Kariappa Chettimada
afa8e6f23a Bluetooth: Controller: Fix extended scanning for BT_CTLR_LOW_LAT
Fix Extended Scanning support for BT_CTLR_LOW_LAT variant
of the Controller implementation by closing the scan window
for every ADV_EXT_IND PDU received that that ULL_LOW context
is enabled back and ticker job can process the request to
start auxiliary PDU reception. Without the change the
ticker job would only run at the end of the scan window that
caused the auxiliary scan prepare to assert due to delayed
ticker timeout expiry callback.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-02 13:46:59 +01:00
Emil Gydesen
6d0c53c959 Bluetooth: Audio: Add addition vol ctlr input checks
Add misisng function parameter input checks to verify
values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 10:56:27 +01:00
Robert Lubos
b6ae195390 net: dhcpv4: Fix potential packet leak in DHCPv4
Packet handlers registered with net_conn API should not use NET_CONTINUE
to report packet processing status. As they register for a specific
local port, it cannot be assumed someone else will handle the packet,
and for net_conn this status is not really handled differently from
NET_OK. Therefore, reporting NET_CONTINUE, and not freeing the packet,
can result in a packet leak.

Too short packets should not really be handled differently from other
malformed packets in DHCPv4 module, therefore report NET_DROP instead of
NET_CONTINUE.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-02 10:01:27 +01:00
Arkadiusz Kozdra
1e293a13bc bluetooth: sco: Error out early on null acl
Cleanup unrefs the ACL connection, so ensure it is never null in the
constructor.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-03-02 09:59:56 +01:00
Emil Gydesen
f2918b0109 Bluetooth: Audio: Fix MCC discover callback on reconnected issue
With BT_GATT_SUBSCRIBE_FLAG_NO_RESUB the MCC subscriptions would
be resent to the server on reconnection. Since this may trigger an
error, the error will trigger a call to the MCC discover complete
callback.

For MCP We can assume that the server stores the subscriptions if
we are bonded, and thus we can use BT_GATT_SUBSCRIBE_FLAG_NO_RESUB.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 09:03:32 +01:00
Emil Gydesen
4b0442ab57 Bluetooth: Audio: Fix missing call to BAP discover cb
If we discover both sink and source ASEs, then we attempt
to subscribe to the ASE CP characteristic twice. However,
if we are already subscribed, then the callback is not called,
and then the 2nd call to discover will not return properly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-01 15:58:15 +01:00
Tomasz Moń
7527b38ff5 usb: device_next: fail Mass Storage requests with invalid length
Fail Mass Storage control requests if wLength is incorrect.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-01 12:02:29 +01:00
Jonathan Rico
caa88b2cfd Bluetooth: host: gatt: don't use settings API in disconnect cb
When `CONFIG_BT_SETTINGS_DELAYED_STORE` is enabled, reschedule the storage
work immediately instead of processing it in the current context.

When that config is not enabled, process the storage in the current
context.

Processing this work (i.e. using the settings API and its likely
FLASH-based backend) in the current context (cooperative prio) may mess
with the real-time constraints of the application threads.

Fixes #55067.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-01 11:10:22 +01:00
Luca Fancellu
d61dcf2f1d net: zperf: improve code quality for tcp_received function
Currently, in tcp_received function defined in zperf_tcp_receiver
module, the assignment of session->state to STATE_COMPLETED is
overwritten on the same path to STATE_NULL and a session is
considered free for both STATE_COMPLETED and STATE_NULL, so remove
the assignment to STATE_NULL.
Remove the break from the STATE_COMPLETED case handling so that it
can fallthrough, in case the same session is used after finish.
Remove also the STATE_LAST_PACKET_RECEIVED case because this state
is never reached.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
7c4ea08db8 net: zperf: fix typo in error messages
Fix typo in error messages from the zperf_tcp_receiver where UDP
is written instead of TCP.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
910de7f83d net: zperf: unify get_session among TCP and UDP
The modules zperf_udp_receiver and zperf_tcp_receiver use two
different functions to get a zperf session to store the
statistics, there is a TODO comment in the zperf_session module
suggesting to unify that part.
So delete the get_tcp_session function and use get_session for
both TCP and UDP receiver module.
Delete sock field from struct session because it's not used
anymore.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
1a12a070eb net: zperf: add configurable for the zperf sessions number
Currently the maximum number of zperf sessions handled is hardcoded
to 4, create a Kconfig parameter, with default value 4, to make the
maximum number of sessions configurable.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Arkadiusz Kozdra
642548daeb bluetooth: host: Check bounds more explicitly
Co-authored-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 13:23:51 +01:00
Arkadiusz Kozdra
8848380dff bluetooth: host: Check bounds on le_adv_report event
If an event with corrupted length arrives, the extra check makes the
handler return early to avoid reading data out of bounds.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 13:23:51 +01:00
Arkadiusz Kozdra
a000c2e903 bluetooth: host: Check for NULL discovery callbacks
Fixes a segfault if a discovery event happens while discovery is not
active and the discovery callback is null.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 12:48:47 +01:00
Dawid Niedzwiecki
2d0a784c41 subsys/mgmt/ec_host_cmd: rework Host Command support
Rework the Host Command support. It includes:
-change API to backend
-change a way of defining rx and tx buffers
-fix synchronization between the handler and backend layer
-simplify the HC handler

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Dawid Niedzwiecki
b2674a4b34 subsys/mgmt/ec_host_cmd: rename peripheral to backend
Follow naming pattern in the subsystems(logging or shell) and name
the layer between generic handler and peripheral driver "backend".

The name doesn't suit that well to the SHI backend, because there isn't
SHI API itself and the SHI interface is used only for the host
communication. So the backend code includes the peripheral driver itself.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Dawid Niedzwiecki
e734adfb78 subsys/mgmt/ec_host_cmd: update directory structure
The Host Commands can be used with different transport layers e.g. SHI
or eSPI. The code that provides the peripheral API and allows sending
and receiving Host Commands via different transport layers is not
actually drivers of a peripheral, so move it to the
subsys/mgmt/ec_host_cmd folder.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Flavio Ceolin
72fbc8c56d pm: device_runtime: Early feature enabled check
Check if device runtime is enabled in the beginning of
runtime_suspend to avoid unnecessary checks.

This does not change the current behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-02-28 10:41:30 +01:00
Flavio Ceolin
c4258dbde3 pm: device_runtime: Early feature enabled check
Check if device runtime is enabled in the beginning of
pm_device_runtime_get to avoid unnecessary checks.

This does not change the current behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-02-28 10:41:30 +01:00
Jun Qing Zou
755f0b7d27 net: tftp: Add client context
Use client context to seperate buffer usage.
Use new `TFTP_EVT_DATA` event to send data to application.
Use new `TFTP_EVT_ERROR` event to report error to application.
Update `tftp_get()` and `tftp_put()` API to use the client context.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-28 10:29:30 +01:00
Emil Gydesen
838cc543d8 Bluetooth: Services: Set IAS alert level before callback
Fix the order of setting the alert level before the callback.
Without this fix, the alert level would be incorrect if
the upper layers ever tried to perform any other IAS operations
in the callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-27 13:20:33 +01:00
Stefan Schwendeler
596a3bd996 net: lwm2m: bugfix lwm2m shell exec command with optional parameter
Actually `execute_cb` is fed with an array of char* and the size of
that array, instead of a single char* buffer and its byte size.

This fix expects a single, already joined, optional shell argument and
feeds `execute_cb` with proper arguments.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-27 11:34:42 +01:00
Miika Karanki
549de77750 usb: device: fix k_usleep in isr in set_endpoint
set_device can be called in interrupt context at least with
stm32u5 soc. Calling k_usleep from there causes the isr
to run forever.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2023-02-27 11:34:33 +01:00
Jonathan Rico
298ae28707 Bluetooth: host: gatt: fix ifdef comment
Forgot to update the ifdef comment when adding another condition.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
1906b05b10 Bluetooth: host: use ATOMIC_DEFINE for GATT global flags
Use a single bit array instead of multiple atomic_t variables.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
3486f133e9 Bluetooth: host: prevent registering services in the wrong context
There is a touchy spot where registering a service might result in sending
service changed indications that are not necessary. This is due to a race
condition between the SC work and the GATT DB hash being calculated.

Only allow users to call this API when we know it is safe:
- either before BT is initialized
- or after settings have been loaded (and hash calculated)

Fixes #54047

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
02edcd6494 Bluetooth: host: calculate GATT DB hash on settings load
Prevent race condtions between the stack and the low-priority thread by
calculating the hash (and acting on it, e.g. for marking peers
change-aware, sending SC indications, etc) in the settings_load() context.

Fixes #54773

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
b3671666e1 Bluetooth: host: clear ATT pending flag on failure to send
`ATT_PENDING_SENT` wasn't cleared when L2CAP reported an error when sending
the packet. This resulted in the channel being unusable for ever, since we
only clear that bit on a response (that will never be sent).

Found when setting `CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768` in the
`notify_multiple` test. The kicker was the bug didn't manifest when EATT
wasn't enabled:
- we were queuing two unsubscribes back to back in the test
- on UATT we have to wait for a req-rsp pair before enqueuing a new one
- on UATT we only have one channel anyways

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:32:13 +01:00
Sjors Hettinga
c51cf4f08d net: websocket: Make sure the mbedtls_sha1 function is build in
In the header the websocket protocol needs a SHA1 hash. This is
implemented using the mbedtls_sha1 function. Select the option
MBEDTLS_MAC_SHA1_ENABLED from the Kconfig of websocket to ensure this
function is build in.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-02-24 18:12:14 +01:00
Tomasz Moń
509c033c1d usb: device_next: new USB Mass Storage implementation
Introduce new USB Mass Storage Bulk-Only Transport implementation
written from scratch. Main goal behind new implementation was to
separate USB and SCSI parts as clearly as possible.

Limited set of SCSI disk commands is implemented in separate source code
file that is internal to USB device stack. While it should be possible
to use the SCSI implementation by other components there is currently no
other user besides USB MSC and therefore SCSI header is kept private.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-02-24 15:19:20 +01:00
Johann Fischer
c51744c6ee usb: device_next: use consistent nil descriptor name
Use a consistent nil_desc name for the descriptor that
terminates a class (function) descriptor.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-24 14:02:37 +01:00
Yuval Peress
8ac822e69c emul: Cleanup emul directory
Avoid implementations in the subsys emul directory to keep the directory
focused on emulator subsystem instead of consumers. Consumers should be
implemented side-by-side to their drivers

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress
a6326f1f7f bmi160: move emulator to driver directory
Allow the emulator to sit in the same directory as the driver
implementation. This will make working on the emulator much easier and
keep the emulator subsystem directory clean by allowing it to focus on
the actual subsystem and not the use cases of the subsystem.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Krishna T
50c1f857e0 net: l2: wifi: Log packet errors
Log packet errors, this is handy for debugging.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-24 11:49:41 +01:00
Andries Kruithof
226c99b455 tests: bluetooth: add prefix to exposed API
In ull_llcp* some functions used in unittesting did not have
the llcp_ prefix
Although this is not a big issue since they are only used when
testing the module this commit adds the prefix so that we
have a more consistent naming

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 11:46:39 +01:00
Andries Kruithof
e6ba1eed90 bluetooth: controller: update unittests for LLCP to use proper ZTEST API
Update unittests for the following areas/controll procedures
- API
- collision handling
- invalid PDUs
- unsupported procedures
- buffer allocation
- TX queue
- Data Length Update
- PHY update
- Encryption
- Ping
- Version
- Channel map update
- Min. used channels
- Connection update
- SCA
- Terminate connection
- CTE request
- CIS create
- CIS terminate

Also moved the internal API tests from the ull_llcp* files
to the proper unittest C-file

Unused files  are removed

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 11:46:39 +01:00
Vinayak Kariappa Chettimada
ade92f4d28 Bluetooth: Controller: Fix mayfly priority check when in ZLI
Fix mayfly_prio_is_equal() function when BT_CTLR_ZLI is
enabled.

When Zero Latency IRQs are used, LLL execution priority
is the Zero Latency IRQ priority and will not be equal
to ULL execution priority.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-24 11:00:43 +01:00
Vinayak Kariappa Chettimada
e409aadf0c Bluetooth: Controller: Fix Peripheral CIS supervision timeout
Fix Peripheral CIS supervision timeout due to missing access
address timestamp capture in subsequent subevents when
anchor point was not sync in the first subevent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-24 11:00:36 +01:00
Zachary J. Fields
66aff25396 usb: usb_transfer.c: Address -Wextra warnings
Changed incrementing `for` loop counters to `size_t` from `int` to
eliminate warning, "warning: comparison of integer expressions of
different signedness: 'uint32_t' {aka 'unsigned int'} and 'int'
[-Wsign-compare]"

Signed-off-by: Zachary J. Fields <zachary_fields@yahoo.com>
2023-02-24 09:39:01 +01:00
TOKITA Hiroshi
cccfc8fc8f fb: cfb_shell: set pixel format as MONO10 or MONO01 on initializing
Set the display's pixel format to MONO10 or MONO01 that cfb supports
on cfb initializing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
TOKITA Hiroshi
279c722edb fb: cfb_shell: turn off display_blanking at initializing
Turn off display_blanking to make it able to refresh on a device
even when blanking default off.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
Emil Gydesen
5d5dffef76 Bluetooth: Audio: Fix ASCS check for streaming state
Add missing check for receiver_ready in the state
change to enabling state. This change makes the
the check in the state change similar to the check
in ascs_ep_iso_connected

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-24 09:24:34 +01:00
Johann Fischer
d17119c612 usb: device_next: add feature endpoint halt/clear state update API
Add USB device class API to notify class instances that an endpoint
has been halted or cleared due to a feature request.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-24 09:15:55 +01:00
Andries Kruithof
94cfb8dbcf Bluetooth: add decoding for BLE 5.4 version string
The BLE 5.4 specification was recently released. Here the
version strings are updated

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 09:13:18 +01:00
Andries Kruithof
b02ce97dd0 Bluetooth: controller: update bluetooth version to 5.4
The Bluetooth 5.4 specification was recently released, and has a new
version identifier (0x0D or decimal 13) assigned to it in the
Bluetooth Assigned Numbers.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 09:13:18 +01:00
Aaron Massey
107cb86bb3 ztest: Add initial zexpect API for delayed failing
Add the zexpect API, inspired by GoogleTest's EXPECT API. This API reports
test failures while allowing test execution to continue. This enables test
reports to show more than a singule failing property on a failing test.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-02-23 20:34:39 +01:00
Andrei Emeltchenko
8e84d840b5 usb: Fix build for 64 bit platforms
Use proper format for size_t type eliminating warnings of type:

...
error: format '%u' expects argument of type 'unsigned int', but
argument 2 has type 'size_t' {aka 'long unsigned int'}
[-Werror=format=]
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-02-23 17:51:31 +01:00
Emil Gydesen
300491af34 Bluetooth: Audio: Shell: Audio shell improvements
This commits allows for setting up multiple streams in
a single CIG as the unicast client.

It fixes an issue with the unicast server not using
the configured QoS when transmitting audio data.

Improves upon setting the preset for the different
type of streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 10:49:53 +01:00
Hubert Miś
2c3863160d ipc: multi-endpoint icmsg cleanup
The multi-endpoint backend of the ipc_service subsystem contains two
roles with separated implementations: initiator and follower. There
was many code duplications for both roles. This patch introduces a new
IPC library: icmsg_me containing common code extracted from both roles
and encapsulating access to common data fields.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2023-02-23 10:46:25 +01:00
Nick Ward
ca3a4f5f5b shell: backends: dummy: default to log level INF
This change fixes code to match the description in
https://github.com/zephyrproject-rtos/zephyr/pull/55061
(see commit 9ecef4b).

This preserves the previous default behaviour of the
shell dummy backend.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-02-23 09:55:11 +01:00
Robert Lubos
43a86b8138 net: tcp: Fix packet processing result reporting
TCP implementation abused the packet processing result reporting
mechanism, by reporting NET_DROP for every packet other than data
packets (which were passed to the application). This simplified the TCP
implementation a bit, as it didn't need to deal with packet releasing.
While technically it worked, it gave incorrect results when it comes to
packet statistics, as a lot of valid TCP packets were counted as
dropped.

This commit fixes this. Each packet that was properly processed by the
TCP stack is not either released at the TCP level, or passed to the
application. In both cases, NET_OK is returned to the network core,
indicating the packet has been properly processed and consumed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-23 09:07:52 +01:00
Emil Gydesen
4fcc3f0c1e Bluetooth: Audio: Add guard for bt_audio_codec_qos_to_iso_qos
The function are only used by the broadcast roles and
the unicast client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Emil Gydesen
f5f1664a41 Bluetooth: Audio: Move most of unicast client-only code from stream.c
Some operations such as Config, QoS, Enable and Stop
are only available for the unicast client, but since
they share the bt_audio_stream prefix, we leave the
agnostic part of it in stream.c, and move the actual
implementation to unicast_client.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Emil Gydesen
6303fa0c18 Bluetooth: Audio: Remove unicast server specific code from stream.c
stream.c had code that was only useful for the unicast server/
ASCS, and have been moved to ascs.c instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Stig Bjørlykke
b77c234691 net: icmpv6: Initialize dns sockaddr in RA RDNSS
Initialize struct sockaddr_in6 in RDNSS handling to avoid
uninitialized sin6_port or sin6_scope_id.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-22 14:26:39 +01:00
Seppo Takalo
abb3163d82 net: lwm2m: Clear out the timestamp when we start registration
There was a corner case that last registration timestamp was used
to detect if we can try UPDATE instead of full registration.

When timestamp was not cleared and DNS resolving failed, it might
cause engine to skip the resolving and continue retrying an UPDATE
message until timeout.

Fixes #54504

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
d8b8d53f5f net: lwm2m: Drop observations when falling back to registration
When we have establised an DTLS handshake and try LwM2M Update,
if the server rejects it, we fall back to sending full registration
but when doing so, we should also clear out any observations.

It was intentional that we don't go to ENGINE_DO_REGISTRATION
state as that would close the socket and cause DTLS handshake.

Fixes #54974

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
96a4bedd30 net: lwm2m: Don't ignore socket errors when sending
Only socket error that we should ignore is EAGAIN (EWOULDBLOCK),
others might be indicating that there are some serious errors
in network layer.
When network stack would block us, just drop the packet and
let CoAP layer handle the retrying.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
ea1eb28135 net: lwm2m: Fix build issue on time-series cache
This was only missing a variable declaration.

Fixes #55031

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Seppo Takalo
bf49540a8d net: lwm2m: Add const qualifier to many pointers
Various functions, mostly concerning time-series cache, were not
using const pointer while they still did not modify the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Emil Gydesen
b46edc7137 Bluetooth: Audio: Fix bad shell string formats
There was a couple of shell prints that was not
formatted correctly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-22 12:19:04 +01:00
Andries Kruithof
ddd83c3bc0 Bluetooth: controller: correct conditional compile for central FEX
In the switch statement there are two cases guarded by ifdef's.
These cases are not compiled in for the following Kconfig settings:
BT_PERIPHERAL=n
BT_CTRL_PER_INIT_FEAT_XCHG=n
The following function call then becomes dead code
This is fixed here by adding the proper guards around the whole case
statement

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-22 12:16:03 +01:00
Marco Argiolas
9ecef4b415 shell: backends: add init log level for dummy shell
Dummy shell was always started with log backend enabled with filter
 statically set to INFO level.
AFAIK no use of such log backend can be made, thus causing waste of
 resources.
The new changes keep INFO as the default filter level. In order to
 disable log backend to be attached to the Dummy shell,
 CONFIG_SHELL_DUMMY_INIT_LOG_LEVEL_NONE has to be set.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-02-22 12:15:24 +01:00
Fabio Baltieri
8c6137d7a7 build: sort and compact drivers and subsys CMakeLists and Kconfig
There are just list of child files to include, right now there's a hint
of that trying to be alphabetical but then entries have been added with
various logic, so one has to figure where stuff has to be added.

Rewrite these to:
- keep the list alphabetical, for CMakeLists unconditional first,
  conditional after so one just has to select and sort
- drop the spaces in the Kconfig
- use a single space between  target and directory
- rename from "Sub Systems" to "Subsystems" (single word)

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-22 10:25:11 +01:00
Stefan Schwendeler
4662c40888 net: lwm2m: read command uses hexdump as default print format
A default format that does always print something useful.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-22 08:50:56 +01:00
Sam Hurst
df117e563a usb_c: Add super state to handle Sender Response Timer
Any Power Delivery message state that expects a reply must
start a sender response timer. This change addes a super
state that implements the Sender Response Timer
functionality, from which Power Deleiver messages states
can inherit from.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-02-21 18:04:04 -05:00
Fabio Baltieri
9b30667c77 build: drop LEGACY_INCLUDE_PATH support
LEGACY_INCLUDE_PATH has been defaulting to "n" and marked as deprecated
in both v3.2 and v3.3. Drop the option entirely for v3.4.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-21 15:06:48 +01:00
Siyuan Cheng
b475e1fcbf zdsp: add ARC DSPLIB backend for zdsp
Introduce ARC DSPLIB backend zdsp library for ARC target.
Add agu and restrict attributes to map with ARC DSPLIB

Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
2023-02-21 15:06:06 +01:00
Stig Bjørlykke
0f71a130ef net: sockets: getaddrinfo: Minor refactoring
Minor refactoring in getaddrinfo() to make the code easier to
read and to make handling IPv4 and IPv6 support more equal.

- Move common wait and error handling code to exec_query()
- Use the same check for CONFIG_NET_IPV4 and CONFIG_NET_IPV6
- Add extra sanity check for family before exec_query()
- Do not set errno when return DNS_EAI_ADDRFAMILY

Fix issue with setting port number for all DNS servers.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-21 15:02:35 +01:00
Emil Gydesen
4f5e113dfd Bluetooth: Audio: Fix bad log statement in cap_initiator
Fix missing argument for a log statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-21 11:00:18 +01:00
Stig Bjørlykke
cb50d49f33 net: icmpv6: Implement IPv6 RA Recursive DNS Server option
Handle RA RDNSS and use the first DNS server fetched. This is needed
when building IPv6 only without static DNS server IP addresses.

This implementation does not handle the lifetime, because the current
resolve logic does not have support for a DNS server lifetime.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-21 10:59:18 +01:00
Ajay Parida
c69731a281 net: wifi_mgmt: Display TWT setup response status
Display the TWT setup response status.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-02-21 10:58:40 +01:00
Jeroen van Dooren
d20cceb48e net: ip: net_mgmt: Increase default queue size
There is no reason why the default size should be 2,
because an event is only a combination of

{uint32_t + void*} + info

Using 2 as default causes a high risk of loosing events,
setting the default to a more sensible value of 5 still
restricts memory usage but keeps it more safe.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-02-21 10:58:10 +01:00
Jeroen van Dooren
a63fcb67b6 net: ip: net_mgmt: Prevent loss of event
The current implementation doesn't handle
re-entrant calls correctly, causing events
to get lost.

Under specific conditions, re-entrancy happens
from event callback done by net_mgmt.c back into
'net_mgmt_event_notify_with_info' causing circular
buffer administration corruption.

These conditions are:

- llmnr_iface_event_handler
- mdns_iface_event_handler
- wifi_mgmt_raise_connect_result_event
- dhcpv4_immediate_timeout uses a workaround

Validated the fix on a Nucleo_H743ZI, using an
sample app.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-02-21 10:58:10 +01:00
Krishna T
55802e5e86 net: l2: ethernet: Fix double free
In the case of no ARP entry, the incoming packet is added to the ARP's
pending queue, while ARP is being resolved. Here a reference is taken
by the ARP layer to the packet to avoid it being freed, but the Ethernet
immediately puts down the reference and send the ARP packet to the
driver.

If the ARP request fails for some reason, L2 returns failure to net_if
which then puts down the reference and the packet will be freed as the
reference count is now zero.

But the packet is still in the ARP's pending queue and after timeout
ARP will put down the reference causing double free bus fault (double
free message is only seen if the CONFIG_NET_PKT_LOG_LEVEL_DBG is
enabled, so, a bit hard to debug.

Fix this by clearing the ARP entry and pending queue after taking a
reference and then free ARP packet, IP packets are either freed by ARP
pending queue drain or net_if layer.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 19:45:28 +01:00
Marcin Niestroj
830308e00f Bluetooth: host: increase BT_CONN_TX_USER_DATA_SIZE for 64bit platforms
Commit 2c00dd5fec ("Bluetooth: host: check net bufs have enough room in
user_data") added a build time check of user data size. This check does not
pass with default CONFIG_BT_CONN_TX_USER_DATA_SIZE=8 and with
`native_posix_64` platform, as 16 bytes are needed in order to store
`struct tx_meta`.

Select 16 as default value for 64bit platforms, so Bluetooth samples/tests
are buildable for `native_posix_64`.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-02-20 19:44:25 +01:00
Emil Gydesen
928e5bbcf0 Bluetooth: Audio: CAP inittiator broadcast stop procedure
Implemented support for stopping and deleting a
CAP broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
9d0ec99315 Bluetooth: Audio: CAP initiator broadcast metadata update
Add support for the update metadata for broadcast audio
procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
6f1bb59b26 Bluetooth: Audio: Implement bt_cap_initiator_broadcast_audio_start
Implement the CAP initiator broadcast audio start procedure.

This basically just verifies that the stream context
is set in the metadata, and then calls the BAP
procedure.

We define a new opaque struct, bt_cap_broadcast_source,
that is just an abstraction of the bt_audio_broadcast_source
but is used to indicate that these functions require a
broadcast source created by the CAP function (and not the
BAP) function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
17b7854961 Bluetooth: Audio: Fix for PA sync in broadcast sink
Fixes a bug where we cleanup the broadcast sink without
properly terminating the BIG sync first.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:22:15 +01:00
Vinayak Kariappa Chettimada
659294bc3f Bluetooth: Controller: Fix AUX_ADV_IND AUX_SYNC_IND radio utilization
Fix AUX_ADV_IND AUX_SYNC_IND radio utilization by having a
configurable offset.

Define an offset between AUX_ADV_IND and AUX_SYNC_IND when
using Advertising Interval for the Extended Advertising and
Periodic Advertising that are same or multiple of each
other, respectively.

Note, to get advertising intervals that are same or
multiple, the Periodic Advertising Interval shall be 10
millisecond more than the Extended Advertising Interval;
this is because the AUX_ADV_IND PDUs are scheduled as
periodic events of Extended Advertising Interval plus 10
milliseconds (Advertising Random Delay) as the periodic
interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 13:18:12 +01:00
Vinayak Kariappa Chettimada
a8862e2adb Bluetooth: Controller: Fix Close Isochronous Event implementation
Fix the Close Isochronous Event (CIE) implementation so that
it follows the Bluetooth Core Specification definition:
Link Layer implementations will normally end a CIS event
early when all scheduled payloads in both directions have
been transmitted and acknowledged.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 11:48:56 +01:00
Vinayak Kariappa Chettimada
e0f5675e70 Bluetooth: Controller: Rename lll_df_conf_cte_tx_disable()
Rename lll_df_conf_cte_tx_disable() to lll_df_cte_tx_disable()
so that it can be used as a common function between connection
and connectionless implementations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 11:36:58 +01:00
Emil Gydesen
9756aea801 Bluetooth: Audio: Ensure strtoX correctness in vcp_vol_rend.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
fe1d5a8177 Bluetooth: Audio: Ensure strtoX correctness in vcp_vol_ctlr.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
668ed75a22 Bluetooth: Audio: Shell: Fix VCP location check
The location value is a uint32_t, and not uint16_t.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
caf259af65 Bluetooth: Audio: Ensure strtoX correctness in tbs.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
d5e625ce9d Bluetooth: Audio: Ensure strtoX correctness in tbs_client.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
87cd6dd743 Bluetooth: Audio: Ensure strtoX correctness in mpl.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
97f14779a5 Bluetooth: Audio: Ensure strtoX correctness in micp_mic_dev.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
07f4c83610 Bluetooth: Audio: Ensure strtoX correctness in micp_mic_ctlr.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
1bf9aae455 Bluetooth: Audio: Ensure strtoX correctness in media_controller.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
f0ea061b3a Bluetooth: Audio: Ensure strtoX correctness in mcc.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
0c9180ef99 Bluetooth: ISO: Ensure strtoX correctness in iso.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
ab9d2c32c9 Bluetooth: Audio: Ensure strtoX correctness in csip_set_member.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
311476d5ce Bluetooth: Audio: Ensure strtoX correctness in csip_set_coordinator.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
774f607cfe Bluetooth: Audio: Ensure strtoX correctness in cap_acceptor.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
760e987529 Bluetooth: Audio: Ensure strtoX correctness in bap_scan_delegator.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
7bbddc14e3 Bluetooth: Audio: Ensure strtoX correctness in bap_broadcast_assistant.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
6fa4b00180 Bluetooth: Audio: Ensure strtoX correctness in audio.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Siddharth Chandrasekaran
011e784844 mgmt/osdp: More error handling and other cleanups
cp_build_command returns the length of the built packet and early
returns for errors. This means there is no need to keep track of return
code in a separate variable -- if we reached the end, we succeeded.

Along with this change, some more changes to enhance maintainability and
readability are also done.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
20f806de4e mgmt/osdp: cp: Rework CP state management
With changes to the phy layer and the way we build and dispatch
commands, we can now simplify some parts of CP state machine. This patch
builds on previous patches to reduce some state transitions and fixes
some bugs in those paths.

While at it, also implement an exponential back-off for PD offline after
a timeout. This is useful when there is a transient PD timeout but the
PD itself is not totally dead.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
d92c2e4ba1 mgmt/osdp: pd: Rework state machine to handle multiple packets
After the check_packet() split from decode_packet() for handling multiple
packets in the RX buffer, PD state machine needed to me modified to
start handling it correctly. While at it, simplify the states as PD does
not have as much state anyways.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
062a45ef35 mgmt/osdp: cp: Split build_packet and send_command
The method send_command was building the packet and also sending it.
This is a problem because even command build failures are reported as
command send failures; although the former can be mitigated by changing
kconfig parameters depending on use cases.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
ec53f2f6a8 mgmt/osdp: phy: Move packet checks out of decode_packet
To handle multiple packets in RX buffer, we need to perform checks on
the buffer first and determine the length of one packet and extact only
that many bytes from the RX buffer instead of pulling everything at
once and failing if there are bytes from the next packet in the buffer.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
b0cf5163d8 mgmt/osdp: cp: Move set PD online status to a method
When a PD is set online, we need to do other actions along with it. To
make this easier in future, move cp_set_state(pd, OSDP_CP_STATE_ONLINE)
to it's own method cp_set_online(pd).

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Jamie McCrae
1b4b979f87 mgmt: mcumgr: Change select to depends on in Kconfigs
Select in Kconfig causes many issues with dependency loops, this
resolves the issue by replacing most select with depends on for
MCUmgr, including updates to the sample smp_svr application and
tests.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 11:27:43 +01:00
Magdalena Kasenberg
e77b571ebd LE Audio: Fix response code expected by ASCS/SR/SPE/BI-18-C
When handling ASE Control operations requested by client,
first verify that the requested ID is within the allowed range.
If it does, lets assume that the NULL returned from ase_find()
means the ASE state is set to idle.

This will fix ASE Notification Response code expected by
the ASCS/SR/SPE/BI-18-C PTS test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 11:26:45 +01:00
Emil Gydesen
c0150c9ce5 Bluetooth: Audio: Ensure stream disconnect correctness for unicast client
Add a new function for the unicast client that verifies whether
or not the unicast client can terminate the CIS given the
state of any paired endpoint and the CIS state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
ad304697ab Bluetooth: Audio: Handle GATT/ISO race condition in unicast client
When releasing a stream causing the CIS to disconnect, there was
a race condition between the CIS disconnect event and the
idle state notification from the unicast server.

This ensures that if we are disconnecting a CIS as part of the
release, then we wait for the CIS disconnect event before calling
the "released" callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
d2dfc3c475 Bluetooth: Audio: Add addition ISO chan state check before disconnect
Add state check for BT_ISO_STATE_CONNECTING before disconnecting
the CIS, else we could end up in a race condition where we
did not disconnect the connecting CIS, and then still have
a CIS afterwards.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
984ce52ddb Bluetooth: ISO: Fix state checks for bt_iso_chan_disconnect
The behavior of bt_iso_chan_disconnect depends on the
state of the ISO channel.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
c67c7728a6 Bluetooth: Audio: Unicast client check ISO state before disconnect
Add a check to see if the ISO is connected before we attempt to
disconnect it. In the case where a stream was not in the streaming
state and was released, the CIS is unlikely to be connected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
fdc26eee78 Bluetooth: Audio: MCS reject long read if value changed
Add support for reject long read if a long value is
changed during the read.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
281d0a3fc8 Bluetooth: Audio: Add media player icon URL changed callback
Add support for notifying MCS a player icon URL change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
4d595014ab Bluetooth: Audio: Add media player name changed callback
Add support for notifying about a player name change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
89e907cb3d Bluetooth: Audio: Truncate MCS notifications per conn
When notifying a long (string) value in MCS, each
connection's MTU is taken into account when
(potentially) truncating the notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
788abf6811 Bluetooth: Audio: Fix truncation of MCS string notifications
The truncation of the MCS string notifications was incorrect.
As per the MCS specification, the MCS shall send ATT_MTU - 3
if the value cannot fit in the notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Sam Hurst
2d510fef8d usb_c: Notify DPM of Unsupported message reception
Notify the Device Policy Manager when an unsupported
message is received.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-02-20 11:24:07 +01:00
Robert Lubos
243af28a2f net: ipv4: Implement fallback to LL address
According to RFC3927, hosts with only IPv4 LL address should still be
able to send packets to destination w/o IPv4 LL address:

   A host with an IPv4 Link-Local address may send to a destination
   which does not have an IPv4 Link-Local address.  If the host is not
   multi-homed, the procedure is simple and unambiguous: Using ARP and
   forwarding directly to on-link destinations is the default route

This behaviour however was not possible with Zephyr, which only allowed
to use IPv4 LL source address for IPv4 LL destinations.

Fix this, by introducing a final fallback (only if IPv4 autoconf is
enabled), to select IPv4 LL address as a source address if no other
address is available.

Additionally, modify the ARP routine a bit if IPv4 LL address is in use.
There's no really point to forward the packet to gateway if IPv4 LL
address is used, as such addresses are not routable. Instead, try to
find the peer in local network in such case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-20 11:19:14 +01:00
Marco Argiolas
92a739e4b4 logging: shell command "disable" fails for "backend" subcommand
A fix to accept valid shell commands of the form `log backend
 shell_rtt_backend disable`, i.e. to affect all modules when no modules are
 specified.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-02-20 11:13:15 +01:00
Vinayak Kariappa Chettimada
3c0c9aca40 Bluetooth: Controller: Replace WFE use with k_cpu_atomic_idle()
Replace the use of WFE with Zephyr kernel supplied
k_cpu_atomic_idle() interface.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Vinayak Kariappa Chettimada
b46b833a7b Bluetooth: Controller: Reuse cpu_sleep interface
Reuse cpu_sleep() interface consistently in Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Vinayak Kariappa Chettimada
67fa62fe22 Bluetooth: Controller: Add a DSB in sleep interface
Add a DSB before doing WFE in cpu_sleep(), to ensure the
memory transactions are complete.

Add a note clarifying a dependency for the existing solution
(dependency is satisfied by ARCH code but is good to state
clearly).

Relates to commit f1264b7e47 ("drivers: entropy: nrf5: add
docs and a DSB in get_entropy_isr").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Jonathan Rico
3a9c825bab Net: Bluetooth: add enough room to user data
We need to make sure the user_data of the network buffer has enough room to
store the L2CAP metadata.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:53:51 +01:00
Jonathan Rico
2c00dd5fec Bluetooth: host: check net bufs have enough room in user_data
Since we accept buffers from external sources in L2CAP, we need to make
sure that we have enough room in user data to store the metadata necessary
for fragmentation over the HCI link.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:53:51 +01:00
Krishna T
b136676772 net: lib: zperf: Add support to disable Nagle's algorithm
This helps in benchmarking smaller packets, esp. as this is the default
behaviour of iperf.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 09:53:43 +01:00
Mingjie Shen
25e3f655f0 Bluetooth: L2CAP: Fix use of 'br_chan'
Assignment to br_chan should be placed after the call of server->accept().
Otherwise, br_chan will always be a null pointer.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-02-20 09:53:26 +01:00
Aleksandr Khromykh
dd1fc0dd03 Bluetooth: Mesh: fix access to uninitialized memory
Running bsim with Valgrind highlighted a couple of
places where read access to uninitialized memory happens.
Config client rewrites publication parameters with not
initialized uuid pointer. Bitfields those are allocated on
the stack keeps not used area uninitialized too.
Uninitialized area is stored in the persistent memory.
PR fixes that.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-02-20 09:53:14 +01:00
Jani Hirsimäki
f21051b728 net: iface: bypassing IP stack with SOCK_RAW sockets
Bypass the IP stack and go directly to L2 with
SOCK_RAW/IPPROTO_RAW sockets in net_if_send_data().

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2023-02-20 09:52:39 +01:00
Stig Bjørlykke
f3661487da settings: Make settings_subsys_init() thread safe
Multiple components may use the settings subsystem, so ensure
settings_subsys_init() is thread safe.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-20 09:52:26 +01:00
Aleksandr Khromykh
59edf5cae3 Bluetooth: Mesh: correction lpn rx delay
If extended advertiser is used, then advertiser sends callback
quite close to the real tx end time. No necessity to consider
advertisement time in lpn rx delay. It allows lpn to spend
less time in active scanning and save more power. Unfortunately,
legacy advertiser shows very slow precision. It is mandatory to
consider adv time for it. Additionally, unnecessary considering of
the advertisement duration has been removed for receive window in lpn.
It makes scanner window longer for a couple of milliseconds.
This is the responsibility of friend node to configure window that
it can manage.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-02-20 09:51:53 +01:00
Krishna T
92aa0e8ab6 net: shell: Log missing Ethernet errors
These error counters are helpful for data path debugging.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 09:51:23 +01:00
Sean Madigan
e79fee7a2e bluetooth: host: conn: Utilize conn_set_state in conn_destroy
Previously we would call conn_cleanup for all connections,
however this had multiple problems such as:
-Not destroying conn->tx_pending packets and causing an assert
-Calling conn_cleanup for connectable adv, triggering
disconnected callback

Now we will use bt_conn_set_state to manage the teardown of
connections correctly. First, if in connected or disconnecting,
set state to disconnect complete. Then for all states, set
state to disconnected. This will carry out proper cleanup
and teardown when required.

To do this, it was required to keep the tx_thread open as
this is used in disconnecting teardown, so this has been
moved to below the conn_cleanup_all call.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2023-02-20 09:50:48 +01:00
Jun Qing Zou
cd79b81d4d lib: tftp_client: Add TFTP PUT function
Add tftp_put() API to support TFTP WRITE request.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-20 09:50:23 +01:00
Jun Qing Zou
f7b0ccba0c lib: tftp_client: Receive file with arbitrary size
Add a callback for READ request to download files with arbitrary length.
Define TFTP_BLOCK_SIZE in API header for application to allocate buffer.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-20 09:50:23 +01:00
Mariusz Skamra
bfb2625818 Bluetooth: audio: has: Fix client context allocation
The client context shall be allocated once paired i.e. encryption is
enabled. This fixes issue that client context was allocated only for
bonded devices and as a result the ATT Unlikely Error was replied to
Control Point operation that paired remote requested.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-02-20 09:49:15 +01:00
Mariusz Skamra
668b40a5c2 Bluetooth: audio: has: Rename has_client struct member
This renames has_client.ntf_bonded to has_client.ntf_pending as this
field is valid for paired devices an contains the notification state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-02-20 09:49:15 +01:00
Magdalena Kasenberg
e26e8d1c07 shell: audio: Add print ASE info command
The command prints id, state and dir of all ASEs of default connection.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00
Magdalena Kasenberg
90ab1c56f5 LE Audio: Add helper functions to get endpoints info
The functions allow to return structure holding information of audio
stream endpoint.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00
Magdalena Kasenberg
5d2fb499af LE Audio: Allow server to initiate Codec Config procedure
Required by ASCS/SR/ACP/BV-07-C PTS test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00
Jamie McCrae
7c6f6cd080 fs: fs_shell: Add read test
Adds an optional shell command for testing the speed of the flash
device and file system, which outputs a rough speed for reading a
file.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 09:48:24 +01:00
Jamie McCrae
cef77afba5 fs: fs_shell: Add erase/write test
Adds an optional shell command for testing the speed of the flash
device and file system, which outputs a rough speed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 09:48:24 +01:00
Paul Adelsbach
4d8160d680 Bluetooth: host: suppress adv timeout warning when successful
The warning was visible even when `bt_le_adv_stop()` was successful, which
is confusing to end-users.

Signed-off-by: Paul Adelsbach <paul@boxsection.org>
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:48:17 +01:00
Emil Gydesen
277e162d82 Bluetooth: Audio: Avoid error log for bidirectional CIS
In the case that the CIS has been setup as bidirectional, and
only one of the directions have an ASE configured yet,
we should only care about valid ISO packets when doing this
check. The reason is that some controllers send HCI ISO data
packets to the host, even if no SDU was sent on the remote
side. This basically means that empty PDUs are sent to the
host as HCI ISO data packets, which we should just ignore.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 09:47:49 +01:00
Emil Gydesen
b9882e2368 Bluetooth: Audio: Guard ep status debug with debug stream data
In the unicast audio streams, there can be a mismatch
between the CIS state and the endpoint state. This
was previously logged, but since this would be logged
continously, we guard it with CONFIG_BT_AUDIO_DEBUG_STREAM_DATA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 09:47:49 +01:00
Ravi Dondaputi
1c547580e4 wifi: shell: Print beacon interval and DTIM period
Print beacon interval and DTIM period as part of Wi-Fi
status output.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-02-20 09:46:34 +01:00
Emil Gydesen
e71460cdb8 Bluetooth: Audio: Only allow receiver to send start command
Only the receiver of the audio is allowed to send the
receiver start ready command.

Furthermore, this removes the automated transition to the
streaming state on the server, as the server now shall
call bt_audio_stream_start to put the stream into the
streaming state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 09:45:18 +01:00
Dominik Ermel
1e0f36e896 fs/fatfs: Move FF_USE_LFN logic to Kconfig
Commit add hidden Kconfig option CONFIG_FS_FATFS_FF_USE_LFN
that is passed to ELM FAT to define FF_USE_LFN configuration.
The FF_USE_LFN still depends, indirectly, on choice
CONFIG_FS_FATFS_LFN_MODE config options
CONFIG_FS_FATFS_LFN_MODE_BSS, FS_FATFS_LFN_MODE_STACK and
FS_FATFS_LFN_MODE_HEAP, but the logic has been moved out of
zephyr_fatfs_config.h into Kconfig file.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-02-20 09:44:18 +01:00
Kumar Gala
5af7ff4558 Bluetooth: Mesh: Cfg_cli: Remove deprecated functions
Remove deprecated functions that have been deprecated for at least
two releases now.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-19 20:48:06 -05:00
Juha Ylinen
fdffdedc41 net: lwm2m: Add event LWM2M_RD_CLIENT_EVENT_REG_UPDATE
New event LWM2M_RD_CLIENT_EVENT_REG_UPDATE to indicate
application that engine starts registration update.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-02-19 20:44:02 -05:00
Rajavardhan Gundi
c71ab5699a tests: drivers: sbs_gauge: Include additional properties
Include tests for Fuel Gauge mode, status, charge current,
charge voltage, design capacity and design voltage.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2023-02-19 20:42:10 -05:00
Tommi Kangas
a25bcfdc59 shell: modules: kernel: add shell command for system heap stats
Added a shell command to print kernel system heap usage statistics.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2023-02-19 20:40:48 -05:00
Mikhail Siomin
b608ddc40f logging: the 'log backend' shell cmd will result in the infinite loop.
The backend_name_get() function always sets 'entry->syntax' to
the name of the last backend, but a calling function iterates
over the idx until 'entry->syntax' is null.
Solution: Added a check that the index is less than the number
of backends and added getting the name of the backend
by the given index.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
2023-02-19 20:37:53 -05:00
Robert Lubos
a28dba2503 net: ip: 6lo: Fix corner case with packet format after IPHC
IEEE802154 drivers expect, that a complete 802.15.4 frame fits into a
single net_buf provided in a net_pkt.

There is a corner case with header compression when this could not be
the case. If the IPv6 packet before IPHC exceeded 802.15.4 MTU, it'd
consist of several net_buf's. This was not an issue, if the IPv6 packet
after header compression still required fragmentation, as the
fragmentation module took care of formatting individual net_buf's
properly.

For short range of packet sizes however this was no the case. The IPv6
packet, after header compression, might not require fragmentation any
more. As the IPHC logic only modified the IPv6 header part, by trimming
the buffer in front of the net_buf, such a packet would still consist of
two net_bufs, even though it should fit into a single 15.4 frame. Such
packet was passed to the driver, causing the driver to send only part of
the packet, from the first net_buf.

Fix this, by using net_pkt functions to manipulate the packet, instead
of operating on net_buf directly. net_pkt_pull() will not trim the
buffer in front, but rather move the entire packet content to the front.
On the other hand, net_pkt_compact() will assure that there's no gaps in
the net_bufs. In result, packets that do not require fragmentation,
should be placed into a single net_buf, as expected by drivers.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-19 20:33:36 -05:00
Théo Battrel
ac3dec5212 Bluetooth: Host: Check returned value by LE_READ_BUFFER_SIZE
`rp->le_max_num` was passed unchecked into `k_sem_init()`, this could
lead to the value being uninitialized and an unknown behavior.

To fix that issue, the `rp->le_max_num` value is checked the same way as
`bt_dev.le.acl_mtu` was already checked. The same things has been done
for `rp->acl_max_num` and `rp->iso_max_num` in
`read_buffer_size_v2_complete()` function.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-02-18 00:09:13 +09:00
Marek Pieta
aed165df61 Bluetooth: host: Fix SC indication on encrypt change
The SC indication can be sent only if the GATT Service Changed is
enabled in the configuration. Change fixes build issues related to
implicit sc_indicate declaration when Service Changed is disabled.

Fixes: #54813

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Marek Pieta
32e534c935 Bluetooth: host: Remove GATT Client dependency for storing CCC and CF
Change removes GATT Client dependency for storing CCC and CF on pairing
complete and identity resolved. These features are needed also if GATT
Client role is disabled.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Jonathan Rico
a0614b6cd1 Bluetooth: host: save CF and CCC values written before bonding
On bond establishment: save the CF and CCC data that have been written
before the peer was bonded.

On identity resolved: update the CF data to use the peer's identity address
instead of its private address (same as is currently done for the CCC).

Fixes #54770.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Jonathan Rico
5d46a0c398 Bluetooth: host: fix subtle bug in db_hash_process
Fixes a bug introduced in the previous refactoring: we would always mark
all peers as change-unaware. Now we only do so when the hash has been
recalculated.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Jonathan Rico
2a15a63509 Bluetooth: host: don't store hash in db_hash_gen()
Move out the storage of the calculated hash from the fn that calculates
it (db_hash_gen).

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Jonathan Rico
b60b0f3505 Bluetooth: host: don't overwrite GATT DB hash before settings_load
Previously, if the app registered a bunch of services at boot before
calling `settings_load()`, then the hash would be silently overwritten.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Jonathan Rico
e8f3ef29a4 Bluetooth: host: store GATT change-aware status in settings
The spec says we have to persist the change-aware status of bonded peers
between resets.
This stores it at the end of the CF storage that we currently have.

Fixes #54173

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Jonathan Rico
4772e5695f Bluetooth: host: Store Client Supported Features on write
Store the Client supported features value when it is written to, instead of
only on disconnection/identity resolved.

Works around the situation where a user bonds, CF is written and the device
is abruptly powered off, discarding the CF value, but keeping the bond.

Fixes #54172.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Magdalena Kasenberg
3c00629bb6 LE Audio: Map EALREADY error of ase_stream_qos()
to send response with code 0x09 = Invalid Configuration Parameter
Value and reason 0x0a = Invalid_ASE_CIS_Mapping.

Previous response code was BT_ASCS_RSP_UNSPECIFIED (0x0e) and
reason BT_ASCS_REASON_NONE (0x00).

Fixes ASCS/SR/SPE/BI-15-C and ASCS/SR/SPE/BI-16-C PTS test cases.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-11 08:21:13 +09:00
Georgij Cernysiov
d7cf297d98 usb: device: class: rndis: remove CDC descriptors
RNDIS is not a CDC class.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-11 08:19:32 +09:00
Georgij Cernysiov
3055a8326d usb: device: class: rndis: correct IAD and IF0 descriptors
Use descriptors as dictated by Microsoft and USB-IF.
That allows the RNDIS device to be correctly detected on Windows.

* Microsoft: https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/supported-usb-classes
* USB-IF Defined Class Codes: https://www.usb.org/defined-class-codes

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-02-11 08:19:32 +09:00
Georgij Cernysiov
fd1f28efb6 usb: device: class: rndis: correct packet reception
Allows receive packets that are bigger than
CONFIG_RNDIS_BULK_EP_MPS.

Considering:
* MaxPacketsPerTransfer is 1
* MaxTransferSize is 1558
* PacketAlignmentFactor is 0 (20=1)

The rndis_bulk_out shall be able to receive transfer
up to 1558 bytes (inclusive).

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-02-10 15:34:05 +01:00
Morten Priess
3712094417 Bluetooth: controller: Fix CIS establishment procedures
Fixing typo in llcp_lp_cc_established revealed the need for completing
the CIS establishment procedure by additional call to local/remote
check_done function.

Fixed by exposing lr_check_done and rr_check_done with naming update and
calling after injecting the CIS_ESTABLISHED event.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-02-10 15:28:35 +01:00
Morten Priess
98161bd1d3 Bluetooth: controller: Enable CIS establishment in same ACL instant
If CIS offset in LL_CIS_IND is less than EVENT_OVERHEAD_START_US, the
controller is not able to establish the CIS in the ACL connection event
specified, but needs to start setup one connection event earlier.

With this commit, if offset is larger than EVENT_OVERHEAD_START_US the
first CIS event can be prepared in due time immediately.

This enables the controller to setup first CIS, even when instant is
equal to the ACL event_counter.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-02-10 15:28:35 +01:00
Vinayak Kariappa Chettimada
220170a549 Bluetooth: Controller: Fix Periodic Advertising time reservation
Fix Periodic Advertising time reservation when enabling with
ADI support. As the PDU is updated, use the updated PDU to
calculate the time reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
1ed9bda92d Bluetooth: Controller: Schedule BIG event after Periodic Advertising
Add implementation to schedule BIG events after Periodic
Advertising when Periodic Advertising is enabled after
Extended Advertising has already been enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
2ae86f4e8d Bluetooth: Controller: Use context specific get interface
As the range of ticker_id has been checked, context specific
get interface be used instead of doing range check again in
ull_hdr_get_cb().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
d93bc9dbd8 Bluetooth: Controller: Fix auxiliary PDU time reservation calculation
Fix auxiliary PDU time reservation calculation to reserve
for possible increase in PDU len due to updates to data in
the Common Extended Header Format of the PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
f4a0543bf4 Bluetooth: Controller: Refactor duplicate aux_time_get implementation
Refactor duplicate aux_time_get() implementation and reuse
the same code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
82ad0777c0 Bluetooth: Controller: Minor rename to sync_time_get()
Minor rename of file static function sync_time_get().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
2fabaf37ef Bluetooth: Controller: Fix assertion scheduling first BIG event
Fix assertion due to delayed prepare of first BIG event when
supporting encryption. Crypto calculation introduce extra
processing delay causing the scheduling of first BIG event
to be delayed. Detect such delay and skip to next ISO
interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
6dbe82a7db Bluetooth: Controller: Relax radio_tmr_start_us assert on win widening
Relax radio_tmr_start_us() delayed start assertion when
window widening in progress.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
11cfd8acc3 Bluetooth: Controller: Fix radio_tmr_aa_save() value for ISO receive
Fix the access address and radio ready timestamp to derive
the value of the first subevent, so that correct anchor
point reference is used in scheduling subsequent subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
64979d7b6b Bluetooth: Controller: Fix uninitialized CIS LLL member variables
Fix uninitialized CIS LLL structure member variables,
uninitialised CIS acl_handle causes HCI command disallowed
for acl_handle's other than 0x0000.
Initialize other variables like sn, nesn etc. when create
CIS control procedure is performed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
09897e2c8d Bluetooth: Controller: Fix GPIO debug pins for ISO Central
Fix the GPIO debug pin assignment for ISO central role.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Jamie McCrae
fce2cadcde shell: backend: Set RX size default to 256 if shell MCUmgr is enabled
This fixes an issue whereby when USB CDC is used for receiving MCUmgr
commands, the commands are corrupted, invalid or messed up by
increasing the receive buffer size so that it can handle at least 1
full MCUmgr fragment.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-10 22:25:21 +09:00
Herman Berget
cc9d2102f2 Bluetooth: Fix enabling PAST as advertiser
It is possible to do PAST as advertiser without support for periodic sync.

Fixes #54613.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-02-09 13:22:57 +01:00
Pierce Lowe
ba09a252ec bluetooth: host: refactor bt_hci_le_per_adv_report data reassembly
Refactoring the periodic advertisment report receive function
to make the handling of data reassembly more readable.

Signed-off-by: Pierce Lowe <pierce.lowe@nordicsemi.no>
2023-02-09 13:12:24 +01:00
Pierce Lowe
a7c1c27e38 bluetooth: host: drop incomplete data in periodic scanner
This changes the periodic scanner to drop periodic adv
reports with incomplete data. This avoids incorrect data
being sent to application in the case where the periodic
adv data is not successfully received by the scanner.

Fixes zephyrproject-rtos#54072

Signed-off-by: Pierce Lowe <pierce.lowe@nordicsemi.no>
2023-02-09 13:12:24 +01:00
Szymon Czapracki
6c374215d0 bluetooth: audio: Fix typo in PACS
A simple typo fix.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-02-09 13:09:46 +01:00
Robert Lubos
05ca67c9ba net: ipv6: mld: Don't attempt to send a MLD query if iface is down
Simply return early returning respective error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-08 11:26:42 +01:00
Robert Lubos
e8803ddaae net: dhcpv4: Do not proceed with DHCPv4 when interface is down
It should be possible to configure/initialize the DHCPv4 for an
interface when the interface is down, the DHCPv4 however should not
proceed with the procedure in such case.

Add a simple check to prevent DHCPv4 from sending packets when interface
is down. As the module registers to the NET_IF_UP event, the procedure
will be restarted when the interface goes up.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-08 11:26:42 +01:00
Robert Lubos
004955f715 net: config: Unify the init behaviour when timeout is enabled and not
Currently, if timeout is not configured for the network initialization in
the config module, the initialization function will configure IPv4/IPv6/
DHCPv4 regardless of the interface status. This is not the case when the
timeout is set, and the interface was not brought up during the timeout
period. This lead to ambiguity in terms of interface initialization.

This commits unifies the behaviour between these two cases. The
aforementioned initializations will always take place, regardless of the
interface status. The IPv4/IPv6 and DHCPv4 routines should be prepared
to deal with interfaces that are not brought up. The only difference
now, between timeout and no timeout scenario, is that the former will
report an error in case the timeout occurs wile waiting for the expected
events.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-08 11:26:42 +01:00
Seppo Takalo
437bfc58d9 net: lwm2m: Fix deregistration timeout state handling
Socket faults or timeouts in CoAP deregistration messages
caused RD client state machine to restart registration.

Fixes #54136

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-08 11:20:00 +01:00
Ryan Erickson
d19e99b6d7 net: DHCPv4: Filter NAK during requesting state
During the requesting state, ignore NAKs from any
non-requesting server.  This gives the requesting
server a chance to ACK the request.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-08 19:05:13 +09:00
Johan Hedberg
9c459b33fb Bluetooth: SMP: Fix setting key distribution bits for no-bonding
9.4.2 section, Part C, Vol 3 of the Bluetooth Core specification v5.3
states the following in the case that the device is in non-bondable
mode:

If Security Manager pairing is supported, the Host shall set the
Bonding_Flags to ‘No Bonding’ as defined in [Vol 3] Part H, Section
3.5.1 and bonding information shall not be exchanged or stored.

Fixes #54104

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-02-08 19:04:51 +09:00
Chris Friedt
c093678784 net: sockets: fix fcntl.h usage
If we are using `CONFIG_ARCH_POSIX`, then include
`<fcntl.h>`. Otherwise, include `<zephyr/posix/fcntl.h>`
since there are no requirements to use `CONFIG_POSIX_API`
internally.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-08 19:04:25 +09:00
Chris Friedt
ac3efe70cd net: sockets: socketpair: header fixups
* include `<zephyr/posix/fcntl.h>` instead of `<fcntl.h>`
* drop unused logging header and module declaration
* reorder headers alphabetically

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-08 19:04:25 +09:00
Wolfgang Puffitsch
c8c81d28b7 Bluetooth: controller: Only allow supported feature bits to be set by host
Redefine mask of host-controlled feature bits to include only features
that are supported by the controller. This fixes a conformance test
failure where setting an unsupported host-controlled feature bit was
not rejected as it should.

Set the Connected Isochronous Streams (Host Support) bit from the host
only if unicast support is configured to avoid failures in
broadcast-only configurations.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2023-02-08 01:16:10 +09:00
Théo Battrel
6dfe5b0e9c Bluetooth: Small fixes for some Bluetooth Shell commands
Update help message of some commands of the Bluetooth Shell that were
inconsistent.

Also add the `dir-rpa` parameter to the advertiser parameters to fully
support directed advertisment parameters.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-02-07 11:58:00 +01:00
Vinayak Kariappa Chettimada
3d54d46bbc Bluetooth: Controller: Fix Central from overlapping BIG events
Fix advanced scheduling to consider active BIG events when
establishing new Central connections. This will schedule
AUX_ADV_IND, AUX_SYNC_IND and Central connections of similar
interval to be non-overlapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-06 22:06:16 +09:00
Vinayak Kariappa Chettimada
d91b20dd3f Bluetooth: Controller: Fix overlapping multiple BIG events
Update advanced scheduling implementation to consider other
active BIG events when scheduling new BIG instances.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-06 22:05:40 +09:00
Emil Gydesen
9d3e287572 Bluetooth: Audio: Fix ASCS CP subscribe in discovery
During discovery the unicast client subscribes to the
ASCS CP characteristic. However, this was done asynchronously
at the end of the discovery, and the discovery complete
callback was called before the subscription was done.

Since the unicast client relies on the auto CCC discovery,
the actual subscription takes place a few connection intervals
after the unicast_client_ep_set_cp function was called. The
result of this is that the actual subscription was missing
when the unicast client application starts performing
BAP operations.

The change done here postpones the discovery callback
until after the CP subscription has taken place, ensuring
that the unicast client correctly receives the CP notifications
when performing BAP operations. This also allows the unicast
client to use the discovery parameter in the
bt_audio_discover_params struct, rather than yet another
discovery parameter struct, saving some memory.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-06 22:05:15 +09:00
Robert Lubos
f39ba57474 net: ipv4: Fix subnet mask setting when autoconf is used
When IPv4 autoconf is enabled and IPv4 LL address is configured on an
interface, the subnet mask should be updated accordingly, otherwise it
can lead to unexpected behaviour (like for example not identifying peer
LL address as a part of the same subnet).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-06 10:10:54 +01:00
Lingao Meng
b3eeb91869 Bluetooth: Mesh: Remove meaningless condition
Since `schedule_send` always have no-null params.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-02-06 10:08:22 +01:00
Krishna T
8069d47c5e net: pkt: Allow zero payload for non-IPv4/v6 frames
For socket families that are niether INET/INET6 e.g., PACKET, we cannot
estimate header length, so, if the payload is zero as well, networking
stack drop the packet.

Instead, allow for zero header + payload packets and let L2 take care of
handling them, for some L2's this is still a valid frame.

E..g, In case of Wi-Fi this is sent as 802.11 Header + LLC Header
(no payload).

Add unittests for both AF_INET + Zero payload and AF_PACKET + Zero
payload.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-06 10:04:03 +01:00
Emil Gydesen
c4d80f7760 Bluetooth: Audio: Shell: Fix issue with setting contexts
There was a bug where BT_AUDIO_DIR_SINK should have been
BT_AUDIO_DIR_SOURCE when setting supported contexts.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-06 10:03:43 +01:00
Andrei Emeltchenko
250f212688 modbus: Remove redundant check
ctx is the result of pointer math and never NULL.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-02-06 10:03:20 +01:00
Lukas Woodtli
6a5260394b net: coap: Allow insertion of an option at arbitrary position
The insertion moves the data in the message buffer to make space for
the new option.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-02-06 10:02:19 +01:00
Robert Lubos
432ff20a72 net: websockets: Fix websocket close procedure
The websocket implementation did not comply with the RFC 6455 when it
comes to connection close. The websocket should send in such case Close
control frame. This commit fixes this behaviour.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-03 10:37:57 -08:00
Robert Lubos
7f0219985d net: websockets: Fix ZFD_IOCTL_SET_LOCK handling
The websocket "socket" layer did not handle ZFD_IOCTL_SET_LOCK command,
and just forwarded it to the underlying socket. This overwritten the
mutex pointer used by the underlying socket, resulting in erroneous
behaviour in certain cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-03 10:37:57 -08:00
Vinayak Kariappa Chettimada
f00da4b0d4 Bluetooth: Controller: Fix ISO Data sn nesn on flush
Fix sn and nesn values of ISO data when starting a new burst.
When central retransmitted but did not get an ack, it did
not update the sn correctly causing the peripheral to drop
the next ISO data PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-03 20:54:20 +09:00
Vinayak Kariappa Chettimada
278b07c971 Bluetooth: Controller: Fix addr type in PA sync established event
The address type in the periodic adveritising sync
established event is incorrectly set to 0x01
(BT_ADDR_LE_RANDOM) when the address is a resolved one,
where it should have been BT_ADDR_LE_RANDOM_ID.

The address type has been fixed by offsetting by 2 to get
BT_ADDR_LE_PUBLIC_ID or BT_ADDR_LE_RANDOM_ID when the
address has been resolved.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-03 02:26:42 +09:00
Armin Brauns
22430ef8c4 net: ipv6_nbr: count outgoing ND packets as sent ICMP packets
This mirrors the behaviour of MLD packets, the only other ICMPv6 subtype
that is tracked separately.

Inbound ND packets are already counted as received ICMP packets by way of
going through the ICMP receive path.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-02-03 02:25:14 +09:00
Armin Brauns
abd4dd4cc5 net: ipv6_nbr: don't count incoming Neighbour Advertisements in sent stats
This caused outgoing MAC address lookups to count as one received and two
sent Neighbour Discovery packets, when it's really one sent Neighbour
Solicitation and one received Neighbour Advertisement.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-02-03 02:25:14 +09:00
Robert Lubos
e540a98331 net: shell: Validate pointer provided with net pkt command
The net_pkt pointer provided to net pkt commands was not validated in
any way. Therefore it was fairly easy to crash an application by
providing invalid address.

This commit adds the pointer validation. It's checked whether the
pointer provided belongs to any net_pkt pools known to the net stack,
and if the pointer offset within the slab actually points to the
beginning of the net_pkt structure.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-03 02:14:32 +09:00
Jonathan Rico
c2e4029aad Bluetooth: host: resume advertising even when BT_EXT_ADV=y
When using extended advertising commands, the advertising set is not
considered to be over until we receive `BT_HCI_EVT_LE_ADV_SET_TERMINATED`
from the controller. Only then do we clear the `BT_ADV_ENABLED` flag.

The problem is that `bt_le_adv_resume` is called on connection established,
which can happen before adv set terminated, and in that case it will
early-return because `BT_ADV_ENABLED` is still set.

This change triggers `bt_le_adv_resume` when we get
`BT_HCI_EVT_LE_ADV_SET_TERMINATED`.

Fixes #53048

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-02 17:05:48 +02:00
Peter Mitsis
cbc3e5c999 tracing: Add event tracing to sysview
Adds event tracing to sysview. This will allow the event related
tracing symbols to be found when CONFIG_SEGGER_SYSTEMVIEW is
enabled.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-02-02 20:21:12 +09:00
Peter Mitsis
bdb49f21ad tracing: Resolve undefined event symbols
Fixes various unresolved symbols when kernel event object tracking
is enabled via CONFIG_TRACING=y.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-02-02 20:21:12 +09:00
Seppo Takalo
d0dc67a72d net: lwm2m: Fix native_posix fcntl() calls
Native POSIX target still needs to use the <fcntl.h> header
instead of <zephyr/posix/fcntl.h>

Also removed the include from various files that did not use it.

Also changed fcntl() calls to zsock_fcntl() because we directly
use zsock_* calls elsewhere.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-02 20:05:08 +09:00
Vinayak Kariappa Chettimada
de2029ac58 Bluetooth: Controller: Fix missing DF related radio register reset
Fix missing DF related Radio register reset on radio_reset().

Regression in commit 465a96181d ("Bluetooth: Controller:
Explicitly set all bits of used radio registers") due to the
removal of NRF_RADIO->POWER register use that was used to
reset all Radio registers on every new Radio Event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-02 11:15:44 +01:00
Andrei Emeltchenko
f9ced67170 bluetooth: audio: Fix dereference before NULL check
Dereference only after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-30 23:47:55 +00:00
Andrei Emeltchenko
2782d6996a bluetooth: Fix duplicated parameter check
Parameter count is checked several lines below this line.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-30 23:47:55 +00:00
Andrei Emeltchenko
dcb199f581 bluetooth: audio: Fix NULL dereference
Fixes NULL dereference right after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-30 23:46:25 +00:00
Emil Gydesen
8512bd18c6 Bluetooth: Shell: Fix unintialized ad_len bug
`ad_len` was never initiatialized before we started
incremetenting and using it.

We would also override any user data in ad_init, which
is fixed by using the length of the user data as an
offset into the array.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-30 10:08:00 +00:00
Jared Baumann
5a62f2592f net: lib: Fix build warning for sockets_tls
Fixes issue where a build warning would be emmited for sockets_tls.c due
to usage of the deprecated fcntl.h header file.

Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
2023-01-28 08:01:03 -05:00
Andrei Emeltchenko
62ab576a6a logging: shell: Fix using uninitialized variables
Fixes using uninitialized variables using returns with correct return
code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-28 08:55:41 +09:00
Seppo Takalo
ec8884d58f net: lwm2m: lwm2m_client: Fix fcntl header path
We don't default to POSIX_API so use Zephyr's
path for fcntl.h

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-01-27 10:41:19 -06:00
Andrei Emeltchenko
8e72f117e3 net: ieee802154: Remove unneeded check
Fixes dead code warning. At this point we have already checked for
broadcast and it is set to false.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-27 10:38:49 -06:00
Andrei Emeltchenko
3c8c903a2d net: ieee802154: Fix dereference before NULL check
Fixes dereference of sec_ctx->level before checking sec_ctx for NULL.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-27 10:38:49 -06:00
Johann Fischer
9ea25d85cf usb: device_next: update bMaxPacketSize0 based on controller capability
Update bMaxPacketSize0 field of the device descriptor based on
controller capability.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-27 16:11:20 +01:00
Johann Fischer
5c60209e79 usb: device_next: trigger dequeue of control IN endpoint on reset event
There might be pending data stage transfer not finished
while host performs a bus reset.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-27 16:11:20 +01:00
Vinayak Kariappa Chettimada
595860567b Bluetooth: Controller: Workaround sequence number misalignment
Workaround sequence number misalignment to ISO event count
when ISO data is supplied in bursts, example through USB.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
6dfbf7c110 Bluetooth: Remove BT_HCI_DATAPATH_ID_DISABLED define
Remove BT_HCI_DATAPATH_ID_DISABLED define as 0xFF, which is
reserved for future value for Data_Path_Id parameter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
3a37834aa7 Bluetooth: Controller: Add ISO Broadcast and Receive ISR Profiling
Add implementation to generate ISR profiling of Broadcast
ISO and ISO Receive usecase.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Carl Stehle
714f80d225 Bluetooth: Controller: Integrate ISOAL for ISO Broadcast
- Include ISO stream count in ISO streams definitions in
  controller.
- Create ISOAL source on controller when ISO data path is
  setup.
- Send broadcast data buffers transferred from host over
  HCI to ISOAL as ISO SDU fragments.
- Allow bot conn and ISO data to use data_buf_overflow.
- Store ISO interval during BIG create.
- Remove ISO data path for each BIS during BIG terminate
  procedure.
- Set value (temporarily) for ISOAL target_event enabling
  it to Tx data.
- Check status of data fragment sent to ISOAL for memory
  allocation and other errors.
- Destroy ISOAL source when ISO stream released.
- Use ISO Advertising handle, not stream handle to destroy
  ISO data path.
- Remove extra ISOAL sink destroy call when removing ISO
  data path.
- Add FIXME comment as reminder to address LL_ASSERT on
  isoal_status error.

Signed-off-by: Carl Stehle <droid@appception.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
532cf9ba2b Bluetooth: Controller: Fix ISO interval based on Max Transport Latency
Fix calculation of ISO interval such that multiple bursts
can be transmitted per ISO interval. This means we can now
have SDU_Interval < ISO_Interval and more than one SDU will
be transmitted in each ISO_Interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
5fbb3bf42b Bluetooth: Controller: Fix BIS Control PDU being dispatched as ISO Data
Fix missing jump to Rx ISR done that caused the Control PDU
to be enqueued as ISO data PDU, causing the ISOAL to assert
on receiving invalid LLID.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
c32ff9608b Bluetooth: Controller: Fix ISO timestamp wrap around
Fix ISO timestamp wrap around which caused ISOAL to assert
checking for valid timestamp.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
27206e17af Bluetooth: Controller: Initial CIG with 1 CIS support in LLL
Add initial support for CIG with 1 CIS in nRF5 SoC's LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
9d01c16c47 Bluetooth: Controller: Define a internal BT_CTLR_ISO_TX_BUFFERS
Define a internal BT_CTLR_ISO_TX_BUFFERS to allocate ISO Tx
buffers used for Broadcast and Connected ISO.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
479ba351d2 Bluetooth: Controller: Fix Ctrl to Host flow control assertion
Fix Controller to Host flow control assertion handling ISO
stream disconnection.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
069a7c0cbd Bluetooth: Controller: Fix isoal_tx_pdu_emit/source_deallocate race
Fix race between isoal_source_deallocate() and
isoal_tx_pdu_emit(). Initiating a local initiated terminate
triggers NULL pointer dereference.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
cd2796e047 Bluetooth: Controller: Refactor ll_setup_iso_path
Refactor ll_setup_iso_path to support Synchronous Receiver
and Connected ISO to be built together.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
362826ea03 Bluetooth: Controller: Code review rework changes
Assorted code review rework changes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
4f36f95e5f Bluetooth: Controller: Fix uninitialized CIG ULL reference count
Fix uninitialized CIG ULL reference count when creating a
CIG after a previous disconnection.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
ab89f7d1e6 Bluetooth: Controller: Fix CIS and CIG teardown
Fix CIS and CIG teardown in Central and Peripheral Role.
cig->lll.num_cis value is used in peripheral role to count
active CISes, and cig->cis_count is used in central role.
Both central and peripheral will stop ticker for CIG when
num_cis and/or cis_count is zero, respectively, but only
peripheral role will release a CIG context. The Central
will keep the CIG context allocated and only mark it as
not started. Remove CIG command will be used for central
role to release a CIG context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
19c80b1020 Bluetooth: Controller: Fix CIS ISO Tx buffer leak on terminate
Fix CIS ISO Tx buffer leak on terminate when the datapath
has been deallocated.

Add a FIXME comment regarding ll_tx_ack_put() being called
from LLL execution context, while it is a ULL callable used
by ACL connections to dispatch ack.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
c7724f00e5 Bluetooth: Controller: Fix k_is_in_isr() assert calling util_aa_le32()
Do not call util_aa_le32() from ISR context as random number
generation in entropy driver on nRF5x series invokes
k_sem_take.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
93f9d9bc6d Bluetooth: Controller: Fix assertion on link_tx_free on CIS re-create
Fix assertion check on link_tx_free when CIS is created a
second time. The Tx mem queue has to be initialized on every
new CIS create as CIS disconnect does the deinitialization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
e5d9ad17bb Bluetooth: Controller: Reorder the functions in ull_central_iso file
Reorder the functions in ull_central_iso file to match the
order of HCI commands in the BT Spec.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
00e31f5e65 Bluetooth: Controller: Workaround datapath field access after release
Workaround the access that check if datapath is NULL when
the stream has already been released. Memory Pool overwrites
first 8 bytes to maintain the free list and free count. This
causes the datapath fields if placed in the first 8 bytes to
not be NULL after the memory is freed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
bb92b018dd Bluetooth: Controller: Code to generate ISO data buffer overflow event
Add code to generate ISO data buffer overflow event if more
than allocated ISO data PDU buffers are tried to be
requested by host or for SDU fragmentation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
8cf58edb8b Bluetooth: Controller: Use instant_latency to detect event skipped
Use instant_latency at the CIG start event count to detect
skipped connection event around the instant. In the future
add implementation to compensate for skipped ACL connection
event and adjust the CIS event count at CIG start.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
149f857f8a Bluetooth: Controller: Reuse ull_conn_event_counter() in LLCP
Reuse ull_conn_event_counter() function in LLCP
implementation to get the current radio event counter value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
aba5176340 Bluetooth: Controller: Fix CIG offset and add time reservations
Fix CIG offset such that it follows after the ACL connection
time reservation to avoid overlapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
b16e5baf80 Bluetooth: Controller: Rename to trx_performed_bitmap
Rename trx_performed_mask to trx_performed_bitmap and add
conditional compilation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
a155b3b37d Bluetooth: Controller: Add LLL required ULL interfaces
Add LLL interfaces implemented by ULL to get group by stream
and to get stream by group iterator functions.
Rename function to set CIS established to reflect that it is
LLL accessible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
53db4a0b1d Bluetooth: Controller: Fix channel indices calculaton cond compile
Fix channel indices calculation implementations conditional
compile so that it can be reused for Connection ISO events
and subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
6f0b6ec90b Bluetooth: Controller: Fix ISO Buffer allocation for SDU fragmentation
Fix ISO Tx Buffer allocation counts considering required SDU
fragmentations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
a949fa7250 Bluetooth: Controller: Use define for packet timer capture
Use the sample capture index define for capturing packet
timer timestamp.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
9119e817fa Bluetooth: Controller: Separate Tx and Rx packet timer status reset
Add interface to have separate Tx and Rx packet timer status
reset, so that packet timer can be setup ahead in time for
starting the Tx or Rx subevent and status reset only clears
the respective PPI/DPPI that was used when Tx or Rx
completes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
bcc4fa4f44 Bluetooth: Controller: Use spec. defined abbrev. for nse, bn, and ft
Use BT Spec. defined abbreviations for number of subevents
(nse), burst number (bn), flush timeout (ft) etc.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
9456a0ecd9 Bluetooth: Controller: List Central and Peripheral ISO supported
Update Kconfig to list Central and Peripheral ISO as
supported. Will continue to be listed as Experimental.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
efd80f4ec1 Bluetooth: Controller: Add conditional compiles for Peripheral ISO
Add conditional compilation for Peripheral ISO support,
use CONFIG_BT_CTLR_PERIPHERAL_ISO.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
863fc7373b Bluetooth: Controller: Re-arrange include in ull_peripheral_iso file
Re-arrange include in ull_peripheral_iso file to be
consistent with other similar files (ull_central_iso).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
5398ae0710 Bluetooth: Controller: Add LL_CIS_HANDLE_LAST, IDX_FROM_HANDLE define
Rename LAST_VALID_CIS_HANDLE to LL_CIS_HANDLE_LAST, to be
consistent naming with LL_CIS_HANDLE_BASE.
Add IDX_FROM_HANDLE defines.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
8e48de8f58 Bluetooth: Controller: Minor refactor of Connected ISO group and stream
Refactor the Connected ISO group and Connected ISO stream
context to be consistent in defining the bitfields and also
rearrange structure members.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
66834e9860 Bluetooth: Controller: Fix missing BT_LL_SW_LLCP_LEGACY cond compile
Fix missing BT_LL_SW_LLCP_LEGACY cond compile causing
compile error when building Peripheral ISO samples with
legacy control procedure implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Siddharth Chandrasekaran
ac9510230b mgmt/osdp: Use memcpy instead of raw loops in many places
This patch replaces many instances where raw loops were used to copy bytes
with memcpy calls.

No functional change intended.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
4386dc355b mgmt/osdp: pd: Fix device capabilities report
Do not check or send the first entry in the pd->cp[] device capability
table which is for function code 0 which is not a defined function code.

Signed-off-by: David Vucich <dave@alcatraz.ai>
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
39bf1264e9 mgmt/osdp: pd: Fix error reply code for CMD_KEYSET
By default, on errors, pd_decode_command replies with osdp_NAK with
sub-error code set to OSDP_PD_NAK_CMD_LEN (achieved using the ret ==
OSDP_PD_ERR_GENERIC check before return). This is works for all packet
framing errors; but when a more specific error code needs to be sent, ret
has to be set to something other than OSDP_PD_ERR_GENERIC (a suitable error
code happens to be OSDP_PD_ERR_REPLY) to prevent the tail check from
overwriting the error info.

In CMD_KEYSET, we fill a more specific error code but do not set the ret to
OSDP_PD_ERR_REPLY. It causes this error to be reported as a framing
error hence loosing some extended info about the error. Fix this issue by
reordering the checks a bit.

Fixes: 7f4d2c741b "mgmt/osdp: Add support for Secure Channel"
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
7f70d5e0e0 mgmt/osdp: Remove unused STR() macro
Initially, subsys/mgmt had its own STR() macro for string pasting which was
replaced with the zephry provided STRINGIFY(). The definition of this macro
seems to have lingered on so remove it.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
514ccabc44 mgmt/osdp: phy: Catch out-of-order SC packets and fail
During handshake, only certain types of secure block types (<= SCS_14)
are allowed. A rouge CP/PD can try to bypass the handshake by directly
sending a secure block type ahead of the sequence and gain a secure
channel. Fix this by adding a check in packet decode time.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
a233dea285 mgmt/osdp: phy: Rework MARK byte handling
OSDP specification section 5.7 states that a transmitting device has to
drive the transmission line to a marking state for a period of one char
in the current baud rate. This can be achieved by sending 0xFF. Since
this is not mentioned in the packet structure definition, many commercial
implementations of OSDP out in the wild do not send/expect this byte.

To work with such non-conforming devices, we will try to be as flexible
as possible in the PD: send mark byte only if the other side sent one. In
case of CP, we have no option but to send the mark byte to be as close
to the specification as possible. If a particular use case needs the CP
to not send it, we will provide a Kconfig option to disable it.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
d44bdb50f0 mgmt/osdp: pd: Add support for key press and card read events
Now that we have the necessary infrastructure to collect events from PD
apps, we can use them to translate it to OSDP packet sequence for card
reads and key press events.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
c9e64e0dd9 mgmt/osdp: pd: Add capability checks on incoming commands
OSDP compliant devices communicate their capabilities and discover what
their peer can and cannot do. Right now, PD advertises these capabilities
and expects CP to honor them. Although this is not known to cause any
issues, it is not desirable to allow such accesses.

Add a check of incoming commands to to validate that the corresponding
capability was enabled and advertised.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
a369bf7f08 mgmt/osdp: Rename cmd_data as ephemeral_data
Since cmd_data member is used by both commands and events to store the
contents of current transaction, rename it to ephemeral_data which
better reflects the purpose of the variable.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Robert Lubos
4234e801b5 net: sockets: Fix TLS_HOSTNAME option length inconsistency
The TLS_HOSTNAME socket option expects a NULL terminated string and
doesn't really care about the optlen provided. However, as the option
expects that the string is NULL terminated, the optlen value should take
NULL character into account, for consistency across the codebase.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-27 19:23:36 +09:00
Théo Battrel
7f9cd24814 Bluetooth: Stop sending SMP PDUs outside of pairing procedure
Stop sending the unnecessary 'pairing failed' SMP PDUs outside of the
pairing procedure.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-01-27 19:23:03 +09:00
Troels Nilsson
9f92dff354 Bluetooth: controller: Fix issue with duration/max number of adverts
When a maximum duration or number of advertisements has been set for an
advertisement set, we will exceed that limit if the last advertisements
happen to be overlapping (ie. we have two primary advertisements pointing
to the same AUX_ADV_IND).

We now have a check in the ticker_cb that will ignore the callback if the
state is such that advertisement would have been stopped if ull_adv_done()
had been allowed to run in the meantime.

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-01-27 19:22:30 +09:00
Emil Gydesen
e5890fc779 Bluetooth: Audio: Broadcast source reconfigure missing streaming QoS
When executing the bt_audio_broadcast_source_reconfig the streams
did not get assigned the new QoS, the ISO parameters were not
properly updated and the codec was not set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-27 18:10:34 +09:00
Nicolas Pitre
d7f9e26433 rand32_timer: make it more random-like for tests to pass
I get a high failure rate for tests/kernel/mem_protect/stack_random
because the default rand32_timer used with QEMU is just too mediocre.
Make it more random looking.

Reference: https://nuclear.llnl.gov/CNP/rng/rngman/node4.html

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-27 17:38:26 +09:00
Emil Gydesen
3ead1cfa2c Bluetooth: Audio: Call stream released on ACL disconnect
If the ACL disconnects, then the unicast server cannot send
a notification to the client about the endpoint and
stream being released. We now call the released callback
if the stream's endpoint was not idle before the disconnection.

Similarly the unicast server (ASCS) did also not call the
released callback if the ACL disconnection causes a endpoint
release.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-27 17:35:51 +09:00
Trent Piepho
c09f6918fa i2c: Allow dumping the data of read messages
Add an argument to i2c_dump_msgs() to log the data from reads too.  And
then rename the function to i2c_dump_msgs_rw() so the API doesn't
change.  If the dump is done after a transaction is processed, as
opposed to before, then the read data is valid and can be very useful.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-26 14:55:44 -05:00
Johann Fischer
a06d9769ce usb: device_next: update IAD during CDC ACM initialization
Set bFirstInterface of IAD and update CDC Union descriptor
during class initialization.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-26 09:37:03 -08:00
Keith Short
6062914cf2 emul: Add support for backend APIs
The emulator structure currently initializes a bus-level API that is
used to communicated register accesses to the emulator from the parent
bus.

Add support for declaring a backend API for emulators. This provides
tests a common way to interact with emulators of the same device type.

Signed-off-by: Keith Short <keithshort@google.com>
2023-01-27 01:01:06 +09:00
Johann Fischer
5c077d72b5 usb: device_next: add BT HCI USB transport layer
Add Bluetooth HCI USB transport layer implementation for the new
experimental USB device support based on the existing implementation
subsys/usb/device/class/bluetooth.c.

This implementation, unlike existing one, contains the interface
descriptors for isochronous endpoints. Since we do not support voice
channels, these are just there to avoid issues with Linux kernel btusb
driver when this implementation is part of a composite configuration.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-27 00:57:22 +09:00
Raphael Treccani-Chinelli
3e937da264 bluetooth: host: Added extra options to PAST subscribe
allow disabling reports (synchronise but don't generate sync reports)
and allows enabling sync reporting with filtering of duplicates.
the default option remains to establish sync, with sync reports,
but without duplicate filtering.

Signed-off-by: Raphael Treccani-Chinelli <raphael.treccani@nordicsemi.no>
2023-01-26 07:29:19 -08:00
Nicolas VINCENT
06d53b1343 settings fcb: Increase buffer for mcu with large write block size
Devices with write block size greater than 16 could not use settings_fcb
due to small buffer size.
Update value in test as well.

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2023-01-26 22:50:40 +09:00
Jamie McCrae
4516e7161c mgmt: mcumgr: transport: smp_bt: Fix wrongly enabling Bluetooth
Bluetooth does not need to be enabled to register services,
therefore the newly introduced automatic bluetooth SMP transport
registration system can be simplified by returning enabling of
bluetooth back to the application.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 12:36:16 +00:00
Robert Lubos
9fef0c521d net: tcp: Remove net_tcp_unref()
There is a pending TODO regarding unifying net_tcp_unref() and
net_tcp_put(). Given that net_tcp_unref() is no longer used by the upper
layer (it should only use get/put APIs), the function can be removed
from external TCP API, as referencing/dereferencing is now only used
internally by the TCP stack.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-26 12:34:04 +00:00
Robert Lubos
79461a378c net: tcp: Fix TCP connection ref counting
The net_context/TCP connection context ref counting needed to be fixed,
to avoid situation where TCP connection context could be released
before net_context is released.

Generally, this commit modifies the ref counting of the above as
follows:
* net_context is referenced both by the application and TCP stack, when
  created.
* TCP context is referenced by the application when created. The TCP
  stack adds ref to the TCP context only after connection has been
  established.
* TCP stack needs to call the final upper layer callback when connection
  is closed, but before the TCP context is released (i. e. to give upper
  layer chance to dereference the context on its side). For this,
  tcp_conn_close() was introduced which is called from within TCP stack
  instead of directly dereferencing the TCP context.
* TCP stack dereferences the net_context only after the TCP context has
  been released (i. e. upper layer has dereferenced TCP context on it's
  side and connection has been tear down, if established).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-26 12:34:04 +00:00
Vinayak Kariappa Chettimada
47921588b4 Bluetooth: Controller: Broadcast ISO encryption support
Implementation of Broadcast ISO encryption using crypto
toolbox function h8. And support for encryption in lower
link layer for nRF5x series.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
4d3f8697a3 Bluetooth: Controller: Make PDU octet3 vendor specific
Make Data, ISO, BIS and CIS PDU structure's octet 3 vendor
specific.

This will allow vendors not supporting the octet 3 or
CTEInfo (8 bits) to save 1 octet in their PDU structures.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
117bdbbf64 Bluetooth: Controller: Use len instead of length in PDU structs
To be consistent in naming as len instead of length in PDU
struct definitions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
f4b4f30596 Bluetooth: Controller: Parse and find BIGInfo to setup ISO sync
Add implementation to parse ACAD and find the BIGInfo before
setting up Broadcast ISO Synchronization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
c8f75de1a5 Bluetooth: Controller: Add packing sequential or interleaved comment
Add code comment related to BIG packing sequential or
interleaved being used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
cc1f937d61 Bluetooth: Fix endianness of cryptographic toolbox function h8
Convert endianness of supplied parameters before calculating
the AES-CMAC. Bluetooth stores values in little-endian and
crypto traditionally operates on big-endian storage.

Relates to commit e9c542ab5b ("Bluetooth: Add the
cryptographic toolbox function h8").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Jonathan Rico
a7746ad55e Bluetooth: Host: Re-subscribe only after encrypt change
Wait until encrypt change to trigger the re-subscription quirk.
Otherwise it could fail with insufficient security.

Also gate it behind a kconfig to make apparent its dependencies:

If `add_subscriptions()` is executed in the first place, that means that
the device was bonded and thus that it has to encrypt the link eventually.

`BT_GATT_AUTO_SEC_REQ` should take care of that.

Also add a new flag to `bt_gatt_subscribe_params` to not send the same CCC
write multiple times in some cases.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-01-26 10:05:13 +00:00
Alberto Escolar Piedras
8a5273525e nrf52_bsim: Convert from a nRF52832 to a nRF52833
The nRF HW models have been updated to correspond to a 52833 instead
of a 52832. Let's follow them.

The motivation for the change is to enable proper BIS encryption support
(for BT LE Audio ISO).

Changes:

* Point in manifest to latest HW models

* SOC_COMPATIBLE_NRF52832 has been removed, and SOC_COMPATIBLE_NRF52833
added in its place (with no uses at this point)

* Where SOC_COMPATIBLE_NRF52832 was used to set encryption like for a 52832
(to avoid using the MAXPACKETLENGHT), we set the condition to just
SOC_NRF52832.
Note: The MAXPACKETLENGHT register exists in the new simulated nrf52833,
thought it does nothing.

* In the BLE ctrl LLL radio HAL, all macros are renamed accordingly
(timings are NOT changed).

* Board dts definition now refers to the 52833 soc definition. New 52833
features set as not supported by now.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-01-26 09:29:18 +01:00
Vinayak Kariappa Chettimada
c325347816 Bluetooth: Controller: Fix missing node rx release on legacy CPR reject
Legacy Control Procedure fix. Fix missing release of the
node rx allocation that was reserved at the start of the
LE Connection Parameter Request procedure and the procedure
ends with reject indication transmitted to the initiating
peer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 09:07:45 +01:00
Juha Heiskanen
1f84409b48 net: lwm2m: Trace clean
Cleaned Trace message print.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-25 15:08:07 +00:00
Chamira Perera
ce49beb297 net: ethernet: Fixes for ethernet stats reporting.
The following fixes were applied:
 - Multicast Rx packets stats were not recorded due not parsing the
ethernet header. The function that tried to parse the ethernet header
was parsing the ethernet packet beyond the ethernet header.
 - Added a new stats for unknown protocol which gets updated when the
ethernet layer encounters an unknown ethernet packet type.

Fixes #53994

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2023-01-25 15:01:14 +00:00
Jordan Yates
fb1ee429a2 pm: device: rework pm_device_children_action_run
Rework the implementation of `pm_device_children_action_run` to use the
common `device_supported_foreach` iterator.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-25 14:58:52 +00:00
Andreas Chmielewski
022ff636da net: lwm2m: rd_client: added init function
To write tests it is necessary to offer init function for the RDClient
to define custom fakes before.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-01-25 14:55:02 +00:00
Nicolas Pitre
90ae60078e ztest: make the FPU flush workaround more generic
In addition to ARM64, it must apply to RISC-V too now.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-24 15:26:18 +01:00
Aleksander Wasaznik
4b675f34db Revert "Bluetooth: Host: Disable host-based RPA resolution when !BT_PRIVACY"
This reverts commit 5824ac90ecd8dd06d9ea117d345dbc6b069e5840.

The resulting revert takes into account changes to the predicate that
guards the use of `resp_addr`.

In the resulting revert, the predicate guarding the use of `resp_addr`
is differs from the naive revert because the intention of that predicate
is to know when `conn.c:bt_conn_le_create` decided to use the Host
resolver. And, the logic in `conn.c:bt_conn_le_create` has changed. The
changes to the logic in `conn.c` are in the following commits:

89780d715d
5a09325ba9

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-01-24 15:13:36 +01:00
Vinayak Kariappa Chettimada
c104fda34f Bluetooth: Controller: Fix filter accept list and privacy default
Fix filter accept list and privacy feature Kconfig default
based on whether host has them enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-24 15:13:36 +01:00
Vinayak Kariappa Chettimada
00dbf6188c Revert "Bluetooth: Controller: Fix filter accept list and privacy default"
This reverts commit 59eef60665.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-24 15:13:36 +01:00
Wouter Cappelle
aaefd3db7e net: http: Use poll for http timeout instead of shutdown
Change the http timeout mechanism to use poll instead of shutdown.
This should fix a problem where the shutdown will be called in a
different thread context which can lead to deadlocks on certain
driver implementations like offloaded modem drivers.
Fixes #53967

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2023-01-24 14:50:11 +01:00
Morten Priess
cb7c4d3850 Bluetooth: controller: Fix ll_cig_remove not cleaning up
When removing a CIG, the instance and associated CIS instances were not
always released. This causes repeated Create_CIG/Remove_CIG operations
to fail assertion with resource error.
Enables CONFIG_BT_CTLR_CENTRAL_ISO in bsim_test_audio.

Fixes issue #53301.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 14:49:43 +01:00
Emil Gydesen
0f394c5958 Bluetooth: Audio: Shell: Add missing metadata type
In handle_metadata_update the metadata type was never copied,
causing it to always be 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:25 +01:00
Emil Gydesen
5357bd5d0f Bluetooth: Shell: add pa_ad_init for cmd_per_adv_data
Similar to the ad_init that automatically adds advertising data
from other modules, pa_ad_init has been added to do the same
for periodic advertising.

The only use case so far is the BAP broadcast source
data, if enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Emil Gydesen
d115bafd40 Bluetooth: Audio: Shell: Split audio_ad_data_add into two
The call to audio_ad_data_add will now either call
connectable_ad_data_add for connectable advertising, or
unconnectable_ad_data_add for unconnectbale advertising.

Most service UUIDs etc. does not make sense to advertise if
not connectable.

This also adds the BAP broadcast advertising data to
unconnectable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Emil Gydesen
f0b104346a Bluetooth: Audio: Shell: Fix off-by-one issue with the HAS uuid
If the advertising is connectable, and we have privacy,
then according to the HAP spec, we should not advertise
the HAS uuid.

This was done by simply truncating the advertising data, but
it was only truncated by 1, instead of by the size of the
UUID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Morten Priess
60b1f2b36b Bluetooth: controller: Reduce ISO peripheral CIS establishement delay
New LLCP will process the CIS establishement in the TX path, meaning it
will only process once every ACL connection interval.
If ACL connection interval is significantly longer than the ISO
interval, CIS packets corresponding to the ACL connection interval will
be lost. This may cause latency in audio rendition.

By processing the CIS establishment in the RX path, notification will be
sent immediately, and audio path is enabled fast to reduce latency.

When a CIS fails to establish, the controller shall complete the
procedure by sending a CIS_ESTABLISHED event containing the error.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess
90d0d93a9c Bluetooth: controller: Fix missing CIS disconnect on MIC failure
Disconnect CIS immediately if event done extra status indicates MIC
failure. Return reason BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL.

Fixes EBQ test /LL/CIS/PER/BV-27-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess
78c3bf569b Bluetooth: controller: Implement CIS offset equivalent calculation
When the 'instant' of a CIS is postponed by increasing the conn_event of
the CIS_RSP compared to CIS_REQ, the CIS offset shall be calculated as
an equivalent window offset by an integer number of ISO intervals.
This is obtained by increasing the CIS_Offset_Min and CIS_Offset_Max by
the modulus of the connection interval delay time.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess
a982c9f9f6 Bluetooth: controller: Start CIG immediately if instant is next event
To be able to timely start the first CIS/CIG, if the requested instant
is the next connection event, call ull_peripheral_iso_start directly
from rp_cc_state_wait_rx_cis_ind instead of waiting for next time
through the state machine.

To enable ULL/LLL to prevent adding latency when LLCP is waiting for
instant, local- and remote procedures with instant now expose a function
for checking this state.

Fixed event_counter function to prevent one-off in RX path. Unified to
use single function ull_conn_event_counter.

Fixed LLCP unit tests and added new mock function.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Tomasz Moń
7608f54433 usb: device_next: Do not leak memory on set address
USB stack did leak memory on every SET ADDRESS request. UDC control
allocator could cope with up to 13 leaked allocations. Therefore,
issuing bus reset 13 times in a row (in addition to automatic reset
after connecting the USB cable) was enough to exhaust memory and
thus drive USB stack inoperable.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-01-24 09:43:00 +01:00
Emil Gydesen
728384992f Bluetooth: Audio: Unicast client add disabled callback for sink ASE
The sink ASE does not have a disabling state, but since the
stream callbacks does not necessarily match the ASE states,
we need to do our own check to see if a sink ASE has been
disabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:55:49 -08:00
Emil Gydesen
13a48de72f Bluetooth: Audio: HAS: Fix notifications/indications
Before this commit we simply always notified/indicated
all presets and active index to any bonded device, even
if they never subscribed to anything, or even if we never
registered HAS.

This commit modifies that, so that only the proper
connected clients will get the notifications/indications,
and that we only send them if something has changed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen
50a0f62df2 Bluetooth: Audio: HAS: Remove unused control_point_work_sync
Remove unused control_point_work_sync field in the has_client
struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen
ea858f26c5 Bluetooth: Audio: HAS: Fix active_preset_work initialization
The security_changed callback may be called before
bt_has_register has been called, thus making the active_preset_work
handler uninitailized, causing an ASSERT when the work is submitted
in the security changed callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen
d6055f9938 Bluetooth: Audio: Fix HAS double register
Calling bt_has_register multiple times would cause attempts
to register a HAS multiple times. Fixed by adding a check
and return with EALREADY if it is already registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Chris Friedt
c2a62f4ad7 net: sockets: conditionally include zephyr/posix/fcntl.h
Only include `<fcntl.h>` for `CONFIG_ARCH_POSIX`. Otherwise,
include `<zephyr/posix/fcntl.h>`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
6ac402bb3a net: socket: additional POSIX constants
The POSIX spec requires that `SO_LINGER`, `SO_RCVLOWAT`,
and `SO_SNDLOWAT`, and `SOMAXCONN` are defined in
`<sys/socket.h>`. However, most of the existing socket
options and related constants are defined in
`<zephyr/net/socket.h>`.

For now, we'll co-locate them. It would be
good to properly namespace things.

Additionally, a no-op for setsockopt for `SO_LINGER` to
make things Just Work (TM) for now.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Vinayak Kariappa Chettimada
02ee85c893 Bluetooth: Controller: FIXME comment for chain PDU time reservation
Add FIXME comments to handle additional time reservations
required for advertising auxiliary channel chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-23 13:08:34 +01:00
Julien D'Ascenzio
740f915721 nvs: use CRC8 if cache size is 256
When cache size is 256, we can use CRC8

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2023-01-23 12:04:55 +00:00
Andrei Emeltchenko
270668b752 bluetooth: controller: Prevent Out of band access
Add check preventing Out of band access. There are tests trying to
access out of band handle like:

test_sink_invalid_ref and test_source_invalid_ref trying to access
handle 99.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-23 12:04:25 +00:00
Andrei Emeltchenko
02fa6ba7e6 bluetooth: shell: Correct ad_len type
Fixes warning when comparing that size_t is negative.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-23 13:26:59 +02:00
Gerson Fernando Budke
eb9460ce5e mgmt: updatehub: Add no memory check at cmd_info
The updatehub shell cmd_info allocate memory but not checks function
return. This add missing checks and proper error handle.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Gerson Fernando Budke
647c48c574 mgmt: updatehub: Add userspace syscalls
The current updatehub version forces user application to run in kernel
mode. This add necessary api syscalls to isolate userspace from kernel.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Gerson Fernando Budke
000257dad0 mgmt: updatehub: Move updatehub.h to header directory
This moves updatehub.h file from subsys to public header include
folder.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Gerson Fernando Budke
22e0a1faa6 mgmt: updatehub: Preparation to move public api
This prepares updatehub.h file to be moved to the public header
directory.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Ajay Parida
ba39235275 net: wifi_mgmt: Add support for power save timeout configuration
Add support for configuring power save timeout in Wi-Fi chipsets.
Changes to configure power save inactivity timer.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-01-23 10:08:01 +00:00
Mahesh Mahadevan
ae97eae8c2 pm: Error with handling z_cpus_active count
z_cpus_active count becomes incorrect when the state is
PM_STATE_RUNTIME_IDLE and CONFIG_PM_DEVICE is enabled.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-01-23 10:06:17 +00:00
Martin Jäger
3b9ba15096 lorawan: services: add Application Layer Clock Synchronization
This service allows to synchronize the clock with the application
server.

Synchronization requests are initiated by the device in a regular
interval, configurable via Kconfig.

The implementation only supports TS003-2.0.0, as the previous revision
TS003-1.0.0 requested to temporarily disable ADR and and set nb_trans
to 1. This causes issues on the server side and is not recommended
anymore.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-01-23 10:05:49 +00:00
Martin Jäger
a9dc566a18 lorawan: add common backend for services
This is a prepartion for adding actual services needed for firmware
upgrade over the air (FUOTA).

The services run in a dedicated work queue.

This commit introduces code that initializes the work queue and
provides functions to schedule uplink messages after a given timeout.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-01-23 10:05:49 +00:00
Szymon Czapracki
77c8cffae0 Bluetooth: Audio: Ignore RFU VOCS location
This commit changes VOCS set location behavior.
When an RFU location is written, VOCS ignores it.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-01-20 16:11:31 +01:00
Sam Hurst
ee9903005a usb_c: Refactor Sink common code
Move non-sink specific code into common code

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-20 12:17:44 +01:00
Vinayak Kariappa Chettimada
d6c3e04eb8 Bluetooth: Controller: Central maximum data PDU size time spacing
Use the maximum data PDU size time reservation space
considering the Data length could be updated from default
27 bytes to maximum support size.

If maximum time reservation is disabled then time space
reservation corresponding to the default data length at the
time of the start/enable of Central role is used.

Note, currently this value is only used to space multiple central
connections and not for actual ticker time reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-20 12:16:43 +01:00
Vinayak Kariappa Chettimada
680e29dd0e Bluetooth: Controller: legacy: Fix conn param request to be cacheable
Fix connection parameter request  procedure to be cacheable
if a remote control procedure is in progress.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-20 12:16:43 +01:00
Vinayak Kariappa Chettimada
5e848761c5 Bluetooth: Controller: legacy: Fix conn upd instant passed on data tx
Fix legacy control procedure implementation to avoid
connection update procedure with reason instant passed
(0x28).

Connection Update Indication PDU is enqueued after data
enqueue to LLL context is paused and the enqueue resumes
when already enqueued data PDUs are all acknowledged.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-20 12:16:43 +01:00
Jamie McCrae
df0fa6d965 mgmt: mcumgr: Add logging output
Adds logging to mcumgr commands for debug and error reporting

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-20 11:57:59 +01:00
Emil Gydesen
50446afe6c Bluetooth: Audio: Shell: Remove csip_set_coordinator init command
Remove the init command for teh CSIP Set Coordinator.
The main reason for this is that we want to ensure that we
register the conn callbacks early so that `conns` array is
properly filled.

The other callbacks registered in the init function
can easily be moved to where they are needed, and even
unregistered to avoid parsing more data than we need.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-20 09:03:51 +01:00
Julien D'Ascenzio
b7c2b3fc3a nvs: NVS cache always rebuild on successful NVS initialization
During the NVS initialization, if gc had to be done, the NVS cache
rebuild wasn't called.

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2023-01-19 17:14:55 +01:00
Ajay Parida
057e2fc59c net: wifi_shell: Display correct power save status
Display power save status correctly.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-01-19 13:48:24 +01:00
Sören Tempel
cf34afd2cc testsuite: coverage: fix -Wcast-align warning
While porting the coverage.c file from RIOT to Zephyr, which employs
different compiler flags, I noticed several -Wcast-align GCC warnings on
arm. I think, as is, the current implementation may perform unaligned
memory accesses which may not be supported on certain platforms. To
workaround that, I have rewritten the code for RIOT using
bytewise-writes with `memcpy`.

Signed-off-by: Sören Tempel <tempel@uni-bremen.de>
2023-01-19 06:51:44 -05:00
Veijo Pesonen
f0258dbe4d net: lwm2m: Sufficient memory for resource names
Full resource names aren't as long as combined basename- and name-buffer
sizes but the compiler doesn't know it. Increasing the buffer size to
avoid the compiler warning.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2023-01-19 12:03:27 +01:00
Andries Kruithof
584bd4069f Bluetooth: controller: Kconfig for event length update
Since the event length update is not necessarily an improvement
in all situations a Kconfig option is added so that it can
be disabled for the users that do not need it.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-01-19 11:18:51 +01:00
Andries Kruithof
e7d60e3ed6 Bluetooth: controller: fix post DLE/PHY update event length
Fix the controller implementation to perform connection
event length reservation based on the completed Data Length
Update and/or PHY Update Procedure.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-01-19 11:18:51 +01:00
Chamira Perera
1c51f7cbbf net: ipv4: Using a different API to ensure that IPv4 is enabled
When init_igmp is called the ipv4 pointer was not initialised.
Therefore, a different API needs to be used to ensure that IPv4
is enabled when calling init_igmp.

Fixes #53913

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2023-01-19 10:35:44 +01:00
Jarno Lämsä
abafd7e810 net: lib: lwm2m: Replace deprecated function calls
Replace calls to deprecated functions with new ones.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
3b3463ecba net: lib: lwm2m: Deprecate string based enable cache
Deprecate the old API and replace with new one which uses
the lwm2m_obj_path struct instead of a string.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
460dd6530f net: lib: lwm2m: Deprecate string based send
Deprecate send API using the string references as paths.
Replace it with one using path structs.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
49cf96858f net: lib: lwm2m: Deprecate buffer set get API
Deprecate old API and make new API using path structs
instead of using old string reference based paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
bca0550413 net: lib: lwm2m: Deprecate callback registration API
Deprecate old API and create new API using path structs
instead of string references to paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
a2e52c5607 net: lib: lwm2m: Deprecate observation API
Add new APIs using the lwm2m path structs instead of
string references to paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
5c80be9379 net: lib: lwm2m: Deprecate object and resource API
Deprecate old API and offer a new API for object and resource
creation and deletion. The new API uses path struct instead
of using a string as a reference to a path.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
15d81a8914 net: lib: lwm2m: Deprecate string based set get API
Use the lwm2m_obj_path struct instead and deprecate old.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Erik Brockhoff
ad06dfc784 Revert "Bluetooth: controller: Reject CIS_TERMINATE when unsupported for role"
This reverts commit ee2a43b5dc.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-01-18 22:19:57 +00:00
Erik Brockhoff
e096ccca8d Bluetooth: controller: fix UNKNOWN_RSP vs. role re CIS TERMINATE support
Proper handling re. non-supported CIS TERMINATE

This fixes EBQ test LL/PAC/CEN/BV-01-C on the general level.
'Replaces' #ee2a43b5dcf884730130345c402d87b2bce9dba1

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-01-18 22:19:57 +00:00
Eivind Jølsgard
cfa1ba1261 fs: fcb: add option to disable CRC for fcb entries
Add option to disable CRC for fcb entries. This improves the write
throughput significantly at the cost of not detecting corrupted data
in flash. This is beneficial for aplications that needs the extra
write throughput, where error detection is done elsewhere.

Allow the FCB entries in flash to have a valid CRC when CRC is
disabled in the FCB. This allows existing solutions to disable
CRC checking, while keeping the CRC areas intact. Note that this
is a one-way option.

Fixes #53707

Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
2023-01-18 22:18:37 +00:00
Andrei Emeltchenko
33b0c0db38 bluetooth: ias: Fix dereferencing before NULL check
It does make sense to dereference after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-18 07:27:00 -05:00
Andrei Emeltchenko
1ec44b6160 bluetooth: Fix using size instead of len
Fix using wrong field.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-18 07:27:00 -05:00
Tomasz Moń
e326c58399 usb: device: Do not cancel transfers on suspend
Cancelling transfers on suspend contradicts Universal Serial Bus
Specification Revision 2.0, 9.1.1.6 Suspended:
  * When suspended, the USB device maintains any internal status,
    including its address and configuration.

The internal status definitely includes any pending USB transfers.
If there is a class that wants to cancel transfer on suspend, then the
cancel should be initiated by the class, not the device stack itself.

Update hal_nordic to a version that does not abort all endpoints at
suspend. It seems that aborting endpoints on suspend in nrfx driver was
the actual reason why transfers were canceled on suspend.

Remove transfer retriggering on resume from CDC ACM and Bluetooth class
implementations because transfers are no longer cancelled on suspend.
Other classes do not have any suspend related workarounds implemented.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-01-18 11:48:13 +01:00
Pavel Vasilyev
46b78bb1d5 Bluetooth: Mesh: Stop scanner before resetting mesh
When we receive Node Reset message, we schedule work in the system
workqueue to call bt_mesh_reset(). In bt_mesh_reset() we call
bt_conn_disconnect() to disconnect proxy client. bt_conn_disconnect()
will put a buffer to a pool and call k_sem_take to let BT HCI TX thread
process this buffer. Because we stop scanner after disconnecting the
proxy, we can still receive a message at this point. Since BT RX thread
has higher priority than the system workqueue, if we receive a message
while in bt_mesh_reset(), it will be processed when we call
bt_conn_disconnect().

Stop scanner before resetting the mesh to avoid processing of a received
mesh message while in the process of resetting mesh.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-18 10:47:44 +01:00
Pavel Vasilyev
6dfc9ecc03 Bluetooth: Mesh: Invalidate pending entries before calling settings API
If, while storing app or net key, or changing cdb, we receive another
mesh message that affects setting of the same key that the mesh
currently stores, the new change won't be stored.

The settings subsystem API has rescheduling point inside. The mesh
settings are stored in the system workqueue and by default mesh messages
are processed from BT RX thread which has higher priority than the
system workqueue.

When the case above happens, a new change will be written to the same
cache entry. But this cache entry will be invalidated after leaving
settings API, which in turns will invalidate the new change:

- Receive Config AppKey Add message
cfg_srv.c -> app_keys.c: bt_mesh_app_key_add()
app_keys.c: update_app_key_settings()
app_keys.c: bt_mesh_settings_store_schedule()
- store_pending() in settings.c is scheduled
settings.c -> app_keys.c: bt_mesh_app_key_pending_store()
app_keys.c: store_app_key() called to store new app key
app_keys.c: settings_save_one() calls flash driver and sleeps
- Receive Config AppKey Delete message while in sleep,
  which wakes up BT RX thread before returning to the system workqueue
cfg_srv.c -> app_keys.c: bt_mesh_app_key_del()
app_keys.c: update_app_key_settings()
app_keys.c: app_key_update_find() finds entry and returns it
app_keys.c: update->clear = 1
app_keys.c: bt_mesh_settings_store_schedule()
- returning back to bt_mesh_app_key_pending_store() from
  settings_save_one()
app_keys.c: update->valid = 0
- the key won't be deleted next time store_pending() is scheduled.

This change moves entry invalidation before calling settings API so that
after returning from settings API, a new change won't be unintentionally
invalidated.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-18 10:47:44 +01:00
Mariusz Skamra
36058480e7 Bluetooth: audio: Improve stream coupling for CIS as the unicast client
Allow  the streams to be paired when creating unicast group. This will
allow to reuse the same ISO for the paired streams.

Fixes: #51796
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-18 09:56:52 +01:00
Andrei Emeltchenko
69a9ae61b4 bluetooth: shell: Fix using wrong field
Fix using data instead of meta field.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-17 21:50:16 +00:00
Dominik Ermel
718be64e14 mgmt/mcumgr: Don't add unused slots in img_mgmt_flash_area_id
The img_mgmt_flash_area_id would add processing of
slot2_partition and slot3_partition if they only exist, even if
not used at all.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-01-17 21:49:46 +00:00
Emil Gydesen
6dc20d5ced Bluetooth: Audio: Add BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED as default ctx
Add BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED as the default supported
context. This is primarily due to the requirement that it
shall always be supported, and the value 0 (previous
default) was invalid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-17 13:17:03 +01:00
Emil Gydesen
2cc1fe259a Bluetooth: Audio: Fix invalid value for setting src supported ctxs
The call to set_supported_contexts in set_src_supported_contexts
gave the wrong value by reference.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-17 13:17:03 +01:00
Ahmed Moheb
60345c1ddc tests: bluetooth: host: Add UT for bt_keys_update_usage()
Unit test project for bt_keys_update_usage().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:02 +01:00
Robert Lubos
6425f0be0a net: ppp: Fix PPP connection with host
A follow up to commit 1d7a077e11 - apparently the PPP interface should
not be brought entirely down internally, as this can break further
communication with the host. Because of that, reintroduce functionality
that used to be covered by net_if_carrier_down() (which basically
skips the L2 enable(false) call), but limited to PPP scope only.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-17 11:28:10 +01:00
Saleh Mehdikhani
a4890f954a Bluetooth: Controller: Fix slot_plus_us by converting max CTE len to us
Fixes #53786
The variable slot_plus_us is assumed to be a number in us unit.
To assign the maximum possible CTE length to this variable,
BT_HCI_LE_CTE_LEN_MAX has been used while this parameter is defined
in a 8us units (it's 0x14=20 that corresponds to 160us).
To convert this number to us, it's needed to be multiplied by 8.

Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
2023-01-17 11:27:36 +01:00
Mariusz Skamra
80f87b9480 Bluetooth: has: Fix HAS features value
The bt_has_register_param's preset_sync_support and independent_presets
make sense only if CONFIG_BT_HAS_PRESET_COUNT is non-zero meaning the
CONFIG_BT_HAS_PRESET_SUPPORT is enabled.
Otherwise, those parameters shall be skipped.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-16 16:53:39 +01:00
Emil Gydesen
2971c0a588 Bluetooth: Shell: Add cmd_per_adv_set_info_transfer
Add command to perform the Periodic Advertising Set
Info Transfer procedure, which transfers information
about a periodic advertising set to a connected device.

In essence this is just PAST but from the advertiser
instead of a 3rd device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-16 16:53:15 +01:00
Emil Gydesen
b43f1351ed Bluetooth: Audio: Fix issue with invalid bt_conn_ref in ASCS
In ascs.c we had a case where we assigned stream->conn
without taking the ref.

In bt_audio_stream_attach we did not check if stream->conn
was NULL before taking a reference, causing multiple calls
to ase_config to take multiple references.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-16 16:53:03 +01:00
Anders Storrø
c819f0f8d6 Bluetooth: Mesh: Separate adv tag/set for friend
The purpose of this commit is to facilitate future improvements to the
LPN and friendship feature. By being able to identify friendship related
messages on the advertising layer, it will be possible to treat these in
a specific manner so that message exchange between LPN and friend
devices can be conducted in a more power efficient manner.

This commit adds the following:
   - A separate tag for friendship related messages
   - A optional separate advertising set for friend related messages

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-01-16 14:40:54 +01:00
Anders Storrø
bedace2105 Bluetooth: Mesh: Config opt for friend adv latency
Adds Kconfig option to enable tuning the Friend receive delay window.

Friend poll events can be made more efficient by compensating for the
time the non-ideal advertising latency otherwise would add to the receive
delay.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-01-16 14:40:54 +01:00
Tom Burdick
3d6f3a52cf tracing: Fix systemview tracing ids
Fixes the overlapping tracing id for thread name set and pm system suspend

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-16 10:05:01 +01:00
Jamie McCrae
571273b78c mgmt: mcumgr: Change transport select to depends on
This changes some of the MCUmgr transport CMake select statements
to depends on, this is to align with other in-tree symbols that
do not pull in whole subsystems and instead only allow selection
if those subsystems are already enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-16 10:04:45 +01:00
Declan Snyder
bb41f7dc9d sd: Enable eMMC cache
Use cache on eMMC

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
a0bfcb737c sd: Support eMMC HS200/400 Timing Mode
Support for eMMC HS200 and HS400 Timing Modes.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
496ded03f1 sd: Enables High Speed Timing for MMC protocol
- Enables HS Timing Mode for MMC protocol.
- Reads data about HS modes from EXT_CSD for MMC.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
c89b2b08ce sd: Enables eMMC in Zephyr
Enables eMMC protocol in Zephyr

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
fea01b4254 tests: sd: Adds MMC test and Kconfigs
Adds MMC test and Kconfigs for MMC
Note: MMC not yet implemented as of this commit

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
cad243d59e sd: Changes framework to support MMC
- Adds mmc.c
- Edits sd.c to init and probe MMC
- Adds mmc init to sd_init
- Some functions from sdmmc.c should be in sd_ops because
they can be used by both sdmmc and mmc.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
9fe18e05b4 sd: Changed Init Header Structure
In sd subsystem, made one header for all the init functions
instead of having a bunch of header files with one function.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
a838eef33b sd: Changed KConfig Structure
Changed KConfig structure for SD:
- Better Menu Interface
- Changed symbol dependency structure

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Daniel DeGrasse
94c858ed86 sd: split sdmmc common functions into sd_ops.c
split reusable portions of SDMMC protocol code into sd_ops.c, so other
SD protocols can use these functions directly without compiling in the
SDMMC subsystem.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-14 09:22:22 +01:00
Daniel DeGrasse
b7cd970493 sd: add stub for SDIO support
Add stub code for SDIO support, capable of verifying card responds to CMD5.
This commit also changes the architecture of the SDIO probe step to make
adding new protocol support more streamlined, and enable compiling out
support for undesired protocols.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-14 09:22:22 +01:00
Stephanos Ioannidis
4a64bfe351 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis
feaab27c1b lib: cpp: Relocate subsys/cpp to lib/cpp
This commit moves the files under `subsys/cpp` directory to the
`lib/cpp` directory because the C++ ABI runtime library and the
standard C++ library components are not a "subsystem" (aka. API) in
conventional sense and is better described as a "library."

Classifying the C++ ABI runtime library and the standard C++ library as
"libraries" instead of "subsystems" also better aligns with how the
existing C standard library implementation (`lib/libc`) is handled.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Krishna T
fadb1fd168 net: wifi: Add support for regulatory domain configuration
Wi-Fi bands are regulated by a governing body depending on operating
country, add support for the user to provide a country of operation as a
hint to the Wi-Fi chipset.

Ideally if the chipset supports this is all handled internally, in that
case "get" is useful but for testing and other usecases add a "set" as
well, similar to "iw reg set" or "country_code=" configuration in
hostapd/wpa_supplicant in Linux world.

This add a new offload API operation "reg_domain" that can be used to
either get or set the regulatory information.

The validation is left to the underlying chipset, shell only does basic
validation, (XY/00).

This is just a regulatory hint to the chipset, there could be other
regulatory hints e.g., beacon that can override this configuration, so,
an additional option to force this setting despite other hints is also
given for testing purposes.

FYI, the standard database used is [1].

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/tree/db.txt

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-13 13:37:14 +00:00
Krishna T
324a45568a net: wifi: Fix unnecessary intermediate variable
Directly return the function return value.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-13 13:37:14 +00:00
Pascal Brogle
6ac281887c net: lwm2m: fix observation path list ordering
under certain conditions the current implementation did not maintain
the desired sort order.

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 13:47:27 +01:00
Szymon Czapracki
35bd427927 Bluetooth: audio: Add configurable PACS supported contexts
Add the ability to change supported contexts in PACS.
Enhance the context command in the shell module to make it configurable.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-01-13 13:47:19 +01:00
Pascal Brogle
cc40bc33ba net: lwm2m: fix senml max name size
base name or name can contain up to two shorts.
(object id & object intstance or resource id & resource instance id)

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
Pascal Brogle
b6bc324a1d net: lwm2m: rename path size define
Rename max path constant to prevent string length vs data size confusion

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
Pascal Brogle
b178ff5246 net: lwm2m: fix senml cbor compiler warning
use size_t instead of assuming uint32_t

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:00:13 +00:00
Chamira Perera
b71b514e93 net: ipv4: Added mechanism to add 224.0.0.1 address to a multicast filter
The purpose of the change was to have the Zephyr network stack
internally add the IGMP all systems 224.0.0.1 multicast address to a
multicast membership list so that multicast hash filter implementations
can add this address to the hash filter.

Fixes #53548

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2023-01-13 09:44:10 +01:00
Andrei Emeltchenko
86f48609fb doc: ztest: Include ztress to API reference
Include ztress documentation to ztest API section.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-13 09:43:40 +01:00
Andries Kruithof
1200fd9314 Bluetooth: host: fix conditional compile for broadcaster role
The call to bt_adv_reset_adv_pool is only required in the
broadcaster role, and not in the observer role, regardless
of the setting of CONFIG_BT_EXT_ADV
As the code was this call was also made for the observer.

Note: handling of the setting of CONFIG_BT_EXT_ADV
is already handled in the bt_adv_reset_adv_pool function

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-01-13 09:43:18 +01:00
Guillaume Lager
e67e6d5af6 mcuboot: Remove public dependency on bootutil
BOOT_MAGIC_SZ and BOOT_MAX_ALIGN were used in the header without
including bootutil/bootutil_public.h. This change remove the need of
the inclusion by making the dependency private.
Fixes #52095

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2023-01-12 19:08:23 +01:00
Ravi Dondaputi
551f8c40b2 net: shell: Support IPv6 address and route config
Add and delete options to configure IPv6 address
 and route from shell.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-01-12 19:08:14 +01:00
Ravi Dondaputi
d11ae3a4c8 net: shell: Add support to configure IP address
Add support to configure IP address using net shell.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-01-12 19:08:14 +01:00
Krishna T
bc80b0a232 net: shell: Use net management API for MAC address configuration
Fix a bug in setting MAC address using net_if API, the API doesn't do a
memcpy but just stores the pointer and shell was passing stack pointer.

We can use dynamic allocation but freeing the memory for the MAC address
would be trickier, so, use the net management API and let the underlying
drivers figure out the MAC address memory management.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-12 19:07:44 +01:00
Krishna T
7952197a89 net: shell: Add MAC address validation
Validate MAC address before setting, add new helper APIs to cover all
cases.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-12 19:07:44 +01:00
Emil Gydesen
baad0c300f BluetootH: Host: add helper functions for resolved addresses
There is special handling done for resolved addresses to convert
them to "regular" addresses for the upper layers.
This commits adds two helper functions to check if they are
resolved, and if so, then properly copied.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-12 13:31:12 +01:00
Emil Gydesen
4af1c99f9d Bluetooth: Host: Translate id addr type for PA sync
We only expose random/public address types to the upper layers.
This is done by checking if the address type of events are
resolved addresses, and if so, then we translate them to
public/random.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-12 13:31:12 +01:00
Florian Grandel
e854314928 net: l2: ieee802154: fix double address swap
As we have to provide LL addresses in big endian to userspace to be
POSIX compliant and we also do not want to reserve extra space for
such addresses, bff6a5cce5 introduced
a change that swaps address bytes in place in the packet before
returning the packet with LL address pointers to userspace.

Unfortunately a regression sneaked into the code base while doing
so: The byte swapping was duplicated when using 6LoWPAN compression
and the byte swapping caused decryption to fail in some cases,
see #53630. This commit fixes the problem.

Fixes: #53630

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2023-01-12 12:46:18 +01:00
Krishna T
02ab878704 net: ethernet: Check return value for start/stop
The L2 networking layer checks for return value from enable, but
Ethernet is not checking and always returns 0, so, relay the return
value from the Ethernet driver to networking stack.

This fixes the issue of interface start failing but interface still
being up.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-12 12:14:55 +01:00
Gerson Fernando Budke
ff6b526a14 mgmt: updatehub: Add storage abstraction
This add storage abstraction to allow switch between different flash
APIs. This remove the erase command at updatehub core and move it to
storage init phase.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Gerson Fernando Budke
eb39f1f12e mgmt: updatehub: Clean-up mcuboot & system dependencies
Currently MCUboot and system reset are invoked directly in the sample
applicatiion. This introduce 2 new methods to isolate system from
application.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Gerson Fernando Budke
689d7cb085 mgmt: updatehub: Clean-up firmware headers
Move header includes to source file. Currently firmware source files
have a hardcode partition identificator. This moves identificators
to updatehub core.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Gerson Fernando Budke
f3159e3885 mgmt: updatehub: Clean-up device headers
Move headers from header includes to source file.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Siddharth Chandrasekaran
73809472f8 mgmt/osdp: Add support for event delivery and notifications
The CP app sends PD a "command" and the PD responds to it. Some times,
the PD has something that it wants to tell the PD which it does so in
response to POLL command. Both CP and PD apps need a way to exchange
these info over the OSDP bus. To archive this we will introduce what are
called "events" that allow the PD app to enqueue and CP app to get
notified.

This is analogous to the incumbent "commands" abstraction where, the CP
app enqueues a command and the PD app gets notified of it.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
c7fec71193 mgmt/osdp: Add length checks for commands and replies
For all commands and replies, the buffer length needed to build or the
length of data needed to decode needs to be checked and asserted. Right now
we do this by ad-hoc if-s. Add macros that do this at a common location.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
f4e3f2b828 mgmt/osdp: Add inline methods for flag checks
The raw, flags check has become a bit excessive and has begun to affect
code readability. Provide inline functions for those accesses that are
frequent. Also, get rid of `struct osdp_cp` as it can be fully represented
by `struct osdp` itself.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
b31e708c03 mgmt/osdp: Rename pd offset as index
CP has an array of PDs and pd->offset was the position of the PD in CP's
list. Since offset has many meanings, rename it to pd->idx.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
059abd8d8b mgmt/osdp: Flush RX buffer before sending data
Partial packets in the RX buffers cause the subsequent packet to be
treated as malformed. The RX buffer can have partial data if the sender
is too slow in sending the packet of if there is an interruption in
transmission mid-way.

To avoid any issues due to such partials, flush the uart channel before
sending the command/response.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
a1f3c7631f mgmt/osdp: Cleanup log messages and return codes
The log lines in CP and PD had a prefix such as "CP: " and "PD: " that
does not add too much value as a given device an either be CP or PD
only. This patch removes those and enhances some other log lines while
at it.

It also adds a enum for return values throughout the module to improve
code quality.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Sam Hurst
d9c4ec31fc usb_c: Fix comments before "else" statements
Move comments that precede an "else" into the "else"
statement.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-11 18:55:18 +01:00
Sam Hurst
f84ee58abd usb_c: Add protocol error flag
Use a flag to report a protocol error to the states. This keeps
state specific actions in the state. Currently, those state
specific actions are handled in the pe_report_error function.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-11 18:55:18 +01:00
Johann Fischer
98770caf2a usb: device_next: remove workaround for the UDC enqueue bug
Remove workaround for the UDC enqueue bug in experimental
CDC ACM implementation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-11 17:44:50 +01:00
Johann Fischer
e9bab613cc usb: device_next: rename Kconfig template instances count
The name and wording used in template can be misleading.
Use more accurate word instance instead of device since
an implementation does not necessarily have to implement
a device (in the sense of Zephyr device model), and if it
does then devicetree should be used to describe number of
instances as in the case of CDC ACM implementation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-11 17:44:27 +01:00
Emil Gydesen
c8014d181e Bluetooth: Audio: Remove unicast_group_valid_qos
The function checked several value, but the BAP spec does
not specify that these cannot be different from stream to
stream in the CIG. The function thus did nothing but needlessly
restrict the upper layers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-11 17:07:11 +01:00
Pavel Vasilyev
ffc4e716f0 Bluetooth: Mesh: Add extra flag to control seg msg in frnd queue
This commit fixes issue introduced in
5d059117fd.

Use extra flag stored in user data of net_buf to control segmented
messages in Friend Queue. The initial idea with using fragments didn't
work.

This fixes the following PTS tests:
- MESH/NODE/FRND/FN/BV-08-C
- MESH/NODE/FRND/FN/BV-19-C
- MESH/NODE/CFG/HBS/BV-05-C

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-11 10:47:06 +00:00
Pavel Vasilyev
7b4f94220d Revert "bluetooth: mesh: Remove illegal use of NET_BUF_FRAG in friend.c"
This reverts commit 5d059117fd.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-11 10:47:06 +00:00
Robert Lubos
a64be51391 net: stats: Fix UDP packet counter for DHCPv4 TX
Fix UDP TX packet count when DHCPv4 is used. Currently UDP TX counter
is only updated when net context is in use. DHCPv4 however does not use
net_context underneath, therefore it needs to update UDP TX stats on its
own.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-11 11:26:08 +01:00
Michał Barnaś
3ae105e76b ec_host_cmd: add NPCX SHI peripheral for the host commands
This commit adds the support for host commands being transported
by the Serial Host Interface on the NPCX SoC.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-01-11 09:38:45 +01:00
Robert Lubos
76dd77df7e net: zperf: Fix potential build warning
A variable was defined directly after a label in two case statements,
resulting in build warning with certain compilers.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-10 14:07:21 +00:00
Troels Nilsson
d7acb9355c Bluetooth: controller: Fix JIT rescheduling for ext. advertising
Fixes two issues with the JIT scheduler:

Rescheduling of primary advertising packets for extended advertising
when using the JIT scheduler did not work, since the done events for
the primary events never made it into the reschedule logic

The EVENT_DONE_EXTRA_TYPE_ADV_AUX event (for auxillary packets) could
cause a "reschedule" for a primary event that was actually sent
successfully (causing it to be sent twice)

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-01-10 14:05:42 +00:00
Jamie McCrae
b8ef838069 mgmt: mcumgr: Select console if using UART transport
This prevents a configuration error by selecting the console if
the UART MCUmgr transport is used, which is actually a dependency
for this transport.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-10 13:49:17 +01:00
Daniel DeGrasse
9a63abc5c6 sd: utilize sdmmc_wait_ready with SPI mode.
Update sdmmc framework to use sdmmc_wait_ready when accessing card in
SPI mode. this will allow cards that do not return to ready to be polled
for busy status until the SD data timeout expires

Fixes #52931

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-10 13:29:32 +01:00
Krishna T
b59c89123c net: shell: Add support to set Ethernet MAC address
Add a shell command to set Ethernet MAC address, useful in configuring
custom/local MAC addresses.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 13:29:22 +01:00
Krishna T
6e3e10e6cd net: shell: Fix duplicate tag
Recently introduced MISRA-C CI check complains about use of a duplicte
tag, so, shorten the variable from shell->sh to avoid same name as the
structure.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 13:29:22 +01:00
Nick Ward
583545b662 net: openthread: Add state change callback list
Add a new callback list structure for state change information.

These APIs are meant to eventually replace the single callback API
provided by openthread_set_state_changed_cb().

This will allow multiple users to gain information about
OpenThread stage changes.

Note CONFIG_OPENTHREAD_MAX_STATECHANGE_HANDLERS
with OpenThread's otSetStateChangedCallback() API can also be
used to enable registration of multiple callbacks of this type but this
cannot be modified if a certified OpenThread binary is used in the
build.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2023-01-10 13:29:15 +01:00
Johann Fischer
7a90b221a5 usb: device: bluetooth: remove USB_TRANS_NO_ZLP for OUT transfers
USB_TRANS_NO_ZLP flag has no meaning for usb_transfer() in
host-to-device direction (USB_TRANS_READ).

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-10 10:30:46 +01:00
Pirun Lee
1e6f36cca7 Bluetooth: OTS - Add Calculate Checksum support
OTS add Calculate checksum feature support.
OTS client add object calculate checksum function.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2023-01-10 09:59:36 +01:00
Emil Gydesen
4716438c20 Bluetooth: Audio: Modify the compile guard for audio_iso.c
audio_iso.c should only be compiled if we require any streams,
so it is now guarded by CONFIG_BT_AUDIO_STREAM.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-10 09:58:54 +01:00
Krishna T
d796f23e0e net: wifi_mgmt: Add support for power save configuration
Add support for configuring power-save in Wi-Fi chipsets, supports
Legacy, WMM and TWT.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 09:52:11 +01:00
Krishna T
3f4597d0c9 net: l2: wifi: Arrange commands in alphabetical order
This helps find the command needed easily.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 09:52:11 +01:00
Sjors Hettinga
1be1b472cd net: tcp: Extend TCP receive queue timeout
After several fixes of the re-ordering logic in TCP, the receive queue
works as intended and cleans itself up properly. Previously the default
timeout was 100 ms, which pretty much disables it for real applications.

Increase the timeout to 2 seconds to actually enable it for in practice.
This should help pass much more of the Maxwell Pro tests.

This is the first step before removing the timeout completely.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-01-10 09:26:28 +01:00
Emil Gydesen
ce9385b388 Bluetooth: Audio: Shell: Fix compile warning for 0 client snk/src ASE
In case that CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT or
CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT is set to NULL, the
unicast client implementation in the shell would have compile
warnings, since the arrays would be 0 and we would attempt to
access it some places (or rather the compiler/linker would
think that, but it would never happen at runtime).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-10 09:25:36 +01:00
PawelX Dobrowolski
07052aba13 logging: days in months calculation fix
Array 'days_in_month' of size 12 may use index value bigger then
count of its elements.

Signed-off-by: PawelX Dobrowolski <pawelx.dobrowolski@intel.com>
2023-01-10 09:23:35 +01:00
PawelX Dobrowolski
20ed64be62 logging: prevent of NULL pointer comparison
Add prevent dereference NULL in strcmp

Signed-off-by: PawelX Dobrowolski <pawelx.dobrowolski@intel.com>
2023-01-10 09:23:35 +01:00
Jamie McCrae
d0e421225a mgmt: mcumgr: callbacks: Fix not checking event ID properly
Fixes an issue whereby event ID was not checked properly, meaning
that OR'd events would not work as one would expect.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-09 17:36:04 -08:00
Yong Cong Sin
20a05b6838 subsys/settings/fcb: removed unused var
Removed the `wbs` var since it isn't used.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2023-01-09 23:19:00 +00:00
Jani Hirsimäki
e92b067b7f net: ip: net_context: AF_PACKET/SOCK_RAW/IPPROTO_RAW: set pkt family
Setting a detected packet family (ipv4 or ipv6) in net_context level
instead in lower layers for AF_PACKET/SOCK_RAW/IPPROTO_RAW type sockets
when sending data.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2023-01-09 19:21:18 +01:00
Jonathan Rico
e6aba3e9af Bluetooth: host: clear ATT_CONNECTED flag on detach
Clear the `ATT_CONNECTED` flag when a channel is detached (could be after
an ATT timeout).

Also convert the assert checking it in `chan send` to an `if` test, since
the channel could be disconnected from a different thread than the one
triggering `chan_send`.

Fixes #53247.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-01-09 19:19:39 +01:00
Flavio Ceolin
a2a2c62abd tracing: none: Remove unnecessary headers
This file does not need any header, remove all of them.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-09 12:07:28 -05:00
Emil Gydesen
d37613d20a Bluetooth: Audio: Audio ISO use log_config_inherit
Change the BT_AUDIO_ISO logging module to use
log_config_inherit to be consistent with the other LE Audio
logging modules.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Emil Gydesen
a9071b361f Bluetooth: Audio: Add missing codec debug Kconfig
Add misisng codec debug Kconfig for the codec.c file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Emil Gydesen
6ca40703d1 Bluetooth: Audio: Fix CAP initiator debug level
Add missing debug level Kconfig option and use it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Emil Gydesen
5e49282dab Bluetooth: Audio: Fix CAP Acceptor Debug log level
The implementation did not use the defined log level
Kconfig.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Gerson Fernando Budke
313049e325 mgmt: updatehub: Rework check integrity
The TinyCrypt is the current library used by UpdateHub to perform
SHA-256 integrity check. This refactor code and add support to
mbedTLS library. It changes default library to mbedTLS to use
hardware accelerator when available.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-09 15:24:10 +00:00
Gerson Fernando Budke
358ad431b8 storage: flash_map: Add name for select integrity backend
Currently choice for FLASH_AREA_CHECK_INTEGRITY does not have a
denomination. Without that it is not possible select a default
backend hash backend for integrity check at project configuration.
This add a name to allow select flash area check integrity backend.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-09 15:24:10 +00:00
Vinayak Kariappa Chettimada
9aa4cdbb67 Bluetooth: Host: Fix access of uninitialized bt_dev.le.acl_pkts
ISO Synchronized Receiver only builds do not transmit and
hence may not have any tx buffers allocated in a
Controller, leaving bt_dev.le.acl_pkts semaphore
uninitialized or bt_conn_get_pkts() returning NULL.
Do not use the semaphore if no Tx buffers allocated in a
Controller.

Regression in commit ef19c64f1b ("Bluetooth: host: poll on
CTLR buffers instead of host TX queue").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-09 12:41:33 +01:00
Kim Sekkelund
78999f0db6 Bluetooth: Audio: TBS: Fix read buffer
Add common function to handle large GATT reads of strings.
Initialize the buffer pointers in the net_buf which is used for large
GATT reads by bt_tbs_client_read_call_state() and
bt_tbs_client_read_current_calls().
Define the size of the allocated buffer based on the enabled features.

Signed-off-by: Kim Sekkelund <ksek@oticon.com>
2023-01-09 12:18:55 +01:00
Emil Gydesen
489e99c091 Bluetooth: ISO: Fix bad handle of data path error for broadcast
The way that the braodcast clause for handling failing
ISO data path would end up in the __ASSERT. It has been
slightly modified to make it use if-else properly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 12:18:11 +01:00
Emil Gydesen
249d4774f3 Bluetooth: Audio: Add bt_audio_dir_str to improve logging of dir
The direction of a stream/endpoint/parameter has just been
logged as a unsigned integer. This commits adds a
value -> string internal function that would log
BT_AUDIO_DIR_SINK as "sink" and BT_AUDIO_DIR_SOURCE
as "source".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 12:18:03 +01:00
Henrik Brix Andersen
11aa8454f0 Revert "random: Change testing random generator"
This reverts commit d6881de3b3.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-09 19:29:50 +09:00
Declan Snyder
d6881de3b3 random: Change testing random generator
The old random timer test was not random-looking
enough on some platforms.

Replace with new test which is psuedo-xoshiro.

The generator is still deterministic
and does not depend on entropy at all,
but should look more random for testing.

Change name of generator tree-wide also.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-09 10:16:55 +01:00
Erik Brockhoff
2f61771948 Bluetooth: controller: consider host ctrl feature bits in feat exchange
Host controlled feature bits were not considered in feature exchange
procedure. This is fixed.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-01-08 19:48:38 +01:00
Aaron Massey
c4be38dec1 fuel_gauge: sbs_gauge: Enable MFR ACC write
Update the SBS Gauge driver that implements the fuel_gauge API to implement
a set_property function allowing the writing of an SBS word to the
manufacturer access register per the SBS spec.

Includes an update to the SBS Gauge emulator and SBS fuel gauge tests to
weakly verify the code runs.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-01-08 19:48:12 +01:00
Aaron Massey
48d5b6c1f1 emul: Correct emul_sbs_gauge to allow SBS word r/w
Fix SBS I2C transfer emulation to accept reads and writes of 16 bit words
as defined by the SBS spec. This change is tested by a following commit
that implements writing and subsequently reading a written SBS property.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-01-08 19:48:12 +01:00
Aaron Massey
c0762d003a fuel_gauge: Implement sbs gauge read for mfr acc
Implement and weakly test fetching the manufacturer access word from an SBS
compatible fuel gauge.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-01-08 19:48:12 +01:00
Emil Gydesen
57218eee31 Bluetooth: Host: Add BT_CONN_INTERVAL_TO_US
The macro BT_CONN_INTERVAL_TO_MS was used a fair amount
of places, but it often was used with integers. This meant
that sometimes the resulting (integer) value would be
incorrect, as something like 7.5ms interval would not
be properly stored as a integer in millisecond units.

Adding BT_CONN_INTERVAL_TO_US allows users to still use
integers to store the result, but in a more accurate unit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-08 19:47:03 +01:00
Emil Gydesen
8d86fa0125 Bluetooth: Audio: Add support for encrypted broadcast
Add support for adding a broadcast code to the broadcast
source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-06 10:35:25 +00:00
Robert Lubos
3fd0801a49 net: ipv4: Fix packet leak with IPv4 autoconf
The IPv4 autoconfiguration feature relies on the fact, that autoconf
ARP packets are always prepared by the ARP module. After recent ARP
refactoring though that could no longer be the case due to packet
queueing mechanism. This could lead to net pkt leaks in the autoconf
module.

Fix this by skipping the pending packet queue for autoconf packets.
Since for autoconf ARP requests there's no really a pending packet
to queue, it can be safely avoided. This results in the ARP request
being always sent for the autoconf case, preventing the packet leak.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-05 14:39:17 +00:00
Juha Ylinen
5e4eeb104d net: lwm2m: Verify data buffer size in lwm2m_engine_set()
Check data buffer size and return error if
     * buffer size is too small for opaque or string data type
     * buffer size is not equal to res data length when data type
       is fixed size

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-05 14:39:01 +00:00
Mariusz Skamra
8cd6c55d96 Bluetooth: audio: ascs: Fix possible race condition
This fixes possible ASE state race condition. The notification is sent
immediately once the ASE state changed that eliminates a situation where
the state was changed by user action (API function call) when the state
was not yet notified to the remote Unicast Client.

Fixes: BAP/USR/SCC/BV-158-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-05 12:43:32 +01:00
Pascal Brogle
60bf310aae net: lwm2m: fix senml cbor object link encoding
use text format instead of tlv format

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-05 12:43:24 +01:00
Juha Heiskanen
a70f420b2b net: lib: Patch file for generated code fix
Patch for generated lwm2m senml-cbor.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Juha Heiskanen
d939c79af1 net: lib: LwM2M SenML-Cbor regenrated files update
Patched and fixed regenerated code.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Juha Heiskanen
637c9bbf95 net: lib: regenerate cbor code using zcbor
with the updated cddl for object links.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Pascal Brogle
547c3063b9 net: lwm2m: support senml cbor object link
use "vlo" map key

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-05 12:43:24 +01:00
Juha Ylinen
eb914f45d1 net: lwm2m: Check return value from lwm2m_rd_client_pause/resume
Check return values from lwm2m_rd_client_pause() and
lwm2m_rd_client_resume() when engine thread suspend is requested.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-05 12:43:00 +01:00
Sam Hurst
983b693198 usb_c: Stop chunking_not_supported timer on exit
Stop chunking_not_supported timer on exit

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
0ed5c886c9 usb_c: Remove unnecessary PE_FLAGS_PROTOCOL_ERROR flag
Remove unnecessary PE_FLAGS_PROTOCOL_ERROR flag

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
77c7a51e4d usb_c: Remove unnecessary code from PE_Send_Soft_Reset
Remove unnecessary code from PE_Send_Soft_Reset

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
3af2752680 usb_c: Transition to Sink Ready on sender response timeout
Transition to pe_snk_ready state from pe_drs_send_swap_run,
on sender response timeout

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
24e18d46f1 usb_c: Properly handle Protocol Errors during DRS
From 8.3.3.4.2.1 PE_SNK_Send_Soft_Reset State, Error Recovery
should be performed if a Protocol Error happens during a Data
Role Swap.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
c27a3a31d3 usb_c: Fix DPM request handlers
Processing the common DPM request handler in the
Sink DPM request handler.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
f04da7f7ab usb_c: Check state machine array of states
Build time check that the number of states initialized
in the state machine array matches the number of enums
used to index said array.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
5b3155ff90 usb_c: Use atomic arrays for PE flags
Use atomic arrays for PE flags because the total number
of Policy Engine flags could exceed 32

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
914fed36d5 usb_c: run clang-format
Run clang-format

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
7910c617be usb-c: Refactor USB-C Subsystem Sink
Refactor USB-C Subsystem Sink so that Power Delivery
Source support and be easily added.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Chris Friedt
4108e14740 ztest: provide sys_clock_tick_set syscall
Accurate timekeeping is something that is often taken for granted.

However, reliability of timekeeping code is critical for most core
and subsystem code. Furthermore, Many higher-level timekeeping
utilities in Zephyr work off of ticks but there is no way to modify
ticks directly which would require either unnecessary delays in
test code or non-ideal compromises in test coverage.

Since timekeeping is so critical, there should be as few barriers
to testing timekeeping code as possible, while preserving
integrity of the kernel's public interface.

With this, we expose `sys_clock_tick_set()` as a system call only
when `CONFIG_ZTEST` is set, declared within the ztest framework.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-04 21:12:58 +01:00
Mariusz Skamra
9148fb65d7 Bluetooth: att: Fix deadlock on meta data context allocation
This fixes deadlock that happened waiting for meta data in system
workqueue.
The meta data always get freed in the system workqueue,
so if we're in the same workqueue but there are no immediate
contexts available, there's no chance we'll get one by waiting.

Fixes: #53455
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-04 16:51:05 +01:00
Emil Gydesen
7d410c5cad Bluetooth: Audio: Fix issue with creating unidirectional CIS
As the unicast client, we would always create bidirectional
CIS to ensure that the PHY parameter is correctly set.
We can, however, just set the (required) PHY value and
leave the SDU and RTN values as 0, to avoid
creating bidirectional CIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
1e5be3f020 Bluetooth: Audio: Fix issue with unicast client src/snk ASE count
If either the sink or source ASE count was zero, calls to
ARRAY_SIZE(srcs) or ARRAY_SIZE(sinks) would cause a build warning.

The arrays should actually not be there at all if the respective
ASE count was 0, as that is just a waste of memory. The arrays,
and all uses of them, have been properly guarded.

This also adds a build assert to ensure that at least one
of them is non-zero, and that we also test building either
of them with the value 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
b9a6e04cb3 Bluetooth: Audio: Add AUDIO_ISO debug logging
Add a logging module for the audio_iso.c file, to enable
logging for that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
32ff1b671b Bluetooth: Audio: Add (un)bind of audio iso for streams
This allows us to allocate and bind the Audio ISO structs
to Audio Streams, thus allowing us to create the unicast group
before they have been configured.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
4c058402a5 Bluetooth: Audio: Fix issue with deleting unicast groups
There was a bug in bt_audio_iso_unbind_ep that caused an
assert, missing unbinding on stream released callback
and missing state check in bt_audio_unicast_group_delete

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Tomasz Moń
73e3fcabc0 usb: dfu: Schedule timer handler from USB workqueue
Use k_work_delayable instead of k_timer in order to execute timeout in
USB workqueue context instead of ISR context. This fixes Will-Detach on
targets where usb_dc_detach() uses functions not allowed in ISR context,
e.g. nrfx usb_dc_detach() acquires mutex.

Fixes: c27d48c89a ("usb: dfu: Support DFU with WinUSB on Windows")

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-01-04 10:33:35 +01:00
Juha Ylinen
c7a5f7fda7 net: lwm2m: Deprecate Kconfig for LwM2M RD Client
RD-Client is essential part of LwM2M specification and it can't
be disabled from LwM2M engine. This commit deprecates Kconfig
variable CONFIG_LWM2M_RD_CLIENT_SUPPORT and removes
all usages if it.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 13:23:46 +01:00
Hein Wessels
3210541c86 toolchain: gcc: rename popcount to avoid conflict with C++20
The macro conflicts with the C++20 feature std::popcount

fixes zephyrproject-rtos/zephyr#53421

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-01-03 11:06:45 +01:00
Marco Argiolas
2527320848 net: lib: sntp: add support for unspecified IP-family type
`sntp_simple()` was forcing to resolve SNTP-server's URL into IPv4 address
addresses. This was not allowing sntp_init() to succeed in case the system
 did not support IPv4 addresses (returning EPFNOSUPPORT, ie. Protocol
Family error).
Now by default SNTP has unspecified family type and it relies on
`net_getaddrinfo_addr_str()` to be able to resolve literal server URLs
into the supported IP family type.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-01-03 11:03:25 +01:00
Marco Argiolas
d51182d57d net: lib: sockets: support IPv6-only use case with AF_UNSPEC
Setting `hints.ai_family` to `AF_UNSPEC` was causing
`net_getaddrinfo_addr_str()` and in turn `getaddrinfo()` to resolve the
literal SNTP SERVER first into IPv4 and then (if supported) IPv6 addresses.
 This was causing useless waste of time and memory in case IPv4 was not
supported. In addition, in case IPv4 addresses were not supported, other
system components (eg. SNTP) could fail due to the DNS returning IP
addresses with unsupported family type (ie. IPv4).
Now, if address family is not explicitly set to `AF_INET` (ie. IPv4), then
 no attempt is made to resolve SNTP server address into an IPv4 address.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-01-03 11:03:25 +01:00
Juha Ylinen
7dfa2c8a2b net: lwm2m: Add shell commands
Add shell commands to read and write native time_t value.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:03:16 +01:00
Seppo Takalo
a33f3b6abb net: lwm2m: Add shell command to enable timeseries cache
Add shell command

  cache   :Enable data cache for resource
           cache PATH NUM
           PATH is LwM2M path
           NUM how many elements to cache

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Heiskanen
1800e629e6 net: lwm2m: LwM2M times series data update
Fixed problem for matching path url with or without '/'
by change time series data structure to use struct lwm2m_obj_path.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Heiskanen
3abd9c364a net: lwm2m: LwM2M Object path equal API
Added new API for check is 2 object path equal.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Ylinen
16b6892294 net: lwm2m: Refactor lwm2m_information_interface_send()
Call lwm2m_send_message_async() from function
lwm2m_information_interface_send() and remove duplicate code.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:02:44 +01:00
Juha Ylinen
1111184b74 net: lwm2m: Remove lwm2m_send_message() from public API
lwm2m_send_message() sends a message directly to the socket. Remove
the function from public API and combine the code with
socket_send_message().

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:02:44 +01:00
romain pelletant
5c14c56f2c net: lwm2m: add binaryappdatacontainer obj support
OMA LwM2M object 19 support for application specific binary data
Related issue #53340

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-01-03 11:02:09 +01:00
Krishna T
59842531d1 net: zperf: Make shell dependency optional
Now that we a proper API, shell is just optional, so, make the
dependency optional by refactoring the code.

Also, add a build test combination in twister.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-03 11:02:01 +01:00
Miquel Raynal
9ce8c26d34 net: l2: ieee802154: Add missing scan callback registration
Initializing an event callback with net_mgmt_init_event_callback() just
sets some of the callback fields but do not propagate those masks in the
core. If we want to use the callback, it is necessary to also call
net_mgmt_add_event_callback().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
6a11e79b4b net: l2: ieee802154: Fix a wrong channel change during association
The current association logic starts by changing the channel. The way it
is done is wrong because it dereferences req->channel which is simply
not initialized by the caller. But anyway, the command itself does not
support providing a channel so we must already be on the right one when
trying to associate. Hence, drop this channel change call.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
31b35973e3 net: l2: ieee802154: Change the hardware filters while associating
During an association, the peer we are trying to connect to will send us
an association response frame with the destination PAN ID set to the PAN
ID we try to join. If we do not update the hardware address filters
beforehands, it is likely that the hardware will just discard the
response and the association will fail.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
19e67800f9 net: l2: ieee802154: Avoid dangling MAC command bits
While the packet structures seem to always be reset when they are
allocated, it's apparently not the case of the data buffers. Indeed,
these are allocated differently and just attached to the packet
structure through a frag/buffer member.

Experience shows that we may get uninitialized buffers so let's set
all MAC parameter bits one by one, even the reserved ones.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
2fd336c5d2 net: l2: ieee802154: AR shall be provided in association requests
The spec clearly states: "association requests shall set the AR bit".

Even though Zephyr can currently only implement RFD devices which are
not expected to support incoming association requests, because this MAC
command is actually processed until being voluntarily ignored, let's
ensure the expected "ar" value is right to avoid failing because of a
wrong reason.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
fa05c60674 net: l2: ieee802154: Fix logic with address types
When validating a MAC command, the "src" and "dst" fields may be set to:
- IEEE802154_ADDR_MODE_SHORT (0x2)
- IEEE802154_ADDR_MODE_EXTENDED (0x3)
- IEEE802154_ADDR_MODE_SHORT | IEEE802154_ADDR_MODE_EXTENDED (0x3)
Hence when the mode check happens, any times the mode is set to SHORT
the check will fail while in practice it was meant to be valid because
the check is:

    if (src_mode == src || dst_mod == dst)

Use bitfields when relevant so that when checking capabilities we use
the bit offsets rather than the plain numbers.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
b86b7d3a41 net: l2: ieee802154: Fix address length macros
When validating a MAC command, there is sometimes a misunderstanding of
what "src" and "dst" length mean.

There are actually two fields in the MHR:
- One giving the type of address, if it is short or extended, it is the
  value provided by the macros IEEE802154_ADDR_MODE_{SHORT,EXTENDED} and
  their respective decimal values are 2 and 3.
- One giving the size of the address field, this is
  IEEE802154_{SHORT,EXT}_ADDR_LENGTH and their value is actually 2 and 8
  (bytes).

The function validate_mac_command() provides inputs to
validate_mac_command_cfi_to_mhr() which expects the former information.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Andrei Emeltchenko
d320100df4 net: ip: Fix dereference before NULL check
Fix warnings like "Dereference before NULL check". Also make check
readable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-12-30 11:11:06 +00:00
Krzysztof Chruscinski
63eba62876 logging: Reset buffered message counter on init
Add reset of buffered messages counter to the initialization function.
It is for testing purposes sinces in the application logging is
initialized only once.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-29 10:33:29 +01:00
Piotr Jasiński
ceb7ca7e80 modules: build segger debugmon code with config
Updated segger module CMake to build code added by
https://github.com/zephyrproject-rtos/segger/pull/14 when relevant
config is provided.

Signed-off-by: Piotr Jasiński <piotr.jasinski@nordicsemi.no>
2022-12-28 12:00:46 +01:00
Dominik Ermel
77f21ce966 storage: flash_map: shell: Show device pointer instead of ID
The commit changes flash_map list output to display flash_map
assigned pointer instead of device ID which was not propagated
anyway.
The commit also fixes formatting of the output.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-27 13:24:55 +01:00
Jamie McCrae
b64ea89ed5 mgmt: mcumgr: img_mgmt: Fix mismatched slot missing variable
Fixes an issue with a missing variable when
CONFIG_IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT is enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-24 16:58:11 +01:00
Juha Heiskanen
4a50f9362f net: lib: LwM2M rd client fix
Fix LwM2M rd client stop call hang when Queue client is at
RX_ON_IDLE_STATE. Added miossing connection resume for
de-register functionality.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-12-22 15:50:31 +00:00
Kai Vehmanen
0368b49ea7 logging: fix error handling in link_filters_init
If k_malloc() of filters fails in log_mgmt.c:link_filters_init(),
return an error and do not rely on the __ASSERT(0).

If __ASSERT_ON==0 in the build, assert will not trigger and
code will proceed to execute

  memset(NULL, 0, sizeof(uint32_t) * total_cnt);

Avoid this by returning -ENOMEM on error.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-12-22 14:43:43 +01:00
Juha Ylinen
1827636ab6 net: lwm2m: Verify receiving buffer size in lwm2m_engine_get()
Check receiving buffer size and return error if
 * buffer size is too small for opaque or string data type
 * buffer size is not equal to data lenght when data type is
   fixed size

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2022-12-22 13:44:27 +01:00
Dominik Ermel
671625cd0c mgmt/mcumgr: Add Kconfig option naming notes
The commit adds Kconfig option naming notes to Kconfig
files of MCUmgr subsystem.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Dominik Ermel
c7378d0d84 mgmt/mcumgr: Move Kconfig options to proper Kconfig files
After Kconfig options got renamed, some of the no longer fit
to files they have been defined in.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Dominik Ermel
db34adf9c3 mgmt/mcumgr: Standardise MCUmgr Kconfig names
Standardise Kconfig options for MCUmgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Rob Barnes
61b5566e74 logging: Add an option for a custom log header
There are scenarios when it is necessary to globally redefine
a log macro. The existing logging frontend is not sufficient since
it redirects at the function level.

One example is using pigweed_tokenzier. The pigweed tokenizer depends
on intercepting log strings at the macro level to function.

Introduce an option to include a custom application provided header
named "zephyr_custom_log.h" at the end of log.h. This allows an
application to extend the LOG_* macros globally.

This change includes a simple test that redefines the core LOG macros
to include a custom prefix.

Signed-off-by: Rob Barnes <robbarnes@google.com>
2022-12-22 11:09:59 +01:00
Jamie McCrae
23ca3841db mcumgr: img_mgmt: Add SHA256 image upload hash check
Will check an uploaded image's hash against the hash that was
originally supplied before the upload began and return the result to
the client to know if the upload was successful or if there was an
error during upload. Requires CONFIG_IMG_ENABLE_IMAGE_CHECK be
enabled for functionality to be available.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:08:49 +01:00
Hubert Miś
0b5ac4023f ipc: icmsg multi endpoint with nocopy in receive path
Add nocopy feature to icmsg-me initiator and follower roles
in their receive path. This feature is optional, configured
with Kconfig.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
6d3d2309ce ipc: icmsg multi endpoint with nocopy in send path
Add nocopy feature to icmsg-me initiator and follower roles
in their send path.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
3a1c9bce6e ipc: icmsg: send nocopy feature
Add a nocopy feature for sending message through the icmsg IPC library.

Also eliminate data races if multiple threads are using the
same ipc instance and are trying to send a message simultaneously.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
5b023df67f ipc: icmsg: rx nocopy feature
This patch adds an optional nocopy feature for RX message to the icmsg
IPC library. The nocopy feature can be enabled using project
configuration.

If this feature is not used by icmsg users it is recommended to disable it
to reduce memory usage and improve run-time performance.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
4a79754dd5 ipc: icmsg capability to clear rx buffer headers
On system startup icmsg headers space must be cleared before
cores start handshake procedure. The simplest way to enforce
it is to clear memory by the core responsible by enabling
the remote core, before the remote core is enabled and before
the handshake is started.

This patch ensures that nRF53 APP core clears both TX and RX
memory for icmsg before it starts NET core.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-12-22 11:07:44 +01:00
Kamil Gawor
d0e21fe6a6 ipc: Enable ICMSG multiendpoint role by default
This commit enables the initiator or the follower
role for the ICMSG multi-endpoint backend
depending on dts by default.
It is needed when BT_RPMSG transport for HCI is used.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-12-22 11:07:44 +01:00
Robert Lubos
d27ace4012 net: zperf: Simplify shell initialization
Instead of calling zperf shell initialization routine on the first
command execution, initialize it during system boot, along with other
zperf submodules.

Remove redundant IP address configuration on an interface. The default
configuration relies on NET_CONFIG module, so there's no need to set the
address manually in zperf.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
7a2c8d2ab8 net: zperf: Shell cleanup
Zperf shell functionality is now encapsuled within a single file,
therefore it no longer makes sense to have a separate shell_utils
file.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
dd3fb692fe net: zperf: Add shell command to stop TCP/UDP server
Add zperf shell command to stop TCP/UDP server.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
87ca1c3329 net: zperf: Make UDP/TCP servers restartable
Make the TCP/UDP server functionality restartable. Provide a public API
to stop the TCP/UDP server.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
cd4f7cbc61 net: zperf: Add public API to start TCP/UDP server
Add public API for zperf download functionality. The TCP/UDP server
modules are decoupled from shell, allowing to trigger download directly
from the application code. The shell submodule makes use of this new
public API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
722ed07287 net: zperf: Add shell option for asynchronous upload
Add shell option to the UDP/TCP upload command, which allows to execute
the upload asynchronously. This allows to unblock the shell for other
commands during the upload.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
fde9577e24 net: zperf: Implement asynchronous upload API
Add an API which allows to perform UDP/TCP upload operations
asychronously.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
812a1bc152 net: zperf: Define a public upload API for the library
This commit defines a public API for zperf upload functionality. The
UDP/TCP uploader modules are decoupled from shell, allowing to perform
uploads directly from the application code. The shell submodule makes
use of this new public API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Jamie McCrae
b4b6346cdc mgmt: mcumgr: Make Bluetooth and UDP transport init automatic
This moves the UDP and Bluetooth initialisation for MCUmgr to be
performed automatically with the new hander registration feature.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Jamie McCrae
541fcb884d mgmt: mcumgr: Make handler registration functions static
Makes group registration functions for MCUmgr handlers static as
they are registered automatically at startup.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Jamie McCrae
d7557102c0 mgmt: mcumgr: Add iterable section to register MCUmgr handlers
This replaces the requirement for applications to manually
register MCUmgr handlers by having an iterable section which
then automatically registers the handlers at boot time.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Emil Gydesen
4e3205d238 Bluetooth: Audio: Add packing to unicast group create
Add the ISO packing field when creating a unicast group.

This refactors the structure of the unicast group create,
as it now takes both the packing as a group parameter, as well
as an array of stream-specific parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-22 10:59:16 +01:00
Emil Gydesen
ba1949759d Bluetooth: Audio: Add packing field to broadcast source
Add support for setting the ISO packing field when
creating a broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-22 10:59:16 +01:00
Emil Gydesen
2935cac9d6 Bluetooth: Audio: Fix handling properly deleting endpoints
When there is an ACL disconnect, or the unicast group is otherwise
deleted, the endpoints were not properly handled, causing
incorrect `dir` values and ASSERTs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
21fd387cab Bluetooth: Audio: Fix unicast group add/free handling of endpoints
When adding or removing a stream from the group, the
endpoint may or may not have been allocated depending
on the state of the endpoint.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
f1bedd01c1 Bluetooth: ISO: Remove wrong requirement for cc_len
The hci_le_setup_iso_data_path function required that if
the path->cc was set, the length could not be 0.

There is no reason why it should not be allowed to be 0
in that case.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
a7e7d87912 Bluetooth: Audio: Fix issue with creating the CIG as unicast client
The unicast client could not create a CIG with a unidirectional
CIS, because it would not set the correct values as per the
HCI spec for the unused CIS direction.

Instead of implementating a work around, this commit modifies
it so that for unidirectional CIS, we copy the QoS values
to the unused direction, so that we always set valid values,
but it also allows us to actually use that CIS direction later,
assuming that the QoS settings does not change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
f239df0ca7 Bluetooth: Audio: Fix audio_iso handling for unicast client
For the unicast client, the direction for the endpoint
is reversed in terms of RX/TX, i.e. a sink endpoint is
RX for the unicast server and broadcast sink, but TX
for the unicast client, and similar for the source endpoint.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Trent Piepho
2112844eea logging: backend_uart: Reword buffer size Kconfig text
As written, the title and description of the Kconfig option seem to
specify the logging sub-system will not flush until the buffer is full.
Someone reading this would expect that shorter log message will not be
flushed until the specified number of bytes accumulate.

This is not the case.  Each log message is flushed when finished.  The
size is only the maximum bytes of a single formatted message's contents
that will be accumated before the backend flushes.

What's more, it only applies in deferred mode.  In immediate mode there
is no buffering, not just of multiple log messages but also of the
message contents as they are formatted.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2022-12-21 12:23:23 +01:00
Ryan McClelland
34cfba73b4 usb: device: hid: correct bcdHID to v1.11 spec
bcdHID is intended for the spec version of USB HID. It was pointing to the
v1.1 bcdUSB define which happens to be the same value for the v1.10 hid
spec version. This corrects it to use the v1.11 HID spec.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2022-12-21 12:20:55 +01:00
Erwan Gouriou
66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Grixa Yrev
2a992c65c0 net: websocket: new receiving algorithm
websocket_recv_msg() is reworked with using fsm. Now the function
return 0 when payload is empty, -ENOTCONN if socket close. Receiving
empty ping and sending empty pong were added in tests.
Fixes #52327

Signed-off-by: Grixa Yrev <grixayrev@yandex.ru>
2022-12-20 17:05:12 +00:00
Pavel Vasilyev
932e57396f Bluetooth: Mesh: Add macros to initialize bt_mesh_msg_ctx struct
The macros are added to make clear which fields of `struct
bt_mesh_msg_ctx` needs to be initialized by an application.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-20 17:05:04 +00:00
Lars Knudsen
081b83531b Bluetooth: has: Make HAS registration dynamic
This changes HAS registration to be dynamic and let's the
application set Hearing Aid Type and binaural features.

Often, devices are flashed with generic firmware with some
features stored post factory production, requiring
the settings to be moved from compile time to run-time.

This change will increase the RAM usage as the GATT
service is moved from ROM to RAM.

Signed-off-by: Lars Knudsen <larsgk@gmail.com>
Co-author: Soren Engquist <soren@engquist.dk>
2022-12-20 17:04:45 +00:00
Jamie McCrae
b4c2b57f1b mgmt: mcumgr: Make returning rc responses when status is OK legacy
This change changes the previous mcumgr behaviour of return result
codes when the status is 0 (OK) to being legacy behaviour, instead
it will skip the rc field for these responses. If there is only an
rc field with status 0 to return, then mcumgr will now instead just
return an empty map.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-20 11:57:22 +01:00
Lingao Meng
f3cea46c75 Bluetooth: Host: Fix missing pull left mem in scan pdu
For num_reports field bigger 1, should pull left mem.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-12-20 10:20:10 +01:00
Emil Gydesen
1424df424c Bluetooth: Audio: Add broadcast source metadata update function
Add API to do the BAP Broadcast Source Metadata update procedure,
which updates the metadata of a broadcast source while
it is streaming.

This is also makes all checks for the "head stream" the same.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-20 09:23:08 +01:00
Emil Gydesen
302ec9fa37 Bluetooth: Audio: Remove const for bt_audio_stream_reconfig codec
The codec is assigned to the stream. However since the metadata,
which is stored in the codec, may be modified by other means,
the stored pointer cannot be const, and thus the
codec argument to bt_audio_stream_reconfig cannot be const
either.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-20 09:23:08 +01:00
Fredrik Danebjer
18a889fb8b Bluetooth: Audio: ASCS: Make ASE Allocation Dynamic
Decoupled the ASEs from the ASCS Session and made them dynamically
allocated instead. A Kconfig option was added to set the maximum
number of active ASEs at a single time. The intent here is to allow
the developer greater control over memory usage; this fix addresses
one of the largest ram usages in le audio.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-12-20 09:23:00 +01:00
Fredrik Danebjer
15644da0a4 Bluetooth: Audio: Endpoint: Decouple Client and Server
Refactored out the client and server members of the endpoint struct
and placed the relevant members in wrappers in ascs and
unicast_client.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-12-20 09:23:00 +01:00
Emil Gydesen
32c7b9f46b Bluetooth: Host: Add logging of pairing req/rsp
Add logging of the fields in the sent and received pairing
requests and responses. This makes it easier to debug
why a pairing would be e.g. rejected, or simply to get
more insight in the resulting pairing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-20 09:22:10 +01:00
Robert Lubos
a60f32549e net: l2: ieee802154: Align LL address update routine
IEEE802154 L2 may modify the LL address during interface operation (when
processing MAC command). So far the L2 workaround the LL address update
protection by clearing the NET_IF_UP flag temporarily, but due to recent
changes it no longer works. Update this workaround to verify
NET_IF_RUNNING flag instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 18:18:03 +01:00
Robert Lubos
129f34fd0b net: if: Allow to set LL address after interface was brough admin UP
Bluetooth IPSP L2 sets the LL address only after establishing Bluetooth
connection. As this can take place after the interface was brough UP by
the application, the network interface API should not block such
attempt. Instead, verify the NET_IF_RUNNING flag.

For the same reason, move the assert verifying that LL address is set
from net_if_up() (which only puts the interface in the admin UP state)
into the function that transitions the interface into operational UP
state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 18:18:03 +01:00
Robert Lubos
f38d5f440f net: l2: bluetooth: Remove invalid check
After network interfaces state handling rework, it's no longer correct
to verify the connection status on `net_if_up()`, as this only changes
the administrative state of the interface. The interface won't be put in
operational UP state until it's connected.

This check prevented the interface from being brought up during system
boot.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 18:18:03 +01:00
Emil Gydesen
a96f8ba9ba Bluetooth: ISO: Fix ISO MTU when CONFIG_BT_BREDR=y
If CONFIG_BT_BREDR=y and bt_dev.le.acl_mtu == 0, then we
would report the bt_dev.br.mtu for ISO channels.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:16:01 +01:00
Emil Gydesen
ba0bb89a70 Bluetooth: ISO: Fix conn_mtu for BT_CONN_TYPE_ISO
If the bt_dev.le.iso_mtu was 0, then we would report
bt_dev.le.acl_mtu if CONFIG_BT_CONN=y (which is often true when
CONFIG_BT_ISO=y). Thus if the ISO MTU is 0, we would often
return a non-0 value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:16:01 +01:00
Emil Gydesen
b245b023e1 Bluetooth: Audio: Always start BAP discovery at handle 0x0001
Instead of only conditionally starting the discovery at
0x0001, we now always start it at that handle. Since we are
reading by UUID, this should not really affect performance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:13:02 +01:00
Emil Gydesen
fd6e6601e0 Bluetooth: Audio: Fix logging of object ID in mcc.c
mcc.c used 0x%016x, but for some platforms we need to
be more explicit and use 0x%016llx to avoid compile
warnings.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:12:50 +01:00
Emil Gydesen
e3fcf8267a Bluetooth: Audio: Fix issue with non-bonded devices in has.c
The HAS implementation of the security_changed callback
expected all devices to have bonded, and thus always added them
to the ntf_bonded implementation.

This adds a check to whether the device is actually bonded.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:12:38 +01:00
Marcin Niestroj
c707585e75 settings: remove local settings_mount_*_backend()
Prototypes of those functions are already in header files in
subsys/settings/include/settings/ directory, so no reason to have
duplicates in C files.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-19 16:00:08 +00:00
Marcin Niestroj
ebe815650e settings: fcb: remove second settings_fcb_storage_get() prototype
Remove settings_fcb_storage_get() prototype, as there the same prototype 5
lines below.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-19 16:00:08 +00:00
Jamie McCrae
95697b5fcf mgmt: mcumgr: Replace non-zephyr cmake functions with zephyr versions
This fixes an issue whilst investigating using iterable sections,
which cannot be used when the non-zephyr prefixed functions are
used. It also resolves a possible critical bug intoduced with the
MCUmgr rework whereby functions or elements seem to have silently
dropped.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-19 13:02:32 +01:00
Robert Lubos
1448923be3 net: shell: Make it possible to abort ping command
Rewrite the "net ping" command handling, to allow the command to be
aborted during execution. This includes:

* Using shell bypass mode to capture input whilst the ping is active.
* Using system workqueue to send individual ping requestes, instead of
  sending ping requests directly from shell thread, in a blocking
  manner. This is needed because in order to receive input in the
  registered bypass handler, the shell thread must be unblocked to
  process the input.
* The bypass mode is left after receiveing `CTRL-C` character (which
  cancels the ping), after receiving all expected Ping replies or after
  the timeout occurs.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 09:46:53 +00:00
Robert Lubos
55af3dd075 shell: Clear command buffer when leaving bypass mode
If bypass mode is left outside of the registered bypass handler, the
command buffer was not cleared, basically containig leftovers from the
processing of the previous command. This resulted in undefined behaviour
on consecutive shell operations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 09:46:53 +00:00
Corey Wharton
21a7c2d7eb pm: don't suspend unready devices when entering low power states
The PM subsystem should not call the PM control callbacks on
uninitialized devices when entering low-power states.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2022-12-19 09:46:17 +00:00
Jonathan Rico
dc4d63e97b Bluetooth: host: adv: set the address in bt_le_adv_resume
The address could have changed. The issue linked (and bsim test in previous
commit) shows a scenario where that could happen:

- we start scanning, host will use NRPA
- we start advertising, host will use identity address
- a device connects (as a central)
-> advertising resume fails for some unrelated reason
- another device connects (as a peripheral)
- the central device disconnects, we resume scanning
- the peripheral disconnects, the stack resumes advertising
-> but it mistakenly advertises using the NRPA set by the scanner

Fixes #52059 .

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-19 09:37:25 +00:00
Jonathan Rico
5f98b1bea4 Bluetooth: host: adv: add adv_is_directed helper
Makes it more readable.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-19 09:37:25 +00:00
Mateusz Wielgos
217987f1b5 usb: host: add port power and port reset USB hub features
Add port power and port reset USB hub features.

Signed-off-by: Mateusz Wielgos <mateusz.wielgos@emerson.com>
2022-12-16 13:21:12 +01:00
Johann Fischer
7c1ef35027 usb: add initial USB host support
This is initial support. Necessary to test the UHC driver API,
for the USB support test implementations, and upcoming USBIP support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-16 13:21:12 +01:00
Emil Gydesen
c27db9ed90 Bluetooth: Shell: Move the name filter last
Moved the name filter last, as that it the most expensive
to use.

The address filter has almost been moved after the more
trivial checks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-16 11:05:24 +00:00
Emil Gydesen
bc1bb4f63c Bluetooth: Shell: Add pa_interval scan filter
Add filtering for the pa_interval. This can be used to
easier find devices that are advertising with periodic
advertising.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-16 11:05:04 +00:00
Troels Nilsson
c0a5b1ef7b bluetooth: controller: Reduce user ops status to uint8_t
The status field is currently a uint32_t even though there are only
3 possible values. Reducing it to a uint8_t allows status to fit in
existing padding in the struct, saving 4 bytes per ticker_user_op

Updated function signatures to match; ticker_op_func left as-is
to avoid having to update a whole bunch of files for no real benefit

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-12-16 11:02:30 +00:00
Carlo Caione
a337bfc3b3 pm: runtime: Move from mutexes to semaphores
To be able to call pm_device_runtime_put() from an IRQ context, move
from mutexes to semaphores and force the async path when the put
operation is called from an ISR.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-15 22:35:38 +01:00
Carlo Caione
d38a6b4bcd pm: runtime: Migrate from condition variables to events
For the async operation move from condition variables to events to
reduce the dependency on the mutexes that cannot be used in IRQ
context.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-15 22:35:38 +01:00
Stephanos Ioannidis
37c6d52f8c random: Fix non-random number generator warning condition
The `TEST_RANDOM_GENERATOR` symbol in itself does not imply that a
non-random number generator is selected -- that is indicated by the
`RNG_GENERATOR_CHOICE` choices, of which only `TIMER_RANDOM_GENERATOR`
is a non-random generator.

This commit updates the Random subsystem to print the "non-random
number generator usage warning" when `TIMER_RANDOM_GENERATOR` is
selected, as opposed to when `TEST_RANDOM_GENERATOR` is selected.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-12-15 22:35:31 +01:00
Stephanos Ioannidis
6f91f97939 random: Clarify the semantics of TEST_RANDOM_GENERATOR
The `TEST_RANDOM_GENERATOR` Kconfig symbol indicates that a non-random
number generator (i.e. a random number generator that is not truly
random) is _allowed_ to be used for testing purposes, and not
necessarily that a non-random number generator is _selected_ -- that is
indicated by the `RNG_GENERATOR_CHOICE` choices that depend on
`TEST_RANDOM_GENERATOR` (i.e. only `TIMER_RANDOM_GENERATOR` as of now).

This commit updates the `TEST_RANDOM_GENERATOR` Kconfig symbol
description to reflect and clarify that.

It also removes the `TEST_RANDOM_GENERATOR`'s dependency on
`ENTROPY_HAS_DRIVER` because the act of _allowing_ a non-random number
generator to be used does not depend on the availability of an entropy
driver -- when an entropy driver is available, by default, the
`ENTROPY_DEVICE_RANDOM_GENERATOR` will be selected; otherwise,
`TIMER_RANDOM_GENERATOR`, a non-random generator, will be selected.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-12-15 22:35:31 +01:00
Reto Schneider
c646a5576a net: zperf: Fix SO_RCVTIMEO dependency
Since 6c30c9ac47 (samples: net: zperf:
Rewrite upload part to use sockets), zperf uses SO_RCVTIMEO in UDP mode,
hence must depend on/enable support for it.

Without SO_RCVTIMEO support, zperf fails like this:
> nb_packets=47   delay=188964    adjust=-13
> setsockopt error (109)
> setsockopt error (109)
> -
> Upload completed!
> LAST PACKET NOT RECEIVED!!!
> Statistics:             server  (client)
> Duration:               0 us    (10.19 s)
> Num packets:            0       (50)
> Num packets out order:  0
> Num packets lost:       0
> Jitter:                 0 us
> Rate:                   0 Kbps  (9 Kbps)

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-12-15 17:14:26 +01:00
Mariusz Skamra
5fc2079963 Bluetooth: audio: ascs: Handle CIS failed to be established error
In case CIS failed to be established, leave the ASE in enabling state
waiting for peer to retry.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-12-15 14:31:11 +00:00
Tomasz Moń
21975231e2 usb: device: cdc_acm: Prevent recursive logging loop
Allow enabling CDC ACM logging only if CDC ACM is not used as logging
backend. This prevents endless recursive logging loop, especially
visible when minimal footprint logging is enabled.

Fixes: #52981

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-12-15 14:54:24 +01:00
Jonathan Rico
ca51439cd1 Bluetooth: host: copy fragment data at the last minute
Only copy the data from the 'parent' buf into the segment buf if we
successfully acquired the HCI semaphore (ie there are available controller
buffers).

This way we avoid pulling and pushing back the data in the case where there
aren't any controller buffers available.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-15 09:58:07 +00:00
Jonathan Rico
ef19c64f1b Bluetooth: host: poll on CTLR buffers instead of host TX queue
When there are no buffers, it doesn't make sense to repeatedly try to send
the host TX queue.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-15 09:58:07 +00:00
Jonathan Rico
c3e5fabbf1 Bluetooth: host: make HCI fragmentation async
Make the ACL fragmentation asynchronous, freeing the TX thread for sending
commands when the ACL buffers are full.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-15 09:58:07 +00:00
Emil Gydesen
cbd1e67574 Bluetooth: Audio: Remove newlines from HAS log statements
Removes two log statements in HAS that added a newline,
which it shouldn't.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 10:45:37 +01:00
Emil Gydesen
7630161376 Bluetooth: Audio: Shell: Improve printing of incoming audio
Instead of printing every audio packet (typically
arriving every 7.5 or 10ms), we now only print every 100th.

Ideally we would add support for changing the number of
"skippe" audio packets at runtime in a shell command, but
that will be postponed.

Ideally we would also have a rx_cnt per stream, but that will
also be postponed to the future, and should be fixed with e.g.
the sequence number (seq_num) as well.

Finally this commit also adds a verification if the currently
incoming data packet contains the same ts or seq_num of the
previous one, and print if it does, as this indicates that
we are receiving some invalid data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 10:44:56 +01:00
Emil Gydesen
b2a8fa1392 Bluetooth: Audio: Shell: Fix issue with restarting start_sine
The lc3_start_time and lc3_sdu_cnt were not reset properly,
causing it to fail when trying to do start_sine after calling
stop_sine.

This commit also ensures that the sending of the sine wave is
stopped once the stream is either released or stopped.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 10:44:11 +01:00
Emil Gydesen
366ddedeb6 Bluetooth: Host: Fix issue with setting 0/NULL data for PA
bt_le_per_adv_set_data would not accept the ad to be NULL or
the ad_len to be 0, making it impossible to set no data (which
effectively clears existing data).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 09:40:16 +01:00
Emil Gydesen
336d706f52 Bluetooth: Host: Add length values to malformed adv data warning
Add the advertised length, and the actual length, in the log statement
so it is more clear what the issue is.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 09:39:55 +01:00
Fredrik Danebjer
c5b270e7b0 Bluetooth: GATT: Fix missing endianess conversion on include end-handle
Added missing conversion to CPU endianess for the include service
end-handle.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-12-14 17:26:03 +01:00
Wojciech Slenska
4b2fffc7f9 shell: added SHELL_AUTOSTART configuration option
In some applications, there is a need to don't start the shell by
default, but run it later on some special condition.
When SHELL_AUTOSTART is set to n, the shell is not started after
boot but can be enabled later from the application code.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-12-14 15:17:02 +01:00
Ian Oliver
1675d49b4c log_core: Add Kconfig symbol for init priority
Users may want to do some configuration after the kernel is up, but
before initializing the log_core. Making the log_core's init priority
configurable makes that possible.

Signed-off-by: Ian Oliver <io@amperecomputing.com>
2022-12-14 15:16:54 +01:00
Marcin Niestroj
2d3365200c settings: file: drop CONFIG_SETTINGS_FILE_DIR
There is already CONFIG_SETTINGS_FILE_PATH, which is set to full file path,
while CONFIG_SETTINGS_FILE_DIR is required to be set to its parent
directory. This is redundant, as parent directory path can be easily found
out either during runtime or optionally during buildtime by CMake.

CONFIG_SETTINGS_FILE_DIR was actually introduced recently after Zephyr 3.2
release as a replacement of deprecated CONFIG_SETTINGS_FS_DIR. This means,
that there is no need to deprecate it for 3.3 release and dropping it
should be fine. Adjust 3.3 release notes accordingly, so that
CONFIG_SETTINGS_FILE_PATH will be used directly.

This patch stops using deprecated CONFIG_SETTINGS_FS_DIR. There is actually
no value in respecting it, as setting anything other than parent directory
of CONFIG_SETTINGS_FS_FILE makes no sense.

There is actually one use of CONFIG_SETTINGS_FILE_DIR in file backend
tests, to derive directory for files containing tested settings.
CONFIG_SETTINGS_FILE_PATH is not used there, so it makes little sense to
derive directory name from it. Instead, just use hardcoded "/settings"
subdirectory, as this was the default value of CONFIG_SETTINGS_FILE_DIR.

Deriving parent directory can be done either in runtime or in
buildtime (e.g. using some helper CMake function). Doing it in runtime
however allows to create directory recursively (which this patch actually
implements), e.g. for some more nested FS tree structure. Additionally it
will simplify migration of settings configuration from Kconfig to
device-tree (yet to be developed feature).

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-14 14:11:03 +01:00
Marcin Niestroj
f386967b06 settings: do not panic on backend initialization errors
There is little reason to panic on settings backend initialization error.
Such behavior was introduced with initial settings subsystem support, which
was adapted from MyNewt. This is not the usual way how Zephyr handles
errors, so it is time to change that.

There is already handling of some errors by simply returning / propagating
them to caller. Rework all the paths that resulted in k_panic() to also
return error codes.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-14 14:10:55 +01:00
Tomasz Moń
fed6bde788 usb: device: cdc_acm: send more than 1 byte in poll out
Schedule CDC ACM tx work to happen 1 ms after first unprocessed data
write. This gives enough leeway for the task writing to the queue to
write more than 1 byte before USB workqueue preempts and schedules IN
transfer. Sending more than 1 byte at a time increases data throughput
because transaction overhead remains the same regardless of packet size.

Prior to this change, virtually every IN transaction carried only one
character when CDC ACM was used as a console.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-12-14 12:07:33 +01:00
Marco Argiolas
f8f3629efd net: lib: lwm2m: add uCIFI LPWAN object
Add support for Low Power Wide Area Network (LPWAN) Object (ID 3412)

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2022-12-14 09:51:38 +01:00
Dominik Ermel
72db5c09c0 samples/smp_svr: Switch to ZCBOR_MAP_DECODE_KEY_DECODER
Swithc zcbor_map_decode_bulk to use ZCBOR_MAP_DECODE_KEY_DECODER
macros.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-13 11:42:02 +01:00
Dominik Ermel
550b6d518d mgmt/mcumgr: zcbor_bulk: Allow spaces in map keys
The CBOR encoding allows strings to have white spaces, and as string
may be used as key it should also be allowed to use space in key.
The commit provides ZCBOR_MAP_DECODE_KEY_DECODER macro, which is
intended to replace ZCBOR_MAP_DECODE_KEY_VAL macro, that allows
to use string keys with spaces in it.
Both macros are available for now.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-13 11:42:02 +01:00
Carlo Caione
e1e06d05fa ipc: static_vrings: Zero config struct
Initialize the config struct to zero before passing down to OpenAMP.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-13 09:44:44 +01:00
Vinayak Kariappa Chettimada
5fab7a5173 Bluetooth: Controller: Fix MIC failure transmitting LL_CIS_REQ PDU
Fix MIC failure transmitting LL_CIS_REQ PDU.
The MAXPACKETSIZE value was not set with using Long Control
PDUs.

Relates to commit e895948047 ("Bluetooth: Controller: Add
Long Control PDU support").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:44:40 +01:00
Vinayak Kariappa Chettimada
88d94a5b8b Bluetooth: Controller: Remove duplicate code in nRF5 radio HAL
Remove duplicate PPI/DPPI configuration in
radio_tmr_start_now() which reuses radio_tmr_start_us().

And other minor refactor to remove unnecessary conditional
compilation of a define.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:44:22 +01:00
Vinayak Kariappa Chettimada
dfb5988da2 Bluetooth: Controller: Fix dynamic tx power for Broadcast ISO
Fix compilation error for ISO Broadcaster with dynamix Tx
power support, and remove setting tx power for ISO
Synchronized Receiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:44:06 +01:00
Vinayak Kariappa Chettimada
0dfa37b7e1 Bluetooth: Controller: Add internal comments in BIS LLL code
Add internal comments explaining the control flow in the
BIS synchronization in LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
b5d089fb48 Bluetooth: Controller: Receive starting at selected BIS and skip others
Updated implementation to save power consumption by
scheduling BIG event starting at the first BIS selected for
synchronization. Also, skip reception of any unselected
BISes in between multiple BISes that the Broadcaster is
transmitting. Added advance calculation of next subevent
channel index.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
9a51ece3fd Bluetooth: Controller: Fix BIS subevent channel indices
From Bluetooth Core Specification v5.3 Vol 6 Part B Section
4.4.6.8 Channel indices,

The subevent number se_n shall be set to the values 1 to
NSE, in order, for the subevents on a given BIS - the same
values shall be used for all the BISes in a BIG - and to 1
for the control subevent.

Hence, fix implementation to reset back to se_n to 1 when
next BIS PDUs are transmitted in the subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
9660f52dc7 Bluetooth: Controller: Fix Broadcast ISO PDU receive connection handle
Fix broadcast ISO PDU receive connection handle. The look up
was using BIS index instead of the index of the selected
stream that is being received.

Example, when receiving BISes 2 and 4, only the connection
handle for BIS 2 was correct and connection handle lookup
was out-of-bounds for BIS 4; symptoms being that Host
dropped the received ISO PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
46ead9915d Bluetooth: Controller: One extra ISO rx buffer for empty PDU reception
Budget for one extra ISO Rx PDU buffer for empty/NULL PDU
reception that has to always remain free in order to be able
to setup radio h/w for new PDU receptions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
554ea0bae3 Bluetooth: Controller: Fix missing cssn and cstf flag initialization
Fix missing cssn and cstf flag initialization in ISO
Broadcast LLL implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Witold Lukasik
c7acd98bf4 usb: device: update logging module registration
Update logging module registration and remove LOG_LEVEL macro
for USB device classes.

Signed-off-by: Witold Lukasik <witold.lukasik@nordicsemi.no>
2022-12-12 15:57:35 +01:00
Jani Hirsimäki
5a93a25158 net: l2: ethernet: ethernet support for AF_PACKET/SOCK_RAW/IPPROTO_RAW
Setting the protocol type for raw IP packets to be sent so that they
can be passed to Ethernet.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2022-12-12 14:56:07 +01:00
Mariusz Skamra
a68f78526d Bluetooth: audio: tbs_client: Fix misleading error log
This fixes error log that has been shown if number of calls in the list
was equal to CONFIG_BT_TBS_CLIENT_MAX_CALLS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-12-12 14:55:41 +01:00
Hang Fan
ebcfa196fc Bluetooth: audio: fix invalid ase state transition
When Receiver Stop Ready operation has completed, the Unicast Server
may request to terminate a CIS and set source ASE state to Qos
configured state immediately. But after CIS disconnected completed,
it will transition source ASE state from Qos Configured to Disabling
state. It's invalid and will cause assert.

we should add Streaming and Enabling state check when CIS disconnected.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-12-12 14:55:32 +01:00
Vinayak Kariappa Chettimada
a1b4896efe Bluetooth: Controller: Fix BT_LL_SW_LLCP_LEGACY compile error
Fix compile error building application with
BT_LL_SW_LLCP_LEGACY. Request Peer SCA command is not
supported in legacy control procedure implementation.

Relates to commit 76439d0ba4 ("Bluetooth: controller:
integrating SCA procedure and adding HCI API").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-11 18:29:02 +01:00
Erik Brockhoff
7c9d792211 Bluetooth: controller: refactor to remove duplicated functionality
Duplicated functionality used for tx handling is moved to local proxy
functions to avoid code overhead

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
edef6f3b46 Bluetooth: controller: refactor conn update notify function
Reusing code between local/remote procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
2fcbdaf3ba Bluetooth: controller: refactor pdu encode/decode functions
Introducing common pdu struct declarations for conn param req/rsp and
data length req/rsp to utilize identicality for optimal pdu handling

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
f5f0714c81 Bluetooth: controller: refactor to remove duplicated state function
Removing code for duplicate state handling in local  procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
7f0a801cdc Bluetooth: controller: refactor enc setup lll function
Reusing code between local/remote procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
1f97652998 Bluetooth: controller: refactor ull_rx_put/sched
Instead of calling both ull_rx_put and ull_rx_sched, combine into one
function

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
ddeb0e9f6e Bluetooth: controller: refactor ll_rx_put/sched
Instead of calling both ll_rx_put and ll_rx_sched, combine into one
function

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Morten Priess
ee2a43b5dc Bluetooth: controller: Reject CIS_TERMINATE when unsupported for role
If a central or peripheral is not configured for ISO connected streams,
reject a remote LL_CIS_TERMINATE_IND procedure, responding with an
unsupported feature error (BT_HCI_ERR_UNSUPP_FEATURE).

This fixes EBQ test /LL/PAC/CEN/BV-01-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
a803588d2c Bluetooth: controller: Add handle to ll_data_path_sink_create
For making handle available in vendor sink creation, add ISO handle
to function prototype.
Expose datapath allocation via new ull_iso_datapath_alloc function.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
f1c9a02dd6 Bluetooth: controller: Minor ISO refactoring due to compiler issue
Function ll_setup_iso_path has a construction which causes proprietary
compiler to generate incorrect code. As a workaround, local data path
pointer variables are eliminated.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
a93a860231 Bluetooth: controller: Fix ISO Test Mode SDU counting for framed
For framed case, the internal RX SDU counter would increment regardless
of whether the first valid SDU was received or not. According to spec,
SDU counter synchronization is done from first valid SDU.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
fae2beba9d Bluetooth: controller: Don't consider CIS connected before established
Make sure ll_iso_stream_connected_get returns NULL until CIS is
established. Always return DISALLOWED when trying to disconnect a CIS
which is not connected.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
44030a9da7 Bluetooth: controller: Fix CIS restart state de-initialization
When a CIS is terminated, the associated link pool must be de-
initialized to be ready for next creation of the corresponding
instance in memory.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
6e2dea3e41 Bluetooth: controller: Reject CIS_REQ with invalid PHY
Send LL_REJECT_EXT_IND if a LL_CIS_REQ was recevied with invalid PHY
specification.

Fixes EBQ tests:
  /LL/CIS/PER/BI-02-C
  /LL/CIS/PER/BI-03-C
  /LL/CIS/PER/BI-05-C
  /LL/CIS/PER/BI-06-C

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
a9f855e2bf Bluetooth: controller: Fix error in ISO reset sequence
To avoid races, ull_conn_iso_reset must be performed before higher level
ull_iso_reset.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
613283548c Bluetooth: controller: Fix LL_CIS_TERMINATE RX node leak
Reusing NODE_RX_TYPE_TERMINATE for CIS requires special deallocation
handling to prevent memory leak.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Yanqin Wei
00cdb7afa2 net: zperf: fix incorrect statistics of zperf
The sequence id from iperf starts with 1. The commit changes the
initial value of "next_id" in zperf from 0 to 1. In addition, the
error output of "error" and "out of order" packets is corrected.

Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
2022-12-09 11:18:25 +01:00
Pavel Vasilyev
163c2bc316 Bluetooth: Mesh: Warn log mode incompatibility with friendship
Log modes other than the deferred may cause unintended delays during
processing of log messages. This in turns will affect scheduling of the
receive delay and receive window for both, Friend and LPN.

Adding a compilation warning instead of assert as a user may still want
to compile a code with friendship feature enabled without actually
establishing a friendship.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-09 11:18:18 +01:00
Pavel Vasilyev
37ab40f2f7 Bluetooth: Mesh: Calculate adv duration instead of using estimation
The duration value passed to `struct bt_mesh_adv_cb::start` is an
estimation.

When running mesh with BT_MESH_ADV_EXT option, the actual duration will
be shorter and the `struct bt_mesh_adv_cb::end` is called right after
the contorller finished advertising. Using the calculated duration the
lpn node can be configured for a shorter receive delay and receive
window and eventually use less power.

When running mesh with BT_MESH_ADV_LEGACY option, the time when adv will
be sent out by controller is unpredictable. But the time between start
and end `struct bt_mesh_adv_cb` callbacks is always 50ms for a single
advertisement. Therefore, the receive delay can't be less than 50ms.

With this change, adv duration is calculated between start and end
callbacks, but timers are started after end callback is called. Therefore
we need to consider time between two callbacks when setting timeouts for
timers.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-09 11:18:18 +01:00
Pavel Vasilyev
5b4b5c0d34 Bluetooth: Mesh: Call friendship callbacks at the end
If a user does some heavy operations in friendship callbacks
unintentionally, this may break friendship communication as timers will
be scheduled or messages will be queued only after code execution comes
back from these callbacks. To avoid this issue, call callbacks only after
required operations are done.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-09 11:18:18 +01:00
Jamie McCrae
5d8c79f064 mgmt: mcumgr: transport: dummy: Fix issue with large packets
Fixes an issue with large packets being received, these packets are
chunked into 127-byte frames for the serial transport but this system
is not needed for the dummy transport as it has a fixed size buffer.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-07 13:53:02 +00:00
Jamie McCrae
656a910b1e mgmt: mcumgr: lib: cmd: os: Add device information handler
The device information handler can be used to retrieve information about
the configuration of the configured device such as board name, board
revision, firmware version and build date.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-07 13:53:02 +00:00
Armin Brauns
dfc97f3f38 fs: fat: document path transformation
The FAT driver converts zephyr paths like /SD:/foo into ELM-FATFS paths
like SD:/foo. Document this behaviour by extracting it into a separate
function (and adding a sanity check).

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2022-12-07 10:31:01 +00:00
Erik Brockhoff
68ef1306fb Bluetooth: controller: proper handling of invalid pdu in CIS create
Do not assert on invalid PDU in CIS create procedure. Instead terminate
with reason BT_HCI_ERR_LMP_PDU_NOT_ALLOWED

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-07 10:30:11 +00:00
Yuval Peress
0f174e5758 zdsp: Fix missing kconfig and no source library
Adds a missing menuconfig for the DSP library as well as fix an issue
with the zephyr library being a STATIC library and having no sources
in the case of the cmsis backend.

Signed-off-by: Yuval Peress <peress@google.com>
2022-12-07 10:24:24 +00:00
Nirosharn Amarasinghe
8510ecf6e3 Bluetooth: controller: corrected time stamps for unframed RX
Corrected an omission in the ISO-AL that required an SDU interval to
be added to the reconstructed RX time stamps for each SDU after the
first.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-12-07 10:15:17 +00:00
Al Semjonovs
da23050812 ztest: Add config to control test summary
Test summary can add a lot of noise to the logs when debugging
a specific test using `-test` argument.
Add control to turn this off.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-12-06 07:35:23 -05:00
Pavel Vasilyev
5d059117fd bluetooth: mesh: Remove illegal use of NET_BUF_FRAG in friend.c
This commit removes illegal use of NET_BUF_FRAG in friend.c, which is an
internal flag.

Now `struct bt_mesh_friend_seg` keeps pointer to a first received
segment of a segmented message. The rest segments are added as fragments
using net_buf API. Friend Queue keeps only head of the fragments.
When one segment (currently head of fragments) is removed from Friend
Queue, the next segment is added to the queue. Head has always 2
references: one when allocated, another one when added as fragments
head.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-06 11:06:43 +02:00
Carles Cufi
3d306c181f net: buf: Simplify fragment handling
This patch reworks how fragments are handled in the net_buf
infrastructure.

In particular, it removes the union around the node and frags members in
the main net_buf structure. This is done so that both can be used at the
same time, at a cost of 4 bytes per net_buf instance.
This implies that the layout of net_buf instances changes whenever being
inserted into a queue (fifo or lifo) or a linked list (slist).

Until now, this is what happened when enqueueing a net_buf with frags in
a queue or linked list:

1.1 Before enqueueing:

 +--------+      +--------+      +--------+
 |#1  node|\     |#2  node|\     |#3  node|\
 |        | \    |        | \    |        | \
 | frags  |------| frags  |------| frags  |------NULL
 +--------+      +--------+      +--------+

net_buf #1 has 2 fragments, net_bufs #2 and #3. Both the node and frags
pointers (they are the same, since they are unioned) point to the next
fragment.

1.2 After enqueueing:

 +--------+      +--------+      +--------+      +--------+      +--------+
 |q/slist |------|#1  node|------|#2  node|------|#3  node|------|q/slist |
 |node    |      | *flag  | /    | *flag  | /    |        | /    |node    |
 |        |      | frags  |/     | frags  |/     | frags  |/     |        |
 +--------+      +--------+      +--------+      +--------+      +--------+

When enqueing a net_buf (in this case #1) that contains fragments, the
current net_buf implementation actually enqueues all the fragments (in
this case #2 and #3) as actual queue/slist items, since node and frags
are one and the same in memory. This makes the enqueuing operation
expensive and it makes it impossible to atomically dequeue. The `*flag`
notation here means that the `flags` member has been set to
`NET_BUF_FRAGS` in order to be able to reconstruct the frags pointers
when dequeuing.

After this patch, the layout changes considerably:

2.1 Before enqueueing:

 +--------+       +--------+       +--------+
 |#1  node|--NULL |#2  node|--NULL |#3  node|--NULL
 |        |       |        |       |        |
 | frags  |-------| frags  |-------| frags  |------NULL
 +--------+       +--------+       +--------+

This is very similar to 1.1, except that now node and frags are
different pointers, so node is just set to NULL.

2.2 After enqueueing:

 +--------+       +--------+       +--------+
 |q/slist |-------|#1  node|-------|q/slist |
 |node    |       |        |       |node    |
 |        |       | frags  |       |        |
 +--------+       +--------+       +--------+
                      |            +--------+       +--------+
                      |            |#2  node|--NULL |#3  node|--NULL
                      |            |        |       |        |
                      +------------| frags  |-------| frags  |------NULL
                                   +--------+       +--------+

When enqueuing net_buf #1, now we only enqueue that very item, instead
of enqueing the frags as well, since now node and frags are separate
pointers. This simplifies the operation and makes it atomic.

Resolves #52718.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-12-06 11:06:43 +02:00
Dominik Ermel
5f4664dabe fs/fat: Improve help of Kconfig options for FAT
The commit fixes usage of old identifiers, from ELM FAT module,
and adds additional information on how certain options affect
FAT operation in Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 17:55:58 +01:00
Dominik Ermel
6ae861f559 mgmt/mcumgr: Remove APP_LINK_WITH_MCUMGR Kconfig option
This option is not actually doing anything.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 17:22:51 +01:00
Morten Priess
51ba6e9dd3 Bluetooth: controller: CIS Central fixes
- New calculation of Max_PDU for framed case according to BT Core 5.4
- Fix CIS_Offset calculation for multiple CIS usecase
- Fix resume ticker setup for central

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-05 15:48:39 +01:00
Franciszek Zdobylak
2259e98d95 fs: Implement mkfs operation in FAT fs
Provide an implementation of fs_mkfs operation in FAT fs.

Signed-off-by: Franciszek Zdobylak <fzdobylak@internships.antmicro.com>
2022-12-05 15:36:00 +01:00
Franciszek Zdobylak
78f8937470 fs: Implement mkfs operation in littleFS
Provide an implementation of fs_mkfs operation in littleFS.

Signed-off-by: Franciszek Zdobylak <fzdobylak@internships.antmicro.com>
2022-12-05 15:36:00 +01:00
Franciszek Zdobylak
7a96ed2771 fs: Add fs_mkfs operation to fs api
Adds fs_mkfs function to fs api. It will allow to perform mkfs operation
in file systems added to Zephyr.

Signed-off-by: Franciszek Zdobylak <fzdobylak@internships.antmicro.com>
2022-12-05 15:36:00 +01:00
Wojciech Slenska
29400b18a6 shell: shell_log_backend: added check for msg allocation
When the message buffer cannot be allocated, dropped package
counter should be incremented.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-12-05 15:35:03 +01:00
Hubert Miś
14a03e90d5 ipc: ipc_service: kconfig cleanup
Separate ipc_service libraries Kconfig entries from ipc_service backend
entries. IPC_SERVICE_BACKEND_ICMSG_BOND_NOTIFY_REPEAT_TO_MS is renamed
to drop BACKEND part, because this entry applies to a library, not to
one backend. Icmsg related entries are grouped now in a menuconfig for
cleaner presentation in configuration editors.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-12-05 15:26:31 +01:00
Dominik Ermel
9a48fdf62f mgmt/mcumgr: Remove redundant config headers
The shell_mgmt_config.h and stat_mgmt_config.h as they have been only
providing alternative identifiers for Kconfig options.
Now the Kconfig options are directly used in code and the headers
have been removed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 15:22:27 +01:00
Krzysztof Chruscinski
1f63a07c5f shell: Fix log message queue size for all backends
188d2dfcca introduced a change where log message queue again
become configurable through Kconfig instead of being fixed in
the code. However, it updated only the configuration of an UART
backend. This commit updates other backends as well. Including
dummy backend which has fixed in the code value.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-05 15:20:01 +01:00
Dominik Ermel
043cea12e5 fs/fatfs: Add CONFIG_FS_FATFS_MIN_SS
The Kconfig option allows to set minimum expected sector size
to be supported by FAT fs driver.
When this value differs from CONFIG_FS_FATFS_MAX_SS the driver
will query device for actual sector size, expecting different
sector sizes for different device. When CONFIG_FS_FATFS_MIN_SS
and CONFIG_FS_FATFS_MAX_SS are the same, then there is slight
reduction if FAT driver size, as the query logic is removed
and CONFIG_FS_FATFS_MAX_SS is used for all devices.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 15:18:05 +01:00
Marcin Niestroj
976520c77e settings: file: do not create file when loading
File backend can be read-only with the use of `settings_file_src()` API. It
makes no sense to create file when `settings_load()` is called and
registered file backend won't be used for saving files (because
`settings_file_dst()` was not used).

Do not create file during `settings_load()` if it does not exist yet. This
just requires to remove FS_O_CREATE flag in `fs_open()` invocation.

Open file with read-only access, which is now possible after removal of
`FS_O_CREATE` flag.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 14:59:59 +01:00
Chris Friedt
510dca57da shell: devmem: add devmem dump subcommand
This allows the caller to dump a region of memory rather than
dumping one byte (word, etc) at a time. Additionally, it
respects alignment requirements so it works for e.g. 32-bit
register accesses.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-05 11:28:22 +01:00
Marcin Niestroj
426896ea3e settings: fcb: remove unnecessary drop of const identifier
`settings_fcb_save_priv()` already takes `const char *value`, so there is
no reason to cast to `char *` before passing.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
36b06f4af8 settings: file: remove unnecessary drop of const identifier
`settings_file_save_priv()` already takes `const char *value`, so there is
no reason to cast to `char *` before passing.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
312bddfe17 settings: line: simplify settings_line_len_calc()
This function was refactored several times due to many features (like
base64 encoding), which got deprecated over time. Simplify it a bit now.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
b1a15f50b2 settings: line: remove unused MAX_ENC_BLOCK_SIZE macro
This macro is not used anymore and is strictly a leftover, which should be
removed as part of commit 55be783c85 ("settings: Remove deprecated
SETTINGS_USE_BASE64 support").

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
c6af1c3320 settings: line: fix typos in comments
Fix some typos in comments.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
fb9807da9a settings: put all options under if SETTINGS
Put all options under one `if SETTINGS` block, so that `depends on
SETTINGS` does not need to be repeated every time.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Yuval Peress
b38445eaa0 math: Introduce a DSP basicmath subsystem with a cmsis backend
Introduce an API mirroring the CMSIS-DSP's basicmath. If CMSIS_DSP is
enabled, then it will by default be used as a backend. Developers may
opt into a custom backend by setting CONFIG_DSP_BACKEND_CMSIS=n. If
done, the application must provide `zdsp_backend/dsp.h` and optionally
implement the functions in its own .c files.

Signed-off-by: Yuval Peress <peress@google.com>
2022-12-02 20:15:55 +01:00
Jamie McCrae
47518d47a2 logging: minimal: Change imply to select for printk
This changes the minimal logging Kconfig to select printk rather
than imply it, this is because if someone turns printk off,
minimal footprint logging does not work, therefore it needs to be
a requirement.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-02 16:17:35 +01:00
Emil Gydesen
abef3d3001 Bluetooth: Audio: Removed unused cmd_mcc_ots functions
The functions were not used, and MCC doen not use OTS, but
rather OTC.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 16:08:54 +01:00
Emil Gydesen
312b06a130 Bluetooth: Audio: Add missing static for MCC shell commands
Adds the `static` keyword to the MCC shell command functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 16:08:54 +01:00
Emil Gydesen
b12a09baa8 Bluetooth: Audio: Replace generic media "send cmd" with explicit commands
Rather than exposing shell commands that take an opcode and
an optional parameter, the shell commands are now explicit
so that it is easier for a person to use the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 16:08:54 +01:00
Madhurima Paruchuri
fa738b0f74 usb-c: Generate USB-C connector VIF policies XML file
Generates XML file containing VIF policies by reading the device tree
using EDT.pickle generated during build
This script writes a subset of general and sink-pdo VIF policies in
output file
This script gets invoked during build if enabled through kconfig
The generated XML containing USB-C VIF policies could be used by
USB PD/Type-C analysers/testers to understand USB-C properties and
perform tests accordingly

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2022-12-02 08:46:04 -06:00
Johann Fischer
fcd21f10d5 usb: device_next: add experimental CDC ACM implementation
Add experimental CDC ACM implementation for new USB device stack.
It currently implements only UART IRQ API support and is WIP.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Johann Fischer
cb8b9ad38a usb: add new experimental USB device stack
The device supprt brings support for multiple stack instances,
multiple configuration, asynchronous transfer model, ability to
change most of the properties of a device at runtime and
the composition of configuration and classes at runtime.

The stack requires new UDC driver API and is not compatible
with old driver API (usb_dc_). The classes (functions) of old
(current) USB device stack cannot be used with new ones and must
be ported.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Emil Gydesen
04092ac9a5 Bluetooth: Audio: Change shell print for default_stream == NULL checks
Change what is printed to the shell if the default_stream == NULL
check fails.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Emil Gydesen
ea448ed69a Bluetooth: Audio: add check for default_conn for audio qos shell command
Add a missing NULL check for the command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Emil Gydesen
ff7f644aff Bluetooth: Audio: Remove audio connect command
The `audio connect` shell command did not really do
anything anymore, and has thus been removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Emil Gydesen
34715022ef Bluetooth: Audio: Move some unicast shell commands to also support server
Some of the unicast audio shell commands were guarded by
CONFIG_BT_AUDIO_UNICAST_CLIENT and only usable by the client.

This moves some of the commands to a CONFIG_BT_AUDIO_UNICAST
guard instead, so that they are usable for builds with just
the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Mariusz Skamra
795573c43f Bluetooth: audio: shell: Fix VCP Volume Renderer build
This fixes VCP Volume Renderer linker error that was seen if built
with VOCS and/or AICS support disabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-12-02 11:28:34 +01:00
Chris Friedt
cdc0f30dbb Revert "shell: devmem: add devmem dump subcommand"
This seems to have caused build failures in spite
of CI passing in PR 52653.

This reverts commit 0a02a4a2af.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-02 14:09:37 +09:00
Chris Friedt
0a02a4a2af shell: devmem: add devmem dump subcommand
This allows the caller to dump a region of memory
rather than dumping one byte at a time.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-01 15:52:47 -05:00
Carlo Caione
cc427b4bb0 cache: Fix libraries and drivers
Fix the usage to be compliant to the new cache API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-01 13:40:56 -05:00
Christian Taedcke
12f2258305 net: Make user_data size in rx and tx buffers configurable
Introduce the Kconfig symbol `NET_PKT_BUF_USER_DATA_SIZE`. It is used to
set the user data size in the buffers used in the rx and tx network buffer
pools.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-12-01 15:50:35 +01:00
Christian Taedcke
5bd3beff14 Kconfig: net: Remove deprecated NET_BUF_USER_DATA_LEN
This Kconfig setting was deprecated since
commit 8e99db5801 ("Kconfig: net: deprecate `NET_BUF_USER_DATA_LEN`")
and zephyr release 3.0.0.

This commit removes this deprecated and unused setting.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-12-01 15:50:35 +01:00
Morten Priess
1d235189d5 Bluetooth: controller: Remove HCI_Read_Local_Supported_Codecs [v1]
An LE controller shall no longer support HCI_Read_Local_Supported_Codecs
[v1] according to BT Core 5.3.
Command bit and support code removed.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-01 15:49:25 +01:00
Erik Brockhoff
218da91211 Bluetooth: controller: Implementing CIS STO & establishment timeout
Adding a bit-mask to the 'extra' data structure allowing passing info
re. active CIS's to the ull_conn_iso_done handling. Per CIS storing
an expiration time counter, monitoring in done handling. Adding
establishment timeout monitor in CIS Create procedure, completing
and ntf'ing accordingly.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-01 10:32:34 +01:00
Erik Brockhoff
3c68fa45d2 Bluetooth: controller: fixing possible race re. termination vs. cis's
If a CIS is in teardown state, the data in structure should not be
trusted, so skip passing data to ISOAL

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-01 10:32:34 +01:00
Erik Brockhoff
0604a4d2f1 Bluetooth: controller: store STO value instead of pre-calculated reload
Instead of storing the calculated reload value (in conn intervals) in
the conn object, now store the timeout value, and perform calculation
when used. This allows using the timeout value across all CIS's without
having to re-calc and store on change of TO

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-01 10:32:34 +01:00
Armin Brauns
7e0e9d0d7e logging: allow disabling auto-start of UART backend
This allows putting the UART backend on a serial device that has to be
quiet unless logging is explicitly enabled at runtime.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2022-12-01 09:48:42 +01:00
Kamil Piszczek
916e02563c bluetooth: host: smp: unauth bond overwrite on different identity
Added a new Kconfig option for the Bluetooth Host to allow
unauthenticated pairing attempts made by the peer where an
unauthenticated bond already exists on other local identity.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-12-01 09:48:02 +01:00
Théo Battrel
e4be91b0c4 Bluetooth: Update Bluetooth legacy logging Kconfig
Update the Bluetooth specific Kconfig legacy log template to use the new
log inheriting template.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-30 14:37:58 +01:00
Théo Battrel
ff5b8f003e Logging: Add Kconfig template for log inheriting
Add a new Kconfig template that allow log modules to inherit their log
level from their parent module.
For example, the logs used in the Bluetooth audio like
`BT_AUDIO_STREAM_LOG_LEVEL` can inherit their level from
`BT_AUDIO_LOG_LEVEL`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-30 14:37:58 +01:00
Erik Brockhoff
9f5eb0f1a8 Bluetooth: controller: fixup to peripheral CIS Create check instant
In case a CIS is the first in a CIG, we should start ISO peripheral
early to allow small CIS offsets

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 13:39:44 +01:00
Erik Brockhoff
9b553c3eb2 Bluetooth: controller: fixup to peripheral CIS CREATE procedure
Missing decode of conn_event_count on CIS_IND
Peripheral Suggest update to conn_event_count in case of a delayed
CIS_IND, allowing CIS peripheral more time to setup

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 13:39:44 +01:00
Jonathan Rico
42e490917e Bluetooth: Host: l2cap: disconnect when PDU > MPS
The Bluetooth spec states that a K-frame exceeding the device's MPS
should trigger a disconnection of the channel.

Fixes two PTS tests that verify this behavior:
L2CAP/LE/CFC/BV-27-C
L2CAP/ECFC/BV-34-C

The current behavior is a silent truncation, which is not very nice for
the user, even if the spec would allow it.

Fixes #52228 and #51174.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-11-30 12:50:10 +01:00
Thomas Ebert Hansen
f192fccf3a Bluetooth: controller: Add lock around LLCP data
Add mayfly locking around the access to the local pending procedure list
as it is accessed by both thread and mayfly.

Fixes #45427

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-11-30 12:49:15 +01:00
Erik Brockhoff
83c380bfcd Bluetooth: controller: adding missing NTF wait state to SCA procedure
When generating notification for Sleep clock accuracy, check for
success on rx_node allocation was left out. This is added.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 12:48:52 +01:00
Erik Brockhoff
d99052b316 Bluetooth: controller: set bit to indicate support for Request Peer SCA
Setting bit to indicate that LE Request Peer SCA command is supported

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 12:31:26 +01:00
Emil Gydesen
e80c70fd05 Bluetooth: Audio: Fix MCC disconnect issue
When MCC disconnected, it would memset the entire instance.
This causes issues, because the subscription parameters
would also be memset, causing the `notify` callback to
be set to NULL. If this was done as part of a disconnect,
the GATT layer would attempt to call the notify callback
as part of cleaning up the ACL, but if the callback was
set to NULL (from the memset) this caused a fatal error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-29 13:26:57 +01:00
Jamie McCrae
b635b55ef0 logging: Increase dummy shell buffer size to 400 bytes for LOG_PRINTK
If LOG_PRINTK is used then the buffer size needs to be larger to
account for the additional header/footer output from the shell.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-29 10:46:26 +01:00
Jamie McCrae
c5a40e3a9d logging: Enable LOG_PRINTK if PRINTK is enabled
This change will enable the logging system to handle printk() calls by
default if printk support is enabled, which improves output resiliency
when logging, mcumgr and printk calls are used. Will disable keep
LOG_PRINTK disabled for tests which are not using the new API as
moving to LOG_PRINTK causes test data to be output to a different UART
in the old test system.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-29 10:46:26 +01:00
Emil Gydesen
f3b0a8f478 Bluetooth: Audio: Fix broadcast assistant recv state pointer value
When reporting a receive state to the upper layers, the broadcast
assistant should report NULL if there is not a receive state
active. The "activeness" of a receive state is determined by
the length of the characteristic - If it is 0 then there
is no receive state active.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-29 09:50:22 +01:00
Yuval Peress
49ca6f8f7d unittest: add support for coverage
Some missing features for getting coverage data for unit tests:
- Setting the unit_testing board to have coverage support and native
  application.
- Fixing the CONFIG_COVERAGE check

Signed-off-by: Yuval Peress <peress@google.com>
2022-11-28 16:26:02 -05:00
Emil Gydesen
bbc85e0b2c Bluetooth: Audio: Use bt_vcp_vol_ctlr instead of bt_vcp
Use the `bt_vcp_vol_ctlr` opaque type instead of the more
generic `bt_vcp`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
914e96e6fe Bluetooth: Audio: Vol rend use bt_vcp_vol_rend instead of bt_vcp
Use the struct bt_vcp_vol_rend instead of the more generic
`bt_vcp`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
ae11b5879b Bluetooth: Audio: Remove bt_vcp from vol rend API
Remove the struct bt_vcp pointer from the volume
renderer API, as there is only ever a single
Volume Renderer instance on a device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
c82af2885e Bluetooth: Audio: Split vol_ctlr and vol_rend callback structure
Split the `bt_vcp_cb` struct into separate structure for
the volume controller and the volume renderer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
7f69b866f0 Bluetooth: Audio: Specify bt_vcp_vol_rend API
The VCP server, known as the volume renderer, has a
more explicity bt_vcp_vol_rend API naming scheme now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
71bd487cc4 Bluetooth: Audio: Add separate API for VCP vol controller
Add a separate API for the VCP volume controller (client).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
966c9f80e7 Bluetooth: Audio: Remove the bt_vcp_vocs API
Remove the bt_vcp_vocs API as it did the same as the
bt_vocs API, and did not really any functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
bfbb704c8e Bluetooth: Audio: Remove the bt_vcp_aics API
The AICS functionality can be exercised using the
bt_aics API instead. These functions did very little
besides cluttering up the bt_vcp API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
ce2b8f9fe1 Bluetooth: Audio: Rename VCS to VCP
Renames almost all occurences of VCS to VCP, as we want to
use the profile as the namespace for volume control.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
aaac86dada Bluetooth: Audio: Rename vcs.h to vcp.h as well as the Kconfig file
Rename vcs.h to vcp.h to better detail what the
file contains, as it is more than just VCS. This also
renames the Kconfig file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Théo Battrel
f739f0b87c Bluetooth: Add legacy warning to Kconfig.template.log_config_bt
Add documentation to tell people to not use the file for new stuff.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-28 17:14:56 +01:00
Martin Jäger
22c8a67d4a lorawan: enforce larger system work queue stack size via Kconfig
The LoRaWAN subsystem uses the system work queue internally and needs
more than the default stack size of 1024 bytes. This is considered
in the sample application, but may be forgotten by out of tree users.

Enforcing it via Kconfig prevents users from accidentally getting
hard-to-debug stack overflows.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-11-28 10:49:18 +01:00
Manuel Arguelles
d17caaacc5 net: icmpv6: fix if need calc tx checksum
Fix regression from 0a3bf289b6.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-11-28 10:47:20 +01:00
Anders Storrø
52a39c0180 Bluetooth: Mesh: Only settings load post mesh init
Prevent mesh stored settings from triggering unless bt_mesh_init
has been called.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-11-25 20:02:53 +01:00
Tomasz Moń
f8ac6b6d66 usb: device: Disable all endpoints on stack disable
Disable all enabled endpoints on stack disable to allow re-enabling USB
device stack.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-11-25 20:02:42 +01:00
Théo Battrel
e458f5aae6 Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log
The `bluetooth/common/log.h` and `bluetooth/common/log.c` files have been
removed. Files that were using them have been updated to use
`zephyr/logging/log.h` instead.

Those replacement have been done consequently:
- `/BT_DBG/LOG_DBG/`
- `/BT_ERR/LOG_ERR/`
- `/BT_WARN/LOG_WRN/`
- `/BT_INFO/LOG_INF/`
- `/BT_HEXDUMP_DBG/LOG_HEXDUMP_DBG/`
- `/BT_DBG_OBJ_ID/LOG_DBG_OBJ_ID/`

Also, some files were relying on the `common/log.h` include to include
`zephyr/bluetooth/hci.h`, in those cases the include of `hci.h` has
been added.

For files that were including `common/log.h` but not using any logs,
the include has been removed and not replaced.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-25 17:08:36 +01:00
Pavel Vasilyev
c32ee7199f Bluetooth: Mesh: Filter out unknown conns and disconns in pb-gatt srv
Ensure that another established connection with the mesh device don't
mess up pb-gatt server state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-25 10:45:07 +01:00
Pavel Vasilyev
2b0fbd86a1 Bluetooth: Mesh: Limit number of Bluetooth connections used by mesh
When a remote devices establishes a ble connection with the mesh device
with default identity and there are more available connection slots, the
mesh stack will try to restart connectable advertisements (either
pb-gatt or proxy depending on the provisioning state). This makes
difficult for an application to advertise own connectable advertisements
as the mesh stack will not let a chance the app to start advertising.

This change adds a Kconfig option that limits number of connection slots
that the mesh stack can use for own connectable advertisements.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-25 10:45:07 +01:00
Mariusz Skamra
93b2205ff5 Bluetooth: tests: shell: Fix build error
This fixes build error that happens when shell is built without CAP
Acceptor Set Member support. The cap_acceptor.c contains shell commands
for Set Member only, thus it's OK to build the code if
CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER is set for now. This can be modified
in the future when shell will be extended with other
Set Member non-specific CAP commands.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-25 10:44:51 +01:00
Emil Gydesen
43e0a63996 Bluetooth: Audio: Fix CSIP compliance check with returns after else
The compliance check did not like the otherwise valid
way of returning from read_set_sirk.

The code has been slightly refactored to avoid the check
failing in CI.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
292db21a18 Bluetooth: Audio: Use svc_inst instead of bt_csip for set_member
Use the service instance struct instead of the more generic
`bt_csip` for the CSIP set member API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
1991fcaced Bluetooth: Audio: Use svc_inst instead of bt_csip for set coordinator
Use the bt_csip_set_coordinator_svc_inst struct in the
set coordinator implementation instead of the more
generic bt_csip.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
5ecaf5af1b Bluetooth: Audio: CSIP set coordinator API not using bt_csip
Modified the CSIP set coordinator slightly to not use the
bt_csip struct at all. For the use a void pointer works
equally well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
87f86cebe2 Bluetooth: Audio: Rename bt_csip to bt_csip_set_member
Renamed remaining structs and functions that are not
for the set coordinator to use the set member CSIP
role name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
93b3944a51 Bluetooth: Audio: Rename CSIS to CSIP
Renamed the coordinated set implementation to use the
profile (CSIP) name instead of the service (CSIS) name, as
the former is more general.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Andrei Emeltchenko
a5400407fc net: conn: Fix issues with SMP in connection code
When testing on qemu_x86_64 with e1000 Ethernet driver, there are
several crashes due to list management simultaneously executing on
different cores. Add mutexes similar to other parts on networking
stack, for example tcp_lock.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-11-24 15:23:11 +01:00
Mariusz Skamra
8c86595289 Bluetooth: audio: has: Fix HAS features dynamic presets value
If there is no support for presets, Dynamic Presets feature
flag should not be set.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-24 15:23:00 +01:00
Chamira Perera
67db7d07f2 net: ip: Fixed IGMP V2 membership report destination address.
As per RFC 2236 Section 9, the IGMP V2 membership reports should be sent
to the group multicast address being reported. Without this fix, when
IGMP snooping is enabled on a network a device is not able to receive
multicast from certain multicast addresses e.g. 239.255.x.x.

Fixes #52449

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2022-11-24 15:22:38 +01:00
Morten Priess
3915754ac3 Bluetooth: controller: Add support for Read/Write Conn. Accept Timeout
Implement HCI commands HCI_Read_Connection_Accept_Timeout and
HCI_Write_Connection_Accept_Timeout, and enable the feature in
supported commands.
Remove hardcoded use of default accept timeout in new LLCP code, and
use configurable value instead.

This makes EBQ test /HCI/CIN/BV-03-C pass.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-24 11:17:28 +01:00
Emil Gydesen
40e3930ebd Bluetooth: Audio: Broadcast source subgroup and BIS codec support
Updates the broadcast source API to create subgroups and
to set BIS specific codec configuration

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 10:21:36 +01:00
Marcin Niestroj
26ea31fc87 settings: use CONTAINER_OF() to access backend structure
Use CONTAINER_OF() macro to access outer backend-specific structure. This
removes the requirement to keep `struct settings_store` as the first item
in outer structure.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-11-24 10:18:35 +01:00
Ahmed Moheb
b86150ff0c tests: bluetooth: host: Add mocks for crypto.c
Add required mocks to be able to compile/test /bluetooth/host/crypto.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 10:06:05 +01:00
Aleksandr Khromykh
2411cf68ab Bluetooth: Mesh: fix adv counter in LPN
LPN should send Poll\Sub Add\Sub Del only once.
Sending multiple times breaks polling time parameters
(Figure 3.17: Friendship timing parameters).

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-11-24 10:03:04 +01:00
Vinayak Kariappa Chettimada
668505e778 Bluetooth: Controller: Fix periodic sync Skip value vs Sync_Timeout
Adjust skip value so that there is minimum of 6 events that can be
listened to before Sync_Timeout occurs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-24 09:37:00 +01:00
Marcin Niestroj
daee6cb4a9 settings: file: change FS (or file system) wording to File
Currently there is inconsistency in repository file names, APIs, Kconfig
options and documentation around file / file-system backend for settings
storage, as both "file" and "FS (file system)" are used. As an example,
there is `CONFIG_SETTINGS_FS` Kconfig option, but the file that implements
this settings backend is called `settings_file.c`. Another example are
names of static functions that implement settings storage API:
`settings_file_load()`, `settings_file_save()` and
`settings_fs_storage_get()`.

This backend is actually storing all settings in a single file, so it makes
sense to use "File" as the name of backend, instead of a more general
"FS" (which would make sense if several files would be used to store
settings).

Fix inconsistency in used wording in the tree and unify it to "settings
file backend". This naming is more precise to how the implementation looks.
It will also make it easier to grep through the codebase and analyze
existing code.

Deprecate settings_mount_fs_backend() function and all Kconfig options
starting with `CONFIG_SETTINGS_FS`.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-11-24 09:36:31 +01:00
Johann Fischer
b70f92e570 net: buf: keep memory alignment provided by k_heap_alloc and k_malloc
Allocation callback in net_buf_heap_cb and net_buf_var_cb
used for net_bufs with variable size payloads, defined by
NET_BUF_POOL_HEAP_DEFINE or NET_BUF_POOL_VAR_DEFINE,
allocate one more octet for internal variable ref_count,
used in function generic_data_ref(), which in turn is needed
for net_buf_clone()).
The user gets a buffer which is shifted by one octet in memory
block. This breaks alignment provided k_heap_alloc and k_malloc.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-11-24 09:35:13 +01:00
Adrian Warecki
aac03280ec dma: dts: Rename of the dma_buf_alignment to dma-buf-addr-alignment
Renamed the dma-buf-alignment field to a more explicit
and descriptive name dma-buf-addr-alignment.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2022-11-23 15:36:31 -05:00
Emil Gydesen
1b2f57270a Bluetooth: Host: Add addr to bt_le_ext_adv_get_info
Add the local advertising address to bt_le_ext_adv_get_info.

This may help with debugging, but is also needed to
properly support something like the BAP Broadcast Assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-23 16:12:52 +00:00
Anas Nashif
cffe98d9de crc: Make the build of crc function dependent on a Kconfig
Add CONFIG_CRC for building CRC related routines.
CRC routines are now being built for each application, whether used or
not and are add in the build system unconditionally.

Keep CONFIG_CRC enabled by default for now and until all users have
converted to use the new option.

Partial fix for #50654

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-23 13:30:00 +01:00
Milind Paranjpe
cf91f1873b usb: disable previously enabled endpoint before re-enabling
When switching between alternate settings of an interface, it is
currently possible to call set_endpoint() multiple times on an endpoint
without first calling reset_endpoint(). For these situations, it is
beneficial to track endpoints for which set_endpoint() has previously
been called, and then reset them to properly terminate any transfers,
and to return the HAL to the correct state

Signed-off-by: Milind Paranjpe <mparanjpe@yahoo.com>
2022-11-23 12:59:40 +01:00
Jamie McCrae
9831b320f2 mgmt: mcumgr: Fix missed variable rename
Fixes accesses a renamed variable when a specific Kconfig is
active that would cause a compile error.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-23 12:24:59 +01:00
Vinayak Kariappa Chettimada
990d9a3abe Bluetooth: Controller: Fix BIS access address generation
Fix BIS access address generation to follow the requirements
in Bluetooth Core Specification v5.3, Vol 6, PartB, Section
2.1.2 Access Address.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-23 12:18:55 +01:00
Vinayak Kariappa Chettimada
1b023e5419 Bluetooth: Controller: Ensure ext header max size reservation
Ensure maximum size of common extended header format be
reserved when CONFIG_BT_CTLR_ADV_RESERVE_MAX=n is used so
that changes to ACAD, like channel map update does not need
frequent update to periodic advertising auxiliary channel
PDU time reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-23 12:18:55 +01:00
Vinayak Kariappa Chettimada
1164c327d6 Bluetooth: Controller: Revert T_MAFS change done for broadcasting roles
When calculating the offsets between primary advertising
PDU, auxiliary PDU, Periodic Advertising PDU, and BIS PDU,
the values used as anchor points for starting the periodic
interval for auxiliary, periodic and BIG events, should be
ensured to have the minimum auxiliary frame spacing T_MAFS
between the PDUs. EVENT_OVERHEAD_START_US has to be reduced
as this value is used to offset the start of the radio
event on air.

Reverts commit b867f0e8a6 ("Bluetooth: Controller: Fix
T_MAFS between broadcasting roles").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-23 12:18:55 +01:00
Lingao Meng
7668bd3b7c Bluetooth: Mesh: Add macro control whether adv main to relay
Enable advertiser main to support relay messages, this maximizes
theutilization efficiency of advertising sets, which is helpful for the
sending of dense relays, but for Friend and LPN, it delays the sending
of local messages a little, this may cause the time slot deviation between
friend and lpn, and the power consumption of lpn will increase.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-23 11:36:57 +01:00
Lingao Meng
a5ebad1e23 Bluetooth: Mesh: Fix missing check local match for mesh message
For Mesh Message, should only process by model layer when dst
is unicast address of this nodes or model subscrip on.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-23 11:36:57 +01:00
Radoslaw Koppel
0620cb1fe1 ipc: ipc_service: icmsg: Increase reliability of bonding
This commit changes the way bonding between endpoints is processed.
There is no blind attempt to read the buffer without mbox notification.
On second side the notification is repeated multiple times until valid
bonding is detected.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2022-11-23 11:34:04 +01:00
Armin Brauns
1f41c01553 shell: kernel: right-align stack usage percentages
This improves readability by aliging digits with the same significance
vertically.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2022-11-23 11:33:47 +01:00
Andries Kruithof
7678cdaa10 Bluetooth: controller: llcp: increase memory for procedures
The default number of buffers (contexts) for locally initiated
procedures was 4. Per default the host initiates 3 procedures
when opening a connection, allowing the application to initiate
only 1 additional procedure in parallel.
This commit increases the default to 6, if auto phy-update and
dle is enabled, increasing the robustness for an application.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-11-23 11:32:49 +01:00
Johann Fischer
1c4011ff6e usb: remove usb_pid.Kconfig file
Remove Kconfig file samples/subsys/usb/usb_pid.Kconfig added in
the commit e5cbe6a9e7 ("usb: cdc: Add unique PIDs for each sample")
with the motivation to have a separate ID for each sample supposedly
to be recognizable by the host.

The new USB support does not use the options, VID/PID is set
directly in the application. As a note, it is not necessary to have
unique PID for each sample, especially for the well known USB classes.

Replace the individual Kconfig options in the documentation
by a table with the references to the samples and PIDs.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-11-22 11:09:21 +01:00
Emil Gydesen
02226d0352 Bluetooth: Audio: Fix mcc.c conn logging statements
mcc.c does not include `conn_internal.h` so it does not
know the `bt_conn` struct, causing logging issues when
trying to log a `bt_conn` pointer.

Fixed by casting the `conn` pointers to `(void *)`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-22 11:05:33 +01:00
Reto Schneider
b51218a110 net: net_pkt: Fix conditional compilation
This aligns the conditional compilation logic with the one used for the
prototype in net_pkt.h, avoids build errors due to a undefined reference
to net_pkt_print_frags.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-11-22 09:30:26 +00:00
Reto Schneider
a66935aea7 net: net_pkt: Embrace NET_PKT_DEBUG_ENABLED
This deduplicates the logic a tiny bit.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-11-22 09:30:26 +00:00
Reto Schneider
217d9ac113 net: net_pkt: Simplify conditional compilation
The #if has the same conditions as the one closed the previous #endif.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-11-22 09:30:26 +00:00
Wojciech Slenska
188d2dfcca shell: shell_log_backend: take buffer size from config
Use LOG_MESSAGE_QUEUE_SIZE config instead of hardcoded value.
LOG_MESSAGE_QUEUE_SIZE default value has been changed to 512, so
it is now matching to the hardcoded value.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-11-22 13:05:29 +09:00
Tomasz Moń
a9bfe0a423 usb: dfu: Reduce default bwPollTimeout value
The bwPollTimeout name is somewhat confusing as it refers to minimum
polling period. The bwPollTImeout is essentially a mechanism allowing
device to ratelimit DFU_GETSTATUS requests from host.

Setting bwPollTimeout to relatively high values effectively slows down
DFU download process. The slowdown is not observed if the time between
DFU_DNLOAD and DFU_GETSTATUS is enough for the device to process the
write. That is, the bwPollTimeout does not effect DFU download if the
first DFU_GETSTATUS after DFU_DNLOAD reports dfuDNLOAD-IDLE state.
Otherwise the host must wait bwPollTimeout ms before issuing next
DFU_GETSTATUS, which slows the communicaiton to not more than 1 download
block (CONFIG_USB_REQUEST_BUFFER_SIZE) every bwPollTimeout ms.

The bwPollTimeout ideally should report an estimate how much longer the
download operation will take. Zephyr does not have such estimate and
therefore defaults to using fixed value. Reduce default bwPollTimeout
from 256 to 8 ms to allow significantly faster DFU downloads on devices
where the time between DFU_DNLOAD and DFU_GETSTATUS is too short to
process download block at the expense of unnecessary bus traffic if
processing download block takes longer than 8 ms.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-11-22 13:03:11 +09:00
Keith Packard
e478a4e850 subsys/cpp: make libstdc++ select full libc to get tests working
Using a STD C++ library requires a toolchain-provided C library with
associated STD C++ library. Instead of using a dependency on !MINIMAL_LIBC,
select REQUIRES_FULL_LIBC so that the build will select a viable C library
rather than failing.

This allows all of the C++ tests to be run as a part of a standard twister
run. I expect this will uncover regressions in some of those which haven't
been run recently.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-22 12:54:00 +09:00
Jamie McCrae
0922ec7d75 mgmt: mcumgr: Move zephyr basic group defines to standard files
Moves the zephyr group ID defines to the mgmt header file as it is
with other group IDs and moves the zephyr basic group command IDs
to the the same header-location style as other groups.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:42:48 +09:00
Jamie McCrae
4cf008cb45 mgmt: mcumngr: Remove old files missed in restructure
Removes some old files that should have been deleted in the recent
cleanup of MCUmgr.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:42:09 +09:00
Jamie McCrae
cbd0d2d55a mgmt: mcumgr: Add fs_mgmt prefix to hash/checksum functions/files
This aligns the naming of files in fs_mgmt so that files and
functions relating to hash/checksum are prefixed with fs_mgmt.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:41:49 +09:00
Yuval Peress
c585df4996 unittest: add C++ support
Some of the struct in the unit test's cpu.h header were empty which
isn't allowed in C++.

Signed-off-by: Yuval Peress <peress@google.com>
2022-11-21 16:11:14 -05:00
Chun-Chieh Li
59f3316d33 usb: audio: do not discard usb_transfer result in usb_audio_send()
Pass result of usb_transfer() as return value to the user,
and allow user to react accordingly, e.g. release net_buf on error.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2022-11-21 20:11:24 +01:00
Emil Gydesen
0a570a25c9 Bluetooth: Audio: Fix null pointer access in mcc.c
One of the notification callback functions did not properly
get the `read_params` pointer, causing an invalid result of
CONTAINER_OF as it would use a NULL pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-21 20:11:13 +01:00
Joakim Andersson
51d510adc6 Bluetooth: host: Call RPA expired on disabled advertising sets
Call the RPA expired callback on advertising sets even when they are
not enabled.
The RPA expired callback will now be called on advertising sets
when the BT_ADV_RPA_VALID flag is cleared for the set.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
d63ae607cc Bluetooth: host: Fix RPA timeout expiration
Fix RPA timeout expiration when BT_EXT_ADV has been enabled.

Always invalidate the device RPA on RPA timeout.
This RPA is used by the scan roles, and the advertiser that was started
using the bt_le_adv_start API.

Call the RPA expire callback only on advertising sets that are enabled
and not being limited by a timeout and not using the identity address.
On RPA timeout always invalidate the RPA of advertising sets that are
disabled.

Fixes: #51208
Fixes: #51228
Fixes: #51247

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
0a1a32841f Revert "Bluetooth: Host: Fix resolvable address update with Ext Adv enabled"
This reverts commit 6c40427931.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
ff36bd42d0 Bluetooth: shell: Add shell support for RPA expire callback and control
Add shell support for RPA expire callback.
This prints a message when the callback is called on the specific
advertising set.
Add a command to control the return value of this callback for a
specific advertising set.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
ba657c9570 Bluetooth: shell: Use a common help text for commands args on and off
Use a common help text for commands args on and off.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Martin Fletzer
144d30eb47 net: gptp_md: Consider different resolutions regarding correction field
From https://www.ieee802.org/1/files/public/docs2007/as-garner-protocol-state-machines-frame-formats-0307.pdf:
  The correctionField is the value of the correction
  measured in nanoseconds and multiplied by 2^16.

Zephyr uses nanoseconds for follow_up_correction_field.
Therefore, the value must be shifted by 2^16.

Signed-off-by: Martin Fletzer <martin.fletzer@kftec.at>
2022-11-21 10:14:48 +01:00
Aaron Massey
2dd0b48140 test: SBS gauge gets initially supported props
Add a test that validates fetching every property from the sbs gauge driver
results in no driver error codes being returned.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-19 17:56:05 -05:00
Aaron Massey
28b8123887 fuel_gauge: Sample sbs gauge driver with tests
Add a sample sbs gauge driver with feature parity and basic tests
comparison to its sensor counter-part. Includes a simple stub test that is
extended upon.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-19 17:56:05 -05:00
Robert Lubos
387a66131e net: pkt: Introduce minimum length requirement to net_pkt_get_frag()
net_pkt_get_frag() and a few other functions did not specify the
allocated fragment length, incorrectly assuming that fixed-sized
buffers are always used.

In order to make the function work properly also with variable-sized
buffers, extend the function argument list with minimum expected
fragment length parameter. This allows to use net_buf_alloc_len()
allocator in variable buffer length configuration, as well as verify if
the fixed-sized buffer is large enough to satisfy the requirements
otherwise.

Update the existing codebase to provide the expected fragment length,
based on the context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
98608b3c30 net: shell: Fix build with CONFIG_NET_BUF_VARIABLE_DATA_SIZE
The "net mem" command handler did not take the variable buffer length
configuration, and failed to build in such case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
521341813e net: pkt: Fix build with CONFIG_NET_BUF_VARIABLE_DATA_SIZE
In case variable buffer length feature was enabled, net_pkt code did
not build due to unconditional references to CONFIG_NET_BUF_DATA_SIZE,
which is not avaialable in this configuration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
00269af3e6 net: tcp: Fix build with CONFIG_NET_BUF_VARIABLE_DATA_SIZE
In case variable buffer length feature was enabled, the TCP stack did
not build due to unconditional references to CONFIG_NET_BUF_DATA_SIZE,
which is not avaialable in this configuration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
0e388e64fd net: shell: Process Echo Replies without a timestamp
In case Echo Request did not carry timestamp (i. e. requested payload
size was smaller than 4), there won't be a timestamp in the reply
either. Such replies should not be ignored. Instead, simply skip the
turnround time calculation if timestamp is missing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:34:45 -05:00
Robert Lubos
2b67e421a0 net: shell: Allow to specify ping payload size
Add -s parameter to the net ping command, allowing to specify the
payload size for the Echo Request.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:34:45 -05:00
Robert Lubos
967a91dce5 net: icmp: Allow to autogenerate Echo Request payload
Let net_icmpv4_send_echo_request() and net_icmpv6_send_echo_request()
autogenerate Echo Request payload, in case data length is specified but
no data pointer provided. The autogenerated payload includes timestamp
(if payload size permits) so that the turnround time can be calculated.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:34:45 -05:00
Morten Priess
afd14d6573 Bluetooth: controller: CIS Central fixes from EBQ run
Various fixes for issues found during EBQ run.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
745bf7297e Bluetooth: controller: Implement CIS Central in ULL
- Add CIS Create policy config choices
- Implemented CIS Central in ULL following proposed setup/commit flow
- Full support for HCI_LE_Set_CIG_Parameters_Test
- Extend ull_conn_iso_start and ull_conn_iso_ticker_cb to handle
  central role
- Partial support for HCI_LE_Set_CIG_Parameters. TODOs:
  * Drop suggested retransmissions if Max_Transmission_Latency is
    exceeded
  * Calculate ISO interval based on policy

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
07acdc9650 Bluetooth: controller: HCI fixes for ISO central role CIG/CIS creation
Fix issues with referencing invalid netbuf data and add missing
parameter. Removed returning of handle in setup functions, as handles
are  not available until commit.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
64ade9e01d Bluetooth: controller: Move CIS peripheral functionality to ull_conn_iso
Move ull_peripheral_iso_start ull_peripheral_iso_ticker_cb to
ull_conn_iso, to share code between CIS peripheral and central.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
38a4e58d1f Bluetooth: controller: Implement local CIS Creation procedure
Local procedure for CIS central establishment. Calls yet unimplemented
functions in ull_central. Changes are guarded by
CONFIG_BT_CTLR_CENTRAL_ISO.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Michał Barnaś
94458f88b9 ec_host_cmd: add eSPI peripheral for the host commands
This commit adds the support for host commands being transported
by the eSPI subsystem.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś
b91849c4bd ec_host_cmd: add missing fields and improve compatibility
Add missing fields in structure containing the arguments used by
the host commands handlers and change the order of parameters
in macro used for defining the handlers.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś
369596dc95 ec_host_cmd: increase stack size, change thread priority and alignment
This commit increases the stack size for thread handling the host
commands requests. It was required due to the stack being
corrupted using earlier default size. The thread priority is now
configurable using the Kconfig.
It also adds alignment to the tx_buffer since the npcx MCU requires it
to work correctly and removes clearing the buffer before use due to
the hard time requirements. Tests checking if buffers are cleared
are also removed.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś
959d3b87fb ec_host_cmd: move the host_cmd_periph.h to subdirectory
Move the header file to corresponding directory which refers to
submodule name instead of root of drivers directory.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Dominik Ermel
7048383362 doc: Move SMP transport documentation under doc/services
The commit moves MCUmgr SMP transport documentation from
subsys/mgmt/mcumgr/lib to doc/services/device_mgmt.
Documentation have been rewritten for that purpose.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Dominik Ermel
4328f165a8 mgmt/mcumgr: Reworking source code tree and API interface
The commit reworks mgmt/mcumgr subsystem source code to remove
lib subdirectory and make it a little bit more flat.
It also moves all API interface files, which are supposed to be
visible by applications using MCUMgr, to interface sub-directories,
and exposes them with full paths; for example to include general
MCUMgr support, group registration and so on, user would now include:
 <mgmt/mcumgr/mgmt/mgmt.h>
to additionally have control on File System group management
registration user would need:
 <mgmt/mcumgr/mgmt/grp/fs_mgmt.h>

All internal headers have been removed from interface.

CMAkeLists.txt get significant rework and various MCUMgr subsystems
have been divided into separate sub-libraries.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Dominik Ermel
7c2924f4bc mgmt/mcumgr: Move transport headers to transport subdir
The MCUmgr transport headers have been moved to
zephyr/mgmt/mcumgr/transport/

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Vinayak Kariappa Chettimada
a6beef4b26 Bluetooth: Controller: Replace Central connection spacing Kconfig
Replace the BT_CTLR_ADVANCED_SCHEDULING_CENTRAL_CONN_SPACING
Kconfig with BT_CTLR_CENTRAL_SPACING to configure the
the spacing from the beginning of a central connection event
to beginning of the next central connection when supporting
multiple simulataneous central connections.

If the BT_CTLR_CENTRAL_SPACING in microseconds is smaller
then the required time reservation for a connection event,
for given maximum data length and PHY in use, then the
calculated time reservation will be used as the spacing
between consecution central connection events.

The change fixes an issue wherein use of old Kconfig with
higher values causes new central connections to be placed
in between already connected central role if there was
free time space available to fit the new connections time
reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-17 14:44:17 +01:00
Omkar Kulkarni
7e3b509ae1 bluetooth: mesh: check id in connection callbacks
When application uses multiple identities mesh stack keeps reacting
on connection events not related to the own identity (BT_ID_DEFAULT)
causing it to trigger additional advertising and this leads to errors.
Though not harmful, this also leads to mesh stack counting connections
wrongly and consuming internal resources.

This commit fixes the issue described above by checking the
connection id before proceeding further.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2022-11-17 11:17:45 +01:00
Vinayak Kariappa Chettimada
465a96181d Bluetooth: Controller: Explicitly set all bits of used radio registers
Explicitly set all bits of used radio registers when
configuring radio events, removing the dependency on having
the power-on reset value and removing the need to ensuring
power-on reset values being set in the radio peripheral.

This will ensure the Controller has radio register value
correctly configured irrespective of changes across SoCs'
radio register power-on reset values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-17 10:56:13 +01:00
Vinayak Kariappa Chettimada
316a999d95 Bluetooth: Controller: Fix to allow multiple connectable advertisers
Fix BT_CTLR_MAX_CONNECTABLE define to allow multiple
connectable advertising sets to be enabled simultaneously.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-17 10:56:00 +01:00
Robert Lubos
1d7a077e11 net: ppp: Revert interface management changes
This reverts changes introduced in commit
dd535f611d, as they broke the gsm_ppp
driver integration with PPP L2. Apparently, a more thorough
refactoring is needed to use the new interface management scheme with
PPP.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-16 11:21:24 +01:00
Aleksandr Khromykh
7e63139499 Bluetooth: Mesh: fix memory corruption if oob string is 16 bytes
strcpy copies string including terminating null character.
strlen returns length without terminating null symbol.
If oob string is 16 bytes length then strcpy will corrupt byte
after auth array.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-11-16 11:21:14 +01:00
Aleksandr Khromykh
fcfc47bf93 Bluetooth: Mesh: fix static oob zero padding
The sample in the Provisioning protocol spec chapter
is in big endian. Static OOB value should append
zeroes on the little endian platforms.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-11-16 11:21:14 +01:00
Aaron Massey
bce9c6e2da emul_sbs_gauge: Rename reg_read/write more unique
Rename the reg_read and reg_write functions in the emul_sbs_gauge emulator
to be more unique symbols so as to support overriding this specific
function in future tests that make use of FFF. See #46817 which includes a
test for error reads as an example.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-16 11:19:21 +01:00
Aaron Massey
1d8750ddd6 emul_sbs_gauge: Don't set bad val in i2c msg buf
The SBS Gauge emulator would set the I2C buffer message with a value from
the emulator's custom read function even on a read error instead of just
returning. This behavior may be improperly relied upon by future tests.

Return early on register read before setting the i2c message buffer value
in the emulator.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-16 11:19:21 +01:00
Aaron Massey
1cff6099f7 emul: emul_sbs_gauge read/write returns ret code
To facilitate testing improper reads and writes on various registers,
enable the emul_sbs_gauge reg_read/write handlers to return custom exit
codes.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-16 11:19:21 +01:00
Emil Gydesen
ecb7591d6b Bluetooth: Audio: Rename BASS and BASS client
Rename BASS to BAP Scan Delegator and BASS Client
to BAP Broadcast Assistant. This is the first step towards
integrating the BASS with the rest of BAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-16 11:17:52 +01:00
Théo Battrel
b56823818d Bluetooth: Rename functions to satisfy CI
In file `subsys/bluetooth/mesh/net.c`:
renamed `loopback` to `net_loopback`.

In file `subsys/bluetooth/host/settings.c`:
Renamed `set` to `set_setting` and `commit` to `commit_settings`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-15 12:20:56 +00:00
Emil Gydesen
1d83e561e6 Bluetooth: Audio: Refactor use of cur_mcs_inst
Removes the global cur_mcs_inst and replace it
with lookup functionality.

This fixes an issue with bt_mcc_discover_mcs not being able
to be called more than once, as well
as streamline the implementation significantly.

This is also the first step towards not only supporting
multipe MCS instances for a single device, but also a
step towards handling multiple devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-15 12:18:50 +00:00
Emil Gydesen
0c04cf3c8e Bluetooth: Audio: Fix issue with NULL instance for MCC notifications
It was possible that on re-connect, the MCC implementation
would receive notifications when cur_mcs_inst was NULL.

This is partially caused by a bug in gatt.c, but can
and should also be handled in MCC.

This commit ensures that we do not compare handles
on notifications with a NULL instance.

This commit also ensures that subscribe_mcs_char_func
is not called outside the context of the discovery
procedure by setting the subscribe callback
to NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-15 12:18:50 +00:00
Emil Gydesen
0b4d33bcbb Bluetooth: Audio: Fix missing path_id for broadcast_sink
Adds support for using the path_id set by the capabilities
for the broadcast sink role.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-15 12:14:14 +00:00
Rodrigo Peixoto
b8ecbfaa57 zbus: Add message bus subsystem to Zephyr
Add zbus message bus as a Zephyr subsystem. No message bus
or communication abstraction other than the usual (message queues,
mailboxes, etc.) enabled developers to implement event-driven systems in
Zephyr quickly. Zbus would fill that gap by providing the community with
a lightweight and flexible message bus. The implementation tries to be
closest as possible to the existing ones. We use the claim/finish
approach, and the API for publishing and reading channels are similar
in message queues. Zbus is about channels, messages, and observers.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2022-11-14 17:25:29 -05:00
Martin Tverdal
09b514a610 Bluetooth: Fix issue with adv_stop
If adv stop was called form connected callback,
it would continue and unref the wrong conn object
if there where 2 connectable advertisers running,
but with only one 1 id configured.

Fixes #52196

Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
2022-11-14 13:07:51 +01:00
Vinayak Kariappa Chettimada
b56a6906e2 Bluetooth: Controller: Fix advertising disable on connection complete
Fix advertising set's is_enabled flag to be reset when
connection complete is dequeued for connectable advertising
started using legacy advertising enable HCI commands. And
reset the is_enabled flag when advertising set terminated
is dequeued for connectable advertising enabled using
Extended Advertising HCI commands.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-14 13:06:38 +01:00
Vinayak Kariappa Chettimada
13c29940bf Bluetooth: Controller: Fix ticker ticks diff calculation
Fix ticks difference calculation to determine delayed
prepare callback. Without the use of masking by
ticker_ticks_diff_get, the diff value can be higher than
the supported 24-bit value. i.e. ticker_ticks_now_get()
rolls over in 24-bit value, whereas ticks_at_event is
free running value of 32-bits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-14 13:06:21 +01:00
Benjamin Lindqvist
85c6de4335 lorawan: enable run-time config of region/freq
This commit adds support for compiling in support for several different
regions/frequencies and dynamically choosing which to use in run-time.
This commit introduces no API breakages - if a prj.conf contains only a
single region Kconfig, the new function lorawan_set_region() does not
need to be called.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2022-11-14 11:16:16 +00:00
Veijo Pesonen
f467410088 net: lwm2m: shell - allow leading slash
Paths should start from root.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-11-11 08:49:25 +00:00
Vinayak Kariappa Chettimada
e895948047 Bluetooth: Controller: Add Long Control PDU support
Add long control PDU size support, also the implementation
now allocates control PDU size restricted to the supported
biggest control PDU that is enabled in the application
build. Features that are covered based on the increasing
control PDU sizes are ClearText connections, Encrypted
Connections, Connection Parameter Request support and
Create CIS control Procedure (Connected Central ISO)
support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-11 08:46:26 +00:00
Carles Cufi
b90c27238a Bluetooth: crypto: Refactor a few items
After merging #51809, a few things were spotted that needed tweaking.
Among them:

- Rename the folder from bt_crypto to crypto, since the prefix is
  unnecesary
- Remove the include folder
- Remove the path from the global include paths

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-10 17:54:14 +02:00
Dominik Ermel
dac058c058 mgmt/mcumgr: Fix documentation for hash_checksum_mgmt_list_cb
Incorrectly hash_checksum_mgmt_handler_fn has been referenced
in documentation for hash_checksum_mgmt_list_cb, causing
documentation generation error, because parameter list does
not match.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-10 15:48:39 +01:00
Jason Wright
e369a8899f testsuite: coverage: create kconfig option for gcov dump heap size
The heap size for serial dump of gcov data is currently
defined by MALLOC_MAX_HEAP_SIZE, which cannot be
adjusted by kconfig. This commit adds a new kconfig
option, CONFIG_COVERAGE_GCOV_HEAP_SIZE, which retains
the behavior or MALLOC_MAX_HEAP_SIZE by default.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-11-10 08:48:06 -05:00
Dominik Ermel
7ed6775d02 mgmt/mcumgr: Fix MCUMGR_BUF_USER_DATA_SIZE selection for BT
Rounded up struct smp_bt_user_data takes 8 bytes; this fixes
static assert failing with message:
  CONFIG_MCUMGR_BUF_USER_DATA_SIZE not large enough to fit Bluetooth
  user data

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-10 13:30:12 +01:00
Jamie McCrae
dbd2176655 mgmt: mcumgr: fs_mgmt: Update hash/checksum supported command
Updates the hash/checksum supported command to use the new command
structure.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
c2b872b901 mgmt: mcumgr: os_mgmt: Switch to new event callback system
Switches to the new event callback system for the os_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
986ea39512 mgmt: mcumgr: img_mgmt: Switch to new event callback system
Switches to the new event callback system for the img_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
4e8fde15a3 mgmt: mcumgr: fs_mgmt: Switch to new event callback system
Switches to the new event callback system for the fs_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
042ed0539b mgmt: mcumgr: Add access denied error code
Adds an access denied error code that can be used to signal to the
mcumgr client that the requested access to a specific resource or
command/functionality has been denied.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
6f75c99b8b mgmt: mcumgr: Rework event callback system
Reworks the event callback system to use a linked list to allow for
chained handlers and support passing a status back to the handler to
indicate if the request should be rejected or allowed. This also
removes the old base callback functionality.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
77374b3857 mgmt: mcumgr: fs_mgmt: Allow querying supported hash/checksums
Adds a new mcumgr command for returning information on all supported
hash/checksum types that the firmware supports.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:10:03 +01:00
Jamie McCrae
2aca1242f7 mgmt: mcumgr: Fix Bluetooth transport issues
This fixes issues with the Bluetooth SMP transport whereby deadlocks
could arise from connection references being held in long-lasting
mcumgr command processing functions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:08:52 +01:00
Jamie McCrae
7028d01544 mgmt: mcumgr: Update struct name in documentation
Replaces mgmt_hdr with smp_hdr in documentation to match changes in
code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:08:26 +01:00
Jamie McCrae
f0669f845c mgmt: mcumgr: Replace mgmt_ctxt struct with smp_streamer
This replaces an intermediatory structure with a different one which
allows command functions to access the full contents of the streamer
structure that would be otherwise unavailable. This is a foundation
for allowing asynchronous mcumgr messages from the server.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:08:26 +01:00
Nirosharn Amarasinghe
bd74d27614 Bluetooth: controller: Time wrapping point used in ISO-AL calculations
-- Handle time calculations across the point at which the controller's
   time information from the controller's clock will wrap (in the
   microsecond range)
-- Use wrapped time in all ISO-AL time calculations

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-11-10 09:29:42 +01:00
Théo Battrel
e9c542ab5b Bluetooth: Add the cryptographic toolbox function h8
Add to the cryptographic toolbox the h8 function, defined in the Bluetooth
Core Vol. 6, part E 1.1.1.

Also add test and SMP self test for this function. The data used for those
are from the Bluetooth Core.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-10 09:28:28 +01:00
Théo Battrel
f16738b62b Bluetooth: Move crypto toolbox functions from smp.c to their own files
Move functions defined in the Cryptographic toolbox of the Bluetooth
specification inside their own files in the following folder:
`zephyr/subsys/bluetooth/bt_crypto`. The functions were previously
implemented in `zephyr/subsys/bluetooth/host/smp.c`.

The cryptographic toolbox functions can now be accessed from outside of the
host.

In addition to that, tests for each cryptographic toolbox functions have
been added.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-10 09:28:28 +01:00
Ryan Erickson
12b4187092 lwm2m: swmgmt: fix observations not working for resources
The pointers to resource values should not be used
directly to update the values.
This will break observations if the server is trying to
observe changes during a software update.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-11-10 09:27:54 +01:00
Pavel Vasilyev
1629a2f4d1 Bluetooth: Mesh: Fix net and app keys commands in shell
Fix net and app keys commands in shell

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-09 10:50:31 -06:00
Mariusz Skamra
6148d8a39d Bluetooth: audio: Fix invalid assert in bt_audio_iso_unbind_ep
This should assert if iso argument does not match the one ep holds
reference to.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-09 10:45:12 +01:00
Emil Gydesen
03a4e1ae48 Bluetooth: Audio: Add missing unbind of audio_iso for broadcast sink
When a BIS disconnected, we removed the references between
the endpoint and the stream. This made it impossible
to later unbind the audio_iso when
broadcast_sink_cleanup_streams was called.

Fixed by unbind the audio_iso when we remove the reference.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-09 10:45:06 +01:00
Markus Fuchs
ea17d5152d net: sockets_tls: Fix memory leak in socket
Fix file descriptor leak on unsupported socket protocols.

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
2022-11-09 10:44:44 +01:00
Erik Brockhoff
b1c0bc0c0a Bluetooth: controller: add central anchor point move to new LLCP
Add central functionality re. anchor point move to refactored LLCP

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 10:43:17 +01:00
Erik Brockhoff
26df2db60a Bluetooth: controller: add handling of preferred periodicity to new LLCP
Port central functionality re. preferred periodicity to refactored LLCP

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 10:43:17 +01:00
Erik Brockhoff
c180afec11 Bluetooth: controller: Adding user ext. anchor point move to ctrl/CPR
Adding support for allowing user extension code to support deferring
anchor point moves. Refactored LLCP only.
Note: This is NOT supported by LEGACY LLCP impl.
KConfig'd by BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE
Modified ll_conn_update API, to accommodate passing offsets
Modified CPR/CU context data structure
Modified CPR/CU procedure to handle anchor point move wait state
Fixed up unit tests, adding anchor point move cases to CPR/CU test

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 10:43:17 +01:00
René Beckmann
26758117d6 net: mqtt-sn: Add MQTT-SN library
This commit adds an implementation of MQTT-SN v1.2.
The specification is available on oasis-open.org:
https://www.oasis-open.org/committees/download.php/66091/MQTT-SN_spec_v1.2.pdf

The following things are missing in this implementation:
- Pre-defined topic IDs
- QoS -1 - it's most useful with predefined topics
- Gateway discovery using ADVERTISE, SEARCHGW and GWINFO messages.
- Setting the will topic and message after the initial connect
- Forwarder Encapsulation

Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
2022-11-09 10:43:00 +01:00
Hubert Miś
dc9d479dea ipc: add a multi-endpoint feature to icmsg
The icmsg backend for ipc_service has a limitation of supporting only
on endpoint. This limitation is acceptable for many IPC instances.
However, some require to use multiple endpoints sharing a single
instance. To preserve the simple and the most efficient single-instance
backend, a separated backend is introduced implementing a wrapper
around icmsg core which adds multiple endpoints support.

There are two multi-endpoint ipc_service icmsg backends: one in the
initiator role, and the other one in the follower role. In a IPC
configuration one end of communication must be in the follower role
while the other one is in the initiator. The initiator initiates
an endpoint discovery handshake to establish enpoint identifiers for
requested endpoint names. The follower responds to requests sent by
the initiator.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-11-09 10:41:43 +01:00
Hubert Miś
6f450fdf18 ipc: separate icmsg core from ipc_service backend
icmsg library was implemented as a ipc_service backend. It is a simple
library with minimal feature set. To preserve its simplicity while
adding more features it is useful to introduce separated ipc_service
backends with added features. To reuse most of the icmsg code for the
simplest backend and other including more features, the core of icmsg
is separated from the simplest ipc_service to an icmsg module which
can be used by multiple backends.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-11-09 10:41:43 +01:00
Erik Brockhoff
85354c405c Bluetooth: controller: refactoring pdu length validation
Using a macro instead of repeated identical code for validation
Use macro for pdu length field encoding

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 09:34:35 +00:00
Erik Brockhoff
2a236e52db Bluetooth: controller: rename pdu_data_llctr struct SCA member
Rename struct member to adhere to general naming pattern

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 09:34:35 +00:00
Christoph Schnetzler
c364721796 net: sockets: Prevent compiler error if warnings being treated as errors
If gcc compiler option -Werror is used the warning,

declared inside parameter list will not be visible outside of this
definition or declaration [-Werror]

is treated as error, for

sockets_internal.h:18:28: ‘struct net_context’
sockets_internal.h:19:32: ‘struct zsock_pollfd’
fdtable.h:108:17: ‘struct k_mutex’

Signed-off-by: Christoph Schnetzler <christoph.schnetzler@husqvarnagroup.com>
2022-11-09 09:15:32 +00:00
Emil Gydesen
64c2d86a64 Bluetooth: ISO: Replace CONFIG_BT_DEBUG_ISO_DATA guard with BT_ISO_DATA_DBG
Instead of guarding all BT ISO data log statements with
CONFIG_BT_DEBUG_ISO_DATA, a new macro, BT_ISO_DATA_DBG, is
implemented to handle the guarding.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-09 09:05:03 +00:00
Emil Gydesen
36c5dd4bca Bluetooth: ISO: Guard addition ISO debug with CONFIG_BT_DEBUG_ISO_DATA
Guard additional debug statements in ISO that deals
with TX/RX with CONFIG_BT_DEBUG_ISO_DATA to avoid spamming
the log.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-09 09:05:03 +00:00
Sean Madigan
a53446cd09 Bluetooth: Host: Check if EATT l2cap server is registered
bt_eatt_init currently registers a l2cap server, however should not
register a new one if it has already been registered - for example in
bt_enable previously.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
f88b19a833 Bluetooth: Host: init bt_workq and cancel rpa_update work
Init bt_workq in bt_enable so it can be safely disabled.

Cancel rpa_update work upon disable as it is no longer required.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
666990b6e4 Bluetooth: Host: add pub_key_hci_disrupted function
Add bt_pub_key_hci_disrupted function for when hci is disrupted during
a pub key hci command, to clear callbacks and BT_DEV_PUB_KEY_BUSY flag.

Call this from bt_disable for the case bt_disable disrupts the pub key
hci command.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
a4fcf39a69 Bluetooth: Host: clean up after connections in bt_disable
Reset disconnected handles as is no longer needed after disable.

Created a destroy function to clear all connection states and cancel any
deferred work.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
c80b6d8223 Bluetooth: Host: reset adv_pool in bt_disable
Reset the adv_pool in disable so that advertising can be started after
re-enabling without issue.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
0e010e8744 Bluetooth: Host: init fifos and slists before use
In bt_att_init, bt_conn_init and bt_l2cap_init, init the fifos and
slists before use. This means that they can be used after disable
without memory leakage.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
0ef4f9740a Bluetooth: Shell: Add bt_disable to bluetooth shell app
bt_disable can now be used with the bluetooth shell.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Jamie McCrae
693e4cda81 mgmt: mcumgr: img_mgmt: Remove packed attribute from some structs
Removes the packed attribute from the img_mgmt structs that do not
need it.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-08 22:38:20 +01:00
Emil Gydesen
a34c2cd90a Bluetooth: Audio: Fix ASE_{SNK,SRC}_COUNT=0 issues
Due to the LISTIFY macro for the counts, the value
cannot be 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 10:48:54 +01:00
Mariusz Skamra
529b4b2b1d Bluetooth: audio: ascs: Fix invalid error code returned
This fixes invalid error code that was returned in case remote requested
Disable operation with invalid ASE ID.

Fixes: BAP/USR/SPE/BI-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-08 10:48:47 +01:00
Pavel Vasilyev
f2ea6f2149 Bluetooth: Mesh: Check avail conn before restarting pb-gatt srv adv
When a provisioner connects to the device, gatt_connected callback is
called in pb_gatt_srv.c, then pb-gatt advertising is stopped and adv_sent
callback is triggered in adv_ext.c. adv_sent callback reschedules
advertising and eventually calls bt_mesh_adv_gatt_send. Since the device
is not provisioned yet, it tries to start pb-gatt advertising again. If
number of available connections is reached, this results in "Advertising
failed" error in adv_ext.c.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-08 10:47:24 +01:00
Vinayak Kariappa Chettimada
0f80133571 Bluetooth: Host: Add auto conn param update retry count and timeout
Add implementation to retry the automatic peripheral
perferred connection parameter request with a configurable
retry countdown and retry back-off timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-08 10:47:07 +01:00
Vinayak Kariappa Chettimada
073b2af808 Bluetooth: Host: Fix use of tabs inside struct and enum definitions
Fix use of tabs inside struct member of bt_conn_le and
bt_conn enum definitions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-08 10:47:07 +01:00
Sam Hurst
37e6f15f34 usb-c: Fix unsupported message reporting
When operating in PD2.x mode, PD_CTRL_REJECT should be
transmitted to the port partner when an unsupported message
is received.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-11-08 10:46:40 +01:00
Mariusz Skamra
e4f0bcdd56 Bluetooth: audio: ascs: Fix audio ISO allocation in QoS->QoS transition
ASE in QoS state already have audio ISO object.
This will just skip the audio ISO allocation and binding in such case
if CIG and CIS parameters did not change.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-08 10:46:07 +01:00
Lingao Meng
93709a7359 Bluetooth: Mesh: Add specific number of keys & groups
Since Mesh Spec and Mesh model sayes, some model no need
groups and no need keys, such as Config Server, but the
current implementation, all model use same configuration,
which cause some ram ext comsume.

So that, change to specific way, but will consume more footprint size.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-08 10:45:15 +01:00
Erik Brockhoff
76439d0ba4 Bluetooth: controller: integrating SCA procedure and adding HCI API
Adding controller support for updating SCA in ACL and ISO peripherals
Adding HCI API support for le_request_peer_sca and complete event.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-08 10:44:54 +01:00
Erik Brockhoff
b3b4b9e322 Bluetooth: controller: implementing SCA update procedure PDU flow
Adding PDU flow and unittest for Sleep clock accuracy procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>

wip kconf
2022-11-08 10:44:54 +01:00
Tom Burdick
e3d877f811 rtio: Userspace support
Add support for userspace with RTIO by making rtio and rtio_iodev
k_objects. As well as adding three syscalls for copying in submissions,
copying out completions, and starting tasks with submit.

For the small devices Zephyr typically runs on one of the most important
attributes tends to be low memory usage. To maintain the low footprint of
RTIO and its current executor implementations the rings are not shared with
userspace. Sharing the rings it turns out would require copying submissions
before working with them to avoid TOCTOU issues.

The API could still support shared rings in the future so that a
kernel thread could directly poll, copy, verify, and start the submitted
work. This would require a third executor implementation that maintains its
own copy of submissions similiar to how io_uring in Linux works.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-08 10:44:03 +01:00
Emil Gydesen
8dffa45e0c Bluetooth: Audio: Add support for multiple subgroups for BAP broadcast sink
The broadcast sink supports multiple subgroups, but was
not possible due to the Kconfig option.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:43:11 +00:00
Erik Brockhoff
6b324122e7 Bluetooth: controller: fix CIS REQ event generation and rejection
Check LE event mask state as well as host controlled feature mask state
and reject CIS request accordingly.
Release pre-allocated ISO resources on rejection of request

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-08 09:38:21 +00:00
Emil Gydesen
87eab711df Bluetooth: Audio: Add additional printing in CSIS client shell
The CSIS client shell did not print the pointers of the instances
discovered, which are needed for future commands.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:37:17 +00:00
Emil Gydesen
6d46472cfe Bluetooth: VCS: More explicit log for abs vol set opcode
When the set absolute volume opcode was received, we
logged the current volume, but without any explaining
text.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:36:04 +00:00
Emil Gydesen
7fb8f77103 Bluetooth: Audio: Shell: Fix metadata argument
The metadata in the presets are just defined
using the BT_AUDIO_LC3_PRESET which ultimately
uses BT_CODEC_LC3_CONFIG_META which correctly
sets the data pointer, but the `value` array is unused.

So we cannot just update the `value`, as that is actually
not used in those cases, and the `data` pointer is `const`.

The solution is to a copy of the metadata data, and use
the copy when calling the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:35:25 +00:00
Kumar Gala
6401682dd3 ztest: Fix building when CONFIG_MP_NUM_CPUS=1
We get compiler warnings on testcases that set CONFIG_MP_NUM_CPUS=1
and platforms that have CONFIG_SMP=y.  Qualify the code so its only
built if CONFIG_SMP && (CONFIG_MP_NUM_CPUS > 1).

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-11-07 21:12:54 -05:00
Andrzej Puzdrowski
2c52733f8d dfu/boot/mcuboot: treat pristine image as confirmed
In case of initial/pre-programed image.
Such image can neither be reverted nor physically confirmed.

Image like this should be recognized as confirmed by the
boot_is_img_confirmed() for consistency.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-11-07 09:50:35 +01:00
Mariusz Skamra
9054435a4a Bluetooth: ascs: Handle CIS disconnection in non-releasing state
Unbind ISO when goint to idle state if there's still reference kept.
It may happen that we get CIS disconnection being in non-releasing
state, so we have to handle that case. This fixes regression that was
introduced in 3fa456905d.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-07 09:50:18 +01:00
Lingao Meng
9cb1ff7fce Settings: NVS: Add cache for nvs name lookup
Add cache for name id lookup.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-05 19:58:34 +01:00
Jamie McCrae
b6cd83bf7a net: ipv4: Add fragmented packet support
Adds support for incoming and outgoing IPv4 fragmented packet support,
allowing a single packet that is too large to be sent to be split up
and sent successfully.

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2022-11-05 19:58:26 +01:00
Pavel Vasilyev
d286bc4699 Bluetooth: Mesh: Fix args parsing in cmd_net_key_add function
cmd_net_key_add has only 2 arguments.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-05 19:56:50 +01:00
Mariusz Skamra
7a6581219d Bluetooth: gatt: Fix notification cleanup on disconnection
This fixes GATT notification buffer missing cleanup on ACL
disconnection. Fixes potential NULL pointer dereference trying to use
invalid conn object in `notify_mult_process` work queue task handler
and/or missing free of pending notification buffer.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-05 19:56:42 +01:00
Stephanos Ioannidis
fa5fd41b61 kernel: Add C++ main() support
The C++ standard requires the main() function to have the return type
of 'int' and does not allow the main() to be defined with the 'void'
return type. Moreover, GCC goes as far as to emit a hard error when the
'::main()' has the return type of `void`.

This commit introduces an option to instruct the Zephyr kernel to call
the 'int main(void)' instead of the 'void main(void)' in case a Zephyr
application defines main() in a C++ source file.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-11-05 16:41:45 +09:00
Mariusz Skamra
fbeee206f2 Bluetooth: audio: pacs: Hotfix invalid PACS length
This fixes adding 2 redundant bytes... to the PAC records.
As a result we end up with broken PAC record.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 10:00:00 +01:00
Mariusz Skamra
7405f81db6 Bluetooth: audio: pacs: Remove unused structure member
The 'pacs' member was never referenced.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 10:00:00 +01:00
Mariusz Skamra
8f6fc38ca3 Bluetooth: audio: unicast_client: Remove redundant code
The unicast_client_ep_set_codec function that is called below
sets the codec id, cid, vid.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 10:00:00 +01:00
Juha Heiskanen
efa75b5a76 net: lwm2m: Send operation registry lock update
Secured Message allocation, init and rebuild process for secure
timeseries ring buffer.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-11-04 09:59:51 +01:00
Juha Heiskanen
05a92f9258 net: lwm2m: Timeseries data cache read update
Added support for handle case when all data is not possible to
add in 1 message for Send and Observed Notification.

Notification continuous pending timeseries data is triggred
by iMIN attribute.

Send Operation generate continuous message in multiple lwm2m
message.

Normal Read by server only report back latest stored data.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-11-04 09:59:51 +01:00
Tommi Kangas
75b5eaac0f net: lwm2m: fix hanging deregistration
Fixed a deadlock in deregistration by moving mutex unlocking.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2022-11-04 08:56:05 +00:00
Mariusz Skamra
50b57056bd Bluetooth: iso: Fix calling wrong function to terminate BIG
The bt_iso_chan contains vaild pointers for Tx and Rx QoS parameters.
This unifies the implementation between different roles.
This fixes checking ISO type that is done based on ISO type that
is kept inside of conn.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
0fa978508c Bluetooth: audio: unicast_client: Inform all related EP's about ISO state
This fixes application callbacks not being called on ISO connection
state change.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
3fa456905d Bluetooth: audio: Factor out bt_audio_iso pool
This adds common bt_audio_iso pool that will be used across all the
roles/profiles. The pool range is dependent on the CONFIG_BT_ISO_MAX_CHAN
which is the maximum number of ISO connections the host can maintain.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
1aaf1e522f Bluetooth: audio: unicast_client: Remove unused functions
This removes unused functions from unicast_client.c

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
6fde7ae96d Bluetooth: audio: ascs: Move control point work to EP
Move the control point work to the EP. The aim is to cleanup the code so
that it there's no EP for ASE that means ASE is in idle state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Jamie McCrae
461b2147d6 mgmt: mcumgr: Fix using wrong value for response packet size
Fixes an issue introduced with a recent change that wrongly uses the
source packet header size for the output instead of the supplied
size.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-03 15:39:17 +01:00
Dominik Ermel
95202ae3da mgmt/mcumgr: Unify function definition style
Move static and return type in line with definition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
98831be2c4 mgmt/mcumgr: Rename mgmt_hdr to smp_hdr
mgmt_hdr has always been part of SMP protocol and the name is
a little bit misleading.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
73d1bf984a mgmt/mcumgr: Make mgmt_hdr definition internal
It is only needed to be known by SMP protocol processing
and in some cases by transport, for example reassembly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
bf8ec99860 mgmt/mcumgr: Remove mgmt_ntoh_hdr and mgmt_hton_hdr
These two-liners have been only used by SMP protocol processing,
and there is no reason to have them available as public functions.
Code from these functions have been moved directly where they
have been used and they have been removed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
5f025cf49c mgmt/mcumgr: Move and rename zephyr_ prefixed functions in OS group
zephyr_ prefix is now redundant as there are no other OSes supported.
The commit also moves functions, after renaming them, and makes
them static, as they no longer have to be shared between compilation
units.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:29 +01:00
Dominik Ermel
80958bbff9 mgmt/mcumgr/lib: Merge Zephyr specific code to fs_mgmt.c
It is no longer needed to have "system specific" API for FS management.
The commit removes fs_mgmt_impl.h and moves Zephyr specific
functions that implement the fs_mgmt_impl.h declared functions
into fs_mgmt.c

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:29 +01:00
Jamie McCrae
4c48b4f21a mgmt: mcumgr: img_mgmt: Fix bug with old image state being present
This fixes an issue whereby the image state of an upload is present
even after an image erase command, which would instruct a client to
continue uploading at an offset that has no preceeding data.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-03 13:03:53 +01:00
Vinayak Kariappa Chettimada
f35b9eb5cc Bluetooth: Shell: Select BT_TICKER_NEXT_SLOT_GET when BT_LL_SW_SPLIT
Select BT_TICKER_NEXT_SLOT_GET when BT_LL_SW_SPLIT enabled
and building applications with shell support (BT_SHELL).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-03 10:24:49 +01:00
Emil Gydesen
cdc3b332ba Bluetooth: Audio: Fix unicast client ep reset
The endpoint was only partially memset on disconnect,
which left the handles untouched. This meant that the
reset endpoint would still get returned by
unicast_client_ep_find.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-03 10:24:03 +01:00
Morten Priess
447c7390f5 Bluetooth: controller: Add window widening for CIS/CIG
Program CIG ticker with window widening drift. Introduce vendor specific
conversion macros allowing sub-microsecond resolution in the
accumulation of window widening drift per interval.

Calculation of window_widening_max_us is done for NSE<3, and must be
adjusted in the LLL before use, if the first CIS in the CIG has a
NSE>=3. In that case window_widening_max_us shall be limited to one sub
interval.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-03 08:56:58 +00:00
Théo Battrel
7d2b4e1917 Bluetooth: Remove unneeded macros
Remove the `bt_hex`, `bt_addr_str`, `bt_addr_le_str` and `bt_uuid_str`
macros from `bt_str.h` as they were just aliases for the `*_real` functions
in the same file.

The functions has been renamed without the `_real` suffix.

Some files were using the functions and not the macros, they have been
updated to use the new name of the functions.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-02 13:28:57 +01:00
Théo Battrel
effb76c61e Bluetooth: Move re-implementation of snprintk
Move the function in the `subsys/testsuite/ztest/src/ztest_mock.c` files.

This is motivated by the fact that there is others re-implementation of
`*printk` functions using libc counterparts in the `ztest_mock.c` file.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-02 13:28:57 +01:00
Théo Battrel
c9d68a5a4f Bluetooth: Move out string related function of common/log.h
Functions related to string manipulation that were defined in
`common/log.h` has been moved to the `common/bt_str.h` file and their
implementation in `common/bt_str.c`.

Files that were using those functions has been updated consequently.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-02 13:28:57 +01:00
Vinayak Kariappa Chettimada
5cf47b1e7f Bluetooth: Controller: Fix ticker slot reserved check
Fix ticker slot reserved check to handle deferred execution
of ticker worker where ticks_elapsed is greater than
ticks_slot_previous. In which case, each ticker expiring be
checked for overlap with previous slot reservation.

This fixes:
ASSERTION FAIL [0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/
controller/ll_sw/nordic/lll/lll.c:476
lll_preempt_calc: Actual EVENT_OVERHEAD_START_US = 3906

Flash erase operation exposed the assertion, CPU being
halted deferred the ticker_worker collision resolution and
ticker expiry was not individually checked for overlap with
previous expired ticker reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:33:22 +01:00
Vinayak Kariappa Chettimada
fbfa2b4631 Bluetooth: Controller: Fix missing first connection event
Fix missing first connection event due to first connection
event ticks_slot of central and peripheral overlapping with
the initiator window ticks_slot and advertising ticks_slot,
respectively.

Use ticker_stop_abs interface so that when the ticker is
stopped the ticks_slot_previous is truncated to the actual
ticks used as requested by the supplied absolute ticks.

Relates to commit 8a294a62d4 ("Bluetooth: controller:
legacy: Fix missing first conn event").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:33:22 +01:00
Tomasz Moń
04059ec8a7 usb: device: msc: synchronize cache after writes
Flush disk cache when write command finishes.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-11-02 10:31:58 +01:00
Vinayak Kariappa Chettimada
af9dd5cb26 Bluetooth: Controller: Fix ticks_current initialization
Fix ticker instance ticks_current initialization to be
acquired from the RTC counter value. The RTC counter may
have run in previous use of ticker before bt_disable hence
keep the instance ticks_current equal to RTC counter value
when ticker_init() is called again.

Relates to commit 4349a475a8 ("Bluetooth: Controller: Add
deinit() infrastructure").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:31:33 +01:00
Vinayak Kariappa Chettimada
943deca7c4 Bluetooth: Shell: Add back erroneously removed ll-addr command
Add back erroneously removed ll-addr command, when removing
legacy Controller, which is provided when using Zephyr
Bluetooth Low Energy Controller to read the random and
public address set by the Host, and used by the Controller.

Relates to commit b67a31e411 ("Bluetooth: controller:
Remove legacy LL").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:30:52 +01:00
Ingar Kulbrandstad
7367980bea Bluetooth: Mesh: Extended advertiser as default
Setting the extended advertiser as default advertiser
to improve both preformence and reliability.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2022-11-01 08:52:56 +00:00
Piotr Pryga
f24b5b4b43 Bluetooth: host: df: fix wrong connectionless CTE enable cmd length
There were a bug in a prepare_cl_cte_rx_enable_cmd_params function.
The size of command buffer was wrong when CTE enabled in AoD mode.
The command buffer was extended by param->num_ant_ids, that was
zero in case of AoD. Then a dummy antenna switch pattern was copied
into the command buffer.

That lead to: memory overwrite, and wrong command buffer length.
The command was rejected by Controller.

To fix, use cp->switch_pattern_len that was already assigned with
correct antenna pattern length.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-31 11:23:44 +01:00
Mariusz Skamra
3ea297960d Bluetooth: audio: Remove capablilities leftovers
Remove dead code that remained after
https://github.com/zephyrproject-rtos/zephyr/pull/51425 was merged.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-31 16:39:05 +09:00
Christoph Schnetzler
0dd14404e1 net: lwm2m: Prevent wundef warnings
If -Werror is used compilation fails due to wundef warning.

Signed-off-by: Christoph Schnetzler <christoph.schnetzler@husqvarnagroup.com>
2022-10-28 22:06:09 +09:00
Carles Cufi
8e4d499fa0 treewide: Use CONFIG_*_ENDIAN instead of __BYTE_ORDER__
In order to avoid using multiple sources of truth for the platfom's
endianness, convert the in-tree code to use the (BIG|LITTLE)_ENDIAN
Kconfig variables exclusively, instead of the compiler's
__BYTE_ORDER__.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-28 19:23:46 +09:00
Jordan Yates
c3eeae80ec debug: thread_info: store arch mode_exc_return offset
Store the offset of mode_exc_return in the arch struct. This is required
to restore the link register to the original value, as `swap_helper.S`
saves the LSB to this field when `CONFIG_ARM_STORE_EXC_RETURN=y`.

Failing to account for this results in broken debugging when
`FPU_SHARING` or `ARM_NONSECURE_PREEMPTIBLE_SECURE_CALLS`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-10-28 11:51:15 +02:00
Emil Gydesen
affd8da9a0 Bluetooth: Host: Fix wrong addr for PA term when using adv list
If using the advertiser list when syncing to a PA, then the
address address needs to be updated for the PA sync object.
This is a small optimization to avoid doing a copy when
the address and SID is already set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-28 07:56:41 +00:00
Emil Gydesen
cba4b1828d Bluetooth: Host: Fix missing term callback for PA syncs
When deleting a PA sync with bt_le_per_adv_sync_delete
Zephyr should call the `term` callback for the PA sync
as per the documentation for the callback.

This was not done in the case that the PA sync was
terminated by local request.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-28 07:56:41 +00:00
Martin Tverdal
0cf6cac77e Bluetooth: extended adv reports with legacy content discardable
To avoid legacy extended adv repots blocking important
events or work, mark them as discaradble.

Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
2022-10-28 07:55:44 +00:00
Kumar Gala
8eb0cdfcfb ztest: Convert CONFIG_MP_NUM_CPUS handling
For test_1cpu_start/test_1cpu_stop make the code only build if
CONFIG_SMP and move to using arch_num_cpus() for runtime loops
and CONFIG_MP_MAX_NUM_CPUS for array decleration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-27 14:02:05 -04:00
Kumar Gala
dd03af653d pm: Rework usage of CONFIG_MP_NUM_CPUS to CONFIG_MP_MAX_NUM_CPUS
Replace usage of CONFIG_MP_NUM_CPUS with CONFIG_MP_MAX_NUM_CPUS for
init and declaration as we phase out CONFIG_MP_NUM_CPUS usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-27 13:51:55 -04:00
Jonathan Rico
4b1585c23f Bluetooth: shell: fix compiler warning
Compiler thinks `err` is not initialized when
`CONFIG_DEBUG_OPTIMIZATIONS=y`.

Fixes #51521 .

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-27 17:23:36 +02:00
Andries Kruithof
5e360b81c2 Bluetooth: controller: llcp: update rx parameters upon receipt of PDU
According to specification, when executing a remote procedure the
rx parameters used need to be updated when the REQ from the peer
is received. Currently this is done only when an ACK is
received on the RSP PDU send out.
This commit updates the RX parameters upon receipt of the REQ PDU

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-10-27 16:57:27 +02:00
Krishna T
1852e33213 net: lib: zperf: Disable prints during ongoing traffic
Prints when traffic is ongoing cost a few Mbps due to writing to UART as
observed by the profiler, so, disable them by default.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-27 15:37:41 +02:00
Aleksander Wasaznik
fd5fe6ca8e Bluetooth: Host: Add CONFIG_BT_ID_UNPAIR_MATCHING_BONDS
This commit prevents the assertion error added in the previous commit,
by introducing the following behavior.

When the Host detects that a pairing procedue would result in more than
one local identity having a bond with the same remote address, it will
try to abort the pairing. If the pairing procedure cannot be properly
aborted, it will remove the pairing locally and disconnect.

This commit also introduces a new kconfig `BT_ID_UNPAIR_MATCHING_BONDS`.
This config changes the above-described behavior to instead un-pair the
old bond and continue with the pairing (if the new bond has the same or
better security.)

The new kconfig is not enabled by default. See the help text of the new
kconfig option for more details.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-27 13:16:59 +02:00
Aleksander Wasaznik
6e926dcd83 Bluetooth: Prevent bonding to the same device more than once
This change prevents two local identities from having bonds to the same
device.

The Core specification is not well suited for Zephyr's multiple-local-
identities feature. The HCI specification seems written with intent that
a controller is used for only one GAP device. A GAP device has at most
one public address, and at most one random static address.

The Zephyr Bluetooth API, on the other hand, has a concept of local
identities. This feature allows the Zephyr Bluetooth stack to
simulatainously assume multiple local addresses. This does not mesh well
with the above intent in the specification.

In particular, the HCI specification for the resolve list does not allow
more than one entry for a remote address. The controller will deny any
attempts at doing this.

The current implementation of the Zephyr host will try the above and be
denied. But there is no handling for this situation and the host ends up
in a confused state. Some parts of the system are ok with the two bonds,
but other parts assume this situation never occurs behave badly.

The result is that the host confuses the multiple bonds to the same
device. Symtoms include:

- Directed advertisements have a different source address than what the
  host intended, in which case the two sides are confused about the
  address of the Zephyr advertiser, and as a result LTKs will not match.

- Errors in the log.

This commit simply asserts. This is not a solution, just a placeholder
for a fix. The next commit will implement a strategy for handling this
situation instead of failing this assert.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-27 13:16:59 +02:00
Aleksander Wasaznik
dfe03c1268 Bluetooth: Host: Define bt_irk_eq
This gives a well-defined method for determining if two IRKs are equal.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-27 13:16:59 +02:00
Veijo Pesonen
8c68e01e55 doc: lwm2m: LwM2M Shell
Describes a possible scenario where to use the LwM2M shell
and how to enable it.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-10-27 11:05:05 +02:00
Juha Heiskanen
a66970a6b8 net: lwm2m: Fix connection resume without DTLS
LwM2M connection resume was missing socket connection when
DTLS is disabled.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-27 11:00:46 +02:00
Sam Hurst
c2677cef57 usb-c: Correct spelling error in comment
Correct spelling error in comment

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-27 11:00:14 +02:00
Sam Hurst
cc393f24af usb-c: Fix policy callback function assertion
Fix the assertion check that's performed on a non-existing
callback.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-27 11:00:14 +02:00
Dominik Ermel
9331591ab1 mgmt/mcumgr: Remove buf.c
buf.c have been providing net_buf pool allocator and dealocator
for SMP packets: mcumgr_buf_alloc and mcumgr_buf_free.
The functions have been moved to smp.c and renamed
smp_packet_alloc and smp_packet_free, respectively.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Dominik Ermel
12b1528df9 mgmt/mcumgr: Remove mgmt/mcumgr/buf.h
SMP buffer allocation functions have been moved to smp/smp.h,
and buf.h has been removed.
Definitions of cbor_nb_reader and cbor_nb_writer have also been moved.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Dominik Ermel
6fdf95fbce mgmt/mcumgr: Move and internalize cbor_nb_*_init functions
The commit moves functions used for initialization of CBOR encoding
and decoding to the only unit that is supposed to use them.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Emil Gydesen
326b2fdf15 Bluetooth: Audio: Fix issue with supporting bidir CIS in ASCS
If 2 ASEs shared the same CIS and the first ASE had the CIS
connected before the second ASE was QoS configured, then
the CIS was missing either the TX or RX pointer, causing
it to be considered unidirectional by the ISO layer.

This commit fixes this issue by configuring the (static)
pointers at an earlier time, so that the RX and TX QoS
pointers are always valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-26 12:01:52 +02:00
Marc Lasch
df68307121 net: lwm2m: Rename timer object instance create function
Rename timer object instance create funciton `timer_create` to fix a
name collision regression with a POSIX function in `timer.h`. The issue
was introduced with commit 73a637eda0 when
first including`timer.h` into `lwm2ms.h`.

Signed-off-by: Marc Lasch <mlasch@mailbox.org>
2022-10-26 12:01:27 +02:00
Tommi Kangas
c3ad5efa19 net: lwm2m: use zsock_ functions
Use Zephyr internal zsock_ calls to remove dependency
to NET_SOCKETS_POSIX_NAMES.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2022-10-26 12:01:14 +02:00
Hang Fan
756421b85e Bluetooth: Audio: Fix codec configuration parameter
Fix wrong Codec_Configuration and Codec_Configuration_Length
when setup ISO data path.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-10-26 12:00:38 +02:00
Wojciech Slenska
861f4f81c3 logging: log_backend_fs: added LOG_BACKEND_FS_AUTOSTART configuration
This configuration option gives the possibility to not enable
the fs backend on startup.
Backend can be enabled in runtime using log_backend_init and
log_backend_enable functions.
Implementation is based on log_backend_net.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-10-26 12:00:29 +02:00
Robert Lubos
3bf503085f net: ip: Increase the number of IPv4/IPv6 interfaces with loopback
In case loopback interface is enabled, it's most likely there will be
more than a one network interface if running on real hardware. Therefore
increase the default IPv4/IPv6 interface count to avoid the need to
increase it manually in every test suite.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Krishna T
9b02f91f80 net: wifi: Fix MFP when security type is not given
When security type is not given but instead MFP is given, MFP setting
will be considered as security type, this is because both are optional
and no way to distinguish them easily.

Make security type mandatory for MFP selection, this way we either
assume defaults for both security type and MFP or explicitly ask user
for both. Reword the help text to reflect this.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-26 12:00:11 +02:00
Keith Packard
ced5053e6c subsys/tracing: Use z_current_get in switch_{in,out}
The thread switching tracing hooks are called in the middle of swapping,
before z_thread_entry has a chance to set the z_tls_current value, so they
cannot use k_current_get. Switch them to z_current_get instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-26 12:00:04 +02:00
Mariusz Skamra
2627063ab2 Bluetooth: audio: pacs: Replace capabilities API with pacs
This changes the API to use proper naming convention, as the code has
been moved out of capabilities.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
e635d3aab6 Bluetooth: audio: pacs: Refactor capabilities related code
This simplifies and removes redundant code.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
ce973edbd2 Bluetooth: audio: pacs: Refactor location related code
This simplifies and removes redundant code.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
49f9119c99 Bluetooth: audio: pacs: Refactor context related code
This implifies and removes redundant code.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
2a1cb0acd8 Bluetooth: audio: Fix building and reading PAC Records
This fixes missing checks, and invalid struct bt_pac definition that was
missing one mandatory metadata byte.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
43ffe3cad9 Bluetooth: audio: pacs: Refactor PAC read handler
This makes use of bt_audio_foreach_capability fuction to
simplify building the PAC attribute value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
7c1f6d93dc Bluetooth: audio: pacs: Move capabilities to PACS
There is no point of having dedicated source file that is PACS
dependent. This moves all of the code from capabilities.c to pacs.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
8500eb1335 Bluetooth: audio: pacs: Fix PACS notification
This fixes sending PACS notification with buffer containing invalid,
uninitialized data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Jamie McCrae
7bab5c1b75 mgmt: mcumgr: transport: smp_bt: Fix deadlock on disconnect with data
This fixes an issue with the bluetooth transport whereby if a device
drops the connection prior to receiving all the output data it could
cause a deadlock.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-25 17:37:17 +02:00
Henrik Brix Andersen
f8a88cdb27 drivers: can: use flags fields for can_frame and can_filter structs
The can_frame and can_filter structs support a number of different flags
(standard/extended CAN ID type, Remote Transmission Request, CAN-FD format,
Bit Rate Switch, ...). Each of these flags is represented as a discrete bit
in the given structure.

This design pattern requires every user of these structs to initialize all
of these flags to either 0 or 1, which does not scale well for future flag
additions.

Some of these flags have associated enumerations to be used for assignment,
some do not. CAN drivers and protocols tend to rely on the logical value of
the flag instead of using the enumeration, leading to a very fragile
API. The enumerations are used inconsistently between the can_frame and
can_filter structures, which further complicates the API.

Instead, convert these flags to bitfields with separate flag definitions
for the can_frame and can_filter structures. This API allows for future
extensions without having to revisit existing users of the two
structures. Furthermore, this allows driver to easily check for unsupported
flags in the respective API calls.

As this change leads to the "id_mask" field of the can_filter to be the
only mask present in that structure, rename it to "mask" for simplicity.

Fixes: #50776

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Henrik Brix Andersen
a9c7c58345 canbus: isotp: avoid reusing CAN controller driver API definitions
Avoid reusing the CAN_EXTENDED_IDENTIFIER and CAN_STANDARD_IDENTIFIER
definitions from the CAN controller driver API for ISO-TP structure members
as this is a fragile design.

The ISO-TP layer must be responsible for its own definitions where
needed. Replace the "id_type" ISO-TP struct member with a well-known
abbreviated "ide" bit (Identifier Extension Bit) struct member.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Dominik Ermel
8e0464ef68 mgmt/mcumgr/lib: Remove zephyr_ and _impl_ from function names
The commit removes zephyr_ and _impl_ from function names in image
management group, and renames img_mgmt_impl.* source files to
img_mgmt_priv and merges img_mgmt_priv.h headers.
The zephyr_ and _impl_ have been removed because they no longer make
sense, as the mcugr is internal part of Zephyr, and removal makes
function names shorter.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-25 16:24:18 +02:00
Dominik Ermel
552217cd68 mgmt/mcumgr/lib: Remove stubbed logging calls from img group
The commit removes some leftover code from feature that has been
supposed to log image upload events with use of SMP, but has never
been actually implemented.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-25 16:24:18 +02:00
Sjors Hettinga
14cb6cb419 net: ip: Speed up the IP/UDP/TCP checksum calculation
Instead of doing a 1-complement addition for every 16-bit word, process
32-bit words and handle the 1-complement addition at the end.

This work is a colaboration with Diego Pino García. The algorithm is
inspired by:
https://blogs.igalia.com/dpino/2018/06/14/fast-checksum-computation/

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-10-25 12:46:11 +02:00
Théo Battrel
2d1d309936 Bluetooth: Move out BT_ASSERT of common/log.h
Macro that was defined in the `common/log.h` has been moved to the newly
created `common/assert.h` file.

Files that were using those macro has been updated consequently. Also, the
include of `common/log.h` has been removed of files that were actually not
using any logging methods.

Some `#include "common/log.h"` have been removed. Those were required
before when including `hal/debug.h`. With this change, `hal/debug.h` no
longer has this requirement, because the replacement, `common/assert.h`
includes what it uses.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-10-25 10:48:17 +02:00
Théo Battrel
fdd0a26348 Bluetooth: Remove BT_HEXDUMP_DBG
Replace unnecessary `BT_HEXDUMP_DBG` with `LOG_HEXDUMP_DBG`.

`BT_HEXDUMP_DBG` did an extra cast to `const uint8_t *` on its first
argument. This was probably the reason it was introduced. But the
current definition of `LOG_HEXDUMP_DBG` does this cast for us.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-10-25 10:48:17 +02:00
Ahmed Moheb
b8a957a0eb bluetooth: host: id: Fix copy BT_HCI_OP_VS_READ_STATIC_ADDRS response
Fix copying addresses returned in response to command
BT_HCI_OP_VS_READ_STATIC_ADDRS for reading controller static addresses.
The loop was iterating only over the destination locations while
keeping the source address pointing to the first location of
the command response.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-25 10:03:27 +03:00
Mariusz Skamra
0b825d0ee4 Bluetooth: audio: csis: Fix bt_conn_foreach function parameter
Exclude non-LE connections when sending notifications.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-25 09:53:23 +03:00
Peter Mitsis
6c1e8efa09 ztest: Make cpu hold time configurable
3000 milliseconds may not always be enough time for all 1cpu type
tests to finish on all platforms. Making the CPU hold time
configurable allows for additional flexibility.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-10-24 11:15:00 -04:00
Robert Lubos
caab8cb1b3 net: lwm2m: Don't assume time_t data type size
sizeof(time_t) can vary depending on architecture/libc being in use,
therefore LwM2M should not assume time_t data type size. Instead of
using magic numbers, use a proper sizeof.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-24 16:13:40 +03:00
Emil Gydesen
d5499e6b87 Bluetooth: Audio: Add CAP stream
Add a new stream object, bt_cap_stream, which is an extension
of the BAP bt_audio_stream. The purpose of this stream
is that we can extend the data stored in the BAP stream for
CAP usage, as well as making it more explicit what type
of stream should be used for CAP.

The callbacks will be extended for CAP in specific use cases,
e.g. when starting one or more unicast audio streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
7a1e827a8b Bluetooth: Audio: Make CAP acceptor more explicit
Remove the generic CONFIG_BT_CAP and CONFIG_BT_DEBUG_CAP
and only use Kconfigs specific to the individual roles.

This also includes renaming cap.c to cap_acceptor.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
ce05cb5c2c Bluetooth: Audio: CAP initiator discover CSIS
The CAP initiator will now discover, or return a
known, CSIS instance included by CAS (if any).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
ed11295cf6 Bluetooth: Audio: CSIS client register multiple callbacks
Change the CSIS client callback to a slist so that
multiple applications can register it. An example of
such a case is that both the application and CAP initiator
want to get the callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
2e42105df0 Bluetooth: Audio: CSIS: Refactor CSIS client discover API
The API will now take a simple bt_conn instead of a
set member struct. This is due to the set member struct
being moved to the stack. The reasoning for this is that
having the struct in the stack, rather than in the
application, the stack itself can initiate the CSIS
discovery which is useful if the remote device
has a service that includes a CSIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
ee70dffc6d Bluetooth: Audio: CAP shell implementations
Implements the CAP shell functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
7a49de12af Bluetooth: Audio: Implement CAP initiator discover
This is the primary discovery of the CAS on the remote device,
but does not include discovering the (optional) CSIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
760177b1be Bluetooth: Audio: Add CAP initiator skeleton
Add skeleton for the expected APIs and
implementation. May be subject to change as
implementation progresses.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Juha Heiskanen
4bcc880670 net: lwm2m: LwM2M engine time API update
Updated lwm2m_enigen_set/get_time API for support time_t.

Updated LwM2M engine set/get resource time to time resource support
time_t and uint32_t input.

LwM2M engine put and get time API update to use time_t.

Time series data cache entry have own type for time resource.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-24 10:39:03 +02:00
Juha Heiskanen
e1e2228e9c net: lwm2m: LwM2M object time resource update
Updated Timestamp resource default buffer type to time_t.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-24 10:39:03 +02:00
Emil Gydesen
31bf99cbd2 Bluetooth: ISO: Change ISO seq_num to 16-bit
The sequence number is by the core spec defined as 16-bit.
We had implemented a workaround for the wrapping of the
sequence number, which required the type to be larger
than 16-bit (32-bit).

However, since the definition of the sequence number,
and the use of, is poorly defined by the core spec, we
are reverting this workaround and reducing the sequence
number to 16-bit again. This way it is more in line
with the core spec, as well as more intuitive given the
other uses for the sequence number.

This change moves the responsibility of using the
right value to the upper layers, as the stack can
and will no longer provide any guarantees.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:38:49 +02:00
Sam Hurst
e90f1b66d8 usb-c: Add USB-C Subsystem with Sink PD Support
This USB-C Subsystem enables an application to include
USB-C Power Delivery Sink functionality.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Chris Friedt
d832b04e96 net: sockets: socketpair: do not allow blocking IO in ISR context
Using a socketpair for communication in an ISR is not a great
solution, but the implementation should be robust in that case
as well.

It is not acceptible to block in ISR context, so robustness here
means to return -1 to indicate an error, setting errno to `EAGAIN`
(which is synonymous with `EWOULDBLOCK`).

Fixes #25417

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-10-22 02:30:04 -07:00
Henrik Brix Andersen
c5352e99a1 canbus: isotp: fix size_t format specifier
Fix the format specifier for logging size_t values.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-10-22 14:36:02 +09:00
Ahmed Moheb
92c93ef3c4 bluetooth: host: crypto: Check input arguments with CHECKIF()
Check input arguments passed to APIs with CHECKIF().

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-21 20:30:47 +02:00
Kumar Gala
a1195ae39b smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS
Change for loops of the form:

for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
   ...

to

unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
   ...

We do the call outside of the for loop so that it only happens once,
rather than on every iteration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-21 13:14:58 +02:00
Emil Gydesen
37028ea0d0 Bluetooth: Shell: Add support for advertising appearance
Add support for advertising the appearance value in the
advertising data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-20 17:00:26 +03:00
Emil Gydesen
135bcd339b Bluetooth: Shell: Remove ad_mode_parse
The function did not provide anything that could
not just as easily have been done in the existing
loops.

This just required moving the call to ad_init to
after the param parsing loop.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-20 17:00:26 +03:00
Mariusz Skamra
39dcde2b7e Bluetooth: audio: ascs: Do not store Bluetooth address
The struct bt_ascs holds the conn reference already,
thus it's not needed to store the device address.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-20 15:41:47 +02:00
Krishna T
9d1974ea08 net: ip: mgmt: Log the event ID for dropped events
This helps debug and fix the maximum event size allocation.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-20 15:40:02 +02:00
Krishna T
0ac7c6a32a net: ip: mgmt: Fix the maximum event size calculation
Use a union to capture all big NET event structures with a default size
of 32bytes, this makes maintenance easier.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-20 15:40:02 +02:00
Kumar Gala
fc95ec98dd smp: Convert #if to use CONFIG_MP_MAX_NUM_CPUS
Convert CONFIG_MP_NUM_CPUS to CONFIG_MP_MAX_NUM_CPUS as we work on
phasing out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-20 22:04:10 +09:00
Robert Lubos
6851a33a64 net: dhcpv4: Fix NAK processing in RENEWING state
NAK message should be processed in the RENEWING state just like in
REBINDING, not ignored.

Additinonally, NAK processing should include the rejected IP address
removal from the nework interface, otherwise the IP address will remain
on the interface indefinitely (i. e. until removed manually), which
might disturb further operation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:01:13 +02:00
Robert Lubos
80f71ff2d2 net: dhcpv4: Fix requested IP address overwrite
It could happen, that the requested IP address, stored in the dhcpv4
config structure in the network interface, could get overwritten with an
unexpected message, for example NAK from the DHCP server. In result, the
DHCPv4 module was no longer able to remove the requested address from
the network interface, as it simply no longer remembered what the
address was.

Fix this, by setting the requested address only when it's actually
provided by the DHCP server, i. e. when handling the OFFER message from
the server. Accordingly, the requested address will be cleared when the
SELECTING stage is entered, where all of the cleanups should've already
be done.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:01:13 +02:00
Ahmed Moheb
07e22abb12 bluetooth: host: id: Fix flags updated by bt_id_del()
bt_id_del() was setting the bit 'BT_KEYS_ID_PENDING_ADD' instead
of setting the bit 'BT_KEYS_ID_PENDING_DEL'

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-20 10:00:48 +02:00
Ahmed Moheb
dcfd0220b4 bluetooth: host: id: Increment IDs count only on success
Increment the number of identities after a successful execution
of id_create() by checking if the return value is 0.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-20 10:00:48 +02:00
Ahmed Moheb
0a2388c5be bluetooth: host: id: Check input arguments with CHECKIF()
Check input arguments passed to APIs with CHECKIF().

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-20 10:00:48 +02:00
Robert Lubos
43b057a7b2 net: if: Remove net_if_carrier_down function
The function is no longer used, as its functionality has been replaced
with net_if_carrier_off().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
0ac6fe913e net: virtual: Align virtual L2 with iface status upgrade
Align virtual L2 with interface state handling update. Introduce
net_virtual_enable() function, which gets called whenever a network
interface is brought up (operational). This, combined with already
existing net_virtual_disable() function, can be used to update the
carrier state on the virtual interface, based on the underlying
interface status.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
dd535f611d net: ppp: Align PPP driver/L2 with iface state upgrade
Align PPP drivers/L2 with interface state handling update. Use the
carrier on/off notification instead of bringing the interface up/down to
update the interface state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
942800784c net: netusb: Align netusb driver with iface state upgrade
Align netusb driver with interface state handling update. Instead of
bringing the interface up/down from the driver level, use carrier on/off
notification to update the inteface state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
65db65a6be net: openthread: Align OpenThread L2 with iface state upgrade
Align OpenThread L2 with interface state handling update. Use the
dormant flag to indicate whether an interface joined a Thread network.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
ec243e2553 net: bluetooth: Align Bluetooth L2 with iface state upgrade
Align Bluetooth L2 with interface state handling update. Use the dormant
flag to indicate whether interface has a Bluetooth connection or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
b279bfd2dd net: ethernet: Align Ethernet drivers/L2 with iface state upgrade
Align Ethernet/Wi-Fi drivers/L2 with interface state handling update.

For drivers, that did not support carrier detection, no changes are
needed.

Driver that did support carrier detection, are updated to set the
carrier state to OFF by default, instead of setting the
NET_IF_NO_AUTO_START flag. This allows to postopne the actual
NET_EVENT_IF_UP notification until driver detects that carrier is ready.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
89b32a0f5d net: if: Verify actual interface state instead of admin state on TX
When packet is passed to transmit at the net_if level, verify the
carrier state (NET_IF_LOWER_UP) instead of administrative state
(NET_IF_UP).

The administrative state is checked anyway at higher level (net_context)
so no need to verify it again. This will allow to still transmit control
packets for example when interface is in a dormant state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
efd03a86d7 net: if: Introduce carrier and dormant management on a network iface
Introduce a new interface state management scheme, according to
RFC 2863. This includes the following changes:

* Introduce a new interface flag: NET_IF_LOWER_UP, along with
  corresponding helper functions. The flag should be set/cleared on an
  interface by a network driver/L2 to signalize physical readiness of an
  interface to transmit data (for example cable plugged in).

* Introduce a new interface flag: NET_IF_DORMANT, along with
  corresponding helper functions. The flag should be set on an
  iterface when the interface is not ready to transmit application data,
  for example still not joined a Wi-Fi network.

* Introduce a new interface flag: NET_IF_RUNNING, indicating that
  interface is ready to transmit application data.

* Update the meaning of the NET_IF_UP flag - it now singnalizes whether
  an interface has been brought up/down by the application (admin
  up/down).

* Introduce operational state of an interface, derived from above. It
  reflects the internal interface state.

The meaning of net_if_is_up() function and NET_EVENT_IF_UP/DOWN events
remains unchanged to retain backward compability - they reflect the
interface readiness to transmit application data.

To verify the administrative up/down state, a new function
net_if_is_admin_up() has been introduced, along with
NET_EVENT_IF_ADMIN_UP/DOWN events.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
04fce39e03 net: if: Fix if down handling for all offloaded interfaces
Socket offloading was not taken into consideration when network
interface was put down. Fix this by introducing a helper function, to
verify whether an interface is offloaded or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Aleksander Wasaznik
046f531a6e Bluetooth: Host: Document bt_irk.rpa
Document `bt_irk.rpa` as "Cache for `bt_keys_find_irk`. Not reliable as
"current RPA"!".

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-20 10:17:04 +03:00
Robert Lubos
c27a6af712 net: zperf: Add QoS support
Improve the zperf upload/upload2 commands, by allowing to specify
DSCP/ECP fields for outgoing packets. The introduced -S option is
compatible with Linux iperf3 utility.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
d437f950db net: shell: Allow for ping arguments to be specified in hex
Improve the parse_arg() helper function used with shell ping command,
by allowing to parse arguments provided in hex.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
9e38a3ec48 net: shell: Add support for ping -Q parameter (Quality of Service)
Add new option to the net shell ping command, which allows to specify
the DSCP/ECN values for an outgoing ping request. The option is
compatible with Linux ping command.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
45ce047605 net: icmpv6: Allow to specify DSCP and ECN values in ping
Add support for setting DSCP/ECN values for an outgoing ping request.
Additionally, copy DSCP/ECN values from an incoming ping request into
the ping response, like Linux does.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
38aff54961 net: icmpv4: Allow to specify DSCP and ECN values in ping
Add support for setting DSCP/ECN values for an outgoing ping request.
Additionally, copy DSCP/ECN values from an incoming ping request into
the ping response, like Linux does.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
618fa8d665 net: sockets: Add options to control DSCP/ECN value
Add new socket options IP_TOS and IPV6_TCLASS which allows to set
DSCP/ECN values on a socket for an outgoing packet IPv4/IPv6 headers.

The options are compatible with Linux behaviour, where both DSCP and ECN
are set with a single socket option.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
d28a72ed9e net: sockets: Add missing break statement in setsockopt
SOL_SOCKET and IPPROTO_TCP levels were missing the break statement at
the end of their processing logic, which could cause unexpected
fallthrough on unhandled optname value.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
c868018c3c net: context: Add DSCP/ECN support
Add a new net_context option, which allows to set DSCP/ECN values on a
net context. Those values are then encoded into outgoing packet
IPv4/IPv6 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
c7af28b9af net: ipv6: Add support for setting/reading DSCP/ECN fields (TC)
Encode/decode recently added DSCP/ECN fields into/from IPv6 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
5c10f6f9d6 net: ipv4: Add support for setting/reading DSCP/ECN fields (ToS)
Encode/decode recently added DSCP/ECN values into/from IPv4 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
c5096f4ca1 net: pkt: Add IP DSCP/ECN information to a packet structure
Add new fields to the net_pkt structure, representing IP-specific
Differentiated services code point (DSCP) and Explicit Congestion
Notification (ECN) values. Those values are encoded in legacy
Type of Service (IPv4) and Trafic Class (IPv6) header fields.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Emil Gydesen
4f78655915 Bluetooth: Audio: Add check when registering media_proxy_pl_calls
Add NULL checks when registering the media_proxy_pl_calls.
Currently the media player expects all of them to be set.

In the future, ideally the callbacks would mostly be
optional and reflect which of the optional
characteristics that there is in the MCS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-19 16:05:46 +02:00
Emil Gydesen
e45eff3e10 Bluetooth: Audio: Add missing commands supported callback for MCS
When registering the media player, we were missing a callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-19 16:05:46 +02:00
Pavel Vasilyev
cf701acb94 Bluetooth: Mesh: Convert model_ackd_send and model_send to a common API
Convert model_ackd_send and model_send from health_cli.c to a common API
to get rid of code duplication in other client models that implement
synchronous messages' sending.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-19 16:05:16 +02:00
Øyvind Rønningstad
1e88e7cc9b lwm2m_senml_cbor.patch: Update patch file to match current changes
File created by commiting changes and running

  git diff HEAD~1.. > lwm2m_senml_cbor.patch

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad
8b295bc58c lwm2m_senml: Regenerate cbor code using zcbor
Also do clang-format and apply patch.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad
7b05569d49 lwm2m_senml_cbor_regenerate.sh: Fix argument order in zcbor call
zcbor 0.6.0 has changed the argument order to put code/convert/validate
first.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad
f8d0c8a43f lwm2m_senml_cbor_regenerate.sh: Use git am instead of git apply
Since it's better at resolving conflicts.
Commit regenerated files before applying patch.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Mariusz Skamra
54d1e15b71 Bluetooth: audio: ascs: Make ascs_ep_set_metadata static
This changes ascs_ep_set_metadata to be static as it's not used outside
of ascs.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-19 16:00:33 +02:00
Mariusz Skamra
fc398ac33f Bluetooth: audio: pacs: Fix redundant CCCD attribute without location
This removes the CCCD that was added even if location attribute was not
there.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-19 16:00:21 +02:00
Aleksander Wasaznik
17fc4b811c Bluetooth: Replace 'bt_addr_le_cmp(x) != 0' with 'bt_addr_le_eq(x)'
These should be equivalent. The '_eq'-form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Aleksander Wasaznik
ea558187b5 Bluetooth: Replace bt_addr_le_cmp in bool context with !bt_addr_le_eq
These should be equivalent. The new form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Aleksander Wasaznik
21e5dcb42a Bluetooth: Replace 'bt_addr_le_cmp(x) == 0' with 'bt_addr_le_eq(x)'
These should be equivalent. The '_eq'-form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Aleksander Wasaznik
9db3fa82d1 Bluetooth: Replace all '!bt_addr_le_cmp' with 'bt_addr_le_eq'
There should be functional equivalence between these two forms. And the
'_eq'-form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Mariusz Skamra
9973d2f1f7 Bluetooth: audio: Factor out PACS related API to internal header
This moves the PACS API to internal header, as it duplicates the
bt_capabilities API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-18 14:14:19 +02:00
Tom Burdick
872e3553f9 kernel: Option to assert on spin lock time
Spin locks held for any lengthy duration prevent interrupts and
in a real time system where interrupts drive tasks this can be
problematic. Add an option to assert if a spin lock is held for
a duration longer than the configurable number of microseconds.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-18 14:14:12 +02:00
Emil Gydesen
4321fef3b7 Bluetooth: Audio: Ensure that stream is in streaming state for ISO recv
Adds check to verify that the audio stream is actually
in the streaming state before handling the
audio data. As per the BAP spec, a stream that
is not in the streaming state shall not send
any data, and this check is to handle any
remote devices that are not working correctly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-18 14:13:51 +02:00
Dominik Ermel
7089f94be9 mgmt/mcumgr: Deprecate zephyr_ prefixed API
The zephyr_ prefixed functions have been marked __deprecated.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel
79f105d778 mgmt/mcumgr: Drop zst_ prefix from smp_transport members
With dropping the zephyr_ prefix, the member prefix zst_ makes
no sense.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel
71e498dbd2 mgmt/mcumgr: Rename zst pointers to smp_transport to smpt
Cosmetic change: the zst was short for zephyr_smp_transport,
now it is just smp_transport so smpt makes more sense.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel
a7e40b35f0 mgmt/mcumgr: Drop zephyr_ prefix from functions
The MCUMgr library is now part of Zephyr, so there is no point
to prefix SMP functions with Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Veijo Pesonen
33453e1135 lwm2m: fails if incorrect registration reply
No need to proceed if registration reply parsing fails.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-10-17 20:06:32 +02:00
Florian Grandel
b674ed6b8b net: pkt: decouple from ieee802154 internals
This change implements part two of the program laid out in the TSCH RFC,
see #50336#issuecomment-1250250154 :

> Consolidate IEEE 802.15.4 options in net_pkt

This change improves decoupling of generic net core code from
IEEE 802.15.4 internals. It also simplifies IEEE 802.15.4
attribute cloning and thereby makes it easier to maintain and less
error prone (and probably even faster as individual bits are no longer
copied over separately).

This enables us to extend and design IEEE 802.15.4 L2 attributes inside
the package in isolation from the net core code which will no longer
have to be changed when introducing changes or additions to the flags.

This flexibility will be built upon in later change sets to model the
IEEE 802.15.4 attributes closer to the spec.

The solution is inspired by Linux's sk_buff->cb attribute which addresses
the same concern as the attribute introduced in this change set:
https://elixir.bootlin.com/linux/v6.0.1/source/include/linux/skbuff.h#L871

As the inline comment says: The cb attribute can be made a union or even a
uint8[something] in the future, if further L2s need a control block, too.
Right now such full indirection would make the code overly abstract, so
I chose to compromise with maintainability in mind.

Care has been taken to ensure that this changes does not introduce
additional padding into the net package. To maintain zero-padding, future
changes to the net packet struct will have to ensure that the
IEEE 802.15.4 struct is 4-byte aligned (iff the IEEE 802.15.4 struct
continues with max uint32_t scalar members) which is no deviation from
the previous implementation.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel
0b94947d33 net: l2: ieee802154: set ll protocol in pkt
The IEEE 802.15.4 L2 now sets the ll protocol in the packet to a
specific value. This corresponds to the respective solution in Linux and
is required to validate access to IEEE 802.15.4 specific attributes of
the packet.

Later change sets will rely on this value to ensure that IEEE 802.15.4
specific package content can only be accessed on IEEE 802.15.4 packages.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel
389bd57753 net: ip: fix and consolidate cloning of ll addr
The net packet structure contains pointers to link-layer source and
destination addresses. Usually, these structures do not point to
separately allocated memory but directly into the packet's data buffer.

In case of a deep package clone (which includes copying the buffer) the
copy of the ll addresses continued to point into the old package
(contrary to a rather misleading inline comment). This was proven by an
additional failing unit test assertion.

As the original package may be unreferenced while the cloned package is
still being accessed, the ll address pointers of the cloned package may
become invalid.

The fix consists of two parts:
 * First it is determined whether a given ll address actually points into
   the buffer and if so at which logical cursor offset it is located.
 * If the address points into the package buffer then the cursor API is
   used to determine the corresponding physical memory location in the
   cloned package. The ll address of the cloned package is then patched
   to point to the cloned buffer.

Additional assertions were introduced to the existing unit test to ensure
that the newly generated address points to the correct content of the
cloned package.

The solution is implemented in a generic way so that the previously
redundant implementations were consolidated into a single one. The code
includes a check that ensures that the ll address check and manipulation
will be skipped in case of shallow package copies.

The change also addresses problems related to the "overwrite" flag of the
package:
 * Package cloning assumes the overwrite flag to be set. Otherwise it
   will not work correctly. This was not ensured inside the clone method.
 * Package cloning manipulates the overwrite flag of the cloned package
   but does not reset it to represent the same state as the original
   package.

The change introduces a fix and unit test assertions for both problems.

Fixes: #51265

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel
f1e9dd2930 drivers: ieee802154: properly announce promisc mode
Most IEEE 802.15.4 drivers do not support promiscuous mode, some do.
There is a dedicated L2 flag to signal this capability to clients.

Unfortunately the IEEE 802.15.4 L2 stack does not announce this flag
even for drivers that correctly expose it in their HW capabilities.
Some clients (notably the OpenThread L2) even uses promiscuous mode
without checking whether the driver actually supports it.

This change lets the vanilla IEEE 802.15.4 L2 check the driver's
HW capabilities to announce promiscuous mode on its 'get_flags()'
interface if supported.

The OpenThread L2 uses a constant (potentially incorrect) response
to 'get_flags()'. Fixing the OpenThread L2 is out of scope of this
change. This change just introduces TODO messages to the OpenThread code
so that the OpenThread team may fix the issue (or delete the TODO if they
deem it irrelevant).

Fixes: #51263

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Gerard Marull-Paretas
178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Emil Obalski
45f0fb1970 ipc: Add deregister API support for icmsg backend
Add support for deregister_endpoint IPC service API
in icmsg backend.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2022-10-17 14:49:42 +02:00
Pavel Vasilyev
93e6f73d62 Bluetooth: Mesh: Change linkage for ctx_shell and default_key in shell
Change linkage for ctx_shell and default_key in shell.c to external to
share their usage in other places.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
73c5568b5c Bluetooth: Mesh: Remove _cli postfix from models shell files
This commits renames `health_cli.c` and `cfg_cli.c` under `mesh/shell`
folder to `health.c` and `cfg.c` accordingly. This is to create a
generic pattern for the future, when not only clients, but server models
will also expose some API through shell commands. This means that server
models' shell commands should be located in the same file as client
commands to avoid cluttering `mesh models` subcommand.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
f93ab2769c Bluetooth: Mesh: Add macro for instance set/get-all mesh shell cmds
This code is a boulerplate that will be needed for many models in mesh
shell module. This commit adds a special macro designed to improve
readability of the code and helps to avoid potential bugs when
copy-pasting identical code.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
8e5ff49118 Bluetooth: Mesh: Make mesh features pluggable in shell
Not all shell commands may be needed for an end application even if a
certain feature is enabled. In that case they will just occupy flash
space without being used. This commit adds a separate Kconfig for each
feature to make possible to selectively disable some mesh shell commands.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
559e526708 Bluetooth: Mesh: Add options to disable health and cfg clients shell
Add Kconfig options to be able to disable Health and Config Client
models shell commands.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
f9c4872ce4 Bluetooth: Mesh: Move mesh shell Kconfig options to a separate file
Move mesh shell related options to a new file to avoid cluttering of
the main Bluetooth Mesh Kconfig file when extending it with new options.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Francois Ramu
f37ebf48ec include: add missing kernel.h for lorawan subsys
Header lora.h and lorawan.c files make use of types defined
in kernel.h without including it.
The types.h is no more relevant with inclusion of kernel.h
Explicitely including <stdint.h>, even if the kernel.h includes
the stdint.h, this is an implementation detail. "If Kernel
decides one day to drop usage of stdint.h (unlikely),
lora.h users be in trouble."

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-10-17 18:10:10 +09:00
Krzysztof Chruscinski
af573dbffb logging: Add ipc_service log link
Added link that sends messages over ipc_service. It uses
log_link_remote and will talk to log_backend_ipc_service based
on log_link_backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
b01867812e logging: Add ipc_service log backend
Added backend that sends messages over ipc_service. It uses
log_backend_remote and will talk to log_link_ipc_service based
on log_link_remote.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
6c785b5677 logging: Add remote link and backend
Added implementation of link and backend that are intended to
complement each other. Both requires transport function hooks
to be provided.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
050378ab39 logging: log_output: Adapt to multidomain support
Add support to multidomain case where source field contains
ID and not address of the source structure.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
e322447109 logging: Initial multidomain support
Adding multidomain support by introducing log_link module which
acts as a receiver of log messages created by another domain.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
1b3a12ce8e logging: Add log_cache module for caching remote names
log_cache is capable of storing fixed length byte arrays
identified by a generic ID. If entry identified by given ID
is not found in cache, the least recently used entry is evicted
from cache.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Sean Madigan
5b1dd71f3e Bluetooth: kconfig: Add config options for PAST
Add config options specific for periodic advertising sync transfer.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-10-17 10:14:10 +02:00
Andy Ross
45ea83af89 subsys/cmsis_v*: Fix racy mutex testing, decouple from k_mutex
The cmsis implementations of osMutex was trying to inspect internal
k_mutex state (the owner and lock count) in the process of trying to
acquire the lock.  This is unfixably racy, by definition other
contexts will be trying to do the same on the unsynchronized data.

As far as I can tell, the only purpose was to be able to synthesize
osMutex's specified error behavior, which we can do with the existing
return codes from k_mutex_lock().  Add similar logic to osSemaphore,
which didn't have the race but was likewise abusing access to kernel
internals.

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Andy Ross
13f78fb005 bluetooth: Don't use k_sem internals
The "limit" field of struct k_sem was in use in two places in the BTLE
host code, in one it was being used as a duplicate placeholder for the
"iso_max_num" field received in read_buffer_size_v2_complete[1].  In
another, it was just being tested for zero[2].

Those are pretty clear abuses of internal data, provide minimal value
beyond a few bytes of memory in struct bt_dev_le, and in any case
won't work with zync, where that field doesn't have the same name and
may not even exist depending on app configuration.

Copy the limit value into the struct where it belongs, and use it from
there.

[1] I strongly suspect there is a bug lurking there if the semaphore
maximum is being used to implement the kind of "packet buffer" this
code looks like.  Calling k_sem_give() on a "full" semaphore WILL NOT
BLOCK.  It will just drop the increment on the floor and return
synchronously.  Semaphores aren't msgqs or ringbuffers!  But disabling
the max value feature in zync does not result in test failures, so
maybe this usage is safe.

[2] Again, this seems suspicious; a valid k_sem should never have a
zero in that field.  Presumably this is really a test for "is
initialized", and so implies there's a mixed up initialization path
somewhere?

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Andy Ross
bd063d1a9e net/ethernet/bridge: Fix k_mutex initialization
The bridge subsystem was written with a ETH_BRIDGE_INITIALIZER that
assumed it could initialize a k_mutex with a zero-filled initializer.
That never worked.  Unlike semaphores, mutexes have always required a
runtime call to k_mutex_init().  What happened instead is that
k_mutex_un/lock() returned error codes, which were ignored by the code
here.  So no locking was happening.

This was discovered while migrating to zync, where an attempt to
unlock an unlocked mutex is a panic condition (and where zero-filled
initializers are legal, but represent an unfair semaphore and not a
mutex, so deadlock correctly).

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Andy Ross
95101e6890 net/route: Add missing lock in net_route_mcast_add()
This is a public API for the subsystem, can be called from app
context, unlocks the local k_mutex on one of its three exit paths, and
it's quite clear that nothing ever locks that mutex!

The code used to work because k_mutex simply returned an error if you
tried to unlock an unlocked object.  Now zync will panic (when
CONFIG_ZYNC_VALIDATE=y) if you try that.

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Piotr Pryga
6a79c3deae Bluetooh: Host: conn: Resume adv after disconn for periph role only
Zephyrs Host has by default enabled automatic resume of advertising
in case of disconnection when peripheral role is enabled.

The feature becomes a bit problematic in case of multirole usage.
For example assume a use case where a device is working as peripheral
and central, where it may establish single connection for each role.

In case there are two connections established and connection in
central role is dropped by peer, Host will automatically resume
advertising. After that an application can resume scanning, e.g.
in disconnected callback. That should not happen.

If one of connections was used for central role, it should not
be stolen by Host to run peripheral role. Host should verify
if a disconnected connection role was peripheral and then resume
advertising.

This approach will not break backward compatibility and change
correct resume behavior. What more, Host will follow an application
decisions about use of connection objects.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-17 10:06:45 +02:00
Kumar Gala
c778eb2a56 smp: Move arrays to use CONFIG_MP_MAX_NUM_CPUS
Move to use CONFIG_MP_MAX_NUM_CPUS for array size declarations instead
of CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-17 14:40:12 +09:00
Emil Gydesen
0af4aad4bf Bluetooth: Audio: Remove call to bt_enable in audio init
The `audio init` should only initialize the audio (BAP)
stack. Furthermore, given that the `bt init` may do more
than just calling `bt_enable` it is generally for the best,
and more future proof, to let that command be the exclusive
way of calling `bt_enable` in the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 14:24:20 +02:00
Emil Gydesen
e4b640ff2b Bluetooth: Audio: Fix segmentation issue in BT Audio shell
It was possible to enter a state where setting the QoS
for a source stream after having released a sink stream
as the unicast client would cause a segmentation error.
This issue is related to how the unicast shell is using
the unicast group.

A fix has been added for it, and a check for
whether or not `audio init` (to register the needed
callback) has been added. This check has also been added
for the broadcast sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 14:24:20 +02:00
Jukka Rissanen
cf24ebcc1f net: dns: Always init the resolver
If user has not specified any DNS servers in
CONFIG_DNS_SERVER_IP_ADDRESSES, then the DNS resolver will not be
initialized properly. So fix this by always calling dns_resolve_init()
so that DNS mutex get properly initialized.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2022-10-14 09:57:09 +02:00
Troels Nilsson
06aa981611 Bluetooth: controller: Support split advertising PDU pools
Adds proper support for having more than one PDU pool for the advertising
PDUs (to save memory)

- Introduces lll_adv_aux_data_init, lll_adv_aux_scan_rsp_alloc and
  lll_adv_sync_data_init to indicate if the PDU is a primary/legacy PDU
  or secondary/auxillary PDU
- Scan response PDUs are initialized later, since the correct pool to draw
  from depends on whether the advertising is extended or legacy

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-10-14 09:56:00 +02:00
Gerard Marull-Paretas
eda9689789 shell: device_service: add missing EARLY init level
The device_service shell was missing the capability to list devices
registered in the EARLY init level.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-14 09:55:48 +02:00
Kim Sekkelund
a83b4f9d06 Bluetooth: Audio: Fix endian conversion in PACS
Not all C compilers understands how to use the address of a return
value as an argument to a function call. At least not our compiler.
Fix the issue by adding a variable to hold the converted value
before passing it to the function call.

Signed-off-by: Kim Sekkelund <ksek@oticon.com>
2022-10-14 09:55:26 +02:00
Gaël PORTAY
6dedea7c16 wifi: shell: Move closing bracket after type enumeration
This fixes the output below by moving the closing bracket to "<Security
type (optional: valid only for secure SSIDs)>" after the enumeration of
security types "0:None, 1:PSK, 2:PSK-256, 3:SAE".

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP
	               "<SSID>"
	               <channel number (optional), 0 means all>
	               <PSK (optional: valid only for secure SSIDs)>
	               <Security type (optional: valid only for secure SSIDs)>
	                                              v----------------------^
	               0:None, 1:PSK, 2:PSK-256, 3:SAE
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
f7dfae5730 wifi: shell: Indent second parameter to new line
Return to line after the first parameter to:
- have the second parameter in a single line (not splitted) and
- start every parameters from a brand new line (easier to read)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
ff077aafe9 wifi: shell: Add missing bracket
This fixes the output below by adding the missing closing bracket to
"<MFP (optional): 0:Disable, 1:Optional, 2:Required":

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP
	               "<SSID>"
	               <channel number (optional), 0 means all>
	               <PSK (optional: valid only for secure SSIDs)>
	               <Security type (optional: valid only for secure SSIDs)>
	               0:None, 1:PSK, 2:PSK-256, 3:SAE
	               <MFP (optional): 0:Disable, 1:Optional, 2:Required
	               ^-------------------------------------------------^
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
b177911a4d wifi: shell: Add missing end of line
This fixes the output below by returning to line after "Connect to a
Wi-Fi AP":

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP"<SSID>"
	                                    ^------^
	               <channel number (optional), 0 means all>
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Emil Gydesen
23562448dc Bluetooth: Audio: Fix reset PAC records on bt_audio_discover
When calling bt_audio_discover, the discovered PAC records
were just added to the pac_cache. If called multiple times,
the PAC records would just be duplicated.

This change reset the pac records for the direction when
called.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:57 +02:00
Emil Gydesen
f307c08331 Bluetooth: Audio: Add additional check and log for stream->conn
bt_audio_stream_config should not be called with a stream
that is already configured to another connection.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:43 +02:00
Emil Gydesen
bd773158e1 Bluetooth: PACS: Add PAC records to the debug log
Logs the PAC records with BT_DBG for easier debugging
of the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:36 +02:00
Emil Gydesen
59a9dd6054 Bluetooth: Audio: Add misisng stream_count reset for broadcast sink
This caused the sink to attempt to sync to more stream
for each call to bt_audio_broadcast_sink_sync as the
stream count was stored in the struct bt_audio_broadcast_sink
but never reset.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:23 +02:00
Emil Gydesen
65f130b73e Bluetooth: Audio: add missing CONFIG_BT_AUDIO_DEBUG_STREAM_DATA guards
Some places did not properly guard debug messages for sending
ISO data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:11 +02:00
Emil Gydesen
0f30fbec96 Bluetooth: Audio: Increase unicast client Kconfig ranges
There is no reason for the previous limitation.

The limit of 255 for the ASEs is based on the ASE IDs
which is a uint8_t, so there is a maximum of 255 of
each ASE type.

The limit of 73 * 2 = 146 is based on the maximum size of an
GATT attribute (512), and the minimum size of a PAC record (7)
makes it a total of 73 PAC records for each direction.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:52:56 +02:00
Andries Kruithof
eb78f9f808 Bluetooth: controller: llcp: fix access to context after release
There is access to the procedure context after a potential release
of the context, which (in theory) can lead to incorrect behaviour

There is no good way of testing this with a unittest without adding
specal debug code to the ull_llcp_local module
After code-inspection no other location has been found with
potential access after context release

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-10-14 09:52:41 +02:00
Emil Gydesen
7ab1cafbc2 Bluetooth: Audio: Add Broadcast source application AD
This refactors how the BAP broadcast source handles the
extended and periodic advertising.

First it removes the start and stop of the extended
advertising, and instead expects the application
(or upper layers) to do this.

Second it exposes API functions to get the
necessary advertising data from BAP (service data and
the BASE), which the upper layers will then also
be responsible for setting and updating.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:51:39 +02:00
Emil Gydesen
cb4541ae51 Bluetooth: Audio: Fix missing metadata_updated calls
The metadataa_updated callback has existed for a long
time, but was never actually used. The metadata is set
or updated in the enabling and streaming state.

Added checks to see if the state actually changes when going
into these states, and if not, then it means that the
metadata was updated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:51:23 +02:00
Andreas Müller
b0e76dbf35 net: shell: fix memory leak in udp_rcvd()
Without pkt_unref(), the shell command "net udp bind" will fail to
receive after a few packets ("net allocs" shows that memory is still
allocated).

Signed-off-by: Andreas Müller <andreas.mueller@husqvarnagroup.com>
2022-10-13 17:10:28 +02:00
Mariusz Skamra
d44e112045 Bluetooth: audio: ascs: Remove unused bt_ascs member
Remove unused struct member.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-13 16:03:34 +02:00
Andrei Emeltchenko
ab2594e313 shell: devmem: Update help string for devmem
Update help string to make it more clear.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-10-13 08:00:52 -04:00
Andrei Emeltchenko
1ff34e234c shell: devmem: Fix help for devmem module
Fixes devmem help string shown below:

uart:~$ devmem -h
devmem - Read/write physical memory"devmem address [width [value]]

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-10-13 08:00:52 -04:00
Yuval Peress
4f75848e71 ztest: fix grammar for errors in bad test phases
Addresses the comments in #48846 regarding the error messages

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-13 06:40:31 -04:00
Yuval Peress
a40a2f5c50 ztest: make failed assumptions fail test binary
Adding the new Kconfig (enabled by default) to make a failed assumption
mark the final result as failed. This change has the following benefits
which have been asked for by the Zephyr community:
1. A failed assumption does not go silent. In this example, the failed
   assumption will still mark the test as skipped, but the final result
   will be to mark the full test run as failed. This would allow
   blocking the CI when an assume fails.
2. Normal test skipping via the ztest_test_skip() is unaffected by this
   change. Those tests will be marked as skipped, but the binary will
   still pass.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-13 06:40:31 -04:00
Emil Gydesen
0dc9f57fa5 Bluetooth: Audio: Fix bad error check for bt_unicast_client_start
If bt_audio_stream_connect didn't fail, we would just return
without sending the receive start ready command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-13 09:57:24 +02:00
Lingao Meng
4a2033a661 Bluetooth: Mesh: net cache uses reverse order traversal
Since the net cache is accumulated in positive order, the net
cache uses reverse order traversal, which can filter duplicate
messages more effectively.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-13 09:56:50 +02:00
Lingao Meng
5867492582 Bluetooth: Mesh: Fix missing clear dup cache
When lpn reject message, should clear dup cache to
avoid dup check next mesh message.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-13 09:56:50 +02:00
Lingao Meng
4f1e326f2a Bluetooth: Mesh: Remove msg_cache_next in rx ctx
Since in bt_mesh_net_recv will call msg_cache_add
and if lpn reject this message, should remove this cache.

But this function sequentially and will not be interrupt
by any thread so, we no need a copy var to save this value.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-13 09:56:50 +02:00
Peter Tönz
46a59124dc net: lwm2m: Fix seg-faults if a socket was closed in the meantime
Our application (posix-naive/debug) ran into segmentaion faults,
because the socket was closed between the "wait for sockets" and the
second if in the first loop. Added the check also to line 690
and 720.
The other uses of sock_ctx[i] are already checked against NULL

Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
2022-10-12 18:42:41 +02:00
Piotr Pryga
c2ea0328fa Bluetooth: Controller: df: Fix spelling errors
Fix spelling errors in coments in ull_df.c source file.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-12 18:41:54 +02:00
Piotr Pryga
3987259888 Bluetooth: Controller: df: Relax cl CTE RX enable param check
According to Core 5.3 Vol 4, Part E, section 7.8.82 slot_durations,
switch_pattern_len and ant_ids are used only for AoA and do not affect
reception of AoD CTE.

To improve interoperability checking of correctness of these parameters
is not required. It will not affect lower link layer in case the AoA
CTE reception feature is not enabled in Kconfig.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-12 18:41:54 +02:00
Mariusz Skamra
9c3f190721 Bluetooth: audio: capabilities: Hide bt_audio_capability_get function
This function exposes list pointer, so that it allows the user to modify
the internal list. This adds bt_audio_foreach_capability iterator finction
that can be used instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-12 18:41:22 +02:00
Florian Grandel
580d789cd0 net: l2: ieee802154: fix frame type field check
The LLDN frame has been obsoleted in IEEE 802.15.4-2015f. This change
removes it from the code, introduces frame types from current spec
levels and updates the frame validation rules in accordance with the
spec.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
14c608e9c4 net: l2: ieee802154: improved context thread safety
Several attributes in the ieee802154_context struct may potentially be
accessed from different threads and/or ISR context. Only some of these
attributes were properly guarded against race conditions.

This may not have been to problematic in the past but as other changes
in this PR introduce additional attributes and mutate several attributes
in a single atomic transaction, leaving such changes unprotected seems
dangerous.

This change therefore introduces systematic locking of the
ieee802154_context structure.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
6a6b89516d net: l2: ieee802154: improve short address support
IEEE 802.15.4 short address support is incomplete in several places.
This change improves short address support without claiming to fix
it everywhere. Future iterations will have to continue where this change
leaves off.

The purpose of this change was to:
 * use the short address returned by association responses,
 * automatically bind IEEE 802.15.4 datagram sockets to the short
   address if available,
 * use the short address in outgoing packages where applicable,
 * improve validation of association/disassociation frames,
 * model association more closely to the spec by tying it to the
   existence of a short address in the MAC PIB thereby removing
   redundancy in the PIB (which makes race conditions less probable),
 * keep both, the short and extended addresses, of the coordinator.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
bff6a5cce5 net: l2: ieee802154: fix short/ext address endianness
This changes fixes several bugs and inconsistencies in the IEEE 802.15.4
L2 implementation. These bugs were revealed while documenting intended
endianness of driver, IP, socket and L2 attributes (see previous
changes).

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
b951f062f5 net: l2: ieee802154: add short address to ll address
This is a preparatory change that fixes one aspect of short address
handling before fixing endianness so that the endianness fix can be
applied consistently in this method.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
34999a8b3e net: l2: ieee802154: document endianness
The IEEE 802.15.4 L2 code stores representation of attributes like
PAN id, short address and extended address in different encodings:

* big endian for extended address and CPU byte order for everything
  else whenever such attributes enter user space (except for IP/socket
  link layer addresses which are always big endian - even in case of
  short addresses - to maintain POSIX compatibility).

* little endian for everything that is close to the radio driver as
  IEEE 802.15.4 frames are little endian encoded.

Endianness was almost nowhere documented which led to several bugs and
inconsistencies where assignments of different byte order were not
converted (or sometimes converted, sometimes not).

This change documents endianness wherever possible within the realm of
the IEEE 802.15.4 L2 code. Conversion bugs and inconsistencies that were
revealed by the improved documentation will be fixed in a separate
commit.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
7ea6cc99ce net: ip: fix minor formatting glitch
This changes just fixes an erroneous indentation from a previous patch.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Christopher Friedt
dbe2c0d59e include: net: http: rename http_x.h http/x.h
Some minor housekeeping prior to adding an http server
implementation. There are already a number of http headers
and that number will likely increase with subsequent work.
Moving them into a common directory cleans up the
`include/net` directory a bit.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2022-10-12 09:02:21 -04:00
Gerard Marull-Paretas
e5eade32e2 shell: device_service: fix MISRA 5.7 violation
Changes in device_service have triggered MISRA 5.7 violation CI error
(Tag name should be unique). Renamed shell to sh, same as some other
modules.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas
495245a971 init: remove _SYS_INIT_LEVEL* definitions
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Dominik Ermel
3d367ae8b4 mgmt/mcumgr: Remove MGMT_MAX_MTU from mgmt.h
Not used anywhere, MTU depends on transport.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-12 18:48:25 +09:00
Andrzej Głąbek
6ae66cc13d net: pkt: Allow compilation with custom IEEE 802.15.4 based L2
This is a follow up to commit bb86f8b967.

Also custom IEEE 802.15.4 based L2 implementations may need to use
packet handling without the IP layer. Add support for such cases.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-10-12 18:46:09 +09:00
Peter Tönz
a868da8568 net: lwm2m: Fix buffer overflow by using CONFIG_LWM2M_VERSION_1_0
By using CONFIG_LWM2M_VERSION_1_0, the function
lwm2m_engine_get_binding() returns the binding
and the queue mode bytes. Therefore the buffer
must be tree bytes long.
The issue is caused by the two inconsistent defines:

lwm2m_registry.c:
    #define BINDING_OPT_MAX_LEN 3 /* "UQ" */
lwm2m_rd_client.c:
    #define CLIENT_BINDING_LEN sizeof("U")

Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
2022-10-12 18:45:50 +09:00
Henrik Brix Andersen
b219b5cba7 stats: shell: enable the stats shell if both stats and shell are enabled
Enable the statistics subsystem shell by default if both statistics and
shell are enabled.

Have the statistics shell imply enabling named statistics as this takes out
a lot of guesswork regarding which statistics counter is which.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-12 06:46:34 +02:00
Gerard Marull-Paretas
b959ab25a9 include: add missing sys/slist.h include
Some headers makes use of slists w/o including sys/slist.h

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
3976ccd5f7 include: add missing sys/printk.h include
Some files were using the printk API without including sys/printk.h

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
e63b0bb3fe include: add missing errno.h include
With the incoming removal of kernel.h/types.h from init.h, lots of files
start to show compile errors because they relied on indirect
definitions, including errno.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
34a6848887 include: add missing arch/cpu.h include
The sys* ops like sys_clear_bit are indirectly included via arch CPU
header. Other stuff like find_msb_set end up included via this header as
well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Anas Nashif
46af0620b3 console: move winstream console to drivers/
This was all done as part of the soc and called from the soc. Define
this type of console under drivers/console and use it in the SoCs
supporting that via SYS_INIT instead of calling the console code
directly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 08:28:25 -04:00
Jamie McCrae
cfd657fcec mgmt: mcumgr: Add fs_mgmt log output workaround on file write
If a file write was attempted with a file that does not exist, over
the shell/UART when logging was enabled, it would output a fs_unlink
error, this works around the issue by checking if the file exists and
needs truncating before performing that action. It also imrproves
flash endurance slightly by performing a truncate operation instead
of a delete, but will fall back to a delete if the truncation
operation fails. This issue can be also be mitigated by altering
logging settings or adjusting the SMP thread priority.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-11 11:15:02 +02:00
Seppo Takalo
d454cc946e net: lwm2m: Add helper macro for filling lwm2m_obj_path structs
Allows filling up struct lwm2m_obj_path by a macro.
For example:
  struct lwm2m_obj_path p1 = LWM2M_OBJ(MY_OBJ);
  struct lwm2m_obj_path p2 = LWM2M_OBJ(MY_OBJ, 0, RESOURCE);

Similarly, some function calls accept the structure, so it can
be initialized from stack and given by a pointer
  lwm2m_notify_observer_path(&LWM2M_OBJ(obj_id, 0, RESOURCE_ID));

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:14:31 +02:00
Dominik Ermel
c759eb0a93 mgmt/mcumgr: Remove net_buf_pool_get call from zephyr_smp_alloc_rsp
It was pointless and nothing has been done with a result.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-11 11:14:22 +02:00
Seppo Takalo
65c084f9e5 net: lwm2m: Don't close the socket context on callbacks
I need to register a service for the pull-context so I can
safely close the socket context. Otherwise the socket loop
would crash, because context would be closed while going through
the list where it was located.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
d49219aede net: lwm2m: Block on semaphose waiting
Minor change, the semaphore is freed by a caller so it was always
free, but just for being correct, it should be a blocking call,
so any errors would clearly block.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
b72fde1f54 net: lwm2m: Remove second layer or rettrying from pull handler
CoAP layer handles retrying so having a second layer of retry
in the pull-context does not make sense. If we need more retrying
it should be done in CoAP layer.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
4ec698004c net: lwm2m: Set FOTA state correctly on URI write
When URI is written, we must first set the state to DOWNLOADING
so when any error happens on the initialization phase, the
result written on a callbacks are correctly reflected and the state
changes correctly IDLE -> DOWNLOADING -> IDLE (result written).

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
99ebcefc71 net: lib: lwm2m: Add shell commands for lock and unlock
Allowing locking the registry from commandline allows
us to test composite observation and observation of
object instances, etc. where multiple values are changed
before the notify message triggers.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:12:20 +02:00
Daniel Leung
90456c94f7 logging: workaround hard fault on Cortex-M0 with sys-t/catalog.
For some reason, running sys-t with catalog message on
Cortex-M0 would result in hard fault in mipi_catalog_formatter()
if log_output_syst.c is complied before the backends (and weird
enough, only with SIZE optimization). This new ordering was
introduced in commit f5587552bb
as it was to group all backend source files under a single
directory.

Workaround the issue by compiling file later after backends
as this issue is causing CI failures. Actual root-cause is TBD.

Relates #50941

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-10-10 18:02:08 +02:00
Troels Nilsson
28a9a79b98 Bluetooth: Controller: JIT fixes for ext. adv. duration handling
- Account for the added random delay when updating remaining duration
- Re-worked JIT re-scheduling update a bit to keep the random delay
  information and remaining duration correct

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-10-10 13:55:37 +02:00
Troels Nilsson
b6f5c75581 Bluetooth: Controller: Ext. adv. duration handling fix
- Remaining duration is now in us instead of ticks to avoid
  overflow when ticks have higher resolution
- First advertising event should not reduce remain duration

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-10-10 13:55:37 +02:00
Troels Nilsson
2a9cd8ffb1 Bluetooth: Controller: Add EVENT_OVERHEAD_START_US when enabling states
Add EVENT_OVERHEAD_START_US to ticks_anchor when enabling
advertising, so the first advertising event is not late due
to calculations for aux packets etc.

Signed-off-by: Troels Nilsson <trnn@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
236d0351e7 Bluetooth: Controller: EVENT_OVERHEAD_START_US for typical usecases
Tune the EVENT_OVERHEAD_START_US for typical usecases on
nRF52833 SoC using the central_gatt_write and
peripheral_gatt_write samples.

Manually run the samples for over 30 mins without any
assertions and use the actual profiled value that would
otherwise be printed on assertion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
a3b0ade9c6 Bluetooth: Controller: Explicit ticker worker trigger on expire in past
When ticks_to_expire is in the past, i.e. ticks_to_expire is
0, perform an explicit trigger of ticker worker instead of
setting up the compare which delays the trigger by the
minimum ticks offset margin. The changes reduce latencies
of the O(n) ticker_resolve_collision by upto the minimum
ticks offset margin (3 for nRF SoCs) for each resolution.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
ebf7236267 Bluetooth: Controller: Add verbose assertion on delayed prepare
When an event's prepare is delayed due to ULL scheduling or
ISR latencies, check and have a verbose assertion that logs
the actual EVENT_OVERHEAD_START_US required.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
7715fb40e2 Bluetooth: Controller: Add LL_ASSERT_MSG definition
Add LL_ASSERT_MSG definition to log a verbose message as
part of assertion check.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Krzysztof Chruscinski
02664dbc91 logging: Use cbprintf flags for log_printk
Use cbprintf flags also when creating log message for printk entry.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-08 18:32:57 +02:00
Krzysztof Chruscinski
dc9c5fca4f logging: Add option LOG_MSG_APPEND_RO_STRING_LOC
Bring back Kconfig option which was previously removed by
9cd5086407 (previously named LOG_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS).
Renamed to shorten and be more descriptive. It can be useful for
external backends or frontends.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-08 18:32:57 +02:00
Juha Ylinen
c8a409d7d3 net: lwm2m: Use const data pointers in lwm2m_engine_set functions
lwm2m_engine_set functions use void data pointers. Change those to
to const void

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2022-10-07 16:43:51 +00:00
Robert Lubos
b76c35d809 modules: mbedtls: Replace select statement with depends on for EC
Instead of using "select" on certain EC configurations, which is
considered unsafe for various reasons, use a "depends on" and rely on
the user to set a proper configuration in the config file.

Update the respective project configurations to comply with the new
configuration scheme.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-07 15:12:42 +02:00
Vinayak Kariappa Chettimada
367004fd57 Bluetooth: Controller: Conditional compile optional ticker interfaces
Conditional compile ticker interfaces like ticker_update
which are not required when individual state or role samples
are build.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-07 14:46:38 +02:00