Commit graph

18898 commits

Author SHA1 Message Date
Martin Jäger
a4c13fc584 lorawan: services: add Class C session handling
The new functions are required for Multicast Class C session setup.

Signed-off-by: Martin Jäger <martin@libre.solar>
2024-01-30 14:14:05 +00:00
Øyvind Rønningstad
3ad47d214a lwm2m: Regenerate zcbor files
with zcbor 0.8.1

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-30 13:38:51 +01:00
Emil Gydesen
515ef17915 Bluetooth: Audio: Change samples and shell to use sinf
Change the samples and shell to use sinf instead of sin,
as that return the expect float data type, instead of
a double.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-30 12:45:26 +01:00
Jordan Yates
1e1d2725a7 net: dns: option to disable auto context init
Adds an option to disable the automatic initialization of the default
dns_context. This lets applications use the default context, while also
managing the `init` and `close` functions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2024-01-29 20:20:19 -06:00
Jordan Yates
e5f4fa0f4a net: dns: function to default initialize context
Adds a function that can be used to initialize a dns context to the
default Kconfig values.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2024-01-29 20:20:19 -06:00
Roman Studenikin
260fc89643 drivers: use DT_INST_PROP over DT_INST_PROP_OR if possible
It might happens that DT(_INST)_PROP_OR is used with boolean properties.
For instance:

	.single_wire = DT_INST_PROP_OR(index, single_wire, false),	\
	.tx_rx_swap = DT_INST_PROP_OR(index, tx_rx_swap, false),	\

This is not required as boolean properties are generated with false
value when not present, so the _OR macro extension is superflous
and the above code can be replaced by:

	.single_wire = DT_INST_PROP(index, single_wire),		\
	.tx_rx_swap = DT_INST_PROP(index, tx_rx_swap),			\

Signed-off-by: Roman Studenikin <srv@meta.com>
2024-01-30 00:26:58 +00:00
Robert Lubos
b8556d0d79 net: icmp: Don't report error on ICMP messages w/o handler
ICMPv4/6 modules print error when ICMP message handling fails, which
includes no message handler registered. This is a bit problematic, as
there are many ICMP messages that Zephyr does not process, and every
time such a message is received, an error log is printed (which wasn't
the case before ICMP rework).

Restore the old behavior (no log on unrecognized ICMP message) by
explicitly filtering out ENOENT error code from printing error. That
way, log will only be printed if an error occured within the actual
message handler.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-29 14:57:35 +00:00
Robert Lubos
cefc391db3 net: dhcpv6: Move DHCPv6 files to lib directory
For consistency with DHCPv4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-29 13:47:05 +01:00
Robert Lubos
19722aa8e8 net: dhcpv4: Move DHCPv4 files to lib directory
As discussed during DHCPv4 server integration, group DHCPv4 client files
with DHCPv4 server in a single lib directory.

Renamed internal "dhcpv4.h" header to "dhcpv4_internal.h" so that it's
not confused with the public "dhcpv4.h" header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-29 13:47:05 +01:00
Ping Wang
6dcde57952 Bluetooth: Audio: improve BASS state logging to be more readable.
When debugging it is hard to remember each state value (e.g. 0, 1, 2,
3) means. Therefore, make functions to improve logging for humans.

Fixes #59679

Signed-off-by: Ping Wang <pinw@demant.com>
2024-01-29 13:20:18 +01:00
Jukka Rissanen
7da14d3129 net: shell: Clarify the name of the virtual interface
The net-shell printed virtual interface name so that it got
the impression it was the network interface name which is not
correct. Now the name is printed as "Virtual name" which is
unambiguous.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-29 10:58:33 +00:00
Jukka Rissanen
a45d66c478 net: if: Do not join multicast address if IPv6 is not enabled
If IPv6 is not enabled for the interface, then do not try to
join the IPv6 solicited multicast address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-29 10:58:24 +00:00
Ping Wang
c7d1dc3b42 Bluetooth: Audio: Use utf8_lcpy to copy UTF8 strings with termination.
use the function utf8_lcpy to ensure that UTF8 encoded strings are
properly copied and NULL terminated.

Fixes #42128

Signed-off-by: Ping Wang <pinw@demant.com>
2024-01-29 10:28:18 +01:00
Fengming Ye
f61a0cb1fa net: zperf: fix the calculation ratio between mbps, kbps and bps
The ratio between mbps and kbps, kbps and bps should be 1000, instead of
1024, as common sense.
The wrong ratio will decrease the Zperf throughput result.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2024-01-29 10:05:35 +01:00
Jonathan Rico
2d9b56d713 Bluetooth: L2CAP: remove metadata allocation
The only thing we put in there is the CID and that fits comfortably into
the (at least) 4-byte void pointer `user_data`.

This removes the dependency between `CONFIG_BT_ATT_TX_COUNT` and
`CONFIG_BT_L2CAP_TX_BUF_COUNT` since previously there was still a need
for an L2CAP context for every TX'd buffer.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-29 09:41:23 +01:00
Jonathan Rico
3a4fd5e23d Bluetooth: L2CAP: remove cb/userdata from TX metadata
They were never used.
Only thing to remove is `cid`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-29 09:41:23 +01:00
Jonathan Rico
77d8c2768e Bluetooth: L2CAP: initialize servers slist
Somehow it slipped through the cracks and didn't crash before.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-29 09:41:23 +01:00
Pavel Vasilyev
54c048989d Bluetooth: Mesh: Send provisioning PDUs with randomized delay
This implements the following statement from the section 5.3.3:
Each Generic Provisioning PDU shall be sent after a random delay between
20 and 50 milliseconds.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-29 09:26:22 +01:00
Pavel Vasilyev
fcfc99a21d Bluetooth: Mesh: Add error code for bt_mesh_adv_terminate
Return error code to let an implementation know if the adv was actually
stopped (was scheduled) or not.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-29 09:26:22 +01:00
Pavel Vasilyev
9af051e349 Bluetooth: Mesh: Call bt_mesh_send_cb.end cb by the end of adv
Before this change, the bt_mesh_send_cb.end callback was called when all
references to the adv were removed. If an implementation kept more
references to the adv buffer after calling `bt_mesh_adv_send`, the end
callback would not be called when the advertiser finished advertising
this adv.

With this change, the end callback is always called by the advertiser
when the advertisement is finished regardless of the number of
references. This allows an implementation to keep the adv buffer for the
future use. As an example, pb_adv.c keeps advs for retransmission.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-29 09:26:22 +01:00
Jukka Rissanen
a1d0764922 net: wifi: Make sure scan band string is null terminated
Make sure that scan band string is properly terminated when
parsing user supplied string.

Fixes: #67944
Coverity-CID: 342930

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-26 19:40:16 +01:00
Seppo Takalo
992936300b net: lwm2m: Use CID_SUPPORTED instead of CID_ENABLED
When ENABLED flag is used, we generate 32 byte DTLS
Connection Identifier and include that in our
DTLS Client HELO. This has no benefit as client only
has one connection toward the server, it does not need
any identification.

When SUPPORTED flag is used, we just include
zero length Connection Identifier in the handshake,
which tell server that we support Connection Identifier
and server can generate one for it.
We then use the CID in the packets that we send towards
server, but response packets don't contain any CID.
This gives all the benefit of CID as server is able to
identify us even when NAT mapping have changed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-26 12:00:51 -06:00
Jonathan Rico
d75b44327a Bluetooth: ATT: don't callback if bearer is invalid
If an att buf is destroyed during bearer teardown, we want to avoid
using and passing invalid references to the application.

Double-check that the current bearer, the ATT object and the ACL conn
objects it is attached to are not NULL before proceeding.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-26 11:57:10 -06:00
Sandip Dalvi
4c7eb600c6 net: wifi: add wifi driver version API
Add command to query to WiFi driver/firmware revision. The API is expected
to return the firmware revision and driver version as a string, and can be
used by the user to determine what revision of the WiFi driver is in use.

Signed-off-by: Sandip Dalvi <sandip.dalvi@nxp.com>
2024-01-26 14:29:39 +01:00
Alberto Escolar Piedras
4ff79cb74a subsys/net/lib/lwm2m: Define required source standard macros
Instead of relaying on those macros having been defined
somewhere else let's define them for this file.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-26 07:48:55 -05:00
Alberto Escolar Piedras
06f15fcc36 subsys shell devmem_service: Fix includes
* The include for the host libC should be guarded with
  using the host libC instead of the POSIX arch, as this
  supports other C libraries.
* This code uses getopt, which is an extension to the
  C library. Let's explicity select one of the extensions
  which includes it instead of relaying on somebody having
  set it for this file somewhere else.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-26 07:48:55 -05:00
Alberto Escolar Piedras
2417599dc0 ztest native extensions: Set standard source macro appropriately
This file uses strtok_r which is an extension to the the
std C library. Let's explicity select one of the extensions
which includes it instead of relaying on somebody having
set it for this file somewhere else.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-26 07:48:55 -05:00
Luca Burelli
5f2c6e58b0 ztest: export ztest_test_* symbols to llexts
Export the minimal set of ztest_test_* symbols to llexts so that the
zassert_* macros can be used by the extension code to affect test
execution. Calling these also requires vprintk() to be exported.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-01-26 12:36:23 +01:00
Vinayak Kariappa Chettimada
87aa53ccae Bluetooth: Controller: Fix BIS Encryption for first subevent PDU empty
Fix radio packet length configuration when first subevent
has empty PDU in the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:35 +01:00
Vinayak Kariappa Chettimada
4192f8a844 Bluetooth: Controller: Fix ISO Sync Receiver sequential BIS PDU drop
Fix ISO Synchronized Receiver sequential packing BIS PDU
being dropped in the first repetation just after previous
BIS subevents where skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:24 +01:00
Vinayak Kariappa Chettimada
653d285210 Bluetooth: Controller: Fix Broadcast ISO Create Scheduling
Fix Broadcast ISO Create Scheduling to consider reducing
Host requested RTN value. And also use maximum overhead
calculation when Extended Advertising and Periodic
Advertising have not been started before BIG create.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:09 +01:00
Vinayak Kariappa Chettimada
818ae7acb0 Bluetooth: Controller: Fix incorrect HCI ISO Data length check
Fix incorrect HCI ISO data length check for Broadcast ISO
transmissions.

Removed initially added code when preliminary support for
Broadcast ISO was implemented.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:09 +01:00
Emil Gydesen
2b0e39dfa5 Bluetooth: Audio: Add bt_audio_codec unset functions
Add functions to unset, or remove, specific codec
LTV structure from codec_cfgs or codec_caps.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-26 09:43:30 +01:00
Pisit Sawangvonganan
4889c9ca17 sd: update comment to reference 'SD host controller specification'
In the code comments referring to section 3.6.1, changed the reference
from 'SD specification' to 'SD host controller specification'
for a clearer and more accurate context.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-25 20:13:25 +01:00
Pisit Sawangvonganan
1829fc33cb sd: omit zero-initialization for csd[4] and cid[4]
After a review of the usage of csd[4] and cid[4],
it has been determined that zero-initialization can be omitted.

It can be expected from successful operations that data will be
appropriately written back from the underlying layer.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-25 20:13:25 +01:00
Pisit Sawangvonganan
8534c38232 sd: omit zero-initialization for sdhc_command and sdhc_data structures
The decision to omit zero-initialization is driven by a desire to enhance
Zephyr's compactness and efficiency.

This is achieved by omitting zero-initialization, thereby reducing the
instruction count and, as a byproduct, the code size.

After a thorough review of the usage of struct sdhc_command and sdhc_data,
it has been determined that zero-initialization can be omitted.
Only a portion of the fields need to be manually initialized.
(e.g. cmd.retries, data.block_addr)

For the uninitialized fields, it can be expected from successful
operations that data will be appropriately written back from
the underlying layer.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-25 20:13:25 +01:00
Pisit Sawangvonganan
612aa7169a sd: add config SD_CMD_RETRIES
Introduced the config SD_CMD_RETRIES option as a build-time parameter.
This allows the assignment of a specific value to cmd.retries.
The default value has been set to 0 to preserve the previous setting.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-25 20:13:25 +01:00
Chaitanya Tata
c07d648304 wifi: shell: Remove duplicate argument count checks
Now that we are using the shell macro to enforce argument count check,
both mandatory and optional arguments, these additions checks are
unnecessary.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-25 11:50:59 -05:00
Chaitanya Tata
c53a1df138 wifi: shell: ap: Add a command to disconnect a station
The shell commands can be used to disconnect a connected station in AP
mode.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-25 11:50:59 -05:00
Chaitanya Tata
de667a7fae wifi: ap: Add support to disconnect a STA
In AP mode, this can be used to disconnect a connected station.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-25 11:50:59 -05:00
Fabio Baltieri
a06b7a4676 input: keymap: use the non _OR_NULL DEVICE_DT_GET variant
This driver really needs a device associated with it for the
syncronization bit to make sense, and since the argument is DT_PARENT it
will get it all the time, so no changes in practice, but this should
have been using the normal macro anyway.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-25 16:02:16 +00:00
Jean Nanchen
80f7d518c6 modbus: Remove mode reset in modbus_disable function
Remove reset mode in modbus_disable.

Signed-off-by: Jean Nanchen <jean.nanchen@gmail.com>
2024-01-25 16:00:38 +00:00
Øyvind Rønningstad
527af809f8 mgmt: Adapt to API changes in zcbor 0.8.0
zcbor_new_state and zcbor_tstr_put_term

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-25 15:09:16 +00:00
Øyvind Rønningstad
1bbb0a9ddb lwm2m: Adapt to zcbor 0.8.0
Regenerate from CDDL, update patch, fix references in code.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-25 15:09:16 +00:00
Hang Fan
b3d2891e16 Bluetooth: Classic: Add support for class of device
Add `CONFIG_BT_COD` for class of device.

< HCI Command: Write Class of Device (0x03|0x0024) plen 3
        Class: 0x200408
          Major class: Audio/Video (headset, speaker, stereo, video, vcr)
          Minor class: Hands-free Device
          Audio (Speaker, Microphone, Headset)
> HCI Event: Command Complete (0x0e) plen 4
      Write Class of Device (0x03|0x0024) ncmd 1
        Status: Success (0x00)

Signed-off-by: Hang Fan <fanhang8@gmail.com>
2024-01-25 15:09:01 +00:00
Bjarki Arge Andreasen
d801e697dd modem: chat: Implement TRANSMIT_IDLE event
Refactors modem chat module to use TRANSMIT_IDLE event instead
of polling when transmitting, cleaning up the transmit handler
by combining duplicate code and using an internal state instead
of multiple iterators to track send state.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-25 11:22:42 +01:00
Bjarki Arge Andreasen
27b0d4e3fe modem: chat: remove receive and transmit timeouts
Remove receive and transmit timeouts which are no
longer useful as the RECEIVE_READY and
TRANSMIT_IDLE events will be used to efficiently
manage timeouts between transmit/receive calls.

Then update the the in-tree drivers using the
modem_chat module to omit the process timeout
parameter.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-25 11:22:42 +01:00
Daniel DeGrasse
c1b7b817cc sd: modify sdmmc_wait_ready to always decrement timeout
As described in issue:
https://github.com/zephyrproject-rtos/zephyr/issues/65027,
sdmmc_wait_ready can enter an infinite loop if the card is removed while
waiting for it to report an idle status. Fix this by always decrementing
the timeout in sdmmc_wait_ready, regardless of whether the SD card is
busy.

Fixes #65027

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-01-24 16:37:21 +00:00
Jonathan Rico
6fa5d1e6a5 Bluetooth: L2CAP: fix net buf frags handling
Fix the handling of buffers with fragments. What seems to have been
broken is the metadata reference that was not passed to the next frag in
the chain.

Add a test to regression too.

The main user of this is IPSP.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-24 14:56:16 +01:00
Jonathan Rico
9d5217f68b Bluetooth: L2CAP: call bt_l2cap_send_cb once
Small refactor to improve readability.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-24 14:56:16 +01:00
Fabio Baltieri
297faf71d0 input: add two input to hid code translation functions
Add a pair of functions to translate from input events to hid codes,
mapping most of the current hid codes defined in zephyr/usb/class/hid.h.
Use a sparse table for the mapping, which takes advantage of the fact
that code 0 is reserved. Inspired by the linux equivalent hid to input
map:

https://elixir.bootlin.com/linux/latest/source/drivers/hid/hid-input.c#L27

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-24 10:44:40 +01:00
Seppo Takalo
ec3ec8cd2a net: lwm2m: Add LWM2M_ON_INIT() macro
Add macro that allows registration of initialization functions that
are called when LwM2M engine starts.

On LwM2M engine starts up, it first executes all initialization
functions in following priority order:
1. LWM2M_PRIO_ENGINE
2. LWM2M_PRIO_CORE, this is where all LwM2M core objects are initialized
3. LWM2M_PRIO_OBJ, this is where all other objects are initialized
4. LwM2M_PRIO_APP, application initialization.

Now on the initialization phase, we could rely that certain objects have
already been registered.
For example custom objects can register callbacks to core objects.
On application phase, we can initialize sensor objects and register
their callbacks because objects have already been initialized.

This LWM2M_ON_INIT() should replace all use of SYS_INIT()
with the default CONFIG_KERNEL_INIT_PRIORITY_DEFAULT.

Priority order is actually just alphabetical order of names, so
the order is set on a linkin phase, and we don't need any
runtime checking for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-24 10:44:28 +01:00
Vinayak Kariappa Chettimada
ac39ad7249 Bluetooth: Controller: Fix extended scanning assertion
Fix extended scanning assertion after long duration.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-24 10:44:12 +01:00
Zhang Lixu
5058355c1b sensing: add rtio implement for sensing subsys
1. add function sensing_iodev_submit and defined struct
   sensing_submit_config
2. fix the issue of phy_3d_sensor

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2024-01-24 10:32:10 +01:00
Tom Burdick
e69ce68d40 sensing: Fix initializer compile-time constant
Initializers must be compile time constants (not expressions!) for clang
to be happy. Clang rightfully pointed out that the callback_list member
of sensing_connection was being initialized using an expression that was
not compile-time constant.

The macros passed along a pointer created by taking the address of a
global constant and then at initialization time attempting to
dereference it using the * operator. So in the end the compiler has
identifier its trying to first take the address of and then later
dereference in an initializer. Clang didn't appreciate this, though gcc
seemed to be just fine.

Actually clang 17 might work just fine with this as well, but clang 16
(the clang I tried) didn't like it at all.

Instead store the pointer to the callback list rather than copying the
struct. This could be done the other way and not passing a
pointer through the macros perhaps.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-01-24 10:32:10 +01:00
Tom Burdick
fe4056a7e3 sensing: Code formatting fixups
Fixes a few small code formatting issues in sensor_mgmt.c adding
brackets where needed for an if and droping a line continuation slash
that failed one of the CI lints.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-01-24 10:32:10 +01:00
Zhang Lixu
f5595b4b9c sensing: support multiple sensor types in one device
Many sensors have multiple functions, for example, icm42688 supports
accel, gyro and temperature, and the sensor streaming api always mixes
the multiple functions in one function call. So we need add a layer in
sensing subsystem to dispatch the result returned from sensor streaming
api for each function.
I changed the sensor-type(int) to sensor-types(array) in sensing sensor
device bindings, so that one device can map to multiple instances of
sensing sensor.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2024-01-24 10:32:10 +01:00
Zhang Lixu
18a257cbe4 sensing: add hinge angle sensor
Add hinge angle virtual sensor for sensing subsystem, hinge angle sensor
takes both base accel and lid accel as reporter.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2024-01-24 10:32:10 +01:00
Zhang Lixu
593dab8218 sensing: implement the phy_3d_sensor
This patch is to implement the phy_3d_sensor in sensing subsystem. It's a
wrapper layer of AGM sensor driver for sensing subsystem. It supports
the accelerometer and gyrometer now.
This has been tested with bmi160 on native_posix simulator.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2024-01-24 10:32:10 +01:00
Zhang Lixu
7b6e1a32d0 sensing: implement sensor data dispatching
Create the dispatch thread to send sensor data to its client by
checking time.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2024-01-24 10:32:10 +01:00
Zhang Lixu
b73eafcc61 sensing: implement set/get interval and sensitivity
1. set/get interval sensitivity is implmented in sensor management module.
2. add the runtime thread to handle the sensor configuration.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2024-01-24 10:32:10 +01:00
Zhang Lixu
46eb27cf73 sensing: unified the sensing sensor api
1. use the sensor_driver_api instead of the sensing_sensor_api.
2. clean up the sensing_sensor.h after using the unified api.
3. select RTIO while CONFIG_SENSING is enabled.
4. remove the sensing_sensor_post_data and sensing_sensor_xxx_data_ready by
introducing the RTIO

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2024-01-24 10:32:10 +01:00
Guangfu Hu
b9b714c8bd sensing: refine sensing API
1) move variable shift behind struct sensing_sensor_value_header in
struct sensing_sensor_value_q31
2) add pointer checking for sensing API
3) add context sensing_callback_list and sensing_data_event_t
4) add macro SENSING_SENSITIVITY_INDEX_ALL
5) rename zephyr,sensing-phy-3d-sensor.yaml

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
2024-01-24 10:32:10 +01:00
Miika Karanki
8b86645108 fs: Add Kconfig key for init priority
Non-configurable init priority POST_KERNEL/99 might
be too late for certain uses cases (e.g. fetching data from
the file system in driver initialization). Chabge it to
be configurable so that applications can mount the
file systems earlies if they want.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2024-01-24 09:22:23 +00:00
Miika Karanki
89d4f06c17 fs: remove not needed SYS_INIT function
fs_init was just initializing mutex and dlist. Those can be
done statically. Not having the SYS_INIT function helps
in ordering the init functions in case e.g. file system
mounts are wanted to happen early stage on the system
startup.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2024-01-24 09:22:23 +00:00
Vivekananda Uppunda
7eb0aa0468 net: wifi_shell: Remove TX-Injection and Promiscuous mode from Wi-Fi mode
Remove TX-Injection and Promiscuous mode setting from Wi-Fi mode shell
command. These commands are being moved to ethernet l2 layer

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2024-01-24 00:08:38 -05:00
Vivekananda Uppunda
db4bf8d409 net: l2: ethernet: bring in TX-Injection mode to l2 ethernet
This set of changes brings in raw packet tx injection mode
feature to ethernet and removes it from being a Wi-Fi only feature.

It was earlier envisaged as Wi-Fi net management feature only.

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2024-01-24 00:08:38 -05:00
Vinayak Kariappa Chettimada
585d98e0d8 Bluetooth: Controller: Fix prepare overhead in scheduling ISO
Fix double prepare overhead considered in scheduling
extended, periodic and ISO broadcast radio events when using
LOW LAT variant.

ticks_slot maintained in ticker includes the overhead, the
ticks_slot stored in role/state context exclude the overhead
hence take care to include ticks_slot_overhead when value is
used from context and not when value used from ticker nodes.

Add jitter due to ticker resolution unit between scheduled
radio events. This will allow the synchronizing side too to
not overlap due to ticker resolution related jitter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:45:29 +01:00
Vinayak Kariappa Chettimada
4a51f68bcc Bluetooth: Controller: Fix ISO Sync Receiver subevent Rx window
Fix ISO Synchronized Receiver subevent Rx window timing and
PDU address receive timeout to consider the +/- 2us active
clock jitter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:45:16 +01:00
Vinayak Kariappa Chettimada
83174ef7dc Bluetooth: Controller: Fix ISO Sync Receiver sequential subevent skip
Fix ISO Synchronized Receiver sequential packing subevent
skip to next BIS subevent, so that radio channel is
correctly calculated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:45:02 +01:00
Vinayak Kariappa Chettimada
6e51950cd8 Bluetooth: Controller: Use EVENT_OVERHEAD_RESERVE_MAX in Periodic Sync
Use EVENT_OVERHEAD_RESERVE_MAX conditional compile in
Periodic Advertising Sync implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:44:41 +01:00
Anders Storrø
93a6ee501a Bluetooth: Mesh: Add artificial beacon delay
After removing 20ms in advertiser, all subnetwork beacons are sent as high
dense packet of frames with minimal distance between them. That might
cause collisions if beacon interval on devices will coincide.

This commit adds an artificial delay between each subnet advertsing
beacons.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-01-23 10:02:00 +01:00
Dawid Niedzwiecki
ea630294d3 logging: add flag to skip source info
Add a flag to skip printing the source info.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-01-22 14:05:11 -05:00
Seppo Takalo
bf872870ea net: lwm2m: Fix segfault on failed bootstrap
If bootstrap fails, RD client will call lwm2m_engine_stop()
which will close the context.
The socket loop, however still contains a call to
hint_socket_state(context, NULL) which has a null pointer now.

Fix the segfault by allowing nullpointer on hint_socket_state().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-22 17:25:02 +00:00
Vinayak Kariappa Chettimada
4158d9523e Bluetooth: Controller: Fix extended scanning data length assertion
Fix assertion due to LLL scheduling of auxiliary PDU
reception was not considered in the ULL when checking for
accumulated data length exceeding the supported maximum scan
data length. This caused the auxiliary context to be release
while LLL was still active with scheduled PDU reception.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-22 16:55:09 +01:00
Mustafa Homsi
e51c47bf43 Bluetooth: Controller: Fix regression in BT_CTLR_USED_PPI_CHANNELS
Fix regression in BT_CTLR_USED_PPI_CHANNELS introduced
in commit e39d98302d ("Bluetooth: Controller: nRF53:
Cleanup dppi and dppi resources file").

Signed-off-by: Mustafa Homsi <mustafa.homsi@rivieh.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-22 14:31:12 +01:00
Emil Gydesen
aef39f6923 Bluetooth: BAP: Fix issue with setting invalid iso data path
BAP would always set up the ISO data path in both directions,
even for unidirectional CIS. This meant that in the
unconfigured direction, the data path configuration data
would all be 0, which causes issues on some controllers.

The new refactored approach implemented by this commit
will always ensure that the data path is setup correctly,
and that we only set the data path in one direction for
unidirectional CIS. The unset path will use the default
ISO path of HCI and transparant format, which should always
be allowed by a controller.

This is building on the requirement in BAP that all streams in
a unicast group shall be QoS configured at the same time. This
ensures that before any streams in the CIG has been connected,
they have all been configured.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-22 13:09:16 +01:00
Rubin Gerritsen
db58810492 Bluetooth: ISO: Fix CIS peripheral disconnection during setup
When the central aborts the CIS setup during the CIS Creation
procedure after it has accepted the CIS request, the peripheral
will receive the HCI LE CIS Established event with an error code.
It does not receive a disconnection event.
See the message sequence chart in Core_v5.4, Vol 6, Part D,
Section 6.23.

This commit ensures that the perirpheral disconnected callback gets
called for this particular scenario.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-01-22 12:59:38 +01:00
Emil Gydesen
b857ef7f83 Bluetooth: BAP: Add ISO state callbacks
Add callbacks to the stream objects that reflects the
state of the isochronous channel. The connected callback
is called when the isochronous channel is connected, and
similarly the disconnected callback is called when it is
disconnected.

There is a special case for unicast, where if the ACL
disconnects first, then we won't get a ISO disconnect
callback. It should be assumed that the isochronous channel
is no longer valid when the BAP stream enters the idle state,
i.e. when the "released" callback is called.

The purpose of the new callbacks is to provide additional
information to the application. Especially the unicast client
can use this to determine when the stream_start function
can be called again, as there can only ever be 1 outstanding
CIS connection request at a time, but there can be multiple
GATT requests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-22 12:59:11 +01:00
Fabio Baltieri
23714980b0 input: utils: fix kbd_matrix_state_log types
Change row and col static types to unsigned, this should prevent really
bad things from happening if a negative number ends up there for
whatever reasons without having to explicitly check for < 0.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-22 11:20:50 +00:00
Bjarki Arge Andreasen
a9779eca40 modem: ppp: Implement TRANSMIT_IDLE event
Implement TRANSMIT_IDLE event for modem_ppp module. This addition
optimizes the sys workque CPU time when performing a throughput
test from 36% to 5%, while only reducing the throughput by 12%.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-22 10:35:37 +00:00
Jakub Rzeszutko
04de43b1a1 shell: Fix shell init procedure when configured as inactive on startup
The previous behavior of the CONFIG_SHELL_AUTOSTART option, where setting
it to 'n' disabled shell interaction at startup but kept the logger
active as a shell backend, was inconsistent.
Now, when CONFIG_SHELL_AUTOSTART is set to 'n', both the shell and the
logger are inactive at startup. Calling the shell_start function will
activate them and print any pending logs. This change ensures a more
consistent and logical behavior regarding shell and logger activity at
startup.

Additionally, now when the shell_stop function is called, both the shell
and the logger are halted. This enhancement ensures that stopping
the shell also effectively stops the associated logger.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2024-01-21 16:01:36 +01:00
Henrik Brix Andersen
3436c93387 drivers: can: remove run-time RTR filtering, add build-time RTR filter
A growing number of CAN controllers do not have support for individual RX
hardware filters based on the Remote Transmission Request (RTR) bit. This
leads to various work-arounds on the driver level mixing hardware and
software filtering.

As the use of RTR frames is discouraged by CAN in Automation (CiA) - and
not even supported by newer standards, e.g. CAN FD - this often leads to
unnecessary overhead, added complexity, and worst-case to non-portable
behavior between various CAN controller drivers.

Instead, move to a simpler approach where the ability to accept/reject RTR
frames is globally configured via Kconfig. By default, all incoming RTR
frames are rejected at the driver level, a setting which can be supported
in hardware by most in-tree CAN controllers drivers.

Legacy applications or protocol implementations, where RTR reception is
required, can now select CONFIG_CAN_ACCEPT_RTR to accept incoming RTR
frames matching added CAN filters. These applications or protocols will
need to distinguish between RTR and data frames in their respective CAN RX
frame handling routines.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-21 11:00:31 +01:00
Fabio Baltieri
5f989e4378 input: add a keymap driver
Add a "input-keymap" driver to translate keyboard matrix event into key
events.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-19 15:14:25 +00:00
Gerard Marull-Paretas
27f14eb3a8 bluetooth: controller: ll_sw: RV32M1: add missing include
cntr.c accesses some registers defined in fsl_device_registers.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-01-19 15:13:53 +00:00
Kamil Piszczek
6852abf521 bluetooth: gatt: add authorization callback API for gatt operations
Added the GATT authorization callback API that allows the user to
define application-specific authorization logic for GATT operations.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2024-01-19 16:08:46 +01:00
Jonathan Rico
68316ace22 Bluetooth: L2CAP: remove l2cap_chan_create_seg()
Remove the logic for adding the SDU length when allocating segments. That
section was dead code after the recent patches.

Inline the remainder of the logic into `l2cap_chan_le_send()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-19 16:59:11 +02:00
Flavio Ceolin
b9d4b9d9ab pm: Remove CURRENT_CPU macro
Just use _current_cpu that works with/without multicore.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-01-19 13:49:54 +01:00
Fabio Baltieri
e11bbb829f input: longpress: move constant entries pointer to the config struct
The entries pointer does not change, no need to have it in RAM, 4 bytes
saved. Refactor the init macro a bit while at it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-19 13:49:43 +01:00
Pavel Vasilyev
83b7513937 Bluetooth: Mesh: Move beacons Kconfiguration under separate submenu
Collect beacons Kconfiguration under own submenu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
bb75d1f813 Bluetooth: Mesh: Move Solicitation Kconfig options
Move Solicitation Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
343fa6d044 Bluetooth: Mesh: Move OdProxy models Kconfig options
Move OdProxy models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
168af2324d Bluetooth: Mesh: Move PRB models Kconfig options
Move PRB models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
84febe83a9 Bluetooth: Mesh: Move LCD models Kconfig options
Move LCD models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
5156f78386 Bluetooth: Mesh: Move OpAgg models Kconfig options
Move OpAgg models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
5b0a1bb165 Bluetooth: Mesh: Move SAR models Kconfig options
Move SAR models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
f89effbe75 Bluetooth: Mesh: Move RPR models Kconfig options
Move RPR models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
c2299e2120 Bluetooth: Mesh: Move DFU models Kconfig options
Move DFU models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
11986a29d8 Bluetooth: Mesh: Move MBT models Kconfig options
Move MBT models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
dcdbb4bceb Bluetooth: Mesh: Move CDP 1.1 Kconfig options
Move CDP 1.1 Kconfig options to the access layer menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
b94b9c7759 Bluetooth: Mesh: Move provisioning 1.1 Kconfig options
Move provisioning 1.1 Kconfig options to the provisioning menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
6060dfbc7f Bluetooth: Mesh: Move mesh-1.1 transport sar configuration
Move mesh 1.1 transport sar configuration under transport menu

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
981c79b7ce Bluetooth: Mesh: Drop explicit support for Bluetooth Mesh 1.0.1
Bluetooth Mesh Protocol 1.1 is backward compatible with Bluetooth Mesh
Profile 1.0.1, therefore the stack can still be qualified for 1.0.1 if
needed. But explicit support for both versions requires additional
maintenance efforts and doubles the CI time. To make the stack
qualifiable for 1.0.1, the one needs to remove Private Beacons reception
and compile out SHA256 algorithm support.

What is changed:
- Removed `CONFIG_BT_MESH_V1d1` option.
- Removed `transport_legacy.c` which was using 1.0.1 implementation. The
  new transport layer has new SaR logic that should still be possible to
  qualify for 1.0.1.
- Removed the legacy transport Kconfig options. They are superseded by
  the new transport Kconfig options.
- Tester app: `overlay-mesh-v1d1.conf` is merged into
  `overlay-mesh.conf`.
- Removed BabbleSim tests for 1.0.1.
- Updated documentation.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Robert Lubos
2c70c5d74a net: shell: Implement DHCPv4 server shell commands
Implement DHCPv4 shell module, which allows to start/stop DHCPv4 server
operation, and print server status (address leases).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos
3bc50871bc net: socket_services: Increase default stack size for DHCPv4 server
Increase socket services thread default stack size when DHCPv4 server is
enabled, as it uses synchronous processing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos
1e08bbd543 net: dhcpv4: Implement DHCPv4 server
Add basic socket-based implementation of DHCPv4 sever.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos
db80ed3e8d net: if: Add function to obtain IPv4 netmask
Add a helper function to obtain IPv4 netmask configured on an interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos
1d14f13d75 net: arp: Make arp_update() function externally visible
So that it's possible to register ARP entries manually. Needed for DHCP
server implementation, which in unicast mode needs to reply to an IP
address that is not registered on the peer interface yet (hence no ARP
reply will be sent). It's needed to add an ARP entry manually in that
case, as hardware address is already known at that point.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Dawid Niedzwiecki
efe92870c8 ec_host_cmd: spi_stm32: prevent accessing null pointer
There is a possibility that the SPI STM32 Host Command backend is being
suspended, without earlier initialization.

Make sure we are not accessing uninitialized pointer, namely the cs
structure.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-01-19 10:33:51 +01:00
Henrik Brix Andersen
75117a0deb drivers: can: remove CAN_FILTER_FDF flag
Remove the CAN_FILTER_FDF flag for filtering on classic CAN/CAN FD frames
as it is not supported natively by any known CAN controller.

Applications can still filter on classic CAN/CAN FD frames in their receive
callback functions as needed.

Fixes: #64554

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-19 09:55:43 +01:00
Juha Ylinen
9eee8d2be5 net: lwm2m: Allow send operations when sleeping
Add new kconfig CONFIG_LWM2M_QUEUE_MODE_NO_MSG_BUFFERING.

When enabled and device is sleeping, Reqistration Update
message is skipped and messages from send operation and
notifications are sent right away.

Reqistration update message is also skipped when
lwm2m_engine resumes from pause state.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-19 09:48:46 +01:00
Bjarki Arge Andreasen
52be26a8e3 net: l2: ppp: Patch carrier lost and L2 enable/disable
L2 PPP is not able to handle the carrier being lost gracefully,
nor is it able to gracefully close the PPP connection when
net_if_down() is called.

This patch refactors the L2 PPP module to use the carrier state
to either properly close or simply terminate the PPP connection.

Additionally, it ensures that the PPP session is closed properly
before calling ppp->stop().

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-19 09:47:33 +01:00
Kapil Bhatt
c22ce801e7 net: wifi_shell: Add help for maximum channels in scan
Add a line for scan's -c parameter which specify
to take care of maximum channels.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-19 09:44:22 +01:00
Markus Lassila
681330aaf0 net: sockets: tls: Fix crashes in get DTLS CID socket options
Get TLS_DTLS_CID_STATUS and TLS_DTLS_PEER_CID_VALUE utilize
mbedtls_ssl_get_peer_cid, which expects that mbedtls_ssl_setup
has been done.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2024-01-19 09:41:34 +01:00
Jamie McCrae
63c21bb383 mgmt: mcumgr: transport: smp_udp: Fix error when message too large
Fixes an issue whereby a message which is too large was attempted
to be sent via the UDP transport would wrongly give an error in
value error

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-01-18 20:16:11 +01:00
Jukka Rissanen
5a933299bb net: socket: Change the printf modifier to print size_t correctly
The argument is size_t, so change the printf modifier to %zd
to avoid warning prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen
84ff0e8cdf net: socket: Allow user to tweak service dispatcher thread priority
User is able to tweak the socket service dispatcher thread
priority in order to get better performance from the system
if needed. By default the dispatcher thread runs in lowest
application thread priority (K_LOWEST_APPLICATION_THREAD_PRIO).

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen
38cacc7f63 net: shell: Make the thread name longer for sockets command
The thread name output field was a bit too short in "net sockets"
command, so make it 25 char long.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen
d3bfef8399 net: shell: Do not crash if no sockets are found
The "net sockets" command was not checking if there is any
sockets in the system before trying to access them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen
1e8cbd5d43 net: zperf: Convert UDP receiver to use socket services
Use socket services API for UDP receiver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen
07823f7710 net: zperf: Convert TCP receiver to use socket services
Use socket services API for TCP receiver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Emil Gydesen
d26ba10640 Bluetooth: GATT: Add missing busy check for auto discover CCC
When using the auto discover CCC, and the function is called
more than once with the same parameters before the previous
discovery has completed, then that may cause issues when we
reset the parameters when we get the response.

This commit adds a small check for the callback function
which is only set to the specified function when the
discovery is in progress. This way we can return an error
if the application calls bt_gatt_subscribe multiple times
before the previous discovery has completed, rather
than asserting.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-18 20:11:08 +01:00
Fabio Baltieri
1c9be802bc usbc: fix shadowed declaration build error
Fixes:

/__w/zephyr/zephyr/subsys/usb/usb_c/usbc_tc_src_states.c:260:21: error:
declaration of 'ret' shadows a previous local [-Werror=shadow]

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-18 11:28:54 +00:00
Chaitanya Tata
df6d4e7717 wifi: shell: Log errors for validation
Handy in giving feedback to the user rather than silent failure.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata
c9363a9c71 wifi: shell: Fix the channel extraction
The channel extraction from string directly uses the end variable with
limited data type, this causes issue if an invalid channel that exceeds
the data is given as an input e.g., 300, which would end up as a valid
channel 44.

Use an intermediate variable with type that can hold all possible
combinations (valid and invalid) and only after validation assign that
to the end type.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata
2f88df9cef wifi: shell: Add channel validation
Validate the channel for both STA and AP modes.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata
2f99379dd5 wifi: utils: Move channel helpers to public API
These can be used for channel validation outside the utils.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata
c6f2152348 wifi: shell: Add a sanity check for MFP
For none and WPA-PSK MFP isn't applicable, it was only introduced in
WPA2-PSK (RSN) and later.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata
4a1847eb22 wifi: shell: Make channel mandatory for AP
For starting an AP mode, channel is mandatory, so, fix the arguments and
the help text.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Pavel Vasilyev
7a41a9d864 Bluetooth: Mesh: Fix processing SegAcks to wrong destination
Do not process SegAcks which were not targeted to the node.

They were rejected in the next if statement always, but generated
the annyoing warning "No matching TX context for ack".

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-18 10:55:24 +01:00
Michał Barnaś
551c7654f5 usbc: integrate the PPC with the USB-C stack
Add calls to the PPC API that enables and disables the sink and source
paths in the appropriate USB-C stack states.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2024-01-18 10:53:53 +01:00
Greter Raffael
5b19fcd7e8 riscv: irq: Add trigger_irq function for clic
In a clic the mip register does not exist and software irq are triggered
in the clicintip register.

Signed-off-by: Greter Raffael <rgreter@baumer.com>
2024-01-18 10:53:27 +01:00
Erwan Gouriou
b98c7942ca pm: console: Use async runtime put to minimize resumption/suspension
When device runtime pm is enabled on console device, do not suspend
device synchronously on each char transmission, but rather use asynchronous
suspension request.
This will save useless and costly suspension/resumption procedure, which
can involve uart device clock suspension but also pin configuration
to sleep state (which itself involves gpio clock activation ...).

On STM32, using asynch device suspension allows to divide by 3 the
transmission time of a character chain.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2024-01-18 10:51:10 +01:00
Emil Gydesen
490c5e3b20 Bluetooth: Audio: Shell: CAP change volume command
Add sthe change volume command to the CAP commander shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 12:00:09 -05:00
Emil Gydesen
6e52f384c8 tests: Bluetooth: CAP commander volume_change unit tests
Adds unit tests for the CAP Commander volume_change
procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 12:00:09 -05:00
Emil Gydesen
b09ce2fade Bluetooth: CAP: Commander set volume support
Add support for setting volume on one or more CAP
acceptors using the CAP Commander API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 12:00:09 -05:00
Emil Gydesen
1faa5a2aa2 Bluetooth: BAP: Add support for transparent coding format
Add support for controlling whether the local controller
should transcode, or whether it will be done by another
module (e.g. the host).

By default when using the macros,
controller transcoding will be disabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 11:59:14 -05:00
Emil Gydesen
476e7b3fa3 Bluetooth: Audio: Ensure that read callbacks can handle conn == NULL
The read callbacks may be called with conn == NULL if the device
does a local read of the attributes. This commit ensures that all
the read callbacks can handle the case where conn == NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 11:58:44 -05:00
Ajay Parida
4d854a193e net: mgmt: Print correct TWT teardown status message
Print success message for TWT teardown successful case.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-17 16:11:37 +00:00
Jukka Rissanen
3a37c5d987 net: shell: Require float printf support from libc
Various network shell commands like ping need floating
point support from libc so select the CONFIG_REQUIRES_FLOAT_PRINTF
option for it.

Fixes #67601

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-17 16:09:17 +00:00
Markus Swarowsky
11175c3ad3 tf-m: Change NS include path for TF-M 2.0.0
The place where TF-M places its non-secure api header files has changed
Therefore changing it for for all applications that use it.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2024-01-17 16:52:52 +01:00
Bjarki Arge Andreasen
358f1ff934 tests: modem: cmux: Implement TRANSMIT_IDLE into test suite
Use transmit idle event to synchronize with data transmitted
through DLCI pipes to test TRANSMIT_IDLE implementation.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-17 09:20:50 -06:00
Bjarki Arge Andreasen
c114627853 modem: cmux: Implement TRANSMIT_IDLE event
Implement transmit idle event both for transmitting data to the
bus, and for the individual DLCI channels.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-17 09:20:50 -06:00
Morten Priess
056d5a354b Bluetooth: controller: Handle peripheral CIS creation latency
Instead of asserting, handle CIS creation latency for the peripheral by
finding next valid ISO event at which to start the CIG ticker.

Refactored calculations of the cig_offset to separate functions, to be
used also when calculating a new start offset.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-01-17 14:44:34 +01:00
Gerhard Jörges
2a0e5e93f3 logging: net: update hostname
This commit adds a function that updates the hostname displayed by the
net backend. It is called by the network stack when the hostname is
updated.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-01-17 14:42:58 +01:00
Gerhard Jörges
72a51c7ec4 net: add set hostname function
This commit adds a function to set the hostname on runtime.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-01-17 14:42:58 +01:00
Jonathan Rico
81d524d081 Bluetooth: L2CAP: always send from workqueue
Always pull from the channel queue from the system workqueue context.
This simplifies debugging.

This also allows us to remove `sent` from the metadata struct.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-17 14:42:40 +01:00
Jonathan Rico
2dcb91ab46 Bluetooth: L2CAP: extract LE part of bt_l2cap_chan_send
Separate most of the param checking in `bt_l2cap_chan_send()`, with the
logic in `bt_l2cap_dyn_chan_send()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-17 14:42:40 +01:00
Vinayak Kariappa Chettimada
60c0087555 Bluetooth: Controller: Fix ISO Sync Receiver time reservation calc
Fix missing ISO Synchronized Receiver radio event time
reservation that did not calculate for all the subevents.

Introduce BT_CTLR_SYNC_ISO_RESERVE_MAX Kconfig option to
allow using a minimal time reservation if needed to allow
other role to pre-empt ISO Synchronized Receiver in
pre-transmission and control subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-17 14:42:32 +01:00
Guennadi Liakhovetski
a1fd8cd078 runtime-pm: remove a superfluous k_is_pre_kernel() test
If runtime_suspend() is called early during Zephyr initialisation,
while k_is_pre_kernel() returns 'true,' 'async' is set to 'false,' so
if 'async' is 'true,' Zephyr initialisation is definitely complete,
so there is no need to check k_is_pre_kernel() again.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-01-17 09:55:48 +01:00
Jukka Rissanen
16a54f251a net: sockets: Refactor accept() to support objcore better
If user has not supplied address pointer when calling accept(),
then we would not be able to figure out the used socket domain
properly. But as there is now SO_DOMAIN option supported, use
that to get the correct socket domain.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-17 09:55:40 +01:00
Jukka Rissanen
298ab2c95d net: socket: Add support for SO_DOMAIN option
The getsockopt() will return the address domain of the given
socket like AF_INET or AF_INET6.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-17 09:55:40 +01:00
Ibe Van de Veire
ba5bcb14ba net: ip: igmp: removed compiler warning when igmpv3 is enabled
Made the definition of in_addr all_routers conditional to remove
compiler warning:
warning: 'all_routers' defined but not used [-Wunused-const-variable=]
The warning occurs when igmpv3 is enabled.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
2024-01-17 09:55:28 +01:00
Miika Karanki
7c0047263a shell: telnet: Don't close the connection on ENOBUFS error
If there's not enough networking buffers at certain moment,
they might become available later. So instead of closing connection
(and failing assertation) sleep and retry. This avoid the following
assertion failure when there's much of data to send:

    net_pkt: Data buffer (1500) allocation failed.
    net_tcp: conn: 0x20076024 packet allocation failed, len=1460
    shell_telnet: Failed to send -105, shutting down
    ASSERTION FAIL [err == 0] @ .../subsys/shell/shell_ops.c:416
    os: r0/a1:  0x00000004  r1/a2:  0x000001a0  r2/a3:  0x00000004
    os: r3/a4:  0x20044380 r12/ip:  0x00001958 r14/lr:  0x080c9027
    os:  xpsr:  0x41000000
    os: Faulting instruction address (r15/pc): 0x0811ed26
    os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
    os: Current thread: 0x20045100 (shell_telnet)
    os: Halting system

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2024-01-17 09:54:15 +01:00
Tom Burdick
897553af17 logging: Remove hda log backend
The HDA log backend has been buggy for some time, and the fixes are well
understood. The issue with HDA log as it is implemented today means
there are concurrency and ISR issues where it can deadlock.

The fixes are effectively dropping the usage of ipc to communicate
status, using polling on the hda stream, and having a formatter per call
context (cores + isr) when log mode immediate is enabled to fix log
mangling. However it was found this had a lot of unintentional side
effects that made it difficult to make progress on when it came to
changes of the host side python tooling.

Meanwhile the feature has sat unused for nearly a year. Remove it, and
it can always be revisited in the future if something like it happens to
be needed.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-01-17 09:52:48 +01:00
Bi Jian
06fa287d45 Bluetooth: Audio: Update audio location definitions
The meaning of bit0 in the audio location bitmap will change to
mono audio, so we update the audio location macro and releated
test cases.

Refer to BT SIG ES-22266.

Signed-off-by: Bi Jian <bi_jian@qq.com>
2024-01-16 14:27:40 -05:00
Chaitanya Tata
dc9d5d9321 wifi: shell: Fix typo in comparison
The length should be 3 for WMM not 4.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-16 14:25:37 -05:00
Konrad Derda
a5b868d94a net: buf: add function to match buffer's content with a given data
This commit adds a new function the net_buf's API that allow an user
to match the net_buf's content with a data without copying it to a
temporary buffer.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-01-16 09:40:04 -06:00
Emil Gydesen
f4cbf403e8 Bluetooth: BAP: Fix uninitialized variable in source_reconfig
The stream_in_subgroup variable in bt_bap_broadcast_source_reconfig
may have been uninitialized.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:37:28 -06:00
Emil Gydesen
bf37784dea Bluetooth: PACS: Fix logical dead paths
In pac_notify and pac_notify_loc coverity found logical dead
paths since if both sink and source notify was disabled,
the functions would still be compiled, but would
never get past the default case.

This is not a real issue as the functions were never called
in that case, but to make coverity happy, and to prevent
any future issues where the functions may be called
incorrectly, the static functions are now fully guarded.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:35:37 -06:00
Emil Gydesen
9fc630d303 Bluetooth: CSIP: Use bt_crypto_aes_cmac instead of own
Instead of reimplementing the aes_cmac function, CSIP
will now use the bt_crypto_aes_cmac function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:33:58 -06:00
Emil Gydesen
64adf0b065 Bluetooth: BAP: Add log of err in bt_bap_stream_detach
We can't really do anything about it if it fails, so we
simply log the value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:32:22 -06:00
Emil Gydesen
f9c116ec73 Bluetooth: CAP: Shell: Fix channel allocation
The channel allocation was incorrect when setting up multiple
streams to a single device, in which case we should apply
individual bits to each stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:31:12 -06:00
Jonathan Rico
38c39af4df Bluetooth: L2CAP: Prepend SDU header immediately
Previously it was not always possible to prepend the header.

It was not possible if the application neglected to reserve the space
for headers.  This is bad because it forces a buffer segment allocation
even if the buffer had enough room for the headers. E.g. a payload of 10
bytes in a netbuf of 30 bytes would have been segmented.

We now explicitly reject the buffer if it does not have the headroom.

This allows us to do a nice thing; simplify L2CAP segmentation.

We convert the SDU from the application into a PDU payload, by
prepending the SDU header, i.e. the SDU length in the original buffer.

This PDU payload is ready to be chunked into PDUs without having to keep
track of where in the SDU we are. This has the effect of removing a
bunch of logic in the segmentation machine.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-16 11:29:43 +00:00
Aleksandr Khromykh
4e7d64b1b4 Bluetooth: Mesh: enable access responses randomization
Enable by default the access layer responses random delays.
Commit also adapts all mesh models, samples and
babblesim tests to use random delay functionality correctly.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-01-16 11:29:20 +00:00
Flavio Ceolin
640a4586c0 pm: device_runtime: Fix domain mgmt in async put
The asynchronous put is not checking if the device was successfully
suspended before suspending its domain and it is not checking if the
domain was claimed. This patch adds these two checks.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-01-16 10:01:08 +01:00
Jukka Rissanen
6033161216 net: shell: Avoid gcc warning print with string catenation
gcc prints this warning message

'strncat' specified bound 1 equals source length [-Wstringop-overflow=]
   58 |                 strncat(fd, "C", 1);

There was no error in the code but avoid the warning by not using
strncat().

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Jukka Rissanen
f5e95852ce net: shell: Add sockets services prints
The socket services users to "net sockets" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Jukka Rissanen
eff5d02872 net: sockets: Create a socket service API
The socket service provides a similar functionality as what
initd provides in Linux. It listens user registered sockets
for any activity and then launches a k_work for it. This way
each application does not need to create a thread to listen
a blocking socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Emil Gydesen
68f8c8ff29 Bluetooth: Audio: Fix off-by-one error in codec.c:ltv_set_val
The function did not move data correctly when increasing
or decreasing the size of a value that was not the last value
in the LTV array.

Added a few tests to verify the fix, using the CCID list as the
main way of verifying it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 10:00:04 +01:00
Emil Gydesen
400cdcaca4 Bluetooth: BAP: Fix invalid GATT error codes in scan delegator
There was a few places where the scan delegator returned an
errno value instead of a valid GATT error codes when rejecting
write request. These have been modified to send
BT_ATT_ERR_WRITE_REQ_REJECTED to the client instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 14:07:15 -05:00
Emil Gydesen
e2b271fbc4 Bluetooth: ASCS: Add additional dbg info in state changes
Add additional debug information in some ASCS debug statements,
so it is easier to follow the state when there is a potentional
state change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 13:59:08 -05:00
Piotr Narajowski
13b0052cfa Bluetooth: MPL: Add notification to track change
This adds notifications to do_first_track only when changing group.
Before the change was made, client was never notified about
track change when changing group in Media Player.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2024-01-15 13:57:21 -05:00
Emil Gydesen
a72da864e0 Bluetooth: BAP: Restrict application ASCS response codes
Some of the ASCS response codes should not be used by the
unicast server, as those will be checked and validated by the
stack.

They are kept in the enum, as the enum is also used by the
unicast client.

Besides updating the documentation, this commit also adds
a function to validate the response codes as well as the
combination of response codes and reason/metadata values,
and log a warning if the application does not adhere to the
documented behavior.

A warning is used instead of an error/assert/modification
of the response codes, as there may be unforseen reasons
why an application provide a non-approved response code,
and since it may be spec-valid, we should not fully
prevent it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 13:56:22 -05:00
Emil Gydesen
234b322dc3 Bluetooth: Audio: Fix len check in ltv_set_val
The length check in ltv_set_val did not consider the size of
the length or type fields.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 13:55:55 -05:00
Flavio Ceolin
d2be3c05dc tracing: sysview: Fix API name
s/k_thread_usermode_enter/k_thread_user_mode_enter/

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-01-15 13:53:44 -05:00
Mirko Covizzi
998e839d67 net: sockets: prevent null pointer dereference
According to the POSIX specification, null pointer
is a valid value for the `address` argument
of the `accept` function.
This commit adds a check to prevent a null pointer
dereference inside `z_impl_zsock_accept`.

Signed-off-by: Mirko Covizzi <mirko.covizzi@nordicsemi.no>
2024-01-15 15:11:57 +01:00
Bjarki Arge Andreasen
7c9f2872e1 modem: chat: Start waiting for response after request is sent
This PR makes the modem_chat wait until a chat script chat
request has been sent before accepting responses to said
request.

This helps ensure that an unsolicitet response is not mistaken
for a response to a request, which is especially problematic
if the chat script chat is using an any match.

For example, start chat script sending AT+CGMI, expecting the
modem name as a response followed by OK

> start script, waiting for response immediately
> start sending "AT+CGMI"
> receive "+CEREG 1,0" while sending
> script accepts "+CEREG 1,0" as the response to "AT+CGMI"
> "AT+CGMI" sent
> receive "QUECTEL BG95"
> receive "OK"

script handler got "+CEREG 1,0" instead of "QUECTEL BG95"

After this PR:

> start script
> start sending AT+CGMI
> receive "+CEREG 1,0" while sending
> "AT+CGMI" sent
> start waiting for response
> receive "QUECTEL BG95"
> script accepts "QUECTEL BG95" as response to "AT+CGMI"
> receive "OK"

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-15 15:11:42 +01:00
Nick Ward
00cfab6cfc mgmt: mcumgr: use delayed workqueue for reset
Same behaviour, less code, smaller code size.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2024-01-15 09:59:23 +01:00
Jonathan Rico
75c2aeb8bd Bluetooth: L2CAP: stop stealing buffers from SDU pool
It seems like a nice idea at first, but leads to hard-to-debug
situations for the application.

The previous behavior can be implemented by the app by defining
`alloc_seg` and allocating from the same pool as `buf`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-15 09:58:58 +01:00
Krzysztof Chruściński
5bafa25e13 logging: Use strings stripping for dictionary backends
Enabled by default strings stripping for dictionary based
backends.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:58:39 +01:00
Krzysztof Chruściński
b9bf596b34 logging: Fix LOG_FMT_SECTION_STRIP Kconfig dependency
Strings stripping was disallowed when LOG_OUTPUT was used. However,
there is a dictionary log_output module which could work with stripped
strings. Dependency is changed to LOG_DICTIONARY_SUPPORT.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:58:39 +01:00
Krzysztof Chruściński
c9e2975a96 logging: log_cmds: Add support for frontend runtime filtering
Add support for controlling runtime filtering for frontend.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:57:54 +01:00
Krzysztof Chruściński
b819b51fe7 logging: Add support for runtime filtering in frontend
So far frontend supported only compile time filtering. Adding
support for runtime filtering. From runtime filtering perspective
frontend is treated similar to any other backend but since
it is a singleton it has fixed ID.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:57:54 +01:00
Manuel Schappacher
bff6054cb8 net: gptp: Always use GM PRIO root system id for announce messages
A problem occurred while running PTP on a multi-port target
(RENESAS RZT2M) with two ports enabled. Announce messages on the
switched devices master port always contained local clock information
instead information from received on the slave port from the better
GM clock. Depending on the BMCA config this turned into having more
than one GM in the system.

Sending always the locally stored GM information helped to overcome
this issue.

Signed-off-by: Manuel Schappacher <manuel.schappacher@hs-offenburg.de>
2024-01-15 09:57:34 +01:00
Ajay Parida
fc959fce47 net: shell: Early wake up for TWT power save
Provision of configurable parameter for generating unblock event
ahead of TWT slot. Host application depending upon latencies can
configure this to wakeup rpu ahead of the TWT slot.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-12 15:56:56 -05:00
Pavel Vasilyev
27b1f4eb7f Bluetooth: Mesh: Fix dereferencing before null pointer check
Don't dereference pointer until it is checked on NULL.

Fixes: #66805
Coverity-CID: 338098

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-12 11:28:59 -06:00
Daniel DeGrasse
76f547e763 net: l2: wifi: wifi_utils: Resolve build warning with strncpy function
ARM GCC version 12.2.0 (Zephyr SDK 0.16.4) generates the following build
warning from the strncpy call in "wifi_utils_parse_scan_bands":

warning: '__builtin_strncpy' output truncated before terminating nul
copying as many bytes from a string as its length

To resolve this warning, pass the maximum length of the temporary
parse_str buffer to strncpy. This also has the benefit of correctly null
terminating parse_str, since we already verify the
scan_bands_str is properly null terminated with the strlen() check in
this function. We can therefore remove the line adding a null terminator
to parse_str as well.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-01-12 12:55:35 +01:00
Vinayak Kariappa Chettimada
7f99677aa6 Bluetooth: Controller: Add support for DYNAMIC_INTERRUPTS
Add support for DYNAMIC_INTERRUPTS and ARM specific
DYNAMIC_DIRECT_INTERRUPTS.

Co-authored-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-12 11:16:08 +01:00
Vinayak Kariappa Chettimada
2b30259e9f 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.

This reverts commit 91781306e9 ("Revert "Bluetooth:
Controller: Fix ull_prepare_dequeue for skipped events"").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-12 10:03:07 +01:00
Yuval Peress
a9afc5a7b8 emul: Add support for non-bus emulators
Adds a stub API for a non bus emulators. The stub is used to keep the
rest of the emulation consistent.

Signed-off-by: Yuval Peress <peress@google.com>
2024-01-12 09:59:31 +01:00
Ajay Parida
56de0a347e net: mgmt: Provide Regulatory channel info
Updated to provide regulatory channel information along with country
code.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-12 09:59:19 +01:00
Ajay Parida
3053484dcb net: mgmt: Update app of TWT teardown status
Update user/app status of TWT teardown sessions.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-11 15:42:50 -06:00
Chaitanya Tata
2ce295b71e wifi: shell: Fix missing case sensitivity
This was missed in earlier that tried to fix all string comparisons to
use case insensitive comparison.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 15:38:42 -06:00
Kapil Bhatt
d8c362253d net: wifi_shell: Add example of scan option
Add an example of the scan's -c parameter
to help with understanding.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-11 16:14:46 +00:00
Emil Gydesen
79af154ae7 tests: bsim: Bluetooth: CAP broadcast AC testing
Add testing of the Audio Configurations from the BAP spec using
the CAP API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-11 16:13:00 +00:00
Pisit Sawangvonganan
1270bce4d8 modem: modem_cmux: optimize modem_cmux_transmit_frame to save ROM
This optimization aggregates frame headers before adding to the ring buffer
and computes the FCS of the frame header in one operation.
This approach improves execution efficiency and reduces memory footprint.
This code adjustment aligns with the changes proposed in https://github.com/zephyrproject-rtos/zephyr/pull/67062.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-11 16:10:37 +00:00
Bjarki Arge Andreasen
4d99c69e4a modem: backend: tty: Implement transmit idle event
Implement transmit idle notification for TTY backend. Since TTY
has an "infinite" transmit buffer, we invoke transmit idle
immediately after writing the data to the TTY file.

The test suite for the TTY backend has been updated to match the
new behavior.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-11 16:09:44 +00:00
Bjarki Arge Andreasen
8c6a9ee594 modem: backend: uart: Implement transmit idle event
Make async and interrupt driven UART backends notify transmit
idle when transmit is idle.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-11 16:09:44 +00:00
Bjarki Arge Andreasen
516af3cb84 modem: pipe: Add TRANSMIT_IDLE event
Add transmit idle event to modem_pipe_event enum. This will
allow modules to await transmit idle before trying to transmit
more data, instead of blindly calling modem_pipe_transmit in
a loop until all data has been accepted.

This will reduce the time spent trying to transmit data while
the backend is blocked.

Similarly to the RECEIVE_READY event, backends will call
modem_pipe_notify_transmit_idle() to indicate that transmit
is idle, and the TRANSMIT_IDLE event will be reinvoked when
the modem pipe is attached to synchronize the state of the
pipe with the user of it.

Additionally, the TRANSMIT_IDLE event is also invoked when the
modem is opened to further help synchronization with the user
of the pipe.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-11 16:09:44 +00:00
Jukka Rissanen
b8708ee781 net: tcp: Fix the CONFIG_NET_TCP_RETRY_COUNT help text
The help text was incorrect, we return -ETIMEDOUT instead
of -ECONNRESET when retransmission timeout occurs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-11 10:26:47 -05:00
Guennadi Liakhovetski
b53a792ff0 llext: enable tristate Kconfig options
kconfiglib.py has a hard dependency on CONFIG_MODULES to support 'm'
values for tristate Kconfig options. It's a logical companion for
but can also be used with other configurations.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-01-11 10:26:04 -05:00
Bjarki Arge Andreasen
3debfc8c8d modem: cmux: Simplify resync mechanism
Some modems don't start sending resync flags as described in
3G TS 27.010 V2.0.0 5.2.5, which results in the CMUX being
stuck in resync mode for said modems.

This patch simplifies the resync mechanism to simply drop
invalid frames, and wait for atleast two consequtive frame
flags (stop+start).

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-11 13:53:25 +01:00
Jonathan Rico
1e6ff5ff05 Bluetooth: L2CAP: separate BR/EDR and LE internal headers
Extract BR/EDR definitions from `l2cap_internal.c` into its own headers:
one for the interface with l2cap.c and one for the rest of the BR/EDR
stack.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-11 10:04:53 +01:00
Jonathan Rico
19da13313d Bluetooth: L2CAP: remove usage of bt_l2cap_send_cb by BR/EDR
Isolates BR/EDR's l2cap use from LE (most of l2cap.c).

Why? Because I'm refactoring l2cap.c and don't want to accidentally
break BR/EDR support, as there are very few tests in CI.

This way, once `bt_l2cap_chan_send` hands control to l2cap_br.c, it will
not call back into l2cap.c, it will instead be a parallel layer going
directly to conn.c.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-11 10:04:53 +01:00
Chaitanya Tata
918e08fda8 wifi: shell: Add a shell command to list stations
In AP mode maintain the database of connected stations based on the
Wi-Fi management events and dump the list.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Chaitanya Tata
725c13bafb wifi: ap: Add client side events
These are helpful to track clients being added and deleted.
Applications can actions based on these events.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Chaitanya Tata
2703955aee wifi: ap: Add status events
These events communicate the status of AP mode operations (enable or
disable) with few pre-defined enumerations.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Chaitanya Tata
09e1ed039a wifi: Fix duplication
Use a common set of events and then add specific ones as per the
configuration.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Kapil Bhatt
773ebe9c41 net: wifi_shell: Update scan argument shell
Update the example of scan -c argument.
Default value for max channels is set to 3,
So, update the example according to that.
Add closing bracket in -s.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-10 20:56:32 -05:00
Kapil Bhatt
3e8dbaf75f net: wifi_utils: Fix max channels allow for scan
Fix the maximum channels allow for scan command
input.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-10 20:56:32 -05:00
Simon Walz
38aa4d5169 net: lwm2m: add gateway callback to handle prefixed messages
Adding a callback for handling lwm2m messages with prefixed paths defined
by the gateway object. If CONFIG_LWM2M_GATEWAY_OBJ_SUPPORT is set,
each path is checked for the prefix stored in the object instances of the
gateway object 25. If prefixes match the msg is passed to the gw_msg_cb.

Signed-off-by: Simon Walz <simon.walz@autosen.com>
2024-01-10 18:22:21 +00:00
Jonathan Hamberg
9c1a45cc00 posix: Fix name collision with __bswap
__bswap_ in zephyr/sys/byteorder.h conflicts with __bswap_ in host's
byteswap.h. byteswap.h from host compiler used in posix_native_64 boards
causes a compilation issue.

This commit renames __bswap_ to BSWAP_ to prevent collision.

Before this commit a compilation error can be created by adding #include
<byteswap.h> to samples/net/sockets/echo/src/socket_echo.c

This does not change external API to byteorder.h, but does change
internal implementation which some other source files depend on.

Replaced manual byteswap operations in devmem_service.c with APIs from
byteorder.h which automatically converts to CPU endianess when necessary.

Fixes #44324

Signed-off-by: Jonathan Hamberg <jonathanhamberg@gmail.com>
2024-01-10 18:13:44 +00:00
James Zipperer
273165c3bb usb: device: audio: fix compiler warning for usb audio microphone
audio_receive_cb is only used by headphones and headset, it is unused in
microphone-only configurations.  Gate compilation based on the device
tree.

Signed-off-by: James Zipperer <jzipperer@fb.com>
2024-01-10 15:08:06 +01:00
James Zipperer
975208209b usb: device: audio options for polling-interval and sample-rate-hz
These descriptor values can now be configured via the device tree

Signed-off-by: James Zipperer <jzipperer@fb.com>
2024-01-10 15:08:06 +01:00
Shane Snover
e49d174be9 driver: usb: change function parameter name from class to base_class.
Change function parameter name in function usbd_device_set_code_triple
from `class` to `base_class` as `class` is a keyword in C++.

Signed-off-by: Shane Snover <ssnover95@gmail.com>
2024-01-10 11:08:11 +01:00
Alberto Escolar Piedras
bd9836be8c subsys logging: Enable native backend if possible
Let's always enable the native_posix backend even
if the serial is used.
Both can be used at the same time, and:
a) users expect the logger output in the invoking shell even if they
enable the UART
b) Since printk is routed to the logger twister actually needs it
for tests to pass as for native platforms it looks into the stdout
of the process.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-10 10:01:37 +01:00
Daniel DeGrasse
1c0b114bf8 sd: add timeout when taking SD card lock for data operations
Previously, if an SD I/O operation was attempted while another thread
held the mutex for the SD card, the I/O operation would simply fail. Add
a timeout to k_mutex_lock calls within the SD subsystem, so that
multithreaded access to the SD card instead blocks until the SD card is
available for I/O

Fixes #66211

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-01-09 15:46:54 -06:00
Anas Nashif
91841587d6 ztest: fix ztest_run_test_suite usage and macros
Fix usage of ztest_run_test_suite that was missed when introducing shell
support.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-01-09 08:15:22 -05:00
Jukka Rissanen
35e1df6bb4 tests: net: tcp: Add support for close callback
Add a function callback that is called when the TCP connection
is closed. This is only available if doing network tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-09 10:03:08 +01:00
Jukka Rissanen
b214207d91 net: tcp: Reschedule FIN timer when entering FIN state
The FIN timer was not set when we entered the FIN_WAIT_1 state.
This could cause issues if we did not receive proper packets
from peer. With this fix, the connection is always terminated
even if peer does not respond.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-09 10:03:08 +01:00
Jukka Rissanen
40215e07a3 net: tcp: Install a last ack timer in passive close
If we are in a passive close state, then it is possible that
the ack we are waiting is lost or we do not accept the one peer
sent to us because of some earlier out of memory issue.
So install a timer (using by default the FIN timer value) to
close the connection if the last ack is not received on time.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-09 10:03:08 +01:00
Daniela Andreea Dumitrache
3bfb2e3ab2 Bluetooth: Audio: Add implementation for PBP and dedicated sample apps.
PBP API allows sources to create a Public Broadcast Announcement.
PBP API to parse a Public Broadcast Announcement.

public_broadcast_source application starts extended advertising and
includes a Public Broadcast Announcement. The advertised broadcast
audio stream quality will cycle between high and standard quality.

public_broadcast_sink application scans for broadcast sources and
synchronizes to the first found source which defines a Public Broadcast
Announcement including a High Quality Public Broadcast Audio Stream
configuration.

Add bsim tests for Public Broadcast Profile APIs.

Add shell implementation for Public Broadcast Profile APIs.

Signed-off-by: Daniela Andreea Dumitrache <danielaandreea.dumitrache@nxp.com>
2024-01-09 09:59:23 +01:00
Anas Nashif
afc319e3fa ztest: shell: add shell support
- Support for listing both testcases and testsuites
- Support for running single suites or single test cases
- Support shuffling tests and repeating execution based on command line
  arguments.

For example, build with

west build -p  -b qemu_cortex_m3  tests/kernel/sleep   -t run -- \
-DCONFIG_ZTEST_SHUFFLE=y -DCONFIG_ZTEST_SHELL=y

Following commands are available:

uart:~$ ztest
ztest - Ztest commands
Subcommands:
  run-all          :Run all tests
  shuffle          :Shuffle tests
  list-testsuites  :List all test suites
  list-testcases   :List all test cases
  run-testsuite    :Run test suite
  run-testcase     :Run testcase

shuffle accepts two arguments --suite_iter and --case_iter which allows
repeated exercution of testcases or suites.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-01-09 09:58:57 +01:00
Anas Nashif
37529505ad ztest: remove old file
This c file is not being used anymore, so remove it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-01-09 09:58:57 +01:00
Flavio Ceolin
3267bdc4b7 fs: fuse: Avoid possible buffer overflow
Checks path's size before copying it to local variable.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-01-08 13:29:19 -05:00
Håvard Reierstad
6c5fc658ef Bluetooth: Mesh: suspend/resume gatt advs
Disables pb gatt- and gatt proxy advs when suspending Mesh, and
enables them again when resuming Mesh.

Adds `bt_mesh_adv_gatt_send` to `bt_mesh_resume` to make sure that
GATT advs start after resumption.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-01-08 13:21:58 -05:00
Håvard Reierstad
9285ea3238 Bluetooth: Mesh: fix proxy srv return value
Previously, `bt_mesh_proxy_gatt_enable` returned the return value from
`k_work_schedule`, which could be a positive (non-error) message.
Now, it only returns negative error codes (else 0).

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-01-08 13:21:58 -05:00
Piotr Pryga
4d0ef142f3 Bluetooth: services: Add HRS notification changed app callback
It is useful for an application to be informed when there is
a subscriber waiting for HRS service notification.
Extend HRS service API and add required code to service implementation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2024-01-08 15:34:20 +02:00
Chaitanya Tata
9e6542b0cc wifi: shell: Use case insensitive comparison
The help text uses the capital case as its an acronym, but passing
capital case fails. Also extend that to others as well.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
66f63455ea shell: Add a space after colon
Just a cosmetic change, but IMHO the help looks much better now :).

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
352ee50af7 wifi: shell: Fix the inconsistency in commands separation
For better readability, below rules will help:

 * Each command should be separated by a newline
 * Each command should end with a full stop (intermediate statements
   shouldn't have full stops)

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
7e7dc76296 wifi: shell: Remove the unnecessary text
The parameters heading is implied and doesn't have the newline, so, just
remove it.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
352f63c909 wifi: shell: Fix the help for reg domain
Separate the two optional parameters and add help.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
467a89e6a4 wifi: shell: Remove the unnecessary text in scan
We are using standard notation to differentiate optional and mandatory,
so, no need for a heading.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
30c492d5de wifi: shell: Fix help for PS command
Clearly mark the args as optional.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
9b55802d98 wifi: shell: Fix optional arg count for connect
Fix an extra optional arg.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata
0044640be6 wifi: shell: Fix the arg count for reg domain
Missed accounting for "-f" option.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Bjarki Arge Andreasen
b3971d0112 modem: cmux: Add DLCI receive buffer overrun LOG WRN
DLCI receive buffer may overrun if data is not processed fast
enough. This error was not reported before this patch, resulting
in unexplained missing bytes.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-05 14:30:56 +01:00
Jonathan Rico
79e86472c3 Bluetooth: L2CAP: clarify BT_L2CAP_STATUS_OUT
Makes it clearer what that bit means:
If set, the channel has capacity to send at least one PDU.

If unset, the channel ran out of credits and won't be able to send
anything until the peer sends credits back.

Also add debug logs.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-05 14:30:18 +01:00
Jonathan Rico
61f834ee67 Bluetooth: L2CAP: don't use bt_l2cap_send internally
Prevents confusion, as the similarly-named `l2cap_send()` also unrefs the
buffer if it fails to send.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-05 14:30:18 +01:00
Fang Huang
37305fa06b logging: mipi_syst: Add CONFIG_LOG_MIPI_SYST_DISABLE_TIMESTAMP
This adds user configurable CONFIG_LOG_MIPI_SYST_DISABLE_TIMESTAMP
Kconfig option to use it for macro MIPI_SYST_PCFG_ENABLE_TIMESTAMP.
Moving macro definition of MIPI_SYST_PCFG_ENABLE_TIMESTAMP from
mipi-sys-t library to platform.h which defaulted to undef.
CONFIG_LOG_MIPI_SYST_DISABLE_TIMESTAMP gives flexibility to users
when needn't use mipi-sys-t protocol timestamp.

Signed-off-by: Fang Huang <fang.huang@intel.com>
2024-01-05 06:40:09 -05:00
Emil Gydesen
87c8b897b3 include: util: Add mem_xor functions
Add functions to do XOR on arrays of memory, with one that
takes arbitrary sizes and one for 32 bits and 128 bits as
those are common sizes for this functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-05 09:06:36 +01:00
Juha Ylinen
7c53fa86ff net: lwm2m: Fix deadlock when calling lwm2m_engine_pause()
lwm2m_engine_pause() caused deadlock if it was called within
engine thread.

Remove while loop from lwm2m_engine_resume().

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-05 09:06:27 +01:00
Juha Ylinen
85dfe3df14 net: lwm2m: Delay triggering registration update
Add short delay before triggering registration update. This allows
postponing the update from application side if needed.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-05 09:06:27 +01:00
Erik Brockhoff
5f99c36ca1 Bluetooth: controller: fix procedure collision handling
If an instant based remote procedure 'overtakes' a local ditto
the local procedure will be 'completed' by remote rejection
but collision flag would not get set ensuring that a new local
conflicting procedure cannot be started before the remote is completed.
This can thus lead to invalid local initiation.

Added unittest to cover case

Fix by ensuring collision flag is set also in the above mentioned
scenario.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-01-05 09:05:26 +01:00
Rodrigo Peixoto
c992707251 zbus: add priority boost feature
Replace mutexes with semaphores to protect the channels in conjunction with
a priority boost algorithm based on the observers' priority.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-01-04 09:41:54 +01:00
Jukka Rissanen
8d3d48e057 net: ipv6: Check that received src address is not mine
Drop received packet if the source address is the same as
the device address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 19:00:33 +00:00
Robert Lubos
898aa9ed9a net: sockets: tls: Align DTLS connect() behavior with regular TLS
DTLS socket is not really connection-less as UDP, as it required the
DTLS handshake to take place before the socket is usable. Therefore,
align the DTLS connect() behavior with regular TLS.
The change is backward compatible. connect() call is still optional for
DTLS socket (the handshake can still take place from send()/recv()) and
a socket option was provided to disable DTLS handshake on connect().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos
c0d5d2fbd5 net: sockets: tls: Allow handshake during poll()
When using DTLS socket, the application may choose to monitor socket
with poll() before handshake has been complete. This could lead to
potential crash (as the TLS context may have been left uninitialized)
and unexpected POLLIN reports (while handshake was still not complete).
This commit fixes the above - POLLIN will only be reported once
handshake is complete and data is available

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos
0a1bee48bf net: sockets: tls: Improve POLLERR error reporting
In case a socket error was caused by TLS layer, it was not reported with
POLLERR. This commit fixes this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos
5b3b462eed net: sockets: tls: Add flag indicating that session is closed
In case TLS session is closed at the TLS level (and thus recv() reports
0 to the application) a certain race occurs between consecutive recv()
call, and TCP session teardown. As mbedtls_ssl_read() only reports
session close upon receiving CLOSE alert, consecutive non-blocking
recv() calls would report EAGAIN instead of connection closed, if called
before underlying TCP connection was closed.

Fix this, by storing the information that TLS session has ended at TLS
socket level. The new flag will be checked before attempting further
mbed TLS actions, so that connection status is reported correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos
1dc9028316 net: sockets: tls: Add function to obtain underlying ssl context
For test purposes only. Should not be used in regular applications.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Bjarki Arge Andreasen
48fa603da3 modem: cmux: Patch resync mechanism
The CMUX resync mechanism can get stuck between states
MODEM_CMUX_RECEIVE_STATE_RESYNC_0 and
MODEM_CMUX_RECEIVE_STATE_RESYNC_1 if the resync flags, which are
sent only once in state MODEM_CMUX_RECEIVE_STATE_SOF, are not
responded to, or the response is lost.

This patch ensures resync flags are sent from states
MODEM_CMUX_RECEIVE_STATE_SOF, MODEM_CMUX_RECEIVE_STATE_RESYNC_1
and MODEM_CMUX_RECEIVE_STATE_RESYNC_2 if its determined that the
resync flags are not being responded to.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 18:58:39 +00:00
Bjarki Arge Andreasen
3ebe814294 modem: chat: Patch invalid dereference
The chat module contains an array of three lists of matches,
one of which are static, two of which are contained within the
currently running script. The current match, which is an
object stored in one of the three lists, is stored in its own
pointer in the chat module context.

A memory error occurs when the script is stopped, while the
chat module is using one of the matches stored withing the
script. This commit clears the match pointer when the script
is stopped if the match is stored within the script.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 18:57:55 +00:00
Jukka Rissanen
ec42d825ec net: context: Fix the v4 mapped address handling in sendto
If we receive a IPv4 packet to v4 mapped address, the relevant
net_context is bound to IPv6. This causes issues if we try
to get the family from the context struct in sendto.
Fix this by checking if the destination address is IPv4 but
the socket is bound to IPv6 and v4 mapping is enabled.
If all these criterias are set, then set the family of the
packet separately and do not get it from net_context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 12:55:14 +01:00
Jukka Rissanen
8f97c1c2ee net: lib: sockets: Initialize iovec to 0 at start of func
Make sure iovec is initialized to a value so that there
is no possibility that it is accessed uninitialized.

Fixes: #66838
Coverity-CID: 334911

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 10:19:50 +01:00
Jukka Rissanen
4e5ef76b15 net: lib: mdns_responder: Fix interface count check
The original idea was to check that we have enough network
interfaces in the system. The check needs to verify max IPv4
and IPv6 supported interfaces instead of always checking
IPv6 one.

Fixes: #66843
Coverity-CID: 334899

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 10:19:38 +01:00
Tomi Fontanilles
6564e8b756 modem: cmux: fix frame data length encoding
In cases where the data is bigger than 127 bytes,
the first bit of the second byte of the data length field
used to always be set.

This is wrong as according to the 3GPP 27.010 spec
only the first bit of the first byte is the EA bit;
all the others denote the data length.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-01-02 10:10:55 +01:00
Fabio Baltieri
a3e39cb0e5 logging: make CONFIG_LOG_ALWAYS_RUNTIME build check less ambiguous
When these fails the compiler just prints "Option must be enabled" with
no reference to what option, so one has to look at the code to find out.
Mention the actual option in the error to make these unambiguous.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-02 10:10:49 +01:00
Mariusz Skamra
b79a3415a9 Bluetooth: audio: has_client: Move bt_has_client structure to header
This moves bt_has_client instance structure to has_internal.h header
file to be able to access to the instance members in tests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2024-01-02 10:10:15 +01:00
Kai Meinhard
70ae47587a LOG: DICT: Forward the User Context Void pointer to backend
The dictionary logging passed the full log_output structure
to the backend instead of the user context void pointer.

Signed-off-by: Kai Meinhard <meinhard@gessler.de>
2024-01-02 10:09:27 +01:00
Armin Brauns
fdea851878 task_wdt: start feeding hardware watchdog immediately after init
Without this, the hardware watchdog would expire if no task watchdogs were
registered within one hardware watchdog period after init. Start the
background channel immediately after init to avoid this.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2024-01-02 09:52:13 +01:00
Seppo Takalo
dc6e7aa4b1 net: lwm2m: Add transmission state indicator to RX as well
Refactored the socket state indication into its own function
that checks the state of TX queues as well as number of
pending CoAP responses.
Check the state after receiving a packet, as it might
have been a last Ack packet we have been waiting.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-27 16:07:59 +00:00
Dawid Niedzwiecki
d64ce2531d mgmt: ec_host_cmd: add PM for SPI STM32 backend
The SPI STM32 Host Command backend doesn't use general SPI driver, so it
has to implement Power Management on its own.

The suspend procedure includes: setting pins to the sleep state,
disabling device clock and disabling CS pin interrupt.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-12-27 15:59:32 +00:00
Hang Fan
915f0fd74c Bluetooth: Shell: Fix coverity issue in cmd_adv_data
Fix wrong parameter type to avoid Unsigned compared against 0

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

Signed-off-by: Hang Fan <fanhang8@gmail.com>
2023-12-27 12:36:23 +02:00
Emil Gydesen
547ffdab6e Bluetooth: MICP: Add mic_ctlr_get_by_conn
Add function to get a MICP microphone controller
instance from a connection pointer. This is effectively
the reverse of bt_micp_mic_ctlr_conn_get, and works similar to
bt_vcp_vol_ctlr_get_by_conn.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-22 14:41:17 +00:00
Mariusz Skamra
2bb8855467 Bluetooth: audio: tbs: Add call_alloc/call_free helper functions
This removes duplicated code by adding helper functions to allocate
and free bt_tbs_call objects.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-22 14:41:00 +00:00
Mariusz Skamra
1894fa1979 Bluetooth: audio: tbs: Simplify bt_tbs_set_signal_strength function
Simplify the function flow, by sending the signal strength notification
in one place, the reporting_interval_work handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-22 14:41:00 +00:00
Mariusz Skamra
b728ff9ed3 Bluetooth: audio: tbs: Factor out GTBS and TBS common code
This refactors the code to remove code duplicates by creating common
tbs_inst object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-22 14:41:00 +00:00
Seppo Takalo
071cad2e76 net: lwm2m: Deprecate lwm2m_get/set_u64
Deprecate lwm2m_set_u64() and lwm2m_get_u64 as only
LWM2M_RES_TYPE_S64 exist. Unsigned variant is not defined.

Technically these might have worked OK, but it is undefined
what happens to large unsigned values when those are
converted to various payload formats (like CBOR) that might
decode numbers differently depending of their signedness.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-22 09:54:07 +01:00
Jukka Rissanen
1a0b6745bd net: shell: Print more Ethernet statistics
Various Ethernet error statistics values were not printed
by the shell.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-22 09:53:26 +01:00
Jonas Woerner
2842f206eb Bluetooth: Host: add hci error to errno translation for INVALID_PARAM
now returns -EINVAL if invalid parameters a are supplied

Signed-off-by: Jonas Woerner <github@bolake.de>
2023-12-22 09:52:29 +01:00
Magdalena Kasenberg
e05d964b46 bluetooth: audio: broadcast: Fix missing update of meta_len
The length of the updated metadata was not updated.
Fixes the CAP/INI/BST/BV-13-C test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-12-21 17:18:09 +00:00
Benedikt Schmidt
4c731f27c6 shell: modules: do not use k_thread_foreach with shell callbacks
Always use k_thread_foreach_unlocked with callbacks which print
something out to the shell, as they might call arch_irq_unlock.
Fixes #66660.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-12-21 10:01:08 +00:00
Jordan Yates
1ef0ec55c9 net: ip: dhcpv4: remove address on interface down
Any received address is no longer valid once the interface goes down.
Leaving the address assigned results in the L4 interface transitioning
through the following on reconnection:
 UP: Interface is connected
 DOWN: Old address is removed by DHCP
 UP: New address is re-added by DHCP

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-21 09:18:32 +01:00
Jordan Yates
434c93ddfb net: conn_mgr: output events as hex
Networking events are masks of bits, which are almost impossible to read
as decimal, and trivial to read as hex. Also unifies the format string
across multiple outputs for some flash savings.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-21 09:18:32 +01:00
Jukka Rissanen
19392a6d2b net: ipv4: Drop packet if source address is my address
If we receive a packet where the source address is our own
address, then we should drop it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-21 09:18:24 +01:00
Jukka Rissanen
6d41e68352 net: ipv4: Check localhost for incoming packet
If we receive a packet from non localhost interface, then
drop it if either source or destination address is a localhost
address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-21 09:18:24 +01:00
Aleksander Wasaznik
700f640948 Bluetooth: ATT: Reject read-by-uuid rsp outside range
A bad peer responding to read-by-uuid can return handles outside the
requested range. This confuses the stack. In particular, the "continue"
and "end" logic in the same function relies on this assumption.

This bad peer was a real issue at UPF, and it caused an infinite loop
during discovery.

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

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-21 09:18:14 +01:00
Seppo Takalo
6161fbdf21 net: lwm2m: Transmission state indications
Allow engine to give hints about ongoing CoAP transmissions.
This information can be used to control various power saving
modes for network interfaces. For example cellular networks might
support release assist indicator.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-20 11:57:48 +00:00
Seppo Takalo
0d650ffd26 net: lwm2m: Update TX timestamp on zsock_send()
In slow networks, like Nb-IOT, when using queue mode,
there might be significant delay between the time we
put the packet into a transmission queue and the time
we actually start transmitting.
This might cause QUEUE_RX_OFF state to be triggered earlier
than expected. Remedy the issue by updating the timestamp on the
moment where packet is accepted by zsock_send().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-20 11:57:48 +00:00
Seppo Takalo
01568b573a net: coap: Add API to count number of pending requests
Add coap_pendings_count() that return number of waiting
requests on the pendings array.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-20 11:57:48 +00:00
Robert Lubos
9aba4e8f3d net: sockets: tls: Read the actual error on interrupted wait
In case a waiting TLS socket reports an error in the underlying poll
call, try to read the actual error from the socket, instead of blindly
returning -EIO in all cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-20 11:10:57 +01:00
Johan Hedberg
3fbf12487c kernel: Introduce a way to specify minimum system heap size
There are several subsystems and boards which require a relatively large
system heap (used by k_malloc()) to function properly. This became even
more notable with the recent introduction of the ACPICA library, which
causes ACPI-using boards to require a system heap of up to several
megabytes in size.

Until now, subsystems and boards have tried to solve this by having
Kconfig overlays which modify the default value of HEAP_MEM_POOL_SIZE.
This works ok, except when applications start explicitly setting values
in their prj.conf files:

$ git grep CONFIG_HEAP_MEM_POOL_SIZE= tests samples|wc -l
     157

The vast majority of values set by current sample or test applications
is much too small for subsystems like ACPI, which results in the
application not being able to run on such boards.

To solve this situation, we introduce support for subsystems to specify
their own custom system heap size requirement. Subsystems do
this by defining Kconfig options with the prefix HEAP_MEM_POOL_ADD_SIZE_.
The final value of the system heap is the sum of the custom
minimum requirements, or the value existing HEAP_MEM_POOL_SIZE option,
whichever is greater.

We also introduce a new HEAP_MEM_POOL_IGNORE_MIN Kconfig option which
applications can use to force a lower value than what subsystems have
specficied, however this behavior is disabled by default.

Whenever the minimum is greater than the requested value a CMake warning
will be issued in the build output.

This patch ends up modifying several places outside of kernel code,
since the presence of the system heap is no longer detected using a
non-zero CONFIG_HEAP_MEM_POOL_SIZE value, rather it's now detected using
a new K_HEAP_MEM_POOL_SIZE value that's evaluated at build.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-12-20 11:01:42 +01:00
Mario Paja
98336b2811 Revert "net: gptp: Fix announce message len"
This reverts commit 6b644dff67.

Reason: breaks Peer-to-Peer gPTP connection. A better solution should be
found to handle the optional TLV on the announce message (chapter 10.5.1
IEEE 802.1AS-2011)

Signed-off-by: Mario Paja <mario.paja@zal.aero>
2023-12-19 22:51:52 +00:00
Aleksandr Khromykh
ac4cfe9880 Bluetooth: Mesh: remove 20ms tx delay in adv bearer
The recommendation to have 20ms is fair for two
consecutive messages over a single bearer. When mesh
sends two messages it can be interpreted as two
bearers working in parallel. No need to keep
an artificial 20ms delay for that. Delay was
removed and all related bsim tests were fixed.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-12-19 16:20:36 +01:00
Pieter De Gendt
276ae6c573 mcumgr: transport: smp_udp: Start socket on interface UP
The implementation waited for a NET_EVENT_L4_CONNECTED event to be
emitted. However we can start the receiving thread in case the interface
is up.

This allows for IPv6 Link Local addresses to be used with mcumgr.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-19 08:51:34 +01:00
Emil Gydesen
8df987935b Bluetooth: MPL: Add track position notifications during seeking
When seeking the media player should notify clients about the
track position change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-19 08:51:21 +01:00
Emil Gydesen
cda5e58aa5 Bluetooth: CAP: Commander discovery support
Implement the CAP Commander discovery function.

Adds support for it in the shell.

This includes initial babblesim and unit testing as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-19 08:50:40 +01:00
Erwan Gouriou
54d7793e82 drivers: bluethooth: stm32wba: Add HCI driver for STM32WBA
Add HCI Driver for STM32WBA devices.
Based on B91 HCI driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-12-18 17:31:08 +00:00
Fabio Baltieri
e51a877a90 bluetooth: shell: match cmd_conn_phy_update conditions
The condition for channel-map are CONFIG_BT_CENTRAL ||
CONFIG_BT_BROADCASTER, change the corresponding handler ifdef so that
it's included in the build if CONFIG_BT_BROADCASTER is enabled but
CONFIG_BT_CENTRAL is not.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-18 17:29:02 +00:00
Chaitanya Tata
6152e64aa0 wifi: shell: Fix arg count for regulatory domain
Regulatory domain supports both get and set, so, fix the argument
counts.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-18 17:46:12 +01:00
Aaron Ye
d385150bb0 drivers: bluetooth: Add Ambiq HCI driver for Apollo4 Blue Plus.
This commits create the dts binding for Ambiq BT HCI instance.
And create the SPI based common HCI driver for Ambiq Apollox
Blue SoC and the extended soc driver for HCI.

Signed-off-by: Aaron Ye <aye@ambiq.com>
2023-12-18 14:54:53 +01:00
Ruben Völl
2b83e91a43 mgmt: fs_mgmt: clear lock before return
Not clearing that lock lead to the fs_mgmt commands being useless, after
the mgmt callback returned `MGMT_CB_ERROR_RC` once, since the lock is now
occupied and never cleared.

Fixes #66581

Signed-off-by: Ruben Völl <ruben.voell@grandcentrix.net>
2023-12-18 11:17:00 +00:00
Mahesh Mahadevan
6cb1ff6560 pm: Move settting timeout to after suspending devices
pm_suspend_devices() could return an error. Set timeout using
sys_clock_set_timeout() to after this error is handled so that
we have the accurate power state when calling the timeout function.
This is useful in cases where we wish to compensate the
system timer for certain power modes.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-12-18 09:29:49 +01:00
Anders Storrø
f70929a8f1 tests: Bluetooth: Mesh: Add proxy adv coex test.
Adds test that verifies correct Proxy advertisement behavior for
a device where the Proxy adv requirements changes over time,
both for single and multiple subnets.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-18 09:29:41 +01:00
Anders Storrø
6c67ab3a63 Bluetooth: Mesh: Refactor proxy adv
Refactors proxy advertising implementation to allow fair sharing of
advertising resources between all subnets.

In the new implementation, each subnet is agnostic to any other subnet
that might have active proxy advertisement work. When proxy
advertisement is triggered, the implementation will first check how
many subnets that has active work. If there are more than one active
subnet, a maximum timeslot will be calculated to ensure that all active
subnets get access to the medium. The implementation will then poll
the next eligible subnet for a proxy advertising request. If the
duration of this request exceeds the maximum timeslot, the duration
for the next advertisement will be set to the maximum value.

If a proxy advertisement for a subnet is interrupted by other
advertising activity, the implementation will now ensure that the
interrupted proxy adv continues from the point where it was
interrupted so that the subnet gets to utilize the entire allocated
timeslot.

This PR also alters the priv_proxy_net_id_multi Bsim test to align
with the refactored proxy advertising scheme.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-18 09:29:41 +01:00
Pavel Vasilyev
fe70e50d41 Bluetooth: Mesh: Added support for randomly delaying publications
The section 3.7.3.1 of the mesh specification recommends to delay
a message publication in certain cases:
- at power-up or upon state change for a time between 20 to 500 ms
- for periodic publications for a time between 20 to 50 ms

This change implements this recommendation by adding the
`CONFIG_BT_MESH_DELAYABLE_PUBLICATION` Kconfig option which enables
the randomization code and by adding the `bt_mesh_model_pub.delayable`
bit field which allows each model decide whether the publications
should be delayed for this model or not.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-12-18 09:29:24 +01:00
Robert Lubos
b7e3ae2521 net: ipv6_mld: Silently drop MLDv1 queries
Zephyr does not support MLDv1 (which has a shorter header than MLDv2),
and this resulted in log errors being printed on header access if MLDv1
queries were received. Since receiving such packet is not really an
error, just drop it silently.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-18 09:28:42 +01:00
Pieter De Gendt
4807ada01e net: lib: coap: Use coap_transmission_parameters in coap_server
Update coap_service_send and coap_resource_send to take an optional
pointer argument to the newly introduced coap_transmission_parameters.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-18 09:28:25 +01:00
Chaitanya Tata
eaba47445a wifi: shell: Display RSSI only for station mode
RSSI makes sense only for modes that have a single peer, so, add a
station mode check.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-18 09:28:16 +01:00
Chaitanya Tata
9736cc7f29 wifi: shell: Fix AP argument checks and help
AP enable takes the same parameters as connect, so, update the help and
also fix the optional parameter count when security is involved.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-18 09:28:16 +01:00
Jonathan Rico
b83b9bede3 Bluetooth: ATT: call-back on buffer destroy
This is just as arbitrary as what was before, but simpler.

Before this change, the callback were invoked upon receiving the num
complete packets event.
This did not necessarily work with all spec-compliant controllers.

Now the callback is invoked as soon as the lower layer destroys the
buffer. ATT shouldn't care whether L2CAP sends it over RFC1149 or
something else after that point.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-15 17:14:56 +02:00
Jonathan Rico
a05a47573a Bluetooth: ATT: Internalize ATT PDU TX pool
Why?
- metadata is easier to manage as an array + index
  - less error-prone -> less memory-management bugs
- we can. because of the previous refactor
- PDU allocations are more predictable
- ATT buffer size can be optimized by app
- isolates ATT from the rest of the ACL users
  - decouples ATT PDU size from e.g. SMP w/ LESC

Drawbacks:
- higher memory usage
- kconfig change

The higher memory use is only temporary, as this will be followed-up
with more refactors that should bring it back down.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-15 17:14:56 +02:00
Flavio Ceolin
8977784afe settings: shell: Fix possible buffer overflow
Checks the size of the given string before copying it to internal
buffer.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-12-15 14:43:50 +01:00
Emil Gydesen
62ab25e3f5 Bluetooth: MPL: Make internal functions static
Several internal functions were not static.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
a8fbab6b1a Bluetooth: MPL: Simplify control point ops
Simplify how control point operations are handled, and
reduce code duplication.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
984e4213c1 Bluetooth: MPL: Simplify track and group changes
Simplify track and group changes by moving the
notifications into the functions that changes the states.

This removes some code duplication, and makes the code easier
to read, as well, as ensuring that notifications are always
sent.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
f138f7dd3e Bluetooth: MPL: Add mpl_set_state
Add the static function, mpl_set_state, to help set the playing
state of the media player.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
9616b3b182 Bluetooth: MPL: Use set_track_position more excessively
The set_track_position handles both correct clamping of the
position, as well as the notification, so use that instead
of setting the value and sending notifications manually.

Also adds a new function, set_relative_track_position,
to help set relative positions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Tomasz Moń
3e7368829b usb: device_next: uac2: interface descriptor macros
Add macros to initialize full set of descriptors required for USB Audio
Class 2 instance. Descriptors start with Interface Association
Descriptor that binds together the AudioControl interface and all
AudioStreaming interfaces.

AudioStreaming interfaces have alternate setting 0 without any endpoints
and alternate setting 1 with isochronous endpoint with max packet size
calculated on maximum sample frequency, number of channels, subslot size
and clock synchronization (asynchronous endpoints require +1 sample).

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-12-15 14:24:44 +01:00
Tomasz Moń
4f1b5b11b2 usb: device_next: uac2: devicetree descriptor macros
Initial set of macros to generate class specific descriptors based on
devicetree nodes. Descriptors are generated as uint8_t array initializer
list because there is variable number of entities in between standard
USB interface and endpoint descriptors. Because the descriptors are
automatically generated there is no real point in trying to generate
corresponding C structures (especially that some entity descriptors have
variably sized fields in the middle of descriptor, e.g. Clock Selector).

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-12-15 14:24:44 +01:00
Jamie McCrae
a48a594f13 mgmt: mcumgr: callback: Add op to receive callback
Adds the operation supplied by the client to the MCUmgr command
received callback

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2023-12-15 11:48:59 +00:00
Robert Lubos
0c095898fb net: shell: Prevent deadlock with net arp command
In case one of the networking shell backends is enabled, net arp command
could potentially trigger a deadlock, as it locks the ARP mutex before
TCP connection mutex, while TCP stack could do this in reverse order
(for instance when sending ACK or retransmission).

Mitigate this, by forcing a separate TX thread in such case, so that ARP
mutex is no longer accessed with TCP mutex locked.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-15 11:42:40 +00:00
Fredrik Danebjer
37e1a116ef bluetooth: shell: Fix stream_start_sine for single stream
Fixed the stream_start_sine function when omitting the all argument.
The verification of the sine checked reversed return value, and was
placed in incorrect order.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-12-15 11:42:26 +00:00
Mariusz Skamra
6e6311ebfb tests: Bluetooth: shell: Use BT_LE_CONN_PARAM_DEFAULT for connection
This basically reverts changes made by
9c8ec58beb.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-15 11:41:34 +00:00
Mariusz Skamra
d2745d6dba tests: Bluetooth: shell: Fix connection reference leak
This fixes regression introduced in recently.
Redundant connection reference is taken twice in connected()
callback. The redunant reference was then not returned, and
as a result we had a leak.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-15 11:41:34 +00:00
Juha Ylinen
d09d3d82ef net: lib: coap: Change coap_pending_init()
Replace function parameter 'retries' with pointer to structure
holding coap transmission parameters. This allows setting the
retransmission parameters individually for each pending request.

Add coap transmission parameters to coap_pending structure.

Update migration guide and release notes.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-12-15 11:41:27 +00:00
Flavio Ceolin
b16110587c pm: device_runtime: Avoid unnecessary work
Similar to what is done in pm_device_runtime_get,
we don't need to wait the device be suspended if
the work is still in the work queue. In this case
we just cancel the work and update the device state
to active.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-12-14 19:07:48 +00:00
Luca Burelli
4d86162989 llext: merge llext_mem and llext_section enums
The only difference in the two enums are some entries related to
relocation sections. However, these entries are not used in the
code, so they can be safely removed, along with the mapping function.

Use LLEXT_MEM_* to avoid confusion with low-level "section" names.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2023-12-14 19:06:55 +00:00
Jamie McCrae
bfb4794c36 retention: Increase read size variables to 16-bit
Increases 2 variables to be 16-bits instead of 8-bits to allow
for target read sizes, this would only be an issue if someone
changed the default retention block size from the default value
of 16 to a value over 256

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-12-14 19:05:22 +00:00
Arnaud Pouliquen
bf2bdcf6f7 ipc_service: open-amp: Fix libmetal shared memory registration
When using multiple instances of IPC static vring, each instance
should register its shared memory with a unique name.
Instead of a predefined default name, the name of the ipc instance
is reused for the metal device name.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2023-12-14 16:18:55 +02:00
Jukka Rissanen
b6aea97dc7 net: l2: dummy: Add start/stop API functions
The dummy L2 layer does not implement any L2 functionality
but it does not mean that it should not implement start/stop
functions that are called when the related network interface
is brought up or taken down.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-14 14:21:31 +01:00
Jukka Rissanen
d8ec9118b4 net: if: Interface stays down if device is not ready
It is pointless to take net interface up if the underlaying
device is not ready. Set also the interface status properly
in this case.

Fixes #65423

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-14 14:21:31 +01:00
Daniel DeGrasse
3091ddc4fe net: lib: lwm2m: use correct format specifier for LOG_ERR
Use correct format specifier for LOG_ERR in lwm2m_obj_device.c. The
previously used format specifier of %u was correct for 32 bit systems
but would produce a build warning for 64 bit systems.

Fixes #66441

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-12-14 09:32:43 +01:00
Mariusz Skamra
1cb80d3282 Bluetooth: audio: has_client: Use CONTAINER_OF to get client instance
This starts using CONTAINER_OF macro instead of inst_by_conn function
wherever possible. It's better approach as the client instance is
a container for parameters passed to the callbacks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-14 09:31:59 +01:00
Declan Snyder
e913ccc753 net: Add Kconfig for net buf alignment
Add a NET_BUF_ALIGNMENT kconfig to make net buffer alignment configurable.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-12-14 09:29:47 +01:00
Jukka Rissanen
477a4a5d34 net: shell: Rename the common.h to be more unique
As the common.h is only meant to be used by the network
shell files, rename it to be more descriptive in order to
avoid possible conflicts with any other common.h file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-13 20:13:39 +01:00
Johann Fischer
52686a8308 usb: device_next: simplify way to set/change triple code
Usually we want set all values of code triple Base Class, SubClass, and
Protocol at once. Merge existing functions to set code, subcode,
protocol into just one helper to set code triple.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-12-13 17:52:00 +01:00
Luca Burelli
2c7ea1dde5 llext: autoselect CACHE_MANAGEMENT on supported targets
Targets that have a data cache must enable CACHE_MANAGEMENT to allow the
llext API to flush it when loading an extension. This patch forces the
flag to be enabled when the target has a data cache.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2023-12-13 15:22:07 +00:00
Luca Burelli
8887402290 llext: fix: use proper global #define for cache flush
The arch_* functions are architecture-specific and may not be defined in
all targets. Use the global alias defined in the Cache API instead.

Fixes #66382.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2023-12-13 15:22:07 +00:00
Anders Storrø
25d44a828d Bluetooth: Mesh: Rename prov_dev->provisionee
Renames "prov device" references and options to
"provisionee" to align implementation with Mesh
Protocol specification v1.1, section 5.4.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-13 13:57:46 +01:00
Robert Lubos
8cb4f09a28 net: tcp: Remove pointless recv callback calls
Calling the registered receive callback when releasing TCP context
doesn't make sense, as at that point the application should've already
closed the associated socket (that's one of the conditions for the
context to be released). Therefore, remove the pointless receive
callback call, while keeping the loop to unref any leftover data packets
(although again, I don' think there should be any packets left at that
point, as they're all consumed in tcp_in()).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-13 10:39:03 +01:00
Robert Lubos
6b00b537aa net: tcp: Fix deadlock with tcp_conn_close()
While improving thread safety of the TCP stack I've introduced a
possible deadlock scenario, when calling tcp_conn_close() in tcp_in().
This function shall not be called with connection mutex locked, as it
calls registered recv callback internally, which could lead to deadlock
between TCP/socket mutexes.

This commit moves the tcp_conn_close() back where it was originally
called. I've verified that the thread safety is still solid with the
test apps used originally.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-13 10:39:03 +01:00
Mariusz Skamra
d3d46a6d80 Bluetooth: has: Fix control point error return code
This fixes the return error code for Preset Write operation that shall
be returned when preset is not writable (or disabled via Kconfig like in
this case).

As per HAS_v1.0; 3.2.2.3 Write Preset Name operation
"If the Writable bit in the Properties field of the preset record which
is identified by the Index parameter is set to 0b0, then the server
shall return an ATT_ERROR_RSP PDU to the ATT_WRITE_REQ PDU with
the Error Code parameter set to Write Name Not Allowed."

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-13 09:42:04 +01:00
Xudong Zheng
545a3973a8 bluetooth: bas: remove select SENSOR
Bluetooth battery service does not use sensor.

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2023-12-12 19:10:17 +01:00
Mariusz Skamra
09e376068e Bluetooth: audio: bap_stream: Fix potential NULL pointer dereference
This fixes potential NULL stream pointer dereference.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:33:13 +01:00
Mariusz Skamra
025ba06c32 Bluetooth: ascs: Avoid possible unexpected assert
This avoids unexpected assert that may happen when the client tries to
QoS configure ASE that is in state which does not allow to be configured.
In such case the assert shall not be not be triggered, as it's not stack
fauly. The assert check has been moved after the state check, so the ASCS
implementation will just return an error code to the client.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:33:13 +01:00
Mariusz Skamra
ddf172c187 Bluetooth: gatt: Fix automatic resubscription causing CCC removal
This fixes CCC subscriptions that were removed if the automatic
resubscription was aborted by ACL disconnection.
As the client renews subscriptions, there is no point of removing those
if the link is disconnected unexpectedly.
The API user won't be notified about the failure, as the automatic
resubscriptions are implicit, and after reconnection the subscriptions
will be still valid.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:32:45 +01:00
Pisit Sawangvonganan
f6f8c3f9b7 shell: correct z_shell_spaces_trim when len equal to zero
Addresses a potential issue when the string contains only '\0',
which results in z_shell_strlen(str) returning len as 0.
Since the for-loop expects len >= 1, the function now immediately
returns when len == 0.
As the null check for 'str' is already handled inside
z_shell_strlen(), an additional check for 'str' is not needed.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2023-12-12 15:02:58 +01:00
Johann Fischer
6a7f43b47b usb: device_next: add SetFeature(TEST_MODE) support
Add an interface to verify and enable a test mode. The test mode
selected in the SetFeature control request must be verified to be
supported by the controller and enabled after the status stage is
completed.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-12-12 15:01:49 +01:00
Johann Fischer
7013b4d7c7 usb: device_next: add support to set device address directly
Not all device controllers expect the device address to be set after the
status stage. Add support to directly set a new device address without
waiting for the control request status stage.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-12-12 15:01:49 +01:00
Miika Karanki
b84bab36b9 settings: file: do not unlink the settings file unnecessarily
fs_rename can handle the file move atomically without unlinking
the file first if the filesystem supports that. This change makes
the settings file more power cut resilient so that the whole
settings file is not lost with poorly timed power cut.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2023-12-12 13:02:15 +01:00
Declan Snyder
e4cca5145b net: Add fallback macro for nef_if_mon functions
Add empty macro for net_if_mon functions if they are not otherwise
defined, like the other functions in the net_if.c file have.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-12-12 10:58:38 +00:00
Andriy Gelman
8232dddf1c shell: telnet: Don't close the connection on EAGAIN error
EAGAIN error is returned if the tcp window size is full. Retry
sending the packet instead of closing the connection if this
error occurs.

Also the full payload may not be sent in a single call to
net_context_send(). Keep track of the number of bytes remaining
and try to send the full payload.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-12-12 10:57:49 +01:00
Flavio Ceolin
b5ca7a06b4 pm: device_runtime: Add delay to async put
Add a delay parameter to asynchronous device runtim put. This allows
to delay the put operation what is useful to avoid multiple states
transitions.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-12-12 10:57:34 +01:00
Flavio Ceolin
0ea173b774 pm: device_runtime: Avoid unnecessary resume/suspend
We don't need to wait an async put to happen in case it has not
started yet. In this case we can simply cancelling the pending work
and change the internal state because the device is still active.
This way we avoid a suspend and resume cycle.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-12-12 10:57:34 +01:00
Juha Ylinen
69e28939dd net: lib: coap: Add new API to configure retransmission settings
Add new functions to the public CoAP API to configure CoAP packet
retransmission settings. Application may need to re-configure the
settings for example when cellular modem changes connection from
LTE-M to NB-IoT or vice versa.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-12-12 10:56:29 +01:00
Mariusz Skamra
af9f526ccd Bluetooth: has: Check writable preset support on preset registration
This fixes issue where API use is able to register writable preset even
if the CONFIG_BT_HAS_PRESET_NAME_DYNAMIC Kconfig option was disabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-11 19:26:36 +01:00
Kuno Heltborg
220a57b0b1 mgmt: mcumgr: improve custom payload types
Use a flag in `c:struct:mgmt_handler` to skip the cbor start and end byte,
and instead use pure custom user defined payload.

Signed-off-by: Kuno Heltborg <kunoh@live.dk>
2023-12-11 18:31:23 +01:00
Emil Gydesen
9c8ec58beb Bluetooth: GMAP: Add GMAP shell
Add the GMAP shell module with support for running the
various audio configurations in an easy way.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 18:30:57 +01:00
Emil Gydesen
7913ebfba3 Bluetooth: GMAP: Add initial implementation of GMAP
Add initial implementation of Gaming Audio Profile (GMAP).

This is a top layer profile in the LE Audio stack,
designed for low latency audio ideal for gaming.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 18:30:57 +01:00
Lingao Meng
ffd716b4a2 Bluetooth: Host: iso_data extend bt_buf_data
Explicitly declare that iso_data extends bt_buf_data.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-11 12:50:54 +01:00
Lingao Meng
0ddb6aa82e Bluetooth: Host: Use actual user_data size
Use actual user_data size not default by 8.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-11 12:50:54 +01:00
Jukka Rissanen
b6d9ed095d net: Move trickle files to lib
The trickle algorithm files are clearly a library so move
them under lib/ directory.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-11 10:50:35 +01:00
Robert Lubos
2cc0d31d9f net: tcp: Move TCP Kconfig options to separate file
The number of Kconfig options for the TCP stack grew considerably,
therefore it makes sense to move them to a separate file not to bloat
the Kconfig file with generic networking options.

Take this opportunity to reorder TCP options, so that protocol
parameters (timings/buffer sizes) are not mixed up with optional
protocol features (fast retransmit/congestion avoidance etc.).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-11 10:11:10 +01:00
Robert Lubos
a150380d65 net: tcp: Implement Keep-alive support
When a TCP connection is established, if there is no data exchange
between the two parties within the set time, the side that enables
TCP Keep-alive will send a TCP probe packet with the same sequence
number as the previous TCP packet. This TCP probe packet is an empty
ACK packet (the specification recommends that it should not contain
any data, but can also contain 1 nonsense byte, such as 0x00.). If
there is no response from the other side after several consecutive
probe packets are sent, it is determined that the tcp connection has
failed, and the connection is closed.

The keep-alive default parameters are aligned with Linux defaults.

Signed-off-by: Horse Ma <mawei@coltsmart.com>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-11 10:11:10 +01:00
Seppo Takalo
005dc60d24 net: lwm2m: Fix pmin handling on tickless
If observed resource was written during the pMin period, it did
not schedule any wake-up event into the future. Notify message would
then only be generated as a result of any other (like Update) event.

Refactor check_notifications() to follow same pattern as retransmit_req().
Return the next event timestamp, which could be now.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-11 09:57:09 +01:00
Emil Gydesen
6158ff03f5 Bluetooth: Shell: Only auto-connect to unconnected devices
The bt connect and bt connect-name commands should only
attempt to connect to connectable devices that we are not
already connected to.

This commit moves the check for BT_GAP_ADV_PROP_CONNECTABLE
as well as checks that we do not already have a connection
to that device with the current ID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 09:54:04 +01:00
Emil Gydesen
01bd94ac4f Bluetooth: Shell: Remove tolower from is_substring
The tolower is not necessary and is what strncasecmp
does anyhow.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 09:53:36 +01:00
Joakim Andersson
f390f7d0a1 bluetooth: shell: Use helper function to convert string to int
Use helper function to convert string to int for appearance value.
This makes the code more clear, as the big-endian conversion function
gives the wrong impression about the byte order of advertising data.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-12-11 09:51:31 +01:00
Aleksandr Khromykh
d175ac0572 Bluetooth: Mesh: access tx msg randomizer
Commit adds implementation of the specification
recommendations regarding randomization of
responses on the access layer.
3.7.3.1 Transmitting an Access messages

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-12-11 09:50:18 +01:00
Arkadiusz Wadowski
3fc40c9779 mgmt/osdp: Remove unused variable from osdp_phy_packet_finalize()
The variable was removed to avoid generating compilation warrning.


Signed-off-by: Arkadiusz Wadowski <wadowski.arkadiusz@gmail.com>
2023-12-08 20:20:56 +00:00
Arkadiusz Wadowski
a9b0230360 mgmt/osdp: Fix compilation when CONFIG_OSDP_SC_ENABLED enabled
The 2 issues were found after CONFIG_OSDP_SC_ENABLED was enabled:
- missing curly brace after if
- typo in type name


Signed-off-by: Arkadiusz Wadowski <wadowski.arkadiusz@gmail.com>
2023-12-08 20:20:56 +00:00
Lingao Meng
683098728a Bluetooth: Mesh: Use memslab replace with net_buf_pool
Use memslab more efficiency than net_buf_pool and consume
less ram with flash resource.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-08 20:19:10 +00:00
Juha Heiskanen
093efc444d modem: modem_cmux: Support modem CMUX DCE role
Added missing command and message handling for use existing
modem cmux for DCE role.
DCE CMUX connection can be now initialized from DTE side.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-12-08 20:17:58 +00:00
Fabio Baltieri
e4796521f2 input: kbd_matrix: add an kbd_matrix_state shell command
Add a "input kbd_matrix_state" shell command. This prints the state of
a keyboard matrix in a much more compact representation than the normal
input event dump, but also keeps track of any key seen during the
execution and reports that on the "off" command. The output can be used
to help setting the actual-key-mask property.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-08 20:16:39 +00:00
Jasper Smit
6003927ac2 net: sntp: Add option for SNTP uncertainty
SNTP response is not analyzed for uncertainty, and no uncertainty is given
to the `struct sntp_time` returned. Fix it with a Kconfig option that adds
optional SNTP uncertainty and timestamp fields in SNTP time struct, and
calculates these when parsing the response.
Adds two helper functions to convert Q16.16/Q32.32 in seconds to `int64_t`
in microseconds to facilitate this.
Also changes combined `lvm` field in `struct sntp_pkt` to bit-fields
`li`, `vn`, and `mode`.

Signed-off-by: Jasper Smit <git@jrhrsmit.nl>
2023-12-08 10:25:46 +00:00
Pavel Vasilyev
ef1f2d1336 Bluetooth: Mesh: Convert no opcode error to debug log
This error message may confuse when `CONFIG_BT_MESH_ACCESS_LAYER_MSG` is
enabled and all messages are processed by the callback anyway.
This error message also confuses when a node is subscribed to the same
address as it publishes to, which makes it generating the error message
every time it publishes a message.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-12-08 10:25:36 +00:00
Pavel Vasilyev
bcd2aba4d7 Bluetooth: Mesh: Allow custom RPL use mesh settings work
This change allows a custom RPL use pending mechanism and the mesh
settings work to store pending RPL entries. `bt_mesh_rpl_pending_store`
is a public API and should be implemented anyway. The custom RPL
implementation has to trigger settings with the
`BT_MESH_SETTINGS_RPL_PENDING` flag to ask the mesh settings work to
call `bt_mesh_rpl_pending_store`.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-12-08 10:25:36 +00:00
Jordan Yates
643984c432 pm: device_runtime: don't assert in ISR put
Don't assert that `pm_device_runtime_get` is not running in an ISR
context, as `runtime_suspend` properly handles that condition.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-08 11:09:34 +01:00
Emil Gydesen
203949c42c Bluetooth: VCP: Allow for multiple vol_ctrl cb registers
Modify the VCP volume controller callbacks to support
multiple registers by making it into a linked list.

This allow for multiple applications to get the information
from procedures or notifications.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-08 10:04:31 +00:00
Lingao Meng
786b9a0ad4 Bluetooth: Host: Add const prefix for UUID
Add const prefix for service uuid and char uuid.

Since Service UUID and Char UUID should not change in the service
definition, they are most reasonably defined as rodata, also for
save some ram footprint.

The field `attr->user_data` type is `void *`, as this PR change
all Service UUID to rodata, so there must add (void *) to avoid warning.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-07 16:16:43 +00:00
Pieter De Gendt
c1204affab net: ip: net_mgmt: Support system work queue and synchronous callbacks
Add Kconfig choice for the user to select how Network Events are
handled. It's own thread, the system work queue or synchronous when
events are emitted.

By default a separate thread is created to be backwards compatible.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 16:15:53 +00:00
Emil Gydesen
3fec3964e0 Bluetooth: CAP: Move initiator/commander common code to cap_common
The CAP Initiator and the CAP Commendar share quite a lot of
functionality in terms of discovery and performing set-based
procedures.

The code for handling most of this has been moved to
cap_common.c to avoid duplicating code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-07 16:14:42 +00:00
Jamie McCrae
f147e8b8f5 dfu: boot: mcuboot_shell: Prevent erasing MCUboot/app flash areas
Prevents the user from potentially bricking a device by erasing
the MCUboot or currently running application flash areas with the
mcuboot erase command

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-12-07 14:24:48 +00:00
Jonathan Rico
3e56b12c58 Bluetooth: ATT: don't access l2cap ops struct
It's bad form, especially since in that case, it's always the same function
that is called `bt_att_sent()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-12-07 10:37:37 +00:00
Pieter De Gendt
35761f724d net: lib: shell: Add CoAP descriptions to event monitor
Add a description for each CoAP event on L4.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 10:34:39 +00:00
Pieter De Gendt
5182dd24c6 net: lib: coap: Introduce net mgmt events for CoAP
Allow users to register net mgmt events callbacks for CoAP events.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 10:34:39 +00:00
Pieter De Gendt
f712441840 Revert "net: lib: coap: Add support for observer event callbacks"
This reverts commit 5227f24815.

The coap observer events will be replaced with net_mgmt events.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 10:34:39 +00:00
Luca Burelli
57e1dc337a llext: shell: fix command completions
Dynamic command handlers should be fully initialized to avoid undefined
behavior. Also, fix the number of arguments required by each command,
since llext_call_fn requires both the llext and the name of the function
to be called.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2023-12-06 18:01:34 -05:00
Luca Burelli
1732177530 llext: flush dcache in the llext memory range
On architectures that have separate data and instruction caches, such as
the Cortex-M7, it is required to flush the reloc changes to the actual RAM
storage before trying to execute any code from the newly loaded llext.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2023-12-06 18:01:34 -05:00
Luca Burelli
e96b713caf llext: record size of each stored section
Store the size of each section in the llext structure.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2023-12-06 18:01:34 -05:00
Luca Burelli
cbed9fd785 llext: always initialize ext param in llext_load
It is not safe to assume that on entry to llext_load, *ext contains
either NULL or a previous reference to the same ext being loaded. For
example, the shell sample was passing an uninitialized value.

Initialize *ext from a search of the llext by name. If NULL, it is the
first instance of this llext (and on load error, it stays that way). If
not NULL, increment use count and return.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2023-12-06 18:01:34 -05:00
Jordan Yates
5bf8edc85f logging: uart: cleanup device runtime PM checks
`pm_device_runtime_get` and `pm_device_runtime_put` have returned `0`
when device runtime PM is not enabled since #56222. Manually checking
the state is no longer required.

Additionally, the functions have been able to run in an ISR context
since #60785, which removed the need to special case `k_is_in_isr()`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-06 18:00:21 -05:00
Yong Cong Sin
f61ce34998 shell: shell_uart: reinstate multi-instance macro
Reinstate the `SHELL_UART_DEFINE` macro and moved the struct
declarations to header file, making it possible to create
another UART shell backend instance by doing
`SHELL_UART_DEFINE()` + `SHELL_DEFINE()` + `shell_init()`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-12-06 11:27:20 -08:00
Nick Ward
b1d24e425c net: lwm2m: device object: optionally store error list in settings
A device can be reset before the error code list is communicated
to a LwM2M server so optionally store error list in settings so it
can restored after reset.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-12-06 17:55:22 +00:00
Nick Ward
b75a3f691d net: lwm2m: device object: use LWM2M_DEVICE_ERROR_NONE
Use LWM2M_DEVICE_ERROR_NONE macro.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-12-06 17:55:22 +00:00
Emil Gydesen
e496cbe512 Bluetooth: VCP: Vol rend: Add check before notification log
To avoid having "notification scheduled in 0ms" in the log,
check to verify that the delay is not K_NO_WAIT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-06 17:55:10 +00:00
Mariusz Skamra
78a4b33e5c Bluetooth: audio: pacs: Add bt_pacs_set_available_contexts_for_conn
This adds the function that sets the available contexts value per
connection object so that API user can set different available contexts
per connection.
The lifetime of such overriden value is the same as connection lifetime,
so on reconnection or device reboot all devices return to having the
same available contexts value again.

Fixes: #64968
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Mariusz Skamra
014c22c9c0 Bluetooth: audio: pacs: Fix invalid lookup
This fixes client lookup that was done with use of bt_conn_index while
the size of the client array is CONFIG_BT_MAX_PAIRED.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Mariusz Skamra
ef362e766a Bluetooth: audio: pacs: Disallow changing supported contexts
Disallow further changes of supported audio contexts characteristic is
the GATT Characteristic Notify Property is not set.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Jonathan Rico
ea04fd95f9 Bluetooth: ATT: remove BT_ATT_ENFORCE_FLOW
Enforcing the peer's behavior is not strictly necessary. All the host
should do is make sure it is resilient to a spec-violating peer.

Moreover, a growing number of platforms were disabling the check, as the
spec allows "batching" HCI num complete packets events, stalling ATT RX.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-06 17:53:54 +00:00
Piotr Narajowski
4dad6616f7 bluetooth: audio: Add API to get MCS service ATT handles
This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2023-12-06 17:52:49 +00:00
Dmitrii Golovanov
f308299ca2 debug: gdbstub: kconfig: Add GDBSTUB_TRACE config option
Add GDBSTUB_TRACE config option to extend GDB backend debug logging
for remote commands received and to debug the GDB stub itself.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-12-06 17:52:18 +00:00
Emil Gydesen
38d73a6ccf Bluetooth: VCP: Add bt_vcp_vol_ctlr_get_by_conn
Add function to get a volume controller from a connection
pointer.

This is required for the CAP to get a vol_ctlr pointer
from the provided bt_conn.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-06 17:51:58 +00:00
Emil Gydesen
c9daed9712 Bluetooth: BAP: Refactor bt_bap_base
This removes the fixed size bt_bap_base, which provides
2 improvements:
1) The RAM usage of the broadcast sink has been reduced.
   For the Broadcast Sink sample it is a reduction of 120
   octets, but with much better scaling for supporting
   more or larger BASEs.
2) The functions to parse BASEs now support arbitrary sized
   BASEs, where they were previously restricted by our
   local Kconfig options. This allow us to parse any BASE
   from a remote device, without encounting memory issues.
   We are still memory restricted on the devices we
   actually want to sync to.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-06 17:51:47 +00:00
Robert Lubos
5f6b4479ed net: conn: Improve thread safety in connection module
Iterating over connection list w/o mutex lock could lead to a crash on
constant incoming packet flow. Fix this by:

1. Adding mutex lock when iterating over an active connection list, to
   prevent list corruption.
2. Create a copy of the callback and user data pointers before releasing
   lock, to prevent NULL pointer dereference in case connection is
   released before callback is executed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-06 09:23:54 +00:00
Robert Lubos
4ab2dded8d net: tcp: Eliminate race between input thread and TCP work queue
Eliminate race between TCP input thread and TCP work queue, when
dereferencing connection. This normally would not manifest itself during
standard TCP operation, but could be a potential opening for abuse, when
the already closed TCP connection is kept being spammed with packets.
The test scenario involved sending multiple TCP RST packets as a
response to establishing the connection, which could result in system
crash. The following changes in the TCP stack made it stable in such
scenario:

1. Use `tcp_lock` when searching for active connections, to avoid
   potential data corruption when connection is being removed when
  iterating.
2. Avoid memset() during connection dereference, not to destroy mutex
   associated with the connection. The connection context is only
   cleared during allocation now.
3. Lock the connection mutex while releasing connection.
4. In tcp_in(), after locking the mutex, verify the connection state,
   and quit early if the connection has already been dereferenced.
5. When closing connection from the TCP stack as a result of RST or
   malformed packet, verify connection state to make sure it's only done
   once, even if multiple RST packets were received.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-06 09:23:54 +00:00
Jukka Rissanen
d5c7761314 net: ipv6: Silently drop unwanted NA messages
Silently drop the IPv6 Neighbor Advertisement if we receive it
for an unknown neighbor or if there some some issue in the packet.
Returning error here would cause the ICMP module to print an
actual error which just pollutes the log without any apparent
benefit.

Fixes #66063

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-06 09:22:44 +00:00
Jordan Yates
8fab08e8e2 pm: device_runtime: release power domain multiple times
Enable the automatic power domain management to release the domain as
many times as it was claimed, instead of only once.

This fixes the domain being permanently enabled if the supported device
is claimed more than once.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-06 09:16:12 +00:00
Seppo Takalo
dc8f6da53c net: lwm2m: Implement fallback mechanism and support for diable
If server registration fails, allow fallback to secondary server,
or fallback to bootstrap.
Also allow fallback to different bootstrap server.

Add API to tell RD client when server have been disabled by
executable command.

Changes to RD state machine:
* All retry logic should be handled in NETWORK_ERROR state.
* New state SERVER_DISABLED.
* Internally disable servers that reject registration
* Temporary disable server on network error.
* Clean up all "disable timers" on start.
* Select server first, then find security object for it.
* State functions return void, error handling is done using states.
* DISCONNECT event will only come when client is requested to stop.
* NETWORK_ERROR will stop engine. This is generic error for all kinds
  of registration or network failures.
* BOOTSTRAP_REG_FAILURE also stops engine. This is fatal, and we cannot
  recover.

Refactoring:
* Server selection logic is inside server object.
* sm_handle_timeout_state() does not require msg parameter. Unused.
* When bootstrap fail, we should NOT back off to registration.
  This is a fatal error, and it stops the engine and informs application.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00
Seppo Takalo
ec962246e9 net: lwm2m: Allow disabling server for a period of time
React to disable executable, as well as add callback that allows
disabling server for a period of time.

Also add API that would find a next server candidate based on the
priority and server being not-disabled.

Move all server related functions into its own header.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00
Seppo Takalo
304d920ef1 net: lwm2m: Allow finding security instance by short ID.
Add API to find a security instance ID with given Short Server ID.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00
Manuel Argüelles
0b32004c09 tests: userspace: exclude ucans32k1sic due to lack of MPU regions
This board have an NXP MPU with 8 configurable regions, of which five
of them are already used by the static MPU configuration. Many of
these tests are failing due to lack of MPU regions or free partition
slots available, even when HW stack protection is disabled when
building with userspace support.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2023-12-05 16:20:10 -06:00
Yong Cong Sin
d65cb1fe12 shell: fix shell instance name typo
Fixing typo from the original implementation in
44705b698c725166834f19d6fd5db2804f9a0d60, which resulted in
the name of current shell instance getting print over and over
again.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-12-05 10:44:56 -05:00
Pieter De Gendt
3157aaaddb net: ip: mgmt: Add support for compile time event handlers
Add an iterable section with network event handlers.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-05 09:17:42 -05:00
Jukka Rissanen
bed63764d6 net: socket: Add IPv6 multicast join/leave via socket
Zephyr has its own multicast join/leave API but for
interoperability, it is possible to use the multicast
socket API and IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP
socket options.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 16:38:49 +00:00
Jukka Rissanen
b58bddb85c net: socket: Add IPv4 multicast join/leave via socket
Zephyr has its own multicast join/leave API but for
interoperability, it is possible to use the multicast
socket API and IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP
socket options.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 16:38:49 +00:00
Aleksander Wasaznik
d3a0c769b0 Bluetooth: Shell: Workaround coverity uint comparation
The current code triggers a false positive from the heuristic "Macro
compares unsigned to 0". It's triggered because of a use of `IN_RANGE`
that checks against the extremal values of a enum type.

This patch replaces the use of `IN_RANGE` with an explicit list of the
possible values of the enum.

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

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-04 16:37:36 +00:00
Jukka Rissanen
060295c63b net: dns: responders: Set the multicast TTL or hoplimit
We are creating a multicast address in mDNS or LLMNR
responder so set the TTL or hoplimit using the multicast
variant API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen
fc006d7daa net: dns: Do not pass 0 as TTL or hop limit
We specifically set TTL/hoplimit to 1 for LLMNR,
but only want to set it if in that specific case.
We must not pass TTL/hoplimit value 0 as that would
cause the packet to be dropped.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen
d44b72355b net: Refactor IP checks just before sending packets
* Check IPv4 TTL or IPv6 hop limit and drop the packet if
  the value is 0
* Check the IP addresses so that we do the loopback check
  at runtime if the packet is destined to loopback interface.
* Update the statistics properly for dropped packets.
* Do not update sent packets if we drop packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen
b4a8e3ffff net: socket: Add support for adjusting IPv4 TTL
The IPv4 TTL could only manipulated via net_context interface.
It makes sense to allow the same from socket interface via
the setsockopt/getsockopt calls.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen
96ac91d1c9 net: Add support for adjusting IPv6 unicast hop limit
Add option support for adjusting the IPv6 unicast
hop limit value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen
e397d199b1 net: if: Fix typo in IPv6 hop limit API name
The net_if_ipv6_set_hop_limit() API was missing the "_if_"
part in it. Fix this so that the network interface API is
consistent. The old function is deprecated and should not
be used. The old function is left to the code and it calls
the new properly named function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen
1c684bc360 net: Add support for adjusting IPv6 multicast hop limit
Add option support for adjusting the IPv6 multicast
multicast hop limit value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen
de0268def0 net: context: Add support for adjusting IPv4 multicast ttl
Add option support for adjusting the IPv4 multicast
time-to-live value.

Fixes #60299

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Håvard Reierstad
897a1d0d1c Bluetooth: Mesh: suspend/resume advertising
Disables Mesh advertising when suspending, and enables advertising
when resuming Mesh.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-12-04 14:38:13 +01:00
Håvard Reierstad
3be26c4cb9 Bluetooth: Mesh: advertiser: add disable function
Adds a disable function for the extended advertising which stops and
deletes the advertising instances, allowing them to be properly
reinitialized when calling `bt_mesh_adv_enable()` after bluetooth has
been disabled and re-enabled.

For the legacy advertising, the function terminates the advertising
thread. If legacy advertising is used, `bt_mesh_adv_init()` must be
called before `bt_mesh_adv_enable()` to properly resume advertising
after suspension.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-12-04 14:38:13 +01:00
Robert Lubos
839553a7d9 net: shell: ping: Fix double packet unref in ping reply handler
This was somehow missed, but since ICMP rework, message handlers should
not dereference the packet, as it's done by the ICMP lib.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-04 14:30:26 +01:00
Robert Lubos
67082289e1 net: l2: ethernet: Fix error handling after ARP prepare
Commit 55802e5e86 fixed error handling of
TX errors, in case ARP request was generated. There are however also
other places where post-ARP cleanup should be done on the TX path (like
running out of buffers for Ethernet L2 header allocation).

This commit fixes those cases in ethernet_send(), where function would
exit early and report error after ARP prepare stage.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-04 14:30:26 +01:00
Chaitanya Tata
07e3869809 wifi: shell: Add long arguments to help
Long arguments are handy for new users. Also use hyphen's rather than
underscore to follow the convention.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata
95b8ae37e3 wifi: shell: Enforce argument count checks
Use the proper API to enforce argument count checks as per mandatory or
optional params.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata
1c46e52bf8 wifi: shell: Add missing security options
Newly added security types are missing from the help. Also, now that we
have two variants of PSK, use the prefix to disambiguate.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata
8ad78a4bb4 wifi: shell: Fix PS mode help
There is only a single parameter called "mode" that takes two possible
values.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata
95e52c9c63 wifi: shell: Fix brackets type for optional params
General notation for Optional params is to use square brackets.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata
8a4f7c02c0 wifi: shell: Fix unbalanced braces
Fix the typo in braces for help.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Noah Luskey
8e4c70750a net: don't overwrite net_if name after iface is initialized
When interface names are enabled, a default name is applied
after initialization. Unintuitively, this overwrites any name that is
set during the net_if init.

This change sets a default name first, and then allows net_if
init to overwrite that default name if it chooses to.

Signed-off-by: Noah Luskey <noah@silvertree.io>
Signed-off-by: Noah Luskey <LuskeyNoah@gmail.com>
2023-12-04 14:18:53 +01:00
Mariusz Skamra
5174e94c91 Bluetooth: audio: has: Fix coverity issues
This fixes issues discovered by coverity check.

Fixes: #65325
Fixes: #65326
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-01 16:26:03 +01:00
Guennadi Liakhovetski
dbea13a1c7 llext: fix read-only extension image
When using the LLEXT buffer loader we now avoid copying extensions
from storage to allocated memory by pointing directly into the stored
image. We then also perform linking and relocation in that memory,
which modifies its contents. However, this is impossible if that
storage is read-only. Add a Kconfig flag to distinguish between
writable and read-only storage types. Also use that flag to decide,
whether the extension image in test_llext_simple.c should be defined
as const or not.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
4e3e9a618e llext: protect the global llext list
Use an existing mutex to also protect the global llext list.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
b5506feed5 llext: remove redundant initialisation
a new llext object is completely initialised with zeros after
allocation, no need to additionally set members of an embedded into
it array to NULL.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
7af6dea799 llext: remove llext_list()
llext_list() is an exported function that returns a pointer to the
llext internal extension list. That list should only be accessible
directly inside llext, while holding a lock. Remove the function.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
ee4540c46c llext: remove llext list scanning from shell.c
The llext list should be internal to llext.c, remove its scanning
from shell.c, export a function for that instead.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
b5ce5012e2 llext: clarify section map allocation size
Use an element size explicitly when calculating the array size and
use the calculated size for memset().

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
b9bdae8c07 llext: add support for exporting symbols from extensions
Extensions should be able to selectively export their global symbols.
Add a LL_EXTENSION_SYMBOL() macro for that. Change the present
.sym_tab to be a temporary symbol table of all global symbols in an
extensions, used only during linking for internal purposes. Add a new
.exp_tab symbol table to store symbols, exported by an extension
permanently.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
86da7840bd llext: fix a memory leak in an error case
If a function fails it should release all the resources it has
managed to acquire. Fix llext_load() to free memory that it has
allocated in case of an error.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
a2acd7b2fb llext: add reference counting
Extend the llext_load() / llext_unload() API to let it be called
repeatedly for the same extension to increment or decrement its
reference counter respectively. We use a mutex to protect the counter
and make both llext_load() and llext_unload() return the use-count to
let the caller identify when the first loading and the last unloading
took place.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
0b5bfd22e3 llext: add support for global functions
Loadable modules can contain global (not "static") functions, even if
they aren't exported for use by other modules, e.g. when a module is
built from multiple .c files. Such functions are then also included
in link tables and have to be re-linked.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
a2a62b46a3 llext: make buffer access functions accessible externally
llext_seek(), llext_read() and llext_peek() are needed outside of the
extension code too, move them to a header.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
b0b4b0baa0 llext: make local relocations optional
Some applications can decide to link their loadable objects for
exactly the same addresses, where they will be loaded. In those cases
local relocations aren't needed any more and can in fact break the
object if applied while the object is in a temporary storage. Add a
parameter to skip such local relocations.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
69cdc32892 llext: export some symbols
Export some symbols for loadable modules. Also add an
EXPORT_SYSCALL() helper macro for exporting system calls by their
official names.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
f98b8bb48f llext: add a function for finding ELF sections
Applications can use custom ELF sections for their own purposes, add
a function for finding them.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
03519afb84 llext: xtensa: add support for local symbol relocations
Add support for relocating local symbols, as specified in the
.rela.dyn section.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Guennadi Liakhovetski
d6a5a6e04c llext: add support for shared objects
Add support for linking PIC shared object, which only require
linking, using their PLT and GOT lists and don't need any relocation
otherwise.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Adam Cavender
ac4f9a6962 Bluetooth: Shell: Fix cmd_chan_map
Allow the channel map to be set when periodic advertising or acting as
an ISO source.

Signed-off-by: Adam Cavender <adam.cavender@nordicsemi.no>
2023-12-01 14:30:52 +01:00
Adam Cavender
ad485866b0 Bluetooth: Host: Fix bt_le_set_chan_map
Allow the channel map to be set when periodic advertising or acting as
an ISO source.

Signed-off-by: Adam Cavender <adam.cavender@nordicsemi.no>
2023-12-01 14:30:52 +01:00
Kapil Bhatt
cb7b650b92 net: l2: wifi: Fix Print of SSID in WIFI status
While printing SSID in wifi status command, If the
length is maximum(32 character). It leads to buffer
overflow. It required one character for null
terminator ‘\0’. Changing the Format Specifiers to
print proper SSID.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2023-12-01 11:03:43 +00:00
Mario Paja
6b644dff67 net: gptp: Fix announce message len
This fix addresses wrong announce message length warning message.

TLV is a variable length (4+8N) based on the 802.1AS-2011 (table 10-8). In
Zephyr TLV is fixed to 12 bytes. TLV type and length are already taken
into account in the announcement message length.

Signed-off-by: Mario Paja <mario.paja@zal.aero>
2023-12-01 11:02:57 +00:00
Peter Johanson
be5a341467 bluetooth: Add CPF attribute to BAS battery level.
BAS v1.1, section 3.1.2.1 notes that a CPF should be added if the
device has more that one instance of the Battery Service, so
add one with the `main` description so that apps can add additional
Battery Level services with other descriptions, e.g. `auxiliary`.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2023-12-01 10:58:27 +00:00
Chaitanya Tata
eb9587596b wifi: Check WPA-PSK passphrase length
When WPA-PSK was introduced the passphrase length check was missed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-01 10:57:06 +00:00
Pieter De Gendt
266181b082 net: lib: coap: Add coap_service_is_running
Add a CoAP service API function to query the running state of the
provided service.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-01 10:56:56 +00:00
Pieter De Gendt
4ff8080b65 net: lib: coap: Init CoAP service socket fd to -1
Set the static initialiser socket file descriptor to -1 to make sure
it is invalid before using coap_service_send.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-01 10:56:56 +00:00
Jukka Rissanen
5d915398a4 net: sockets: Add additional checks to recvmsg()
Add extra checks that make sure that msg_iov is set
as we cannot receive anything if receive buffers are
not set.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-01 10:56:34 +00:00
Mia Koen
0bcad09392 bluetooth: mesh: Doc fix Bluetooth mesh to Mesh
SIG has changed Bluetooth mesh to Bluetooth Mesh
Updating zephyr docs accordingly
Leaving out old release notes

Signed-off-by: Mia Koen <mia.koen@nordicsemi.no>
2023-12-01 10:56:18 +00:00
Andries Kruithof
c3e2be4314 Bluetooth: audio: host: call the stream disable callback
Even though the ASCS Sink ASE state machine does not enter the disabling
state according to ASCS spec, it still makes sense to do so.

the state transition unit tests are updated to verify calling or not
calling the disable callback, depending on the transition of the state

fixes #63230

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-12-01 10:50:04 +00:00
Magdalena Kasenberg
c94cd30cec bluetooth: bap: Fix shift of requested_bis_sync
The BIS_Sync bitfiled received over the air in Add Source and Modify
Source operations uses BIT(0) for BIS Index 1. Shift it when storing
it to match bis_sync bitfield where BIS Index 1 is at BIT(1).

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-30 12:10:35 +00:00
Magdalena Kasenberg
2094183d81 bluetooth: bap: Fix shift of BIS_Sync parameter of notification
bis_sync contains BIS index bitfield which is shifted by 1 bit relative
to the BIS_Sync parameter of Broadcast Receive State notification.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-30 12:10:35 +00:00
Robert Lubos
222fa42609 net: icmp: Fix Echo Replies with unspecified address
Fix two issues with sending ICMP Echo Reply for requests sent for
multicast address:
* Use the originator IP address instead of multicast when selecting
  source address for the reply
* In case no address match is found, drop the packet, instead of
  replying with unspecified address.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:07:45 +01:00
Pieter De Gendt
8252ec7570 net: lib: coap: Translate handler errors to CoAP response codes
The CoAP request handler returns errno codes in the following cases:
* ENOENT if no handler found; respond with 4.04
* ENOTSUP if an unknown request code received; respond with 4.00
* EPERM no handler found for the method; respond with 4.05

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-30 10:07:32 +01:00
Robert Lubos
37d39425ee net: tcp: Fix possible race between TCP work items and context unref
Fix the possible race between TCP work items already scheduled for
execution, and tcp_conn_unref(), by moving the actual TCP context
releasing to the workqueue itself. That way we can be certain, that when
the work items are cancelled, they won't execute. It could be the case,
that the work item was already being processed by the work queue, so
clearing the context could lead to a crash.

Remove the comments around the mutex lock in the work handlers regarding
the race, as it's not the case anymore. I've kept the locks however, as
they do make sense in those places.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:06:50 +01:00
Aleksander Wasaznik
dc834cb217 Bluetooth: l2cap: remove bt_l2cap_chan_send_cb
It has no more users and was an internal API.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Aleksander Wasaznik
8a3201c223 Bluetooth: att: Remove att use of bt_l2cap_chan_send_cb
EATT is the only user of `bt_l2cap_chan_send_cb`, and not necessary. We
can maintain the same functionality without it.

Instead of passing and storing the callback into l2cap, we can store it
in a callback queue in the ATT bearer struct.

This will allow us to remove that internal API later, in order to
streamline the l2cap API.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Aleksander Wasaznik
535e003a00 Bluetooth: Use CONFIG_BT_CONN_TX_USER_DATA_SIZE
Replace hardcoded value `8` with `CONFIG_BT_CONN_TX_USER_DATA_SIZE`,
that is `8` but is going to change.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Jukka Rissanen
1f1712a89f net: context: Add ARG_UNUSED to relevant places in opt handling
If some specific option is not enabled, then add missing
ARG_UNUSED() calls in relevant functions.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Jukka Rissanen
77e522a5a2 net: context: Refactor option setters
Set separate option setters for bool, uint8_t and uint16_t
values. Use those generic setters when storing the desired
option value.

The uint16_t option setter stores the value to uint16_t variable
and expects that user supplies int value.

For uint8_t value, it is expected that uint8_t value is supplied
instead of int.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Jukka Rissanen
55958d851f net: context: Refactor option getters
Set separate option getters for bool, uint8_t and uint16_t
values. Use those generic getters when fetching the desired
option value.

Noticed mixed usage (bool vs int) for txtime option. Changed
the code to use int type like in other options.

The uint16_t option getter gets the value from uint16_t variable
but returns int value to the caller, and also expects that user
supplies int value.

For uint8_t value, it is expected that uint8_t value is supplied
instead of int.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Arkadiusz Wadowski
90978b9f40 mgmt/osdp: Make OSDP slab init safer
slab_buff size is calculated based on size of osdp_ephemeral_data union
so it is safer to use same structure for slab init.
Changes in osdp_event or osd_cmd structures can cause crashes without this.

Signed-off-by: Arkadiusz Wadowski <wadowski.arkadiusz@gmail.com>
2023-11-30 10:02:20 +01:00
Konrad Derda
3c39f7efd9 net: hostname: trigger an event when the hostname changes
This commit introduces new network event that is triggered on every
change of the hostname.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-11-29 13:16:16 -06:00
Joshua Lilly
b3cba84dcd testsuite: coverage: allow access to gcov internals
This allows external applications wishing to report coverage data over
different interfaces the ability to do so by exposing the gcov list.

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-11-29 04:59:47 -08:00
Armin Brauns
5b1b260f80 bluetooth: add HCI driver parameter to set controller's public address
This allows HCI drivers to expose vendor-specific functions to set the
public address.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-11-29 10:44:25 +01:00
Dominik Ermel
e49ca8b967 settings: Remove leftover duplicate and unused declarations
Removed duplicated and unused code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-11-29 10:09:59 +01:00
Lukasz Majewski
25addd0984 net: ethernet: Add support for setting T1S PLCA parameters
The Zephyr's core ethernet code had to be adjusted to support setting T1S
PLCA parameters from user Zephyr programs.

Such approach allows more flexibility, as T1S network configuration;
especially PLCA node numbers, can be assigned not only via device tree
at compile time. For example user can read them from EEPROM and then
configure the network accordingly.

For now - the union in struct ethernet_t1s_param only consists of plca
structure. This can change in the future, when other T1S OA parameters -
like Receive/Transmit Cut-Through Enable (bits RXCTE/TXCTE in OA_CONFIG0
register) are made adjustable from user program.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2023-11-29 10:06:30 +01:00
Kyra Lengfeld
77ab683dc6 Bluetooth: Host: Align return lines of bt shell helper function phy2str
As other helper functions were introduced for the LE Power Control
Request Feature (see CONFIG_BT_TRANSMIT_POWER_CONTROL), it was noticed
that the return statements of switch cases should be on the next line
generally. This will align phy2str with the rest in bt.c.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Kyra Lengfeld
2c9af855bc Bluetooth: Host: Add bt shell functions LE Power Control Request Feature
To use LE commands of Le Power Control Request Feature one must utilize
the BT_TRANSMIT_POWER_CONTROL config.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Kyra Lengfeld
93e5cf6e61 Bluetooth: Host: Add LE Power Control Request Procedure APIs
This commits adds the LE API's for the LE Power Control Request Feature
in Zephyr.

The support of feature is provided with the controller-based feature
selection with BT_CTLR_LE_POWER_CONTROL_SUPPORT and is selectable via
BT_TRANSMIT_POWER_CONTROL.

With the new APIs, the applications will:
get improved reading of local and remote tx power
be aware of changes in remote or local tx power

Defined HCI commands in Core Spec v5.4:
7.8.117 LE Enhanced Read Transmit Power Level command:
improvement to existing local tx power reading.
7.8.118 LE Read Remote Transmit Power Level command:
Remote tx power is read through an event (LE Transmit Power Reporting)
7.8.121 LE Set Transmit Power Reporting Enable command:
Enables local or remote tx power reporting to monitor changes in tx power
7.7.65.33 LE Transmit Power Reporting event

Note: to utilize the Feature fully Nordic-LL-only vendor-specific commands
are needed. These will not be added in RTOS zephyr but instead
implemented in a maintainable way in sdk.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Kyra Lengfeld
56a5901955 Bluetooth: Controller: Add Kconfig for LE Power Control Request Feature
Add the controller Kconfig to use in Zephyr.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Robert Lubos
afd2e9561c net: tls_credentials: Add missing include dir for PSA API
Protected credential storage makes use of the PSA API, therefore it must
be present in the library include path. This was missed during the
recent CMakeLists.txt rework of this library.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-28 15:35:00 +01:00
Troels Nilsson
f0032a369d Bluetooth: L2CAP: Fix leaking tx metadata
Fix l2cap error handling generally not properly disposing of tx buffers for
enhanced channels; Any callbacks have to be called and the
l2cap_tx_meta_data has to be freed

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-11-28 15:34:51 +01:00
Troels Nilsson
b782b11f16 Bluetooth: L2CAP: l2cap_create_le_sig_pdu() no longer uses buf
The l2cap_create_le_sig_pdu function no longer uses the buf
argument; Remove it from the function

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-11-28 15:34:51 +01:00
Bartosz Bilas
fcee384aad zbus: remove superflous default n from runtime observers
By default, it is set to n, so remove that line.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2023-11-28 15:33:42 +01:00
Bartosz Bilas
ce812c1b25 zbus: rework buffer allocation Kconfig options
Add a name for the Kconfig choice symbol
indicating the Zbus subscriber buffer allocation
and adjust the name of the existing choices.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2023-11-28 15:33:42 +01:00
Pavel Vasilyev
161aadd590 Bluetooth: Mesh: Return immediately if labels not supported
This avoid unnecessary triggering of settings work.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-28 14:48:29 +01:00
Pavel Vasilyev
362924a693 Bluetooth: Mesh: Use ATOMIC_DEFINE instead of atomic_t
atomic_*_bit functions work with atomic_t arg as with array, therefore
the atomic variable should be declared using ATOMIC_DEFINE.

Coverity-CID: 333358
Fixes #65588

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-28 14:48:29 +01:00
Pieter De Gendt
473cc03c38 net: ip: icmp: Cleanup packet on failed priority check
A network memory leak would occur if the priority check fails.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-27 19:59:26 +01:00
Maciej Baczmanski
c2f1ff7f5f net: openthread: upmerge to 75694d2
Regular OpenThread upmerge to commit `75694d2`.

Move CONFIG_OPENTHREAD_PLATFORM_KEY_REFERENCES_ENABLE
from header file to Kconfig.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2023-11-27 19:59:04 +01:00
Jukka Rissanen
1961adfb96 net: socket: Return ENOTSUP for unknown socket type in recvfrom()
If we for some reason are supplied unsupported socket type in
recvfrom(), then return ENOTSUP error to the caller instead of
silently accept it by returning 0.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen
5488e76bb2 net: socket: Add support for filling receive pktinfo data
If user has set either IP_PKTINFO (for IPv4) or
IPV6_RECVPKTINFO (for IPv6) socket options, then the system
will return relevant information in recvmsg() ancillary data.

Fixes #36415

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen
80704bb361 net: socket: Add support for setting pktinfo options
Add IP_PKTINFO or IPV6_RECVPKTINFO BSD socket options that
can be used to get extra information of received data in
the ancillary data in recvmsg() call.

For IPV6_RECVPKTINFO see RFC 3542 for details.
For IP_PKTINFO see Linux ip(7) manual page for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen
c3acd56e27 net: context: Add support for setting receive pktinfo option
Add low level support for setting IP_PKTINFO or IPV6_RECVPKTINFO
socket options. The support is disabled by default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen
760c2f2949 net: sockets: Remove extra check from sendmsg()
There was double "if (status < 0)" check in sendmsg(),
remove the extra check.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen
4b365fab45 net: sockets: Add recvmsg() implementation
Add support for recvmsg() function which can return data
in msghdr struct (iovec).

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Carlo Caione
09fd6b6ea5 mem_mgmt: Add a memory attributes memory allocator
Using this new library it is now possible to leverage the memory
attribute property 'zephyr,memory-attr' to define and create a set of
memory heaps from which the user can allocate memory from with certain
attributes / capabilities.

When the CONFIG_MEM_ATTR_HEAP option is set, every region marked with
one of the memory attributes listed in
include/zephyr/dt-bindings/memory-attr/memory-attr-sw.h is added to a
pool of memory heaps used for dynamic allocation of memory buffers with
certain attributes.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-11-27 19:56:48 +01:00
Mariusz Skamra
b373079275 Bluetooth: audio: ascs: Remove spurious error message
This removes spurious error message printed when CIS has been
disconnected and it was not used by any of the endpoints.
This case is valid and may happen on Connection Timeout when the
controller reports ACL Disconnection first.
When the CIS Disconnection is reported after, the ASE is already in idle
state and the referenece to CIS has been already removed (on ACL
disconnection).

Fixes: #64896
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-27 12:16:30 +00:00
Vinayak Kariappa Chettimada
d36e085ecc Bluetooth: Controller: Fix scan aux context leak
Fix scan aux context leak under BT_CTLR_SCAN_UNRESERVED.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
d573951f0d Bluetooth: Controller: Revert back early abort of previous prepare
Revert back to implementation that did early abort of
previous prepare when a short prepare is enqueued.

Adds back implementation deleted in
commit 7f388bb70a ("Bluetooth: Controller: Fix short
prepare when many enqueued in pipeline").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
b444dc442b Bluetooth: Controller: Minor re-arrange advanced feature Kconfig
Minor refactor of Kconfig order such that the advanced
feature Kconfig is just above the enabling/visible of the
advanced features menu.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
ec7bdde22b Bluetooth: Controller: Improve preempt timeout req/ack counting
Improve preempt timeout request and acknowledge counting.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
12cefe1027 Bluetooth: Controller: Fix compiler warning when RL_SIZE=1
Fix compiler warning when BT_CTLR_RL_SIZE=1.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-25 08:54:39 -05:00
Vinayak Kariappa Chettimada
6c7c5bd5dd Bluetooth: Controller: Fix uninitialized ad_len_chain variable
Fix uninitialized ad_len_chain variable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-25 08:47:36 -05:00
Vinayak Kariappa Chettimada
ca45155a23 Bluetooth: Controller: Fix NULL pointer dereferencing in Sync ISO
Fix NULL pointer dereferencing when Host supplies an out of
bounds BIG handle.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-25 08:47:00 -05:00
Jun Lin
3f9d24e4c0 mgmt: ec_host_cmd: shi_npcx: support the enhanced mode
The original SHI module only has one output FIFO buffer. It costs a lot
when the driver has to send/change the protocol control code because it
must fill out all 128 bytes of output FIFO. In npcx4, we introduce
another output buffer in 1-byte depth. These two buffers can switch back
and forth during the transaction. We can use the single-byte buffer
to send the control code and the 128-byte FIFO to send the data payload.
It helps improve the SHI driver's efficiency.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2023-11-24 11:45:13 +01:00
Jun Lin
717a7835bb mgmt: ec_host_cmd: shi_npcx: add pm_policy lock
Implement the pm_policy lock to prevent the chip enters the deep slepp
mode while shi transaction is ongoing.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2023-11-24 11:45:13 +01:00
Lukas Streitenberger
10a167f6c1 Bluetooth: TBS: Added missing callState notifications
Changes of call state were not notified. Fixed by calling notify_calls
in respective functions.

Signed-off-by: Lukas Streitenberger <lukas.streitenberger@wsa.com>
2023-11-24 11:39:34 +01:00
Aleksandr Khromykh
3d37549bac Bluetooth: Mesh: allocate mesh max required buffer number
Since sending of public key was moved into system
work (https://github.com/zephyrproject-rtos/zephyr/pull/62331)
it uses the same context as a Host Tx buffer
allocator for gatt sending. Host cannot wait for
free buffer anymore. Mesh requires 4 buffers
to send max size frame(public key) during
provisioning.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-24 09:26:37 +01:00
Krzysztof Chruściński
465446e5aa logging: Add string validation to detect %p misuse
Logging shall not use character pointers with %p because in
certain configurations it may lead to memory faults. A compile
time detection is added. If faulty usage is detected then
message is replaced with error message which indicates which
message failed and what shall be done (casting to a pointer
of different type).

Validation is enabled only for configurations which remove
strings from binary as otherwise it may impact CI execution
time.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-24 09:23:18 +01:00
Juliane Schulze
eeb6bf7dd9 input: make short-inputs optional
By making short inputs optional, the user can bypass short-events all
together if necessary (e.g. custom button-press listener).

Signed-off-by: Juliane Schulze <juliane.schulze@deveritec.com>
2023-11-23 09:51:57 +00:00
Daniel Leung
40ba4015e3 kernel: mm: only include demand_paging.h if needed
This moves including of demand_paging.h out of kernel/mm.h,
so that users of demand paging APIs must include the header
explicitly. Since the main user is kernel itself, we can be
more discipline about header inclusion.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-23 10:01:45 +01:00
Siddharth Chandrasekaran
5b24a8ad72 mgmt/osdp: Fix off-by-one in buf len checks
Initially, the command/reply ID byte was not part of the data length
macros. But later, when it was changed to include it, the buffer length
checks was not adjusted. Due to this, we were not using the last byte in
the buffer. Fix this issue by correcting the condition.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-11-23 09:59:52 +01:00
Siddharth Chandrasekaran
061a87aff8 mgmt/osdp: Replace __ASSERT() with an explicit if
Commit c7fec71193 ("mgmt/osdp: Add length checks for commands and
replies") attempted to remove code duplication by adding a macro to perform
a length check. At the time, a CI linter did not like macros with control
flow so the code was switched to a method which called __ASSERT() on this
condition.

The __ASSERT() macro is a nop if CONFIG_ASSERT=n (which is the default) and
causes the buffer access to be unguarded which may lead to OOB accesses.
This patch fixes the issue by reintroducing the if check.

Fixes: c7fec71193.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-11-23 09:59:52 +01:00
Bartosz Bilas
43d5f39209 zbus: add MULTITHREADING dependency
Zbus uses mutexes internally that are available
only when MULTITHREADING is enabled so add
it to fix the following error:

/opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/
12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/subsys/
zbus/libsubsys__zbus.a(zbus.c.obj): in function `k_mutex_init':
/builds/zephyr/mcuboot/zephyr/include/generated/syscalls/kernel.h:969:
undefined reference to `z_impl_k_mutex_init'

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2023-11-22 21:54:44 +01:00
Kamil Piszczek
1ab08634f2 settings: nvs: improve the name ID metadata handling on delete operation
Improved the updates to the name ID metadata (NVS_NAMECNT_ID) item
in the Settings NVS backend implementation. The improvements should
make the implementation more robust in handling edge cases such as:
power downs, resets or a case in which the storage partition is
full. In the last case, the NVS backend could return an ENOSPC error
in the context of the settings_delete API. This change also fixes
this issue.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-22 14:54:53 +00:00
Alexander Vasiliev
76276e2bd3 net: mqtt-sn: Remember incoming registered topic name
When a client uses wildcard subscription and a new message is
published to the matching topic for the first time, the gateway
sends REGISTER message to the client, containing the exact
topic name and a new topic ID.
This change fixes adding these topic ID and name to the internal
topics list.

Signed-off-by: Alexander Vasiliev <alexander.vasiliev@siemens.com>
2023-11-22 09:53:33 +01:00
Alexander Vasiliev
6caf76346a net: mqtt-sn: Add a function to get topic name by topic ID
Add a function to MQTT-SN library API to get topic name by ID
from the internal topics list.

Signed-off-by: Alexander Vasiliev <alexander.vasiliev@siemens.com>
2023-11-22 09:53:33 +01:00
Mariusz Skamra
e1a14bad30 Bluetooth: audio: has: Add non-volatile settings
This adds non-volatile settings for the HAS Server. Those are needed to
restore the client awareness of preset list entries exposed by the
server. Based on the settings, the implementation determines how to
notify the client about the HAS related characteristic value changes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-22 09:51:33 +01:00
Ibe Van de Veire
1d0f47b005 net: ip: igmp: add igmpv3 support
Added igmpv3 support based on the already existing structure for igmpv2.
The already existing api is not modified to prevent breaking exisiting
applications.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
2023-11-21 15:50:31 +01:00
Ibe Van de Veire
ca7ce90dc7 net: ip: utils: changed input arguments of igmp_checksum to net_pkt
Added igmpv3 checksum function to make it possible to calculate the
checksum of a complete igmpv3 pkt at once.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
2023-11-21 15:50:31 +01:00
Jukka Rissanen
bc8b5b3813 mgmt: updatehub: Fix CMakeLists.txt file
Fix the CMakeLists of the updatehub to link with mbedtls.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-21 08:48:04 +00:00
Declan Snyder
cf42b8b2fb net: sockets: fix shadowing warning
Fix compiler local variable shadowing warning

Rename ret to bytes_sent in offending funciton

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-11-21 08:48:04 +00:00
Declan Snyder
7c72d4a2d6 net: Fix CMakeLists
Fix the CMakeLists of the tls_credentials and sockets folders
to link/interface to the net library instead of the zephyr library.
This fixes issues where some files are not found in the link interface
when compiling the sources in this folder.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-11-21 08:48:04 +00:00
Robert Lubos
aa6f698d31 net: zperf: Fix TCP packet counting
Make sure we send the entire packet buffer before bumping the packet
counter, send() does not guarantee that all of the requested data will
be sent at once with STREAM socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Robert Lubos
e6d90b409b net: sockets: tls: Set errno on TX waiting error
In case underlying socket reported error while waiting for TX, the
errno value was not set accordingly. This commit fixes this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Robert Lubos
3a38ec1aaa net: tcp: Feed TX semaphore on connection close
Otherwise, if the application was for example blocked on poll() pending
POLLOUT, it won't be notified.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Robert Lubos
9976ebb24b net: tcp: Rework data queueing API
Rework how data is queued for the TCP connections:
  * net_context no longer allocates net_pkt for TCP connections. This
    was not only inefficient (net_context has no knowledge of the TX
    window size), but also error-prone in certain configuration (for
    example when IP fragmentation was enabled, net_context may attempt
    to allocate enormous packet, instead of let the data be fragmented
    for the TCP stream.
  * Instead, implement already defined `net_tcp_queue()` API, which
    takes raw buffer and length. This allows to take TX window into
    account and also better manage the allocated net_buf's (like for
    example avoid allocation if there's still room in the buffer). In
    result, the TCP stack will not only no longer exceed the TX window,
    but also prevent empty gaps in allocated net_buf's, which should
    lead to less out-of-mem issues with the stack.
  * As net_pkt-based `net_tcp_queue_data()` is no longer in use, it was
    removed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Robert Lubos
16fd744c13 net: pkt: Add function for allocating buffers w/o preconditions
Add new function to allocate additional buffers for net_pkt, w/o any
additional preconditions/checks. Just allocate what was requested.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Emil Gydesen
1829cf4324 Bluetooth: Audio: Add set functions for codec meta
Add set function for all metadata types for both
codec_cfg and codec_cap.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-21 08:38:29 +00:00
Bjarki Arge Andreasen
8128a726a4 modem: backend: uart_async: Remove UART flush
The UART flush is not relevant for the async UART implementation.
UART drivers should handle this internally.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2023-11-20 13:03:08 +01:00
Bjarki Arge Andreasen
6f1d49e7b3 modem: backend: uart_async: Use single ring buffer
Use single ring buffer and protect it with a spinlock as it is
shared between backend and UART thread (ISR). This is simpler
than the double ring buffer setup.

The receive idle timeout has also been made configurable
instead of being a hardcoded value.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2023-11-20 13:03:08 +01:00
Bjarki Arge Andreasen
7cf2b0fc9d modem: backend: uart_async: Extend "closed" requisites
The current implementation only waits for the RX disabled event
to determine if the UART is closed. It should wait for all RX
buffers to be released, and the TX to be done as well.

We now also call uart_tx_abort() when closing the pipe.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2023-11-20 13:03:08 +01:00
Henning Fleddermann
8e4c588eab net: lib: lwm2m: Use int16_t for signal quality
RSRQ is the ratio between send and received signal strength and usually
understood/expected to be represented as a ratio in dB and as such always
has a negative range. So to allow RSRQ to be represented correctly the
resource must allow negative values, but currently it's limited to unsigned
8bit integers.

Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
2023-11-20 13:01:23 +01:00
Alberto Escolar Piedras
4a0dec6a5a subsys/bindesc: Fix kconfig dependency
BINDESC can be used with any POSIX arch based target,
not just native_posix.
Fix the kconfig filter and the sample yaml filter.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 12:02:48 +01:00
Bjarki Arge Andreasen
0aa6f3f3ff modem: cmux: Fix coverity issues
Possible NULL pointer dereferences where discovered by static
code analysis, they are addressed in this commit.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2023-11-20 09:24:58 +01:00
Robert Lubos
8a75a4b9db net: shell: Fix array indexing with dynamic iface command
Network interface numbering starts from 1, therefore when accessing
help/index array, the interface index should not be used directly, but
rather decremented by 1, to avoid out-of-bound access on those arrays.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:47 +01:00
Robert Lubos
f0247131bf net: tftp: Ensure the error message fits into transmit buffer
Make sure that the error message does not overflow the transmit buffer
when copying the error message string.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:18 +01:00
Robert Lubos
59544d58ef net: tftp: Verify connect return value
Verify that connect() succeeded before reporting success.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:18 +01:00
Robert Lubos
69e6b3a563 net: tftp: Log transmit error
There's not really much to do when the transmission of the error reply
fails, but we can at least log the failure.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:18 +01:00
Robert Lubos
a3362d969d net: lwm2m: Explicitly initialize path_list_size variable
To get rid of compiler warning about potential use of uninitialized
variable.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:11 +01:00
Robert Lubos
7f7d019b25 net: lwm2m: Add error checks for option encoding in BS registration
Add missing error checks when encoding CoAP options for Bootstrap
Register message

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:11 +01:00
Robert Lubos
ec50e5393c net: lwm2m: shell: Add error check for string to float conversion
The result of string to float conversion in LwM2M shell write command
was not verified, which could result in incorrect data being written to
the resource.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:11 +01:00
Pavel Vasilyev
07848a4456 Bluetooth: Mesh: Fix integer overflow
Fix potential integer overflow by casting one of operands to int64_t.

Coverity-CID: 329961
Fixes #65356

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Pavel Vasilyev
3bc17d1d18 Bluetooth: Mesh: Fix async behavior of Private Beacon Client API
The Private Beacon Client API requires a response argument to allow to
call the API in the asynchronous manner
(https://github.com/zephyrproject-rtos/zephyr/pull/56426).

Because the removal of the EXPERIMENTAL tag for this API was not
released yet, it should be OK to change this API.
The EXPERIMENTAL tag has been removed here:
https://github.com/zephyrproject-rtos/zephyr/pull/64866

Coverity-CID: 330039
Coverity-CID: 330029
Coverity-CID: 329977

Fixes #65336
Fixes #65338
Fixes #65354

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Pavel Vasilyev
b15611eb28 Bluetooth: Mesh: Check return value of bt_conn_get_info
Coverity-CID: 323094
Fixes #65366

Coverity-CID: 323081
Fixes #65370

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Pavel Vasilyev
6a5d082cc5 Bluetooth: Mesh: Ignore return value of settings_delete
This suppresses warning from Coverity.

Coverity-CID: 330638
Fixes #65330

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Robert Lubos
e702ecc8fb net: dhcpv6: Verify net_pkt_skip() return value
Verify the return value of net_pkt_skip() function, in case the parser
ignores the unrecognized options, so that in case the option was
malformed and the actual provided option length exceeds the packet
length, it is recognize (net_pkt_skip() should fail then).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:23:22 +01:00
Benjamin Cabé
79c677c0ef net: lib: coap: Fix NULL pointer dereference
As reported by Coverity, cpkt was being used before checking it's not
NULL.
Fixes #65372 / CID: 323075

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-11-20 09:23:12 +01:00
Lingao Meng
5f1c2f199b Bluetooth: Mesh: Make element as rodata
the reason is that the Mesh Profile clearly stipulates that Mesh nodes
cannot change their own element definitions.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-20 09:22:55 +01:00
Henrik Brix Andersen
c0c8952739 shell: do not enable subsystem/driver shell modules by default
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.

The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.

This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-11-20 09:21:40 +01:00
Benjamin Lindqvist
1d6d24b6ef net: lwm2m: don't load credentials on plaintext context
Since lwm2m_load_tls_credentials(ctx) will assume that the ctx has a
valid security object assigned to it, it should not be called at all
when ctx.use_dtls == false.

This solves a major bug where LwM2M comms are DTLS encrypted but FOTA is
allowed to be plain-text.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2023-11-20 09:20:43 +01:00
Pieter De Gendt
0156593221 bindesc: Use zephyr_library_add_dependencies
Replace usage of add_dependencies(${ZEPHYR_CURRENT_LIBRARY} ...)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-20 09:19:34 +01:00
Jukka Rissanen
5209666539 net: mdns: Fix compile error when using clang
No issues with gcc but clang gives this error for
the *v4 variable few lines below.

.../lib/dns/mdns_responder.c:712:2: error: expected expression
        struct net_context *v4;

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen
5049a049db net: mdns: Create a listener to all available network interfaces
Instead of just listening first network interface in the system,
install a multicast listener to all available network interfaces.

Fixes #18748

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen
dd2a222086 net: if: Add helper to calculate number of interfaces
Add a helper macro that can be used at runtime to return
the number of network interfaces in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen
3f891ced3a net: conn: Check also network interface for duplicates
When verifying if there are duplicate connections, check
also network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen
8157b48734 net: context: Add function to bound to a network interface
Helper function that marks the net_context to bound to a
network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen
31ee2e678d net: context: Allow binding to different interfaces
Allow user to bind to different network interface. This is
useful if binding a multicast address to a certain network
interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jonathan Rico
dfd7624270 Revert "Bluetooth: att: use a dedicated metadata struct for RSP PDUs"
This reverts commit 14858d96d87d33ebb593d61380f4607e14107287.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-17 09:26:08 +01:00
Jonathan Rico
bd9c35b496 Revert "Bluetooth: att: re-use REQ buf for RSP"
This reverts commit aa7954bd4725bbd46e974a03c0d0312b7e9a483f.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-17 09:26:08 +01:00
Jonathan Rico
530e845f92 Revert "Bluetooth: att: don't re-use the ATT buffer for confirmations"
This reverts commit 4cd0748a407b118145916393a954231ee11abb1e.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-17 09:26:08 +01:00
Guennadi Liakhovetski
e0ea44cbfa llext: fix symbol address calculation for ET_DYN
Symbopl tables of ELF objects of type ET_REL contain offsets instead
of addresses as for ET_DYN.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-17 09:25:42 +01:00
Guennadi Liakhovetski
21cea07b8c llext: fix a confusion between section indices
A common pattern is used throughout llext.c:

ext->mem[ldr->sect_map[sym.st_shndx]]

where ldr->sect_map[sym.st_shndx] actually contains indices from
enum llext_section but ext->mem[] is indexed, using enum llext_mem
values. Fix this by changing ldr->sect_map[] to actually contain
enum llext_mem values.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-17 09:25:42 +01:00
Guennadi Liakhovetski
eb3071ebe8 llext: check for an allocation failure
Add a missing allocation failure check in llext_export_symbols().

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-17 09:25:42 +01:00
Guennadi Liakhovetski
fb92636056 llext: remove a symbol count copy
The symbol count in struct llext_loader is redundant, we already have
one in struct llext_symtable, accessible via struct llext. Remove the
redundant copy.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-17 09:25:42 +01:00
Guennadi Liakhovetski
db43d35f61 llext: (cosmetic) remove an unused variable
op_code in llext_link() is unused, remove it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-17 09:25:42 +01:00
Guennadi Liakhovetski
60aef84cad llext: (cosmetic) use a local variable
Simplify llext_copy_symbols() by using a local variable to store a
pointer.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-17 09:25:42 +01:00
Guennadi Liakhovetski
fef999c06f llext: (cosmetic) remove "inline" in llext.c
Let the compiler decide which functions to inline.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-17 09:25:42 +01:00
Aleksander Wasaznik
bf2f065876 Bluetooth: Host: Remove ifdef around sc_indicate
Instead, `sc_indicate` is defined as a no-op when if would previously
not be defined.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-17 09:25:34 +01:00
Alberto Escolar Piedras
ebd70f959f flash host fuse access: Fix for native_sim
For native_sim we need to have the fuse library linked with the
native simulator runner, not with the embedded code.
Let's fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-17 09:23:48 +01:00
Seppo Takalo
8cfede8f2e net: lwm2m: Support DTLS Connection Identifier
DTLS Connection Identifier support requires DTLS stack
that supports it. MbedTLS support in Zephyr is already
ported in, also some offloaded sockets support it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-17 09:23:29 +01:00
Lingao Meng
2cd8d40b97 Bluetooth: Mesh: Split Model Structure
Split Model Variables to separate structue.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-16 16:52:14 +01:00
Lingao Meng
ab08f34fd9 Bluetooth: Mesh: Make bt_mesh_model as rodata
Since model struct most of member should not change at run time,
so mark as const will be suitable and safely.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-16 16:52:14 +01:00
Flavio Ceolin
d027d26298 logging: LOG_PRINTK disabled in userspace
LOG_PRINTK needs to run in supervisor mode and since there
is no syscall that allows it to be called from userspace, this
option has to be disabled when userspace is selected.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-16 09:25:21 -05:00
Flavio Ceolin
a48e68441b logging: Remove syscall for z_log_msg_runtime_vcreate
This syscall is completely problematic in userspace, it does
not check ANY parameter that is given and it uses variadic argument
that are not copied / checked before being used in the implementation,
instead it just pass a pointer to user stack with unknown data is
blindly consumed by the kernel.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-16 09:25:21 -05:00
Mike J. Chen
85fb2873e4 logging: log_core: support CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD value of 1
Previous implementation didn't work if CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD
was set to 1. Minmimum value that worked was 2. A value of 1 would
just be ignored and act like 0 with threshold triggerring disabled.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2023-11-16 09:28:26 +01:00
Yong Cong Sin
72fea5df56 shell: backends: uart: add public function to access smp shell data
`smp_shell_input_timeout_handler`. Create a public function in
the `shell_uart.c` for it to get the pointer to the
`smp_shell_data` and fix the compilation error.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-15 16:38:16 +01:00
Guennadi Liakhovetski
6246caa643 llext: (cosmetic) rename a variable to match its role
str_cnt in llext_find_tables() is actually used to count sections,
rename it to better match that usage.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-15 14:17:08 +00:00
Guennadi Liakhovetski
6058512b06 llext: use provided size for more generic code
Use .sh_entsize instead of sizeof(elf_rel_t) to make code suitable
for both REL and RELA types.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-15 14:17:08 +00:00
Guennadi Liakhovetski
68b4898b7e llext: skip first dummy symbol table entry
The first entry in the symbol table is empty, skip it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-15 14:17:08 +00:00
Guennadi Liakhovetski
a88facacaa llext: clarify the use of loop variables, simplify code
Several cosmetic changes with no change in functionality:

The pos variable in multiple functions is used as a loop variable -
it's initialised before the loop starts and then it's incremented for
each loop iteration. Move it to the loop header for readability.

"return ret" is clearer than "goto out" where the "out" label does
nothing but "out: return ret" because one sees immediately that the
function is terminated at that location with no further actions
without the need to check the "out" label.

k_heap_free(heap, NULL) is valid, no need to check the address to be
freed for NULL.

Object counters can be simple (unsigned) integers, no need to make
them size_t or elf_word.

"return 0" is simpler than "return ret" because it shows the return
value immediately without the need to check what it can be at that
location.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-15 14:17:08 +00:00
Mariusz Skamra
ba61420504 Bluetooth: audio: ascs: Retry ASE state notifications on error
This adds retry logic for ASE state notifications if failed due to
insufficient number of buffers to send ATT PDU. The state transition is
retried after connection interval delay.

Fixes: #64574
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-15 10:03:07 +01:00
Tomasz Moń
b5f4d8374a net: buf: Preserve buffer pointer in destroy callback
The use case is to have a netbuf pool that is used exclusively with
net_buf_alloc_with_data() where the destroy callback takes care of
freeing the actual data buffer pointed to by __buf.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-11-15 10:02:55 +01:00
Krzysztof Chruściński
d31424e040 mgmt: osdp: Add dependency to UART runtime configuration
Force enabling of the UART runtime configuration for OSDP.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-15 10:02:18 +01:00
Krzysztof Chruściński
b032382011 modbus: Add dependency to UART runtime configuration
Force enabling of the UART runtime configuration for modbus serial.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-15 10:02:18 +01:00
Krzysztof Chruściński
7778b7d46d debug: gdbstub: Add dependency to UART runtime configuration
Force enabling of the UART runtime configuration for GDBSTUB.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-15 10:02:18 +01:00
Lingao Meng
1f4dacad08 Bluetooth: Mesh: Remove relay sets config for adv
Separate queue should also used for lagecy adv, due to
when local queue has adv buf, k_poll will process local queue.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-15 10:01:47 +01:00
Yong Cong Sin
aa71ed4a1f logging: backend: uart: compile the uart_dev pointer conditionally
Compile the `uart_dev` pointer only when necessary
(when `zephyr,log-uart` is used), this saves 4 bytes in
32-bit systems and 8 bytes in 64-bit systems.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-14 12:26:48 -05:00
Yong Cong Sin
2049aa8d16 logging: backend: uart: variable shouldn't have the same name as struct
Rename the `device` variable in the `struct lbu_cb_ctx` to
`uart_dev`, as it is a convention in Zephyr to not have the
struct variable name after the struct.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-14 12:26:48 -05:00
Yong Cong Sin
1b4a647950 logging: backend: uart: append index conditionally for compatibility
Updated the `LBU_DEFINE` so that the index is appended only
when given to improve backward compatibility.

When it is depending on the `zephyr,console` node, the backend
is defined as `log_backend_uart`.

When it is depending on the new `zephyr,log-uart` node, the
backend is defined as `log_backend_uart0`,
`log_backend_uart1`, and so on.

Updated the names of the internal variables to follow the same
naming convention.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-14 12:26:48 -05:00
Krzysztof Chruściński
e6e6515972 shell: uart: Rework Kconfig dependencies
When UART asynchronous API support was added to shell it was set up
to be the default one and was turning on asynchronous API if it was
supported. However, it may lead to complation failures if device
requires additional setup for asynchronous UART (e.g DMA in device
tree). Becuase of that, it is reverted back to use interrupt driven
API and use asynchronous API if it is already enabled in the
application.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-14 16:09:08 +02:00
Krzysztof Chruściński
6d2e3b59a5 mgmt: mcumgr: smp_shell: Change the way shell uart device is fetched
SMP shell was looking into internal shell uart structures to get
uart device. This structures are now internal to the shell and
cannot be used. Using device tree chosen instead.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-14 16:09:08 +02:00
Krzysztof Chruściński
d6a3fd7cf0 shell: uart: Add missing casting of the data pointer
Fixing compilation failure due to treating void pointer as uint8_t
array. Added missing casting.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-14 16:09:08 +02:00
Georges Oates_Larsen
9f093ab731 net: tls_credetials: Add TLS Credentials shell
Adds a shell interface for TLS Credentials, allowing management of
credentials via the Zephyr shell

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-11-14 10:40:02 +00:00
Georges Oates_Larsen
f5d12102a0 net: tls_credentials: sectag iterators
Add (internal) support for sectag iterating.

Also officially marks negative sectag values as reserved for internal
use.

This will allow a prospective TLS credentials shell to iterate over all
available credentials.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-11-14 10:40:02 +00:00
Georges Oates_Larsen
16bd8a82a6 net: tls_credentials: credential_digest
Adds an internal credential_digest for generating a string digest of
credentials.

Such digests would allow users of a prospective TLS credentials shell to
verify the contents of a given credential without directly accessing
those contents.

Offloading the digest process to the underlying backend allows backends
for which private portions are not directly accessible to be eventually
supported.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-11-14 10:40:02 +00:00
Vinayak Kariappa Chettimada
09c69731cd Bluetooth: Controller: Reduce RTN for requested Max Transport Latency
Add implementation to reduce CIG's CIS retransmissions so as
to meet the Host requested Maximum Transport Latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-14 09:46:02 +01:00
Kamil Piszczek
f6d6742ca1 bluetooth: id: make sharing RPA between adv sets optional
Added a Kconfig option that makes the RPA sharing feature optional. By
default, the Zephyr Bluetooth stack now uses the RPA rotation policy
that was active before the introduction of the RPA sharing functionality
in the following PR:

https://github.com/zephyrproject-rtos/zephyr/pull/55449

The new Kconfig option configures the advertising sets linked with the
same Bluetooth identity to use the same Resolvable Private Address in
a given rotation period. After the RPA timeout, the new RPA is
generated and shared between the advertising sets in the subsequent
rotation period.

When this option is disabled, the generated RPAs of the advertising
sets differ from each other in a given rotation period.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-14 09:22:51 +01:00
Krzysztof Chruściński
5e4e944cc0 shell: backends: uart: Rework and add support for async API
Rework UART backend to clearly use single instance approach as
before it was a bit messy with some parts of implementation indicating
multi-instance approach and some single instance. Backend has been
around for years and multi-instance requirement never came.

Added support for UART asynchronous API which is more efficient
in terms of power consumption and performance. Asynchronous API
support is using uart_async_rx helper module for handling data
received asynchronously.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-14 09:21:46 +01:00
Jordan Yates
e74676223a bluetooth: host: gatt: statically init callback list
Statically initialise the callback list so that subscriptions can be
registered before the call to `bt_enable`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-11-14 09:21:16 +01:00
Dominik Kilian
28df44946f ipc: add dynamically allocated buffers to icmsg
The icmsg and icmsg_me backends has limitations in context of
concurrent access to single instance. Some limitations are:
* sending by more thread at the same time may cause -EBUSY
* allocating TX buffer will cause errors in other threads that want
  to allocate before first thread sent the message,
* during no-copy receive, when RX buffer is on hold receiving is
  totally blocked.
This backend resolves those limitations by adding dynamically allocated
buffers on shared memory next to ICmsg circular buffer. The data is
passed using those buffers, so concurrency is not a problem. The ICmsg
is used only to pass short 2-byte messages containing references to
those buffers. The backend also supports multiple endpoint.
The ipc/icmsg_me sample was modified to support this backend.

Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
2023-11-13 11:11:43 +01:00
Martin Jäger
c72b9f5048 lorawan: use callback function signature typedefs
This avoids duplication of the function signature in several places and
makes the API documentation more clean.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-11-13 09:53:32 +01:00
Martin Jäger
8b7c8b09ec lorawan: rename lorawan_set_battery_level_callback and make it void
Rename the lorawan_set_battery_level_callback to
lorawan_register_battery_level_callback to make it consistent with other
functions for downlink and data rate changed callbacks.

Also making the function void for consistency. The get_battery_level
already checks if the callback is NULL before invoking it.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-11-13 09:53:32 +01:00
Pavel Vasilyev
64e1d0c3be bluetooth: mesh: Don't write to const value
`bt_mesh_default_key` is declared as const and thus located in flash.
`bt_mesh_cdb_subnet_key_export` tries to copy to that address which
results in a Bus Fault.

Use separate array for storing net_key.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-13 09:51:25 +01:00
Pieter De Gendt
655c72c52e net: lib: coap: coap_server: Allow clients to refresh observe requests
A CoAP client can re-issue an observe request (same endpoint and token)
to refresh it's subscription. No new observer should be registered in
this case.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-13 09:50:19 +01:00
Pieter De Gendt
cbf9680f96 net: lib: coap: Add coap_find_observer
Add a function to the public CoAP API to find and return the unique
observer based on the address and token.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-13 09:50:19 +01:00
Robert Lubos
61c392c5b1 net: iface: Introduce TX mutex locking
A recent iface lock removal in ed17320c3d
exposed issues with concurrent access on TX to drivers that are not
re-entrant.

Reverting that commit does not really solve the problem, as it would
still exist if multiple Traffic Class queues are in use.

Therefore, introduce a separate mutex for TX data path, protecting the
L2/driver from concurrent transfers from several threads.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-13 09:49:57 +01:00
Marcus Penate
250ff71c64 zbus: Fix parameter order of net buf pool fixed define
Fixed order of pool-size and data-size parameters
in use of `NET_BUF_POOL_FIXED_DEFINE()`

Signed-off-by: Marcus Penate <marcus.penate@ellenbytech.com>
2023-11-13 09:49:49 +01:00
Jamie McCrae
6c4b89cb00 mgmt: mcumgr: grp: os_mgmt: Add datetime get/set functions
Adds datetime set and get functions which allow for setting and
getting the current time to/from the rtc alias device

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-13 09:48:13 +01:00
Chris Friedt
c0064f1de8 logging: uart: support multiple instances
Extends the log_backend_uart to support logging to multiple
UART instances.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-13 09:47:06 +01:00
Robert Lubos
8aba7740b8 net: lwm2m: Fix core objects version reporting
Core objects version reporting was broken for LwM2M version 1.1, as the
default object version not necessarily matches the LwM2M version.
Therefore, implement a table with default object versions for particular
LwM2M version, which can be looked up when determining whether it's
needed to include object version or not during Registration/Discovery.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-13 09:46:06 +01:00
Mariusz Skamra
f434198a2b Bluetooth: att: Retry ATT request if security elevation is in progress
If the conn security elevation is already in progress, retry the ATT
request if failed due to security reasons.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-13 09:45:20 +01:00
Tomasz Moń
f12e1d75ed usb: device: cdc_acm: Always buffer poll out data if possible
Queue characters in TX ring buffer regardless of interface state. This
allows simple applications that print basic output to CDC ACM port to
not care about connection or DTR state. Note that depending on actual
application requirements it might be still wise to wait for DTR before
trying to send data.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-11-13 09:43:46 +01:00
Tomasz Moń
0127d000a2 usb: device: cdc_acm: Use ZLP to detect initial host read
Prevent ECHO on Linux by arming IN endpoint with ZLP when interface is
configured and making sure that actual payload is only sent after
initialization timeout. The ZLP is not visible to host side applications
because the applications are really accessing tty buffer and received
ZLP does not modify tty buffer in any way.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-11-13 09:43:46 +01:00
Emil Gydesen
06d5a625a6 Bluetooth: Audio: Add codec cap set functions
Add set functions for codec capability, to set all
assigned number values in the bt_audio_codec_cap
struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-13 09:42:35 +01:00
Emil Gydesen
c35e677d82 Bluetooth: Audio: Split ltv_set_val from codec_cfg_set_val
Add a new function, ltv_set_val, that did most of the
data manipulation from codec_cfg_set_val, so that we can
reuse that code for the codec cap and codec meta
functions as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-13 09:42:35 +01:00
Fabio Baltieri
6ae03d98a0 drivers, subsys: sort the lists again, mark the blocks for checking
Sort the Kconfig and CMakeLists include blocks again, and mark the start
and end of the blocks so that the CI can keep them sorted.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-13 09:41:05 +01:00
Magdalena Kasenberg
647207c024 bluetooth: leaudio: Fix missing set of BIG_Encryption
In the PTS BASS/SR/CP/BV-19-C test case a client executes Set
Broadcast Code operation of Broadcast Audio Scan Control Point
characteristic with Broadcast_Code set to an invalid value.
After syncing to an ISO stream there is an expected failed attempt
to decrypt the stream data, but the host does not set BIG_Encryption
value to the expected value 0x03 (BT_BAP_BIG_ENC_STATE_BAD_CODE).
Add missing BIG_Encryption state into the failing check.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-10 10:40:40 +01:00
Guennadi Liakhovetski
0bf08e5775 llext: use llext_peek() for section pointers
Try to use llext_peek() for section pointers. If it's supported and
succeeds we don't need to allocate buffers.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-10 10:40:26 +01:00
Guennadi Liakhovetski
ce4cdac3c0 llext: add llext_peek()
The only way so far to access extension images is via a memory
buffer. Since this, supposedly, will also be a rather common method,
it makes sense to add a method to access extension data quickly by
obtaining a pointer instead of copying data into local buffers. Add a
llext_peek() method for that.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-10 10:40:26 +01:00
Guennadi Liakhovetski
a9a82d557c llext: use elf_rela_t instead of elf_rel_t
elf_rela_t contains elf_rel_t exactly and contains an additional
field at the end. Therefore pointers of that type can be used for
both types, making the code generic.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-09 18:21:27 +01:00
Guennadi Liakhovetski
f0527b5571 llext: add a weak arch_elf_relocate() stub
The module linking API can be used for shared objects with no
architecture-specific relocation code. Add a weak function for such
cases.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-09 18:21:27 +01:00
Guennadi Liakhovetski
ade72c2b3a llext: remove a superfluous variable initialisation
ret in llext_load() is always assigned before use, remove its
redundant initialisation.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-11-09 18:21:27 +01:00
Magdalena Kasenberg
35f326b821 bluetooth: leaudio: Termination of PA at Modify Source
From BASS spec:
If the PA_Sync parameter value written by the client is set to a value
of 0x00 (Do not synchronize to PA) and the server is synchronized to
the PA, the server shall stop synchronization with the PA and shall
write a value of 0x00 (Not synchronized to PA) to the PA_Sync_State
field of the Broadcast Receive State characteristic .

Fixes BASS/SR/CP/BV-12-C test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-09 15:32:32 +01:00
Pieter De Gendt
e8e6d23270 net: lib: coap: Add CoAP server shell
Add shell commands that allow to start/stop CoAP services.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt
ae6e0106e7 net: lib: coap: Add service support
Add CoAP services and server as a subsystem implementation.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt
5227f24815 net: lib: coap: Add support for observer event callbacks
This commit adds the option to register an event handler to CoAP
resources when observers are added/removed.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt
291743b686 net: lib: coap: coap_remove_observer result type
Change coap_remove_observer to return the result of removing the
observer if found.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt
fac670e1e2 net: lib: coap: Add coap_find_observer_by_token
Add a CoAP helper function to find a matching observer by token.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt
cc89338888 net: lib: coap: Add coap_packet_is_request
Add function to check if CoAP packet is a request to the public API.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt
0a4668a2f7 net: lib: coap: Add coap_uri_path_match
Add URI path matching function to public CoAP API.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt
bea29cf631 net: lib: coap: Add resources length based variants
Add length variant for the well known core resource and parsing.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Chaitanya Tata
ed17320c3d net: Remove unnecessary lock
The main action in this function it queueing the packet for
transmission which doesn't need a lock and interface flags use atomic
operations.

So, remove the unnecessary lock.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-09 10:21:13 +00:00
Emil Obalski
d769a92520 ipc: icmsg: Allow to support future versions
Allow magic number to be longer than the sizeof(magic).
This will allow to support future versions of the icmsg
with backwards compatibility.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-11-09 10:19:02 +00:00
Emil Obalski
eb4fc3f083 ipc: backends: Port IcMsg based backends to use pbuf
Replace spsc_pbuf with pbuf implementation dedicated to
be used by IcMsg based backends.
The pbuf is written on top of simple read/write semantics
with minimal footprint and code complexity

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-11-09 10:18:37 +00:00
Emil Obalski
380f83bab1 ipc: Add pbuf implementation
This adds implementation of secure packed buffer.
Secure packed buffer is added with intention to be used
in icmsg backed backends.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-11-09 10:18:37 +00:00
Emil Obalski
f93243b68f ipc: Remove nocopy feature from icmsg_me backend
Remove nocopy feature from icmsg_me backend.
The backend is not meant to be used to send big
data chunks thus no-copy feature is removed.
If one wants to use no-copy it is recommended
to use icmsg_me only for control messages while
allocator will shall be written seperately.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-11-09 10:18:37 +00:00
Seppo Takalo
d69d4013d3 net: lwm2m: Fix blockwise response code
In CoAP blockwise the client is supposed to
respond with 2.31 Continue code on Ack. This was recently
broken when Block1 parsing was moved after the initialization
of reponse packet. We need separate CoAP API to modify the code
of existing CoAP packet.

Also Ack packet should contain the Block1 options, even the
last one.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-08 15:11:36 +00:00
Magdalena Kasenberg
a2210bde63 bluetooth: audio: delegator: Use BT_ATT_ERR_WRITE_REQ_REJECTED
If the total length of the opcode and parameter values of Broadcast
Receive State characteristic operation is incorrect, the server shall
respond with an ATT Error Response and the Error Code set to Write
Request Rejected (0xfc), instead of 0x0d
(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN).

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-08 15:10:39 +00:00
Aleksandr Khromykh
c5ee143d77 Bluetooth: Mesh: no more tinycrypt in ble mesh tfm image
PR allows to get rid of tinycrypt objects from
the final binary of the ble mesh apps based on
PSA TFM crypto.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-08 15:09:50 +00:00
Robert Lubos
83f9fc4ce2 net: ip: Add hidden Kconfig symbol for IP fragmentation
Instead of consistently checking for both, IPv4 and IPv6 fragmentation
in several places, add a hidden Kconfig symbol which indicates that some
IP fragmentation has been enabled (either IPv4 or IPv6 or both).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
c724cf99f4 net: pkt: Add explicit flag to indicate packet is IP reassembled
The current logic to determine whether a packet is IP reassembled is
flawed, as it only worked in certain conditions (which was ok, as the
conditions were satisfied for the current use case, but now it's a
public function). Therefore, add an explicit flag that indicates whether
a packet is IP reassembled or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
24abc4307b net: Verify L4 checksum unconditionally for reassembled packets
In case of reassembled IP packets, we cannot rely on checksum
offloading as the drivers/HW has no means to verify L4 checksum before
the fragment is reassembled. Therefore, for such packets, verify L4
checksum in the software unconditionally.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
76a256ea57 net: pkt: Add function to check if packet was reassembled at IP level
Move the existing code verifying that the net_pkt was reassembled at IP
level to a helper function, as it will be needed in other places as
well. Additionally, add packet family check before accessing union
fields.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
2836d0701d net: ip: Set net_context on the final fragment
IPv4/6 fragmentation did not set the net_context pointer on the fragment
packet and in result the send callback registered on net_context was not
called. Therefore, copy the net_context pointer from the original packet
to the final fragment to ensure that the registered callback is called.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
64e615263a net: ipv6: Set IP header length on the fragmented packet
IPv6 fragmentation code did not set the IP header field on the
fragment net_pkt.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
0c1c939d9e net: ipv6: Remove invalid/unneeded code from fragmentation logic
Skipping both next_hdr_off and last_hdr_off and filling last_hdr
variable doesn't make much sense, as this effectively moves the packet
cursor inside/behind the last (L4) header with no particular meaning.
Plus the last_hdr variable isn't really used anywhere, which kind of
proves the point. Therefore, remove the unused variable and needless
net_pkt operations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
13a22e6814 net: ipv6: Calculate checksum before fragmentation
In case the stack has to fragment the IPv6 packet, calculate the
checksum before fragmentation (if haven't done so).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
887a3a321d net: ipv4: Calculate checksum before fragmentation
In case the stack has to fragment the IPv4 packet, calculate the
checksum before fragmentation (if haven't done so).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
08879ea7fb net: ip: Add option to force checksum calculation
Modify internal L4 protocols APIs, to allow to enforce checksum
calculation, regardless of the checksum HW offloading capability.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
eadd933607 net: Set a flag when checksum has been computed
Set checksum flag on the net_pkt, when checksum is calculated in
software.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos
98b46340f2 net: pkt: Add flag indicating checksum status
Add new net_pkt checksum, which indicate checksum status on the packet
(i. e. whether it has already been calculated or not).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Kamil Piszczek
29a67338d1 bluetooth: id: fix uninitialized RPA for non-default identities
This change fixes uninitialized RPA values for advertising sets of
non-default Bluetooth identities. The regression has been introduced
in the following commit:

8d6b206064

The follow-up fix for the default Bluetooth identity has been
introduced in a separate commit:

88c20b9cdd

Non-default Bluetooth identities can be loaded from the Settings
subsystem. In this case, RPAs of related advertising sets to these
identities are left uninitialized as the bt_id_create() function
context is not executed. As a result, the RPA is not created for
advertising sets of non-default Bluetooth identities, and the
advertising is started with the 00:00:00:00:00:00 address.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-08 15:09:22 +00:00
Przemyslaw Bida
2a4350dfd2 net: openthread: Adding snoop entries kconfig.
Adding missing `CONFIG_OPENTHREAD_TMF_ADDRESS_CACHE_MAX_SNOOP_ENTRIES`
to thread kconfig file.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2023-11-08 10:08:58 +01:00
Aleksandr Khromykh
b6f20d67c2 Bluetooth: Mesh: fix On-Demand API usage
On-Demand proxy client API has been changed but
usage of this API in shell test was missed.
Commit fixes this API usage.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-08 10:08:36 +01:00
Aleksandr Khromykh
50d17a0d52 Bluetooth: Mesh: split gatt client and solicitation pdu sending
The ability to send the solicitation PDU doesn't
depend on GATT Client role.
Commit makes independent one functionality from
another.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-08 10:08:36 +01:00
Tom Burdick
982cc794e3 llext: Make the shell list command output nicer
Remove unnecessary newline characters from shell_print, it already adds
them. Align the table pipe characters better in the list of modules.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-11-08 10:07:50 +01:00
Tom Burdick
6d651e37a3 llext: Track module memory usage
The memory usage shown in the shell was 0 which is obviously incorrect.
At some point the memory allocation tracking was dropped from llext.c
mistakenly. Add it back.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-11-08 10:07:50 +01:00
Tomasz Moń
8db6919695 nrfx_usbd: Rename to nrf_usbd_common
Rename local usbd copy from nrfx_usbd to nrf_usbd_common and use it in
both USB stacks. Renaming header to nrf_usbd_common.h allows breaking
changes in exposed interface. Mark all doxygen comments as internal
because local usbd copy should not be treated as public interface
because we are under refactoring process that aims to arrive at native
driver and therefore drop nrf_usbd_common in the future.

Use Zephyr constructs directly instead of nrfx glue macros.

No functional changes.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-11-07 14:06:51 +01:00
Ingar Kulbrandstad
e1a5605889 Bluetooth: Mesh: Remove experimental tag
Remove experimental tag for Mesh Protocol v1.1,
Mesh Model v1.1, Mesh DFU v1.0 and Mesh BLOB v1.0
features.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-11-07 11:57:17 +01:00
Rubin Gerritsen
8b2dd61eba Bluetooth: HCI: Add bt_hci_get_ver_str()
This new API returns the version string corresponding to a given
HCI version.

The API can be used by applications to print out human-readable
information about the controller being used.

Adding this API removes possible code duplication.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-11-07 09:55:05 +01:00
Jukka Rissanen
e89c9a6671 net: tcp: Fix compilation if congestion avoidance is disabled
Fix tcp.c compilation if user unsets
CONFIG_NET_TCP_CONGESTION_AVOIDANCE config option.

Fixes #64824

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-07 09:54:31 +01:00
Chaitanya Tata
d12627e70f wifi: shell: Move defaults to beginning
This sets defaults first and then overrides if configured, easier to
read.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-07 09:53:39 +01:00
Chaitanya Tata
8c179870d4 wifi: shell: Fix default band value
The enum is mainly to print output of band, so, the default value is 0
which means 2.4GHz, which is not correct when using it to configure like
in connect.

Fix the default value to unknown i.e., no user preference. This way we
can use same enum for both set and get.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-07 09:53:39 +01:00
Emil Gydesen
b92ac42677 Bluetooth: CAP: Commander API and skeleton
Adds the CAP Commendar API and skeleton that can
implemented.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-07 09:49:41 +01:00
Seppo Takalo
8608b2dc45 tests: lwm2m: Information Reporting Interface [300-399]
Implement testcases for Information Reporting Interface [300-399]:

* LightweightM2M-1.1-int-301 - Observation and Notification of parameter
  values
* LightweightM2M-1.1-int-302 - Cancel Observations using Reset
* LightweightM2M-1.1-int-304 - Observe-Composite Operation
* LightweightM2M-1.1-int-306 – Send Operation
* LightweightM2M-1.1-int-307 – Muting Send
* LightweightM2M-1.1-int-308 - Observe-Composite and Creating
  Object Instance
* LightweightM2M-1.1-int-309 - Observe-Composite and Deleting
  Object Instance
* LightweightM2M-1.1-int-310 - Observe-Composite and modification of
  parameter values
* LightweightM2M-1.1-int-311 - Send command

303 and 305 cannot be implemented using Leshan as it only support
passive cancelling of observation.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-07 09:47:00 +01:00
Daniel DeGrasse
726128f810 sd: add SDIO subsystem
add SDIO subsystem code. SDIO subsystem currently supports
card initialization, SDIO read/write, SDIO extended
read/write, and SDIO card interrupts.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-11-06 19:01:08 -05:00
Jukka Rissanen
b0d0f60389 net: shell: Print device and wifi information for iface cmd
If the interface is WiFi one, then print information about it.
Also the device information is useful to know so print device
name corresponding to the network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-06 15:51:36 -06:00
Emil Lindqvist
7f19764d9e kconfig: name choices to make changable in outside Kconfigs
This commit names a couple of choices to allow the default
value to be overridden by Kconfig files out of tree

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2023-11-06 15:33:35 -06:00
Magdalena Kasenberg
1747c33796 bluetooth: audio: delegator: Notify state after updating BIG_Encryption
If the server has synchronized to the PA and detected that the BIS is
encrypted, the server writes a value of 0x01 (Broadcast_Code
required) to the BIG_Encryption field of the Broadcast Receive State
characteristic to request a client to provide a Broadcast_Code.
In PTS BASS/SR/CP/BV-14-C test case the PTS (client) expects that the
new value of the Broadcast Receive State characteristicstate will be
notified, so the PTS could sent Set Broadcast_Code operation to the
server.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-06 12:32:23 +01:00
Troels Nilsson
3c9d952820 Bluetooth: Controller: Fix failing LL/DDI/SCN/BV-88-C
Fixes failing EBQ test LL/DDI/SCN/BV-88-C Extended Scanning,
Active, Properly Ignore RFU Fields

Several minor modifications made to le_ext_adv_report() to
properly ignore any invalid fields present in the received PDUs

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-11-06 10:10:47 +01:00
Andries Kruithof
2a34ecf858 Bluetooth: shell: host: add missing conditional compile
There was a conditional compile misssing for the
BT_PER_ADV_SYNC_TRANSFER_SENDER, potentially leading
to build failures

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-11-06 10:10:07 +01:00
Greter Raffael
774858c6dc ztest: Add comfort functions for non-zero return codes
Many functions return non-zero return codes on errors. I added an assert
for the case, when a function is expected to fail. It is just a
shorthand for `zassert_not_equal(0, ret);`, analogous to
`zassert_ok`, introduced in c5d85e175f.

I also added the corresponding `zassume_nok` and `zexpect_nok`.

Signed-off-by: Greter Raffael <rgreter@baumer.com>
2023-11-04 07:39:46 -04:00
Ederson de Souza
049b67aca9 subsys/shell/backends: Fix shell_telnet.c build with clang
It declares a variable inside a switch statement without brackets to
properly delimit the scope, making clang barf. This patch adds them.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2023-11-03 20:04:08 -04:00
Anas Nashif
a08bfeb49c syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
ee9f278323 syscall: rename Z_SYSCALL_VERIFY -> K_SYSCALL_VERIFY
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
9c4d881183 syscall: rename Z_SYSCALL_ to K_SYSCALL_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
9c1aeb5fd3 syscall: rename z_user_ to k_usermode_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
56fddd805a syscall: rename z_user_from_copy -> k_usermode_from_copy
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
6ba8176e33 syscall: rename z_user_alloc_from_copy -> k_usermode_alloc_from_copy
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
df9428991a syscall: Z_SYSCALL_MEMORY_ARRAY -> K_SYSCALL_MEMORY_ARRAY
Rename macros and do not use Z_ for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
684b8fcdd0 syscall: Z_SYSCALL_VERIFY_MSG -> K_SYSCALL_VERIFY_MSG
Rename macros and do not use Z_ for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
4d5d04169d syscall: rename z_is_in_user_syscall
Rename z_is_in_user_syscall -> k_is_in_user_syscall

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
a6b490073e kernel: object: rename z_object -> k_object
Do not use z_ for internal structures and rename to k_object instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
c91cad735a kernel: object: rename z_object_init to k_object_init
Do not use z_ for internal API and rename to k_object_init.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif
d2c025dd78 kernel: objects: rename z_dynamic_object_create -> k_object_create_dynamic
Do not use z_ for internal APIs and rename z_dynamic_object_create.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
David Corbeil
724c162821 shell: backends: telnet: Added support for echo option
Adding support for echo option if telnet commands are supported. This is
useful when the telnet client is in character mode. It allows to use the
arrow keys, ctrl-c and more. Something to keep in mind is that when
character mode is turned on by the client, network traffic is
considerably increased as each typed character is sent over the wire.

Note: echo mode is only supported if SHELL_TELNET_SUPPORT_COMMAND is
enabled.

Signed-off-by: David Corbeil <david.corbeil@dynon.com>
2023-11-03 11:46:08 +01:00
Marc Lasch
73bab817a0 net: lwm2m: Remove the resource type in registration message
Do not include the resource type (rt=) in the registration message when
using the OMA JSON format. This was a workaround specifically for the
Wakaama LwM2M server which is no longer needed since the latest master
branch.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2023-11-03 11:44:28 +01:00
Chaitanya Tata
d4d96b3df2 net: zperf: Fix the check for IPv6
It was typo.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-03 11:21:16 +01:00
Bjarki Arge Andreasen
011adfa4ca modem: Add experimental tag
The modem subsystem is novel and should therefore be marked
experimental.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-11-03 09:56:30 +01:00
Benjamin Lucke
1b34884d81 Bluetooth: TBS: Fixed return call_index 0 after overflow
Fixed range of call_index 1 to 255, since 0 is reserved for outgoing calls.

Signed-off-by: Benjamin Lucke <git@lucke.tech>
2023-11-03 09:55:22 +01:00
Seppo Takalo
b6ab302fe8 net: lwm2m: Fix overlapping buffers from Portfolio object
Portfolio object created string buffers for Identity resources
that was overlapping on some cases.

Don't calculate pointers by hand, allow compiler to calculate it.

Fixes #64634

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-02 09:28:04 +01:00
Seppo Takalo
2eb804a558 net: lwm2m: Add shell support for deleting object and resource instances
Extend the previous support of creating object instances by allowing
creation of resource instances as well.
Similarly, add support for deleting.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-02 09:27:55 +01:00
Carles Cufi
9cf07bbdb5 bluetooth: Rename rpmsg HCI driver and sample to ipc
The existing driver and sample:

- drivers/bluetooth/hci/rpmsg
- samples/bluetooth/hci_rpmsg

are no longer correctly named, since they now use the IPC subsystem to
send and receive data. The IPC subsystem can use RPMsg as a transport,
but that is one of several selectable backends.

I initially wanted to deprecated both the BT_RPMSG Kconfig option as
well as the zephyr,bt-hci-rpmsg-ipc chosen node in Devicetree. However,
this proved to be undoable in the case of the Kconfig option. This is
because it's a choice option, and those have special behavior. In
particular, the only practical way to deprecate would've been to keep
the old Kconfig option outside the choice (much like it's done in this
commit) but then also add a 'depends on !BT_RPMSG' on each of the
remaining choice symbols *except* on the new BT_HCI_IPC one. This, however,
only works correctly for .conf files. If a board instead sets the
default BT_HCI_BUS_TYPE in the Kconfig.defconfig file then the Kconfig
tree parsing would fail, because it'd try to set it to a value
(BT_RPMSG) that is no longer part of the choice.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-11-02 08:32:20 +02:00
Ben Marsh
18a0952407 subsys/mgmt/mcumgr: Name struct to avoid violation
The mcumgr SMP UDP configs struct was causing a unique tag name
violation (rule 5.7).

The struct name has been changed from configs to smp_udp_configs.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
2023-11-01 12:01:58 +00:00
Ben Marsh
f9809a0a72 subsys/mgmt/mcumgr: Reduce unnecessary ROM usage
mcumgr's SMP UDP transport was unnecessarily using a potentially large
amount of ROM space due to static initialising fields in a
config struct that also contains buffers/stacks.

This has been changed to instead initialise fields in the start
function, reducing ROM usage by ~5K in the default configuration
with IPv4 and IPv6 enabled.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
2023-11-01 12:01:58 +00:00
Henrik Brix Andersen
5d5249d85b drivers: can: unify spelling of CAN Flexible Data-rate abbreviation
Unify spelling of CAN Flexible Data-rate abbreviation to "CAN FD" instead
of "CAN-FD". The former aligns with the CAN in Automation (CiA)
recommendation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-11-01 11:17:17 +00:00
Krzysztof Chruściński
01cf78ad39 logging: Do not check pointers when strings are stripped
When logging strings are stripped from the binary prevent
performing check of pointers which requires access to the
string.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-31 09:01:38 +01:00
Jamie McCrae
e3c06c5d8f mgmt: mcumgr: transport: Fix UDP user data buffer overflow
Fixes a buffer overflow issue if UDP is enabled for IPv4 only
but IPv6 networking is enabled

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-30 14:58:49 -05:00
Benjamin Lucke
9c323d685b Bluetooth: BAP: Shell: Fixed some bap shell cmds
Added missing initialization for cmd_stream_qos and cmd_sync_broadcast.

Signed-off-by: Benjamin Lucke <git@lucke.tech>
2023-10-30 14:57:33 -05:00
Alberto Escolar Piedras
08f6532b67 Bluetooth: Controller: Fix corruption during BIG_CHANNEL_MAP_IND
radio_pkt_big_ctrl_get() returns a statically allocated
buffer of type pdu_big_ctrl, but the callers expect a
buffer where a whole PDU for a BIG control packet can fit
(not just space for the payload),
and use it as such, overflowing this statically
allocated buffer, and smashing other variables after.

Let's fix it by allocating a buffer of the correct size
to fit a BIG control PDU.

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

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-30 18:36:39 +01:00
Benedikt Schmidt
be8408cbac usb: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Benedikt Schmidt
c5b252d8f1 testssuite: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Benedikt Schmidt
24de378986 portability: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Benedikt Schmidt
d7f0da1c78 net: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Alberto Escolar Piedras
55c59e041e Bluetooth: Controller: Avoid division by 0 with BT_CTLR_THROUGHPUT
With very fast HCI interfaces (for ex. in the simulated nrf5340)
the tx_rate calculation can do a division by 0
(if to packets are enqueued in the same 32KHz clock period).
Let's avoid it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-30 10:49:51 +01:00
Dawid Niedzwiecki
0aed42f2ee mgmt: ec_host_cmd: improve handling buffer sizes
Add the len_max rx structure member to indicate maximum number of bytes
possible to receive. It is needed to send information about our protocol
parameters to host.

Also, limit the maximum size of request/responses for backends that uses
buffers provided by the handler.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-10-27 13:26:00 -05:00
Krzysztof Chruściński
9470e3d129 logging: Imply strings stripping if dictionary frontend is used
When UART dictionary frontend is used strings can be removed
from the binary.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 11:42:21 +02:00
Krzysztof Chruściński
59abf921c1 logging: Add option to remove strings from binary
Add option to remove string literals which are constant and
never touched by the firmware. It can save significant amount
of RO memory.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 11:42:21 +02:00
Benjamin Cabé
0fe6c72d40 debug: coredump: guard selection of ADSP memory window backend
Enabling the core dump via memory window backend only makes sense on
Intel ADSP platform wtih memory windows enabled.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-10-27 10:53:32 +02:00
Benjamin Cabé
9ff60803c4 debug: coredump: logging backend should always select LOG
The DEBUG_COREDUMP_BACKEND_LOGGING option should automatically
select LOG Kconfig instead of just depending on it.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-10-27 10:53:32 +02:00
Andries Kruithof
8c1513c837 Bluetooth: shell: make behaviour of iso cmd same as bt cmd
When no parameters are given to the 'bt' command it prints
the help message. The 'iso' command responds with 'missing
subcommand'. This commit updates the behaviour of the iso
command so that it behaves the same as the bt command, i.e.
prints a help message

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-27 10:53:25 +02:00
Jukka Rissanen
e44de3e381 net: shell: Join IPv6 mcast group if needed
If user adds IPv6 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-27 10:52:48 +02:00
Jukka Rissanen
1467d7fa7b net: shell: Join IPv4 mcast group if needed
If user adds IPv4 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.

Fixes #64389

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-27 10:52:48 +02:00
Chaitanya Tata
a1024f6aeb net: zperf: By default bind to any IP address
Default behaviour should only bind to port independent of IP, this
allows even multicast/broadcast L4 traffic to be received.

User can always specify a specific address to bind using shell or
Kconfig or API.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-10-27 10:52:19 +02:00
Chaitanya Tata
dee1f2deaa net: zperf: Set default IP addresses only if configured
If the user has not configured then we see the error prints for the
defaults always.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-10-27 10:52:19 +02:00
Chaitanya Tata
6bd47ffb10 net: zperf: Distinguish between IPv4 and IPv6 address set failures
Using a generic IP for address set failures is confusing, esp. two same
prints (one for v4 and the other for v6), so, use explicit version.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-10-27 10:52:19 +02:00
Guennadi Liakhovetski
5064df0500 llext: copy complete string sections while parsing ELF
This has several advantages:

1. we don't need any hard assumptions about symbol length. The
current hard-coded limit of 32 characters might well be not true.
2. replaces a lot of code for reading those names with a single
call to a 1-line function to calculate string location.
3. eliminates the need to allocate buffers for exported symbol names
by replacing them with a simple pointer assignment.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-10-27 10:51:49 +02:00
Guennadi Liakhovetski
23472509d3 llext: refactor section copying
Instead of first allocating all sections and then copying then,
create a helper function to allocate and copy a single section and
call it for all appropriate sections. We need to call this function
from another location when copying string sections.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-10-27 10:51:49 +02:00
Krzysztof Chruściński
a68cdb0558 logging: Optimize handling of simple and common log messages
Some compilers (e.g. riscv32) does not handle well complex macros
for logging. Generated code is bigger than expected (e.g. riscv32
code is almost twice bigger than cortex-m code). Use of logging can
lead to unexpected code increase.

To handle that an analysis of the zephyr code base was performed and
it shown that 75-80% of logs are simple strings with 0 arguments
(~45%), one 32 bit argument (~26%) or two 32 bit arguments (~6%).
Given that a set of dedicated macro were created which are applied
to those 3 cases which on 32 bit platform create very simple log
messages without padding or alignment needed.

Such dedicated macros save up to 40% of code (riscv32) and also
executes 30% faster (arm cortex and riscv32).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 10:50:39 +02:00
Krzysztof Chruściński
900f9c3b24 logging: log_frontend: Add optional API for common messages
Extend frontend API with optional set of functions which can
be used when simplified log message handling is enabled. If this
mode is enabled then there are dedicated macros for processing the
most common messages (string + 0-2 word arguments). Using this API
can speed up the processing of messages that are the most common.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 10:50:39 +02:00
Krzysztof Chruściński
1a0e8d6f9e logging: log_msg: Add functions for handling simple log messages
In preparation for new feature which optimizes handling of
the most common log messages (0-2 32 bit word arguments) add
functions dedicated for that purpose.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 10:50:39 +02:00
Jeppe Odgaard
530a3092fe debug: coredump: flash backend: print error if write fails
The loop in `coredump_flash_backend_buffer_output` might fail without
any alerts. This could be due to e.g. a too small coredump-partion.

Add a LOG_ERR if an error occurs.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-10-26 07:57:12 -04:00
Tomasz Moń
08bd1c5ec2 usb: device: Fix ZLP write race condition
ZLP packet has to be read and acknowledged by host just like any other
DATA packet. Do not end transfer until the host actually acknowledged
the trailing ZLP. This fixes the race condition between host and Zephyr
application where the next transfer could be lost if host did not issue
IN token (that would read read ZLP) before the application tried to
start new transfer.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-10-26 13:52:31 +02:00
Emil Gydesen
6aea1864c1 Bluetooth: ISO: Minor fixes for ISO shell
If CONFIG_BT_ISO_TEST_PARAMS=y then the CIG and BIG
create params was not properly initialized.

Modified the TX for BIS and CIS to be more similar

Added a timeout on the buffer to avoid any potentional
deadlocks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-26 09:48:54 +02:00
Jukka Rissanen
83c875adab hostap: Move the relevant config options away from hostap
Moving the Zephyr specific config options from
modules/hostap/Kconfig to corresponding Kconfig where the
option is specified.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-26 09:48:47 +02:00
Peter Mitsis
467ce89458 cmsis: resolve undefined reference to k_calloc()
When no heap has been configured, osMessageQueueNew() will no
longer include a call to k_calloc() (which needs the heap).
In such a configuration, if osMessageQueueNew() indicates that
the buffer must be allocated, it will fail and return NULL.

Fixes #61196

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-10-25 19:54:13 +02:00
Seppo Takalo
cf513451eb net: lwm2m: Keep user_data between blocks
CoAP reply structure user_data should be kept between
ongoing blocks, so that callbacks for LwM2M send continue
to work on blockwise transfers.

Fixes #64290

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-25 17:36:30 +02:00
Emil Gydesen
34058146a5 Bluetooth: BAP: Shell: Remove unused variable stream_frame_duration_us
The variable was unsused and caused compiler warnings.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-25 17:36:22 +02:00
Anders Storrø
d4037ce6a1 Bluetooth: Mesh: Correct pack of net idx hb_status
Ensures correct packing of net idx in Heartbeat Publication Status
messages on the Configuration Server.

Reference to net idx packing format: MshPRTv1.1 section 4.3.1.1

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø
05774c5d76 Bluetooth: Mesh: Fix unpacking of hb_pub status
Fixes incorrect unpacking of Heartbeat Publication status
messages on the Configuration client.

Reference to packing format: MshPRTv1.1 section 4.3.2.63

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø
46d9c97991 Bluetooth: Mesh: HB pub status for unassigned addr
Fixes issue where Heartbeat Publication Status message sends
garbage data when destination field is set to the unassigned address.

MshPRTv1.1, section 4.4.1.2.15:
"When the Destination field is set to the unassigned address, the values
of the CountLog, PeriodLog, TTL, and Features fields shall be set to
0x00 and NetKeyIndex field shall be set to 0x0000."

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø
c51bb9c13b Bluetooth: Mesh: Update spec ref 1.0.1->1.1
Updates Bluetooth mesh specification references:

- Change "Profile" to "Protocol" since the main specification has
changed its name.
- Update/align formating of specification references. This will
make it easier to find spec references in the future.
- Change some section references to point to the correct section of the
newest version of the specification (v1.1).

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:14 +02:00
romain pelletant
efebb1841f modem_chat: fix hard fault on script stop
Fix fault on modem_cellular disconnection/reconnection
Issue #64291

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-10-25 10:05:45 +02:00
Yong Cong Sin
0e2f5c2dbb shell: print name and prompt when listing backends
The shell name defined with `SHELL_DEFINE` is implicitly
guaranteed to be unique while it is possible that more than one
shell backends can have the same prompt.

Print the name of the shell backend alongside with its prompt
to differentiate between the backends.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-25 09:57:29 +02:00
Yong Cong Sin
a068288091 shell: add new APIs to get the backend instances
Added some new APIs to get the backend instances more easily,
so that dev does not need to rely on `shell_backend_*_get_ptr`,
which looks more like a hack to access a local variable.

These APIs are basically copied from the log backend
implementation.

Added testcase for the APIs.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-25 09:57:29 +02:00
Yong Cong Sin
dd154406ba shell: make the backend thread name variable generic
Rename the shell backend `thread_name` variable to just `name`,
to be used for other things not specific to thread later.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-25 09:57:29 +02:00
Piotr Kosycarz
bc8b7dd6dd testsuite: coverage: allow gcov data dump directly on console
When there is no buffer for gcov hex data,
dump them directly to console.
This saves RAM which can be used to hold more gcov data.

Reduce number of gcov hex data send by console -
do not send space between every two digits.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2023-10-25 09:57:15 +02:00
Bjarki Arge Andreasen
b4f3150592 modem: cmux: Optimize log message to save ROM
This commit reuses the string "Unknown %s frame type" for two
log messages, as suggested by ycsin.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen
ee44357cfb modem: modem_cellular: Reset receive state on attach
This commit resets the state of the CMUX receive state
machine when the CMUX instance is attached to a pipe.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen
b495fda6a1 modem: modem_cmux: Improve logging
This commit adds logging for CMUX frames and commands and
their data, for both transmit and receive. It also removes
the superseded LOG_DBG() lines like "Received frame".

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen
0f38136431 modem: modem_cmux: Clear DLCI pipes on open
This commit resets the receive ring buffer for each DLCI
pipe when they are opened. They may have old data stored
from last time they where opened.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen
92ad351e2a modem: modem_cmux: Use k_event_test instead of K_NO_WAIT
This commit replaces the k_event_wait calls using K_NO_WAIT
with k_event_test.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen
79e6c8411f modem: modem_cmux: Reset CMUX events on release
This commit resets the CMUX events to match the
initial value of disconnected.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Bjarki Arge Andreasen
7fe491c050 modem: modem_cmux: Make async connect/disconnect stateful
This commit adds a check to the async connect and disconnect
functions to validate the CMUX is not already connected
or disconnected respectively. This was already part of the
sync connect and disconnect functions, so the sync functions
now simply wrap the async functions to avoid duplicate code.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-24 14:31:38 +01:00
Vinayak Kariappa Chettimada
f64d123a3d Bluetooth: Controller: Fix missing ext adv terminate event
Fix missing Extended Advertising terminate event and
advertising scheduling not being stopped.

Under race conditions, auxiliary event is aborted without
the generation  of done extra event which is suppose to
stop the scheduling when max events count is used.

The fix now generates the done extra event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-24 15:12:18 +02:00
Vinayak Kariappa Chettimada
05c85ddbcf Bluetooth: Controller: Fix periodic advertising sync window
Fix periodic advertising sync window calculation to include
the scheduling resolution margin, i.e. be double as with
the event jitter value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-24 15:12:18 +02:00
Jukka Rissanen
8a58104396 net: shell: Add net-sockets command
The new "net sockets" command will utilize the object core
support to track and show information about BSD sockets that
are created in the system. This command is able to show info
for all network sockets (native, offloaded etc) in the system.

Example of the output of the new command:

uart:~$ net sockets
 Creator  Name       Flags  FD   Lifetime (ms) Sent  Received

    main  af_inet46  6ST    0    3260          819   498
    main  af_inet46  4ST    1    2110          469   142
    main  af_inet46  6DU    2    2110          9941  9941
    main  af_inet46  4DU    3    2110          1375  621

4 active sockets found.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 11:11:30 +02:00
Jukka Rissanen
7d9f2ad2ca net: sockets: Add object core support to sockets
Use the generic object core support to track network sockets
and their statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 11:11:30 +02:00
Jukka Rissanen
5bf18e39ad net: sockets: Set writefds in case of error in select()
The writefds is typically set if there is an error while
waiting for example the connect() to finish. So check if
the user supplied the writefds and update it accordingly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Jukka Rissanen
ec4973dd15 net: tcp: Set errno properly if connecting to non listening port
If we try to connect to a port which no socket is listening to,
we will get a packet with "ACK | RST" flags set. In this case
the errno should be ECONNREFUSED instead of ETIMEDOUT like we
used to return earlier.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Jukka Rissanen
b864880000 net: sockets: Add SO_ERROR socket option to SOL_SOCKET level
Return the last socket error to user.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Jukka Rissanen
fd1c226cd8 net: tcp: Increment ref count in initial SYN
Increase reference count already when initial SYN is sent.
This way the tcp pointer in net_context is fully valid for
the duration of the connection.

Fixes #63952

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Omkar Kulkarni
3de98643ed Bluetooth: Mesh: FU Server should not update internal state on error
According to conditions in the DFU spec section 6.1.3.7 (Sending a
Firmware Update Status message) and in 'Idempotency' part of section
6.1.3.4 (Receiving a Firmware Update Start message), the FU Server
should not update internal state when 'Wrong Phase' error condition
is triggered.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2023-10-24 09:05:59 +02:00
Robert Lubos
c6fd2b2d44 net: shell: Fix unexpected timeout on loopback ping
In case ping is sent to own address, the request is looped back to the
stack and served before ping work had a chance to reschedule. In result,
when the final ping reply has been server, and ping operation finalized
with `ping_done()`, the work was rescheduled one last time, causing the
ping timeout to be reported. Fix this by rescheduling the work before
sending the actual request, so that the reply handler can cancel the
work properly in such case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-24 09:05:20 +02:00
Robert Lubos
dcf7b1905b net: core: Set LL address on loopback packet
In case packet is looped back to the stack, set LL address information
on the packet, using the LL address set on the corresponding network
interface, so that the information can be interpreted by the SOCK_DGRAM
packet socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-24 09:05:20 +02:00
Jukka Rissanen
73896eef6c net: Set Dummy net_if as default one for tests
If we run network tests under tests/net, then set the
Dummy network interface as a default one so that it will
be picked up first.

This should solve the issue if the DUT is having a real
network interfaces like onboard Ethernet interface which
could cause the test to fail. The test might fail in this
case because the network tests assume that only simulated
network interfaces are used by the tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 09:05:04 +02:00
Flavio Ceolin
c166685fcf ztest: Do not abort k_current_get from ISR
Do not abort k_current_get() from ISR.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-24 09:04:42 +02:00
Flavio Ceolin
564adad952 treewide: Add CODE_UNREACHABLE after k_thread_abort(current)
Compiler can't tell that k_thread_abort() won't return and issues a
warning unless we tell it that control never gets this far.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-24 09:04:42 +02:00
Jukka Rissanen
63d9c8fa06 net: shell: Print v4-mapping-to-v6 address properly
The remote address of the connection is checked whether
it is v4-mapping-to-v6 address in which case we should
print it such.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen
2238baa831 net: tcp: Do not overwrite remote address in new conn
When a new incoming connection is accepted, do not overwrite
the listening remote address. The remote address for the
listening socket is the any address (like :: for IPv6)
and not the accepted socket remote address.
This only affects the "net conn" shell command which prints
the remote address incorrectly. There is no problem accepting
new connections in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen
e3f664dfe2 net: conn: Fix the rank value print
We should use the NET_CONN_RANK() macro when printing the
current rank value as that macro masks the rank values properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen
1b4a76cc36 net: tcp: Fix the accepted socket address
The socket address passed in accept() call should point
to the new connection address and not the old one.
Fortunately this only affects things after the v4-mapping-to-v6
support so older code than this works fine.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen
dea896f6e7 net: tcp: Set address len properly when accepting a socket
The address length of the accepted socket must reflect the
size of the address struct, so it should either be
sizeof(struct sockaddr_in) for IPv4 or sizeof(struct sockaddr_in6) for
IPv6 socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen
4f37d63ed1 net: Add support for v4-mapping-to-v6 sockets
This allows IPv4 and IPv6 share the same port space.
User can still control the behavior of the v4-mapping-to-v6
by using the IPV6_V6ONLY socket option at runtime.
Currently the IPv4 mapping to IPv6 is turned off by
default, and also the IPV6_V6ONLY is true by default which
means that IPv4 and IPv6 do not share the port space.
Only way to use v4-mapping-to-v6 is to enable the Kconfig
option and turn off the v6only socket option.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen
256d5fac4f net: utils: Print IPv4 mapped IPv6 addresses properly
Add support for IPv4 mapped IPv6 addresses when converting
IP address to a string in inet_ntop() function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Robert Lubos
05361edb1b net: shell: Fix TCP connect behavior
Fix two issues with net tcp command:

* The `net tcp` commands are still based on net_context API. For TCP,
  the API caller (net shell) should add one extra reference to the
  allocated net context, to prevent premature context release in case of
  connection teardown. Currently that was not the case, and the context
  was released too early, resulting in missing final ACK from the Zephyr
  side on connection close.

* The net context API should not be called from the registered connect
  callback, as this creates a temporary deadlock situation. The
  net_context_connect() function blocks until the connection is
  established, or an error or timeout occurs. For that time the
  net_context mutex is being locked. In case of connection error (for
  example after receiving RST packet) the connect callback is called,
  indicating an error. If we try to call net_context API from within, a
  deadlock situation takes place, as the context mutex is still locked
  by the net_context_connect() (called from the shell thread). This
  blocks the further execution of the TCP stack and can result in an
  unexpected behavior (like for example retransmitting the SYN packet,
  which takes place from yet another thread, TCP work queue).
  Fix this, by releasing the net context not from the callback directly,
  but based on the return value from net_context_connect().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-23 16:08:37 +02:00
Xudong Zheng
9ddca0bfc6 debug: coredump: add name for backend and dump options
This makes the backend and dump options more easily configurable via
Kconfig.

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2023-10-23 15:22:37 +02:00
Andries Kruithof
e3d6aac5c0 Bluetooth: ISO: use IN_RANGE for CIG create parameters
Use IN_RANGE instead of explicitly checking that a value is
in between two other values

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-23 15:22:10 +02:00
Andries Kruithof
8b3b8cf2ad Bluetooth: ISO: extend API for setting SDU interval
The BT Core Spec v5.4 allows separate SDU_Interval to
be set on C_To_P and P_To_C directions,
but this is not possible with the existing interface.

This PR splits the interval parameter in the call to
bt_iso_sig_create into one for C_To_P
and one for P_To_C

It also splits the latency parameter into one for
C_To_P and one for P_To_C

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>

Bluetooth: ISO: update UI for extended API

The API for setting the SDU interval and latency have been updated.
This PR also updates the setting of these by the user in the shell
and the iso_connected_benchmark sample

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-23 15:22:10 +02:00
Yong Cong Sin
1f60c1379e net: shell: fix compilation errors
`suspend.c` and `resume.c` are missing the `zephyr/pm/device.h`
add that to fix compilation warning

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-23 14:20:23 +01:00
Jamie McCrae
b032d0bc00 mgmt: mcumgr: grp: fs_mgmt: Select CRC if hash/checksum is enabled
Since CRC32 hash/checksum support is enabled by default, make it
select the CRC Kconfig symbol

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-23 12:15:41 +02:00
Jamie McCrae
8f5925c6de mgmt: mcumgr: Do not imply CRC
Only SMP over console transports need CRC support, therefore do
not imply CRC support for MCUmgr entirely because only 2 optional
transports require it

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-23 12:15:41 +02:00
Jamie McCrae
0c1d968581 mgmt: mcumgr: transport: shell/uart: Require CRC to use
SMP over console uses a checksum, therefore it is required in order
to enable these transports

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-23 12:15:41 +02:00
Johann Fischer
c152e0980c usb: device: cdc_acm: block in uart_poll_out() routine
According to the UART API documentation, implementation must block when
the transceiver is full. For CDC ACM UART, TX ringbuffer can be
considered as transceiver buffer/FIFO. Blocking when the USB subsystem
is not ready is considered highly undesirable behavior. Blocking may
also be undesirable when CDC ACM UART is used as a logging backend.

Change the behavior of CDC ACM poll out to:
 - Block if the TX ring buffer is full, hw_flow_control property is
   enabled, and called from a non-ISR context.
 - Do not block if the USB subsystem is not ready, poll out
   implementation is called from an ISR context, or hw_flow_control
   property is disabled.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-23 11:48:44 +02:00
Johann Fischer
9112c7e0ff usb: device: cdc_acm: restart OUT transfer in only configured state
When a usb_transfer is cancelled, the callback is finally invoked.
Silly, there is no transfer status passed, and in the callback we can
only check the size and device status.

Reported-by: Alex Kaiser
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-23 11:48:44 +02:00
Jukka Rissanen
4b41f9f246 net: wifi: Fix compile error when -Werror -Wextra are set
The warning which became error looks like this

error: type qualifiers ignored on function return type
                                [-Werror=ignored-qualifiers]
  219 | const char * const wifi_ps_txt(enum wifi_ps ps_name);

It is pointless to add a const qualifier to a return value.
So remove the const pointer to avoid this warning.

Fixes #64197

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 11:06:23 +02:00
Jamie McCrae
e8bbb033ef mgmt: mcumgr: grp: img_mgmt: Fix erase returning unknown error
Fixes an issue whereby the erase function would return an unknown
error, which would happen when the slot was already erased.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-23 10:03:02 +01:00
Aleksander Wasaznik
9f42c92e26 Bluetooth: Host: Fix GATT Long Read for EATT
When EATT is established, the value returned from `bt_att_get_mtu` is
not useful to determine the ATT_MTU that applies to a ATT response. This
is because `bt_att_get_mtu` may return the value for a different bearer
than the request is serviced on.

To fix this, the params struct for the GATT read operation is given a
new field that will record the ATT_MTU that applies to this ATT
operation. This value is then used to determine if the GATT long read
operation is concluded.

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

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-10-23 11:01:21 +02:00
Jukka Rissanen
046f00244c net: shell: vlan: Enforce arg count via shell macro
Use the SHELL_CMD_ARG() to enforce the minimum parameter
count in vlan command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
4265fe7a93 net: shell: stats: Use generic iface idx dynamic completion
The interface number is generated automatically if one
presses <tab> when expecting the interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
10def6cac5 net: shell: Allow dynamic interface name expansion
Allow multiple commands use the same dynamic shell command
completion when expecting network interface index.

For example "net iface" and "net stats" are such commands.

The network interface expansion cannot be used in "net ipv6 add",
"net ipv4 add" and "net route" commands as they require more
data after the network interface index argument.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
5bad9680a5 net: shell: Remove the stacks command
The "net stacks" has been obsolete for a long time already
so remove it for good. It is replaced by "kernel stacks" cmd.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
34cd82e80b net: shell: Removing extra stuff that is not needed
The remaining stuff that is not used in net_shell.c can be removed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
aab371364c net: shell: Add websocket command
Move "websocket" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
d84c2572ec net: shell: Add vlan command
Move "vlan" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
82a57b9789 net: shell: Add virtual command
Move "virtual" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
7a167648eb net: shell: Add udp command
Move "udp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
5afeade2fc net: shell: Add tcp command
Move "tcp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
7cdc235ff5 net: shell: Add suspend command
Move "suspend" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
fdb86e89a6 net: shell: Add stats command
Move "stats" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
76eab4e440 net: shell: Add stacks command
Move "stacks" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
8b4b064a85 net: shell: Add route command
Move "route" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
cb46113df4 net: shell: Add resume command
Move "resume" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
e5534b5262 net: shell: Add ppp command
Move "ppp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
58ad0a5c13 net: shell: Add pkt command
Move "pkt" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
a669d4aba3 net: shell: Add ping command
Move "ping" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
0c9fd96604 net: shell: Add nbr command
Move "nbr" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
5b6423dd2f net: shell: Add mem command
Move "mem" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
e0c30bc2b6 net: shell: Add ipv4 command
Move "ipv4" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
36db200c15 net: shell: Add ipv6 command
Move "ipv6" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
49012a5c6b net: shell: Add iface command
Move "iface" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
55eb526d0a net: shell: Add gptp command
Move "gptp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
97e0609dd9 net: shell: Add events command
Move "events" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
fea7001678 net: shell: Add dns command
Move "dns" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
5a7fd25e97 net: shell: Add conn command
Move "conn" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
e03adee6e4 net: shell: Add capture command
Move "capture" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
0e3b197f84 net: shell: Add arp command
Move "arp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
e850517a15 net: shell: Add allocs command
Move "allocs" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
3f36f78654 net: shell: Common header for all shell commands
Some useful APIs and macros for all net shell commands
to use.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
394a40470d net: shell: Rename current command as net_old
This is a preparation for the refactoring. The old "net" command
is renamed "net_old" so that the individual commands can be
placed into a separate .c files.
This is done like this because we need to use the
SHELL_SUBCMD_SET_CREATE() to create the sub-command and then
use the SHELL_SUBCMD_ADD() in the .c files to add the command
into the sub-command and not get conflict with the same name
sub-command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen
56c1bb813f net: shell: Move the shell code to subsys/net/lib/shell
This is preparation commit that moves the net shell code to
subsys/net/lib/shell directory. The following commits will
then refactor the code in net_shell.c to smaller and more
manageable pieces.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Alberto Escolar Piedras
eab871a1ff ipc: backend: rpmsg: Add support for POSIX arch
To enable runninng and testing this backend on the POSIX
architecture, we need to allow defining the shared memory
buffer as a compiler provided symbol, instead of a hard
address provided by the DTS.
For this case we refer to a symbol a POSIX arch implementation
(typically the board) needs to provide.
It is the responsability of that implementation to ensure
that symbol exists and points to a memory buffer of the
DT defined size.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-23 10:37:33 +02:00
Michał Barnaś
6fc22462a3 usbc: add sleep prevention in places that may require it
Add sleep prevention in crucial USB-C stack functions to make
state transitions faster and to send responses faster.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-23 10:33:38 +02:00
Michał Barnaś
2aabcabad3 usbc: add function that prevents the USB-C stack from sleep
Add internal function that prevents one sleep of the USB-C stack.
It can allow to have longer sleep times to conserve more power, while
still having possibility to respond in the required time and
set specific registers.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-23 10:33:38 +02:00
Gerard Marull-Paretas
915cb05bb6 dts: drop HAS_DTS
HAS_DTS has become a redundant option. All Zephyr architectures now
select this option, meaning devicetree has become a de-facto
requirement.  In fact, if any board does not provide a devicetree
source, the build system uses an empty stub, meaning the devicetree
machinery always runs.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-10-20 12:18:17 -07:00
Flavio Ceolin
2d5b781e99 llext: Fix wrong check
In llext_copy_symbols the check after llext_read
was looking the result of llext_seek operation instead
of the read.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-20 15:20:35 +02:00
Dawid Niedzwiecki
eac3ba2b3d mgmt: ec_host_cmd: remove timeout for UART callback
Do not use timeout for UART callback. The UART IRQ bases on the IDLE
line, so waiting for additional bytes is not necessary and it introduce
additional latency.

Another issue with the timeout is that the UART drivers use sysworkq for
implementing timeout. The sysworkq thread may have lower prio than the
host command thread, which may cause a delay in calling the UART
callback, which gives the semaphore to the HC handler.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-10-20 15:17:47 +02:00
Jordan Yates
7aa34e6482 bluetooth: hci_core: handle NUM_COMPLETED_PACKETS rsp
The `BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS` is not expected to generate a
response from the controller, but from the spec:

Normally, no event is generated after the
HCI_Host_Number_Of_Completed_Packets command has completed. However, if
the HCI_Host_Number_Of_Completed_Packets command contains one or more
invalid parameters, the Controller shall return an HCI_Command_Complete
event with a failure status indicating the Invalid HCI Command
Parameters error code.

In practice, this can also be generated if flow control is inadvertedly
turned off during operation. Running `hci_cmd_done` is not correct when
the event happens (as there is no corresponding command buffer), and
`ncmd` should not be returned as this command ignores the semaphore when
sending.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-10-20 15:16:54 +02:00
Anders Storrø
0a25a61c7d Bluetooth: Mesh: Op agg mdl coex
Refactors the implementation of the Opcode Aggregator
models to allow them to coexist on the same device.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:16:33 +02:00
Jukka Rissanen
31081d8411 net: tcp: Change FL() macro to avoid runtime overhead
Instead of strlen() use sizeof() in FL() macro. This way
all the checks are done at compile time instead of runtime.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-20 15:15:28 +02:00
Håvard Reierstad
765b31979f Bluetooth: mesh: update model extension
Adds a goto statement to ensure that model extensions are registered
in Composition Data Page 1 if it is enabled.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-20 15:14:41 +02:00
Ludvig Jordet
c613e23b4a Bluetooth: Mesh: Fix issue where dfu_cli could get stuck
This fixes an issue where the DFU client could get stuck trying to
transmit a message to servers if the DFU client was misconfigured, for
instance missing application key or network key.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2023-10-20 15:13:53 +02:00
Pavel Vasilyev
337ba330a2 Bluetooth: Mesh: Allow to set the extension list size to zero
If instantiated models don't have any relations at all, then the
extensions list will be empty. We should allow to disable it at all
to not waste RAM.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-20 15:13:35 +02:00
Robert Lubos
4ea3d247d0 net: tcp: Add Kconfig option to enable TCP RST on unbound ports
Add Kconfig option to control TCP RST behavior on connection attempts on
unbound ports. If enabled, TCP stack will reply with RST packet (enabled
by default).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-20 15:13:22 +02:00
Robert Lubos
95d9543e2e net: tcp: Send RST reply for unexpected TCP packets
Send RST as a reply for unexpected TCP packets in the following
scenarios:
1) Unexpected ACK value received during handshake (connection still open
   on the peer side),
2) Unexpected data packet on a listening port (accepted connection
   closed),
3) SYN received on a closed port.

This allows the other end to detect that the connection is no longer
valid (for example due to reboot) and release the resources.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-20 15:13:22 +02:00
Robert Lubos
a28215d028 net: tcp: Add helper function to send RST packet w/o active connection
Add a helper function which allows to send a RST packet in response to
an unexpected TCP packet, w/o associated connection or net context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-20 15:13:22 +02:00
Seppo Takalo
a95bafec74 net: lwm2m: Check access rights on composite operations
Composite operations need to check read/write access
rights as well.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-20 15:12:39 +02:00
Seppo Takalo
77ea861f12 net: lwm2m: Fix composite operations
As composite operations don't have path in CoAP packet,
it wrongly triggered a check for security object and got
denied the access.

Fixes #64012

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-20 15:12:39 +02:00
Seppo Takalo
bd0ad5bd66 net: lwm2m: Initialize empty string sizes correctly on objects
When objects are initialized, empty strings should be set to length of
zero, instead of length of the full buffer.

So use INIT_OBJ_RES_DATA_LEN() to give both, the buffer size and data
length.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-20 15:11:32 +02:00
Seppo Takalo
015b1103fb net: lwm2m: Properly initialize buffers for resource instance
When resource instances are initialized, we must calculate
beginning of the data buffer using the index and maximum
data length. Otherwise buffers would overlap with previous.

Fixes #64011

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-20 15:11:32 +02:00
Seppo Takalo
36d6a7257b net: lwm2m: Count null-terminator in string size
As the lwm2m_registry.c and specificly lwm2m_set()
functions already ensure null-terminator on string and
count that into string lenght, the content type handlers
should do the same.

When string is written, strlen()+1 is the data length.
When string is read, use the data length, so we don't
leak uninitialized strings. If buffer overrun have
removed the null-terminator the strlen() migh be larger
than data_len.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-20 15:11:32 +02:00
Emil Gydesen
f58bea6b7b Bluetooth: BAP: Scan Delegator bis_sync_req cb called on rem
If a receive state is removed, then the bis_syn_req callback
will be called with 0x00000000, to indicate to the application
that the sink should be desynced.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:10:37 +02:00
Emil Gydesen
8e9b2c745a Bluetooh: BAP: Fix issue with SRC_ID_VALID flag
The flag was not properly set when the broadcast sink
did not add the source (e.g. if a broadcast assistant
added it).

This also downgrades two LOG_WRN to LOG_DBG as they may
happen without indicating an issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:10:37 +02:00
Juha Ylinen
1aef034126 net: coap: add support for Echo option (RFC 9175)
Resend the request with Echo option and the received Echo
option value when receiving a 4.01 (Unauthorized) response
with the Echo option.

Add missing header file kernel.h to coap_client.h.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-10-20 15:09:44 +02:00
Juha Ylinen
1d9098f3f0 net: coap: Add support for request-tag (RFC 9175)
Add support for Request-Tag (RFC 9175) when doing block-wise
send.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-10-20 15:09:44 +02:00
Pavel Vasilyev
5b8a9517a1 tests: bluetooth: tester: Allow to compile mesh without LPN
This can be needed to qualify features without LPN support.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-20 15:09:25 +02:00
Pavel Vasilyev
6a2c102aca Bluetooth: Mesh: Keep sending Partial Block Report message
When the BLOB server is in Pull mode and all chunks were received for
the current block, and the current block is the last block, then
according to section 5.2.4 of MshMBTv1.0 the server should stop sending
BLOB Partial Block Report messages if it determines that the client
knows that the transfer is complete:

```
While the Pull BLOB State Machine is in the All Chunks Received state,
the Pull BLOB State Machine continues to send the BLOB Partial Block
Report messages until one of the following happens:
•  The Receive BLOB Timeout timer expires.
•  If the current block is not the last block, then the client starts a
new block, in which case a new Pull BLOB State Machine is instantiated.
•  If the current block is the last block, then the server determines
that the client knows the transfer is complete. For example, a
higher-layer model may indicate that the client considers the transfer
complete.
```

We currently don't have any OOB mean (for example, API) to determine
whether the client knows that the transfer is complete. We also need to
keep in mind that the Partial Block Report message can get lost so one
transmission may not be enough. The client could immediately send BLOB
Transfer Get message to get the transfer status, but this goes against
its state machine defined in section 6.2.4.2, where a Block transmission
completes when a BLOB Partial Block Report message is received with an
empty list of requested chunks (table 6.4, figure 6.1).

Because of this, we need to keep sending Partial Block Report messages.
We can keep sending them at least until Block Report timer expires.
If the client sends BLOB Transfer Get message, then it finished with
sending the block and we can change the phase and finish the transfer.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-20 15:09:25 +02:00
Flavio Ceolin
84f679d22d logging: Fix misuse of const and k_tid_t
"const k_tid_t" is "struct k_thread * const" and not
"const struct k_thread *" as the code may be assuming. Just
drop it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-20 15:08:42 +02:00
Ambroise Vincent
68dfd819c1 net: gptp: Create a stack size Kconfig option
The stack size was previously hardcoded in the source code, making it
difficult to change when enabling options that require a larger stack.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Ambroise Vincent
357f88bb59 net: ethernet: Don't use VLAN tag on gPTP messages
According to IEEE Std 802.1AS-2011 11.3.3, gPTP messages are not
VLAN-tagged.

Remove the use of VLAN headers for gPTP messages on the TX path.
The RX path is handled by the drivers. The network drivers in Zephyr
might need to be updated as well in order to accept receiving
non-VLAN-tagged gPTP messages when the CONFIG_NET_VLAN option is
selected.

Continue sending gPTP packets with VLAN tags when CONFIG_NET_GPTP_VLAN
is enabled. Specify that this option is for testing purposes.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Ambroise Vincent
d0ac02a18d net: gptp: Invert priority of outgoing packets
The previous implementation was setting priority 3 (Critical
applications) for Sync, Pdelay and Pdelay_Resp messages; and priority 6
(Internetwork control) for the other PTP messages. This might have been
done under the incorrect understanding that "Critical applications" was
the highest priority.
This resulted in the Pdelay_Resp_Follow_Up getting sent before the
Pdelay_Resp message when enough TC_TX queues were being used
(NET_TC_TX_COUNT >= 2), which is an inversion compared to the intended
order.

Invert the priority of the outgoing PTP packets so that the PTP event
messages are sent with higher priority, as was originally intended.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Ambroise Vincent
b7df39f81f net: ip: Clarify highest priority traffic class
The priority 3 (Critical applications) was incorrectly marked as
"highest priority", which might have led to incorrect use of
NET_PRIORITY_CA in some cases.

Note that this is already correctly advertized in other places, as it
was partially fixed in af8a0b1a5d.

NET_TC_SKIP_FOR_HIGH_PRIO was previously only allowing to push priority
3 (Critical applications) packets directly to the driver, but not the
ones with a higher priority. Change it so that it is now in effect for
priority 3 and above.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Anders Storrø
0ce77c227b Bluetooth: Host: CMake dependency for Mesh Bsim
Links host to mbedTLS library if Bluetooth Mesh is enabled, and
CONFIG_BT_TESTING=y.

Bluetooth Mesh has test dependencies in the host.
In order to compile Bsim tests with these test features
and PSA enabled, the libraries must be linked.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:07:51 +02:00
Emil Gydesen
a38d534ae0 Bluetooth: BAP: Shell: Add better checks for bis_sync
Since the BIS indexes start at 0x01, then BIT(0) is a
invalid BIS sync value and shall not be sent by the
broadcast assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:05:51 +02:00
Emil Gydesen
779f725db3 Bluetooth: CAP: Add verification of CCIDs as the initiator
When the initiator provides CCID in the metadata, we verify
that the CCIDs exist on the device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:05:33 +02:00
Troels Nilsson
7d96c997e2 Bluetooth: Controller: Fix endianness issues for SyncInfo
Fix bitfield crossing byte boundary - replaced with macros for
setting/getting the values

Fix missing endianness conversion for evt_cntr

Changed aa from uint32_t to uint8_t[4] to align with the rest of
the code and avoid any potential endianness issues

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-10-20 15:05:20 +02:00
Emil Gydesen
3b58fec96c Bluetooth: CAP: Add size and rank checks for CAS register
For the CAP acceptor the size and rank characteristic shall
be set as per the CAP spec. Add checks for 0, as 0 indicates
not initializing the characteristics in the CSIS instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:05:00 +02:00
Anders Storrø
6f2ebb963a Bluetooth: Mesh: Add proxy test API
Adds internal proxy API to enhance testabillity of
the proxy implementation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:04:54 +02:00
Anders Storrø
5551b4cfad Bluetooth: Mesh: Priv net id parse on proxy cli
Adds parsing of Private Network Identity parsing in the proxy client,
allowing the client to use these messages to establish a GATT
connection.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:04:54 +02:00
Anas Nashif
719fee2bbc doc: ztest: adapt ztest docs
Remove remaining usage and documenation of dropped kconfig that is now
the default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Anas Nashif
996c8457d7 ztest: remove old ztest api
Remove old Ztest API entirely. New API is the now the default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Anas Nashif
01281ed8af ztest: enable ZTEST_NEW_API by default
Enable by default so we can remove kconfigs from tests/samples and keep
things working as before.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Rubin Gerritsen
65501061ed Bluetooth: Controller: Kconfig: Move out BT_LL_SW_SPLIT configs
BT_CTLR_ISOAL_LOG_DBG_VERBOSE, BT_CTLR_ISO_TX_SEG_PLAYLOAD_MIN, and
BT_CTLR_CONN_ISO_AVOID_SEGMENTATION are very tied to the BT_LL_SW_SPLIT
implementation. It is very unlikely that these will ever be used by
another controller

Therefore move them out to the BT_LL_SW_SPLIT specific configuration
file. This will likely create less confusion when using another
controller.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-10-20 15:03:46 +02:00
Emil Gydesen
6054714a08 Bluetooth: BAP: Add PSN debug log support
Add a Kconfig that enables support for logging and
debugging invalid sequence numbers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:02:55 +02:00
Michele Imbriani - Oticon
b435dc1c6a bluetooth: shell: Fixed logic in is_substring function
Fixed the character check in is_substring function.

Signed-off-by: Michele Imbriani - Oticon <mbim@demant.com>
2023-10-20 15:02:28 +02:00
Alexander Kaiser
078cec1e1f usb: msc: Added check for negative overflow length
Added a check for when current_offset plus size is less than BLOCK_SIZE.

Signed-off-by: Alexander Kaiser <akaiser@urbansky.com>
2023-10-20 15:00:57 +02:00
Emil Gydesen
a2ab57c240 Bluetooth: Audio: Update bsim and shell to use codec set chan alloc
Update the BSIM test and the shell to use
bt_audio_codec_cfg_set_chan_allocation rather than implementing
their own versions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:00:27 +02:00
Seppo Takalo
8ffb64d46f net: lwm2m: Allow configuring update period
Add new configuration value CONFIG_LWM2M_UPDATE_PERIOD
that allows calculating update period from last update,
instead of calculating it from the lifetime.

In runtime, server is allowed to change the lifetime of the
registration which causes update perdiod to be effected.

When fixed update period is preferred, UPDATE_PERIOD
config is then used.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-20 14:57:38 +02:00
Michał Barnaś
3848e4c023 usbc: add checks for results of TCPC functions
This commit adds checks for results and in case of error, handles it.
The failed initialization of the TCPC can postpone initialization in
case the TCPC needs more time after powering up. Otherwise if other
error happened, the Type-C Layer will be disabled.
Errors in other places of the USB-C stack, like communication errors,
moves the state machine to the error recovery, restarting the
communication with parner.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś
fe0b6af337 usbc: merge the is_rx and get_rx_pending_msg functions
These two functions are used together so there is no need for
splitting them into two functions. This commit also makes this
function required to be implemented by the TCPC driver.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś
793d29d23f usbc: check if setting the CC and VCONN was successful
This commit adds check in cc_open entry state and logs if setting
either of the values were unsuccessful.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś
cff8bb2687 usbc: check if sampling CC lines were successful
When the get_cc function returns error, the CC lines should be
considered as open. It may happen either due to some chip malfunction
or chip going into sleep mode and needing time to reinitialize.
TCPC should only go to sleep if there is no partner attaches, so
in case of this error, the lines should be considered as disconnected.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś
0f4eb42c97 usbc: check if message is pending before trying to receive it
If TCPC supports checking for pending messages, it should be done
instead of forcefully trying to read the message and getting no-data
result. This helps with powereficiency for chips that go to sleep
when there is no message pending. Trying to read the message can
wake up the chip providing higher power usage.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś
216bc4db73 usbc: add check if tcpc initialization was successful
The TCPC driver initialization can be unsuccessful and it should be
checked and logged if that's the case.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś
88b6fc62d5 usbc: change type for functions that may return error code
TCPC API functions should be able to inform the caller if the function
is supported and successfully executed. Bool values doesn't allow this
so it is needed to change the type to int.
For is_rx_pending_msg function the return code should conform to
existing error codes, so in case of function being not supported,
the -ENOSYS should be returned. In case of successful execution,
if there is no pending message, the -ENODATA should be returned and
in case of message pending, the value of 0.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Emil Gydesen
f67f840def tests: Bluetooth: Add tx/rx and data verification for BAP unicast
The BAP unicast babblesim tests now does RX and TX
and verifies that the data is correctly received on both
the client and server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:56:28 +02:00
Emil Gydesen
9c47eb924f Bluetooth: Audio: Refactor codec_cfg_get_frame_duration_us
Refactor the codec_cfg_get_frame_duration function to return the
assigned numbers value, instead of a converted value, but with
support for converting the value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:56:13 +02:00
Lingao Meng
c2b2641fc1 Bluetooth: Mesh: Move ext adv sector to vector
Obviously, it looks obscure by putting it in a sector,
so, let's move to vector.

refs: https://github.com/zephyrproject-rtos/zephyr/pull/57883

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Lingao Meng
1b22324317 Bluetooth: Mesh: Use system workqueue for dhkey gen
Since the default process dhkey gen in bt rx, will block send
Trans Ack, cause peer device send more package.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Lingao Meng
141467a261 Bluetooth: Mesh: Rename adv relay to adv simultaneous
Since notice that simultaneous advertising is not only used
by relay message, provision over pb-adv can also be used.
so it was changed to a more general name.

refs:https://github.com/zephyrproject-rtos/zephyr/pull/48903

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Lingao Meng
b14d235c31 Bluetooth: Mesh: Remove bits for adv tag
since tag for buf single only, no need for bit, also for
save some memory for rfu.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Mariusz Skamra
49e7030363 Bluetooth: audio: has: Minor logging improvement
This adds more logs for debugging purposes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
27049744b9 Bluetooth: audio: has: Remove include of conn_internal header
This makes use of bt_conn_get_info function to access the conn address.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
df1fd21892 Bluetooth: audio: has: Truncate Control Point notifications to ATT MTU
This will truncate ATT notifications/indications if exceed ATT MTU size.
It is up to the client to exchange MTU.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
b0e7a1b0ac Bluetooth: audio: has: Fix missing memset of parameters
This fixes missing memset of parameters used for indications and/or
notifications.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
4d023023a3 Bluetooth: has: Fix preset list notifications after reconnection
This fixes sending proper Preset List notifications after
reconnection. The issue was observed when the last preset
known to the client has been removed.
As we do not hold the information about the deleted presets,
we need to use Generic Update procedure to:
 1. Notify the presets that have been removed in range
    (PrevIndex = current_preset_last, Index=previous_preset_last)
 2. Notify deletion of preset Index=previous_preset_last.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
a7406aa8f4 Bluetooth: has: Factor out bonded client persistent data
Some of the data shall be persistent across connections to bonded
clients. This includes notidication state flags that are used to
determine whether notify bonded client after reconnection.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
9c6419c615 Bluetooth: audio: has: Refactor preset list to single-linked list
This refactors the preset list to use sys_slist API. There have been
various issues seen while iterating presets, thus it's more save to use
well-defined and tested sys_slist API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
31e329bb2d Bluetooth: audio: has: Defer notifications to sysworkq
Defer sending the features, active index, preset list and preset read
response to sysworkq and retry sending in case failed due to buffers not
available at the moment.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
2735339a82 tests: Bluetooth: has: Add test Preset Changed Offline Behavior
Verify that a HAS Server IUT sends changed characteristic notifications
or indications when the Lower Tester reconnects.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
b89cdadc74 Bluetooth: audio: has: Factor out set_preset_availability function
This moves common code to set_preset_availability function to be called
from bt_has_preset_available and bt_has_preset_unavailable.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
f63726da79 Bluetooth: audio: has: Fix sending notifications on reconnect
This fixes missing setting of FLAG_CONTROL_POINT_NOTIFY flag that
indicate whether submit control_point_work. In case the there are more
indications/notifications to sent (is_last flag is unset), the
FLAG_CONTROL_POINT_NOTIFY shall be set to resubmit control_point_work.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
c44f0da4f1 Bluetooth: audio: has: Don't revert features value on error
This removes revering the features value back to previous state if work
submission failes. Even if it fails it indicates an internal sysworkq
issue, so even retry won't help. The client can read the features value
anyway, thus it's sane to just log an error in such case.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
cf2f2df61d Bluetooth: audio: has: Fix indentation
This fixes code indentation.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
b10f02da61 Bluetooth: audio: has: Fix checking wrong flag
This fixes testing and clearing features flag.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Emil Gydesen
84c01bb527 Bluetooth: Audio: Add ISO test parameters to the BAP API
Add support for the ISO test parameters in the BAP API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:50:48 +02:00
Emil Gydesen
0521ffd5a3 Bluetooth: ISO: Rename BT_ISO_ADVANCED to BT_ISO_TEST_PARAMS
Rename the Kconfig option from BT_ISO_ADVANCED to
BT_ISO_TEST_PARAMS to more explicitly denote that it
enables support for using the ISO test parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:50:48 +02:00
Jeppe Odgaard
a58bf96d0d fs: fix missing semicolon in fuse_fs_access.c
Add missing semicolon in fuse_fs_access.c.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-10-18 15:50:50 +03:00
Christopher Friedt
137097f5c3 logging: log_core: correct timeout of -1 ms to K_FOREVER
Many releases ago, specifying to block indefinitely in the log
processing thread would do just that.

However, a subtle bug was introduced  such that specifying -1
for `CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS` would have the
exact opposite effect than what was intended.

As per Kconfig, a value of -1 should translate to a timeout of
`K_FOREVER`. However, conversion via `K_MSEC(-1)` results in
a `k_timeout_t` that is equal to `K_NO_WAIT` rather than the
intent which is `K_FOREVER`.

Add a dedicated check to to ensure that a value of -1 is
correctly interpreted as `K_FOREVER` in `log_core.c`.

For reference, the blocking feature was described in #15196,
added in #16194, and it would appear that the regression
happened in c5f2cdef09.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-10-16 12:06:42 +02:00
Ladislav Podivin
390b6520b8 Logging: improve help message of LOG_PRINTK Kconfig option
Improve it so that:
- it mentions the important fact that it redirects `printk` messages
 to the logging subsystem
- it is consistent with the help messages of the other options in this
 file (i.e. it starts with "If enabled")

Signed-off-by: Ladislav Podivin <ladislav.podivin@tietoevry.com>
2023-10-13 22:36:47 +03:00
Tom Burdick
c678f25bc1 llext: Fix a bug in section linking
When relocating section symbol addresses the value where the
relocation is to be written is an offset into the section to load.

Simply rewriting it with the section address is not enough, we need
to write the address of the section with the offset into it.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-10-13 16:47:02 +01:00
Jakub Rzeszutko
69d50db53a shell: fix a memory corruption coverity issue
Added a condition to check if the size of the copied
memory is a positive number.

Fixes #58700
Fixes #58703

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2023-10-13 13:11:28 +03:00
Dawid Niedzwiecki
f02c612c99 mgmt: ec_host_cmd: align buffers
Align the rx and tx buffers to prevent unaligned access.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-10-13 11:59:33 +03:00
Alexander Stark
d385d10130 mgmt: mcumgr: update bt smp initialization
Oneline fix to smp_bt.c smp transport register.
smp_client_transport_register() is a void function and
has no return value, so it should be ignored.

Signed-off-by: Alexander Stark <alexander.t.stark@gmail.com>
2023-10-13 09:40:21 +01:00
Flavio Ceolin
5fcae0c021 random: timer: Use build constant for seed
Use Kconfig symbol for initial seed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-13 10:03:53 +03:00
Flavio Ceolin
a99a0700ba random: kconfig: Allow customizing timer initial state
Add a build option to allow changing the initial state used
in the timer based random generator and by the kernel in the
early random number generator.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-13 10:03:53 +03:00
Mariusz Skamra
3828f1cec2 Bluetooth: ascs: Check subscription state on ASE notification
Check whether peer is subscribed for ASE state notification before
calling bt_gatt_notify. This handles an assert thrown when the
notification failed to be sent.

Fixes: #63728
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-12 18:48:09 +03:00
Emil Gydesen
c47b7f7936 Bluetooth: BAP: Broadcast sink: Clear pa_sync on PA terminated
If the PA gets terminated, we clear the pa_sync field of the
corresponding broadcast sink object.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:19:46 +03:00
Emil Gydesen
00deb0ea75 Bluetooth: BAP: Remove static from state_changed in mod_src
For some reason the state_change variable was static, which
does not make any sense. Changed it to a regular local
bool in bt_bap_scan_delegator_mod_src.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:18:42 +03:00
Emil Gydesen
58e40239fd Bluetooth: BAP: Scan delegator missing state change for bis_sync
If the bis_sync value changes, that should trigger a state change
notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:18:42 +03:00
Aleksandr Khromykh
00457ae6c6 Bluetooth: Mesh: improve solicitation debug logging
Commits adds debug logging for all reasons
preventing of the proxy solicitation.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-12 18:07:50 +03:00
Aleksandr Khromykh
625faa7f03 Bluetooth: Mesh: fix proxy solicitation
Commit makes workable proxy solicitation functionality
only server part without dependencies on client part.
Only on demand proxy server is required.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-12 18:07:50 +03:00
Pavel Vasilyev
0af523eba7 Bluetooth: Mesh: Fix failing DFU/SR/FD/BV-08-C test
The `upload_status_rsp_with_progress` function uses the currently set
slot pointer to set firmware id field in the message. If another
upload starts but the firmware is already received, the slot API won't
let us to set the fwid and will return an error code. In this case, the
slot pointer stays invalid as fwid wasn't set, and
`upload_status_rsp_with_progress` will not add fwid as the lenght is
zero.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-12 15:29:45 +03:00
Pavel Vasilyev
5cf6218c62 Bluetooth: Mesh: Fix Capabilities Status message with OOB upload enabled
The `else` case was incorrectly excluded by preprocessor.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-12 13:59:06 +03:00
Jamie McCrae
c67560cbbd mcumgr: grp: settings_mgmt: Handle settings return values
Handles return values from settings handlers which were missing
and would return "Unknown error" to clients instead of the read
error

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-12 11:54:30 +01:00
Jamie McCrae
828940b420 mcumgr: grp: fs_mgmt: Fix error on hash/checksum of empty file
Fixes the error code being returned when trying to perform a
hash/checksum on an empty file to show it is because the file is
empty, not because a paramter (which was not provided) was too
large.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-12 11:54:01 +01:00
Jamie McCrae
65bb96f37c retention: blinfo: Fix issue with crash writing to keys
Fixes an issue which would cause a fault if someone attempted
to write to the (non-writable) blinfo keys

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-12 11:53:21 +01:00
Jukka Rissanen
0a16d5c7c3 net: socket: mgmt: Check buf size in recvfrom()
Return EMSGSIZE if trying to copy too much data into
user supplied buffer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-12 10:33:36 +03:00
Vinayak Kariappa Chettimada
7ee427ff58 Bluetooth: Controller: Fix CIS encryption when DF support enabled
Fix hung Controller when establishing CIS on an encrypted
ACL connection with Controller built with direction finding
support enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-12 09:48:54 +03:00
Emil Gydesen
de67ec9e67 Bluetooth: BAP: Fix broadcast source reconfig with subset of streams
When the bt_bap_broadcast_source_reconfig was supplied with a subset
of the streams, it would only update the codec cfg and qos for the
streams provided in the parameters.

This commit changes that, so all streams are properly updated,
as they share some common values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:41:30 +03:00
Emil Gydesen
7339849077 Bluetooth: BAP: Broadcast Sink should not terminate the PA Sync
When calling bt_bap_broadcast_sink_delete, the broadcast sink
should not attempt to terminate the PA Sync. The PA sync can live
on without the broadcast sink, just as the broadcast sink can live
on without the PA sync (which is why the PA sync check was completely
removed).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:40:41 +03:00
Emil Gydesen
37b6ddd918 Bluetooth: BAP: Broadcast Sink only set synced BIS indexes
When updating the Scan Delegator receive state, we shall only
set the BIS indexes in bis_sync that we are actually synced to.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:33:55 +03:00
Bjarki Arge Andreasen
517bec233e modem: modem_cmux: Increase modem cmux buf size
This commit increases the buffer used for commands
in the control channel within an instance of the
modem_cmux module. The buffer was not large enough to
store an MSC command if the optional break signals
where included. This commit fixes the issue and
updates the test suite to use the max size MSC message.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-10-11 18:57:11 +03:00
Pavel Vasilyev
2c9fc043d7 Bluetooth: Mesh: Print URI and FWID in Upload OOB Start msg
this is useful for debugging.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
d1c2ca2525 Bluetooth: Mesh: Release previously reserved slot before reserving again
If the previous upload was in-band and it didn't complete, the slot will
stay reserved. By design we release slot not at the end of the upload
phase, but at the start of a new upload phase.

This fixes DFU/SR/FD/BV-13-C.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
7154f356af Bluetooth: Mesh: Ignore duplicate OOB upload request
If a Fw Distribution Client sends the Upload OOB Start message, but the
application layer didn't call bt_mesh_dfd_srv_oob_check_complete yet,
we have no other option other than ignore the message. The next phase
in this case could be Transfer Active, Transfer Success or Failed and it
will be set only after Check Firmware OOB procedure completes.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
1329a9d312 Bluetooth: Mesh: Fix Fw Dist Upload OOB Start msg length check
This message _at least_ 2 bytes long, but can be longer, thus
BT_MESH_LEN_MIN should be used.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
9641864a20 Bluetooth: Mesh: Fix Upload Progress for already received fw
In OOB upload, when Check Firmware OOB procedure completes successfully
and the firmware is already received, we send Firmware Distribution
Upload Status message with update Phase set to Transfer Success. In this
case, we must set Upload Progress to 100%. This can't be done through
the callback as the application layer doesn't yet know that the firmware
is already received. This will happen by the exist from
bt_mesh_dfd_srv_oob_check_complete function, which will return error
code -EEXIST.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Mariusz Skamra
916df03e7a Bluetooth: ascs: Fix Source ASE link loss state transition
According to the ASCS_v1.0 the ASE in Streaming state shall transit to
QoS Configured state when link loss happen.

Relates: ES-24215 (errata)
Fixes: BAP/USR/SCC/BV-168-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-10 15:18:37 +03:00
Flavio Ceolin
e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Pavel Vasilyev
68365d5b67 Bluetooth: Mesh: Reset targets state before starting DFU on DFD srv
The list of receives in the Firmware Distribution Server model and
and the Firmware Update Client model are 2 different lists.

In the Firmware Update Client model it is called the Update Receives
state and the Active Update Receivers state which is a subset of
receivers from the Update Receivers State. In the Firmware Distribution
Server model it is called the Distribution Receivers List state.

When Distribute Firmware procedure starts, in the Initiate step, the
Receivers List input (which is the input for the Update Receivers
state), is composed of the Distribution Receives List state. During DFU,
the Update Receivers state becomes the Active Update Receivers state
which keeps only active nodes. Timed out or failed nodes dropped out
from this list. The Distribution Receivers List state stays unchanged
and thus don't need to be populated again after every successfull and
failed DFU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-09 16:18:53 +03:00
Martin Jäger
33bd2fed08 task_wdt: fix race condition for task_wdt_add function
The task_wdt_add function changes the reload_period of the channel to a
non-null value, which indicates that the channel is used. If the
function is interrupted by a task_wdt_trigger running in ISR context
before adding of the new channel has finished, the next timeout will be
scheduled based on inconsistent channel data.

Using a spinlock avoids such data races.

Fixes #61004

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-10-09 16:10:00 +03:00
Håvard Reierstad
3d40d91f86 Bluetooth: mesh: access: Fix model relation register
Added offset to the model relation register for vendor
models to find correct model index
for Composition Data Page 1. The previous implementation used the
'mod_idx' from the 'bt_mesh_model' struct, which led to issues in the
model relation register due to SIG and vender models having the same
model index.
Modified existing functions related to the model relation
register to take in the offset.

Modified macros for determining if a model is a base- or
extending model.

Added check in 'add_items_to_page' to check whether the model relation
is an extension.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-09 15:06:06 +03:00
Håvard Reierstad
ea753eb52a Bluetooth: mesh: Change cfg_cli buffer length check
Changed buffer length check in bt_mesh_comp_p1_elem_pull.
The previous threshold would result in the
method not detecting the final element when it consisted of just one
model.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-09 15:06:06 +03:00
Jeroen van Dooren
fe8d30dd42 net: ip: tcp: Fix kernel crash on idle thread
Fixing kernel crash caused by memory release
while having a scheduled work item pending.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-10-09 10:16:05 +02:00
Dennis Grijalva
b122685eff bluetooth: conn: Fix compiler warning
When compiling conn.c using arm-none-eabi-gcc version 11.3.1 20220712
with the -Wmaybe-uninitialized flag a warning is emitted due to
pending_no_cb not being initialized. I'm not sure if initializing it to
NULL is the "correct" fix, but it's certainly not any worse then it being
uninitialized, and it fixes the warning.

Signed-off-by: Dennis Grijalva <dennisgrijalva@meta.com>
2023-10-08 18:17:22 +03:00
Carles Cufi
f2af4a7bfd Bluetooth: host: document the connection states
Connection states are non-trivial to understand based on their names
only, so add short descriptions in the header file explaining what they
do.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 17:50:03 +03:00
Fredrik Danebjer
fefbb28edb Bluetooth: Audio: Fix return code in PACS notify
Fix errenous return value in pacs_gatt_notify function. The function
would always return zero, and not forward the error correctly.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-10-06 17:43:08 +03:00
Pavel Vasilyev
f4a592f3bb Bluetooth: Mesh: Don't reset mod pointer
Don't reset values set in init callback as it is called only once by
bt_mesh_init call. The reset callback is called on every node reset.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-06 16:47:09 +03:00
Anders Storrø
65f029e185 Bluetooth: Mesh: Common comp page parse func
Create common composition page parser function.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-06 16:21:02 +03:00
Anders Storrø
57cb1b1ccb Bluetooth: Mesh: Add missing comp pages to LCD mod
Adds support for all composition data pages to the
Large Composition Data model.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-06 16:21:02 +03:00
Carles Cufi
ee0314a832 Bluetooth: host: Replace length check assert with if statement
A few of the length checks that deal with HCI packets coming from the
controller were using assert statements. But the recommended practice is
to drop invalid packets and continue execution whenever a malformed
packet arrives from an external source, so replace those assert
statements with branches that will drop the packet and return.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 16:18:43 +03:00
Ingar Kulbrandstad
a5d15ec017 Bluetooth: Mesh: Fixed issue with RPR server and client.
Fixed issue when reprovisioning is done on a device with
both RPR client and server on the same device.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-10-06 16:06:12 +03:00
Andries Kruithof
e8716bf793 Bluetooth: controller: change calc for data in PDU
The existing formula for the amount of data that can be filled
in in the current PDU is correct but confusing. Replace it with
a simpler formula.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Andries Kruithof
d00d44c925 Bluetooth: controller: fix failing EBQ advertising tests
Updates the chaining for advertising.
Instead of unconditionally adding a new PDU when new data
is added we now instead fill the last PDU in the chain with
the incoming data, only adding a new PDU when there is
not enough room.

This reduces the nr. of PDUs used for advertising, and also
fixes some qualification failures

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Emil Gydesen
af953a1d07 Bluetooth: BAP: Fix bug in BASE bis index
The indexes were reset to 0 for each subgroup, which meant
that if we had a broadcast source with 2 subgroups and
1 BIS in each, both of them would use index 0x01.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-06 12:21:42 +01:00
Jonathan Rico
b1da312e9d Bluetooth: ATT: discard RX on a disconnected connection
A race condition between ATT RX and the connection teardown can happen, as
the teardown is executed from a workqueue.

For example:
- connection is established
- `connected` cb is called (in BT RX context)
- user calls `bt_conn_disconnect` in that cb
- connection is marked as disconnecting
- ATT teardown & general conn cleanup is scheduled
- BT RX gets an ATT request, tries to handle it
- ATT bearer is still not GC'd, so it tries and fails to send it
  -> results in error message "not connected" on log
- ATT teardown & general conn cleanup runs

To avoid that, we not only check the bearer state, but also its ACL conn
state.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-10-06 12:19:39 +01:00
Vinayak Kariappa Chettimada
e50748b67c Bluetooth: Controller: Fix leak in scheduled ticker node
Fix leak in scheduled ticker node when rescheduling ticker
nodes.

Applications having active Extended Advertising or Observer
role with the use of ticker reschedule in window feature
would experience assertion check failure due to delayed
radio event preparation or stalled controller with no active
roles.

Fix updating of the ticker linked list when handling
rescheduled tickers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-06 12:54:12 +02:00
Vinayak Kariappa Chettimada
7495846b62 Bluetooth: Controller: Rename ticker reschedule variables
Rename ticker reschedule in window variable to improve
readability.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-06 12:54:12 +02:00
Yonatan Schachter
23b977d1c4 bindesc: Use UTC time by default and comply with ISO-8601
Use UTC time by default, and add the option to use local time.
Also, change the default formats to comply with ISO-8601.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2023-10-06 13:37:02 +03:00
Carles Cufi
a5e7ba3564 Bluetooth: Controller: Remove legacy BT_CTLR_FAST_ENC option
When the legacy LLCP implementation was removed this Kconfig option was
mistakenly left over. Remove it now with all its users.

Fixes #63212.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 13:32:33 +03:00
Andrzej Głąbek
cb1b1ce7d1 bluetooth: common: Kconfig: Add missing dependency for BT_MONITOR
This module calls `log_output_*` functions so it should enable
the `LOG_OUTPUT` Kconfig option explicitly.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-10-06 11:42:40 +03:00
Tom Burdick
9e8d609b5d rtio: Remove unused Kconfigs for executors
There's only one executor now and its always built, no need for these
old crufty Kconfigs.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-10-06 09:18:43 +02:00
Bjarki Arge Andreasen
1816b6380b modem: modem_cmux: Set C/R bit in UIH frames
This commit sets the C/R (command/response) bit when UIH
CMUX frames are sent from the modem_cmux module. This bit
is ignored by some modems like the Quectel BG95, as there
is no defined response to this specific CMUX frame type.
However, other modems, like the TELIT ME910, require the
bit to be set (command). If the bit is not set, the modem
will simply ignore the frame completely.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-06 09:18:32 +02:00
Emil Gydesen
147cef6660 Bluetooth: Controller: Add hdl checks in isoal.c
Add checks to verify the `hdl` parameters before accessing
the sink and source arrays.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-05 15:25:17 +02:00
Emil Gydesen
f4221d66c1 Bluetooth: Controller: Make aa in radio_aa_set const
Make the aa argument const to solve a Coverity issue
that assumes that any value that is being byteswapped
is tainted. Making the argument const should avoid
this assumption from Coverity.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-05 15:25:09 +02:00
Andries Kruithof
c5d844fe41 Bluetooth: controller: fix comparision of unsigned int to 0
Fix the coverity issue CWE570, comparison of unsigned int to 0
in the definition of IS_SYNC_ISO_HANDLE

There is a potentially the same issue for IS_ADV_ISO_HANDLE,
fixed that as well

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-05 15:24:54 +02:00
Stasys Aužbikas
deac568b18 mgmt: mcumgr: transport: dummy: Fix truncating uint16_t
`smp_send_pos` is 16 bits wide but it was being
passed as uint8_t, thus truncating.
This made it impossible to receive packets
larger than 256 bytes.

Signed-off-by: Stasys Aužbikas <stasysau@gmail.com>
2023-10-05 11:22:32 +02:00
Aleksandr Khromykh
0ba6e80a12 Bluetooth: Mesh: fix settings work queue size for rpr
If RPR server is used then Mesh settings work queue
requires more size during provisioning procedure.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-05 09:44:00 +01:00
Flavio Ceolin
3521c95c2f fs: fuse: Fix possible buffer overflow
Ensure that the path in fuse_fs_access_readdir does not overflow
the local buffer.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-05 09:42:17 +01:00
Emil Gydesen
e962fda0ee Bluetooth: Audio: Fix BAP Broadcast source reconfig param count
The check for number of streams in a subgroup was reversed, so
it would never allow for correct values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-05 09:19:56 +02:00
Wojciech Slenska
dcf6327d6a net: context: set context->local for offloaded iface
Currently context->local is not set for offloaded interface.
This change move net_offload_bind call after set of context->local.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-10-04 20:29:33 +02:00
Mateusz Kapala
7a1b194a97 bluetooth: host: smp: Add runtime check for central-specific path
Added run-time BT_CENTRAL role check for the path that was
central specific and did not have such check.

When multi-role BT device tried to pair without bonding (peripheral role)
while already previously bonded with the same device on another
Bluetooth identity, pairing failed.
It executed central-specific code, which should not be executed in case
when the device acts as peripheral (as it is even opt-out from code when
CONFIG_BT_CENTRAL is not enabled).

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2023-10-04 14:53:26 +01:00
Emil Gydesen
c6cecef120 Bluetooth: Controll: Fix dead code in ll_setup_iso_path
In ll_setup_iso_path cis is only ever set if CONFIG_BT_CTLR_CONN_ISO
is enabled, and similarly adv_stream is only ever set if
CONFIG_BT_CTLR_ADV_ISO is enabled.

The two assignments were reported as dead code by Coverity due
to this, which has been fixed by guarding the code with
the respective Kconfigs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-04 14:52:54 +01:00
Rait Rääk
6c2da47e4c bluetooth: conn: Fix forced pairing request handling
BT_SECURITY_FORCE_PAIR option gets overridden when CONFIG_BT_SMP_SC_ONLY
or CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY is defined. Cache the bit value
before overrides.
Add explicit forced pair handling to existing security level check.
Functionality did not change as this was done implicitly due to integer
comparison for enums.
Add extra clarification to the method doc.
Signed-off-by: Rait Rääk <raitraak@gmail.com>
2023-10-04 14:49:58 +01:00
Juha Ylinen
22f09e9fa0 net: coap: release non-confirmable messages
Only confirmable messages need pending tracking. Non-confirmable
messages are released after sending.
Match incoming packets with token, not message ID.
Ignore responses with non-matching tokens.
Remove unused function send_reset().

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-10-04 11:25:16 +02:00
Robert Lubos
1b21109c2c net: lwm2m: Reset ongoing notification in case token changes
In case observation token changes (the LwM2M server re-sends
observation request to the client), the LwM2M engine should cancel any
ongoing notifications based on the old token. Otherwise, it will be
impossible to match the pending notification reply (ACK) with the
observer context anymore, causing new notifications for this
observation to stall.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-04 11:23:53 +02:00
Emil Gydesen
89db200117 Bluetooth: Controller: Remove unused terminate_ack
Remove the terminate_ack from struct ll_conn since it is
not used anywhere, and results in dead code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-04 10:08:07 +02:00
Alperen Şener
fe6fb0f467 bluetooth: mesh: fix static oob auth padding
The remaining bit should be zero if auth is
shorter than PROV_AUTH_MAX_LEN and it should
be trimmed by removing octets with indexes
higher than PROV_AUTH_MAX_LEN.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-10-04 10:07:55 +02:00
Flavio Ceolin
15aa3acaf6 kconfig: Remove MP_NUM_CPUS usage
Zephyr's code base uses MP_MAX_NUM_CPUS to
know how many cores exists in the target. It is
also expected that both symbols MP_MAX_NUM_CPUS
and MP_NUM_CPUS have the same value, so lets
just use MP_MAX_NUM_CPUS and simplify it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-03 17:45:53 +01:00
Florian Grandel
630bfff65f net: lib: zperf: fix compiler warning
The compiler emits a "null where non-null expected" warning unless the
argument of strlen is non-null at compile time.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-10-03 15:21:34 +01:00
Kai Meinhard
33494d4ea2 LLEXT: Make max size in shell configurable
The maximum size of an extension accept by the shell
was previously a define and is now made configurable through Kconfig.

Signed-off-by: Kai Meinhard <meinhard@gessler.de>
2023-10-03 15:17:39 +01:00
Martin Åberg
8130435c2a mgmt: mcumgr: grp: os_mgmt: Add SPARC
Define the preprocessor symbol PROCESSOR_NAME for SPARC to avoid a
preprocessor warning.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2023-10-03 15:14:30 +01:00
Kieran Tyrrell
a714b42080 net: ip: fix promiscuous mode altering packets
Always clone net_pkt to pass to promiscuous queue.
Previously, net_pkt was passed to L2 before conditionally cloning.
But L2 would in some cases strip ethernet headers, so cloned
net_pkt received through promiscuous interface would be missing headers.

Signed-off-by: Kieran Tyrrell <kieran@sienda.com>
2023-10-03 15:10:57 +01:00
Andrei Emeltchenko
d68db1ecfa net: dhcpv6: Fix params check
Fix params check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-10-03 15:10:41 +01:00
Vivekananda Uppunda
b0c9658029 net: l2: wifi: Fix Wi-Fi mode get command bug
The mode command operation has to be set to WIFI_MGMT_GET when the
option -g is provided. It was mistakenly set to true. Correcting the
same

This PR fixes #63424 and sets the proper value for the get command

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2023-10-03 11:30:13 +02:00
Emil Gydesen
2248394327 Bluetooth: Audio: Fix issues when setting new cfg values
Fix issues when setting new values in cfg that modify
the length of the codec configuration LTV value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-03 09:21:20 +02:00
Ivan Iushkov
c650f6aea0 Bluetooth: documentation change of kconfig.iso configs
Added comment to KConfig.iso file to make description
of BT_ISO_TX_MTU and BT_ISO_RX_MTU more clear

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2023-10-02 22:58:58 +03:00
Ivan Iushkov
a4a196f002 Bluetooth: fix iso_has_ts field for SDU fragmented to multiple HCI packets
iso_has_ts wasn't set correcrly for fragments of HCI ISO Data packets,
now it is set depending on timestamp
provided in the original buffer provided by host user

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2023-10-02 22:58:58 +03:00
Ivan Iushkov
4f5323a1cf Bluetooth: fix HCI ISO Data packets fragmentation
this commit partially reverts e460847b60

According to Core Spec 5.4, Vol. 4, Part E, 5.4.5, Data_Total_Length field
contains length of the whole packet including optional fields of SDU
(Time_Stamp, Packet_Sequence_Number, ISO_SDU_Length, RFU and
Packet_Status_Flag). In Zephyr Host, Data_Total_Length value
is stored in bt_dev.le.iso_mtu field.
Therefore, there is no need to calculate iso_hdr_len(),
this length is already taken into account in conn_mtu(conn).

This commits removes iso_hdr_len() function and fixes
calculation of HCI ISO Data packet length calculations.

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2023-10-02 22:58:58 +03:00
Vinayak Kariappa Chettimada
48c83a1f42 Bluetooth: Controller: Fix num cmplt for BIS HCI ISO Data fragments
Fix number of completed packets generated when BIS HCI ISO
Data packets sent to Controller are in fragments. Use the
ISOAL stored sdu_fragment count to generate the number of
completed packets count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 11:36:33 +02:00
Vinayak Kariappa Chettimada
a178aa9855 Bluetooth: Controller: Review rework flush timeout support
Review rework changed related to flush timeout support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
291cd03818 tests: bsim: Bluetooth: Test RTN=2, FT=2, Cen skip 2 SE in Controller
Test RTN=2, FT=2 in Controller with 2 subevents dropped by
central.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
2935d3b731 tests: bsim: Bluetooth: Test RTN=2, FT=2, Per skip 2 SE in Controller
Test RTN=2, FT=2 in Controller with 2 subevents dropped by
peripheral.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
61d00467b4 Bluetooth: Controller: Option to ignore Tx ISO Data Packet Seq Num
Kconfig option to turn off ISO Data Packet Sequence Number
use to place the ISO Data in the correct radio event,
instead simply buffer it to next radio event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
e3ecab3142 Bluetooth: Controller: Fix ISO Data timestamp when FT > 1
Fix ISO data timestamp to reflect the SDU reference point
and not the ISO event anchor point when PDUs received after
retransmissions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
7fa77a67fc Bluetooth: Controller: Use of payload_count for Flush Timeout
Use of payload_count for supporting flush timeout in
Central and Peripheral ISO Lower Link Layer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
7a14830d85 Bluetooth: Controller: Remove HCI ISO data with invalid status
Remove incorrect implementation of HCI ISO data with invalid
status.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Johann Fischer
d18cb6c189 usb: host: usbh_ch9: add ASSERT for unresolved data stage conditions
Do not explicitly check buf parameter in usbh_req_setup()
but add ASSERT to check unresolved data stage conditions.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer
dd43679fdf usb: host: add command to get the current device configuration
Add command to get the current device configuration.
Revise the shell part to have a set|get configuration
subcommands.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer
2cea6e091b usb: host: remove unused USBH_DEFINE_CLASS(bazfoo) from the shell
With the latest change, there is no need for this structure
to be used as a completion handler.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer
c1065e0e19 usb: host: rework ch9 tools to work on USB device
Use the USB device structure and wrappers introduced earlier.
With this patch, users of ch9 requests do not need to work
directly with the UHC API. The requests are now blocked until
there is a response from the UHC. Callers finally have access
to the data buffer and request status.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer
c3bcf31481 usb: host: add a structure to represent a USB device.
Add a structure to represent a USB device and wrappers to avoid
glue UHC calls when operating on devices. Although there is a long
road to device configuration and management, we can start with
the tools that can also be used for USB device support testing.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer
aced8f528e usb: host: cleanup UHC event processing
Remove ugly hack to call class driver ops.
This is preparation for later changes where we will change
parts to work on structure that represents USB device and
not on glue UHC functions.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer
9cb777b95e drivers: uhc: rework transfer buffer handling
The current approach is a bit impractical in the upper layer.
This patch removes the two fifos that hold the transfer buffers
and replaces them with a byte array for the setup packet and
a pointer to a data buffer. The data buffer is mandatory for
all types of transfers except control without a data stage.
The waste of eight unused bytes for non-control transfers should
be insignificant, since an additional pointer would be at least
half of it, and then there would be the overhead of handling it.

This patch also clean up the transfer flags, rename owner to callback
as it reflects the upper layer use case, and add an additional member
to hold the pointer to the USB device (peripheral on the bus).

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer
ef72f73945 usb: device_next: loopback: fixup left over from early state
Class instance must not call usbd_ep_ctrl_enqueue().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Chandler Keep
27b4b9f4c8 mgmt/MCUmgr/mgmt: Support for finding registered command groups
This commit adds support for finding registered mcumgr command groups.

By default, supported command groups are local to the namespace where
they're registered. This api addition allows applications to get
reference to these supported command groups to deregister & re-register
them.

This adds scope for applications to support multiple implementations
of a command group alongside the default.

Signed-off-by: Chandler Keep <chandlersamkeep@gmail.com>
2023-09-30 18:48:06 +02:00
Bjarki Arge Andreasen
48a069204c modem: modem_pipe: Avoid inconsequential open/close calls
This PR adds a mechanism to avoid calling open() or close()
on pipes which are already opened or closed respectively.

This optimization can help simplify backends implementing
the modem_pipe API by avoiding duplicated boilerplate code.

The TTY backend test suite has been updated to match the
new behavior.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-30 18:47:48 +02:00
Bjarki Arge Andreasen
d6a96a4b24 net: l2: ppp: Don't attempt reestablish PPP if carrier is down
This commit adds a check to prevent attempting to reestablish
the PPP session if the carrier is down. Without this check,
the PPP FSM attempts and fails to establish a PPP session
twice before giving up. The behavior is not breaking anything,
but it is not desired.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-30 18:47:33 +02:00
Peter Mitsis
2f003e59e4 kernel: Re-factor k_mem_slab definition
Rearranges the k_mem_slab fields so that information that describes
how much of the memory slab is used is co-located. This will allow
easier of its statistics into the object core statistics reporting
framework.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-30 08:04:14 +03:00
Tom Burdick
41e0a4a371 llext: Linkable loadable extensions
Adds the linkable loadable extensions (llext) subsystem which provides
functionality for reading, parsing, and linking ELF encoded executable
code into a managed extension to the running elf base image.

A loader interface, and default buffer loader implementation,
make available to the llext subsystem the elf data. A simple management
API provide the ability to load and unload extensions as needed. A shell
interface for extension loading and unloading makes it easy to try.

Adds initial support for armv7 thumb built elfs with very specific
compiler flags.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Co-authored-by: Chen Peng1 <peng1.chen@intel.com>
Co-authored-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-09-29 20:50:38 -04:00
Robert Lubos
51d3341066 net: icmp: Don't unref net_pkt from the registered handler
A minor overlook from the recent ICMP rework, the registered handlers
should no longer unref the processed packet as it's now the
responsibility of the ICMP module.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-29 18:49:43 +03:00
Emil Gydesen
f5dd62bbec Bluetooth: Audio: Update codec_cfg_get_chan_allocation
Update the function name from codec_cfg_get_chan_allocation_val
to just codec_cfg_get_chan_allocation, and add
codec_cfg_set_chan_allocation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 16:29:58 +02:00
Najumon B.A
c5094776e9 sd: add check for maximum supported voltage by host controller
add check for maximum voltage supported by hc before apply card voltage.

Signed-off-by: Najumon B.A <najumon.ba@intel.com>
2023-09-29 16:29:00 +02:00
Florian Grandel
60ad26403b net: l2: ieee802154: only log fully assembled pkts
As we already log fragmented packets there's no need to log them again
unless they have been fully assembled and the result is to be logged.

We also want to log the final packet in all cases (after mangling LL
address) for the non-fragmented case.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:31 +02:00
Florian Grandel
a5d46e7d66 net: l2: ieee802154: mgmt: NET_CONTINUE unless pkt is unrefed
It is the general rule in Zephyr's network stack that methods that
return NET_OK are expected to have "consumed" the packet, i.e. it should
not be referenced any more.

This change applies this rule to the methods in ieee802154_mgmt.* for
improved consistency with the remainder of the network stack.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:31 +02:00
Florian Grandel
203391a378 net: l2: ieee802154: security config
The "encryption only" security level was deprecated in IEEE
802.15.4-2015. This deprecation has already been introduced in the code
but was overlooked in net config.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:31 +02:00
Florian Grandel
36402b6d2a net: pkt: time: introduce ns timestamp helper
A little refactoring that simplifies dealing with nanosecond timestamp
values in packets and further decouples calling code from PTP:

Benefits:
- simplifies calling code by removing redundant conversions.
- prepares for removing PTP dependencies from net_pkt.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:15 +02:00
David Corbeil
8a25b039e4 logging: net: changing syslog server address while running bug
Fixed bug where changing the syslog network server's address while it's
still running would fail most of the time

Signed-off-by: David Corbeil <david.corbeil@dynon.com>
2023-09-29 16:27:04 +02:00
Alperen Şener
05e806d31d bluetooth: mesh: check upload slot before release
Check if the slot is not reseved, NULL before try to
releas it.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-09-29 16:26:42 +02:00
Rahul Singh
6ef75a26ea net: zperf: Add support for bind to host option for tcp/udp download
The current zperf tcp/udp download command doesn't provide the option
to bind the server to a specific host address. If there is more than
one interface, it will not be possible to test each interface with zperf
tcp/udp download command without building the Zpehyr.

This patch will add support for zperf tcp/udp download command to bind
server to host interface address.

Signed-off-by: Rahul Singh <rahul.singh@arm.com>
2023-09-29 16:25:26 +02:00
Emil Gydesen
c8a79e1fc1 Bluetooth: Audio: Add codec_cfg_set_frame_blocks_per_sdu
Add the bt_audio_codec_cfg_set_frame_blocks_per_sdu function
to set or add the frame blocks per SDU field in the
codec configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 16:25:17 +02:00
Juha Heiskanen
647fb4dc8f net: lwm2m: RD client Deregister event indicate
Added a new event for LWM2M_RD_CLIENT_EVENT_DEREGISTER for
indicate LwM2M client dereistartion.

Updated unit test and sample for new event type

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-09-29 16:53:55 +03:00
Alberto Escolar Piedras
2243d7b717 Bluetooth controller nrf: Provide radio hal header for simulated nrf5340
Provide a radio HAL header for the new nrf53 bsim target

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-29 16:21:43 +03:00
Alberto Escolar Piedras
48f70eba2b Bluetooth: Controller: Fix clang warning on ull
Fix a clang warning
ull.c:1235: warning: use of bitwise '|' with boolean operands

The result of ({1/0} &&(int)) is either true(1) or false(0),
not the int and therefore bm is not a bitmask, but just true(1)
or false(0) all together.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-29 15:07:34 +02:00
Vinayak Kariappa Chettimada
303ce143c2 Bluetooth: Controller: Fix regression in Adv PDU overflow calculation
Fix regression in Adv PDU payload length overflow
calculation.

Regression in commit de8c19da5e ("Bluetooth: controller:
Handle fragmented AD without chaining PDUs").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-29 15:41:14 +03:00
Henrik Lindblom
01757cfd32 modbus: add support for defining custom functions
Enables support for custom function codes. Modbus specification allows
vendor specific function codes in the range 65-72 & 100-110 [1] and this
feature allows users to implement custom logic for those codes.
Additionally, since the Zephyr Modbus stack doesn't implement all defined
Modbus fcs this feature allows users to add support for codes outside the
basic register reading / writing functionality offered by Zephyr.

Custom function codes can be added on a per-interface basis and the handler
structures are allocated by the caller.

[1]: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf

Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
2023-09-29 13:05:42 +02:00
Jukka Rissanen
6661f05daf net: ppp: Mark the PPP L2 as non-experimental
The experimental status of the PPP L2 is long overdue so
it can be removed as the component is working fine.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-29 10:33:50 +02:00
Krzysztof Chruściński
6b7c8ae1b3 logging: log_output: Minor code cleanup
Z_LOG_EVAL was used in place where COND_CODE_1 was a much
better fit. Z_LOG_EVAL gave the same result but it was not
intended to be used here.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-09-29 09:48:57 +02:00
Armin Brauns
9727f61371 logging: return actual filter level when runtime filter is disabled
log_filter_set() is defined to return the actual level that was set by the
call. In case runtime filtering is disabled, this is always the compiled-in
log level, not the level passed by the user.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-09-29 09:48:49 +02:00
Emil Gydesen
5656c23243 Bluetooth: Audio: Add codec_cfg_set_octets_per_frame
Add the bt_audio_codec_cfg_set_octets_per_frame function
to set or add the octets per frame field in the
codec configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 09:46:58 +02:00
Emil Gydesen
8ab3fbf570 Bluetooth: Audio: Split bt_audio_codec_meta_get to cfg and cap
Split the bt_audio_codec_meta_get functions to cfg and cap
variants. This provides a more explicit API where users
do not need to dereference their cfg/cap structs in order
to use this functions.

Furthermore this will also make the get functions more
similar to the upcoming set functions, where the set functions
will require the use of the cfg and cap structs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 09:46:15 +02:00
Armin Brauns
4c8866243d bluetooth: disable BT_ATT_ENFORCE_FLOW for BlueNRG devices
The firmware on these devices seems to have a bug that can cause reordering
of received packets. This can lead to new GATT requests being received
before the acknowledgement of the previous GATT response, accompanied by
log messages like the following:

<wrn> bt_att: bt_att_recv: Ignoring unexpected request

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-09-29 09:45:48 +02:00
Daniel Leung
d47b1c05f3 kernel: userspace: add k_object_is_valid()
This adds a function k_object_is_valid() to check if a kernel
object exists, of certain type, and has been initialized.
This replaces the same (or very similar) code that has been
copied from kernel into the network subsystem.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-09-28 17:28:43 -04:00
Dominik Ermel
e48354455a mgmt/MCUmgr/grp/os: Add booloader info support
Adds command allowing to query information on bootloader.
In this case support is provided to query MCUboot information.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-28 16:27:45 +02:00
Daniel Leung
0a50ff366e kernel: rename z_current_get() to k_sched_current_thread_query()
The original idea of z_current_get() was to be the counterpart
of k_current_get() when thread local variable for current has
not been initialized if TLS is enabled, otherwise they are
the same function. Now since z_current_get() is being used
outside of core kernel, rename it under kernel namespace so
other subsystem can conceptually use them too.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-09-28 16:15:46 +02:00
Jordan Yates
2b92598df1 net: wifi: re-add WIFI_MGMT_FORCED_PASSIVE_SCAN
Re-add the `WIFI_MGMT_FORCED_PASSIVE_SCAN` option removed in #62751.
Now that `struct wifi_scan_params` is a reasonable size, we can enforce
the passive scan request even when no parameter struct is supplied by
the user.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-28 15:44:01 +02:00
Jordan Yates
3b7237e6cd net: wifi: shell: update SSID argument format
Instead of providing a comma seperated list of SSIDs, provide the SSIDs
individually. This substantially simplifies the implementation.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-28 15:44:01 +02:00
Juha Ylinen
3ffa1d5550 net: coap: Fix coap client timeout
Fix bug in timeout_expired() function. Coap client was resending
pending messages after 500 ms (COAP_PERIODIC_TIMEOUT) and didn't
wait for retransmission timeout.

Use 64-bit k_uptime_get()

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-09-28 15:18:12 +02:00
Florian Grandel
bd038fc743 doc: ieee802154: l2: improved docs
Hides types used in the IEEE 802.15.4 L2 sub-API and L2-internal APIs
that are of no public interest and improves documentation of the
remainder.

The changes are mostly minor as the API documentation had already been
improved and clarified in previous changes. Also includes non-visible
documentation to the subsystem-internal Frame API by adding references
to the specification.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-28 15:13:12 +02:00
Georges Oates_Larsen
98a506f341 net: conn_mgr: Write documentation
Write documentation for conn_mgr and its subsystems, especially
guidelines for writing connectivity implementations

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-09-28 15:11:14 +02:00
Emil Gydesen
85bb2624bc Bluetooth: Audio: Refactor codec_cfg_get_freq
Refactor the codec_cfg_get_freq function to return the assigned
numbers value, instead of a converted value, but with
support for converting the value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 14:05:18 +02:00
Erik Brockhoff
1de8a76f58 Bluetooth: controller: adding API for unmasking peer features
For asymetrical features there needs to be a separate mechanism to
unmask features in peer. This must be used in central for unmasking in case
of 'unsupported in peer' condition for CIS Create.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-09-28 14:05:00 +02:00
Erik Brockhoff
730f7caa21 Bluetooth: controller: add missing NTF alloc in central CIS Create
If a CIS create is requested prior to having a complete feature exchange
the central will initiate a feat exch before enqueing the CIS create.
IF then the feature exchange results in peripheral NOT supporting
CIS create the central needs to allocate an RX node for the NTF

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-09-28 14:05:00 +02:00
Yonatan Schachter
5508b17fb4 bindesc: Add initial support for binary descriptor definition
Binary descriptors are data objects stored at a known location
of a binary image. They can be read by an external tool or image,
and are used mostly for build information: version, build time,
host information, etc.
This commit adds initial support for defining such descriptors.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2023-09-28 07:39:09 -04:00
Vinayak Kariappa Chettimada
28ed48cbac Bluetooth: Controller: Fix connected ISO dynamic tx power
Fix connected ISO dynamic tx power support compilation
error.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-28 13:31:40 +02:00
Jonathan Rico
c1baa8282d tests: Bluetooth: Add ATT sequential procedures test
The purpose of this test is to prove that the zephyr host can handle the
behavior described in the Bluetooth Core Specification Vol.3 Part.F
3.3.2 "Sequential protocol".

The host should be able to handle all of those in parallel: one
indication, one write request, multiple commands and multiple
notifications.

The "tester" part had to be written with a "tiny host" implementation
instead of the Zephyr host, as the ZH conflates GATT client and server
and doesn't allow a device to enqueue an ATT request + an ATT indication
on the same bearer.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-28 14:21:27 +03:00
Jonathan Rico
7093538c42 Bluetooth: att: don't re-use the ATT buffer for confirmations
If the peer is a zephyr host, there is no problem, as the Zephyr
host limits sending parallel REQs and INDs.

But the spec allows sending those in parallel, and it may end up that
the re-used REQ buffer hasn't been destroyed when an indication comes.

Only re-use the buffer when enqueuing ATT responses.

This means that we may run out of buffers if the peer sends too many
indications and our application also sends a lot of commands/notifications.

The rationale for this is that having to handle a lot of requests is a
more plausible scenario (e.g. being discovered by multiple peers) than
handling lots of parallel indications.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-28 14:21:27 +03:00
Vinayak Kariappa Chettimada
3bfeadfa4a Bluetooth: Controller: Fix ULL_HIGH ticker operations count
Fix ULL_HIGH ticker operations count, it is discovered in
new BabbleSim test implementations that mesh tests using
Extended Advertising and Scanning enqueue upto 4 ticker
operations before ULL_LOW ticker_job could process it.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-28 13:21:05 +02:00
Piotr Narajowski
54126ec4e5 bluetooth: audio: Add API to get VCP service ATT handles
This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2023-09-28 13:16:23 +02:00
Emil Gydesen
cbf7312e37 Bluetooth: Controller: ISO: Fix compile issue with unicast
There was a case where TICKER_ID_ADV_AUX_BASE was not available
but was attempted to be used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 13:12:19 +02:00
Emil Gydesen
c2328a7bc3 Bluetooth: ISO: Fix issue with bt_iso_cig_reconfigure
bt_iso_cig_reconfigure would almost always fail due to invalid
checks that did not take the functioner properly into account.

The CIS provided to bt_iso_cig_reconfigure can now be allocated
beforehand, if the CIG for the CIS is the same as the one being
reconfigured.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 13:12:19 +02:00
Kapil Bhatt
29bbcb1e38 net: wifi: Move function from shell to mgmt
The CONFIG_NET_L2_WIFI_SHELL isn't always enabled.
But these functions might still be used, so need to
move functions into mgmt.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2023-09-28 12:30:29 +02:00
Anas Nashif
6d23a960db lib: os: build fdtable conditionally
Stop building fdtable by default, make it conditional and build it only
when needed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-28 06:25:16 -04:00
Pieter De Gendt
cf8f92d73e net: lib: mdns_responder: Fallback IPv4/IPv6 address
If an IPv4 address is requested on an IPv6 interface or vice versa
use a sane default fallback address to send the response.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-09-28 10:53:53 +03:00
Vinayak Kariappa Chettimada
1b0cb324f3 Bluetooth: Controller: nRF53: Fix back-to-back PDU chaining
Fix back-to-back PDU chaining using DPPI on nRF53x SoC.
Relates to commit b61bd2364c ("Bluetooth: Controller:
nrf53: Fix back-to-back Tx Rx implementation").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-28 09:35:33 +02:00
Jukka Rissanen
fa4e978fba net: zperf: Fix the IPv6 ping done in shell
The zperf shell sends a IPv6 ping at the start when working
with IPv6. Convert the sending of the ping to use the new API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen
3baaa72920 net: icmp: Add offloading support
Add suitable functions that offloaded network device driver
can receive ICMP Echo-Request (ping) requests and give
ICMP responses back when it receives them from the network.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen
c473626267 net: if: Add function for network interface offloading status
Add new net_if_is_offloaded(iface) that returns true if
the network interface is offloaded (either IP or socket
offloading is enabled for that interface) and false if
the interface is not offloaded.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen
e3fb634e7a net: shell: Use the ICMP API for ping command
Change the ping command to use the ICMP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen
19273087f2 net: Use the ICMP API for receiving ICMP messages
Modify the internal network stack code to use the ICMP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen
31a25da8c2 net: icmp: Introduce new API to send ICMP messages
Allow user to send ICMP Echo Request message a.k.a pings.
The same ICMP API and framework is used for network stack
internal needs in later commits. One benefit for this new
API is that it allows sending Echo Requests to offlined
network devices.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jakub Rzeszutko
c631bc7757 shell: modules: kernel: add human readable uptime
Added options: -p and --pretty to the kernel updtime command.

Fixes: #62543

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2023-09-28 09:34:00 +02:00
Robert Lubos
6fb19bc7f0 net: shell: Add DHCPv6 support
Print DHCPv6 status in net shell (with "net iface" command).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 09:31:20 +02:00
Robert Lubos
72cf06ada4 net: config: Add DHCPv6 support
Add DHCPv6 support to the net config library. In case DHCPv6 is enabled,
net config will attempt to acquire IPv6 address and/or prefix when used.
The user can select with Kconfig whether to request address or prefix
(or both).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 09:31:20 +02:00
Robert Lubos
afa5887b70 net: dhcpv6: Introduce net events for DHCPv6
Add net events for DHCPv6, in similar fashion as it's done for
DHCPv4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 09:31:20 +02:00
Robert Lubos
e73e78a550 net: dhcpv6: Add Zephyr DHCPv6 client
Add a DHCPv6 client implementation for Zephyr (RFC 8415).

The implementation allows to request IPv6 address and/or prefix from the
DHCPv6 server, and for now supports only the mandatory set of DHCPv6
options needed to achieve this. Currently the implementation supports
the following scenarios:
 * Requesting new IPv6 address/prefix with Solicit/Request exchange
 * Refreshing existing leases with Confirm, Renew or Rebind (depending
   on the context).

For now, no Information Request (the case where neither IPv6 address or
prefix are requested) is supported. No support for Reconfigure was added
either, as this is optional (the client manifests clearly to the server
that it does not support Reconfigure). Support for these can be added
later if needed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 09:31:20 +02:00
Théo Battrel
c2b99c0123 Revert "Bluetooth: Host: Fix GATT server handling of CCC"
This reverts commit cfd368fef1.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-09-28 09:21:57 +02:00
Jamie McCrae
db4febc584 retention: Add bootloader configuration interface
Adds a bootloader configuration interface which allows for a
bootloader (e.g. MCUboot) to set configuration in a shared data
area which is then read by the application.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-27 20:18:31 -04:00
Rodrigo Peixoto
0b0aa435af zbus: Add Message subscriber
Besides the changed channel reference, the message subscribers receive a
copy of the message during the VDED execution. ZBus guarantees message
delivery for `MSG_SUBSCRIBERS`.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2023-09-27 20:03:43 +03:00
Flavio Ceolin
5d505c7b28 random: Fix feature dependency usage
Code using sys_csrand_get should depend on CONFIG_CSPRNG_ENABLED symbol
and not in ENTROPY_HAS_DRIVER since they are not using the entropy
device directly.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-09-27 11:55:10 -05:00
Flavio Ceolin
646a06c9fe random: Fix kconfig symbol name
s/CSPRING_ENABLED/CSPRNG_ENABLED/g

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-09-27 11:55:10 -05:00
Flavio Ceolin
23106b81c8 random: Remove deprecated Kconfig symbol
XOROSHIRO_RANDOM_GENERATOR has been deprecated in
Zephyr 1.12 (???), time to remove it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-09-27 11:55:10 -05:00
Flavio Ceolin
37be80ddbe random: ctr_drbg: Thread safe in SMP
irq_lock() does not make this this csprng api thread safe
in SMP systems. Change it to use a mutex.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-09-27 11:55:10 -05:00
Flavio Ceolin
eba567cf18 random: ctr_drbg: Remove unused variable
state_sem was statically defined but never used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-09-27 11:55:10 -05:00
Florian Grandel
a12a6ab5b9 drivers: ieee802154: introduce channel pages
Replaces the previous approach to define bands via hardware capabilities
by the standard conforming concept of channel pages.

In the short term this allows us to correctly calculate the PHY specific
symbol rate and several parameters that directly depend from the symbol
rate and were previously not being correctly calculated for some of the
drivers whose channel pages could not be represented previously:
* We now support sub-nanosecond precision symbol rates for UWB. Rounding
  errors are being minimized by switching from a divide-then-multiply
  approach to a multiply-then-divide approach.
* UWB HRP: symbol rate depends on channel page specific preamble symbol
  rate which again requires the pulse repetition value to be known
* Several MAC timings are being corrected based on the now correctly
  calculated symbol rates, namely aTurnaroundTime, aUnitBackoffPeriod,
  aBaseSuperframeDuration.

In the long term, this change unlocks such highly promising functional
areas as UWB ranging and SUN-PHY channel hopping in the SubG area (plus
of course any other PHY specific feature).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-27 12:44:15 -04:00
Théo Battrel
545f17b722 Bluetooth: Host: Fix SYS_SLIST_FOR_EACH_NODE_SAFE misuse
In `gatt_write_ccc_rsp`, the third field of
`SYS_SLIST_FOR_EACH_NODE_SAFE` was use as the `prev` sys_node when
calling `gatt_sub_remove`. This was wrong because the third field of
`SYS_SLIST_FOR_EACH_NODE_SAFE` is actually the next node.

Fix the issue by adding a pointer to the previous node and passing it to
`gatt_sub_remove`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-09-27 15:48:49 +02:00
Vinayak Kariappa Chettimada
7af967a2f5 Bluetooth: Controller: Fix BIS payload sliding window overrun check
Fix BIS implementation for checking overrun of the BIS PDU
sliding window buffer overrun.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 15:48:38 +02:00
Dominik Ermel
dfccc473a6 Bluetooth: Host: Use memcpy instad of strncpy in bt_set_name
memcpy makes more sense here.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-27 15:48:25 +02:00
Aleksandr Khromykh
0e98a35e39 Bluetooth: Mesh: refactor mandatory oob for mesh1d1
Provisioner should be able to manage received capabilities
unconditionally. Mandatory oob authentication is the node
feature and it is still compile time feature.
Split handling of this feature on provisioner and node part.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-09-27 15:48:08 +02:00
Aleksandr Khromykh
236e3b64db Bluetooth: Mesh: shell supports 32 bytes static oob
Commit adds support of 32 bytes static oob in mesh shell.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-09-27 15:48:08 +02:00
Aleksandr Khromykh
707d1ed819 Bluetooth: Mesh: fix static oob setting
According to specification it is possible to provide
static oob value with any length. Mesh should trim or
append\prepend by zeroes if it is longer\shorter than
required value.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-09-27 15:48:08 +02:00
Vinayak Kariappa Chettimada
3c2b1f952c Bluetooth: Controller: Add BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX Kconfig
Add BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX Kconfig to allow the
omit of EVENT_OVERHEAD_START_US and EVENT_OVERHEAD_END_US in
the time reservation calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 15:47:45 +02:00
Vinayak Kariappa Chettimada
1ab007a2ba Bluetooth: Controller: Fix compile error when BT_CTLR_CENTRAL_SPACING=n
Fix compile error when CONFIG_BT_CTLR_CENTRAL_SPACING is
undefined.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 15:47:45 +02:00
Fredrik Danebjer
c2a13a0bec Bluetooth: Audio: Make CSIP delete bonds in cache locally
This change from using the mechanic of CONFIG_BT_KEYS_OVERWRITE_OLDEST
to instead handle the bonding cache through bond_deleted.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-09-27 15:47:33 +02:00
Fredrik Danebjer
078b00b155 Bluetooth: Audio: Add resend mechanic to CSIP notifications
Added retry mechanic to CSIP notifications by adding them into system
workqueue. Bookkeeping is done for notifications for all clients, and
potentially disconncted clients will also receive notifications on
reconnect. This also adds mechanic to restore the local clients list
upon registration of the service, as well as BSIMs to test notify on
reconnect.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-09-27 15:47:33 +02:00
Fredrik Danebjer
147796b36f Bluetooth: Audio: Change CSIP notification to use Atomic flags
Reformated csip_set_member to use atomic flags for notifications
instead of a pending notification array. This better conforms the
style of the code to how its done in other LE Audio services.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-09-27 15:47:33 +02:00
Seppo Takalo
a8f9777586 net: lwm2m: Generate new tokens for LwM2M SEND blocks
Previously each piece of LwM2M SEND was
using token length of zero. I think this was unintentional.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo
1606d352e1 net: lwm2m: Append CoAP Etag to protect integrity of blockwise
To protect the integrity of outgoing block-wise transfers, append
Etag option that allows client to see if the received block is
generated from same content as it is expecting.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo
ebb90c5184 net: lwm2m: Fix composite read on SenML-CBOR
Composite read was incorrectly trying to parse CoAP packet
instead of payload of the packet.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo
69cd597887 net: lwm2m: Refactor blockwise SEND to support GET and FETCH
Allow blockwise-send buffers to be used with GET and FETCH
queries as well.
When outgoing packet is split into multiple blocks, don't free
it when first block is send. Keep it in memory until some other requests
come.

Following queries to next block are matched using CoAP token.
However, this required Leshan to use COAP.BLOCKWISE_REUSE_TOKEN=true
option from Californium.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo
b9028bb722 net: lwm2m: Remove unneeded function pointer parameter
lwm2m_udp_receive() is only called with same function
pointer, so there no need to carry that in the parameter.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo
4e97607c27 net: lwm2m: Only parse block1 option for WRITE operation
In reality, single-write is the only operation that handles
BLOCK1 operations when receiving paylod.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo
f227b56792 net: lwm2m: Separate opaque content format into its own
Opaque content format is not part of clear-text, so it
should be separated into its own file.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo
42ce4bbfd7 net: lwm2m: Allow content formats to support only some data types
Partial content format support is required to have a proper support
for content format OPAQUE instead of threading it as a part of
plain text format.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Vinayak Kariappa Chettimada
b61bd2364c Bluetooth: Controller: nrf53: Fix back-to-back Tx Rx implementation
Back-to-back Tx Rx implementation was incorrect for nRF53
that uses DPPI. Both current and next DPPI channels where
enabled in the implementation which only worked correctly
to have the right tIFS when current and next PDU length
were same.

Fix ensures that the correct current DPPI is subscribed
to by the radio subscribe.

The implementation has been refactor to be able to use the
current sw_tifs_toggle value in the HAL implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 09:52:53 +02:00
Vinayak Kariappa Chettimada
e39d98302d Bluetooth: Controller: nRF53: Cleanup dppi and dppi resources file
Minor cleanup typo, redundant conditional compile and
refinition.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 09:52:53 +02:00
David Corbeil
d732a8678b logging: runtime setting of syslog server ip address
Added functionality to change the syslog server's
ip address at runtime as well as sample for
syslog network backend

Signed-off-by: David Corbeil <david.corbeil@dynon.com>
2023-09-27 09:13:23 +02:00
Joshua Lilly
f51575212b testsuite: coverage: extend code coverage to include risc-v
This PR adds regions for gcov symbols in bss to enable gcov
functionality for risc-v

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-09-26 23:32:45 -04:00
Seppo Takalo
ebfbf83153 net: lwm2m: Clean up shell documentation
Move commands that require parameters first into the list.

Move syntax line first, command documentation second,
flags last. This is much like Unix commands do

❯ /bin/ls --help
Usage: /bin/ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).

Compared to:

uart:~$ lwm2m
lwm2m - LwM2M commands
Subcommands:
  read    :read PATH [OPTIONS]
          Read value from LwM2M resource
          -x   Read value as hex stream (default)
          -s   Read value as string

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-26 16:55:16 +02:00
Vinayak Kariappa Chettimada
652544e396 Bluetooth: Controller: Fix CIS assymmetric PHY usage
Fix CIS assymmetric PHY usage by adding implementation to
use correct PHY in radio when switching transceiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-26 17:45:18 +03:00
Vinayak Kariappa Chettimada
9e01c4df53 Bluetooth: Controller: nRF53: Fix missing NRF_CCM subscribe clear
Fix missing NRF_CCM subscribe clear which can lead to
spurious trigger of TASK_CRYPT in NRF_CCM. This may
lead to corruption of Rx PDU buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-26 15:09:31 +02:00
Vinayak Kariappa Chettimada
ed5883d9a0 Bluetooth: Controller: Use unique goto label in scan aux code
Use unique goto label in scan aux connect response ISR.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-26 15:08:07 +02:00
Jukka Rissanen
0e5016e502 net: arp: Directly send the queued pkt
We must send the packet without queueing it. The pkt has already
been queued for sending, once by net_if and second time in the ARP
queue. We must not queue it twice in net_if so that the statistics
of the pkt are not counted twice and the packet filter callbacks
are only called once.

Fixes #62483

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-26 15:07:20 +02:00
Dominik Ermel
f3067f2364 mgmt/MCUmgr/grp/img: Add support for DirectXIP with revert
The commit adds support for uploading image to board with MCUboot
configured with DirectXIP with revert.
It allows to set uploaded image either for test or as permanent
boot application, until newer image gets confirmed.
Note that in DirectXIP with revert MCUboot will remove image
that has not been set for test nor confirmed and MCUmgr does not
set either mode unless image has the mode set within uploaded
binary.
The commit adds Kconfig option
CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT
that enabled the new mode of operation within MCUmgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-26 13:40:11 +02:00
Pieter De Gendt
cb4fb765f0 net: if: Add ASSERT in net_if_ipv4/6_select_src_addr
Add an assert for the destination address provided to find the best
source address.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-09-26 12:04:03 +02:00
Alberto Escolar Piedras
292ca93795 Bluetooth controller nrf: nrf52 bsim radio hal fix
hal_radio_tx_chain_delay_ns_get() was incorrectly
returning the microsecond value, resulting in a 1us
error in the timing => Fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:43 +02:00
Alberto Escolar Piedras
865f3c1614 Bluetooth controller nrf: nrf52 bsim radio hal header minor updates
Align the header a bit with the one for the real radio,
adding missing Tx power levels and removing TODO which did not
need doing.
The old one originated as a copy of the nrf52833 one, and did not
evolve like the real ones.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:43 +02:00
Alberto Escolar Piedras
07bb88d28a Bluetooth: Controller: nrf: HAL for DPPI configuration cleanup
Remove a few macros which are not used anywhere in the tree.
For the sake of simplifying the header and easing its understanding.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:31 +02:00
Alberto Escolar Piedras
c5191ba5b7 Bluetooth: Controller: nrf: Use HAL for DPPI configuration
The following changes have been done:
1.
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_TASK(index)
  = HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_TASK(channel)
has been convered into
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_TASK(index, channel)

2.
HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_TASK(index)
  = HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_TASK
Which was only used in one place, has been replaced with the
equivalent HAL call

3.
HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_TASK(index) = 0
was replaced with the HAL subscribe clear function
nrf_dppi_subscribe_clear(NRF_DPPIC,
   HAL_SW_DPPI_TASK_EN_FROM_IDX(SW_SWITCH_TIMER_TASK_GROUP(index)));

4.
NRF_DPPIC->SUBSCRIBE_CHG[group].EN/DIS = 0;
have been replaced with the equivalent HAL clear call

5.
NRF_DPPIC->TASKS_CHG[group].DIS = 1;
have been replaced with the equivalent hal task_trigger() call

6.
Manually setting the CHG registers, has been replaced with a
clear + add (because the hal does not have a set function yet)
So,
  NRF_DPPIC->CHG[group] = value
has been replaced with
  nrf_dppi_group_clear(NRF_DPPIC, group);
  nrf_dppi_channels_include_in_group(NRF_DPPIC, value, group);
(A set function has been requested from the HAL team)

Note: There is other direct registes writes to the dppi subscribe and CHG
registers in the coded phy parts which have not been changed yet.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:31 +02:00
Jonathan Rico
480e228a50 Bluetooth: host: document settings backend requirement
This requirement was implicit as the only backend the host is currently
tested with behaves this way.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-26 08:39:09 +02:00
Vinayak Kariappa Chettimada
8c9ac505db Bluetooth: Controller: nRF53: Fix sw switch single timer id regression
Fix regression in sw switch single timer id use for nRF53x
series SoC.

Regression introduced in commit cfcbe5d68e ("Bluetooth:
Controller: Remove redudant header file includes").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 19:47:10 +02:00
Jordan Yates
ca5931065c testsuite: boards: unit_testing: default HCI bus
Be explicit about the HCI backend that Bluetooth unit tests require.
Some unit tests depend on `BT_HAS_HCI_VS`, so also enable that.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 16:43:42 +02:00
Alberto Escolar Piedras
bae0dace16 Bluetooth controller nrf: Rename bsim radio hal header
Rename the bsim header in preparation for having more
simulated targets.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-25 16:42:45 +02:00
Alberto Escolar Piedras
f1557804a9 Bluetooth controller nrf: ifdef some coded phy only code
To avoid a build error when coded phy is not enabled
for a nrf53: These three functions are only used for coded phy,
and depend on macros which are only defined if coded phy
is enabled.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-25 16:42:45 +02:00
Alberto Escolar Piedras
bab4ed1623 Bluetooth controller: nrf: Switch to use SOC_COMPATIBLE
Switch use of kconfig:
* SOC_SERIES_NRF53X -> SOC_COPATIBLE_NRF53X
* SOC_NRF5340_CPUNET -> SOC_COMPATIBLE_NRF5340_CPUNET
to also select those options/code when building for
the nrf53 simulated targets.

Also switch three kconfig range dependencies from
SOC_SERIES_NRF52X to SOC_COPATIBLE_NRF52X
(IRQ priority related) for consistency. These sound
not really have an impact.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-25 16:42:45 +02:00
Vinayak Kariappa Chettimada
94bd4837bb Bluetooth: Controller: Fix missing host feature reset
Fix missing host feature reset on HCI reset command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 16:42:20 +02:00
Vinayak Kariappa Chettimada
cb28104cb0 Bluetooth: Controller: Fix assertion due to late PER CIS active set
Fix assertion due to late Peripheral CIS active flag being
initialized. CIS active flag shall be initialized when it is
acquired.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 16:42:20 +02:00
Vinayak Kariappa Chettimada
e4cc5838fd Bluetooth: Controller: Fix PHY value in HCI LE CIS Established Event
Fix PHY_C_TO_P and PHY_P_TO_C value in HCI LE CIS
Established Event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 16:42:20 +02:00
Jukka Rissanen
37b8dc17bc net: socket: Allow same port if different address family
It is always possible to bind to same port if the sockets
are in different address family.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-25 10:53:49 +02:00
Emil Gydesen
e51ac69156 Bluetooth: Audio: Add bt_audio_codec_cap_get helper functions
Add helper function to get specific values from
a codec capability struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-25 09:48:47 +02:00
Jordan Yates
b54951b86e net: wifi_mgmt: linearise scan_params->chan arrays
Turn the nested arrays of `scan_params->chan` into a single array.
This adds the requirement to specify the band for each channel, but
eliminates the large amount of dead memory for unused bands. Overall,
this saves 50% of the RAM space for this variable.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 09:48:16 +02:00
Jordan Yates
6a428f19b6 net: wifi_mgmt: make number of scan channels configurable
Make the maximum number of channels that can be manually scanned
configurable by the application. The previous value of 233 was vastly
overallocating memory as the largest band only contains 60 allocated
channels.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 09:48:16 +02:00
Dominik Ermel
ea6129cd7c mgmt/MCUmgr/grp/img: Add support for three image configuration
The commit adds support for uploading images to secondary slots
of three images.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-22 15:13:31 +02:00
Daniel Stuart
9a193ac1c3 settings: shell: Add value type and allow for strings to be used
This can be further extended to support other data types.

Signed-off-by: Daniel Stuart <daniel.stuart@localiza.com>
2023-09-22 14:02:02 +02:00
Pavel Vasilyev
6267259f91 Bluetooth: Mesh: Use decimals instead of hex nums in DFD shell cmds
JSON doesn't support hexdecimals as numbers.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-22 09:30:07 +02:00
Pavel Vasilyev
ac050455c5 Bluetooth: Mesh: Fix printing device UUID
IS_ENABLED was incorrectly used here.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-22 09:23:44 +02:00
Emil Gydesen
2147eefa15 Bluetooth: PACS: Remove CONFIG_BT_PACS_{SNK,SRC}_CONTEXT
The Kconfig option was never used by the stack and should
thus be removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-22 09:21:53 +02:00
Saw Xu
459f8e3251 usb: device: audio: Support volume control
Makes USB device audio class support volume control feature.

Signed-off-by: Saw Xu <Saw1993@126.com>
2023-09-21 15:04:14 +02:00
Marcin Gasiorek
c668fbc4d2 net: ip: Add cloning of missing attributes
A few attributes isn't cloned togerder with pkt.
This commit add missing part.
Additionally, because the `eof` flag in net_pkt structure is
avilable unconditionally hence `#if defined(CONFIG_NET_SOCKETS)`
guard has been removed form setter and getter functions for
this flag.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-09-21 13:36:20 +02:00
Marcin Gasiorek
6a536f9f8c net: Deprecated and unused flags cleanup.
In net_pkt structure couple of flags are no longer used.
Flag pkt_queued can be removed permanently togeter with setter
and getter functions.
Second flag sent_or_eof has been renamed because it is still
used partially only for indicating EOF. Additionally unused setter
and getter for 'sent_' part of this flag are removed.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-09-21 13:36:20 +02:00
Vinayak Kariappa Chettimada
3fba1a18e7 Bluetooth: Controller: Use max time when scheduling Broadcast ISO
Use maximum event time length when scheduling Broadcast ISO
events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Vinayak Kariappa Chettimada
0f2980db15 Bluetooth: Controller: Maximize BIG event length and preempt PTO & CTRL
Maximize BIG event length to extend upto ISO interval, and
allow PTO and Control subevents to be pre-emptible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Vinayak Kariappa Chettimada
87138e7ee3 Bluetooth: Controller: Calculate Broadcast ISO event overheads
Calculate Broadcast ISO event overheads due to extended and
periodic advertising events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Vinayak Kariappa Chettimada
5b4eb9bc76 Bluetooth: Controller: Minor rename ull_adv_sync_iso_created()
Minor rename to ull_adv_sync_iso_created().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Fabio Baltieri
6e78b435be Bluetooth: BAP: drop unused variable
stream_in_subgroup is set but never used here.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-21 12:44:08 +02:00
Jamie McCrae
0d5c508fc7 mgmt: mcumgr: grp: fs_mgmt: Update file upload errors
Updates possible return errors for fs mgmt file upload, to clarify
when a provided path is on a read-only filesystem or if the mount
point does not exist.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-21 11:54:26 +02:00
Martin Jäger
6b0135b151 canbus: isotp: rename ctx function parameters to rctx/sctx
This makes clear if the context is a recv_ctx or a send_ctx and
improves code readability.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-09-21 11:54:11 +02:00
Martin Jäger
b82a4478ad canbus: isotp: add _TIMEOUT_MS suffix to defines for timeouts
The defines like ISOTP_A were obfuscating that this is actually a
timeout value.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-09-21 11:54:11 +02:00
Martin Jäger
5fdc43270f canbus: isotp: improve internal function naming
Use prefixes to make naming more clear and improve code readability.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-09-21 11:54:11 +02:00
Seppo Takalo
0a982c3617 net: lwm2m: Add shell command to create object instances
Some testcases might need to be able to create
object instances, so add shell command for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-21 10:15:34 +02:00
Seppo Takalo
b0303f5bd3 net: lwm2m: Don't allow operations on security object
In spec:
The LwM2M Client MUST reject any LwM2M Server operation on
the Security Object (ID: 0) with an "4.01 Unauthorized" response
 code.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-21 09:29:16 +02:00
Seppo Takalo
d8d81a8075 net: lwm2m: Fix build warning on access-control object
With bootstrap one function is unused. Fix by changing
ifdef to if (IS_ENABLED()) so linker can drop it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-21 09:29:05 +02:00
Dawid Niedzwiecki
340ffe1c48 mgmt: ec_host_cmd: fix struct init order
Order structure members according to the structure definition.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-09-21 09:28:59 +02:00
Dawid Niedzwiecki
fa4086875d mgmt: ec_host_cmd: fix checking number of backends
If autoinit is not enebled, it is allowed to build a few backends and
initialize a proper one in runtime.

Check number of backends only if autoinit is enabled.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-09-21 09:28:59 +02:00
Kapil Bhatt
4b9f5cc455 net: l2: wifi: Change arrays to functions
The header file contains mixture of functions and static arrays.
Replacing static arrays to functions.
Initialize functions in C file.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2023-09-21 09:28:46 +02:00
Vinayak Kariappa Chettimada
e8fe144f3a Bluetooth: Controller: Fix missing PHY_CODED cond compile
Fix missing Coded PHY implementation conditional compile
causing compile error when disabling Coded PHY support in
SoCs that have radio that support Coded PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
d8f0006de5 Bluetooth: Controller: Revert EVENT_OVERHEAD_START_US for Coded PHY
Revert EVENT_OVERHEAD_START_US value for Coded PHY support,
needed to pass LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-25-C.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
02b1c76820 Bluetooth: Controller: Reduce successive ticker_job() on Extended Scan
Reduce number of successive calls to ticker_job() by
disabling mayflies in the ULL_HIGH priority, enqueue
ticker_yield_abs() and ticker_start() before re-enabling
so that single ticker_job() handles both yield and start.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
c1042dff40 Bluetooth: Controller: Refactor prepare dequeue iteration code
Refactor/rename prepare dequeue iteration code and reuse it.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
7f388bb70a Bluetooth: Controller: Fix short prepare when many enqueued in pipeline
Fix short prepare handling when more than one event is
enqueued in the pipeline and the short prepare is placed at
the end of the prepare pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
377e2a1f48 Bluetooth: Controller: Fix ticks_slot_window use in Observer
Fix ticks_slot_window use in Observer, do not use for
unreserved continuous scanning, and do not use when scanning
on both 1M and Coded PHY simultaneously.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
67a2fc4293 Bluetooth: Controller: Use ticker_ticks_diff_get to check short prepare
Use ticker_ticks_diff_get consistently when calculating
difference between ticker ticks when determining short
prepare requests.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
dacadf2f1a Bluetooth: Controller: Use the state/role param in prepare pipeline
Use the state/role context parameter in prepare pipeline
to identify the preempt timeout that was setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
91781306e9 Revert "Bluetooth: Controller: Fix ull_prepare_dequeue for skipped events"
These change are reverted as part of fixing regression
failure in LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-25-C.

This reverts commit 0d54ca8761.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Emil Gydesen
f0cc8d4cb1 Bluetooth: CAP: Add support for long read/write
Add support for reading and writing long values (> MTU)
when using the CAP API.

This change does make it slightly slower to execute the
CAP procedures as it is now done on a one-by-one basis,
which affect multi-ACL setups, but that also means
that the buffer requirements for CAP will generally be lower.

There is still room for improvement as we can perform the BAP
operations in parallel on each ACl, which should return this to
its former performance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:24:27 +01:00
Emil Gydesen
5cc14b6c50 Bluetooth: Audio: Replace BT_AUDIO_CODEC_PARSE_ERR_ with errno
Replace the BT_AUDIO_CODEC_PARSE_ERR_ values with errno values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:22:24 +01:00
Jordan Yates
5452665beb net: l2: wifi_mgmt: remove scan kconfig defaults
Remove the wifi_mgmt interface overriding default values with values
from kconfig. The defaults were only applied when a `params` struct was
provided by the application.

This is the case when the application is explicitly setting the options
it wants, why is the mgmt API changing these. When `params` is NULL and
thus modem defaults are requested, these defaults aren't applied. This
is the opposite behaviour from what seems reasonable.

In addition, these options are:
 * Undocumented
 * Using non-trivial string parsing functions (strtok)
 * Adding complexity to the API implementation by forcing support for
   ROM versions of command line arguments.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-20 20:21:49 +01:00
Emil Gydesen
9693ae3021 Bluetooth: Audio: Add parsers for getting metadata values
Add parsers to retrieve metadata values from codec
capabilities and codec configuration structs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:21:24 +01:00
Emil Gydesen
8eecca2419 Bluetooth: BAP: Broadcast sink call stopped after BIG cleanup
Modify the order of operation in
broadcast_sink_iso_disconnected so that when the application
gets the last stopped callback, the BIG has already been cleaned
up, and the broadcast sink is in a reusable state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:21:16 +01:00
Emil Gydesen
c3c83c7049 Bluetooth: ASCS: Modify the ACL disconnect behavior
Instead of calling ase_release for each ASE in the ACL
disconnected callback, we now call the state_transition_work_handler
directly. This is to ensure that when the disconnected callback
returns, the bt_conn object has been properly unref'ed in
a timely manner.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:20:27 +01:00
Emil Gydesen
f93caa3903 Bluetooth: Audio: BT_AUDIO_CODEC_LC3_ID -> BT_HCI_CODING_FORMAT_LC3
Replace the BT_AUDIO_CODEC_LC3_ID macro with the
BT_HCI_CODING_FORMAT_LC3 as there is no reason to
define and use the LC3 ID different than the other
allowed codec IDs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:19:50 +01:00
Emil Gydesen
956a202ab8 Bluetooth: BAP: Add cc len check for BT_HCI_CODING_FORMAT_TRANSPARENT
When using BT_HCI_CODING_FORMAT_TRANSPARENT as the codec_id, the
codec configuration (cc) len sent to the controller shall be 0.

Since this goes for all devices, we ensure that we don't
send invalid codec ID and cc data over air.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:19:50 +01:00
Emil Gydesen
d327b1625c Bluetooth: BAP: Broadcast source reconfig with subgroups
Modify the bt_bap_broadcast_source_reconfig to use the same
parameter struct as bt_bap_broadcast_source_create so that
the two are more similar, since they both set the same values.

This allow for full control of which subgroups and stream
are updated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:16:52 +01:00
Michał Barnaś
9608c8f667 usbc: fix conflicting Kconfigs for USB-C related init priority
There was a new Kconfig for USB-C init priority that is conflicting
with currently used Kconfig for init of VBUS and TCPC.
This commit changes the names to more specific related to the subsystem
they belong to.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-09-20 11:26:40 +01:00
Lucas Dietrich
a59666754e lorawan: Add LORAWAN_PUBLIC_NETWORK configuration choice
Provides a toggle between public and private network selections.

Signed-off-by: Lucas Dietrich <lucas.dietrich@socomec.com>
2023-09-20 08:57:20 +02:00
Tobias Frauenschläger
dcc63120cf net: sockets: add support for SO_REUSEPORT
This commits adds support for the SO_REUSEPORT socket option.

The implementation follows the behavior of BSD and tries to also follow
the specific additional features of linux with the following
limitations:
* SO_REUSEADDR and SO_REUSEPORT are not "the same" for client sockets,
  as we do not have a trivial way so identify a socket as "client"
  during binding. To get the Linux behavior, one has to use SO_REUSEPORT
  with Zephyr
* No prevention of "port hijacking"
* No support for the load balancing stuff for incoming
  packets/connections

There is also a new Kconfig option to control this feature, which is
enabled by default if TCP or UDP is enabled.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-09-20 08:56:31 +02:00
Tobias Frauenschläger
3d3a221b1e net: sockets: add support for SO_REUSEADDR
This commit adds support for the SO_REUSEADDR option to be enabled for
a socket using setsockopt(). With this option, it is possible to bind
multiple sockets to the same local IP address / port combination, when
one of the IP address is unspecified (ANY_ADDR).

The implementation strictly follows the BSD implementation and tries to
follow the Linux implementation as close as possible. However, there is
one limitation: for client sockets, the Linux implementation of
SO_REUSEADDR behaves exactly like the one for SO_REUSEPORT and enables
multiple sockets to have exactly the same specific IP address / port
combination. This behavior is not possible with this implementation, as
there is no trivial way to identify a socket to be a client socket
during the bind() call. For this behavior, one has to use the
SO_REUSEPORT option in Zephyr.

There is also a new Kconfig to control this feature similar to other
socket options: CONFIG_NET_CONTEXT_REUSEADDR. This option is enabled by
default if TCP or UDP are enabled. However, it can still be disabled
explicitly.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-09-20 08:56:31 +02:00
Vinayak Kariappa Chettimada
879c611f58 Bluetooth: Controller: Fix LE Set Ext Adv Param Cmd invalid status
Fix HCI LE Set Extended Advertising Parameter Command
invalid status reason.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-19 15:26:32 +01:00
Vinayak Kariappa Chettimada
4cefcb6fc7 Bluetooth: Controller: Fix order of preempt timeout requested flag
Fix the order of setting the flag that indicates that
preempt timeout has been successfully requested versus
the request is waiting to be scheduled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-19 15:25:30 +01:00
Vinayak Kariappa Chettimada
f4e05e3e54 Bluetooth: Controller: Fix ticker to prefer ticker node started
Fix ticker implementation to prefer to keep ticker node
started in case of race condition to start and stop.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-19 15:25:21 +01:00
Konrad Derda
b3a3a8b3a2 net: ip: use default interface while matching LL src address
While matching source address for a given Link-Local destination the
functions iterate over interfaces and return a first result with a
valid LL-address. However, they should first try to fetch address of
the default interface as it not always the first one on the list.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-09-19 15:24:04 +01:00
Seppo Takalo
da1463756e net: lwm2m: Allow Bootstrap server to close DTLS connection
Allow Bootstrap server to close the DTLS connection immediately
after receiving Ack to Bootstrap-Finish command.
This is not an error as either parties are allowed to tear down
the connection.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-19 15:23:32 +01:00
Seppo Takalo
f49309cf52 net: lwm2m: Add timeouts to state machine
Allow certain RD-client states to timeout.

As stated in LwM2M specification:
    The bootstrap procedure failed when the LwM2M Client did not
    receive the "Bootstrap-Finish" operation after the
    EXCHANGE_LIFETIME time period expired.
    The EXCHANGE_LIFETIME parameter is defined in RFC 7252

We must handle the case where Bootstrap server is not sending
information towards us.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-19 15:23:14 +01:00
Emil Gydesen
9d62bef3ac Bluetooth: BAP: Broadcast source state checks for ID and BASE
Add state checks for the get_id and get_base functions, as the
ID and base are not valid when the state of the broadcast
source is BT_BAP_EP_STATE_IDLE.

Since the broadcast_source_get_state uses the slist functions,
the broadcast source object for bt_bap_broadcast_source_get_id
can no longer be `const`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-19 15:23:10 +01:00
Juha Heiskanen
0c6a3faeb4 mgmt: mcumgr: Image management client fix
Fix broken MCUmgr image group client.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-09-19 15:21:08 +01:00
Kuno Heltborg
2d02cae964 MGMT: Add user data to mgmt_handler
RFC: #60616

Signed-off-by: Kuno Heltborg <kunoh@live.dk>
2023-09-19 15:20:58 +01:00
Weiwei Guo
326d8c79fe net: mqtt-sn: Active mqtt-sn process work when buffer run out
When publish buffer run out, no thread active process work.
Fix this, by reschedule process work.

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-09-19 15:20:09 +01:00
Weiwei Guo
04bb819d20 net: mqtt-sn: Improve thread safety of publish/topic allocators
Current MQTT-SN topic and publish allocators are not thread safe.
Fix this, by using k_mem_slab instead of arrays.

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-09-19 15:20:09 +01:00
Anas Nashif
a04a1d8991 tracing: remove references to deprecated k_pipe_block_put
k_pipe_block_put was deprecated some time ago.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-18 19:20:02 -04:00
Ambroise Vincent
bb450eb26f net: sockets: Keep lock when notifying condvar
Releasing the lock before notifying condvar led to a race condition
between a thread calling k_condvar_wait to wait for a condition variable
and another thread signalling for this same condition variable. This
resulted in the waiting thread to stay pending and the handle to it
getting removed from the notifyq, meaning it couldn't get woken up
again.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-09-18 15:41:23 -04:00
Andreas Ålgård
fa0bbaf66c net: promiscuous: Fix crash in promiscuous mode
When a packet can't be cloned we crash as we try to initialize the
cursor on a nullptr. We should check if we have a valid pointer,
and if we don't we drop the packet along with a warning.

Signed-off-by: Andreas Ålgård <aal@ixys.no>
2023-09-18 20:34:31 +02:00
Dominik Ermel
47396e18e1 net: Fix usage of strncpy in net_if_get_name and net_if_set_name
Replaced with memcpy.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-18 20:34:19 +02:00
Chaitanya Tata
40ee8791f2 net: socketpair: Fix use after free
In low memory conditions, its possible for socketpair memory allocation
to fail and then the socketpair is freed but after that the remote
semaphore is released causing a crash.

Fix this by freeing the socketpair after releasing the semaphore. Add a
test case to induce low memory conditions (low HEAP and high socketpair
buffer size), with the fix issue is not seen.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-09-18 20:34:12 +02:00
Bjarki Arge Andreasen
586504bed8 modem: chat: Track size of script_chat request to avoid strlen()
This commit optimizes the performance of the script chats by
storing the size of requests with the chat script chat, negating
the need to use strlen() within the modem_chat module every time
a chat script chat request is sent.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-18 14:11:40 +01:00
Bjarki Arge Andreasen
c9bc07a4f3 modem: chat: Add synchronous functions for script exec
This commit adds one new feature, modem_chat_run_script(),
which synchronously runs a script.

The existing function modem_chat_script_run() is async,
and doesn't follow the naming convention created for the
other modem modules, specifically, all functions are sync,
unless appended with _async.

To preserve backwards compatibility, the existing function
modem_chat_script_run() will remain until deprecated. It
simply calls modem_chat_run_script_async().

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-18 14:11:40 +01:00
Nirosharn Amarasinghe
b96436296f Bluetooth: controller: Included kconfigs for ISO-AL logging
Included kconfigs to set the ISO-AL logging level and control debug
logging verbosity.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Erik Brockhoff
365a56ce87 Bluetooth: controller: disregard length field on pdu error
In case of unframed iso rx, length field cannot be trusted in case of
PDU error.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-09-18 14:35:42 +02:00
Nirosharn Amarasinghe
d414cab87a Bluetooth: Controller: ISO-AL validation and selection of TX time stamps
Intent is to pass Ellisys ISOAL quality tests for framed TX scenarios
where the TX SDU includes a time stamp that is not based on the
controller's clock.

Changes:
-- Include controller's reception time as a separate field in the TX SDU
   information
-- Include decision on whether SDU time stamp is valid and based on the
   controller's clock
-- Arbitrate and select / compute time stamp for the SDU

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Nirosharn Amarasinghe
31df0ef80b Bluetooth: controller: corrected time-offset for endianness
Changes:
-- Corrected reading and writing time offset in framed segment header to
   account for endianness
-- Corrected bit positioning of time offset bit field in the segment
   header structure definition
-- Fixed upstream Zephyr BSIM test build failure due to debug logging
   39-bit variable

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Nirosharn Amarasinghe
e318a3032b Bluetooth: controller: Use consecutive event for framed TX and RX bugfix
Changes:
-- Disregards target event after segmenting the first TX SDU and instead
   decide event based on the next payload and feasibility to fragment
   for that event (time-offset > 0)
-- Corrected error SDU release logic when an error occurs while
   expecting the start of a new SDU, to avoid releasing an SDU which
   could be received in the next payload or event
-- Included additional debug logging

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Vinayak Kariappa Chettimada
5daa864b5e Bluetooth: Controller: Use DIV_ROUND_UP macro in HAL ticker
Use DIV_ROUND_UP macro in HAL ticker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
34100cb7ea Bluetooth: Controller: Use defines for femto and pico seconds
Use defines for femto and pico seconds in HAL ticker
calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
333ff94e6b Bluetooth: Controller: Use HAL_TICKER_US_TO_TICKS_CEIL for ticks_slot
Use HAL_TICKER_US_TO_TICKS_CEIL for ticks_slot calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
01314b2e43 Bluetooth: Controller: Make openisa and test hal ticker.h consistent
Make openisa and unit test hal ticker.h consistent with
nrf hal ticker.h.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
c986104485 Bluetooth: Controller: Revert EVENT_OVERHEAD_END_US to original value
Revert back the EVENT_OVERHEAD_END_US value to original
value in initial commit 5c3709c13f ("bluetooth:
controller: Add def's re. update to slot reservation calc").

40 us is a sufficient margin considering ~30 us being the
worst case Rx chain delay for S8 Coded PHY on nRF5x SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Hake Huang
acf3755d1c ztest_new: add CONFIG_ZTEST_NO_YIELD to ztest_new
Rather than yielding to idle thread, keep the part awake.
So debugger can still access it,
since some SOCs cannot be debugged in low power states.

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2023-09-18 06:50:08 -04:00
Ludvig Samuelsen Jordet
b990a74f8b Bluetooth: Mesh: Add support for Upload OOB Start
This adds support for the Upload OOB Start message to the DFD server, by
providing callbacks that the application can use to hook any OOB scheme
into the model behavior.

There are also extensive changes to the dfu_slot module, to accomodate
the new needs that appeared with the support for OOB transfer (mainly,
fwid, size and metadata are no longer available when the slot is
allocated, they appear later in the handling).

Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
2023-09-18 10:55:20 +01:00
Jordan Yates
dd090f06b7 net: wifi_mgmt: change type of wifi_scan_params->chan
All WiFi channel numbers fit within a 8 bit number, as the maximum
allocated channel is 233. This halves the memory requirement.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-18 10:54:31 +01:00
Martin Jäger
eae44a55d8 net: lib: sockets: sockets_tls: prefix mbedtls error with 0x
The errors are printed in hex, but no prefix was used. This could be
confused with usual errno return values. The 0x prefix makes clear
that it's a hex value.

Also a missing minus sign is added to one log message.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-09-18 10:38:44 +01:00
Wojciech Slenska
798b863f36 modem: modem_ppp: added net stats
Added ppp net stats to modem subsys.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-09-15 15:13:06 -05:00
Wojciech Slenska
6f3bbe19a7 net: ip: stats: changed dependency for PPP stats
NET_STATISTICS_PPP are dependend on NET_L2_PPP, not on NET_PPP.
This allows to use statistics also in modem subsys.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-09-15 15:13:06 -05:00
Leifu Zhao
61ab3a844c pm: policy: add check for device busy in policy
Add check for device busy when CONFIG_PM_NEED_ALL_DEVICES_IDLE is
set to y because one or more devices may still in busy and causes
problem when system go into low power in Intel ISH platform.

Signed-off-by: Leifu Zhao <leifu.zhao@intel.com>
2023-09-15 14:51:50 -04:00
Gerard Marull-Paretas
011321f0cf usb: usb_c: use POST_KERNEL level
Usage of application level for device drivers needs to be avoided. Also
introduced a new init level, with default to 90 as other dependencies of
USB-C run at priority 80.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Gerard Marull-Paretas
e6bef2d3f3 usb: device: class: audio: move to POST_KERNEL
Devices should be initialized in pre/post-Kernel levels.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Gerard Marull-Paretas
d4ffef507c testsuite: busy_sim: use POST_KERNEL
Devices should be initialized in pre/post-Kernel.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Gerard Marull-Paretas
1ffacb6c3a input: longpress: use POST_KERNEL level
Because APPLICATION is going to be deleted.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Gerard Marull-Paretas
4f80e50b55 bluetooth: controller: coex: convert to DT device
Convert the driver to a dt-based device. Also update Kconfig so that it
depends on the right compatible being enabled, initialize in POST_KERNEL
(APPLICATION should not be used for devices) and remove one redundant
include.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Gerard Marull-Paretas
349306bda7 bluetooth: audio: use SYS_INIT
The device model was not used for anything useful, only to call some
init code. Change to SYS_INIT instead.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Carlo Caione
e4a125b6a4 dt: Make zephyr,memory-attr a capabilities bitmask
This is the final step in making the `zephyr,memory-attr` property
actually useful.

The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.

With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.

The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).

For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_VOLATILE |
			       DT_MEM_NON_CACHEABLE |
			       DT_MEM_OOO )>;
   };

The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-region = "NOCACHE_REGION";
       zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
   };

See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).

The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
			       DT_MEM_SW_ALLOCATABLE )>;
   };

Or maybe we can leverage the property to specify some alignment
requirements for the region:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_CACHEABLE |
			       DT_MEM_SW_ALIGN(32) )>;
   };

The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).

When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`

Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory  region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-15 12:46:54 +02:00
Vinayak Kariappa Chettimada
d42d14e392 Bluetooth: Controller: Fix missing lazy calculation for Central ISO
Fix missing lazy calculation when using ticker interface
required for Central CIS create.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-15 09:27:37 +02:00
Vinayak Kariappa Chettimada
1291e4b686 Bluetooth: Controller: Fix initialization of lazy_active
Fix initialization of CIS lazy_active event count used when
first CIS event is active. Now initialization for first and
any subsequent CISes made active.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-15 09:27:37 +02:00
Vinayak Kariappa Chettimada
afd48e03d0 Bluetooth: Controller: Minor clean up of redundant initialization
Minor clean up of redundant initialization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-15 09:27:37 +02:00
Gerard Marull-Paretas
aaeb0a672e toolchain: only include <zephyr/toolchain.h>
It is wrong to use toolchain-specific header files.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 09:27:30 +02:00
Mahesh Rao
a57a90feb4 subsystem: sip_svc: Reduce the max timeout to 1 second.
Reduce the max timeout for shell to 1 second.
Change the sip_svc open shell function to take millisecond as timeout
argument.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-09-15 09:26:49 +02:00
Mahesh Rao
c13466974e subsystem: sip_svc: Use atomic variable for locking in singly open system
Use atomic variable for singly open system.
Add k_timer_stop() for sip_svc open timer().

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-09-15 09:26:49 +02:00
Mahesh Rao
97f9d3c60b subsystem: sip_svc: Initialize clients structure after allocation
Initialize client structure after memory allocation.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-09-15 09:26:49 +02:00
Mahesh Rao
817f44f714 subsystem: sip_svc: Change polling delay to micro seconds
Change polling delay to use microseconds.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-09-15 09:26:49 +02:00
Mahesh Rao
7b2e82ecc7 subsystem: sip_svc: Check the number of clients as part of build
Check number of clients as part of build.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-09-15 09:26:49 +02:00
Mahesh Rao
0993bce77d subsystem: sip_svc: Increase stack size for sip_svc thread
Increase sip_svc thread stack size to 4096.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-09-15 09:26:49 +02:00
Bjarki Arge Andreasen
40b9f51ee5 modem: pipe: Reinvoke receive ready on attach
This PR makes the modem_pipe instances track if they have
data ready to receive, and invoke the RECEIVE_READY event
every time they are attached if the backend implementing
the pipe has notified that receive is ready.

This mechanism ensures that modules attaching to a pipe
get the async RECEIVE_READY event immediately after
attaching to a pipe if there is data ready, instead of
having to poll the pipe, or worse, wait until newer data
becomes available.

The addition revealed a timing issue in the cmux test
suite. Specifically the CMUX instance now immediately
receives the response to a command which the CMUX
instance has not sent yet, causing it to drop the
response.

The CMUX test suite now uses the transaction
mechanism of the mock_pipe to wait for the command
before sending the response.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-14 16:44:04 -05:00
Donatien Garnier
185a6117c0 Bluetooth: Host: Amend existing L2CAP accept callbacks
This patch amends the existing L2CAP accept callbacks to use the new
accept signature that includes a pointer to the L2CAP server structure.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-09-14 14:36:34 +02:00
Donatien Garnier
815891643e Bluetooth: Host: Pass pointer to server in L2CAP accept() callback
Add a pointer to the associated server structure in the L2CAP accept()
callback. This allows the callee to know which server an incoming L2CAP
connection is associated with.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-09-14 14:36:34 +02:00
Emil Gydesen
3f585f527b Bluetooth: Host: Add additional logging for bt_conn_exists_le
The bt_conn_exists_le is commonly hit by users attempting
to connect (either as central or peripheral) to a device
they are already connected to in some way. The current log statement
does not provide particularly much information, so added more.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-14 14:36:09 +02:00
Vinayak Kariappa Chettimada
f2069530ee Bluetooth: Controller: Fix some compiler instruction re-ordering
Fix some compiler instruction re-ordering. Mayfly code with
cpu_dmb() help avoid stalled memq_ull_rx processing when
rx_demux is to be executed using mayfly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-14 14:30:36 +02:00
Gerard Marull-Paretas
691facc20f include: always use <> for Zephyr includes
Double quotes "" should only be used for local headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-14 13:49:58 +02:00
Hang Fan
3fb434a653 Bluetooth: Shell: Fix bt adv-data command
Fix wrong adv elements length for bt adv-data command

Signed-off-by: Hang Fan <fanhang8@gmail.com>
2023-09-14 08:35:40 +02:00
Grant Ramsay
a4383c2fd1 canbus: isotp: add CAN-FD support
ISO-TP CAN-FD support can be enabled at runtime.

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
Signed-off-by: Martin Jäger <martin@libre.solar>
2023-09-14 08:34:09 +02:00
Marcin Niestroj
a9fbcd2785 logging: swo: add Kconfig option for SWO reference frequency
SWO reference frequency was set based on `swo-ref-frequency` under `itm`
nodelabel or `/cpus/cpu@0/clock-frequency` property. Not all platforms
configure those.

All ST devices configure CPU frequency in `clock-frequency` under `rcc`
nodelabel. Configuring the same value for each board in
`/cpus/cpu@0/clock-frequency` would be one way to make SWO work out of the
box. There is lots of copy-pasting involved in this, which makes this very
error-prone.

Introduce Kconfig option, which will default to values configured in `itm`
or `/cpus/cpu@0`. The main advantage will be for platforms like ST, where
CPU clock frequency is already configured in another place. Thsoe could
override default value in SoC, board or any other platform specific layer.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-09-13 16:29:56 +02:00
Rick Talbott
829b91ab2f shell: Fix scrolling long commands in history
This fixes scrolling long commands in command history in the shell

Signed-off-by: Rick Talbott <richard.talbott1@t-mobile.com>
2023-09-13 16:26:02 +02:00
Mourad Kharrazi
a85ffa8130 drivers: sdhc: allow bandwidth selection
The current implementation uses both, host and card capabilites to derive
the maximum bus width to be used. However, in cases where a MMC device is
not connected to the host via shdc using the full bus width of 8 lines,
device initialization fails. Introducing the `bus-width` property
circumvents this by reducing the host bus capabilites and forcing
communication with the MMC device using 1, 4 or 8 lines.

Signed-off-by: Mourad Kharrazi <mourad.kharrazi@ithinx.io>
2023-09-13 16:20:59 +02:00
Vivekananda Uppunda
450dbb15ef net: l2: wifi: Add support for W-Fi mode setting and selection
This change brings in support for setting various Wi-Fi modes and
enables a specific Wi-Fi interface to be also placed into a sniffer
operation via monitor mode and promiscuous mode. A raw TX- packet
Injection mode is also introduced

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2023-09-13 11:47:28 +02:00
Alperen Şener
f6a9fc1202 Bluetooth: Mesh: add optional OOB info to ext scan report
Even though the OOB information is optional we can add it
to extended scan reports in cases there is detected unprovisoned
devices.

Referring to MshPRT section 4.4.5.3:
When the Remote Provisioning Extended Scan procedure completes without
receiving an advertisement from the unprovisioned device, the
OOBInformation and AdvStructures fields shall be skipped. When the
obtained data is empty, the AdvStructures field shall be skipped. The
Status field shall be set to Success.

and referring to MshPRT section 4.3.4.9:
The OOBInformation field contains the OOB Information of either the
unprovisioned device or the Remote Provisioning Server.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-09-13 10:07:42 +02:00
Chaitanya Tata
79158a777b zperf: Add support to configure context priority
This is handy in setting a custom priority for the context either
through shell or API.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-09-12 21:26:28 -04:00
Chaitanya Tata
7711d28b03 net: Add configuration option to allow any priority
This adds support to allow any priority from the user instead of
limiting to the protocol values (0-7). This is useful in conveying
custom priorities from application to the driver/chipset.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-09-12 21:26:28 -04:00
Chaitanya Tata
3b4c529d7e net: Add priority to ping
This is handy in testing of setting priority directly rather than
deriving from DSCP. Please note ICMP doesn't use net context.

This is applicable for both shell and API.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-09-12 21:26:28 -04:00
Anas Nashif
fcf50ed6e7 kernel: move timeout_q.h to kernel/include
This is a private kernel header with private kernel APIs, it should not
be exposed in the public zephyr include directory.

Once sample remains to be fixed (metairq_dispatch), which currently uses
private APIs from that header, it should not be the case.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-12 12:55:36 -04:00
Aron Lander
89c866ab68 modules: Add DFM and move Tracerecorder into percepio module
This commit adds the DFM (DevAlert target side code) module and
moves the TraceRecorder module into the percepio module, which
results in the TraceRecorder module definition being removed
from the west manufest and module definition within zephyr.

Signed-off-by: Aron Lander <aron.lander@percepio.com>
2023-09-12 10:19:37 -04:00
Bjarki Arge Andreasen
840f2e40b5 modem: chat: Add partial match feature to modem_chat
This commit adds support for partial matches for the modem_chat
module. A match is a combination of an expected response to a
request along with delimiters to use and a handler for the
parsed response.

The usual behavior of the modem_chat script is to continue to
the next step when any expected response is received. The partial
flag indicates that the script should not proceed to the next
step if the response matches the match. This is useful for
commands which respond with an unspecified number of lines,
followed by an "OK". This flag allows the script to essentially
run in a "while" loop until OK is received.

Along with this addition, a more scalable macro for initializing
the modem_chat match struct, MODEM_CHAT_MATCH_INITIALIZER().
Without this macro, we will need 4 different macros to initialize
the 4 variants of a chat_match, and 8 when the next feature is
added...

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-12 14:50:17 +02:00
Rafał Kuźnia
5b12b6ab55 ipc: icmsg: Dedicated workqueue for ICMSG backend
The ICMSG backend now has a dedicated workqueue to process incoming IPC
messages. The system workqueue is no longer utilized for that purpose.

Testing shows that in certain scenarios substituting a RPMsg backend
with ICMsg results in deadlocks.
The deadlocks were a symptom of running a synchronous RPC protocol from
the context of the system workqueue and transpired as follows:

1. The RPC protocol sends a request over the ICMsg backend on the system
   workqueue thread.
2. The RPC protocol puts the thread to sleep until response is received.
   This puts the system workqueue thread to sleep.
3. The response to the request arrives over ICMsg backend.
4. The backend signals a work item to the system workqueue.
5. The system workqueue is unable to process the response due to being
   previously pended on the RPC request.

The deadlock was initially observed with the nrf-802154 driver in
conjuntion with the IPv6 stack.

To prevent this condition from occurring, the approach was selected to
give ICMsg a dedicated workqueue thread.

Added a Kconfig option that enables the dedicated workqueue by default.
The config can be disabled, if the user wants to preserve RAM capacity
and is certain that the deadlock condition is not encountered.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2023-09-12 10:17:27 +02:00
Sachin D Kulkarni
85b39b8449 net: wifi: Fix crash in wifi_utils_parse_scan_ssids
wifi_utils_parse_scan_ssids could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.

Also limit the range of the CONFIG_WIFI_SCAN_SSID_FILT_MAX parameter
from 1 to 4 to avoid stack overflow due to users specifying a large
value for this parameter.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-09-12 09:24:06 +02:00
Sachin D Kulkarni
0b92327fc3 net: wifi: Fix crash in wifi_utils_parse_scan_bands
wifi_utils_parse_scan_bands could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-09-12 09:24:06 +02:00
Wojciech Slenska
012457580b modem: backends: uart: fix backend selection
Modem backed configs should be used instead of uart.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-09-11 16:56:39 -04:00
Anders Storrø
6559de3238 Bluetooth: Mesh: Store priv proxy in sep entry
Stores persistent on-demand private GATT proxy state in separate
settings entry. This is implemented to avoid issues related to
backwards compatibility between device firmware updates.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-11 19:58:05 +02:00
Anders Storrø
c80a52a1e3 Bluetooth: Mesh: Store priv beacon in sep entry
Stores persistent private beacon state in separate settings entry.
This is implemented to avoid issues related to backwards compatibility
between device firmware updates.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-11 19:58:05 +02:00
Jamie McCrae
da96722552 bluetooth: Make long workqueue init priority configurable
Makes the long workqueue init priority configurable and sets
the default to 50, this is to allow for relocating bluetooth
libraries to other parts of memory e.g. external flash, and
allows for those flash drivers to be initialised prior to
calling functions residing in them.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-11 19:57:08 +02:00
Bjarki Arge Andreasen
c61057354e modem: Delegate async UART pipe closed event
This commit delegates the modem_pipe_notify_closed() call
resulting from the UART async API UART_RX_DISABLED event
to the workqueue. This is neccesary as the async UART
callback may be called from ISR context.

modem_pipe_notify_closed() must be called from outside of
the ISR context as it takes a mutex.

The commit also adds a missing break to the async UART
callback, and adds a missing dependency to the Kconfig
for the UART backends, RING_BUFFER=y

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-11 19:56:48 +02:00
Noah Pendleton
00d8870a50 debug: Set thread_info.c variables to const
The variables are usually placed into an output region located in FLASH
memory when linking, but the variables are not marked `const`, so the
section ends up with `W` writeable section flag:

```bash
❯ arm-zephyr-eabi-readelf --section-headers build/zephyr/zephyr.elf | \
  grep -E '(Section Headers:)|(  \[Nr\])|(zephyr_dbg_info)'
Section Headers:
  [Nr] Name            Type     Addr     Off    Size   ES Flg Lk Inf Al
  [10] zephyr_dbg_info PROGBITS 60012298 01238c 000040 00  WA  0   0  4
```

Set them as const to set the output section to read-only:

```bash
❯ arm-zephyr-eabi-readelf --section-headers build/zephyr/zephyr.elf | \
  grep -E '(Section Headers:)|(  \[Nr\])|(zephyr_dbg_info)'
Section Headers:
  [Nr] Name            Type     Addr     Off    Size   ES Flg Lk Inf Al
  [10] zephyr_dbg_info PROGBITS 60012298 01238c 000040 00   A  0   0  4
```

Signed-off-by: Noah Pendleton <noah.pendleton@gmail.com>
2023-09-11 19:56:18 +02:00
Pirun Lee
008a82e3ba Bluetooth: OTS: Fix memory leak while procedure is not finished
cur_inst is the copy of ots_client instance to prevent duplicate
API call while client is in middle of read/write procedure.
But cur_inst can only be cleared while write_obj_tx_done or read rx_done.
If ACL is disconnected while read/write is on-going, there is no chance
for cur_inst being cleared.
This causes ots client will no longer perform select/read/write
procedure anymore. API will always return -EBUSY.

Let l2cap_disconnect check if cur_inst is NULL and NULL it
unconditionally as what it is designed.

Make bt_ots_client_unregister public API.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2023-09-11 19:55:56 +02:00
Mariusz Skamra
ff71508d5f Bluetooth: audio: ascs: Add endpoint by stream lookup function
This adds endpoint by stream lookup function used to find the active
endpoints that use the stream object provided. The function is used
instead of dereferencing stream->ep that may be not valid if application
did not memset the stream object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-11 11:08:53 +02:00
Mariusz Skamra
c1214f2067 Bluetooth: audio: ascs: Make stream->ep valid in bt_bap_stream_ops.released
Once the application bt_bap_stream_ops.released callback is called make
sure the stream->ep pointer is valid so that application can still access
the endpoint details like e.g. endpoint direction.

Fixes: ASCS/SR/ACP/BV-{24,25,26,27,28,29,30,31}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-11 11:08:53 +02:00
Emil Gydesen
b86548ca7c Bluetooth: Audio: Add check for valid cid and vid for LC3
When using the LC3 codec, the cid and vid fields of the
codec shall both be 0x00, as per the BAP and ASCS specs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-11 11:08:39 +02:00
Florian Grandel
141293ea23 net: l2: ieee802154: settings: make ACK configurable
Add a network configuration option to configure whether IEEE 802.15.4
packets are expected to be ACKed or not.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-09 05:18:41 -04:00
Florian Grandel
c88e5360b1 net: l2: ieee802154: fix settings order
In the IEEE 802.15.4 area certain settings must be set before
net_if_up() may be called (e.g. the channel).

Also net_if_up() may not be called if
CONFIG_IEEE802154_NET_IF_NO_AUTO_START=y.

This fixes the set-up order and handling of
CONFIG_IEEE802154_NET_IF_NO_AUTO_START.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-09 05:18:41 -04:00
Florian Grandel
5aa329cecd net: l2: ieee802154: mgmt: fix locking issue
Fixes a locking issue in the IEEE 802.15.4 net mgmt implementation.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-09 05:18:41 -04:00
Alperen Şener
66bf33f090 Bluetooth: Mesh: Fix Solicitation Mesh crypto API use
Pointer of the keys should be send to mesh en/decryption APIs.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-09-08 14:45:22 +02:00
Alberto Escolar Piedras
bb811a1e1d Bluetooth: Controller: Nordic LLL: Use HAL to clear EVENTs
Use the HAL event clear functions to clear EVENTS
instead of accessing the registers directly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-08 14:45:13 +02:00
Alberto Escolar Piedras
7082222ac6 Bluetooth: Controller: Nordic LLL: Use HAL to clear RTC event
Use the HAL event clear function to clear the RTC EVENT
instead of accessing the register directly.

This allows using an updated version of the RTC HW models
which generate level interrupts (as the real HW) and in
which if the EVEN register is not properly cleared,
the interrupts are kept high, resulting in the interrupt
handler reentering immediately after exiting.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-08 14:45:13 +02:00
Emil Gydesen
1e826bb670 Bluetooth: BAP: Shell: Fix issue in cmd add_pa_sync
The command was missing a metalen check, and attempted
to access array of size 0, which could give a build
warning.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-08 14:44:39 +02:00
Anders Storrø
6b627771c8 Bluetooth: Mesh: Shell support for comp data page2
Adds shell support for composition data page 2 and 130

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-08 14:44:25 +02:00
Anders Storrø
9d849736ef Bluetooth: Mesh: Support for comp data page 2
Adds support for composition data page 2 & 130.

In this implementation the responsibillity for filling the page 2
buffer is left to the application through the new comp page 2 cb API.
Only the application can know/decide if the device is NLC compliant,
and must thus be given the responsibillity for cheking the NLC profile
requirements, defined in the NLC specs, and filling the response buffer
for comp data page 2.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-08 14:44:25 +02:00
Emil Gydesen
1e50132237 Bluetooth: ISO: Handle central disc of pending CIS
If the central disconnects a CIS while it is being
established, then we receive both a CIS established event
with BT_HCI_ERR_OP_CANCELLED_BY_HOST and a disconnect complete
event.

In this case we should not call bt_iso_disconnected in the
CIS established event handler, as that will also be
called from the disconnect complete event handler.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-08 14:43:23 +02:00
Emil Gydesen
7e66bb1e09 Bluetooth: ISO: Reject disconnecting pending CIS as peripheral
As per the core spec, the CIS is not allowed to disconnect
a CIS if it is pending (i.e. in the connecting state).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-08 14:43:23 +02:00
Piotr Narajowski
96954acfff bluetooth: audio: Add API to get MICP service ATT handles
This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2023-09-08 14:43:00 +02:00
Florian Grandel
d218b20643 tracing: make API tracing configurable
So far only object tracing/tracking could be individually disabled (e.g.
CONFIG_TRACING_SEMAPHORE=n). Now tracing of any API may be disabled
(e.g. CONFIG_TRACING_PM=n).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-08 06:10:14 -04:00
Jonathan Rico
22bde976e5 Bluetooth: l2cap: validate reconfigure packet length
The specification only allows up to 5 16-bit CIDs in this PDU.
Enforce it.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-07 20:18:06 +02:00
Morten Priess
79ab982f46 Bluetooth: controller: Introduce config for avoiding SDU fragmentation
The CIS Central uses the algorithm described in BT Core 5.4 Vol 6,
Part G, Section 2.2 to calculate the Max_PDU value for framed mode.

However, HAP needs the Max_PDU to be calculated according to "Core
enhancement for ISOAL CR" coming with the "Atlanta" update. With this
update, the fragmentation is controlled via a parameter at CIG creation.

Enabling CONFIG_BT_CTLR_CONN_ISO_AVOID_SEGMENTATION will set the
ISO_Interval to 7.5 ms for a 10 ms framed CIG, and calculate Max_PDU to
45/65 for 16/24 kHz.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-09-07 14:25:35 +02:00
Robert Lubos
370096e4f5 net: tcp: Fix goto condition in case of RST/packet error
In case RST packet is received or malformed packet is received, the TCP
should not proceed with the state machine execution (which may process
the invalid packet) but rather jump directly to exit, where the
connection will be closed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-07 11:41:52 +02:00
Bjarki Arge Andreasen
111db23d0a net: mgmt: Fix memory corruption in wait_on_iface
The net_mgmt subsystem offers a function which waits (blocks)
until a specified net event occurs. An event callback is
pushed to the stack, then added to the net_mgmt_event_callback
list. If the event occurs, the net_mgmt thread calls the
callback and deletes the callback from the list. However, if
the event does not occur within the timeout specified when
invoking mgmt_event_wait_call() the function will return,
corrupting the callback structure the stack is reused.

This PR fixes the issue by deleting the callback before exiting
in case the event does not occur.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-07 09:44:06 +02:00
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