Commit graph

18898 commits

Author SHA1 Message Date
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
Daniel Mangum
775a8e8c8d net: sockets: use DTLS in NET_SOCKETS_TLS_MAX_APP_PROTOCOLS
Updates NET_SOCKETS_TLS_MAX_APP_PROTOCOLS Kconfig option description to use
DTLS instead of DTL.

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

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

No functional changes, just clean up of Kconfig menu.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #60826

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

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

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

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

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

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

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

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

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

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

Fixes #60212

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Updated SMP transport for send request.

Added API for register SMP transport.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Keeping 30ms window only for legacy advertiser support.

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

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

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

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

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

Accessor function `ieee802154_radio_attr_get` is provided.

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

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

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

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

First this:

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

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

The above condition will simply never be true.

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

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

Then this:

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

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

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

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

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

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

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

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

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

Issue ##50611 is one example.

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

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

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

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

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

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

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

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

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

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

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

Fixes #59002.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #59919

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

All changes are documented by pointers into the spec.

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #59514.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Flag sync_iso_create_get() function

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

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

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

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

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

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

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

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

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

Now if PMAX changes, next event timestamp is recalculated.

Fixes #59397

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #58942.

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

Fixes #59512.

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

Fixes #58999.

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

Fixes #58984.

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

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

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

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

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

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

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

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

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

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

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

Also fixes a missing include of conn.h.

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

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

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

Tests adjusted as appropriate.

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

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

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

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

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

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

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

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

Fix for issue#45968

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #59683

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

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

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

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

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

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

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

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

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

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

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

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

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

Modify it to use a simple bool.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Coverity-CID: 321153
Fixes #59527

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

Coverity-CID: 321075
Fixes #59522

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

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

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

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

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

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

Modified to only use get_next_seq_num.

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

Fix by checking that `conn` is not NULL.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-21 13:24:12 +02:00
Jamie McCrae
0b6077443d mgmt: mcumgr: grp: img_mgmt: Add optional mutex lock support
Adds an optional Kconfig that adds mutex locks to image management
group functions, this prevents collision between multiple threads
and/or transports.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-21 13:24:01 +02:00
Jordan Yates
6271f2fa56 net: if: default NET_IF_LOWER_UP at compile time
The `net_if` layer should not be forcing `NET_IF_LOWER_UP` to be set on
all interfaces at runtime. Because `net_init` runs relatively late by
default, this is overriding any control the driver itself may have
performed using `net_if_carrier_on/off`.

Initialise this bit at compile-time instead. As the structure is already
being initialised, this doesn't increase any footprints.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-06-21 09:35:49 +00:00
Seppo Takalo
95cef5f3ab net: lwm2m: Ensure string termination
When writing string data to resources which are string types,
we should count in the terminating character into the data length.

Corner cases exist where LwM2M resource type is opaque but
lwm2m_get_string() or lwm2m_set_string() are used to read/write
the data. We must ensure string termination on those case, but
terminating character must not be stored in the engine buffer
or counted in the data length as this might be considered
as part of the binary data.

Fixes #59196

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-21 10:42:31 +02:00
Emil Gydesen
8b9815aff6 Bluetooth: IAS: Fix alert level loop
The loop was supposed to set the alert level to the highest
value by any device. The loop, however, only made sense if
CONFIG_BT_MAX_CONN > 1.

It has been modified to start from [0] instead of [1] and
the initial condition was modified.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-21 09:34:49 +02:00
Luca Fancellu
38a43b0eec net: config: Add VLAN identifier as network initial configuration
Add a new Kconfig parameter NET_CONFIG_MY_VLAN_ID as initial network
configuration to enable users to set VLAN identifier at startup.

Add a new setup_vlan(...) function to setup the VLAN identifier in
the device, the call have an effect only when NET_CONFIG_MY_VLAN_ID
is above zero.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-06-21 09:32:41 +02:00
Gerard Marull-Paretas
48b201cc53 device: make device dependencies optional
Device dependencies are not always required, so make them optional via
CONFIG_DEVICE_DEPS. When enabled, the gen_device_deps script will run so
that dependencies are collected and part of the final image. Related
APIs will be also made available. Since device dependencies are used in
just a few places (power domains), disable the feature by default. When
not enabled, a second linking pass will not be required.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
1ebd76ed51 pm: add prompt to DEVICE_DEPS_DYNAMIC
The option can now be set by projects. This change will also allow to
make it dependent on a future CONFIG_DEVICE_DEPS option.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
319fbe57e1 device: s/HAS_DYNAMIC_DEVICE_HANDLES/DEVICE_DEPS_DYMAMIC
Rename the Kconfig option to be in line with recent renamings in device
handles/dependencies.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
5982d83e2a device: s/struct device.handles/struct device.deps
Rename struct device `handles` member to `deps`, in line with previous
renamings in the device API.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
4eb406e093 device: s/DEVICE_HANDLE/DEVICE_DEPS/
Rename multiple internal device macros to use the DEVICE_DEPS naming, so
that it is clear they belong to the device dependencies APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas
e5f82cb5dc device: hide DEVICE_HANDLE_SEP/ENDS
These macros are used internally by the device dependencies functions.
There's no need to expose them publicly, so prefix them with Z_ and add
them under INTERNAL_HIDDEN docs section.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Jamie McCrae
3e71797ba2 mgmt: mcumgr: grp: img_mgmt: Fix missing define
Fixes a missing define which causes a build failure.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-20 15:14:19 +02:00
Alberto Escolar Piedras
e59f6a8135 portability cmsis_rtosv2: Check return of k_mem_slab_init()
Instead of trusting blindly that k_mem_slab_init()
will succeed, let's check it, and handle failures
appropriately.
Otherwise, a buffer of garbage will be passed
around, leading to misterious failures later on.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-06-20 10:45:33 +00:00
Emil Gydesen
1f1e51ad6b Bluetooth: Shell: Fix typo in disconnected
A callback function had a typo where disconencted should
have been disconnected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-20 10:44:07 +00:00
Aleksandr Khromykh
a13157f997 Bluetooth: Mesh: fix missed old encryption in dfu metadata
PR fixes the old internal encryption api usage
for dfu metadata.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-20 10:10:19 +02:00
Aleksandr Khromykh
327eb119b6 Bluetooth: Mesh: add tf-m support for ble mesh
This PR adds ability to build mesh with tf-m psa
for platforms those support tf-m.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-19 15:04:17 +02:00
Michał Grochala
5ac063d793 bluetooth: controller: Fix build with BT_HCI_VS_EXT disabled.
Fixing error: undefined reference to 'vs_set_min_used_chans'
when building with 'BT_HCI_VS_EXT' option disabled.

Signed-off-by: Michał Grochala <michal.grochala@nordicsemi.no>
2023-06-19 11:02:14 +02:00
Aleksandr Khromykh
a322e4d20d Bluetooth: Mesh: clarification about adv local identity
BT_ID_DEFAULT is hardcoded in mesh. Added clarification about
the necessity of another local identity allocation for BLE
if it coexists with mesh.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-19 11:01:30 +02:00
Saravanan Sekar
bdb26cfe02 net: mqtt: close tcp socket after websocket_disconnect
websocket_disconnect api does not closes mqtt's tcp socket, so
tcp socket must be closed after done.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2023-06-19 09:18:45 +01:00
Saravanan Sekar
3c9f3b7849 net: websockets: do not close tcp socket in websocket
The websocket_connect api expects connected tcp socket, do not close
the user supplied socket so that the caller can re-use it if needed.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2023-06-19 09:18:45 +01:00
Victor Chavez
bee43bd972 logging: Fixed BLE backend buffer size independent of MTU
The BLE backend has a bug that when the MTU size is less than
the buffer the notification always fails and does not allow
to flush the buffer.

This fix checks for the MTU size of the current connection
and adjusts it. In addition, the buffer size is no longer
settable by the user and depends on the transmission size
of MTU set with CONFIG_BT_L2CAP_TX_MTU.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-06-19 08:38:08 +02:00
Florian Grandel
f32fae07f2 net: l2: ieee802154: fix endianness bug
The PAN ID in IEEE 802.15.4 frames is little endian while in the
IEEE 802.15.4 context it is kept in CPU byte order.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
267db64f39 net: l2: ieee802154: fix acknowledgment procedure
The ACK procedure had the following issues:

- MAC commands were not acknowledged.

- When the package is a broadcast package the package must not be
  acknowledged.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
7571be3261 net: l2: ieee802154: deprecate NET_L2_IEEE802154_ACK_REPLY
Acknowledgment is mandatory if legitimately requested by the package's
"ACK requested" flag. The L2 layer will have to ensure that compliant
ACK packages will always be sent out automatically as required by the
standard.

For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option is
therefore being deprecated.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
f96b620d12 net: l2: ieee802154: properly handle TX HW capabilities
The existing calls to ieee802154_radio_send() and soft MAC ACK handling
were inconsistent and/or not properly integrated with more recent
radio driver capabilities as CSMA/CA and ACK in hardware.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
1ee4d3ed77 net: l2: ieee802154: document L1/L2 sep. of concerns
The method ieee802154_radio_handle_ack() does not belong to the
PHY/radio layer but to the L2 layer. It is a callback called from the
radio layer into the L2 layer and to be implemented by all L2 stacks.
This is the same pattern as is used for ieee802154_init(). The
'_radio_' infix in this function is therefore confusing and
conceptually wrong.

This change fixes the naming inconsistency and extensively documents
its rationale.

It is assumed that the change can be made without prior deprecation of the
existing method as in the rare cases where users have implemented custom
radio drivers these will break in obvious ways and can easily be fixed.

Nevertheless such a rename would not be justified on its own if it were
not for an important conceptual reason:

The renamed function represents a generic "inversion-of-control" pattern
which will become important in the TSCH context: It allows for clean
separation of concerns between the PHY/radio driver layer and the
MAC/L2 layer even in situations where the radio driver needs to be
involved for performance or deterministic timing reasons. This
"inversion-of-control" pattern can be applied to negotiate timing
sensitive reception and transmission windows, it let's the L2 layer
deterministically timestamp information elements just-in-time with
internal radio timer counter values, etc.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
ffcae5f029 net: l2: ieee802154: separate CCA and retransmission
The IEEE 802.15.4 standard clearly separates clear channel assessment
from retransmission. This separation of concern was not represented in
the current channel access vs. retransmission implementation which
resulted in considerable duplication of code and logic.

This change removes the duplication of logic and encapsulates the
resulting functions in a private API that may only be used from within
Zephyr's native L2 layer.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
5827066ca9 net: l2: ieee802154: radio: fix csma/ca algorithm
The CSMA/CA algorithm had multiple issues:

- Timing of backoff periods depends on the PHY's symbol rate and other
  PHY-specific settings. We introduce a preliminary solution that works
  with current drivers. A fully standard-compliant long-term solution
  has already been conceptualized but requires further pre-conditions,
  see #50336 (issuecomment-1251122582).

- We enforce the condition defined in the standard that macMinBe must be
  less than or equal macMaxBe.

- According to the standard a CSMA/CA failure should lead to immediate
  abortion of the transmission attempt, no matter how many
  retransmissions have been configured.

- The number of retransmissions was off by one. It is now used as
  defined in the standard algorithm.

- Retransmissions are only allowed when acknowledgement is requested in
  the packet.

- prepare_for_ack() has side effects and must be called before each
  retransmission.

We also replace variables by constants where possible.

The function was renamed as it represents unslotted CSMA/CA and does not
support other CSMA/CA modes. These may be introduced in the future.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
f08b70549f net: l2: ieee802154: radio: fix aloha algorithm
The ALOHA algorithm had two minor implementation errors:

- The number of retransmissions was off by one.

- Retransmissions are only allowed when acknowledgement is requested
  otherwise it is to be assumed that the transmission was successful.

- prepare_for_ack() has side effects and must be called before each
  retransmission.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Florian Grandel
6bfa52afe5 net: l2: ieee802154: fix CSMA/CA configuration ranges
The allowable ranges of several CSMA/CA-related settings were not
conforming to the standard, see IEEE 802.15.4-2020, section
8.4.3.1, table 8-94 (MAC PIB attributes). This change fixes the ranges.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 16:20:21 -04:00
Ingar Kulbrandstad
ce3317d03e Bluetooth: Mesh: Updated ACL configuration settings
Setting default value for BT_BUF_ACL_TX/RX_SIZE and
BT_CTLR_DATA_LENGTH_MAX to 37, as this will process the
incoming data the most efficient way.
When GATT is enable BT_BUF_ACL_RX_SIZE does not have to be 73,
as this will just give segmented messages for the public keys
exchange during provisioning.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-06-17 08:06:16 -04:00
Pavel Vasilyev
47e3c5386a Bluetooth: Mesh: Add option to disable Label UUIDs recovery
After adding support for virtual addresses with collision (where two
Label UUIDs have the same virtual address), the format of the data in
the persistent storage with the Label UUIDs which a model is subscribed
to or publishes to has been changed. The recovery code is added and the
Label UUIDs will be recovered by picking first Label UUID matching to
the virtual address in the subscription list or model publication. This
options can disable the recovery code and save some flash if the
recovery is not required (e.g. virtual address support wasn't enabled
before this option was added, or the devices were unprovisioned before
upgrading to the version with this option).

Making this option as deprecated to be able to drop support of this
option and remove the recovery code eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 08:00:55 -04:00
Pavel Vasilyev
648378b292 Bluetooth: Mesh: Add full virtual addresses support
This commit adds the following features related to virtual addresses
support:
- Allows to store Label UUIDs which virtual addresses collide;
- Allows to decrypt messages encrypted with a virtual address with
collision;
- Allows to publish a message to a specific Label UUID to avoid virtual
addresses collision by adding a pointer to Label UUID to
struct bt_mesh_msg_ctx and struct bt_mesh_model_pub;
- Allows to differentiate Label UUIDs in the model's Subscription List
by storing all subscribed UUIDs in struct bt_mesh_model.uuids field.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 08:00:55 -04:00
Pavel Vasilyev
1956b06ecc Bluetooth: Mesh: Don't poll friend when sending over loopback
When LPN sends a segmented message to itself, it unnecesseraly polls
Friend. Since Friend doesn't receive this message, the segmented message
transmission will eventually fail (send end callback will return error),
while the message will actually be passed to the access layer.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 08:00:55 -04:00
Théo Battrel
37cac7f2e2 Bluetooth: Host: Use custom API for Bluetooth settings
This commit wrap the `settings_set_one` and `settings_delete` functions
in `bt_settings_store_one` and `bt_settings_delete`. By doing that the
Bluetooth settings can be managed in a single place.

This commit also introduce a new API to manage Bluetooth storage with
`bt_settings_store_*` and `bt_settings_delete_*` functions. Each
Bluetooth settings key have their own store and delete functions. Doing
that so custom behavior for key can be done if necessary.

This change is motivated by a need of keeping track of different
persistently stored settings inside the Bluetooth subsystem. This will
allow a better management of the settings that the Bluetooth subsystem
is responsible of.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-17 07:58:07 -04:00
Daniel Leung
e734911c96 ztest: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
c1d9dc4f18 rtio: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
c51d80fd40 random: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
1e1ab38bf0 net: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
cacefd4c33 mgmt: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel Leung
057ceb1408 logging: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Ajay Parida
041201b0d1 net: wifi_mgmt: Reject TWT setup till IP address is configured
If a user tries to enable TWT too early in the connection, then we might
enter TWT sleep even before DHCP is completed, this can result in packet
loss as when we wakeup we cannot receive traffic and completing DHCP
itself can take multiple intervals. Though static ip address can be
assigned too. Reject TWT till Wi-Fi interface has
a valid IP address.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-17 07:56:17 -04:00
Gerard Marull-Paretas
b617f03439 bluetooth: controller: rv32m1: configure debug pins in DEBUG_INIT
The debug pins were configured in a board specific file, however, the
subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h file
already contains board-specific pins, meaning there's no need to split
the information in 2 places. Move the GPIO configuration calls to the
DEBUG_INIT() macro in the controller debug header.

Note that in the future, Devicetree should be used to provide a
hardware-agnostic debug module.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-17 07:50:21 -04:00
Morten Priess
3cecb92e53 Bluetooth: controller: Fix CIS peripheral conditional offset_min
When config BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START is enabled, the
minimum accepted offset value in the CIS_REQ is the minimum defined by
the spec.
Add define CIS_MIN_OFFSET_MIN with value 500 us, as defined in the Core
spec. The previously used value of 400 us was incorrect.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-06-17 07:48:01 -04:00
Bjarki Arge Andreasen
22152915ab drivers/gsm_ppp: Update existing modules to use PPP L2
This commit replaces the workarounds spread around the
drivers and subsystems with the updated PPP L2
interface.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-06-17 07:46:21 -04:00
Bjarki Arge Andreasen
df88664864 subsys/net/ppp: Make NET L2 PPP use net_if properly
Currently, the L2 PPP subsystem is not using the network
interface subsystem appropriately. Here are the issues:

1. net_if_up hidden away internally in net L2 PPP
2. net_if_down not used at all...
3. net_if_carrier_on / off is not used, a workaround is
   used instead, which results in duplicated code
4. L2 PPP does not listen for network events, instead
   it needs the workaround callbacks from drivers.
5. The carrier_on workaround is delegated to a complex
   and broken sys work queue item.

This commit fixes all above issues. net_if_up/down and
net_if_carrier_on/off now work as expected. workaround
for carrier_on/off has been removed.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-06-17 07:46:21 -04:00
Aleksandr Khromykh
29895d8275 Bluetooth: Mesh: refactor mesh to use both tinycrypt and psa based crypto
A mesh key type has been added to be able to choose the different
key representation for different security libraries.
The type as well as some functionality related to Mesh key
management has been added as a public API.
If tynicrypt is chosen then keys have representation
as 16 bytes array. If mbedTLS with PSA is used then keys are
the PSA key id. Raw value is not kept within BLE Mesh stack
for mbedTLS. Keys are imported into the security library
and key ids are gotten back. This refactoring has been done
for the network(including all derivated keys), application,
device, and session keys.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-17 07:46:03 -04:00
Guangfu Hu
335278d60a sensing: initial sensor list and enumerate each sensor
Implement sensing_init():
	1) create sensors from device tree
	2) sequence sensors following node dependency ordering rule generated by
	   Zephyr DTS
	3) initial each sensor, includes:
		a) creating sensor connection between reporter and client,
		b) calling sensor init callback,
		c) setting sensor state
Implement sensing_open_sensor():
	1) malloc connection from reporter to application
	2) bind connection
Implement sensing_close_sensr():
	1) unbind connection
	2) free connection from reporter to application
Implement sensing_set_config():
	1) call set_interval
	2) cann set_sensitivity
Implement sensing_get_config():
	1) call get_interval
	2) call get_sensitivity

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
2023-06-17 07:43:25 -04:00
Zhang Lixu
25ca09ea01 sensing: phy_3d_sensor: add phy_3d_sensor skeleton
Add the sensor phy_3d_sensor skeleton in Sensing Subsystem.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-06-17 07:43:25 -04:00
Zhang Lixu
685160b4bf sensing: add Sensing Subsystem skeleton
Add Sensing Subsystem skeleton.

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-06-17 07:43:25 -04:00
Emil Gydesen
118a68518a Bluetooth: Shell: bt connect-name should only attempt connectable
The auto-connect by name did not verify that the found device
was connectable before attempting to connect.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-17 07:38:40 -04:00
Pavel Vasilyev
c301ed07ca Bluetooth: Mesh: Regenerate private beacon even when disabled
Even if PRB state is disabled, PRB can still be sent over GATT if Proxy
Privacy parameter is enabled. In such case PRB won't be regenerated.
To keep the privacy of the network, PRB should be regenerated when sent
over GATT regardless of PRB state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Pavel Vasilyev
dfb8bcaf38 Bluetooth: Mesh: Fix Proxy Privacy parameter support
According to section 6.7, upon connection Proxy Server shall determine
value of Proxy Privacy parameter (sections 6.5 and 7.2.2.2.6). Depending
on that, it will either send Secure Network Beacon or Private Beacon to
Proxy Client, but never both.

Proxy Privacy parameter is determined by GATT Proxy, Node Identity
states and their private counterparts (section 7.2.2.2.6). Since
non-private and private states are mutually exclusive, it is enough to
only check either Private GATT Proxy state or Private Node Identity
state of any known subnet for which the state is currenty enabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Pavel Vasilyev
c952cf4818 Bluetooth: Mesh: Fix binding between proxy related states
Fix binding between GATT Proxy, Node Identity and their private
counterpart states according to sections 4.2.45.1 and 4.2.46.1
accordingly. When non-private state is enabled, the private counterpart
is disabled. The reverse binding prohibits change of non-private state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Pavel Vasilyev
2d13329eca Bluetooth: Mesh: Store Private GATT Proxy state persistently
State should be stored persistently.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-17 07:37:20 -04:00
Jonathan Rico
931a089e2c Bluetooth: host: invalidate the RPA when starting legacy adv
This fixes the failure to use a resolvable private address in this
scenario.

1. call `bt_le_oob_get_local`, will generate and mark RPA as valid
2. start connectable adv w/ IDENTITY bit
3. start connectable adv w/o IDENTITY
4. RPA is not set (in `bt_id_set_private_addr`) because RPA
   is still marked as valid

When EXT_ADV is enabled and the controller supports it, a different code
path is taken that doesn't have this issue.

Unconditionally invalidating the RPA when starting advertising works around
this issue.

Fixes #56326

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-06-17 07:36:58 -04:00
Alberto Escolar Piedras
8444343511 usb: device: class: rndis: Fix for 64bit platforms
Instead of assuming pointers are 32bits wide,
cast them to the appropriate pointer arithmetic type.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-06-17 07:36:36 -04:00
Donatien Garnier
cf0350e021 Bluetooth: Host: Re-order LE L2CAP connection accept procedure
Currently, when an incoming dynamic LE L2CAP connection is requested by
a peer, the connected() callback provided by the user is raised
*before* a L2CAP_LE_CREDIT_BASED_CONNECTION_RSP is sent back to the
peer.
In some cases the user will start sending data in the connected()
callback which would be received too early by the peer.
This commit fixes this behavior by making sure the connected() callback
is raised only after the connection response has been sent to the peer.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-06-17 07:33:11 -04:00
Florian Grandel
b224a099fd net: l2: ieee802154: standardize RSSI value
The RSSI value in net_pkt (net_pkt_cb_ieee802154.rssi) was used
inconsistently across drivers. Some drivers did cast a signed dBm value
directly to net_pkt's unsigned byte value. Others were assigning the
negative value of the signed dBm value and again others were offsetting
and stretching the signed dBm value linearly onto the full unsigned byte
range.

This change standardizes net_pkt's rssi attribute to represent RSSI on
the RX path as an unsigned integer ranging from 0 (–174 dBm) to 254 (80
dBm) and lets 255 represent an "unknown RSSI" (IEEE 802.15.4-2020,
section 6.16.2.8). On the TX path the rssi attribute will always be
zero. Out-of-range values will be truncated to max/min values.

The change also introduces conversion functions to and from signed dBm
values and introduces these consistently to all existing call sites. The
"unknown RSSI" value is represented as INT16_MIN in this case.

In some cases drivers had to be changed to calculate dBm values from
internal hardware specific representations.

The conversion functions are fully covered by unit tests.

Fixes: #58494

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 07:16:32 -04:00
Théo Battrel
363676764a Bluetooth: Host: Fix wrong ID being stored
Fix an issue causing a wrong Bluetooth identity value to be stored. It
was happening because the `bt_dev.id_count` was incremented after the
settings being stored.

To fix this, `bt_dev.id_count` is now incremented right before the ID
creation and is decremented if the ID creation failed.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-16 07:57:46 -04:00
Mingjie Shen
b2c00ec032 net: utils: fix offset used before range check
This use of offset 'i' should follow the range check.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-06-16 05:46:05 -04:00
Maxim Adelman
ecf2cb5932 kernel shell, stacks shell commands: iterate unlocked on SMP
call k_thread_foreach_unlocked to avoid assertions caused
by calling shell_print while holding a global lock

Signed-off-by: Maxim Adelman <imax@meta.com>
2023-06-15 05:55:56 -04:00
Jamie McCrae
1edc8cc762 mgmt: mcumgr: grp: img_mgmt: Fix using signed values
Fixes wrongly using signed values for slot and image number when
listing images.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-14 13:47:08 -04:00
Ajay Parida
6002061efe net: wifi_mgmt: Pass address instead of value as pointer
Fix for not getting expected event information at application.
net_mgmt_event_notify_with_info() expects the address
not the value as pointer.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-13 08:28:43 -04:00
Jamie McCrae
5f9737f482 mgmt: mcumgr: fs_mgmt: Fix duplicate bool ok variables
Fixes wrongly declaring duplicate local variables that already
exist and hiding the previous variables definitions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-13 07:10:43 -04:00
Emil Gydesen
7bce75bd0d Shell: Add missing long long type in shell_strtoull
shell_strtoull used a unsigned long instead of a unsigned
long long to store the result in stroull, so the return
value may have been truncated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-13 07:08:04 -04:00
Juha Heiskanen
d6c85c2f59 net: coap: CoAP reply handler fix
Fix corner case when client RX request with same token than
own request where it wait responses.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-06-13 07:06:08 -04:00
Pavel Vasilyev
8902de75eb Bluetooth: Mesh: Print UUID with correct endianess
bt_uuid_str expects UUID in little endian while UUID encoded into
unprovisioned mesh beacon is encoded in big endian. sys_memcpy_swap will
change endianess of uuid so that bt_uuid_str can be used.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-13 07:05:21 -04:00
Pavel Vasilyev
21b5d423e8 Bluetooth: Mesh: Fix printing UUID log message
CONFIG_BT_MESH_PROV_DEVICE_LOG_LEVEL_INF may not be present while
CONFIG_BT_MESH_PROV_DEVICE_LOG_LEVEL is always present.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-13 07:05:21 -04:00
Tomasz Moń
ae6c856128 usb: device: class: rndis: Limit response length
Prevent potential buffer overflow when encapsulated response is more
than CONFIG_USB_REQUEST_BUFFER_SIZE. Log error and truncate response if
USB control transfer request buffer is not large enough.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-06-13 07:02:49 -04:00
Emil Gydesen
bb81b42861 Bluetooth: TBS: Ensure that inst exist when notifying terminate
When calling the `terminate_call` the `inst` would always be NULL
as we had just terminated the call that we attempted to look up.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-13 07:00:02 -04:00
Florian Grandel
d451895907 net: l2: ieee802154: fix buffer pointer ref
The uncast reference caused a cbprintf() warning on the console.

Fixes: #59125

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-13 06:58:57 -04:00
Florian Grandel
8d8faae3e7 net: l2: ieee802154: shell: fix printing ext addr
A bug was introduced in one of my earlier commits: The shell does no
longer print the full extended address. Fixes the issue.

Fixes: #59125

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-13 06:58:57 -04:00
Florian Grandel
378f0dd29d net: lib: zperf: fix kernel panic due to invalid thread prio
Compiling an application with CONFIG_NET_ZPERF=y leaving
CONFIG_ZPERF_WORK_Q_THREAD_PRIORITY at its default value would
systematically cause a kernel panic during thread initialization.

The Kconfig variable is NUM_PREEMPT_PRIORITIES by default. Application
threads may not define a priority lower than NUM_PREEMPT_PRIORITIES - 1,
though.

This change limits zperf's thread priority to a valid range. It does not
change the default value as it makes sense to default the thread
priority to the lowest possible value (which is NUM_PREEMPT_PRIORITIES)
but Kconfig does not allow for arithmentic. So the combination of
CLAMP() plus the Kconfig default will ensure min priority plus limit the
range to valid values no matter what has been defined as priority in
Kconfig.

Fixes: #59141

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-13 06:58:15 -04:00
Robert Lubos
8287e56fa3 net: context: Verify that laddr was set before use in connect
In previous patch fixing this issue, I've missed the fact that offloaded
drivers would not set the context->local address, which resulted in a
regression, where the previously introduced assert would hit in
offloaded cases. Not setting laddr is not a problem in case of
offloading, as it's only used in net_tcp_connect() which would not be
reached in this case.

Therefore I propose to remove previous patch to get rid of regression.
As an alternative fix, verify the laddr just before use, so that it is
only checked when native net stack is in use.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-12 14:03:04 -04:00
Robert Lubos
ad33d03dce Revert "net: context: Fix ambigous pointer check in net_context_connect()"
This reverts commit 22b889e3b4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-12 14:03:04 -04:00
Chaitanya Tata
1b7ef97c31 net: l2: ethernet: Fix IPv6 Kconfig
Function net_if_ipv6_addr_rm is only defined for NATIVE_IPV6.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-12 07:40:43 -04:00
Vinayak Kariappa Chettimada
fc210a8cee Bluetooth: Controller: Fix disable all advertising sets
BlueZ stack in Linux distributions use disable all
advertising sets when advertising is turned off.

Add missing implementation to support disabling all
active advertising sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-12 07:28:25 -04:00
Vinayak Kariappa Chettimada
05aabdc6d9 Bluetooth: Controller: Rework internal header includes
Rework internal header files to not have includes, rather
have the required includes in the c source files.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-12 06:20:24 -04:00
Carles Cufi
22f73992b2 Bluetooth: Rework the HCI header set
In order to have clean, self-contained HCI headers that do not have any
dependencies towards the Host or any other part of the system (except
types), reorganize the headers in the following way:

- Split out the macros and structs from hci.h to a new hci_types.h
- Merge the existing hci_err.h into the new hci_types.h

Fixes #58214.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-12 06:20:24 -04:00
Lars Knudsen
a7254b85e1 shell: Fix BT verbose scan logging
Fix endianness printout of values.

Handle service data output with initial UUID.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-06-11 05:08:08 -04:00
Emil Gydesen
7712f81171 Bluetooth: CAP: Shell: Add cmd_cap_initiator_unicast_cancel
Add cmd_cap_initiator_unicast_cancel to call the cancel
function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:39 -04:00
Emil Gydesen
e9c1be88ca Bluetooth: CAP: Add Initiator cancel procedure
Add function to cancel any current proecedure. This is useful
in cases where the connection to one or more acceptors is lost
or if some acceptor does not respond to our requests for whatever
reason.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:39 -04:00
Emil Gydesen
65c2f8ef37 Bluetooth: BAP: Release stream on codec config if requested
An ASCS endpoint may go into either the idle or codec configured
state when a stream is released. However since we have such a high
coupling between audio streams and endpoints, we need to consider
the endpoint as having been released (i.e. gone to the IDLE state).

This is handled by a boolean state variable for now, but we may
want to consider a more generic approach where streams and
endpoints may be less coupled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:15:37 -04:00
Emil Gydesen
f3f8380296 Bluetooth: BAP: modify when ASCS disconnects the CIS
When an audio stream in a bidirectional CIS is released,
it should not disconnect the CIS if there is still a stream
for the opposite direction streaming. Only if both streams
are not in a streaming state, should ASCS attempt to disconnect
the CIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:15:37 -04:00
Emil Gydesen
bc89eabfdd Bluetooth: BAP: Remove bad log error from bt_audio_valid_codec
There was a LOG_ERR from debugging.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:14:12 -04:00
Emil Gydesen
1a3fd597a8 Bluetooth: ISO: Log status as hex instead of decimal
Log status values in events as hex instead of decimal
to make it easier to compare to the spec and hci_err.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-09 14:16:15 -04:00
Lars Knudsen
fb408077df shell: Fix shell_vfprintf when vt100 is disabled
Without this fix, for every call to shell_vfprintf,
a prompt string and vt100 codes are printed too,
resulting in mangled log output.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-06-09 11:44:49 -04:00
Emil Gydesen
028e0a3c8d Bluetooth: Shell: On disconnect set new default_conn
When a device disconnects we previously just unref'ed it and
set default_conn = NULL. However, if we are connected to mulitple
devices, it makes sense to set the default_conn to one of the
other connections.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-08 11:50:34 -04:00
Emil Gydesen
f282ce90cc Bluetooth: MPL: Modify parse_search to use bt_data_parse
Modify the implementation of parse_search to use a
net_buf_simple and bt_data_parse to parse the LTV
search structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-08 11:49:58 -04:00
Carles Cufi
c0c2c6e35c Bluetooth: Host: Set valid default for secondary adv phy
Set the secondary advertising PHY to a valid value when using
legacy advertising through the LE Set Extended Advertising Parameters
command.

Fixes #57885.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-08 09:33:30 -04:00
Nathan Olff
685476d7e0 tracing: sysview: implement SEGGER_SYSVIEW_APP_NAME
Implement APP_NAME define in Kconfig for Segger SystemView module.
Use APP_NAME in Systemview initialization function

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2023-06-08 06:51:03 -04:00
Nathan Olff
833a228db4 tracing: sysview: implement RTT channel selection through KConfig
Implement Kconfig value for selecting the RTT channel to be used
by Segger SystemView

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2023-06-08 06:51:03 -04:00
Vinayak Kariappa Chettimada
466f3e8e70 Bluetooth: Controller: Fix cis_offset_min to have additional margin
As the coarse tick of ACL prepare and CIG prepare jitter by
+/- 1 tick, hence when initially scheduling the CIG place it
with enough margin so that cis_offset_min calculated when
there already exists a CIG can be larger than peer's
cis_offset_min being negotiated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:50:41 -04:00
Vinayak Kariappa Chettimada
4195ba5870 Bluetooth: Controller: Fix read ISO Tx Sync for Broadcast ISO
Fix missing read ISO Tx Sync for Broadcast ISO feature.

Co-authored-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:48 -04:00
Vinayak Kariappa Chettimada
48f6411416 Bluetooth: Controller: Fix Broadcast ISO interval unit
Fix incorrectly stored Broadcast ISO interval in
microseconds instead of storing in 1.25 ms units.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:48 -04:00
Vinayak Kariappa Chettimada
52c5ce97d4 Bluetooth: Controller: Update BT_CTLR_ISOAL_SN_STRICT help text
Update BT_CTLR_ISOAL_SN_STRICT help text.

Co-authored-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:25 -04:00
Vinayak Kariappa Chettimada
5f38c4ba71 Bluetooth: Controller: Fix Tx ISO SDUs dropped due to strict SN check
Introduce a Kconfig BT_CTLR_ISOAL_SN_STRICT to relax the Tx
ISO Data SDUs being dropped due to strict check of sequence
numbers in ISOAL, i.e. dropped when ISO Data SDUs are
delayed from upper layer with respect to the current
payload number in the ISO radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:25 -04:00
Vinayak Kariappa Chettimada
54aa6f1075 Bluetooth: Controller: Fix ISOAL sink create role for ISO Receiver
Fix ISOAL sink create role for ISO Receiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 12:25:31 +02:00
Pavel Vasilyev
242c8f1c77 Bluetooth: Mesh: Avoid undefined behavior in bit shift in blob_cli.c
block_size_log can be 0x20 which will shift 1 by 32 bits which will
cause undefined behavior. Adding ULL to 1 is an option but this will add
little bit more code when debug option is enabled. So simply print the
logarithmic value.

Coverity-ID: 316387
Fixes #58951

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-08 04:11:29 -04:00
Théo Battrel
cfd368fef1 Bluetooth: Host: Fix GATT server handling of CCC
GATT server was not doing enough check before udpating the CCC.

For example, a non-bonded client could update the CCC of a bonded client
by spoofing his address.

This fix the issue by dissociating the CCC configuration of a bonded and
a non-bonded peer. To do that, a new field is added to the CCC config:
`link_encrypted`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-08 04:10:58 -04:00
Lingao Meng
b6fc474777 Bluetooth: Mesh: Fix unable sent mesh message
In PR (#58723) has introduce another bug, that,
the flag ADV_FLAG_PROXY set before actually enabled.

When ctx:: BT RX call schedule_send will atomic_test_and_clear
ADV_FLAG_PROXY, but at this time, the proxy advertising will
not at advertising state, maybe in update params or set adverting
data phase,

so that, call bt_le_ext_adv_stop will nothing, and then call
k_work_reschedule --> send_pending_adv(at this time, the proxy
advertising actually enabled, but the upper layer clear proxy flags),
cause latest advertising unable start, because unable in advertising
state to update params(-EINVAL).

Fixes: #58721

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-06-08 04:09:04 -04:00
Robert Lubos
22b889e3b4 net: context: Fix ambigous pointer check in net_context_connect()
Coverity reported, that laddr pointer used in net_context_connect()
could be passed as NULL to net_tcp_connect() where it could be
dereferenced. This is because the actual setting of laddr to a valid
address structure was only done after
net_sin/sin6_ptr(&context->local)->sin/sin6_addr verification.

In practice though, the aforementioned pointer verification would always
pass, as the bind_default() guarantee that the context->local address is
set to an unspecified address (if it hasn't been set earlier).

Therefore refactor the code a bit: replace the pointer verification
with NET_ASSERT - only to assure that we can catch regression in case
for any reason the behavior of bind_default() changes. This should also
ensure that Coverity no longer reports that laddr is NULL when reaching
net_tcp_connect().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 19:43:20 -04:00
Robert Lubos
233524f471 net: ieee802154_mgmt: Fix memcpy to uninitialized pointer location
As since commit bff6a5c, params.dst.ext_addr is no longer assigned with
the ctx->coord_ext_addr pointer, but a endianness swap is included, it
should be assigned with a proper buffer before the memcpy.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:12:18 -04:00
Robert Lubos
f9a818cc56 net: websockets: Fix implicit type conversion Coverity warning
Coverity reported potential issues with implicit signed/unsigned type
conversions and potential problems with this. Fix this, by casing the
byte-shifted data variable to uint64_t type explicitly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:11:46 -04:00
Robert Lubos
e5aa433f87 net: lwm2m: Fix pointless variable assignment
Coverity reported that assigning ret = 0 is pointless, as in any
scenario (loop continues or ends) the ret variable is overwritten
anyway, w/o using the assigned value. Therefore remove the needless
assignment.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:07:09 -04:00
Robert Lubos
479036165c net: lwm2m: Fix possible out-of-bound access when creating FW object
obj_inst_id should not be used directly to index the instance array, as
the instance ID is not tightly bound to the maximum instance count and
can exceed this value, causing out-of-bound access.

Therefore, perform some extra validation when choosing the array index
for the object instance to make sure we stay in the array bounds, or
return an error if there's no more room for more object instances, in a
similar way it's done for Security object.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:06:52 -04:00
Robert Lubos
e96f1d7b47 net: lib: coap: Fixed unchecked send return value in CoAP client
The retransmission attempt in CoAP client library did not verify the
send result.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:06:29 -04:00
Robert Lubos
7deabaa77b net: tcp: Fix possible double TCP context dereferencing
In case TCP connection is being closed from the TCP stack, due to for
instance retransmission timeout, the stack should also switch the TCP
state to CLOSED. Otherwise, there was a risk of dereferencing the TCP
context twice, for example if the application was in active socket
send(), and tried to reschedule data transmission.

Additionally, make sure that the TCP_CLOSED state handling is a no-op
state - otherwise, there is a risk that if packets keep incoming before
the application dereferences the TCP context on its side, TCP stack
will incorrectly dereference the context for the second time from
within due to current TCP_CLOSED state logic.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-06 11:11:22 -04:00
Mariusz Skamra
a84ecc2f96 Bluetooth: audio: tbs_client: Remove GATT subscriptions upon disconnection
As long as we do not have NVS support in TBS, the subscriptions shall be
removed once ACL is disconnected to avoid potential crash on
reconnection, as the subscription parameters might be not valid anymore.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-06 11:10:10 -04:00
Mariusz Skamra
2d593a1e8d Bluetooth: audio: tbs_client: Fix missing cleanup
This fixes repeated attempt to bt_tbs_client_discover that failed
because srv_inst->current_inst was not cleared during previous discovery
process. The issue seen in case the GATT Read CCID returned an error.
The code has been factored out to separate helper function.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-06 11:10:10 -04:00
Mariusz Skamra
6656d33a90 Bluetooth: audio: tbs_client: Fix possible override of GATT read parameters
This fixes missing guard access to GATT read parameters.
The code checks `busy` flag and returns an error in case there's ongoing
GATT Read operation already.

Fixes: #58425
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-06 11:10:10 -04:00
Mark Oude Elberink
67dd58418f net: mqtt-sn: fix port in mqtt-sn debug message
The port we are connecting to is stored in network byte order,
thus, we need to convert it to the CPU's byte order before logging

Signed-off-by: Mark Oude Elberink <mark@oude-elberink.de>
2023-06-06 09:40:52 -04:00
Armin Brauns
fdde5bd7ef net: tcp: populate context's local address for incoming connections
`local_addr` would only be initialized if `context->local->sin*_addr` was
non-null. However, since `context` is a fresh context object, `local_addr`
always remains at its initial value of `INADDR_ANY`, which is propagated to
the context by `net_context_bind()`.

By populating `local_addr` using the TCP endpoint, `getsockname()` now
returns the correct local address.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-06-06 09:40:36 -04:00
Seppo Takalo
a1cfe983b6 net: lwm2m: Allow overiding of default socket behaviour
In order to support external IP stacks that might have Connection
ID support, the LwM2M engine should allow client to bypass default
behaviour.

New set_socketoptions() callback added into client context
that allows overriding all socket opetions. This is called
after a socket is opened, but before the connect() is
called. This cannot be combined with load_credentials() callback
on all platforms as for example nRF91 requires modem offline
when credentials are written. This would cause socket to be closed
as well.

Second change is that we allow fine tuning of what we do with
socket handle when QUEUE mode is enabled and engine enters idle
state.

First option would be to close the socket. That would cause
TLS Alert(Close Notify) to be send. This is a band choice if
LTE modem was already in PSM or eDRX power saving mode.

Second option would be to delay socket closing until we
are going to send LwM2M update. There TLS Alert is also send,
but most probably lost due to NAT mapping timed out. This
is a best choice for LTE modem with DTL session cache enabled.

Two new options are to keep socket open, and either stop listening
or just keep listening. Both of these options work fine when
we have DTLS Connection ID support.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-06 09:40:16 -04:00
Nirosharn Amarasinghe
ff89e98cc6 Bluetooth: controller: Release missing / lost SDUs for framed PDUs
-- Implemented reporting of lost / missing SDUs for framed PDUs. This
   should result in SDUs being released when only framed padding PDUs or
   error PDUs are received.
-- Removed unused configuration params structure, storage and linked
   APIs.
-- Reduced default logging level to INF instead of DBG.
-- Included debug logging messaged for framed consumption.
-- Removed separate latency_unframed and latency_framed and replaced
   with a common sdu_sync_const as they are mutually exclusive for each
   sink.
-- Restricted framed time stamp calculation only to situations where all
   dependent information is available.
-- Corrected SDU sequence numbering to release starting at zero.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Nirosharn Amarasinghe
40dde5b7bd Bluetooth: controller: fix time-wrapping of cig_ref_point
Time wrapping was omitted at some points. These were corrected or
clarified.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Nirosharn Amarasinghe
0398d8ddf6 Bluetooth: controller: Release SDU as missing if RX only unf. padding
Based on interpretation of Clarification Errata ES-22876 Request for
Clarification - Recombination actions when only padding unframed PDUs
are received, it was decided that an SDU should be released as "Missing"
when only padding PDUs are received for any SDU.
- https://bluetooth.atlassian.net/browse/ES-22876

This change will also assist streaming in the Common Central design
where the central was found to send only padding PDUs before streaming
starts.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Robert Lubos
2e0b0af44e net: lwm2m: Fix lwm2m_socket_start() error handling
In case lwm2m_socket_start() internal error, it should only do cleanup
on the socket, i. e. call lwm2m_socket_close(), not lwm2m_engine_stop().
The latter resets the entire lwm2m_context, which results in removal of
active observations.

This should not be done, as it collides with the RD client logic, where
connection resumption may skip the full registration phase, in result
not notifying the server that it should restart the observations.

At the same time, the RD client should clean the lwm2m_context when it's
done trying to update the registration and proceeds with regular
registration/bootstrap in the network error handler. In that case, only
the socket was closed, so the lwm2m_context needs to be reset
separately.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-06 06:51:34 -04:00
Emil Gydesen
c764c34232 Bluetooth: BAP: Improve handling of ASCS notification error
If the num_ase == 0xff then it is a special case that needs to be
handled like if num_ase == 0x01.

If there is an error with ase_id = 0x00 then the error cannot
be translated to a specific stream, so the callbacks may now get
NULL for the stream object.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-06 09:35:16 +02:00
Théo Battrel
7d9fe3d0b1 Bluetooth: Host: Fix GATT Store on Write
When CCC or CF store on write is disabled and the other one is enabled,
leading to the delayed store being enabled. This cause the value of the
corresponding `n` selected option to not be stored at all.

To fix this, the checks to know if we need to store the CCC or the CF,
happening at the disconnection, are now ensuring that the CCC or the CF
are stored even if the one of them does not enable store on write.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-05 13:54:37 -04:00
Emil Gydesen
6652eb7be8 Bluetooth: Shell: Update framing and packing checks in cmd_cig_create
The checks are now less generic and avoids a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 10:50:11 -04:00
Emil Gydesen
07f986b2e8 Bluetooth: BAP: Remove lower check in BT_BAP_BASS_VALID_OPCODE
Remove the lower check (BT_BAP_BASS_OP_SCAN_STOP) in
BT_BAP_BASS_VALID_OPCODE as it is always used on unsigned
variables, so no point in check if it is lower than 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 10:49:29 -04:00
Dominik Ermel
f9ebb72a9f nvs: Fix missing nvs_ate.part init in nvs_add_gc_done_ate
Add initialization.

Fixes #58691

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-06-05 10:49:15 -04:00
Emil Gydesen
1b9645c6a6 Bluetooth: BAP: Broadcast assistant add idx check for read recv state
Add check for the index in the function itself, as well as where
we call it internally, to ensure that we do not attempt to access
invalid indexes of broadcast_assistant.recv_state_handles.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 10:48:45 -04:00
Mariusz Skamra
0f44fac75c Bluetooth: audio: has: Fix conditional check
This fixes missing `CONFIG_*` prefix.
The `BT_HAS_PRESET_CONTROL_POINT_NOTIFIABLE` option is already guarded
with `BT_HAS_PRESET_SUPPORT`, so it has been removed from `depends on`
condition.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-05 16:24:18 +02:00
Mariusz Skamra
21599a6b14 Bluetooth: audio: has: Fix building with preset support disabled
This fixes regression causing compilation errors seen when the
code is built without preset support (BT_HAS_PRESET_COUNT = 0).

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-05 16:24:18 +02:00
Dominik Ermel
5cdfeffea1 nvs: Fix writing uninitialized nvs_ate.part on close
nvs_sector_close has not been initializing nvs_ate.part, before
writing it to flash.

Fixes #58699

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-06-05 08:33:34 -04:00
Emil Gydesen
192a236c0f Bluetooth: TBS: Added assert in discover_next_instance for inst lookup
Added assert when looking up the next instance, as the caller of this
function should ensure that the index is correct before calling
discover_next_instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:33:16 -04:00
Emil Gydesen
ba7fde1bae Bluetooth: Audio: Shell: Fix use of IN_RANGE when MIN is 0
If the minimal value of an IN_RANGE is 0, then it is
a useless check, and the cases have been modified to
not use IN_RANGE. This also fixes some coverity issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:32:43 -04:00
Emil Gydesen
4e1020e742 Bluetooth: BAP: Fix bad check in audio_stream_qos_cleanup
The check was a && but should have been an ||. Fixed by moving
the check to a new if statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:32:27 -04:00
Emil Gydesen
bff6eca6d4 Bluetooth: TBS: Add missing NULL check when notifying terminate
When notify_app is called for BT_TBS_CALL_OPCODE_TERMINATE
we did a lookup on the call index, but never did a NULL check
before dereferecing it.

This does not fix the issue that the instance will always
be NULL in this case, as we have terminated the call so
we cannot possibly look up the call afterwards.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:32:03 -04:00
Emil Gydesen
738e23efb8 Bluetooth: TBS: Fix copy of friendly name
The friendly copy always assumed that the friendly name could
fit in memory, which could cause overflows. Fixed by using
utf8_lcpy as that not only ensures that the copy is truncated
to fit in memory, but also ensures that it is null terminated
and truncated in a way that supports multi-byte UTF8 characters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:31:46 -04:00
Aleksander Wasaznik
a4e7b53d4b Bluetooth: Host: Fix bt_addr_from_str for str starting with ':'
The previous implementation would read from `addr->val[0]` before it was
initialized if the input string started with a colon ':'.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-05 08:31:06 -04:00
Emil Gydesen
09c1d412af Bluetooth: ASCS: Add missing return check for bt_conn_get_info
We never checked the return value before accessing the
returned information.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 08:30:10 -04:00
Anders Storrø
e4c7ce3316 Bluetooth: Mesh: Remove unintentional dbg string
Remove debug string that accidentally got merged to
the mesh shell cfg file.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-06-05 08:29:14 -04:00
Emil Gydesen
b49d981e36 Bluetooth: BAP: Unicast client add stream->conn checks
Add checks for the stream->conn before we attempt to use it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:07:28 -04:00
Jamie McCrae
942fc8517f mgmt: mcumgr: grp: fs_mgmt: Fix unchecked return value
Fixes a coverity issue whereby a return value was not checked.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-05 07:06:37 -04:00
Emil Gydesen
9c13b85665 Bluetooth: OTS: Fix offset maximum range check
If offset is only 32-bit, then it can never be > UINT32_MAX,
so added another conditional that only if the type (off_t) is
larger than 32-bit, we perform the maximum value check.

off_t is not a standard type and thus the size of it is poorly
defined, and are just defined as a signed integer type.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:06:19 -04:00
Emil Gydesen
7435c66972 Bluetooth: IAS: Fix coverity issue with IAS client lvl check
The check compared the levels against < BT_IAS_ALERT_LVL_NO_ALERT
which of course does not make sense given than the lvl_u8 is an
unsigned value that can never be < BT_IAS_ALERT_LVL_NO_ALERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:59 -04:00
Emil Gydesen
448bb4ca55 Bluetooth: Audio: Shell: Use unsigned long long for OTS IDs
Use unsigned long long and shell_strtoull to get the ID of
OTS objects, as unsigned long may not be able to store all 48
bits.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:20 -04:00
Emil Gydesen
de3e709b50 Shell: Add shell_strtoull
Add a shell_strtoull function that works similar to
shell_strtoul except that it calls strtoull instead
of strtoul.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:20 -04:00
Emil Gydesen
578acd8cee Bluetooth: Shell: Ensure scan_filter.addr is null terminated
Ensure that scan_filter.addr is NULL terminated by only copying
the sizeof the buffer -1 and then always setting the last byte to
\0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-05 07:05:00 -04:00
Robert Lubos
0ae7812f6b net: dns_sd: Prevent dead code in query parsing
The number of buffer provided was verified in the final else block of a
long validation sequence. It would never be executed though, as one of
the conditions before would always evaluate to true.

As the number of buffers provided verification appears to be significant
in this case, as the buffers are referenced during other validations,
move this check at the beginning of the sequence instead. This also
eliminates the dead-code problem.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-03 04:13:46 -04:00
Pirun Lee
5ba418c442 Bluetooth: OTS: Fix coverity issue
Fixed issue Coverity CID: 316293 https://github.com/zephyrproject-rtos/zephyr/issues/58518

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2023-06-02 18:57:44 -04:00
Pavel Vasilyev
24bd211d77 Bluetooth: Mesh: Avoid dead code in access
Use if-else-endif construction to avoid dead code.

Coverity-CID: 316484, GitHub issue #58539

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
2b3175f2fa Bluetooth: Mesh: Avoid divizion by zero when chunk_size is zero
Avoid divizion by zero when chunk_size is zero.

Coverity-CID: 316406, GitHub issue #58531

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
ee548488cc Bluetooth: Mesh: Drop PENDING_RESET flag without checking it
Just drop PENDING_RESET flag without checking it.

Coverity-CID: 316394, GitHub issue #58530

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
617154f9d5 Bluetooth: Mesh: Avoid undefined behavior when block_size_log is 0x20
Use ULL suffix to promote the type of the shift operand to uint64_t to
avoid undefined behavior when block_size_log is 32.

Coverity-CID: 316387, GitHub issue #58528

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Pavel Vasilyev
395f250ef8 Bluetooth: Mesh: Check return value in blob server
Ignore return value of bt_mesh_model_send().

Coverity-CID: 316126, GitHub issue #58506
Coverity-CID: 316272, GitHub issue #58517
Coverity-CID: 316430, GitHub issue #58533
Coverity-CID: 316567, GitHub issue #58549

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-02 18:57:14 -04:00
Carlo Caione
9930c346af pm: policy: Selectively compile on "zephyr,power-state" compatible
Coverity is complaining:

      CID 316017:  Control flow issues  (NO_EFFECT)
  >>> This less-than-zero comparison of an unsigned value is never true.
  148      for (size_t i = 0; i < ARRAY_SIZE(substate_lock_t); i++) {

This is a false positive but we can still optimize the code and making
coverity happy by simply avoiding compiling the offending code when no
power states are defined into the DT.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-06-02 18:56:39 -04:00
Emil Gydesen
208908e293 Bluetooth: Audio: Shell: Fix long/int32_t value checks
In places where we verify that the value of the long
variable does not exceed the limits of int32_t, we do
actually not need to compare the values if the two
types are the same size, which is often the case for
32-bit systems.

This fixes a variety of coverity reported issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-02 18:56:17 -04:00
Emil Gydesen
1767621f6f Bluetooth: Shell: Change strcpy to strncpy for addr copy
When copying the address in cmd_scan_filter_set_addr we now
use strncpy to not copy more bytes than what fits. This
should already have been fixed with a check earlier in the
function, but coverity still complains.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-02 18:52:20 -04:00
Florian Grandel
4375962399 net: l2: ieee802154: document non-standard ACK feature selection
For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option must
automatically be active if the radio driver does not AUTOACK and inactive
otherwise. No user interaction is required.

Future changes will deprecate this option and replace it by a standard
compliant automatic mechanism.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-02 18:47:59 -04:00
Florian Grandel
1e2133ffa7 net: l2: ieee802154: document non-standard channel page selection
The IEEE 802.15.4 standard does not specify a "Sub-GHz" option.
Therefore this option will be deprecated in the foreseeable future.

Rationale: Selecting PHYs and frequency bands is abstracted by the
concept of channel pages (see IEEE 802.15.4-2020, 10.1.3).

Radio drivers may expose additional configuration options that
specify the low level frequency band, operating mode and other
PHY-specific parameters. Such parameters should be exposed on a driver
instance level, e.g. via devicetree or as runtime options of the driver.
PHY-specific attributes derived from driver settings (e.g. available
channels) can then be announced to L2 w/o the user having to be aware of
any implementation details of the specific PHY.

Future changes will introduce the necessary infrastructure to define
channel pages and other PHY-specific configuration options to
replace this option. New drivers should therefore not rely on this
option.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-02 18:47:59 -04:00
Robert Lubos
16fa99a887 net: coap: Validate token length in coap_header_get_token()
In theory, coap_header_get_token() should only be used on already parsed
packets, and coap_packet_parse() would detect an invalid token length in
a packet. Coverity however complains about possible out-of-bound access,
as in theory the function can return token length up to 15. Therefore
add an extra validation of the token length within the function, to
avoid out-of-bound access due to programming errors and to make Coverity
happy.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-02 15:13:41 -04:00
Krzysztof Chruściński
6718869658 logging: log_output: Fix for Coverity issue 316014
Log level is stored on 3 bits thus in theory it can be set to 7
and yet accepted levels are up to 4 thus Coverity complains.
Adding assert that prevents use of levels above 4.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-06-02 15:07:08 -04:00
Krzysztof Chruściński
314fb05166 logging: log_output: Fix for Coverity issue 316019
Adding missing casting.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-06-02 15:07:08 -04:00
Jordan Yates
bf3872a05c lorawan: initialise data structures earlier
Now that `lorawan_init` only initialises data structures and does not
start the stack or communicate with a physical device, run the init as
soon as possible. This allows `lorawan_register_downlink_callback` to
be called much earlier by other init functions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-06-01 13:44:16 -04:00
Théo Battrel
3937b25dd6 Bluetooth: Host: Fix GATT delayed store
When `CONFIG_BT_SETTINGS_DELAYED_STORE` is enabled (by default it is),
the local GATT server will delay the write to flash of the CCC and CF
values. The delay is defined by `CONFIG_BT_SETTINGS_DELAYED_STORE_MS`.
If a disconnection happen before that delay, the `bt_gatt_disconnected`
will reschedule the delayed store operation. But that operation will not
happen before `bt_gatt_disconnected` is complete, at this moment, the
CCC and CF values will have already been cleared.

To fix this issue, the delayed store operation is now done during the
`bt_gatt_disconnected` function.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-01 14:58:39 +02:00
Lingao Meng
5f9ac54e2f Bluetooth: Mesh: Fix unable sent mesh message
When proxy advertising enabled, but at same time, the
connection event report, will cause `ADV_FLAG_PROXY` not
set, so cb `connected` will not be process, cause mesh message
unable to sent.

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

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-06-01 04:52:45 -04:00
Flavio Ceolin
4f29930e4c pm: Fix cpus active count
Only set a cpu as active (on pm subsystem) when the cpu is effectively
initialized. We cannot assume on pm subsystem that all cpus were
initialized since when the option CONFIG_SMP_BOOT_DELAY is used cpus are
initialized on demand by the application.

Note that once cpus are properly initialized the subystem is able to track
their status.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-06-01 10:05:31 +02:00
Jordan Yates
c61818b065 Bluetooth: host: hci_core: handle additional error code
Some Bluetooth controllers (Nordic Softdevice) now use
`BT_HCI_ERR_INSUFFICIENT_RESOURCES` to signify when advertising sets
cannot be created, instead of the old `BT_HCI_ERR_CONN_LIMIT_EXCEEDED`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-06-01 10:04:46 +02:00
Emil Gydesen
0229dad6d2 Bluetooth: Host: ISO: Fix issue with removing central data paths
On CIS disconnect, the central will clear all data paths.

However hci_le_remove_iso_data_path will fail if attempting to remove a
data path that has not been setup, so if only the CTLR_TO_HOST
direction was set, and the HOST_TO_CTLR bit was set, the
function returned an error and never attempted to clear the other
direction.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-01 10:04:36 +02:00
Emil Gydesen
e31713de27 Bluetooth: Controller: ISO: Fix issue with removing peripheral data paths
On CIS disconnect, the peripheral will clear all data paths.

However ll_remove_iso_path will fail if attempting to remove a
data path that has not been setup, so if only the CTLR_TO_HOST
direction was set, and the HOST_TO_CTLR bit was set, the
function returned an error and never attempted to clear the other
direction.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-01 10:04:36 +02:00
Gerard Marull-Paretas
49ec35fe5e testsuite: group all test-related APIs under 'testing'
Before this change we had 2 top-level Doxygen entries for Testing APIs:

- Zephyr tests
- Zephyr testing suite

This patch creates a single top-level group to contain ZTest and FFF
extensions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-31 14:39:29 -04:00
Rander Wang
59b054fdd6 coredump: Add memory wirte pointer fo intel ADSP memory window backend
The buffer_output interface is called a few times during one core dump,
so we need to maintain a memory write pointer to prevent data overwriting.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2023-05-31 14:38:58 -04:00
Johann Fischer
02129e90d8 net: buf: fix data ref_count offset in generic_data_ref()
This patch fixes commit b70f92e570
("net: buf: keep memory alignment provided by k_heap_alloc and k_malloc").
One-line was overlooked in the above patch and may result in a
cloned net_buf using a data block that has already been freed.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-31 10:01:40 -04:00
Robert Lubos
fa5b706871 net: websocket: Implement websocket_recv_msg timeout
Although websocket_recv_msg function accepts timeout parameter, the
functionality was rather limited, allowing only to either work in
non-blocking manner, or to block indefinitely. Any timeout value
other than -1 (forever) ended up in non-blocking operation.

This PR fixes this by implementing a basic timeout mechanism, built on
top of poll(). For now on, only timeout of 0 will result in non-blocking
operation, any other timeout will make the function block for the
specified amount of time.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-31 11:07:10 +02:00
Morten Priess
5db51d3679 Bluetooth: controller: Fix reconfiguring of CIG and CISes
Up until now, it has not been possible to reconfigure a CIG and its
CISes after initial configuration, without first removing the CIG.

With this commit, le_set_cig_parameters allows the following
reconfiguration operations in configuration state:
- Set new CIG configuration parameters on existing CIG
- Iteratively configure single CIS (of more CISes)
- Increment number of CISes via multiple configuration calls
- Keep handle- and CIS_ID relation

Changes:
- Pass handles in le_set_cig_parameters from ll_cig_parameters_commit
  via output variable.
- Implement CIG state variable instead of 'started', with states
  IDLE/CONFIGURABLE, ACTIVE and INACTIVE.
- Implement ll_conn_iso_stream_get_by_id for easier access to specific
  CIS.

This fixes the following CIS Central EBQ tests:
- HCI/CIS/BI-10-C
- HCI/CIS/BI-11-C
- HCI/CIS/BI-13-C
- HCI/CIS/BV-05-C

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Morten Priess
3fd1fbeff8 Bluetooth: controller: Validate parameters for CIG configuration
Parameter checking updates for passing HCI/CIS/BI* EBQ tests.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Morten Priess
03faaa9e45 Bluetooth: host: Fix hci_le_remove_iso_data_path direction parameters
The path_dir variable of BT_HCI_OP_LE_REMOVE_ISO_PATH must be bitflags,
with the following meaning:
- BIT(0) : DIR_HOST_TO_CTLR
- BIT(1) : DIR_CTLR_TO_HOST

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Morten Priess
acd83ad794 Bluetooth: controller: Fix ll_remove_iso_path direction parameter
According to the Core spec, the direction parameter passed to this function
should be bitfields, i.e.:
- BIT(0) : DIR_HOST_TO_CTLR
- BIT(1) : DIR_CTLR_TO_HOST

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-05-30 08:59:16 -04:00
Krzysztof Kopyściński
67a33ed1a0 Bluetooth: Mesh: fix Random value generation for Private Beacons
In `private_random_update`, when first beacon is advertised, there could
be a case when uptime is less then interval * 10s
(`priv_random.timestamp` is equal to 0 for first beacon). Then, Private
Random value will not be generated and will be set to all zeros.

New Private Random must also be generated  before Random Interval
expires, when KR or IVU flags are changed. Reset timestamp to 0 on
`bt_mesh_beacon_update` to generate new Random value.

Do not generate new private random if it won't be used (Private Beacon
state is not enabled).

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-05-30 06:30:25 -04:00
Lukasz Mrugala
fe3f5816b8 testsuite: Docstring typo fix
Word 'platform' misspelled as 'platorm'.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2023-05-29 14:34:33 -04:00
Robert Lubos
e6fc53b399 net: sockets: tls: Allow to interrupt blocking accept() call
In order to allow the TLS accept() call to be interrupted, it should
release the top-level TLS socket mutex before blocking. As the
underlying TCP accept() makes no use of TLS resources, and has its own
mutex protection, it should be safe to do so.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-29 14:34:03 -04:00
Robert Lubos
76b74f007f net: sockets: Fix accept() not being interrupted on close()
The accept() so far would block with mutex held, making it impossible to
interrupt it from another thread when the socket was closed.

Fix this, by reusing the condvar mechanism used for receiving. It's OK
to use the same routine, as underneath accept() is monitoring the same
FIFO as recv().

Additionally, simplify k_fifo_get() handling in accept() - as the
waiting now takes place on condvar, it can be used in a non-blocking
manner. Blocking accept() call should not reach this place if there's no
new incoming connection waiting on the FIFO.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-29 14:34:03 -04:00
Marco Argiolas
49436dc453 net: lib: lwm2m: add missing #include to lwm2m_rd_client.h
Definition for 'struct lwm2m_ctx' was missing and build warnings were
generated.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-05-29 04:57:18 -04:00
Anas Nashif
c0469e6bbd ztest: deprecate old ztest API
Deprecate old ztest APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-28 11:35:12 -04:00
Pieter De Gendt
d4e11a173b debug: Make stack sentinel incompatible with MPU stack guard
The MPU stack guard can move the start address of a thread stack.
Don't allow both options to be enabled at the same time.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-05-27 06:29:27 -04:00
Vinayak Kariappa Chettimada
c23c5f39e7 Bluetooth: Controller: Cleanup Periodic Adv Channel Map Update
Remove redundant code and cleanup Periodic Advertising
Channel Map Update implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-26 14:57:22 -04:00
Madhurima Paruchuri
a19d905cc4 USB-C: genVIF: Cleanup and add support to pick static data from input
Removed few VIF properties which are being hardcoded
Updated the script to parse source VIF XML and add information to
the output
Added optional Kconfig option to configure custom source VIF XML path
Cleaned up the code

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-05-26 13:54:43 -04:00
Dawid Niedzwiecki
53525bb9c5 mgmt: ec_host_cmd: add support for IN_PROGRESS status
The IN_PROGRESS status is a specital status that can be sent during
handling a host command. Synchronous backends don't support it, so
an additional check is required.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Dawid Niedzwiecki
66d8e27c34 mgmt: ec_host_cmd: add a function to send response
A function to send Host Command response is needed for commands that
that sends IN_PROGRESS status or doesn't return e.g. perform reboot.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Dawid Niedzwiecki
a2b9c56ee5 mgmt: ec_host_cmd: fix checking usage of handler buffer
The usage of RX handler buffer was checked incorrectly.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Robert Lubos
2c75070360 net: sockets: tcp: Fix possible race between connect/recv
Installing recv callback with net_context_recv() after
net_context_connect() left an opening for a possible race - in case the
server send some data immediately after establishing TCP connection, and
Zephyr did not manage to install the callback on time, the data would be
lost, corrupting the stream.

This can be avoided, by installing the recv callback before the
connection is triggered. As net_context_recv() called w/o timeout only
registers the callback function, it should have no negative impact. The
only change on the TCP side is when the connection is closed - in case
TCP is in connect stage, do not call the recv callback (before this
change it'd be NULL at that point).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-26 09:55:13 -04:00
Rubin Gerritsen
9e617bdd86 Bluetooth: KConfig: Enable ISO CTLR features if host has enabled them
This ensures that when running a combined host + controller build, the
ISO features in the controller are enabled automatically.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-05-26 09:51:09 -04:00
TOKITA Hiroshi
476a5f57fd fb: cfb_shell: correct invert command implementation
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
 with the tile")

Remove the cfb_invert_area() calling.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-05-26 09:49:25 -04:00
TOKITA Hiroshi
75904f0d19 fb: correct invert_area image calculation
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
with the tile")

Fixed not enough consideration when the drawing area height
is eight lines or less.
Simplify to XOR calculation.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-05-26 09:49:25 -04:00
TOKITA Hiroshi
92efbeeec6 fb: cfb_shell: Add draw rect command
Add the `draw rect` command to execute the `cfb_draw_rect()` API.

This command render rectangle.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
59a6092849 fb: cfb: Add cfb_draw_rect() API
Add cfb_draw_rect() API for rendering rectangle.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
182c55f69f fb: cfb_shell: Add draw line command
Add the `draw line` command to execute the `cfb_draw_line()` API.

This command render line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
ea42b0dc9d fb: cfb: Add cfb_draw_line() API
Add cfb_draw_line() API for rendering line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
39c8288bab fb: cfb_shell: Add draw point command
Add the `draw point` command to execute the `cfb_draw_point()` API.

This command render single dot.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
TOKITA Hiroshi
9def1258a0 fb: cfb: Add cfb_draw_point() API
Add cfb_draw_point() API for rendering dot.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-26 09:48:56 -04:00
Johann Fischer
32668dc7fd usb: device_next: allow string descriptor index to be updated
Support for multiple instances of a class implementation,
and the ability to register an instance to a configuration
at runtime, requires a mechanism to add a string descriptor
and update its index based on the total number of descriptors.

We also need to handle some special string descriptors like
Product or Serial Number provided by the application.
Marked as such by using specific macros, these descriptors
can be sorted out by the stack and the device descriptor
indexes are updated automatically.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
8a8e9e1dfe usb: device_next: implement usbd_class_shutdown()
Implement marked as TODO usbd_class_shutdown().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
9a4ed741d6 usb: device_next: use specific macros for string descriptors
Add and use specific macros for manufacturer, product, and
serial number string descriptors.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
7e2d359e8f usb: device_next: use dlist instead of slist for descriptors list
While this does not provide much of an advantage yet,
it will allow us to add descriptors and assign an index
more easily in the next commit.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
07ef9aaed4 usb: device_next: allow selection of alternative USB device context
When we enable USBD shell support with samples like cdc_acm or mass,
there would be another USB device context besides the one provided
by the shell. This patch introduces a new command to select an
alternate context to be used by USBD shell commands.

Also fix the type where "add" command should be "remove".

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
c34ad3114c usb: device_next: allow reuse of string descriptor nodes
If we try to reuse a string descriptor node, the content will
be corrupted because the device stack assumes it is still ASCII7
encoded. Add a flag to indicate that a descriptor node contains
UTF16LE encoded content.

And while we are at it, add a flag to indicate that the SN string
should not be obtained from the hwinfo API.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
291b5a7ec3 usb: device_next: check if another context is initialized
There may be more than one context using the same device, for example,
if the shell module is enabled. Check if another context that uses
the same device is initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
99d2c2f6dd usb: device_next: do a little more cleanup on shutdown
At the shutdown of USB device stack we have to cleanup and
remove all registered class instances and string descriptors
from a configuration.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Johann Fischer
2a4d6810db usb: device_next: remove foobaz interface from common shell code
Foobaz interface will be renamed and added as a standalone part
to serve as an API example in a subsequent commit.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Jarno Lämsä
05e0b31fa8 net: lib: coap: Add an asynchronous coap client
The coap client takes requests and provides responses
asynchronously to callback given in a request.
Currently supports only 1 request at a time.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-05-26 09:44:50 -04:00
Fredrik Danebjer
7457bcf0a2 Bluetooth: Audio: Make HAS optional notify characteristics optional
Added Kconfig options to make HAS characteristics that has notify as
optional property selectable and thus optional. These settings are
global, meaning that a chosen notify property will be used for all
registered has instances.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-05-26 09:09:06 -04:00
Emil Gydesen
527591a766 Bluetooth: BAP: Fix off-by-one in shell cmd add_broadcast_id
The arguments in the shell start from [1] as [0] is the command
itself.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 09:08:42 -04:00
Andrei Emeltchenko
75637bd44a bluetooth: audio: Fix buffer overflow
Add missing return preventing memcpy() with buffer overflow.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-26 09:08:23 -04:00
Jamie McCrae
d2eed56f4f mgmt: mcumgr: grp: os_mgmt: Fix issue and add xtensa
Fixes an issue with a missing else as part of a condition and adds
xtensa.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
c052a9f4eb mgmt: mcumgr: Disable legacy Kconfigs if legacy mode is disabled
It does not make sense to control configuration of legacy
options if legacy mode is diabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
7225ba0788 mgmt: mcumgr: grp: os_mgmt: Change select to imply for reboot
OS management's reset is optional, therefore only imply reset
instead of selecting it, so it can optionally disabled if not
needed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
aff663dd2f mgmt: mcumgr: smp: Expand ver to version and limit version
Expands a bitfield name from nh_ver to nh_version so it is more
obvious what it is. Also changes the version that goes into the
response to indicate what the maximum supported version of the
protocol is for a device

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Robert Lubos
966eff642f net: sockets: Fix recv() not being interrupted on close()
In case recv() call was waiting for data, and the socket was closed from
another thread, the recv() call would not be interrupted, causing the
receiving thread to be blocked indefinitely.

Fix this, by signalling the condvar the recv() call is waiting on
close(). Additionally, close will now set the socket into error mode,
with EINTR as the error condition, allowing the blocked calls to
recognise that the call was interrupted, and return a proper error code
on the event.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-26 09:05:12 -04:00
Alberto Escolar Piedras
0ae060d174 drivers: Console: Move all posix arch boards to same driver
All posix arch boards are required to provide the same
tracing/print API.
So, instead of having a different driver for native_posix and the
bsim boards, let's have a common one which uses this API.
This in turn results in the printk strings being printed in
the same underlaying backend as before with individual drivers.

A part from this, the native_posix console driver was a full
backend for the now long gone Zephyr console shell
(named legacy_shell from 527256501f
until it was retired in fd0b7f7767).
The whole input handling in this driver was dead code
(since 140a8d0c8a)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-26 12:57:41 +02:00
Emil Gydesen
19c2bd28a4 Bluetooth: BAP: Unicast client optimize long notify reads
Optimize the read procedure when receiving long notifications
by storing the already notified data in the buffer if the
client instance is not already busy. If it is busy we have
no way to store it, and will just need to read the entire thing
later.

This also modifies when we reset the ATT buffer. Instead of reseting
when we want to use it, we reset it when we are done using it.
The reason for this is to avoid making state checks before calling
long_ase_read to determine whether it should reset the buffer
or not.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
870d8b350a Bluetooth: BAP: Add support for long ASE notifications
Add support for long notifications ASE notifications
by doing a long read if the notification has length of
the maximum MTU.

This behavior is currently not defined by the BAP spec,
so may not work with all devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
e8ade2356a Bluetooth: BAP: Add unicast client and server write long support
Add support for long writes for the unicast client and server.
This reuses the ATT buffer for long reads.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
486ea06fcb Bluetooth: BAP: Rename BAP uni cli read buf to att_buf
att_buf is more generic and makes more sense when we
also want to use it for long writes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Emil Gydesen
36170e2a84 Bluetooth: TBS: Fixed missing guard of handle_string_long_read
The function is optionally used by the module, and should be
guarded to avoid compiler warnings about unused functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:54:58 -04:00
Emil Gydesen
5109c941f2 Bluetooth: Audio: Add TBS client TX buffer count requirement
After removing the high default for MCS, it was discovered that
the TBS client requires a significant amount of buffers to work
properly as well. Added the requirement as a build assert that
depends on which optional TBS client features are enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:54:58 -04:00
Emil Gydesen
5c3241ca5b Bluetooth: MCS: Remove requirement for TX_BUF_COUNT
A recent change in MCS significantly reduced the requirement
of L2CAP_TX_BUF_COUNT and should now work with any value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:54:58 -04:00
Flavio Ceolin
313fca2b7a bt: audio: Avoid hiding outer parameter
cap_stream is re-declared inside a for loop in
bt_cap_initiator_qos_configured.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-26 05:51:42 -04:00
Jamie McCrae
7e23e73bc1 mgmt: mcumgr: transport: udp: Rework transport
This reworks the UDP transport to resolve some issues with object
interactions and streamlines the code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 10:22:42 +02:00
Dominik Ermel
9cc6a7f060 mgmt/MCUmgr/grp/img: Fix possible missing failure check
No reason to continue zcbor encoding of slot information for image
list when already failed at encoding version.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:53 +02:00
Dominik Ermel
2f53e7af43 mgmt/MCUmgr/grp/img: DirectXIP flag pending slot as permanent
Image list should also flag pending slot as permanent.
This follows the image list for swap configuration where slot
confirmed for next boot is marked as permanent.
The difference is that in DirectXIP mode it is still possible
to erase slot marked as pending and permanent, before restart
happens.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:28 +02:00
Dominik Ermel
1847540663 mgmt/MCUmgr/grp/img: Remove leftover header img_mgmt_impl.h
The header has been replaced with img_mgmt_priv.h.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:05 +02:00
Jamie McCrae
0cce365c4f mgmt: mcumgr: fs_mgmt: Add other access hooks and minor fixes
Adds callback checks to other fs_mgmt group file access functions
which allows for file access control, and moves where the callback
is triggered for uploads and downloads to prevent getting the
callback multiple times for the same file. The callback struct has
been modified so applications using the previous signature will
need to be updated.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 10:20:39 +02:00
Lars Knudsen
79c48edcb9 shell: Use SDU sent callback in bap shell
Use the bt_bap_stream_ops sent callback and not a timeout
while streaming the sine tone in the bap shell to avoid
jitter when the shell is busy.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-05-25 16:36:54 -04:00
Gerard Marull-Paretas
9a145e52a0 pm: policy: add support for events
Events in the power-management policy context are defined as any source
that will wake up the system at a known time in the future. By
registering such event, the policy manager will be able to decide wether
certain power states are worth entering or not.

Events will bypass the ticks argument received by the policy manager if
they occur earlier.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-25 16:29:40 -04:00
Gerard Marull-Paretas
c8cd40f5ae pm: policy: clarify latency units and clarify private members
Latency is always specified in microseconds, so apend `us` to the
relevant variables. Also, make it clear that latency request structures
are private (they are just exposed publicly to allow static allocation).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-25 16:29:40 -04:00
Emil Gydesen
4f3cfe5cd1 Bluetooth: TMAP: Fixed bad size when copying UUIDs
In both instances the sizeof returned the size of the
array, rather than the specific uuid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 16:27:26 +02:00
Emil Gydesen
4bd3452245 Bluetooth: CSIP: Add guard for accessing svc_insts[>1]
Added a guard before attempting to access
svc_insts[cur_inst->idx + 1], as that code can only ever be value
if CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES > 1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 16:27:26 +02:00
Emil Gydesen
083125d5fa Bluetooth: CSIP: Fix warning of unused rank variables
Guarding code that uses __ASSERT with IS_ENABLED seemingly
does not work, and still gives unused variables (rank_1 and
rank_2). Modified the guard.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 16:27:26 +02:00
Emil Gydesen
e0b84798c9 BluetootH: Audio: Split CAP broadcast start API
Split the CAP initiator broadcast start API into a create
and a start. This will allow users to create the broadcast source
without starting it immediately, making it possible to get the
BASE etc. without an active advertising set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-25 08:26:33 +00:00
Aleksander Wasaznik
92fcd9ef40 Bluetooth: Host: Add L2CAP seg_recv API
This is an alternative API for the L2CAP receive functionality. It
allows an application the receive L2CAP segments directly and manage
credits explictly. The API is guarded by an experimental kconfig option.

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

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-05-24 13:15:14 -04:00
Carlo Caione
6f3a13d974 barriers: Move __ISB() to the new API
Remove the arch-specific ARM-centric __ISB() macro and use the new
barrier API instead.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-24 13:13:57 -04:00
Florian Grandel
a2c6bb9f1c net: l2: ieee802154: move variable declaration to start of block
Variable declarations are moved to the beginning of the block in
which they are visible to ensure consistency with the remainder
of the code base.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
26041dc32b net: l2: ieee802154: fix typos
A few security-related constants contained typos which are
fixed in this change.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
ee079495d5 net: l2: ieee802154: enc-only security level removed from spec
The encryption-only security level has been removed from the
spec, see IEEE 802.15.4-2020, 9.4.2.2 Security Level field.

The standard provides the following explanation (ibid):

"This security level is deprecated and shall not be used in
implementation compliant with this standard. Devices that
receive frames with security level 4 shall discard them, as
described in 9.2.4. The counter mode encryption and cipher
block chaining message authentication code (CCM) used allows
trivial changes to the underlaying encrypted data unless
data authenticity is provided, thus using data confidentiality
only is not useful. In the case of TSCH mode, security level 4
allows higher security level frames to be downgraded to
security level 4 frames."

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
0a2d8522e9 net: l2: ieee802154: simple address mode removed from spec
See IEEE 802.15.4-2020, 7.2.2.11 Source Addressing Mode field and
7.2.2.9 Destination Addressing Mode field, table 7-3: The
previously deprecated "Simple addressing mode" was removed
from the spec.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
ea6a55afad net: l2: ieee802154: zero-copy encryption
Currently the insertion of an authentication tag requires a memcpy() call
and breaks encapsulation.

This change removes the need for memcpy() and improves the encapsulation
by calculating and reserving the required headspace early on while
keeping insertion where it belongs in the outgoing security procedure.

This is also a preparation for improved standard compliance of the
outgoing security procedure which is scheduled for a later commit.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
315394eb53 net: l2: ieee802154: consistently name authtag length
The naming of variables and arguments containing the authentication
tag length was inconsistent:

* Naming inconsistency between header "length" vs. authtag "size"
  in the same API calls
* "Tag" rather than "Auth[orization ]Tag" in external API calls
  which is too generic from a compliance and readability viewpoint.

This is in preparation to zero-copy authentication support.

Almost all call sites will be subject to required structural changes
later on so no relevant git blame noise/history loss will be introduced
by this naming change in the long run.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Florian Grandel
32e1213b0c net: l2: ieee802154: improve inline documentation
Over time, some non-standard concepts and extensions were introduced
into the stack (in KConfig, in drivers, in the internal API and into the
implementation) which makes introduction of additional standard-
compliant extensions like TSCH (and others) unnecessarily difficult.

To introduce extensions like TSCH it is required for the IEEE 802.15.4
stack to become more structurally aligned with the standard again which
will be the focus of some of the upcoming preparatory changes.

One way to check and prove standard compliance is to reference the
standard from within the source code. This change therefore introduces
inline references to the IEEE 802.15.4-2020 standard wherever possible.
Deviations from the standard are documented with TODO or deprecation
labels to be addressed in future changes.

In the future, new code introduced to the IEEE 802.15.4 stack should
be documented and reviewed for standard-compliance to avoid further
divergence. Most importantly:
* MAC/PHY configuration (via net mgmt, radio API, devicetree or
  KConfig) should always be directly linked to well-defined MAC/PHY
  PIB attributes if visible to the MAC API or the end user.
* Net management/shell/radio API commands should have a documented
  reference to the corresponding MLME action from the standard.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-24 16:41:57 +02:00
Emil Gydesen
6b004e267e Bluetooth: Audio: Fix missing reset of receiver_ready for unicast client
The unicast client did not properly clear the receiver_ready flag
when going out of the streaming or enabling state. This caused
incorrect behavior when attempting to restart streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-24 16:41:47 +02:00
Emil Gydesen
699ccbac41 Bluetooth: Audio: Remove bad LOG_ERR from bap_stream
There was a debugging LOG_ERR that should not have
been merged.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-24 16:41:28 +02:00
Piotr Pryga
622299b1c5 Bluetooth: controller: Move DF feat selection to LL_SW_SPLIT KConfig
The BT_CTLR_DF_SUPPORTED KConfig was a wrapper for DF related features
set that are supported by Zephyr's BLE Controller. At the same time the
KConfig is used by Host in compound build to enable BT_DF. That makes
the whole thing a bit coupled with Zephyr's controller.
External implementations of controller must provide same feature set
as Zephyr's Controller or there will be an error during build.

The PR moves the Zephyr's Controller DF supported features set to
Kconfig.ll_sw_split, where it is included only when BT_LL_SW_SPLIT
is selected. BT_CTLR_DF_SUPPORTED is now a top DF_SUPPORTED KConfig
option that enables possibility to select actual DF features.
That allows to select individual set of DF features by any controller
implementation and makes possible to enable BT_DF and build selected
DF Host features.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2023-05-24 16:41:21 +02:00
Silviu Petria
5096aa1c00 Bluetooth: Audio: Add TMAS and two TMAP samples
Add implementation of the Telephony and Media Audio Service, as well as
two sample applications.

tmap_central reflects a smartphone implementing the Unicast Media Sender
and Call Gateway TMAP roles.

tmap_peripheral reflects an earbud implementing the Unicast Media
Receiver and Call Terminal TMAP roles.

Upon connection, tmap_central starts an audio stream using CAP Initiator
APIs.

CCP, MCP and VCP are discovered and used to send example commands.

Future improvements: 2-earbud support, add TMAP Broadcast roles,
update with new CAP Acceptor/Commander APIs as they become available

Signed-off-by: Silviu Petria <silviu.petria@nxp.com>
2023-05-24 16:39:38 +02:00
Qipeng Zha
7aa618d288 logging: trigger log process once reach threshold
atomic_inc(&buffered_cnt) return previous count of log messages,
should use current count to compare with threshold config value.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Signed-off-by: Qipeng Zha <qipeng.zha@intel.com>
2023-05-24 05:06:11 -04:00
Nils Ruf
97c1d05dec net: allow UDP missing checksum by default
According to RFC768 UDP packets with zero checksum are allowed with IPv4.
Enable this by default.
For example, some routers use zero checksum in DHCP packets.

Signed-off-by: Nils Ruf <nils.ruf@endress.com>
2023-05-23 22:09:47 +02:00
Rodrigo Peixoto
caf68d9485 zbus: remove POSIX arch iterable sections restriction
Zbus iterable sections config in Kconfig unnecessarily excluded POSIX
architectures. Remove the constraints and adjust the sample YAML file to
enable that.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2023-05-23 22:09:33 +02:00
Jamie McCrae
56f66334b0 mgmt: mcumgr: grp: fs_mgmt: Fix cmake selection
Fixes an issue whereby mbedtls will not be included if tinycrypt
is included in the build.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 18:00:53 +02:00
Fabio Baltieri
b9ea2c2705 build: downgrade the no optimization ztest error to warning
The current approach of failing the build on ztest with no optimization
broke coverage builds, and generally raised some concerns about being
too aggressive.

Downgrade the error to a warning and rework the option to inhibit the
warning, while also dropping it automatically for POSIX (that are not
really affected by stack size) and coverage run (that always runs with
no optimization).

Will reconsider this down the road if we still see issues filed for the
tests broken with no optimization and no further tuning.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-23 14:51:24 +00:00
Jamie McCrae
2e4c3f1da9 mgmt: mcumgr: grp: fs_mgmt: Change insecure warning
Changes the warning from being text in Kconfig for filesystem
management as a whole to being a cmake warning which is displayed
if the user has not enabled file access hooks with a link to the
documentation on how to set them up.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 16:36:38 +02:00
Jamie McCrae
1d6ee8da5f mgmt: mcumgr: Change from mcumgr to MCUmgr
Fixes the name of the system.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 16:36:38 +02:00
Dawid Niedzwiecki
aa0c0727b4 mgmt: ec_host_cmd: add config to create a dedicated thread
Add a config to decide if a new dedicated thread for Host Command is
created during initialization.

If not, the ec_host_cmd_task has to be called by another thread to
handle host commands.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-23 16:19:53 +02:00
Pavel Vasilyev
e51a909343 Bluetooth: Mesh: Shell: fix vnd model pub command
The command at most takes 11 args. argc = num of args + 1 (command
name) => 12. We substruct 3 from argc (cmd name, mod id, addr). This
gives argc = 9 when all args are provided for vendor model.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-23 13:03:18 +02:00
Andries Kruithof
253818ebea Bluetooth: controller: move bn scope from filescope to lll-scope
The scope for the burst number for tx and rx is currently at module
level in both lll_central_iso.c and lll_peripheral_iso.c
 This PR puts the scope to the lll level

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-05-23 12:56:07 +02:00
Fabio Baltieri
f5830f3c3f ztest: error out when building tests with no compiler optimizations
Many tests are known to fail when built and no compiler optimizations.
Add a CMake check to error out when building a ztest based test with no
optimization, ask not file issues about it but also adds an opt-out
option to bypass the error for tests are actually designed to work in
this setup.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-22 12:25:43 -04:00
Florian Grandel
ca6d552bbb net: l2: ieee802154: fix payload handling
The current implicit MAC payload length algorithm (based on
an otherwise irrelevant footer pointer) produces invalid
(non-standard) values for beacon and command frames.

This change produces standard-conforming MAC payload length
values and simplifies access to payload length.

It would have been possible to fix the current footer pointer
based approach but there are arguments in favor of the new
approach:
- The footer pointer is used nowhere in the current code
  base and makes length calculations rather non-obvious.
- The new approach does not use more memory and is easier
  to understand and use.
- This change is a first step to support of IEEE 802.15.4
  information element (IE) support. At a later stage the
  distinction between MAC payload length and frame payload
  length will be introduced and become relevant to
  distinguish between header and payload IEs. At that point
  the current implicit length calculation algorithm will
  break down anyways.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
4fcdfab7d9 net: l2: ieee802154: fix beacon filtering
The current IEEE 802.15.4 stack would not accept beacons
unless hardware filtering was active.

This change fixes the bug.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
c5fc0e5577 net: l2: ieee802154: shell: release event cb
The shell command calling the IEEE 802.15.4 scanning procedure
did not properly release its net management event callback.

This change fixes the memory leak.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
cb5ea0ec83 net: l2: ieee802154: always revert channel/pan after scan
Active and passive scanning requires the channel and PAN to
be set temporarily.

This change ensures that the temporary configuration will
be reverted even when the scan is aborted due to an error.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Florian Grandel
8eec8441cd net: l2: ieee802154: release consumed frames
Beacon and command frames are consumed by the IEEE 802.15.4
stack internally and should therefore be released before
returning control to the generic net stack.

This change fixes the resource leak.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 16:33:28 +02:00
Jonathan Rico
202d2ed005 Bluetooth: host: clarify the behavior of BT_PRIVACY
This makes it explicit that enabling `BT_PRIVACY` will make the device
_use_ private addresses.

The device can still resolve RPAs when `BT_PRIVACY=n`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-22 15:26:55 +02:00
Krzysztof Kopyściński
61cf1bb9e4 Bluetooth: Mesh: fix SRPL clearing
If len=0 then `primary` address should be cleared.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-05-22 15:26:17 +02:00
Krzysztof Kopyściński
38c925308b Bluetooth: Mesh: fix Proxy Solicitation build without CONFIG_BT_SETTINGS
`bt_mesh_settings_store_schedule` should be called only when
CONFIG_BT_SETTINGS is enabled.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-05-22 15:26:07 +02:00
Emil Gydesen
d770e2af13 Bluetooth: Audio: Remove BT_CODEC_MAX_DATA_LEN > 0 checks
The minimal value of BT_CODEC_MAX_DATA_LEN is 1, so it
is always > 0.

Includes to audio.h in shell bt.c was removed as audio.h
should only be included if BT_AUDIO=y.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:25:54 +02:00
Emil Gydesen
71af6c0c6b Bluetooth: Audio: Remove CONFIG_BT_CODEC_MAX_METADATA_LEN
The Kconfig option was not used anywhere besides some checks
that should have checked against CONFIG_BT_CODEC_MAX_DATA_LEN
instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:25:54 +02:00
Matthias Breithaupt
d2163bc0b9 net: DHCPv4: Add option callback
In certain scenarios, it may be necessary to get values of additional
options from the application layer. With this patch, this can be
accomplished by registering a callback with the DHCP client.

This change has been tested using the posix build in qemu.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
2023-05-22 15:25:40 +02:00
Emil Gydesen
37aad05883 Bluetooth: BAP: Shell: Remove superfluous call to discover_cb
The call to discover_cb did not add any value as we already
print the error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
3074c72d79 Bluetooth: BAP: Move endpoint discovery to new callback
Add a new endpoint callback that is used to report the found
ASEs during BAP discovery, rather than calling
the discovery callback with optional values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
1c304d9d23 Bluetooth: BAP: Move pac record discovery to new callback
Add a new pac_record callback that is used to report the found
PAC records during BAP discovery, rather than calling
the discovery callback with optional values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
5d498d78ad Bluetooth: BAP: Remove bt_bap_unicast_client_discover_params
Remove the BAP unicast client specific discover parameter struct.
This make the BAP discover work more similar to the other
profiles.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
ffca5f9b2f Bluetooth: BAP: Remove dir from BAP discovery parameters
The direction has been moved to a function parameter instead,
and we keep a local copy of the value in the stack instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
1199e46e0b Bluetooth: BAP: Remove num_eps from BAP discover params
The field is not required and is no longer used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
0b10498fb1 Bluetooth: BAP: Remove num_caps from BAP discover params
The field is not needed and no longer used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
11f5f3b080 Bluetooth: BAP: Move uni cli discov err to callback
Move the err field from the discover parameters to
the callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Emil Gydesen
39406a4843 Bluetooth: BAP: Move uni cli discover callback
Move the unicast client discover callback from the
parameters to the callback structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-22 15:24:28 +02:00
Jamie McCrae
ea6d326ab4 mgmt: mcumgr: grp: img_mgmt: Remove unused file
Removes a file that provided unimplemented and unused functions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:25:05 +02:00
Jamie McCrae
fbd5415ca2 mgmt: mcumgr: grp: fs_mgmt: Fix not checking offset
Fixes an issue whereby the user supplied offset was not checked if
it was provided or not.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:24:48 +02:00
Jamie McCrae
c95b8ff831 mgmt: mcumgr: grp: img_mgmt: Remove useless hash variable
Removes a hash variable that was set then never used.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:21:41 +02:00
Wojciech Slenska
db7803b60e shell: shell_cmds: added prompt commands
Added command for enabling/disabling shell prompt.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-05-22 12:03:03 +02:00
Vinayak Kariappa Chettimada
b726b5e62a Bluetooth: Controller: Fix BT_CTLR_SW_SWITCH_SINGLE_TIMER feature
Fix BT_CTLR_SW_SWITCH_SINGLE_TIMER to correctly disable the
PPI group used to switch radio Tx/Rx. The issue was
uncovered when adding coverage in BabbleSim test.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-22 12:02:02 +02:00
Vinayak Kariappa Chettimada
9eb931836b Bluetooth: Controller: Prepare to replace HAL_RADIO_ENABLE_ON_TICK_PPI
Prepare to replace HAL_RADIO_ENABLE_ON_TICK_PPI with
independent use of HAL_RADIO_ENABLE_TX_ON_TICK_PPI and
HAL_RADIO_ENABLE_RX_ON_TICK_PPI.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-22 12:02:02 +02:00
Vinayak Kariappa Chettimada
f8f01a07ff Bluetooth: Controller: Use NRF_RADIO_TXRX_END_EVENT
Use NRF_RADIO_TXRX_END_EVENT instead of EVENTS_END in the
Controller HAL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-22 12:02:02 +02:00
Michael Trimarchi
b4bac3d7f1 modbus: cancel the server_work in modbus disable
Allow to periodically initializes/disables the modbus interface.
Switch from modbus line discipline to serial and switch back to modbus.
This can be required when the serial is shared by two sensors

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
2023-05-22 10:50:20 +02:00
Gerard Marull-Paretas
dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Mariusz Skamra
f5d4e9e0db Bluetooth: audio: ascs: Fix conn object being unreferenced prematurely
This fixes invalid conn unref that happens in ACL disconnected callback
context. When the ACL disconnects, the implementation waits for CIS to
be disconnected if connected. If the client won't disconnect the
CIS, the implementation initiates the disconnection by itself, from
delayed work context. Thus the ACL conn object has to be remained at
that time because it indicates whether the ASE object is in use or not.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Mariusz Skamra
3aea893ca5 Bluetooth: audio: ascs: Fix repeated ops->released callback call
Once the ACL disconnects, the implementation releases the related
endpoints. The ops->released callback is called once ASE enters IDLE
state, thus there is no need to call it explicitly.
This fixes repeated ops->released callback call.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Florian Grandel
51108a9ce4 net: l2: ieee802154: test: /w and /wo sockets
This change splits the IEEE 802.15.4 test into two separate
test profiles, one with and one without sockets enabled to ensure
that both configurations work correctly.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 08:06:14 +00:00
Florian Grandel
e6c4109e94 net: l2: ieee802154: expose implicit frame assumption
The current IEEE 802.15.4 stack assumes that drivers will
not provide more than one fragment in incoming packages.

This change exposes and enforces the pre-existing assumption
made by the implementation.

So far this is not a limiting restriction as MPDUs with more
than 127 bytes are not supported yet. It will probably have to
be changed as soon as larger payloads (as allowed by PHYs
introduced more recently into the spec) might want to allocate
smaller fragments.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 08:06:14 +00:00
Florian Grandel
66bd007f30 net: l2: ieee802154: security: properly clean up previous session
When changing IEEE 802.15.4 security settings or setting security
to 'none' then the previous session must be cleaned up to avoid
resource leaks.

This change introduces proper clean-up of the security session.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-05-22 08:06:14 +00:00
Mariusz Skamra
8c3568f213 Bluetooth: audio: mcs: Fix endianess issues
This fixes missing endianess conversions in mcs.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-19 19:53:02 +00:00
Mykola Kvach
99661137bb fs: littlefs: add ability to build little fs without flash map
LittleFS may be used not only for Flash devices, we can use it for
block devices too.

Add possibility of building LittleFS for case when
CONFIG_FLASH_MAP and CONFIG_FLASH_PAGE_LAYOUT are disabled.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-05-19 15:53:29 +02:00
Mykola Kvach
ba4ad699e0 fs: littlefs: remove dependency on flash map from FILE_SYSTEM_LITTLEFS
LittleFS may be used not only for Flash devices, we can use it for block
devices too. So, I have changed dependency rules and remove dependency
on flash map from FILE_SYSTEM_LITTLEFS.

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-05-19 15:53:29 +02:00
Mateusz Kapala
15bd8b256f bluetooth: host: Fix NULL pointer dereference in bt_conn_auth_cb_overlay
There is a check in bt_conn_auth_cb_overlay function which validates
if content of the callback structure is correct, but there is no
NULL-check on the structure pointer itself, which could result in
NULL pointer dereference.

It should be possible to set the callback structure pointer to `NULL`
using bt_conn_auth_cb_overlay function if the application requires
ex. Just Works pairing for one Bluetooth identity and global
callbacks are configured for advanced pairing scheme (like Passkey
Display) for other Bluetooth identity.

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2023-05-19 09:40:21 +02:00
Ajay Parida
d47021b2f9 net: shell: Fix for PS timeout param type.
Param type is set to correct type for power save timeout.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-18 15:14:31 -04:00
Mariusz Skamra
84fd596062 Bluetooth: audio: mcs: Offload notifications to system work queue
This implements the deferring of characteristic value notifications to
be sent from system work queue thread context. Notifications issued from
Bluetooth Rx thread might not be sent if there are no L2CAP Tx buffers
available, as the operation is non-blocking to prevent deadlock while
waiting for free buffers.
The same operation issued from other thread context is blocking,
meaning that the thread waits until L2CAP Tx buffers become available.
Thus it's guaranteed the notifications will be sent.

With this patch, the control point operations become blocking until the
control point response is sent. Meaning there might be only one
pending operation waiting for completition. This might be further
improved by queuing the operations if needed.

Fixes: #57444
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-18 13:35:57 +00:00
Mariusz Skamra
94853e310a Bluetooth: audio: mcs: Fix unused functions warning
This guards functions called only if CONFIG_BT_OTS is enabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-18 13:35:57 +00:00
Jamie McCrae
a476eeb8ec mgmt: mcumgr: grp: os_mgmt: Use new error for invalid format
Uses the new error system to report an error if the user provides
an invalid format for the OS info command.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-18 13:31:19 +02:00
Dawid Niedzwiecki
7efc8938eb mgmt: ec_host_cmd: update checking the handler buffer
The general handler may provide buffers for a backend. Use ranges to
check if the provided buffer is used, because the backend may shift the
beginning of the buffer to make space for preamble.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
0a17aa8605 mgmt: ec_host_cmd: add autoinit config
Add a separate config to enable autoinitialization of the host command
subsystem, called by the chosen backend.

It allows setting the chosen backend without autoinit.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
4064a41ce2 mgmt: ec_host_cmd: follow clang format
Edit some source files to follow the clang format.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
3d8a5c7e5c mgmt: ec_host_cmd: make host command structure available
The application code may need inside information about the host command
e.g. the thread id. Add a function that returns the main host command
structure which contains such data.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
PawelX Dobrowolski
0bff695d2c coredump: Intel ADSP memory window backend
For debug usage is added backend for memory window.
Coredump is being dumped in raw data. It needs to be converted to
ACSII for later analysis. Data is written to telemetry slot
in memory window which is a space where is located all debbug
information.

Signed-off-by: PawelX Dobrowolski <pawelx.dobrowolski@intel.com>
2023-05-17 14:10:49 -04:00
Fredrik Danebjer
f3fdb1f96f Bluetooth: Audio: Make VCS optional notify characteristics optional
This change makes VCS Volume Flag characteristic Notify property
optional and selectable through Kconfig.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-05-17 19:26:54 +02:00
Andrei Emeltchenko
303a0af68f net: tcp: Make sure we shift by less then bit width
Shifting "timeout <<= conn->zwp_retries" by more then 63 bits results in
undefined behaviour.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-17 19:26:44 +02:00
Tomasz Moń
7ba5ecf451 usb: device_next: report medium error on Mass Storage failed writes
End Write command with Medium Error / Write Error when underlying disk
write or sync fails.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-05-17 11:45:45 +02:00
Tomasz Moń
3532c2563a usb: device_next: accept padded Mass Storage CDBs
Universal Serial Bus Mass Storage Specification For Bootability requires
that device shall accept Bulk-Only-Transport bCBWCBLength of 12 for all
commands documented in the specification. Allow padding for commands
documented in Bootability specification, but leave others intact.

This fixes Request Sense on Windows 11 which previously failed due to
bCBWCBLength being 12 instead of 6.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-05-17 11:45:45 +02:00
Dominik Ermel
ac38411e2e mgmt/MCUmgr/grp/img: Rework image list to support DirectXIP
Image list will only report active flag for active image and pending
flag for other slot, but only if image in that slot has higher
version than currently running image.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-17 09:47:54 +02:00
Krishna T
b7cabb72fa net: wifi: Fix typo in event
Wrong macro was copied, this causes the event to fail.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 11:41:43 -04:00
Krishna T
2c129609d0 net: context: Set priority based on DSCP
If a socket has DSCP set then the packets from the socket should also be
marked with appropriate priority in case traffic classes are used in
networking stack.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 13:21:25 +02:00
Krishna T
10f3ca2e1d net: wifi: Add an event for disconnect complete
This is needed for applications that rely on WPA supplicant being
in disconnected state before issue subsequent commands (e.g., issue scan
immediately after disconnect fails, until disconnect is completed).

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 13:21:10 +02:00
Vinayak Kariappa Chettimada
9ff23ed029 Bluetooth: Controller: Fix Central CIS SN/NESN for skipped events
Fix Central CIS SN and NESN for skipped events during CIS
setup. It is possible that CIG event may overlap the ACL or
other events at the CIS create instant, and hence have non
zero lazy value during the CIS setup events until CIS is
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-16 13:20:15 +02:00
Vinayak Kariappa Chettimada
3b3d53f09e Bluetooth: Controller: Fix CIS offset_min for dissimilar interval
Fix CIS offset_min calculation to consider that ACL interval
and ISO interval can be dissimilar and the offset value has
to be compensated for the latency until the instant at which
the offset is used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-16 13:20:15 +02:00
Vinayak Kariappa Chettimada
22e67eac6e Bluetooth: Controller: Fix sn on Peripheral CIS event abort
Fix SN value on Peripheral CIS event abort. Adjust the SN
value based on the burst number such that the ISO data where
transmitted as normal.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-16 13:20:15 +02:00
Andrei Emeltchenko
2c0fcdf22b bluetooth: shell: Add missing return
Avoid invalid bit shift by adding return.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-16 12:08:06 +02:00
Yuval Peress
7153157f88 rtio: Add support for multishot reads
- Introduce multishot reads which remain on the SQ until canceled

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-15 10:10:12 -04:00
Yuval Peress
2c30920b40 rtio: add cancel support
- Add a new API `rtio_sqe_cancel` to attempt canceling a queued SQE
- Add a new syscall `rtio_sqe_copy_in_get_handles` which allows getting
  back the SQE handles generated by the copy_in operation so that they
  can be canceled.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-15 10:10:12 -04:00
Emil Gydesen
c66f210f6b Bluetooth: BAP: Broadcast source fix idle state
The idle state was never set, thus providing a poorly
implemented state machine. Updated the code so that unused
code was removed and so that the idle state is properly set.

Optimized the way that a state is set for all endpoints
for a broadcast source with a new function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-15 15:26:14 +02:00
Sjors Hettinga
a28a656aa0 net: tcp: Avoid double acknowlegding retransmitted data
In the FIN_WAIT_1 any incoming data is dropped, but anknowledged. Add a
check to see if the data is already acknowleged to prevent double
acknowledging of the data and bringing the acknowlegde counter out of
sync. When the acknowledge counter gets out of sync, the connection will
never properly terminate any more.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-05-15 15:25:51 +02:00
Vinayak Kariappa Chettimada
354226022e Bluetooth: Controller: Fix peer ISO feature support check
Fix peer ISO feature support check, by using feature support
bit instead of whether locally supported bit value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-15 13:38:38 +02:00
Vinayak Kariappa Chettimada
0249006813 Bluetooth: Controller: Use swapped role specific features bit
Use swapped role specific features bit to calculate features
usable by local device, on feature exchange procedure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-15 13:38:38 +02:00
Vinayak Kariappa Chettimada
fe53891788 Bluetooth: Controller: Fix Central ISO establish assertion failure
Fix Central ISO assetion failure on being established due to
regression in commit a53d89450a ("Bluetooth: controller:
fixing CIS establish flow for refactored LLCP") that
required changes due to Create CIS LLCP being refactored.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-15 13:38:38 +02:00
Herman Berget
93f36d4bff Bluetooth: Host: Fix double conversion of phy
The phy was converted both when reading from the event
and when reading from the sync, leading to incorrect
value in the synced callback.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-15 13:10:29 +02:00
Emil Gydesen
6862884f87 Bluetooth: BAP: Broadcast sink fix interval to timeout calc
The calculation in interval_to_sync_timeout did not take into
account that the periodic advertising sync interval was in units
of 1.25ms, and not ms.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-15 10:53:54 +00:00
Gerard Marull-Paretas
a8b36ffb4d bluetooth: mesh: use STRUCT_SECTION_ITERABLE_ARRAY
STRUCT_SECTION_ITERABLE cannot be used with arrays, because of
preprocessor tokenization issues.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-15 18:52:07 +09:00
Jamie McCrae
f59b857f6a mgmt: mcumgr: smp: Convert functions to function pointer array
Converts the list of functions for registering an MCUmgr SMP
transport from function arguments to a single list which contains
the function pointers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 10:23:35 +02:00
Jamie McCrae
6f5b974949 mgmt: mcumgr: Add command result codes (ret)
Adds a new map to responses that command handlers can use to
return result codes of functions themselves, unrelated to SMP
error codes. This is achieved by adding an optional "ret" map
which contains a 16-bit "group" and 16-bit "rc" error code,
this map will not be included if the "ret rc" is 0 (which
implies success).

In order to allow this, a new version of the protocol has been
which can be indicated for use by setting a bit in the header.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 09:27:16 +02:00
Lukas Woodtli
fb924e2b62 net: lwm2m: Handle CONTINUE in registration message
The continue code is not considered an error in case of
block-wise transfer.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
73fb4e73a8 net: lwm2m: Handle CONTINUE response and send new block
After sending a CoAP block and receiving the CONTINUE response
code the next block is sent.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
49f8d08f98 net: lwm2m: Split message into blocks for sending
Add functionality that creates blocks from a big payload body.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
3707a0d229 net: lwm2m: Provide buffer for block transfer
Allow to use a buffer for the complete message body if block transfer is
enabled. This buffer is used when serializing the message. For sending
the message the body is split into blocks.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
12de4018ef net: coap: Add function for getting BLOCK1 option
The function gets the the BLOCK1 option from a received message
and extracts the block number, block size and has-more flag from
it.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
db480169a0 net: coap: Add function for inserting block option for sending
The function adds a block option to a CoAP message. If the message
is a request the BLOCK1 option is added. Otherwise (response) the
BLOCK2 option is added.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Dawid Niedzwiecki
65bd27246f mgmt: ec_host_cmd: fix node chosen strings
Update the backend device node chosen strings.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-15 09:16:53 +02:00
Emil Gydesen
07f32b732a Bluetooth: ASCS: Add support for long writes
Add support for long writes to the control point
to handle e.g. metadata that's larger than the MTU.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
8c4908b3f2 Bluetooth: ASCS: Add support for long read
Increase the size of the ase_buf to support
the maximum size of the Codec Configuration
and Metadata.

The ase_buf is not also guarded by a semaphore, so no
more than one thread will use it at any time. This is
needed as ase_status_changed can be called from multiple
threads.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
572055e205 Bluetooth: Audio: Add long read support to BAP unicast client
Add support for long read by adding a read_buf and store
the data when long data is being read.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
892819ede8 Bluetooth: Audio: ASCS ASE discover by UUID added
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
be781b2a56 Bluetooth: Audio: PACS context discover by UUID added
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
ec1b2a1844 Bluetooth: Audio: PAC discover by UUID added
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs, and that we need
to do a long read on the PAC records anyhow, and that
cannot be done with the read by type/UUID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
ba19bf3d96 Bluetooth: Audio: Add unicast_client struct
Add a new struct unicast_client to hold all the conn-specific
data for the Unicast Client implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
3ff3d8db2c Bluetooth: PACS: Set PACS read_buf size to BT_ATT_MAX_ATTRIBUTE_LEN
The maximum size of the characteristic is BT_ATT_MAX_ATTRIBUTE_LEN.
The previous size limited the size of the characteristic to
the maximum possible MTU, thus not utlizing support for the
Read Long procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
3d4622b4d4 Bluetooth: PACS: Fix bad __ASSERT condition
__ASSERT(true will never be triggered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
5a28d80893 Bluetooth: PACS: Removed unused conn arg from get_pac_records
The `conn` argument was not used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Emil Gydesen
98adaf0811 Bluetooth: PACS: Add read_buf_sem
Add a semaphore to guard the read buf. The reason for this
is that the read buf is populated from either the BT RX
thread, or the workqueue thread. The semaphore ensures
that both threads will never have attempted to
add any data to the buffer at the same time.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Erik Brockhoff
5ca6724664 Bluetooth: controller: adding release of rx/tx nodes retained in LLCP
On connection clean-up release nodes held by LLCP. These are released
in two steps, first on LLCP terminate (in local/remote) by moving
to rx/tx_node_release chains, and then on conn_cleanup_finalize
nodes are released back to appropriate mem-pool/queue.
Rename abort functions to refer to terminate.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Erik Brockhoff
eece00e4b0 Bluetooth: controller: updating TX node pre-alloc store mechanism
Instead of using the node ref used for TX ack for storing a TX node
pre-allocated in case of NTF RX node availability delay, introduce a
separate store to TX node. This to avoid misunderstanding on clean-up
in terminate flow.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Erik Brockhoff
a53d89450a Bluetooth: controller: fixing CIS establish flow for refactored LLCP
Latest modification to LLCP removed 'monitoring' of cis->established
flag in LLCP, relying instead on signal through ULL.

For this to work properly the signal must also be generated, so this is
introduced. Note - checking of cis->established flag could be removed
if caller ensures only calling once (on establish condition)

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Erik Brockhoff
998512f59b Bluetooth: controller: use RX node piggy-back for NTF when possible
When possible re-use the already allocated RX node for notifications.
Store (retain) RX node and Link element on RX if NTF could occur.
Pass link element to LLCP (ull_cp_rx()) together with RX node.
New RX node type RETAIN introduced to signal retention

When no RX node is available allocate one and hold off TX on procedures
until such time that a node is available for NTF.

In case waiting for NTF buffer avail is needed, allocate and store TX
node to use for TX once NTF becomes available.

CIS Established (incl. timeout handling) is now handled entirely as a
specific event driven by ull_conn_iso - ie removal of procedure check
of cis->established and cis->expire, as this is doubling mechanism
in the conn_iso context.

Unit test and helpers updated to handle new node type.
Function ull_cp_release_ntf() was used only in unit test, so moved to
helper context.
Updating release_ntf to handle the fact that with piggy-backing in test
context the node used for NTF can be from two different memory pools

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 12:53:16 +02:00
Ajay Parida
e70bb70651 net: wifi_mgmt: Support to provide raw scan data
Support to provide raw beacon and probe response data
to registered application.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-12 10:50:21 +00:00
Gerard Marull-Paretas
d0e58ad0a6 device: use iterable sections
Use iterable sections to handle devices list. This simplifies devices
implementation by using standard APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
f0db892d7b toolchain: add trailing _ to iterable section name
Add a trailing _ to the section iterable name. This is useful, for
example, to implement numeric sorting like this:

SORT(.z_device_LEVEL_?_)
SORT(.z_device_LEVEL_??_)

Without the trailing _ it would not be possible to use the ?? wildcard
without triggering into trigraphs issues, because linker-defs.h header
is included in C files as well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
13f87494bb shell: device_service: remove levels command
While it may be useful in some contexts, this information can be
obtained at compile time. Removing this command allows to migrate the
device infrastructure code to standard iterable sections, done later.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Ravi Dondaputi
0889ceaa4e net: wifi: Display MFP info in scan results
Display MFP info in scan results.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-05-12 11:57:13 +02:00
Dominik Ermel
a763454c0b mgmt/mcumgr/grp/img: No MCUboot flags setting in DirectXIP
It is no longer possible to select image for test or confirm
when MCUboot has been configured for DirectXIP.
MCUboot flags, in image trailer, are now ignored in DirectXIP
mode allowing to use entire slot for image upload.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Dominik Ermel
0a5c4aba52 mgmt/mcumgr/grp/img: No upload for MCUboot in single app mode
Image management is now disabled by default if MCUboot
is configured for single application mode.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Dominik Ermel
87efe30b3a mgmt/mcumgr: Use boot_set_next to set image for test or confirm
The commit adds img_mgmt_set_next_boot_slot function which uses
boot_set_next, from MCUboot/bootutil, to set application slot
for next boot.
The img_mgmt_set_next_boot_slot is intended to replace
img_mgmt_state_confirm and img_mgmt_state_set_pending.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Dominik Ermel
2244974dd6 mgmt/mcumgr: Add img_mgmt_active_slot() and img_mgmt_active_image()
The commit adds img_mgmt_active_slot() which allows to get
active (running) slot for given application image.
Added img_mgmt_active_image() allows to get number of image running
on current MCU core.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Mariusz Skamra
12d8a0d178 Bluetooth: id: Keep RPA as bt_addr_t
There is no need to store the RPA in bt_addr_le_t structure, as the
bt_addr_le_t.type is unused anyway. Both bt_rpa_create and
bt_id_set_adv_random_addr take bt_addr_t as parameter.
Saves 1 byte of address type.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-12 10:55:50 +03:00
Mariusz Skamra
88c20b9cdd Bluetooth: id: Fix uninitialized RPA
This fixes uninitialized RPA value for BT_ID_DEFAULT.
The regression has been introduced in
8d6b206064.
As the result, the private address was not created and the advertising
was started with 00:00:00:00:00:00 address.
In case of the other advertising ID's, those are initialized
from id_create context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-12 10:55:50 +03:00
Balaji Srinivasan
491628ae06 Bluetooth: host: Fix dangling reference in service changed
The bt_gatt_indicate() expects its parameters to remain valid while the
indicate procedure is active. But the `sc_range` variable was local to
the function. It is assigned to the `data` field and passed on to
bt_gatt_indicate(). The memory associated with `sc_range` goes out of
scope as soon as the function returns thereby breaking the contract of
the API. This dangling reference will lead to undefined behavior.
This is now fixed by making the `sc_range` array static and further
making it an array of arrays, as the sc_range may have different values
for each connection.

Found as violation of MISRA C:2012 and CERT DCL30-C by sonarcloud.

Signed-off-by: Balaji Srinivasan <balaji.srinivasan@nordicsemi.no>
2023-05-12 09:55:53 +03:00
Erik Brockhoff
b49ce8febe Bluetooth: controller: fixup HCI LE Create CIS 'parameter' checks
BT Core Spec states that feature exchange should be initiated if
not already performed. So in this case initiate feature exchange
and 'abort' enqueued CIS create if peer doesn't support CIS peripheral
feature

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Erik Brockhoff
105621bdce Bluetooth: controller: Only generate ntf on host initiated feature exch
Only generate notification when feature exchange was initiated by host

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Erik Brockhoff
c1b5aaecf8 Bluetooth: controller: confirm central role on CIS Create
Confirm that the 'requesting connection' is acting as central

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Johann Fischer
2dbccf0654 usb: device_next: do not set alternate 0 for non-existent interfaces
A request to set alternate zero for a non-existent interface
would succeed because of the inappropriate order of checks.
Move the check if the desired alternate is the same as the
current one after the check if interface exists.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Johann Fischer
aa5b6db0f4 usb: device_next: correct return type of get/set alternate value helper
Correct the return type of the helper function to get/set
current interface alternate value.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Johann Fischer
e3b17aa5ed usb: host: improve robustness of descriptors print
Check that the length of the packet is at least the size of
the descriptor head. Otherwise there may be unpleasant side effects.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Andrei Emeltchenko
a4341bbc2c bluetooth: audio: Fix logical check
I imagine that expression (req != 0 || req != 1) is always true. Fix
it changing '||' to '&&'.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-11 13:29:46 +02:00
Georges Oates_Larsen
62168b659e net: conn_mgr: connect/disconnect adjustments
Rather than raise error on connect if iface is down, just take the iface
up.

Rather than raise error on disconnect if iface is down, just ignore the
disconnection request.

Adjust tests and documentation accordingly.

This should make the API easier to use for applications and is more in
line with the original L2 agnostic connectivity RFC.

Also replace some instances of net_if_flag_is_set with
net_if_is_admin_up, which is cleaner and identical in function.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
068dc8ba6f net: conn_mgr: Simplify DAD handling
The current method for handling DAD directly tracks a DAD state for each
iface.

This does not reflect the fact that each individual IP has a separate
DAD state.

This also does not align with the logic in conn_mgr_initial_state, which
instead uses net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...).

Thus, the current approach falsely reports IPv6 ready when DAD adds
the link_addr, and also fails to report IPv6 ready if DAD is disabled.

This commit removes DAD tracking completely, and relies solely on
net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...), fixing both
problems, and simplifying the event tracking.

For consistency, slight modifications to IPv4 handling as well.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
74ba47bed0 net: conn_mgr: Fire events only on connectivity gain/loss
Currently, conn_mgr fires L4_CONNECTED and L4_DISCONNECTED events for
every individual iface that gains or loses connectivity.

After this commit, these events are only fired when the first iface gains
connectivity, and the last iface loses connectivity, respectively.

This is so that applications can rely on conn_mgr as a simple way to
track whether connectivity is available.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
b6897c211a net: conn_mgr: Ignore ifaces and L2s
Adds a flag to allow ifaces and L2s to be ignored.

This is so that applictions have better control over what ifaces they
want connectivity management for.

Enabling the flag forces conn_mgr to consider the iface
unready.

Also increase NET_CONNECTION_MANAGER_PRIORITY default value from 0 to 1
so that applications can register SYS_INIT callbacks that fire just
before conn_mgr initializes. This allows ignored ifaces to be configured
before conn_mgr starts, if needed.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
6cda221c53 net: conn_mgr: refactor event logic
In preparation for altering the conditions under which conn_mgr
fires NET_EVENT_L4_CONNECTED and NET_EVENT_L4_DISCONNECTED,
refactor the event logic without changing its behavior.

These changes do not alter the behavior of conn_mgr. They merely change
how that behavior is expressed so that it is easier to understand, and so
that upcoming changes are easier to implement.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
7afca97f9e net: conn_mgr: Add thread-safety
Current implementation does not prevent the net_mgmt thread from
preempting during state change handling and generating more
state changes. Add a mutex to protect internal state of conn_mgr

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
ad7e0d3712 net: conn_mgr: Rename flags
Rename internal flags for clarity

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
41d6a9bcec net: conn_mgr: relocate if_get_binding
Relocate conn_mgr_if_get_binding to conn_mgr_private.h so that it
can be used by test suites.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
716c19f7ef net: conn_mgr: Reorganize files
Since conn_mgr is a subsystem rather than a library, relocate it
directly into subsys/net rather than subsys/net/lib/

Rename header files to better match their function.

Remove net_ prefix from conn_mgr types, API, and files, since it is
unnecessary.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Vinayak Kariappa Chettimada
7eaf577772 Bluetooth: Controller: Fix Peripheral CIS supervision timeout
Fix premature Peripheral CIS supervision timeout due to
corrupted trx_performed_bitmask value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Vinayak Kariappa Chettimada
875349047e Bluetooth: Controller: Fix Peripheral CIS receive window size
Fix peripheral CIS receive window to consider that the
peripheral ACL could drift at the instant the CIS is being
established.

Hence add additional EVENT_TICKER_RES_MARGIN_US as receive
window length.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Vinayak Kariappa Chettimada
9338ecc5b8 Bluetooth: Controller: Fix Central CIS scheduling precision
Fix Central CIS offset scheduling to microsecond resolution
precision. CIS offset calculation was missing the ACL event
remainder value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Johann Fischer
71d9b0d5ff usb: device_next: add CDC ECM class implementation
Add CDC Ethernet Control Model class implementation for the
new experimental USB device support based on the existing
implementation subsys/usb/device/class/netusb/function_ecm.c.

The implementation forms virtual ethernet connection between
USB host and USB device and requires two corresponding MAC
addresses, one for the virtual interface on the device side,
and other for the host which is described by a string descriptor.
With upcoming changes it should also possible to use a real
ethernet controller as media access on the device side.

CDC ECM implementation supports multiple instances which are
specified using DT. The number of instances is limited by the
number of endpoints on the controller, two to three should usually
be possible.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 11:26:54 +02:00
Nithin Ramesh Myliattil
8d6b206064 subsys/bluetooth/host: Make rpa same for adv sets with same id
Add check to see if RPA is already generated for adv sets
with same id. If generated use the same address for all adv sets
with same id else create new RPA.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2023-05-11 08:31:24 +00:00
Emil Gydesen
563b66bc29 Bluetooth: BAP: Shell: Broadcast assistant compiler warning fixes
Fixes a few compiler warnings from the BAP Broadcast Assistant
shell modules.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-11 10:15:10 +02:00
Vinayak Kariappa Chettimada
a2a2b86665 Bluetooth: Controller: Fix uninitialized CIG num_bis member variable
Fix uninitialized CIG num_bis member variable on CIG Remove.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 10:05:55 +02:00
Emil Gydesen
117f6295d1 Bluetooth: BAP: Broadcast source validate subgroup count in create
Add proper validation check for the number of subgroups
attempted to be added to the broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-11 10:05:41 +02:00
Emil Gydesen
afd4161a84 Bluetooth: BAP: Broadcast start add missing NULL check for adv
Added missing NULL check for the advertising set pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 17:54:12 +02:00
Emil Gydesen
926219156b Bluetooth: Audio: Shell: Add preset copy functions
Add common preset copy functions for unicast streams and
broadcast sources.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 15:27:46 +02:00
Emil Gydesen
4d43101fa7 Bluetooth: Audio: Shell: Make broadcast source generic
Implement profile-agnostic broadcast source and broadcast
stream structs, similar to the unicast stream struct.

The purpose of these are to be able to use the same structs
for multiple profiles such as BAP, CAP and TMAP.

Since only the BAP shell implements broadcast support at this
moment, the changes are minimal, but makes it easier to implement
broadcast support for other profile shells.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 15:27:46 +02:00
Flavio Ceolin
942b99a322 usb: audio: kconfig: Fix experimental feature
select EXPERIMENTAL for experimental option.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-10 11:41:50 +02:00
Flavio Ceolin
9b1da61d6a lwm2m: kconfig: Fix experimental feature
select EXPERIMENTAL for experimental option.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-10 11:41:50 +02:00
Robert Lubos
ff0fd2d7a7 net: iface: Improve thread safety of net_if_ipv*_maddr_* functions
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Robert Lubos
45cb3f9813 net: if: Improve LL address access thread safety
As `net_if_get_link_addr()` returns a pointer to the link layer
structure, some extra protection is needed to prevent its contents from
being changed while accessed. Using the mutex lock associated with an
interface should do the trick.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Robert Lubos
838a94288e net: if: Rework interface locking
Instead of having a single global mutex, covering, in most cases
unrelated, access to all network interfaces, introduce a separate mutex
for each network interface.

Wherever interface function operates on an individual interface context
data, use local mutex protection instead. The global mutex remains only
to protect access to shared resources (IPv4/6 context pool, timer lists
etc.).

Finally, rework the timer expiry handlers, to prevent interface
functions from being called while the global lock is held (the global
mutex has to be held when iterating over the timer list, as lists are
not thread safe). The reason for this is to avoid possible deadlock
scenario. The global mutex is sometimes being locked, while inside
interface function (protected by a local mutex), so if it was allowed
the other way as well, a deadlock could occur.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Emil Gydesen
5ce5940ac5 Bluetooth: CSIP: Fix issue with ordered access without lock char
Fixed issue when performing the ordered access procedure on
a set of devices where none had the lock characteristics.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
41fd5b80df Bluetooth: CSIP: Add missing and fix Set Coordinator set info
The set info returned by the Set Coordinator did not contain
information about the lockable state. Furthermore the
set info was not properly initiated, as it was missing the
rank, which was set somewhere else.

This commit adds the lockable state to the set info.
This commit removes the rank from internal structure,
and uses a reference to the set info instead, and only
store the rank there.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
f3259daa8a Bluetooth: CSIP: Fix Set Member set size and rank param validation
The set size and rank validation did not allow setting e.g.
rank = 2 and set_size = 0, which should be allowed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
3f8daa6762 Bluetooth: CSIP: Add support for optional characteristics
Whenever a CSIS instance is registered with
bt_csip_set_member_register we now properly check if the
set size, rank and lock characteristics should be present.
If not, then remove them from the service declaration.

It is done this way, as it is easier (read: possible) to
remove characteristics from the service declarations,
than it is to add the optional characteristics, as the
optional characteristics may be present in some CSIS
instances, but not in others.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
8ae46910c8 Bluetooth: CSIP: Avoid multiple conn CBs registers
The bt_csip_set_member_register function would register
the connection, and connection auth info, callbacks for
each CSIS instance, which could give errors when/if the
callbacks are called too many times. In any case, they
should not be registered multiple times.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Georgij Cernysiov
464f6f6438 net: l2: ethernet: lldp: prevent slist corruption
LLDP start timer is executed when iface is up
at startup, then once more when iface up event
is received.

When iface is up before net_lldp_init call, then multiple
entries are added to the lldp_ifaces related to the
same iface.

That leads to continuous loop execution within
lldp_tx_timeout.

This commit checks if lldp tx_timer_start is set and
doesn't append new entry into the slist.
The tx_timer_start is set at startup and reset on
down event.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-05-10 16:54:44 +09:00
Emil Gydesen
8c2df1bfd5 Bluetooth: BAP: Add return error for sink cb register
Since the provided callback can be NULL which would
break things, add a check and a return value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 16:54:10 +09:00
Emil Gydesen
70b88378f9 Bluetooth: BAP: Limit broadcast sink streams to proper max value
The number of streams for a broadcast sink is maximum 31,
or the maixmum number of BIS we support.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 16:53:56 +09:00
Tom Burdick
ea8930bd78 rtio: Cleanup the various define macros
Reworks the zephyr macros and pools to be objects in their own right. Each
pool can be statically defined with a Z_ private macro. The objects can
then be initialized with an rtio instance statically.

This cleans up a lot of code that was otherwise doing little bits of
management around allocation/freeing and reduces the scope those functions
has to the data it needs.

This should enable sharing the pools of sqe, cqe, and mem blocks among rtio
instances in a future improvement easily.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Tom Burdick
e4b10328b4 rtio: Use mpsc for submission and completion queue
Rather than the rings, which weren't shared between userspace and kernel
space in Zephyr like they are in Linux with io_uring, use atomic mpsc
queues for submission and completion queues.

Most importantly this removes a potential head of line blocker in the
submission queue as the sqe would be held until a task is completed.

As additional bonuses this avoids some additional locks and restrictions
about what can be submitted and where. It also removes the need for
two executors as all chains/transactions are done concurrently.

Lastly this opens up the possibility for a common pool of sqe's to
allocate from potentially saving lots of memory.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Vinayak Kariappa Chettimada
92f0b5490c Bluetooth: Controller: Fix uninitialized ticks_slot in CIS create
Fix use of uninitialized ticks_slot value in calculation of
cis_offset_min when creating CIS. Calculate the ticks_slot
value earlier when committing the CIG parameters.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:31 +02:00
Vinayak Kariappa Chettimada
9c95dce9a4 Bluetooth: Controller: Fix incorrect use of rx buffer in Tx ISR
Do not enqueue node rx buffers for generating invalid ISO
data from Tx ISR while supplying the node rx buffer to
Radio. This causes node rx pool corruption and also MIC
failures in the central ISO LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
038c89b2c9 Bluetooth: Controller: Remove redundant CIS encryption code
Remove redundant unused CIS encryption related code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
0777583ca1 Bluetooth: Controller: Fix peripheral ISO data ack mechanism
Fix peripheral ISO data ack mechanism to correctly update
the SN when PDUs fail to be received.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
0b27981f94 Bluetooth: Controller: Do not disconnect all CIS on MIC failure
Fix implementation to not disconnect all CIS when one
connection has MIC failure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
8a376a747e Bluetooth: Controller: Use strict cis_offset_min when CIG is active
When there is an active CIG for a new CIS create, then use
strict cis_offset_min/cis_offset_max so that the new CIS
is scheduled inside the active CIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 15:04:32 +02:00
Ajay Parida
7f9ba751e9 net: wifi_mgmt: Handle ps command error
Failure of setting ps param is handled with error string
at user/ app level.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
49e6b0c256 net: shell: Code cleanup for ps related commands
Setting ps_mode and ps_timeout related changes handled
in single power save op.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
bdef1bad78 net: wifi_mgmt: Configure ps wakeup mode
'ps_wakeup_mode' is used to set the wake up interval
to either 'dtim or 'listen_interval'. By default the
sta wakes up every dtim interval.
With 'ps_wakeup_mode' set to 'listen_interval' sta
will wake up for every listen interval period configured.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
68403669c6 net: wifi_mgmt: Configure listen interval
listen interval is the time periods the STAs may be in idle
without listening beacons.
By default STA wakes up for every DTIM period.
If listen interval based power save is used
STA uses configured listen interval period(default 10
beacon intervals) to wake up.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Dmitrii Golovanov
63fc307404 tests: ztress: Extend ZTRESS_EXECUTE() description
Add more details on the number of thread contexts possible
for ZTRESS_EXECUTE().

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-09 08:47:53 -04:00
Dmitrii Golovanov
130652efbd tests: ztest: ztress: Fix out-of-bounds at ztress_execute
Fix ztress_execute() out-of-bounds in case it is called with timer
and for maximum number of threads allowed (CONFIG_ZTRESS_MAX_THREADS).

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-09 08:47:53 -04:00
Mahesh Rao
d3010aae80 subsystem: sip_svc: Add SDM mailbox specific shell
Add shell based on sip_svc subsystem to access the SDM mailbox in
EL3 layer using ASYNC sip_svc request.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-05-09 08:46:50 -04:00
Mahesh Rao
dc9dc3d044 subsystem: sip_svc: Add ARM SiP SVC subsystem
Introduce a new SiP SVC subsystem to provide ARM Silicon Provider based
supervisory call services. SiP SVC service provides the capability to
send SMC/HVC call from kernel running at EL1 to hypervisor/
secure monitor firmware running at EL2/EL3 and also added SiP SVC shell
commands to exercise the service.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-05-09 08:46:50 -04:00
Jamie McCrae
aaed91ec4f mgmt: mcumgr: grp: img_mgmt: Only verify image if hash is valid
Prevents verifying the image has been uploaded successfully using
the hash provided at the start of the upload if the hash is not
the correct length of an SHA256 hash.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-09 14:29:05 +02:00
Herman Berget
688f5baded Bluetooth: Host: Fix warning from the logging subsystem
Cast `dhkey` to `void*` to avoid a warning from the logging subsystem:
```
<wrn> cbprintf_package: (unsigned) char * used for %p argument.
It's recommended to cast it to void * because it may cause misbehavior
in certain configurations
```

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-09 14:28:49 +02:00
Pavel Vasilyev
1fdf283531 Bluetooth: Mesh: Remove outdated RPL entries in settings work item
This allows to move flash operations from the context that triggered
IVI update to the mesh settings work item that runs on the system
workqueue. After this change, the outdated RPL entries will be removed
in the setting work item triggered by store_pending function in
mesh/settings.c. This is required to for a case where the mesh settings
work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-09 13:03:38 +02:00
Troels Nilsson
c743edaaa6 Bluetooth: Controller: Fix endianness handling for DID/SID struct
Bitsets across byte boundaries does not work properly for big-endian;
Converted to use two uint8's instead

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-05-09 13:03:28 +02:00
Vinayak Kariappa Chettimada
81c9795023 Bluetooth: Controller: Set Broadcast ISO related supported cmd bits
Set Broadcast ISO related HCI Read Supported Commands bits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 11:30:41 +02:00
Ajay Parida
bdec033889 net: shell: Display TWT response details
Show TWT response parameters details.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 09:24:30 +02:00
Krishna T
2b48c92742 net: wifi: Fix TWT interval
As we are using a generic validation function for limits, due to data
type mismatch the check for TWT interval overflow and fails.

Fix the data type and accordingly the maximum value in the help.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-09 16:24:10 +09:00
Aleksander Wasaznik
bb1ede6a9b Bluetooth: Use bt_addr_eq
Refactor. Using `bt_addr_eq` instead of `bt_addr_cmp`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-05-09 09:23:52 +02:00
Xudong Zheng
79c4c82baf logging: change log_output_timestamp_to_us() to take log_timestamp_t
If CONFIG_LOG_TIMESTAMP_64BIT is enabled, the timestamp will be 64-bit

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2023-05-08 16:57:02 -04:00
Emil Gydesen
68d1d7d1b4 Bluetooth: Audio: Shell: Add broadcast assistant add broadcast_id
Add command to add a source by the broadcast ID. This will
initiate scanning for the broadcast ID, making it unnecessary
for the user to keep track of both the broadcast ID, the SID
and the address, and just focus on the (properly) known
broadcast ID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
d97b0e1ea9 Bluetooth: Audio: Shell: fix missing opt arg for assistant scan_start
The command has an optional parameter that could not be used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
ed2d30e382 Bluetooth: Audio: Shell: cmd_bap_broadcast_assistant_broadcast_code use hex
The cmd_bap_broadcast_assistant_broadcast_code used decimal, instead
of hex, for the broadcast code, making it a lot harder to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
f24e9d9fcd Bluetooth: Audio: Shell: Print BIS Sync as hex
Since the value is a bitfield, printing it as hex makes it easier
to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
8a3aa4c289 Bluetooth: Audio: Shell: Remove name from bap_broadcast_assistant_scan_cb
The callback does not have the advertising data, so the name
would always just be empty.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
1ef2ce40d6 Bluetooth: Audio: Add PA sync broadcast shell commands
Add shell commands to add a PA sync as a broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a180c013db Bluetooth: Audio: Modify broadcast_id prints/logs to use 24-bit
Always print/log the 24-bits (as hex) of the broadcast ID to better
use it with e.g. the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
f2ce934209 Bluetooth: Audio: Add additional logging to broadcast assistant
Adds additional logging, as well as making the API param checks
more similar.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
043241d6fa Bluetooth: Audio: Broadcast Assistant: Fix subscribe issue
If starting the discovery procedure multiple times, the
subscribe function returns -EALREADY which needs to be handled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
fa70c86cd6 Bluetooth: Audio: Add common audio shell print commands to audio.h
Move common audio shell print functions into audio.h.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a431f5235b Bluetooth: Audio: Move the decode_base functionality to a public function
Moved the implementation of the pa_decode_base to a public
function, and modified it to return better error codes.

The implementation was moved to be publically
accessible, rather than internal in the Broadcast Sink,
as e.g. a Broadcast Assistant need to be able to decode the
BASE too. This wil also allow an application to decode it
itself, if it so wanted to.

This also adds a log module for the audio.c file, as logging
would otherwise not be supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
e23a5234a1 Bluetooth: Audio: Make broadcast assistant params const
Make the add and mod source parameters `const`, as well
as the broadcast code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
4e5a3b9e79 Bluetooth: Audio: Broadcast Assistant: Verify PAST support
Verify that PAST would be possible before providing
BT_BAP_BASS_PA_REQ_SYNC_PAST as the PA sync value to the
Scan Delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a6bd893d55 Bluetooth: Audio: Make pa_sync boolean
Make the `pa_sync` field of the
bt_bap_broadcast_assistant_add_src_param and
bt_bap_broadcast_assistant_mod_src_param to boolean
instead of uint8_t, as it represents a boolean value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Herman Berget
1f43e126a8 Bluetooth: Host: Fix setting missing params in create connection v2.
The adv_handle and subevent were always set to 0.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-08 11:24:25 +02:00
Dmitrii Golovanov
4694b15605 net: pkt: Fix possible NULL dereference at net_pkt_cursor_operate()
Fix possible NULL dereference at net_pkt_cursor_operate() and
resolve 'Dereference after null check' warnings from the Coverity
static code analysis.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-08 17:40:41 +09:00
Fredrik Danebjer
da25ed53d0 Bluetooth: audio: Add paired_ep to endpoint info
Added paired_ep to bt_bap_ep_get_info, which would allow to check
whether an endpoint is paired with another endpoint, this would
indicate that its coupled to a bidirectional iso.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-05-08 10:25:07 +02:00
Piotr Jasiński
e010dcee5d net: update tfm dependency for psa
TFM is not the only provider for PSA API, which means
the PSA config shouldn't depend only on it.

Signed-off-by: Piotr Jasiński <piotr.jasinski@nordicsemi.no>
2023-05-08 10:23:18 +02:00
Emil Gydesen
4421b80dd1 Bluetooth: ASCS: Fix receiver_ready on state change
The receiver_ready field can only be set while in the enabling
state, and is a requirement to go into the streaming state.

If for any reason we go into a state that is not enabling
or streaming, then the receiver_ready field should be
cleared, as the circumstances are changed.

This also fixes an issue where if the CIS disconnects,
then we go from the streaming state to the
qos configured state, without clearing it, causing
incorrect behavior if we attempt to connect the streams
again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 09:59:44 +02:00
Marek Pieta
8df81737e0 mcumgr: img_mgmt: Let image version comparison use build number
Change allows using build number in image version comparison.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-05-08 09:59:19 +02:00
Marek Pieta
ce18ed05d1 mcumgr: img_mgmt: Fix check for upgrade-only
Change fixes check for upgrade-only to ensure that the the new image
version is greater than version of the currently running image.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-05-08 09:59:12 +02:00
Pavel Vasilyev
177e9b93bf Bluetooth: Mesh: Add API to store model's user data in settings work
Mesh models may have a data that needs to be stored persistently.
Currently, the models should call bt_mesh_model_data_store and the store
will happen in the calling context. Most likely that it will be called
in BT RX thread as this is the context from which model's opcodes
handlers are called. Thus, the thread will be blocked until the store is
finished.

Another issues is that some models may have states that changes
frequently. Triggering the store on every state change may wear out
flash. Therefore, the models need to implement some postpone mechanism
to reduce the flash wear out.

The mesh stack has already implemented the mechanism of deferred store
with its own settings. The models could use it instead of implementing
their own mechanism.

In combination with the mesh settings workqueue, the models can store
their data without blocking the stack work.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-08 09:58:21 +02:00
Pavel Vasilyev
e33a4ace0f Bluetooth: Mesh: Use separate workq for storing mesh settings
Currently mesh settings are stored in the system workqueue context.
Most of other stack functionality, such that advertisements (incl
relay), loopback, transport sar, beacons transmission, etc. is also
processed in the system workqueue context. When a massive amount of
data needs to be stored and in particularly when page erase needs to
be triggered by GC of NVS subsystem to allocate flash pages, the
execution of the stack (and other functionality that uses the system
workqueue) will be blocked until storing is finished. For example,
right after the provisioning of a erased device, a node may not be
responsive for up to 400ms before it can continue sending messages.
The waiting time may increase if there is a GATT connection in the
mean time.

When write or erase operation is triggered, the flash driver waits for
Bluetooth controller to allocate a time needed to perform the operation.
During the whole operation, the context from which the operation was
triggered is put to sleep. This allows other threads to run until
Bluetooth controller finds the time for the flash driver. In other words,
every settings_save_one or settings_delete should be considered as
rescheduling points.

Considering this, Bluetooth mesh can use another thread to store its
settings, thus releasing the system workqueue for other tasks including
the operation of the stack itself.

The consistency of the data to be stored is guaranteed by the current
implementation where the data is copied to another struct before calling
settings_save_one. The pending flag of a particular module is dropped in
settings.c before starting to store the corresponding data. Thus, if
during the sleep the node receives a message that triggers a change in a
module which data is currently being stored, the pending flag will be
restored and the new change will be stored eventually.

Having this option enabled including with the partial erase, will make
the node more responsive in the described situations.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-08 09:58:21 +02:00
Emil Gydesen
8d24d506b3 Bluetooth: Audio: Shell: Move audio defines to audio.h
The generic BT shell header, bt.h, contained quite a few things
related to audio, which should be put in the audio.h shell header
file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-05 16:17:59 +02:00
Vinayak Kariappa Chettimada
c01cd1c482 Bluetooth: Controller: Review rework changes for multiple CIS support
Assorted review rework changes for multiple CIS support
implementation commits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
94821ef04c Bluetooth: Controller: Preliminary multiple peripheral CIS support
Updated nRF5 Series LLL implementation to support multiple
peripheral CIS establishment from peer central devices.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
3306f3160f Bluetooth: Controller: Central multiple CIS using advanced scheduling
Central multiple CIS create implementation using advanced
scheduling to find the active CIG events and calculate the
CIS offset to be used in the LL_CIS_REQ PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
2007967553 Bluetooth: Controller: Use Conn ISO prepare latency to check timeout
Use accumulated connected ISO LLL prepare callback latencies
to check supervision timeout.

Also use the accumulated connected ISO LLL prepare callback
latencies to adjust SN and NESN values.

Connection establishment can cause short prepare callbacks
inserted before Connected ISO group prepare callbacks, that
cause the Connected ISO group prepare callbacks being
cancelled while being in prepare pipeline. Hence, it is
necessary to accumulate prepare callback latencies wherein
ticker callbacks are executed but prepare callbacks are
cancelled in the prepare pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
ef8b05e83a Bluetooth: Controller: Preliminary Central multiple CIS support
Implementation of preliminary Central with multiple CIS
create support in Lower Link Layer. Uses a simple CIS
offset calculation that works when ACL are created with
connection interval that is multiple of CIG ISO interval.
Each ACLs are offset using BT_CTLR_CENTRAL_SPACING hence
having the same CIG sync delay values for all the ACLs.
Advanced Scheduling to setup CIS in any order of ACL and
CIS combination, ACL placed anywhere in timeline and CIS
creation will come therein will be implemented in later
Pull Requests.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
5152672d06 Bluetooth: Controller: Include remainder when calculating cis_offset
Include ticker expire remainder value when calculating the
cis_offset to acheive fine timing in scheduling the CIG
radio events relative to its associated ACL radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
e09c2ddf7a Bluetooth: Controller: Use ticker_start_us for Central and ISO setup
Use the ticker_start_us() interface for Central and Central
ISO setup to acheive fine timing for the first expire
timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
4e65cae32a Bluetooth: Controller: Ticker first expire with remainder
To acheive microsecond or fine timing for first expire
timeout, pass remainder value of the coarse tick to a new
ticker_start_us() interface. The new interface is available
with BT_TICKER_EXT feature enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
285649c894 Bluetooth: Controller: Fix implementation of CIS Null PDU Indicator use
Fix implementation of CIS Null PDU Indicator use to meet the
BT Specification statement, that, if the source of the data
fails to provide a payload in time for a CIS subevent, then
the link layer shall transmit a CIS Null PDU instead.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9ccf70fd27 Bluetooth: Controller: Extended Advertising using ticker expire info
This is re-introduction of Extended, Periodic Advertising
and Broadcast ISO using ticker expire info feature to get
the aux, sync and BIG offsets.

Relates to commit 714d74b77b ("Bluetooth: controller: Use
new ticker feature to get offsets").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
6a1a93e587 Revert "Bluetooth: controller: Use new ticker feature to get offsets"
This reverts commit 714d74b77b.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9cada37d9b Bluetooth: Controller: Add BT_TICKER_EXT_EXPIRE_INFO Kconfig
Add BT_TICKER_EXT_EXPIRE_INFO Kconfig.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
52615afcf1 Bluetooth: Controller: Remainder and Lazy depends on match get
Ticker remainder and lazy get depends on match get interface
provided by BT_TICKER_NEXT_SLOT_GET_MATCH.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
e912a6589a Bluetooth: Controller: Remove redundant Kconfig range and default
Remove redundant range and default for BT_CTLR_ADV_AUX_SET
when supporting BT_CTLR_ADV_PERIODIC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
08c1b1749a Bluetooth: Controller: Fix BT_TICKER_NEXT_SLOT_GET select
Fix BT_TICKER_NEXT_SLOT_GET select, to depend on
BT_CTLR_SCHED_ADVANCED.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9600c94c4b Bluetooth: Controller: Fix BT_TICKER_EXT BT_TICKER_LOW_LAT dependency
BT_TICKER_EXT is not supported with BT_TICKER_LOW_LAT.
Remove redundant select of BT_TICKER_EXT for
BT_CTLR_ADV_EXT.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
3fb90bb601 Bluetooth: Controller: Group depends on together in Kconfig file
Group depends on clauses together in the Kconfig.ll_sw_split
file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Emil Gydesen
2a2f067333 Bluetooth: HAS: Add missing memset of read params
The missing memset caused invalid chan_opt when EATT was
enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-05 11:26:11 +02:00
Maurits Fassaert
42507c69c2 storage: flash_map list partition labels
Add the labels from the device tree fixed flash partitions
as a column to the flash_map list shell command.

Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
2023-05-05 10:02:19 +02:00
Herman Berget
a947af8ac3 Bluetooth: Host: Fix PHY translation from HCI
HCI events use different values for the PHYs than the GAP macros.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-04 20:50:58 +02:00
Erik Brockhoff
44df982d0b Bluetooth: controller: disallow enc start/pause when CIS established
Start/pause encryption should not be initiated on ACL with CIS
established (BT Core Spec 5.4, Vol 6, Part B, Sect. 5.1.3)
Adding test for the added procedure peek function

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-04 10:47:37 +02:00
Kumar Gala
b07be57875 logging: Use TYPE_SECTION macros for log dynamic
Clean up log_dynamic to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Kumar Gala
bae0a5b8b6 logging: Use TYPE_SECTION macros for log const
Clean up log_const to utilize macros for handling sections.

Update database_gen.py to match naming convention change.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Jonathan Rico
7d1a5f5554 Bluetooth: iso: use BT_ISO_SDU_BUF_SIZE()
Use BT_ISO_SDU_BUF_SIZE() instead of calculating manually.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
Jonathan Rico
fb10381328 Bluetooth: iso: use kconfig for userdata size
Use BT_CONN_TX_USER_DATA_SIZE when defining pools of buffers that will go
through `bt_conn_send_cb()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
Jonathan Rico
e460847b60 Bluetooth: host: don't fragment ISO if len <= MTU
MTU doesn't count against the ISO and ISO data headers.

Then a config with CONFIG_BT_ISO_TX_MTU ==
CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE should not fragment SDUs over HCI.

Also set the TS_Flag bit if a timestamp is present.

Fixes #56749

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
romain pelletant
75dd2c9904 net: lwm2m: use path as block context retrieval
Replace block context retrieval using object path instead of token.
Update block context structure
Fix issue #57165

Signed-off-by: romain pelletant <romain.pelletant@fullfreqs.com>
2023-05-03 10:01:37 +02:00
Herman Berget
bf4e3fe2a4 Bluetooth: Host: Fix sync subevent cmd length
The subevents were not considered in the length of the command.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-02 16:56:01 +02:00
Nikolay Agishev
0d8292ab6b ARC: Add HS4x support
Minimal HSDK4xD support

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-05-02 16:54:24 +02:00
Hunter Searle
898a59eb80 Shell: Edit shell to store/retrieve return values
This change to the shell API enables the user to retrieve the
return code of the most recently run shell command. This is
useful both for users wanting specific information beyond the print
statements in a command, but especially for automated users
that prefer a simple return code to parsing human readable text.
This was tested using all default shell commands, as well as
eeprom, flash, and i2c, where specific errors could be forced.
In all cases, the correct return value was returned by the new
retval command.

Signed-off-by: Hunter Searle <hsearle@xes-inc.com>
2023-05-02 16:52:21 +02:00
Emil Gydesen
66f8ab5a28 Bluetooth: BAP: Add specific error code for stopping stopped sink
If the broadcast sink is already stopped (i.e. the streams have
all been disconnected), then we can return a more useful
error code than EINVAL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-02 09:35:11 -05:00
Jordan Yates
8e603d091c Bluetooth: controller: Kconfig TX power dBm
Adds a Kconfig symbol which contains the default controller TX power
directly in dBm. This allows code to directly display/use the configured
power, instead of having to manually iterate over all the
`BT_CTLR_TX_PWR` options.

```
  LOG_INF("BT controller configured for %ddBm TX power",
          CONFIG_BT_CTLR_TX_PWR_DBM);
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-05-02 10:12:23 +02:00
Yuval Peress
3fd0a1508b rtio: fix bug in mempool release API
It was previously assumed that the 'sys_mem_blocks' struct would maintain
information about contiguous blocks allocated so the release API only
took the starting address. This led to an issue where allocating 2+
blocks would end up with a memory leak because any block not being the
first would never be released.

Add the buffer length as an argument so the correct number of blocks can
be released. Also, ammend the tests to match and verify.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-01 09:26:06 -05:00
Paul He
322f5ad4ef storage: flash_map: shell: fix error 'sh' undeclared
Some of `shell` were missed to be updated with `sh`.

Signed-off-by: Paul He <pawpawhe@gmail.com>
2023-04-30 12:48:55 -05:00
Robert Lubos
d15f8e6337 net: shell: Print new flags with the net iface command
Print new NET_IF_IPV6_NO_ND and NET_IF_IPV6_NO_MLD flags when
the "net iface" command is used.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
ee1271f23c net: openthread: Disable ND/MLD for OpenThread interfaces
OpenThread networks do not use ND or MLD as they have their own set of
protocols to cover this functionality. So far, the use of OpenThread
with Zephyr relied on disabling those protocols support statically with
Kconfig, which prevented OT interfaces from being used along with other
IPv6 interfaces.

With the new network interface flags, it's now possible to disable ND
and MLD on individual interfaces, therefore disable them for OT
specifically.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
c349d53150 net: if: Add possibility to disable MLD per interface
Add new network interface flag, which allows to disable Multicast
Listener Discovery protocol from being used on the interface. This
allows to interfaces that do not support ND (like OpenThread) to
coexist with other IPv6 interfaces.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
c43c408783 net: if: Add possibility to disable ND per interface
Add new network interface flag, which allows to disable Neighbour
Discovery protocol from being used on the interface. This allows to
interfaces that do not support ND (like OpenThread) to coexist with
other IPv6 interfaces.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Pavel Vasilyev
1113c2efd4 Bluetooth: Mesh: Store device key candidate asynchronously
This allows to move flash operations from the context that triggered
storing device key candidate to the mesh settings work item that runs
on the system workqueue. This is required to for a case where the mesh
settings work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-29 12:24:28 +02:00
Pavel Vasilyev
f3085ab95d Bluetooth: Mesh: Move storing of new prov data to settings work item
This allows to move flash operations from the context that triggered
bt_mesh_provision or bt_mesh_reprovision to the mesh settings work item
that runs on the system workqueue. This is required to for a case where
the mesh settings work item is running on a separate thread instead of
the system workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-29 12:24:28 +02:00
Emil Obalski
169d8fafdc ipc: icmsg: Add mutual exclussion access to shmem
If the icmsg backend is sending the data from many
contexts, the send buffer must be accessed only by one
context at a time. Ensure that by adding mutex when
sending.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Emil Obalski
52e203f800 ipc: Remove internal API for clearing shared memory
Clearing of shared memory by one side of the communication
is no longer required after
commit 0620cb1fe1
("ipc: ipc_service: icmsg: Increase reliability of bonding")
was merged.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Stine Åkredalen
80158c1428 doc: Bluetooth: Mesh: update proxy solicitation docs
Updated related docs. Small fix in mesh/Kconfig and shell.rst.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-04-28 20:37:45 +02:00
Krishna T
30efd04060 net: Make net_mgmt queue timeout configurable
This helps us work with low queue depth of network management queue in
case the we have high rate events.

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

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-04-28 10:35:27 -05:00
Aleksander Wasaznik
67d6011851 Bluetooth: hci_raw: Fix a LOG_ERR message
The LOG_ERR was printing the wrong variable. `type` always has the value
`BT_BUF_H4` here, so there is no point in printing it.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-28 10:33:18 -05:00
Aaron Massey
07ee466591 emul: Migrate all emulation use to use DT_HAS_
Remove all enabling of CONFIG_EMUL_.* in favor of automatically enabling
peripheral emulators based on the compatible string presence in the device
tree and the one true CONFIG_EMUL.

Zephyr has long since moved to a model of enabling drivers based on the
presence of their associated IC's compatible string in the final devicetree
overlay. There is no reason that emulators can't align in just the same
way, and probably ought to to remove superfluous enabling of configs.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-04-28 08:37:33 -05:00
Herman Berget
5893606187 Bluetooth: Host: Use a valid disconnect reason
"Unspecified Error" is not a disconnect reason allowed by spec.

Fixes #56989

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 14:50:11 +02:00
Mariusz Skamra
292bf966be Bluetooth: audio: ascs: Make use of bt_bap_stream_reset
This deduplicates a code a bit by reusing existing bt_bap_stream_reset
function to unbind and detach the stream object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-28 14:49:25 +02:00
Mariusz Skamra
197e20e3c2 Bluetooth: audio: ascs: Remove redundant sessions pool
This removes redundant bt_ascs structure pool that held the list of
ases per connection. The memory usage can be reduced by moving the conn
reference to bt_ascs_ase structure. This change reduces flash and RAM
memory usage.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-28 14:49:16 +02:00
Herman Berget
d7218fe359 Bluetooth: Host: Add support for receiving connections while synced
The PAwR sync can receive a connection request from the PAwR
advertiser and become peripheral.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 11:00:48 +02:00
Herman Berget
c961e2c212 Bluetooth: Host: Add support for initiating connections from PAwR
This is known as the Periodic Advertising Connection Procedure.

The PAwR advertiser can initiate a connection to a synced device and
become the central.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 11:00:48 +02:00
Morten Priess
5b6198403c Bluetooth: controller: Fixes for CIG with two CISes and separate ACLs
Prevent referencing inactive CISes by clearing state variables
after teardown. This was seen as necessary when having CISes on
different ACLs, and disconnecting ACLs in random order.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-04-28 10:07:46 +02:00
Sam Hurst
0056249a13 usb-c: Add USB-C Subsystem Source PD Support
Add USB-C Power Delivery Source Support to USB-C
Subsystem

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
cb9a250579 usb-c: Refactor soft reset code
Refactor soft reset code

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
3851d3648d usb-c: Properly detect reception of first AMS message
Detect and flag the reception of the first AMS mesage

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
d1cf8148cc usb_c: Transmit Error are not Protocol Errors
Transmit errors must be treated differently than Protocol Errors.
This change sets a flag that informs the stack of a Message
Transmit error.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Emil Gydesen
5076476cf5 Bluetooth: BAP: Fix missing remove of streams from slist
In the broadcast sink when the streams disconnected (without
the PA disconnecting), the streams were not properly
removed from the sink's list of streams. This allowed
the same stream to be added to the list twice, which
would cause a infinite loop as the stream would
point to itself as the next.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-27 20:19:58 +09:00
Jacob Siverskog
6cefad338b Bluetooth: BAP: Shell: Fix NULL pointer dereference
Make sure 'state' is valid.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2023-04-27 20:18:55 +09:00
Ajay Parida
a004a85ccf net: shell: Check connection & capabilities in any TWT operation
Connection status & AP capabilities checked before any TWT operation
is initiated.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-27 09:52:00 +02:00
Herman Berget
e745439c40 Bluetooth: Host: Fix periodic sync reassembly
The reassembly buffer for periodic sync was not initialized
if the sync was established via PAST.

Move the initialization of the reassembly buffer to a common place.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Herman Berget
95bc5cf8e5 Bluetooth: Host: Add support for PAwR Sync
Adds API for Periodic Advertising with Responses - Scanner:
 - Synchronize to a PAwR train
 - Choose which subevents to synchronize to
 - Receive advertising reports from subevents
 - Send responses

The support is enabled by CONFIG_BT_PER_ADV_SYNC_RSP, and requires
a controller that selects CONFIG_BT_CTLR_SYNC_PERIODIC_RSP_SUPPORT.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Herman Berget
9021e2f438 Bluetooth: Host: Add support for PAwR Advertiser
Adds API for Periodic Advertising with Responses - Advertiser:
 - Configure parameters
 - Receive subevent data requests
 - Set subevent data
 - Receive response reports

The support is enabled by CONFIG_BT_PER_ADV_RSP, and requires
a controller that selects CONFIG_BT_CTLR_ADV_PERIODIC_RSP_SUPPORT.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Dmitrii Golovanov
560b777fa8 net: dhcpv4: Fix NULL dereference at dhcpv4_create_message()
Fix dhcpv4_create_message() dereferenced NULL return value from
net_pkt_alloc_with_buffer() in case of no memory available.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-26 20:07:04 +02:00
Dominik Ermel
00f1639e38 mgmt/mcumgr: Fix image erase returning MGMT_ERR_EMSGSIZE
In case when CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR=n then
the image erase command would incorrectly return MGMT_ERR_EMSGSIZE,
even though no such error occurred.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-26 18:15:40 +02:00
Dmitrii Golovanov
f7331e0d66 net: ipv4: Fix fragmented packet NULL dereference possible
Fix net_ipv4_send_fragmented_pkt() dereference of NULL return value
from net_pkt_get_data() possible with non contiguous packet data.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-26 14:34:23 +02:00
Jonathan Rico
ece481d560 Bluetooth: host: att: clear ATT_PENDING_SENT
The ATT_PENDING_SENT flag was still not being cleared in all cases.

Also reset `data->att_chan` when not able to send on a given channel.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Jonathan Rico
2809bace65 Bluetooth: host: l2cap: send only 1 credit
The API doesn't allow the stack to make any guarantees about the number of
available buffers that the app has.

Only send 1 credit at a time, as that is the only guarantee the stack can
give to the peer.

We can send MTU/MPS's worth of credits once we have acquired an SDU buffer
from the application (that is, on the first PDU of the SDU). Though we
still have to cap that to the buffer size we have just acquired.

------

The testcase added here shows a scenario where the relationship
between the number of credits and the number of available buffers does not
hold true any more:

In this test, the app only has one buffer in its pool.

The central will queue SDUs that are bigger than the stack's
buffers (so the user allocator is necessary) but lower than the
channel's MTU.

The device receiving the SDU keeps a reference to the buffer before
returning from the `recv` callback. It releases that reference after a
small delay.

The central will still have credits, so it will queue another SDU, but the
peripheral will not be able to receive the next SDU (as the allocator will
fail) and will close the channel.

To see the test fail, just revert the `l2cap.{c,h}` changes.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Jonathan Rico
6cdb82cb59 Bluetooth: host: l2cap: trigger SDUs that get lost in limbo
Turns out the [first bugfix] was too naive: there is a case where resuming
all channels will not work on all queued SDUs, and the work handler will
give up and wait for the next sent SDU instead of trying to resume again.

This happens when the number of credits and conn contexts is very low for
the amount of data to send.

Always reschedule with a delay to avoid that situation.

[first bugfix]: https://github.com/zephyrproject-rtos/zephyr/pull/50476

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Anas Nashif
6388f5f106 xtensa: use sys_cache API instead of custom interfaces
Use sys_cache instead of custom and internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-26 07:31:22 -04:00
Ryan McClelland
b19c8fc3bc net: ip: net_shell: fix double-promotions warnings
Double promotion warnings are generated with the flag -Wdouble-promotion

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-04-26 12:58:36 +02:00
Kumar Gala
0090ad718a net: Fix build issues with arm-clang
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:

	Error: L6218E: Undefined symbol
	net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
	(referred from ethernet.o).

Fix by adding ifdef protection around promisc code.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-25 19:59:06 +02:00
Ajay Parida
5c023fbbb9 net: wifi_shell: Updated TWT flow id range
TWT flow id is of 3 bit value(maximum mnumber of flows
supported is 8). Flow id range limited to 0 to 7.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-25 12:21:35 +02:00
Mariusz Skamra
d384ef4e57 Bluetooth: audio: ascs: Fix handling arrayed parameters
This fixes loop over arrayed metadata/cc parameters. The paramaters have to
be pulled from the buffer, because in case the ASE_ID is invalid or in
invalid state, the next loop iteration would read invalid data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-25 12:21:23 +02:00
Emil Gydesen
303bcfdcb7 Bluetooth: Shell: Add testcases for AUDIO_RX and TX disabled
Add configurations where CONFIG_BT_AUDIO_TX and CONFIG_BT_AUDIO_RX
are disabled.

Fixes issues found in the BT shell implemented caused by these
configurations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Emil Gydesen
2c5a249fdd Bluetooth: BAP: Add guard before accessing qos->latency
The qos->latency is not available for broadcast sink-only
builds.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Emil Gydesen
32e8392400 Bluetooth: BAP: Move TX guard to not cover verify funcs
Move the BT_AUDIO_TX guard so that it does not cover the
verification functions for valid_codec and qos, as they
are also relevant for receivers to verify what remote
devices send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Dmitrii Golovanov
6ec39dca6b net: ZWP timeout explicit type on bit shift calculation
Fix tcp_send_zwp() retransmission timeout calculation to avoid sign
extension on bit shift operation: the uint16_t value was implicitly
promoted to 32-bit signed type with sign extension to uint64_t.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-25 12:19:45 +02:00
Pawel Osypiuk
4b7f156403 IPC: rpmsg: Changed method of checking bounded endpoints
Initially that was checked by presence of name and now is changed
to check the flag.

Signed-off-by: Pawel Osypiuk <pawelosyp@gmail.com>
2023-04-24 15:45:09 +02:00
Hein Wessels
2689e16670 net: sntp: support building without NET_SOCKETS_POSIX_NAMES
Fixes the compiler error that occurs when attempting to build
the SNTP library with CONFIG_NET_SOCKETS_POSIX_NAMES=n, while
using native_posix.

Closes #57133

Co-authored-by: Chris Friedt <cfriedt@meta.com>
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-04-24 09:23:17 -04:00
Krzysztof Kopyściński
0a55ec8d52 Bluetooth: Mesh: Add callback for received beacons
This adds callbacks for Secure and Private Network Beacons.
SNB callbacks are called after `secure_beacon_authenticate` ends
with success, and Private Beacon callback after Private Beacon
payload is decrypted succsessfully.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-24 13:36:12 +02:00
Mariusz Skamra
81532bf5f0 Bluetooth: audio: ascs: Remove ascs_cp_rsp_add function redundant param
This removes opcode from ascs_cp_rsp_add function parameters and moves
response buffer initialization to be done in Control Point write
function context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-24 13:34:59 +02:00
Mariusz Skamra
9ec93b5bd5 Bluetooth: audio: ascs: Fix using magic numbers
Use defined values instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-24 13:34:59 +02:00
Sihyun Noh
3788ce3b8b fs: change fatFS initialization to match littleFS.
Mounting the disk in a global function can lead to an issue
where fatFS cannot be mounted due to it not being registered beforehand.
To solve this problem, fatFS is now initialized in POST_KERNEL,
just like the littleFS initialization function.
fatfs_init must be called before attempting to mounte the disk.

Signed-off-by: Sihyun Noh <awake_noh@naver.com>
2023-04-24 13:34:12 +02:00
Pavel Vasilyev
c4fa085ec4 Bluetooth: Mesh: Add async API for Large Comp Data Client
Add asynchronous API for Large Composition Data Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Pavel Vasilyev
b99d4dbce2 Bluetooth: Mesh: Use bt_mesh_msg_ackd_send API in LCD Client
Use bt_mesh_msg_ackd_send API in LCD Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Pavel Vasilyev
60e874472c Bluetooth: Mesh: Use BT_MESH_MSG_CTX_INIT_DEV macro in LCD Client
Use BT_MESH_MSG_CTX_INIT_DEV macro in LCD Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Aleksander Wasaznik
2091144c51 Host: ATT: Use bt_att_is_enhanced everywhere
Refactoring. All occurences of `atomic_test_bit((.*)->flags,
ATT_ENHANCED)` are replaced with `bt_att_is_enhanced($1)`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
af5103bdc3 Bluetooth: ATT: Set correct MTU for EATT L2CAP channel
The EATT MTU in Zephyr is static. We know it at channel creation time,
so we should communicate the MTU as part of channel creation.

Side note: With this approach, it should no longer be neccessary or
useful to do a channel reconfigure.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
3de6f7c99d Bluetooth: ATT: Move setting of initial MTU to att_chan_new
The L2CAP MTU can and should be set already during the channel setup.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
a2dc61a465 Bluetooth: ATT: MTU min instead of cap
The previous approach with `cap_eatt` was flawed. It would overwrite
`le_chan->tx.mtu`, losing its true value. (It is supposed to be the
L2CAP MTU as reported by the remote side.)

The previous approach worked out for UATT because the locally triggered
exchange always carries the remote MTU in the response, so we did not
need to keep track of the remote MTU.

But, unlike the UATT MTU exchange, the L2CAP reconfigure only exchanges
the MTU in one direction. If the remote does the first reconfigure, we
would correctly cap the ATT MTU to our local MTU. But, we would
incorrectly store this as the remote's MTU. When we then increase our
local MTU using `bt_eatt_reconfigure`, we correctly set and send our
MTU.  But we have an incorrect notion that the remote MTU is the value
that we ourselves limited. And mistake would incorrectly limit the
negotiated ATT MTU locally.

The simplest solution is to not mess with `le_chan->tx.mtu` and just
calculate the ATT MTU like Spec intended.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
fa9d41f39b Bluetooth: Host: Add helper bt_att_is_enhanced
This is a refactor. Hopefully, it makes the code easier to maintain.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
d4d0956516 Bluetooth: ATT: Split BT_ATT_MTU for UATT/EATT
This is a refactor. There is no behavioral change because
`BT_LOCAL_ATT_MTU_UATT` is `BT_LOCAL_ATT_MTU_EATT + 2` is
`BT_ATT_BUF_SIZE` is the old `BT_ATT_MTU`.

The old `BT_ATT_MTU` was wrong for EATT bearers. EATT MTU is two bytes
less because of ECRED overhead.

Instead of the old `BT_ATT_MTU`, we define one for each bearer type. We
also define the max of them to use as a convenience for allocating
buffers that fit either.

To avoid confusion, 'LOCAL' has been added to the name. This is to
differentiate it from what the spec calls 'ATT MTU', which is a
negotiated property. (It is the minimum of the two side's local ATT
MTU.)

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
46646452fe Bluetooth: L2CAP: Add missing req_mtu assert in l2cap_ecred_conn_req
There is an assert that `req_psm` is the same for all channels in the
same connection request because HCI requires this. The same is true for
`req_mtu`. This adds the obviously missing assert.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
3148389695 Bluetooth: ATT: Introduce bt_att_mtu
This is a refactoring, only visible inside `att.c`.

Give the expression `chan->chan.tx.mtu` the name `bt_att_mtu`. Use it
when the intention is to get the ATT MTU property of a channel.

This is done in preparation a more complex expression for `bt_att_mtu`,
since the expression currently incorrect. The fix will come in a later
commit in the same PR.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Dominik Ermel
783f8666fc mgmt/mcumgr: Add zcbor_map_decode_bulk_reset utility function
The function should be used to reset map decoding state
between calls to zcbor_map_decode_bulk, while using the same map
for different buffers.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:49 +02:00
Dominik Ermel
4878eebebb mgmt/mcumgr: Add missing initialization of internal state
There was missing initialization for found member of
zcbor_map_decode_key_val structure.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:49 +02:00
Dominik Ermel
a48e6b926c mgmt/mcumgr: Fix failure to confirm active image not reported
Due to broken logic in img_mgmt_state_confirm failure to confirm
was not reported to caller.
If hooks were enabled confirmation event would be passed regardless
whether it has been successful.

Fixes #56617

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:09 +02:00
Jamie McCrae
4cdfa7bdd5 retention: Add optional mutex disablement
Adds an optional Kconfig to disable use of mutexes in the
retention subsystem.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
5e8b067364 dfu: mcuboot_shell: Add command to enter serial recovery
Adds a command which can be used to enter mcuboot's serial recovery
mode when the retention subsystem is enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
7e11b6392b retention: Add boot mode system
Adds a boot mode system which allows for redirecting the boot
target of a device depending upon the state of a retained value.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
64f4404481 retention: Add retention system
Adds a retention system which builds on top of retained_mem
drivers to allow partitioning of areas and data integrity with
magic header prefixes and checksum of stored data.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
c8a0e8c598 mgmt: mcumgr: grp: img_mgmt: Remove dummy header
The dummy header was an opt-in feature to allow testing without a
real image but since we support testing on Qemu in CI which
supports flash partitions, there isn't a need for this option. Not
being deprecated as Kconfig would only have been used as part of
CI, not user applications.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-21 16:33:30 +02:00
Dawid Niedzwiecki
7f7e48e66e mgmt: ec_host_cmd: create chosen string per backend
Create strings to set the chosen node per backend. It is done for
better clarity.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-21 16:29:59 +02:00
Dawid Niedzwiecki
1d62002bba mgmt: ec_host_cmd: update configs naming
Just use better namings for the buffer sizes configs.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-21 16:29:59 +02:00
Emil Gydesen
5ab585d1af Bluetooth: ASCS: Log missing fields of qos_pref
Added logging of the pref_pd_min and pref_pd_max field.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 16:29:08 +02:00
Dominik Ermel
d4ab079cd9 mgmt/mcumgr: Add zcbor_map_decode_bulk_key_found utility function
Function allows to check whether given key has been found
during map decoding with zcbor_map_decode_bulk.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-21 16:28:34 +02:00
Emil Gydesen
4b8574d7b1 Bluetooth: BAP: Shell: Fix bad arg to CAP acceptor ad data
The data array was using the wrong index.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 16:23:27 +02:00
Mariusz Skamra
f35959a261 Bluetooth: ascs: Fix ASE Control Point PDU length validation
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.

ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
length operation if the total length of all parameters written by the
client is not equal to the total length of all fixed parameters plus
the length of any variable length parameters for that operation"

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 13:01:42 +02:00
Mariusz Skamra
3b57b2014c Bluetooth: audio: ascs: Fix invalid Response_Code in notification
This fixes sending proper Response_Code in ASE Control Point
notification in case the client initiates Receiver Start/Stop Ready
operation on Sink ASE.
The response that shall be sent according to the specification is
"Invalid ASE direction", while the implementation sent "Invalid ASE state"
instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 12:55:46 +02:00
Johann Fischer
75ab9f81e3 usb: device: fix control endpoint handling with MPS of 8 bytes
The possible control endpoint MPS for USB 2.0 FS devices is
8, 16, 32, or 64 bytes. Typically, USB2.0 compliant devices support MPS
up to 64 bytes, and we have not had the need to support other MPS.

This patch implements a mechanism to fall back to the minimum allowed
MPS when a controller is likely a USB 1.1 compliant device and does
not support control endpoint MPS of 64 bytes.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-21 12:45:57 +02:00
Emil Gydesen
8e7757275e Bluetooth: BAP: Guard bt_bap_stream_send with CONFIG_BT_AUDIO_TX
Modify the guard of bt_bap_stream_send to use the
CONFIG_BT_AUDIO_TX.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 09:40:39 +02:00
Emil Gydesen
3d877338e6 Bluetooth: BAP: Fix missing guards of sent and recv in uni cli
The unicast client did not properly guard the sent and recv
callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 09:40:39 +02:00
Theo Gasteiger
ce2ac63953 Bluetooth: Fix CONFIG_BT_CTLR_DEBUG_PINS_CPUAPP compile error
Fix appcore compile error when enabling CONFIG_BT_CTLR_DEBUG_PINS_CPUAPP.

Signed-off-by: Theo Gasteiger <gatcode@wdw.one>
2023-04-20 16:10:42 +02:00
Kumar Gala
caea9dc196 logging: Use TYPE_SECTION macros for log strings
Clean up log_strings to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:52:07 +02:00
Kumar Gala
301d0c4712 net: buf: cleanup net_buf_pool use of iterable section
Cleanup linker scripts for net_buf_pool section to use the linker
script related iterable section macros.

Also replace _net_buf_pool_list with macro's instead to complete
iterable section usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:50:04 +02:00
Emil Gydesen
fa95a7add2 Bluetooth: BAP: Add missing Broadcast source param checks
Several input parameter checks were missing in the BAP broadcast
source API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-20 10:47:10 +02:00
Martin Rieva
ddf518e706 Bluetooth: Shell: Extend the shell output of scan data
Add verbose output of scan data to output all received data types as
hex values. This is turned off by default and can be toggled using
the bt scan-verbose-output <on|off> command.

Signed-off-by: Martin Rieva <mrrv@demant.com>
2023-04-20 10:32:55 +02:00
Pieter De Gendt
7de95b76a6 net: lib: dns: mdns_responder: Fix ipv4/ipv6 address handling
This commit simplifies the arguments for sending dns responses
and fixes an issue where both the ipv4 and ipv6 member of a header
union were accessed.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Pieter De Gendt
292bb97f0d net: lib: dns: mdns_responder: Simplify setup_dns_addr
The setup_dns_addr function packet argument can be reduced to
a socket address family.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Pieter De Gendt
e5b52ac034 net: lib: dns: dns_sd: Improve debug prints
Duplicate logging prints make it hard to find the origin.
This commit does a cleanup of the debug messages printed.

Also change the level of an invalid record to debug as this
is out of our control.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Kumar Gala
eec299c130 pm: Use TYPE_SECTION macros for pm_device_slots
Clean up pm_device_slots to utilize TYPE_SECTION macros for handling
sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:15:29 +02:00
Wojciech Slenska
c3575fbd2e net: sockets: fix POLLOUT for offloaded iface
For offloaded iface net_tcp_get is never called, so context->tcp
is always NULL. In that case net_tcp_tx_sem_get will return wrong pointer.
For pollout k_poll will be called with NULL semph,
which cause HardFault.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-04-19 17:15:12 +02:00
Kumar Gala
47cf00058e fb: cfb: Use TYPE_SECTION macros for cfb_fonts
Clean up cfb_fonts to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:54 +02:00
Emil Gydesen
754a5da2ff Bluetooth: MICP: Shell: Add missing "mic_dev" for MICP cmds
The MICP Microphone Device commands were missing the proper
role name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 17:14:30 +02:00
Emil Gydesen
12e82347b4 Bluetooth: BAP: Shell: Scan Delegator prefer past by default
Change the default value of past_preference to true, to prefer
PAST by default when using the scan delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:55:09 -04:00
Emil Gydesen
66af395726 Bluetooth: BAP: Broadcast source fix invalid data pointer
When copying the stream specific codec configuration data,
the value pointer in the bt_data struct was not properly
updated, causing possible invalid data access.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:54:53 -04:00
Emil Gydesen
80bf8c0f7d Bluetooth: CAP: Add missing NULL checks for CAP broadcast start
Add missing checks for param and adv.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:54:37 -04:00
Emil Gydesen
dda3703755 Bluetooth: CAP: Add missing NULL check for unicast_audio_update
The bt_cap_initiator_unicast_audio_update function was missing
NULL and 0 checks for input parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 10:00:45 +02:00
Gerard Marull-Paretas
1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Vinayak Kariappa Chettimada
4b90d01398 Bluetooth: Controller: Fix cis_offset_min used in CIS Create Response
Use the minimum supported cis_offset_min considering that
ACL radio event does not overlap with CIG event. Use the
calculated maximum of local and remote cis_offset_min in the
Response PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-19 03:47:19 -04:00
Øyvind Rønningstad
31c10f5fe1 lwm2m_senml_cbor_encode.c: Manually edit whitespace
since it crossed the 100 column cutoff, even after clang-format.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad
d0c278af78 lwm2m_senml_cbor: Regenerate code files using zcbor 0.7.0
and the _regenerate.sh script.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad
e9eb61bd14 lwm2m_senml_cbor: Update the regenerate script and the patch file
Do patch file application before clang-format.
Add copyright to generated files using the --file-header option in zcbor.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Kumar Gala
6b5139c4bb shell: Convert to using iterable sections
Convert handling of shell_root_cmds, shell_subcmds, and
shell_dynamic_subcmds to use iterable section macros.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-18 12:48:16 +02:00
Georges Oates_Larsen
7c4397ae79 net: conn_mgr: connectivity API
Allows L2s to declare generic association/connection routines
that can be bound by name to ifaces.

Allows L2-agnostic control over connectivity/association for
iface that support it.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-04-18 09:31:53 +02:00
Aleksandr Khromykh
e7f1856143 Bluetooth: Mesh: add experimental support mbedtls psa
Commit adds experimental support mbedtls psa as crypto
backend for ble mesh. It were run only on bsim tests.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Aleksandr Khromykh
77c72aa67b Bluetooth: Mesh: get rid of host dependency for dh key for mesh
Commit gets rid of host dependency to generate DH key.
Mesh uses its own function for it that has synchronous
behavior and correct endianism. It simplifies the provisioning
state machine since it doesn't require waiting for the host HCI
handler.
Also, it removes hidden cross-dependency between BLE Mesh and
SMP in the aspect of competition for the same DH key
(https://github.com/zephyrproject-rtos/zephyr/issues/23292)

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Aleksandr Khromykh
3f08bd335f Bluetooth: Mesh: split crypto on seclib dependent and independent parts
Commit splits mesh crypto module on security library dependent
and independent parts.
Independent part includes security toolbox implementation.
Dependent part includes security algorithms usage based on
API third party security library.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Daniel Nejezchleb
663b684fea net: socket: fix hanging net contexts
Calls put instead of unref on net contexts
in the socket accept function.
Mere unref didn't subtract the reference
count of net context which leaves
it in used state. This situation happens
in case of accepting already
closed connection.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-04-17 15:12:41 +02:00
Daniel Nejezchleb
ee720b5412 net: socket: asynchronous connect
Added a feature of socket connect
being asynchronous. If socket is set
to nonblock with O_NONBLOCK flag,
then connect() is non-blocking aswell.
App can normally poll the socket to
test when the connection is established.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-04-17 11:35:20 +02:00
Johann Fischer
0ad1eef4b7 usb: device: Revert "fix possible deadlock in usb_transfer_sync()"
This reverts commit cd7461495f,
introduced to fix possible deadlock as result of changes in
commit f206170c65
("usb: device: Do not call callback when transfer is cancelled")
which is now reverted.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-17 11:30:48 +02:00
Nickolas Lapp
81e4934ebd usb: device: Revert "Do not call callback when transfer is cancelled"
This reverts commit f206170c65
introduced as workaround for nRF USBD device controller in PR
https://github.com/zephyrproject-rtos/zephyr/pull/16193.

This commit may be reverted due to changes made in
commit e326c58399
("usb: device: Do not cancel transfers on suspend").

Signed-off-by: Nickolas Lapp <nickolaslapp@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-17 11:30:48 +02:00
romain pelletant
eab19663a9 net: lwm2m: add callback for send confirmation
Issue #52328

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-04-17 11:29:14 +02:00
Vinayak Kariappa Chettimada
64b4c6ddbd Bluetooth: Controller: Fix Adv PDU RAM usage for direction finding
Fix Advertising PDU size calculation when direction finding
feature is enabled and PDU fragment count includes the
maximum CTE PDU chained. Fix removes redundant PDU count
included for Extended Advertising. Only Periodic advertising
PDUs chain CTE requires number of additional PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-17 11:22:00 +02:00
Rubin Gerritsen
19547e815b Bluetooth: Increase HCI CMD buffer size when ISO Central is used
When ISO Central is enabled it is allowed to configure many CISes at
once. For this a large command buffer is needed. This is also tested
by HCI/CIS/BI-05-C.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-04-17 10:18:27 +02:00
Kenny Johansson
353e5f2577 net: tcp: Fix IPv6 TCP MSS issue
Fixes #56657, incorrect TCP MSS calculation for IPv6.

Previously the supported MSS would incorrectly returned as the MTU if it
was less than the MTU, probably to account for the case where
the network interface MTU check returns 0.

New behaviour is to return the supported MSS as MTU minus header length,
using default MTU for this calculation if network interface MTU check
returns 0.

Signed-off-by: Kenny Johansson <wirehell@gmail.com>
2023-04-17 10:17:09 +02:00
Krzysztof Kopyściński
0d5c33b045 Bluetooth: Mesh: Fix recovery of WAITING_FOR_START BLOB Server state
If device running BLOB Server called `bt_mesh_blob_srv_recv`,
but rebooted before it received `XFER_START` message from BLOB Client,
it was wrongly "recovered" into Suspended phase, which would lead to
Server try to resume transfer on `XFER_START`. It would not be possible,
because `srv->state.xfer` was not set with acual values yet.

Set phase again to BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START, which will
allow to accept new transfer.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-17 10:15:56 +02:00
Stine Åkredalen
938c59c063 ztest: mock: fix failed test printed message.
Corrected printed message on failing test with expected or received
NULL pointer in ztest_check_expected_data.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-04-14 12:39:52 -04:00
Erik Brockhoff
3cb42157c4 Bluetooth: controller: removing (invalid) ASSERT on invalid PDU
A case of an invalid PDU was seen leading to a hit on this ASSERT, ie
this COULD happen. Refactoring of the state handling re. expectedness
in remote vs local request machines combined with ensuring the local
request machine ceases to expect PDUs when remote procedure 'takes over'

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-04-14 14:03:55 +02:00
Vinayak Kariappa Chettimada
2579690be7 Bluetooth: Controller: Fix connection update window offset data type
Fix regression in refactored LLCP using uint16_t instead of
uint32_t in storing the win_offset_us value. This caused
connection update to fail with incorrect window offset being
used to schedule the connection radio events.

Regression since commit e1c2c36f56 ("Bluetooth: controller:
llcp: set refactored as default").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-14 12:57:00 +02:00
Gerard Marull-Paretas
a86ad87d84 shell: add missing blank line after declaration
Fix checkpatch compliance issue by adding a blank line after
declaration.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
404b2ba474 shell: signal is a reserved identifier use sig instead.
Rule 21.2 "A reserved identifier or macro name shall not be declared"

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
b2d442ee87 shell: fix MISRA 5.7 violations on struct tm
s/struct tm *tm/struct tm *t/ to fix MISRA 5.7 rule violation
(uniqueness of tag identifiers).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Kumar Gala
c7c8ea6a45 logging: Fix build issues with arm-clang
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Fixes #56630
Fixes #56628

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-14 06:04:11 -04:00
Keith Packard
0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Andrei Emeltchenko
37575def5f mgmt: Fix comparing usigned < 0
Fix type from size_t to ssize_t.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-04-13 11:05:47 -04:00
Kumar Gala
d3b3a4f293 bluetooth: audio: Only build code if BT_CONN is enabled
The audio code utilizes BT_CONN so ensure its only built if
CONFIG_BT_CONN is set.  This is to fix a build issue we see
with arm-clang for:

sample.bluetooth.broadcast_audio_source

which fails to link since bt_conn_get_info is missing.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-13 16:13:52 +02:00
Vinayak Kariappa Chettimada
6551630c2c Bluetooth: Controller: Fix window offset calculation
Fix window offset calculation which is missing the radio
rx ready delay timing be subtracted because the connection
offset from the start of the radio for scan window to the
end of the ADV_IND PDU includes the radio rx ready delay
timing, where as the determined window offset by advanced
scheduling calculates the offset from the ticks_at_expire
of the scan window to an active central connection's
ticks_at_expire.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
9d5ecd5bc9 Bluetooth: Controller: Use remainder in win_offset_us calculation
Update Advanced Scheduling implementation to use remainder
value in precisely calculating the connection request window
offset in microseconds.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
205406820f Bluetooth: Controller: Move rx chain delay use into prepare_connect_req
Move the use of rx chain delay value used to calculate the
window offset into lll_scan_prepare_connect_req() instead of
current two places, one for legacy and other for extended
connection setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
d1d58de94c Bluetooth: Controller: Match Central roles for BT_CTLR_CENTRAL_SPACING
Find and match only Central role ticker when applying the
BT_CTLR_CENTRAL_SPACING value.

Use the EVENT_TICKER_RES_MARGIN_US value as +/- jitter
margin when ticker advanced scheduling is used to group
radio events.

When using CONFIG_BT_CTLR_CENTRAL_SPACING, do not add the
+/- jitter to the ticks_slot.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Nirosharn Amarasinghe
11ce28f8f7 Bluetooth: controller: Consideration for SDU interval in fragmentation
Included consideration for the packet sequence number and time stamps
together with the SDU interval in matching the event for fragmentation
of SDUs to unframed PDUs.

Implemented:
-- Increase in kconfig limit of BT_CTLR_ISO_TX_BUFFERS to allow full 32
   buffers to be available for LL/CIS/PER/BV-39C
-- ISO-AL microsecond time wrapping exposed to be used externally to
   adjust incoming Group Reference Points and Time-stamps where required
-- Function that handles adjustment of payload number according to
   incoming SDU exposed for external use to allow next payload number to
   be accessed by ISO transmit tests
-- Changed internal fragmentation source identification parameter from
   the source structure pointer to the source handle so that only the
   source handle needs to be used for external calls

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-04-13 16:09:39 +02:00
Maurits Fassaert
6bfb663167 shell: backends: add SHELL_BACKEND_RTT_BUFFER option
This new configuration option, SHELL_BACKEND_RTT_BUFFER, allows selecting
an alternative buffer for the Shell's RTT backend. By default buffer 0 is
used, which conflicts with the default logging subsystem RTT backend
buffer.
This option is the counterpart to the logger's LOG_BACKEND_RTT_BUFFER.

Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
2023-04-13 11:43:28 +02:00
Pavel Vasilyev
8dd24bf9c3 Bluetooth: Mesh: Restore PRB state after reboot
Add missing code for restoring Private Beacon state after reboot.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Pavel Vasilyev
95d6e66ec3 Bluetooth: Mesh: Don't process PRB when mesh-1.1 disabled
Private Beacons are mesh-1.1 feature and without mesh-1.1 spec enabled,
the node shall not process such beacons.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Pavel Vasilyev
c36fdf251f Bluetooth: Mesh: Allow sending SNB and PRB in parallel
Private Beacons and Secure Network Beacons are not mutually exclusive by
spec. This means both beacons can be sent simultaneously. For both
beacons spec defines their own observation intervals and related
parameters, which means we need to monitor both beacons types
separately.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Kumar Gala
0686476310 bluetooth: Fix compiler warning with arm-clang
Since we enable -fshort-enums for arm-clang we get the following
warning:

subsys/bluetooth/mesh/pb_adv.c:139:40: warning: cast to smaller
integer type 'enum prov_bearer_link_status' from
 'void *' [-Wvoid-pointer-to-enum-cast]

Fix this by first casting to an int to grow the size of the type.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-12 16:03:11 -04:00
Jiapeng Li
2568ab661d canbus: isotp: fix single frame state machine stuck issue
it is too late to set ctx->state to ISOTP_TX_WAIT_FIN after send_sf
because send_state_machine could be called just between `send_sf` and
`ctx->state = ISOTP_TX_WAIT_FIN;`  in extremely case. like below:
```c
	ret = send_sf(ctx);
	-> send_state_machine (irq handler)
	ctx->state = ISOTP_TX_WAIT_FIN;
```
it will cause isotp_send never return.

Signed-off-by: Jiapeng Li <mail@jiapeng.me>
2023-04-12 17:45:04 +02:00
Seppo Takalo
1dd9d514f1 net: lwm2m: Move utility functions from engine
Some utility functions belong to lwm2m_util.c.
Block contexts belong to lwm2m_message_handling.c

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-12 17:44:37 +02:00
Fredrik Danebjer
7e416c8ec0 Bluetooth: audio: csis: Fix Big Endianness for RSI generation
This changes so that generation of RSI now uses LE arrays instead of
uint32 words. Both input and output of rsi and sih genration now uses
LE. This also fixes the generation of RSI for BE systems, which
wasn't working.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2023-04-12 17:44:29 +02:00
Gerard Marull-Paretas
cb067800b4 ztest: mock: fix UNNECESSARY_INT compliance issue
Fix checkpatch issue: UNNECESSARY_INT: Prefer 'unsigned long' over
'unsigned long int' as the int is unnecessary

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 16:42:29 +02:00
Gerard Marull-Paretas
4863c5f05b sys/util: extend usage of DIV_ROUND_UP
Many areas of Zephyr divide and round up without using the DIV_ROUND_UP
macro. Make use of it, so that we make use of a tested system macro and
at the same time we make code more readable.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 16:42:29 +02:00
Gerard Marull-Paretas
a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Jiapeng Li
9d47a3f6d9 mgmt: mcumgr: grp: fs_mgmt: set .upload flag in file_access_data
minor fix, set .upload true if uploading

Signed-off-by: Jiapeng Li <mail@jiapeng.me>
2023-04-12 14:25:14 +02:00
Vinayak Kariappa Chettimada
51a7de2beb Bluetooth: Controller: Fix BIG handle when operation cancelled by Host
Fix the BIG handle in the HCI LE BIG Sync Established event
when BIG Create Sync operation is cancelled by Host.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-12 13:10:39 +02:00
Mariusz Skamra
13341a3e7e Bluetooth: audio: ascs: Fix missing ISO state check
This fixes missing ISO connection state check, as there might be no ISO
connection when Receiver Stop Ready has been received. This might happen
on ASE state transition from Enabling to Disabling.
Without this check the code asserts in ascs_disconnect_stream_work_handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-12 13:05:20 +02:00
Aleksandr Khromykh
4b5be77531 Bluetooth: Mesh: check buffer tailroom before relaying proxy message
PR adds checking proxy buffer tailroom before adding
a relayed message. That prevents potential proxy trash attacks.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-12 13:04:56 +02:00
Anders Storrø
fc49ad3ac6 Bluetooth: Mesh: Shell: Align parameter docs
Aligns Bluetooth mesh shell parameter documentation to use the
same syntax, abbrevations and formating.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-04-12 13:04:42 +02:00
Anders Storrø
1026ec5b38 Bluetooth: Mesh: Shell: Change pub cmd period arg
Changes the implementation and documentation in config client shell
command for Config Model Publication Set and Config Model Publication
Virtual Address Set to accept period resolution and period steps as
separate arguments to make it more user friendly.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-04-12 13:04:42 +02:00
Robert Lubos
afaf4cddd2 net: sockets: tls: Implement handshake timeout
Currently, the handshake operation could only be fully blocking or
non-blocking. This did not play well if SO_RCVTIMEO was set for DTLS
server, as the recv() call where the blocking handshake was used, could
block indefinitely, ignoring the timeout parameter. Fix this, by
allowing for the handshake operation to timeout.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
9082d4b98e net: sockets: tls: Implement TLS/DTLS socket TX/RX timeout
As the underlying socket operations for TLS/DTLS are now non-blocking,
it's no longer possible to rely on the underlying socket timeout
handling. Instead, implement SO_RCVTIMEO/SO_SNDTIMEO at the TLS socket
layer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
81be0f6d73 net: sockets: tls: Switch DTLS to use non-blocking socket operations
As for TLS, switch to use non-blocking operations on underlying socket.
This is a bit tricker for DTLS, as there were not truly blocking bio
(binary input/output) function for DTLS, as timeout had to been
implemented. It is possible though to implement non-blocking mbedTLS bio
function instead, and handle timeout outside of mbedTLS context, which
has been done in this commit.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
ee48ddc205 net: sockets: tls: Switch TLS to use non-blocking socket operations
Switch TLS sockets to use non-blocking socket operations underneath.
This allows to implement the socket blocking outside of the mbedTLS
context (using poll()), and therefore release the mutex for the time the
underlying socket is waiting for data. In result, it's now possible to
do blocking TLS RX/TX operations simultaneously from separate threads.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
96e14ba91f net: sockets: tls: Implement ZFD_IOCTL_SET_LOCK handling
Implement ZFD_IOCTL_SET_LOCK so that TLS socket layer gets access to the
mutex protecting socket calls.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Théo Battrel
b48a69023a Bluetooth: Logging: Make BT_LOG and BT_LOG_LEGACY hidden symbols
Make `BT_LOG` and `BT_LOG_LEGACY` hidden Kconfig symbols.

They should not be used by the user to configure the Bluetooth logging
system. If the user want to completely disable Bluetooth logging, they
should use `BT_LOG_LEVEL_OFF=y`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-04-12 10:23:04 +02:00
Krzysztof Kopyściński
1993c5facd Bluetooth: Mesh: Link Close without success should fail NPPI procedure
When we receive `RPR_OP_LINK_CLOSE` message with reason other than
`SUCCESS` we should fail NPPI refresh procedure, not complete it.
Dropping `COMPLETE` flag will result in calling `reprovision_fail`
in `prov_link_closed`, not `reprovision_complete`.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-12 10:22:27 +02:00
Luca Fancellu
e25d484b6f net: ip: Kconfig for TCP packet allocation timeout
TCP packet allocation timeout is currently 100ms, but there are cases
where it is not enough and as a side effect, the kernel internals are
printing some errors on the log before retrying again, create a
Kconfig parameter to be able to tune this value.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-04-12 10:22:12 +02:00
Johan Hedberg
a6e5755da8 Bluetooth: Fix clearing sent_cmd pointer when allocating event buffer
We should clear the bt_dev.sent_cmd pointer after using it to allocate a
new HCI event buffer in the bt_buf_get_cmd_complete() function.
Otherwise, there is a risk of reusing the same stored net_buf for
multiple consecutive HCI events in case the controller sents duplicate
or invalid event packets.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-04-11 16:57:37 +02:00
Gerard Marull-Paretas
0ebe14beb4 sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +02:00
Emil Gydesen
d2d3c49f39 Bluetooth: Audio: Shell: BAP scan delegator term sync cmd
Added command to terminate the PA sync as the scan delegator.
This can also be used to cancel any pending PA syncs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
65bbc3673e Bluetooth: Audio: Add bis_sync_req scan delegator callback
Add callback to notify the application about which
BIS it should sync to when requested by the Broadcast
Asssitant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
56d0947c92 Bluetooth: Audio: Add broadsink sink create
Add support to create a broadcast sink from a PA sync, rather
than using the broadcast sink scan functions.

This allows for the scan delegator implementation to
autonoumsly add broadcast sinks.

This refactors how the broadcast sink uses flags, to
ensure thread safetyness.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
7b9ddc24c0 Bluetooth: Audio: Integrate scan deletagor and broadcast sink
This integrates the Scan Delegator functionality with the
Broadcast Sink functionality. The Broadcast Sink will
automatically update the receive state for the PA and BIG
sync values, based on state of the Broadcast Sink.

Similarly, a request to terminate the BIG or PA sync from
a Broadcast Assistant will terminate the Broadcast Sinks'
PA or BIG syncs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
df490ea222 Bluetooth: Audio: Add Scan Delegator receive state iterate functions
Add bt_bap_scan_delegator_foreach_state and
bt_bap_scan_delegator_find_state to support finding
specific receive states.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
fe75a41134 Bluetooth: Audio: Remove enc_state from scan_delegator_set_bis_sync_state
The field is added/modified by bt_bap_scan_delegator_add_src
and bt_bap_scan_delegator_mod_src. This makes it easier
to modify the BIG sync state, without worrying about
the encryption state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
76002eb025 Bluetooth: Audio: Add cmd_bap_scan_delegator_rem_src
Add the cmd_bap_scan_delegator_rem_src to remove
receive state sources locally as the Scan Delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
43dd0f884e Bluetooth: Audio: Add cmd_bap_scan_delegator_mod_src
Add cmd_bap_scan_delegator_mod_src to modify a BASS
receive state source as the scan delegator in the
shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
d35c5540c3 Bluetooth: Audio: Add cmd_bap_scan_delegator_add_src
Add command for the scan delegator to add a source
locally based on a PA sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
60da9747c8 Bluetooth: Audio: Scan delegator mod source added
Add function for the scan delegator to modify the metadata
of a receive state locally.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
0005b85e16 Bluetooth: Audio: Fix issue with subgroup metadata for scan delegator
The scan delegator attempted to put the subgroup pointer into the
metadata data, instead of the metadata.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
315aa4dcd8 Bluetooth: Audio: Add BASS server sync test case
Add a test case that tests the scan delegator and
broadcast assistant features when the scan delegator
syncs to a PA without being asked to by the
broadcast assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
f0668550b8 Bluetooth: Audio: Fix bug in bis_syncs_unique_or_no_pref
The check did not work when aggregated_bis_syncs
was 0. Also modfied the function to be more readable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
781e6fc691 Bluetooth: Audio: Support local add_source for scan delegator
Add support for adding a source from the scan delegator itself.
This is useful if e.g. the broadcast sink syncs to a PA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
c1836e80da Bluetooth: Audio: Fix issue with bt_bap_scan_delegator_remove_source
The bt_bap_scan_delegator_remove_source failed due to invalid length,
as the buffer supplied to scan_delegator_rem_src should not
contain the opcode.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
42f1868189 Bluetooth: Audio: Move requested_bis_sync from recv_state to internal
The requested_bis_sync value is not part of the BASS receive
state. Moving the field makes it possible to use the
recv_state struct in more situations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
32cfcb9257 Bluetooth: Audio: Add scan delegator broadcast code callback
Add a callback that is called when the broadcast
assistant supplies a broadcast code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
b37985a898 Bluetooth: Audio: Remove PA sync handling from scan_delegator
The scan delegator will no longer be responsible for
handling the actual synchronization of the periodic
advertisers, and will offload this to higher layers.

The reason for this, is that scanning is a global state,
and should be avoided autonousmly by the stack. The
application is much better suited for handling this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
b99d989420 Bluetooth: Audio: Add receive_state_updated for scan delegator
Add the receive_state_updated callback for the scan delegator.
This callback will be called whenever a receive state is updated
by any means, giving the upper layers the option to always know
the latest changes.

This commit also refactors the name used for the internal
receive state (which contains additional information), for
the sake of readability.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
3348ed76be Bluetooth: Audio: Remove autonomous BIS sync from scan delegator
The Scan delegator will rely on upper layers calling
bt_bap_scan_delegator_set_bis_sync_state instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
ab1fd85c9e Bluetooth: Audio: Refactor scan delegator set sync state
The bt_bap_scan_delegator_set_sync_state has been refactored
to bt_bap_scan_delegator_set_bis_sync_state, as it will,
going forward, only be used to set the BIS sync states,
and not the PA sync state. The PA sync state will, in a future
commit, but autonousmly handled by the scan delegator
based on the PA sync callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
93045467b4 Bluetooth: Audio: Remove testing guard for scan delegator set sync state
The set sync state will be used for upper layers to set the BIS
sync state. This is due to the fact that the scan delegator cannot
automatically get this information from the ISO layer, unlike
the PA sync state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
e275e0f713 Bluetooth: Audio: Make scan delegator recv state const in API
Since the data is informative only, the struct should be
const.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
6bbda2cbfd Bluetooth: Audio: Add Scan Delegator dependency for Broadcast Sink
Per the BAP specification, if the Broadcast Sink role is
supported, then the Scan Delegator shall also be supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Yuval Peress
dbb470ea7a rtio: Add a managed memory pool for reads
- Introduce a new Kconfig to enable mempool in RTIO
- Introduce a new RTIO_DEFINE_WITH_MEMPOOL to allocate an RTIO context
  with an associated memory pool.
- Add a new sqe read function rtio_sqe_read_with_pool() for memory pool
  enabled RTIO contexts
- Allow IODevs to allocate only the memory they need via rtio_sqe_rx_buf()
- Allow the consumer to get the allocated buffer via
  rtio_cqe_get_mempool_buffer()
- Consumers need to release the buffer via rtio_release_buffer() when
  processing is complete.

Signed-off-by: Yuval Peress <peress@google.com>
2023-04-10 18:34:43 -04:00
Yuval Peress
80d70b4e96 rtio: Add cqe per each sqe in transaction
Update the policy such that every completed sqe has a parallel cqe.
This has the primary purpose of making any reads in the sqe visible
to the consumer (since they might have different buffers).

Signed-off-by: Yuval Peress <peress@google.com>
2023-04-10 18:34:43 -04:00
Kumar Gala
c09e8fae23 twister: Use pyelf to extract symbol information
For ztest twister would parse the symbol information that was
generated as part of the build (zephyr.symbols).  However the format
of the zephyr.symbols files is highly dependant on the toolchain.

Move to using pyelf to parse the symbol information directly from
zephyr.elf instead so that this works regardless of toolchain.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 18:37:52 +02:00
Marcin Niestroj
850ed72214 Bluetooth: logging: don't imply LOG_FUNC_NAME_PREFIX_*
By default there is only CONFIG_LOG_FUNC_NAME_PREFIX_DBG=y enabled. When
both Bluetooth (CONFIG_BT=y) and logging (CONFIG_LOG=y) subsystems are
enabled, then other CONFIG_LOG_FUNC_NAME_PREFIX_{INF,WRN,ERR}=y options are
pulled in as well using an 'imply' Kconfig command indirectly from
`CONFIG_BT_LOG`. This behavior was introduced recently as part of
commit af01a0f313 ("Bluetooth: Logging: Move all logging symbols
together") with no explicit reason provided.

Pulling in LOG_FUNC_NAME_PREFIX_* options automatically with (CONFIG_BT=y
&& CONFIG_LOG=y) blows up flash usage. As an example of downstream project
(nRF52840-based, with Bluetooth and WiFi connectivity), it increases flash
usage from 473668 bytes to 487856 bytes. This seems "only" 3% difference,
but this is actually a lot when there is no good reason why this happens.
Downstream users quite often compare flash sizes of subsequent Zephyr
releases and this 3% footprint increase might be a blocker at some point.
Additionally, it is not trivial to find the root cause of footprint
increase for most (non-expert) users.

The reason why there is so much footprint overhead because of
CONFIG_LOG_FUNC_NAME_PREFIX_*=y is because each function in the
codebase (be it Zephyr or downstream application) that contains logging
macros (LOG_{DBG,INF,WRN,ERR}()) is bloated because the function name has
to be included in the output image.

Remove 'imply LOG_FUNC_NAME_PREFIX_*' commands from 'menuconfig BT_LOG'
option, so that flash usage does not increase too much. Those logging
options are not enabled by other subsystems, so Bluetooth should not be an
exception here.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-04-08 12:34:07 +02:00
Kumar Gala
5c4d184016 emul: Use STRUCT_SECTION macros for emul devices
Clean up emulator code to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 12:33:54 +02:00
Pavel Vasilyev
0d7c7eb4c9 Bluetooth: Mesh: Remove incorrect opcode check in RPR Client
RPR Client doesn't send RPR_OP_LINK_REPORT and therefore it can't wait
for it using ack ctx. It should have been RPR_OP_PDU_OUTBOUND_REPORT
to cover a case where Outbound PDU transmission failed. But in this case
the link status will be non equal to BT_MESH_RPR_SUCCESS (see pb_error in
rpr_srv.c) and the link state will be set to idle. And the client will
reset the link together with ack ctx.

When bearer user (provisioner.c) sends an Outbound PDU, it uses the
callback (see bt_mesh_prov_send in provisioner.c) to send a next PDU,
but it doesn't check the error code even though it is provided through
the callback. Therefore calling the callback with error code would
require error handling in provisioner.c.

With ordinary provisioning PB-ADV doesn't call the callback in case of
error, but closes the link by timeout if doesn't receive ACK (see
prov_send_adv in pb_adv.c). PB-GATT always calls the callback with
error code 0 once the PDU is transmitted (see buf_send in pb_gatt.c).

Thus this change aligns RPR Client implementation with other bearers.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-07 13:38:36 +02:00
Szymon Janc
a7eee34339 Bluetooth: Host: Fix legacy OOB pairing as central
When central is sending SMP Pairing Request is it unknown if
pairing will be legacy or LE SC so set OOB flag if any OOB
data is present and assume to peer device provides OOB data
that will match pairing type.

This was affecting following qualification test cases:
SM/CEN/OOB/BI-01-C
SM/CEN/OOB/BV-01-C
SM/CEN/OOB/BV-03-C
SM/CEN/OOB/BV-09-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-04-07 13:36:41 +02:00
Krishna T
1e6e20f667 net: wifi: Log failure reason for AP mode
In case AP mode is not supported log the failure reason clearly.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-04-07 13:35:28 +02:00
Siddharth Chandrasekaran
cd116b22b5 mgmt/osdp: Clear secure channel base key from stack
Secure Channel Base Key (SCBK) is a secret key used to derive the session
keys used to encrypt and decrypt OSDP packets. Secure coding practice
requires us to clear such sensitive data from stack once we are done
needing it. This patch addresses this issue.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
814433d433 mgmt/osdp: Make sure we decrypt atleast one block
OSDP secure channel message blocks are terminated with a 0x80. This means
that even for zero length messages, we would have at least one block of
encrypted data to decrypt (since message blocks are rounded up to the next
16 byte boundary). The current length assertion checks for 16 byte
alignment but a malicious peer could send a specially crafted packet with
zero length blocks. Fix this issue by adding check for length == 0 case.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
0effd82b7a mgmt/osdp: discard secure channel if KEYSET is ACKed in plaintext
HID readers are responding to a KEYSET command with an ACK in plaintext
instead of using the current session keys to acknowledge this command
(which is the reasonable thing to do as the command itself was received
encrypted with the old key). Since the spec doesn't say anything about
this, both methods are technically correct.

Make changes to CP so it allows ACKs in plaintext for KEYSET command in
particular and make the PD implementation do this too as it makes the code
look cleaner there (perhaps HID did it for the same reasons :D).

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
a1edd3e74d mgmt/osdp: phy: Allow non-conformant, 0 length, encrypted data blocks
If command or reply has no data, PD "should" use secure message types
SCS_15 or SCS_16. But some PD seem to not implement this correctly. We
will be tolerant towards those faulty implementations.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
1648e86f4b mgmt/osdp: Rework secure channel key management
OSDP command KEYSET is used to set the secure channel base key for all
connected PDs. This key is then used to derive the session keys for each
secure channel session. When the app wants to set the this key, it has
to issue a command and then both the CP/PD has to be notified of this
change so they can store this key in a non-volatile medium for future
operations across power cycles.

The current implementation of OSDP had limited support for key
management. This patch adds all the bells and whistles needed to handle
keyset command/event in the CP/PD application.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
431cac80f4 mgmt/osdp: sc: Restructure loop to avoid a bunch of -1s
Hoisting a `length--` helps simplify a lot of code which has ad-hoc -1s
in a  bunch of places. Also, fix some formatting issues and remove
unnecessary log lines.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Wojciech Slenska
df98af0c23 shell: backends: telnet: init structure before first function call
Struct sh_telnet should be initialised before first function call.

Right now there is a possibility that telnet_accept function will
be called before memset.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-04-07 13:24:32 +02:00
Dawid Niedzwiecki
4ef47888ef ec_host_cmd: add UART backend
Add a new backend for Host Commands that uses UART. The backend bases
asynchronous UART API.

The UART backend is mainly used by FPMCU.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-07 13:05:59 +02:00
Dawid Niedzwiecki
7490adcd2a ec_host_cmd: update Kconfig help message
The help messages for max request/response SHI sizes were adjusted only
for NPCX, update it.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-07 13:05:59 +02:00
Emil Gydesen
3d3e692190 Bluetooth: Audio: Add missing null checks in mpl
There were a missing NULL check for the track segment in
paused_state_command_handler when performing the segment
operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
695f85e29d Bluetooth: Audio: Add MCC verification of read object IDs
Add check to verify that the object IDs we receive from
the server are valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9c129c5bc7 Bluetooth: Audio: MCC memset discover params for included
The discovery parameters may contain values from previous
discovery calls. The simply and future proof solution to
this is to simply memset it before using it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
b7c2629a6f Bluetooth: Audio: Add value_handle check to MCC subscribe cb
If the subscribed callback is called with value_handle = 0,
then it should not be treated as a subscription complete.

This will happen when bt_mcc_discover_mcs is called, as
reset_mcs_inst unsubscribed to all characteristics before
discovering again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9e823184e2 Bluetooth: Audio: Add value check for bt_mcc_set_playing_order
Add check for the (playing) order value, to verify that is it
a valid value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9ebad924ac Bluetooth: Audio: Add input validation for bt_mcc_send_search
Add validation of the search pointer and len value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
e7770a6a7e Bluetooth: Audio: Add BT_MCS_VALID_OP
Add the BT_MCS_VALID_OP macro to verify MCS opcodes for
both the MCC and MCS implementations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
32cd16cfac Bluetooth: Audio: Add BT_MCS_VALID_OBJ_ID
Add macro BT_MCS_VALID_OBJ_ID to verify the OTS Object
ID before attempting any OTS operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
67acec1d6f Bluetooth: Services: Add macro for verifying OTS object ID
Add BT_OTS_VALID_OBJ_ID which verifies if an object ID
is valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Seppo Takalo
1c6a853528 net: lwm2m: Default lifetime is also a minimum accepted lifetime
If server or bootstrap writes a lifetime value less than
configured default lifetime, client will automatically overwrite
the value with default one.

This gives better control for the application where client
behaviour is fine tuned on the Kconfig, but default values
from bootstrap server cannot be fine-tuned.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:15:04 -05:00
William MARTIN
e121ea28d9 canbus: isotp: Allow to override ISOTP_FIXED_ADDR_* constants
This patch allow to use isotp use_fixed_addr feature
with CAN identifier which not match SAE J1939 format.


Signed-off-by: William MARTIN <william.martin@power-lan.com>
2023-04-06 19:43:02 +02:00
TOKITA Hiroshi
47f14d6375 fb: cfb_shell: support area inverting
Extend the invert command to run cfb_invert_area when given four arguments.
Make a change to invert the screen immediately in case of run invert
without arguments.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
e2c946536e fb: cfb_shell: Add draw text command
Add the `draw text` command to execute the `cfb_draw_text()` API.

The command is similar to the `print` command. The difference is
`draw text` can render to coordinate that is not on tile boundaries.
The command is not run `cfb_framebuffer_clear()`,
So it allows rendering appendiceal with keeping already drawn image.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
7068587505 fb: cfb: support inverting with coordinates that do not align with the tile
Improve `cfb_invert_area()` able to invert even at a coordinate
not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
5634691d8c fb: cfb: Add cfb_draw_text() API
Add cfb_draw_text() API for rendering text.
It is similar to cfb_print(), the difference is cfb_draw_text() accepts
coordinate that is not on tile boundaries and don't wrap the line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
ca5de12503 fb: cfb: support drawing to any coordinates
Implements dot-by-dot font rendering to make cfb_print() able to
draw text even at a coordinate that is not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
b4965d672b fb: cfb: add const modifier for argument of cfb_print
cfb_print does not modify either address and contents of
the pointer that is pointing drawing text.
Thus, it can add a const modifier.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
6663b558fa fb: cfb: Restore inverted framebuffer to make able to reuse
cfb_framebuffer_finalize() invert the framebuffer, and it still
leave as inverted after executing the function.

It restores the framebuffer at the end of the cfb_framebuffer_finalize()
for the continued drawing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
Dölker Kim
3e5cca196c fb: cfb: fix cfb_framebuffer_clear() implementation
dev and clear_display parameter are unused and only
the framebuffer was cleared. A condition which calls
cfb_framebuffer_fanalize when clear_display is
true is implemented. Then not only the buffer,
but  buffer and display are cleared.

Signed-off-by: Dölker Kim <KDoelker@baumer.com>
2023-04-06 18:52:21 +02:00
Emil Gydesen
4bb8b2523f Bluetooth: shell: Guard adv_opt with CONFIG_BT_BROADCASTER
The advertising options are only valid if we are a
GAP broadcaster.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-06 15:37:30 +02:00
Seppo Takalo
3a241592b5 net: lwm2m: Remove lwm2m_path_to_string
This function had only one use in SenML CBOR formatter and it
contained some specific tweaks, so move the function to be a
static member of that module.

Fixes #53674

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 15:37:21 +02:00
Vinayak Kariappa Chettimada
8c3c33a970 Bluetooth: Controller: Fix compile error due to missing DF include
Fix compile error due to missing Direction Finding header
file include.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-06 12:57:20 +00:00
Tomasz Moń
59f33a6019 shell: uart: Fix wait for DTR before TX
Fail compilation when incorrect configuration is detected, i.e. when
SHELL_BACKEND_SERIAL_CHECK_DTR is set but UART_LINE_CTRL is not set.

Use periodic timer to wait for DTR instead of waiting in uart callback
to prevent blocking caller workqueue and/or sleeping in ISR.

DTR check was only ever supported with interrupt driven backend so add
appropriate depends on to Kconfig.

Fixes: e9f238889b ("shell: uart: Add waiting on DTR signal before
sending data")
Fixes: #47120
Fixes: #54705

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-04-06 14:21:57 +02:00
Seppo Takalo
567b2510b8 net: lwm2m: Allow stopping while paused
When LwM2M engine is paused, stop functionality just
marks the intent and when we resume, it will send the
de-registration if that was requested.
Otherwise it will stay in SUSPENDED state until resumed
and then goes into ENGINE_DEREGISTERED -> IDLE.

This also removes the blocking loop from lwm2m_rd_client_stop().
It does not need to block because lwm2m_rd_client_start()
is already checking if client is in IDLE.

Fixes #56254

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:21:49 +02:00
Kumar Gala
804af856f8 bluetooth: Fix linking issues with armclang
Various bluetooth tests fails to link because bt_le_ext_adv_set_data
can't be resolved.  Solve this by adding a check CONFIG_BT_EXT_ADV
around use of bt_le_ext_adv_set_data.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-05 19:32:34 +02:00
Robert Lubos
162c0f64c2 tests: net: websocket: Fix test execution on 64-bit platforms
Instead of passing the test parameters to the websocket function, by
casting the pointer to integer (which may not work on 64-bit platform
due to int/pointer size mismatch), let the test allocate a file
descriptor, and initialize it with test context. The tested functions
expect a file descriptor as an argument anyway, so it's a more intuitive
approach.

The conditional test code within WS implementation can retrieve the test
context by using FD APIs to obtain the object represented by the FD.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-05 15:01:50 +02:00
Kamil Kasperczyk
6fe83ea810 logging: Changed log template to consider default log level
Added using LOG_DEFAULT_LEVEL kconfig option in log module
template for assigning the default log level to newly created
module instance, instead of assuming always INFO level.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2023-04-05 13:47:06 +02:00
Pieter De Gendt
6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Keith Packard
3f3224d880 subsys/net: Labels cannot be applied to declarations
C only permits labels on statements, not declarations.  Separate the
declarations from the assignments so that the labels can target
statements instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-05 10:38:34 +02:00
Anas Nashif
ef1a589f61 ztest: add macro for custom testcase result
Some cases, especially those dealing with faults need to inject output
manually, so provied a macro for special case.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Jakub Rzeszutko
336c0ed98f shell: fix assert when bypass mode is set
For the duration of the bypass function shell sets the command context.

Fixes: #51637

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2023-04-05 10:03:11 +02:00
Manuel Arguelles
09dd8c74ae littlefs: translate error code when mount fails
When lfs mount fails and there is no formatting requested, the return
code must be translated to errno before being passed to the application
layer.

Additionally, only log a warning that the FS will be formatted, when the
system is not read-only.

Fixes #56378

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-04-04 18:22:10 +02:00
Pavel Vasilyev
62191ba8fd Bluetooth: Mesh: Add async API to Private Beacon Client
Add asynchronous API to Private Beacon Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-04 14:32:57 +02:00
Pavel Vasilyev
3a2dc591d4 Bluetooth: Mesh: Use bt_mesh_msg_ackd_send API in Private Beacon Cli
Replace duplicate code in Private Beacon client with
bt_mesh_msg_ackd_send API.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-04 14:32:57 +02:00
Emil Gydesen
856a20bcc6 Bluetooth: Add missing dependency for PAST feature
The PAST sender needs to support periodic advertising
and the PAST receiver needs to support periodic advertising
sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 14:31:17 +02:00
Emil Gydesen
f3af19618b Bluetooth: BAP: Shell: Add check for uuid sizes
The check is very unlikely to be needed, but fixing
warning about assigning ARRAY_SIZE to an uint8_t value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 14:30:34 +02:00
Kumar Gala
762b109179 shell: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 13:47:14 +02:00
Hein Wessels
8735d0f653 logging: support custom timestamp formatting
This feature adds support for using a custom function to format
the timestamp used for all logging backends. When the kconfig
option LOG_OUTPUT_FORMAT_CUSTOM_TIMESTAMP is set the custom
formatting function will always be used.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-04-04 13:41:17 +02:00
Emil Gydesen
6dface9947 Bluetooth: Audio: Add select BT_GATT_DYNAMIC_DB for audio services
Many/most LE Audio services are dynamically registered,
but have been enabled without BT_GATT_DYNAMIC_DB.

Add select BT_GATT_DYNAMIC_DB for the services. Select
was used instead of depends on to make it simpler
to enable them.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 13:36:26 +02:00
Mariusz Skamra
05540b2c4d Bluetooth: audio: iso: Remove code duplicates
This removes duplicated code related to bap iso binding/unbinding.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:36:17 +02:00
Mariusz Skamra
9cddbabc6f Bluetooth: audio: endpoint: Remove redundant conditional
This fixes redundant check, as CONFIG_BT_BAP_UNICAST_CLIENT
enables CONFIG_BT_BAP_UNICAST.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:36:08 +02:00
Mariusz Skamra
92d6b78fe6 Bluetooth: audio: Introduce helper BT_AUDIO_RX(TX) flags
This adds new hidden compilation flags that indicate whether the
implementation is configured to be able to receive/transmit audio data.
The flags are profile agnostic to loosen dependencies between
modules/services.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:35:56 +02:00
Jamie McCrae
e00cf28001 mgmt: mcumgr: grp: fs_mgmt: Improve upload and download performance
This vastly increases the performance of file transfers using the
fs_mgmt group over MCUmgr by allowing the file handle to remain open
between commands instead of having to open, feek, read/write then
close the file handle for each invocation.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-04 11:51:43 +02:00
Victor Chavez
649570ebc4 logging: Fixed BLE backend when used alone
There was a bug in the BLE backend when it was the only enabled
backend. Instead of using the API `log_backend_activate` to
activate the backend, the logger requires the first time to be
enabled with `log_backend_enable`.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-04-04 08:53:25 +00:00
Radoslaw Koppel
61ce27a12e ipc: ipc_service: Remove the race condition from bonding
This commit removes the possible race condition when notifying
the bonding request.
When the race condition appears there is possibility that
one of the cores would never send notification for bonding.
This change makes it sure that the notification would be sent
at least once.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2023-04-04 10:30:47 +02:00
Victor Chavez
a18aa915ce logging: Added BLE Backend Service
Added a new logger backend to recieve data over a BLE
notification characteristic.
The characteristic is based on the UUID from the Nordic connect SDK
service NUS, which allows to have a UART shell over BLE.
The idea behind this, is that this logger can be used directly
with the NRF apps or any other BLE UART terminal app.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-04-03 15:17:57 +02:00
Emil Obalski
5143db540c ipc: Fix icmsg deregister functionality
This change fixes the deregister functionality for
icmsg backend. There are two changes:

Memory access layer was not initialized properly
when the endpoint was registered again. This lead to
memory fault when attepmt to write to the buffer was
done.

Mbox driver was initialized before memory access layer
was initialized. This could lead to race condition
where immediately after the mbox driver was initialized,
the receiving work is scheduled due to pending interrupt.
In that case an attempt to read from garbage address will
occur.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-03 11:29:08 +02:00
Tom Burdick
a539d9c904 rtio: Add transceive op
Adds the transceive op which is needed for full SPI support. Notably
in RTIO transceive is expected to be a balanced buffer pair of the same
length and have non-null tx/rx bufs.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Tom Burdick
912e7ff863 rtio: Add callback op
Adds a callback op to RTIO enabling C logic to be interspersed with
I/O operations. This is not safe from userspace but allowable in kernel
space.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Tom Burdick
bb72809326 rtio: Add tiny write op
When sending small buffers out it makes sense to copy rather than
reference to avoid having to keep the small buffer around for the
lifetime of the write request.

Adjusts the op numbers to always be +1 from the previously defined op
id making it easier to re-arrange if needed in the future.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Daniel Leung
8dda1fe154 pm: mark pm_device_runtime_auto_enable as boot function
When demand paging is enabled, only a minimal set of functions
are available at boot. Anything not marked as boot functions
would not be loading in memory at boot which would result in
page faults when jumping to those functions. However, at early
boot, demand paging has not been enabled yet. So we need to
mark necessary functions as boot functions so they are placed
in the correct linker section where they are loaded at boot.

Fixes #56414

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-31 14:31:52 -04:00
Théo Battrel
ff10a9cf23 Bluetooth: Host: Remove unnecessary guarding
Remove unnecessary guarding. With `BT_DEBUG` removed, those conditions
were not needed anymore.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-31 14:01:33 +02:00
Kumar Gala
b9a63b805e lwm2m: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 14:01:24 +02:00
Szymon Czapracki
33bf1fa0c6 Bluetooth: audio: Expand AICS API
This commit adds new API functions for AICS
Setting automatic/manual only gain modes
Setting mute disabled
Use new functions in btp.vcp

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-03-31 09:20:15 +02:00
Kumar Gala
b4d4e30e9b bluetooth: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 09:19:16 +02:00
Kumar Gala
19b6b1fb30 dns: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 09:19:09 +02:00
Tom Burdick
f09685e1ac shell: Provide runtime power management toggling
Adds a device pm_toggle shell command which calls pm_runtime_device
functions put and get to toggle the runtime power state.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-30 17:33:22 -04:00
Mariusz Skamra
fc54859645 Bluetooth: audio: ascs: Handle ascs_ase_read with NULL conn
If the callback is called with NULL conn, just return ASE Idle state
value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-30 13:48:22 +02:00
Mariusz Skamra
f38c2633e7 Bluetooth: ascs: Remove redundant ase_id check
The ASE_ID is assigned locally via preprocessor macro, thus it's ensured
to be valid.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-30 13:48:22 +02:00
Emil Gydesen
630f6a7d82 Bluetooth: BAP: Store biginfo data in broadcast_sink->codec_qos
Store information from the biginfo in a
broadcast_sink->codec_qos struct, and add a reference to that struct
when syncing, so that the stream->qos contains a valid struct
with properly initialized information.

This also adds a guard for the codec_qos.latency as that
is not set nor used by the broadcast sink (as it is
not available).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-30 10:40:13 +00:00
Emil Gydesen
114e45eb2a Bluetooth: BAP: Broadcast Sink BASE contains presentation delay
The presentation delay is now properly stored in
the BASE struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-30 10:40:13 +00:00
Théo Battrel
9b8b58c70b Bluetooth: Logging: Remove BT_DEBUG
Remove Kconfig symbol `BT_DEBUG`. It was not useful anymore with the
previous logging updates.

Replace it, where it was used, by the file local debug symbol.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-30 10:40:01 +00:00
Jordan Yates
db3d51bb7d pm: device_runtime: add zephyr,pm-device-runtime-auto
Add the `zephyr,pm-device-runtime-auto` flag to `pm.yaml` and
`struct pm_device`.

This flag is intended to signify to the boot system that device runtime
PM should be automatically enabled on the device after the init function
has run.

Only run `pm_device_runtime_auto_enable` function on a device if
initialisation succeeded. This prevents actions being run on devices
that are not ready.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-29 12:21:13 -04:00
Szymon Janc
ee48754af3 bluetooth: host: Fix checking if LTK is present
conn->le.keys are set on-demand when actual security action happens and
it is possible that permission check needs to happen before those.

This fix regression in following qualification test cases:
GAP/SEC/AUT/BV-23-C
L2CAP/LE/CFC/BV-25-C
L2CAP/ECFC/BV-32-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-29 15:54:47 +00:00
Szymon Czapracki
6fd7b3bac6 bluetooth: audio: Fix TBS call stale state
This commits fixes a call staying in dialing state
after originate.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-03-29 15:52:32 +00:00
Manuel Arguelles
884e6b98f4 debug: arm64: add FPU context offset in thread info
When FPU is enabled for Arm64, the saved_fp_context must be tracked by
thread info to visualize correctly the FPU context of threads.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-03-29 09:28:57 -04:00
Dominik Ermel
fcef8bb781 mgmt/mcumgr/img_mgmt: Fix upgrade accepting equal version
As name suggest upgrade only should allow image upgrades onlu, but due
to greater or eqal sign used in version comparison, upgrade actually
also accepted current version.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-29 11:31:19 +02:00
Jamie McCrae
0cf14d5ae9 mgmt: mcumgr: transport: shell: Add optional input expiration
Adds an optional feature that can be used to time out a partially
received MCUmgr packet over the shell interface. Prior to this
change, if a header was received, then the whole shell would be
unavailable until the module is rebooted or additional full MCUmgr
packet was sent.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-29 11:30:55 +02:00
Jordan Yates
c6191858c3 pm: device_runtime: PM unsupported is not an error
Returning an error code when PM is not supported for a device only makes
writing drivers harder, as instead of checking for failures with `< 0`,
they also need to check for `-ENOTSUP`.

From the point of view of a driver, an `-ENOTSUP` return value is
equivalent to success, as if the device it is trying to turn on doesn't
support PM, by definition it is already enabled. This is equivalent to
the API behaviour when `CONFIG_PM_DEVICE_RUNTIME=n`.

Whether a device supports PM or not can still be determined at runtime
by inspecting the return code of `pm_device_runtime_enable` if
necessary.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-28 17:36:32 -04:00
Jordan Yates
2ef95ecd8f pm: device_runtime: balanced power domain operations
Only run `pm_device_runtime_put` on the dependent domain if the original
claim operation succeeded. This fixes unbalanced operations when running
```
pm_device_runtime_get(dev);
pm_device_runtime_put(dev);
```
On a device that does not have PM enabled but does have a power domain.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-28 17:36:16 -04:00
Szymon Janc
8fe734c7ac bluetooth: host: Add common helper for checking LTK presence
Both L2CAP and GATT have same requirements with regards to error code
on no encryption when LTK is or isn't present.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-28 16:15:58 +00:00
Szymon Janc
dc1ca29ca0 Bluetooth: host: Fix ATT error code on GATT authentication procedure
“Insufficient Encryption” shall be returned only if link is not
encrypted and proper LTK is present, otherwise “Insufficient
Authentication” shall be used.

Core Specification 5.4 Vol. 3 Part C 10.3.1

"If neither an LTK nor an STK is available, the service
request shall be rejected with the error code
“Insufficient Authentication”.
Note: When the link is not encrypted, the error code
“Insufficient Authentication” does not indicate that
MITM protection is required.
If an LTK or an STK is available and encryption is
required (LE security mode 1) but encryption is not
enabled, the service request shall be rejected with
the error code “Insufficient Encryption”."

This was affecting GAP/SEC/AUT/BV-11-C qualification test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-28 16:15:58 +00:00
Mariusz Skamra
6ba2839f6f Bluetooth: audio: ascs: Unbind endpoint in idle state
This moves duplicated bt_bap_iso_unbind_ep function call to
be handled when ASE enters BT_BAP_EP_STATE_IDLE state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
4d1f9973ed Bluetooth: audio: ascs: Fix double bt_bap_stream_detach call
This fixes possible double bt_bap_stream_detach() function call.
The bt_bap_stream_detach() called from ascs_ep_set_state
state BT_BAP_EP_STATE_IDLE handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
a6cdb12572 Bluetooth: audio: bap_stream: Remove reference to conn internals
This removes the usage of conn internal API in bap_stream.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
1abee09a8b Bluetooth: audio: Fix declaring conn type object in header file
The fact of having such extern in iso_internal.h forces the source files
that include this header to include conn_internal.h. This breaks the
encapsulation of conn object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
43d8e92bdd Bluetooth: audio: ascs: Fix ISO server listen incorrect behavior
This fixes incorrect behavior of ISO server listen that was not handling
the case of two endpoints sharing the same CIS/CIG and the endpoints
belonging to different connections.

Fixes: #51552
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
58de595c70 Bluetooth: audio: ascs: Register ISO server on ASCS init
This moves the ISO server registration to bt_ascs_init.
When the ASCS gets cleaned up (the callbacks are unregistered), the ISO
server gets unregistered.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
08aedc66dd Bluetooth: audio: ascs: Make use of SYS_SLIST_FOR_EACH_CONTAINER_* macros
This cleans up the code a bit by replacing the occurences of
SYS_SLIST_FOR_EACH_NODE with SYS_SLIST_FOR_EACH_CONTAINER(_SAFE)
so that the explicit CONTAINER_OF() usage is not needed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
710103db1d Bluetooth: iso: Add bt_iso_server_unregister function
This adds function that unregisters previously registered ISO server.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
f5b31c21a9 Bluetooth: audio: ascs: Fix Response_Code for mandatory opcodes
This fixes invalid Unsupported Opcode Response_Code that
happened to be sent in ASE Control Point notification
as the response to operation initiated with Mandatory opcode
to support.
When the Unicast Server callbacks are not registered, every
operation that is initiated by client will fail with
Unspecified Error instead.

Fixes: #56139
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
e9a878c072 Bluetooth: audio: ascs: Fix ASE leak if codec config failed
This fixes ASE that is not returned to pool when Codec Config
operation failed. The ASE is allocated in Codec Config operation
context. With this fix, if the operation failed to complete,
the ASE is returned back to the pool, so that it can be allocated
again by this or other client.

Fixes: #56138
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
5909a00a00 Bluetooth: audio: ascs: Minor refactor of ASE allocation
This removes redundant bt_ascs_ase_get_from_slab function and moves it's
functionality to ase_new(). It's sane, because the ASE shall be
allocated from ase_new() function context only.
bt_ascs_ase_return_to_slab() has been renamed to ase_free() to follow
the naming convention. Furthermore, few logs have been fixed/added.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
ee754fd020 Bluetooth: audio: ascs: Remove redundant check
The ID is ensured to be valid before ase_new() function is called, as
the client request is already validated.
On the other hand, if function is called from server initiated procedure
context, the assert shall occur as it indicates stack issue.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
31aa555890 Bluetooth: audio: ascs: Cleanup ASCS on callback unregister
This adds cleanup of ASCS that is called when upper layer unregisters
it's callbacks. Without callbacks registered, the service is unusable.
The ASE's that were in non-idle state stay in this state, because the
implementation returns an error on every operation that is performed by
the client. The cleanup added moves all the ASE's to idle state.

Fixes: #56111
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Krzysztof Kopyściński
3322bdce10 Bluetooth: Mesh: fix blob_cli.c build with Clang
There should be logic OR, not bitwise OR in update_missing_chunks.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-28 15:06:44 +02:00
Krzysztof Kopyściński
fc2dcc4665 Bluetooth: Mesh: save stream mode in io_open()
Mode affects access to flash aread for `block_start`. When mode is set
to `BT_MESH_BLOB_READ` function return early, and because
`BT_MESH_BLOB_READ = 0` this is default behaviour. For write flash area
must be erased to allow driver to write there new data - bits can only
be pulled down, so overwrite will not be permitted.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-28 15:06:44 +02:00
Andreas Chmielewski
357181be23 net: lwm2m: Add is_suspended() routine
Add is_suspended() routine to have control over the rd client from the
outside whether it is suspended.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-03-28 15:06:15 +02:00
Théo Battrel
9c69f29d0d Bluetooth: Logging: Deprecate BT_DEBUG_LOG
Deprecate Kconfig symbol `BT_DEBUG_LOG`. With the new `BT_LOG` having
the same effect, `BT_DEBUG_LOG` is not useful anymore and shouldn't be
used.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-28 10:33:24 +02:00
Théo Battrel
af01a0f313 Bluetooth: Logging: Move all logging symbols together
Move all Kconfig symbols related to Bluetooth logging into the newly
created `Kconfig.logging`. The logging symbols are now grouped by into a
menu "Bluetooth logging". Closely related symbols are grouped with each
others. For example, audio related logging symbol are found behind a
submenu "Audio" inside the "Bluetooth logging".

The deprecated logging symbols have also been moved in a submenu of
"Bluetooth logging", it's easier to avoid them so.

Behavior of the Bluetooth logging system:

When `LOG` symbol is selected, if Bluetooth is enabled (`BT` symbol
selected), the Bluetooth logging is enabled.

If the user does not set any log level, the Bluetooth logging symbols
will inherit the log level of `BT_LOG_LEVEL`. If the user does not set
the level of `BT_LOG_LEVEL`, the default log level will be the one
defined by the logging subsystem. Which currently is `LOG_LEVEL_INF`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-28 10:33:24 +02:00
Alexander Svensen
674e23820f sd: Return ret if error in sdmmc_spi_read_cxd
- Check OCR when sending CMD58, reject if 0

Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
2023-03-28 09:23:47 +02:00
Aleksandr Khromykh
9011a067f2 Bluetooth: Mesh: split rpr cli ack ctx for provisionning and scanning
PR adds 2 acknowledgment contexts to RPR client to handle
scanning and provisioning in parallel.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-03-27 13:20:33 +00:00
Chris St John
1c0ade0051 Bluetooth: Audio: fix possible overflow in BASE LTV decode
Consistently process BIS data, codec data and codec metadata.
Range check count of data received so that buffer overflow cannot occur.

Signed-off-by: Chris St John <chris_st._john@bose.com>
2023-03-27 09:49:58 +02:00
Daniel Nejezchleb
6898094111 net: shell: Fix shell freeze
Adds clean up after failed ping from shell,
so it does not freeze the output.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-03-25 07:49:18 -04:00
Chris Friedt
ff2efd7ae5 net: socket: socketpair: remove experimental status
Socketpair functionality has matured enough to be used in a
consistent way now regardless of architecture or platform,
even on `native_posix`.

Remove the experimental status to reflect that.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-25 07:05:53 -04:00
Vinayak Kariappa Chettimada
ae5b424a2b Bluetooth: Host: Fix handling of incomplete data status adv reports
When receiving extended advertising reports with incomplete
data status, it is not necessary to mark for recovering from
currently assembled fragments, but rather drop them and
start a fresh assembly of subsequently received extended
advertising reports.

Timing changes in the Controller cause Periodic Advertising
PDUs AUX_SYNC_IND + AUX_CHAIN_IND to be placed between
primary channel ADV_EXT_IND and AUX_ADV_IND. This causes the
Controller to generate alternating incomplete and complete
data status reports, exposing the Host bug that is fixed in
this commit.

Relates to commit ba09a252ec ("bluetooth: host: refactor
bt_hci_le_per_adv_report data reassembly").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 17:36:32 +00:00
Emil Gydesen
dd5e476f86 Bluetooth: Audio: Shell: Add CAP Acceptor Set Member AD data
Add automatic adding of the CAP Acceptor Set Member AD data.

This also moves the CAP Acceptor service data into the
cap_acceptor.c shell implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-24 17:35:11 +00:00
Fabio Baltieri
5b36b4fa16 input: add a longpress device
Add an input device to take input key events as an input and generates
short press or long press devices as output.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-24 13:48:28 +00:00
Vinayak Kariappa Chettimada
b161c7fca4 Bluetooth: Controller: Fix ticker to reduce RTC min compare offset
Fix ticker to explicitly trigger worker when ticks_to_expire
is less than or equal to elapsed time.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 12:10:37 +01:00
Vinayak Kariappa Chettimada
925066ae1f Bluetooth: Controller: Continuous scan with ticks_slot_window
Use ticks_slot_window for continuous scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 11:32:42 +01:00
Vinayak Kariappa Chettimada
852b3e9e17 Bluetooth: Controller: Reschedule unreserved ticker with slot window
Update ticker implementation to reschedule unreserved ticker
that use ticks_slot_window.

This will avoid unreserved ticker from continuously
overlapping with reserved tickers. And the change is
required to reduce processing overheads before reserve
ticker timeout callback executes.

Unreserved tickers with ticks_slot_window will always yield
to any colliding reserved or unreserved tickers.

The implementation moves unreserved tickers (no ticks_slot
value, in this case continuous scan window) to end of a
colliding reserved/unreserved ticker so that reserved
tickers (like central role) do not have high overheads due
to unreserved ticker's prepare (scanner) be preempted
everytime before reserved ticker's prepare (central).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 11:32:42 +01:00
Emil Gydesen
b7e265265d Bluetooth: BAP: Do not allow start op when CIS is connecting
When the CIS is connecting we should not allow sending the
receiver start ready command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-24 09:17:07 +01:00
Anders Storrø
09a32928aa Bluetooth: Mesh: RPR cli @ mod elem 0 check
Add check to the Remote Provisioning Client model init call
that verifies that the model is located at the root element.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-03-23 15:43:29 +01:00
Johann Fischer
ad81b3b797 drivers: udc: move transfer status to buffer info structure
This allows us to get the result of synchronous transfer without
any hacks, just from the net_buf structure.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-03-23 10:08:03 +01:00
Emil Gydesen
6fc8ca7863 Bluetooth: iso: Add misisng bt_conn_unref in error cases
The ISO hci_le_cis_req event handler was missing
calls to bt_conn_unref and bt_iso_cleanup_acl to properly
clearn up the reference counters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Emil Gydesen
7ec4a6a19e Bluetooth: host: df: Add missing bt_conn_unref in error cases
Added missing bt_conn_unref where bt_conn_lookup_handle is
called, but where the function returns without providing the
conn pointer to the caller.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Emil Gydesen
317bd5af30 Bluetooth: Host: Missing unref for PAST sync_info
When we supply the conn pointer of the remote device that
provides the PAST information, we do a lookup on the
conn_handle using bt_conn_lookup_handle which takes a
reference count. This count is never dereferenced again.

This commit adds calls to bt_conn_unref to ensure that we
do not keep the reference count after the function
returns.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Jonathan Rico
c84fdfe438 Bluetooth: controller: fix kconfig dependency
BT_TICKER_EXT is being selected undiscriminately, but it's a Zephyr
controller feature.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-22 21:20:22 +01:00
Franciszek Zdobylak
3ff1e97367 fs: Fix Kconfig formatting
- use tabs instead of spaces in indentation
- use 2 spaces instead of tab in help message

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-03-22 13:52:07 +01:00
Szymon Janc
1ebb49eeee bluetooth: ascs: Fix NULL pointer dereference in ascs_ase_read
"The (ATT attribute read) callback can also be used locally to
read the contents of the attribute in which case no connection
will be set."

This means that callback may be called with NULL conn. Since
for ascs_ase_read NULL conn object have no meaning just return
error.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-22 13:51:58 +01:00
Mariusz Skamra
b8d441842a Bluetooth: audio: ascs: Add cleanup function
This adds ascs_cleanup() function guarded by ZTEST_UNITTEST. The purpose
of it is to clean up the ASCS between the tests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-22 11:39:18 +01:00
Omkar Kulkarni
a5057e96d1 bluetooth: mesh: Do not skip PDU forwarding on ADV
Fixes a bug where goto statement results into network layer skipping
the forwarding of unicast message on the ADV bearer, if the message
gets succesfully sent on the GATT bearer. This is undesirable. Node
has no knowledge of which external entity has which unicast address.
It may be possible that Proxy node can deliberately add unicast
addresses of other nodes to the whitelist to receive some traffic
for sniffing.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2023-03-22 11:38:51 +01:00
Magdalena Kasenberg
57784df5f0 LE Audio: Refactor server ASE callbacks to return rsp object
From now app layer is able to return explicit response code and
reason that will appear in ASE Control Point notification.

Fixes issues of ASCS/SR/SPE/BI-(07/08/09)-C PTS test cases, where
PTS was receiving wrong response codes and reasons.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-03-22 11:38:37 +01:00
Troels Nilsson
714d74b77b Bluetooth: controller: Use new ticker feature to get offsets
Updated the 3 places in extended advertising where the ticker was
previously inquired about the expiration of another ticker ID in a
separate mayfly (adv_aux, adv_sync and adv_iso). It will now use the
new ticker feature where another ticker IDs expiration info will be
added to the callback.

Channel map updates are now handled in ticker_cb and applied immediately
if the ticker is not running

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-03-22 08:57:37 +00:00
Troels Nilsson
e990ab941d Bluetooth: controller: Add option for ticker to return expiration info
It is now possible (via the extended ticker interface) to ask for
expiration information for another ticker ID to be returned in the
ticker callback. This utilises the extended ticker interface and a
callback function with a different context to keep the current ticker
interface as unchanged as possible.

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-03-22 08:57:37 +00:00
Pavel Vasilyev
08f4a82038 Bluetooth: Mesh: Remove deprecated health API
Deprecated Health client and server API has been deprecated for two
releases: 3.2.0 and 3.3.0.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-22 09:35:01 +01:00
Ahmed Moheb
fac21b3616 tests: bluetooth: host: Add UT for bt_pub_key_gen()
Unit test project for bt_pub_key_gen().
This is part of subsys/bluetooth/host/ecc.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Ahmed Moheb
3c76bd06e4 tests: bluetooth: host: Add mocks for ecc.c
Add required mocks to be able to compile/test /bluetooth/host/ecc.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Théo Battrel
483126f492 Bluetooth: Host: Move new bt_data functions to data.c
Move newly added `bt_data_get_len` and `bt_data_serialize` from `ead.c`
to `data.c`.

Also, removed unnecessary include of `zephyr/kernel.h`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-21 18:17:52 +00:00
Robert Lubos
dc8f023098 net: ipv6: Fix Kconfig dependencies when native IPv6 is disabled
In case native IPv6 is disabled, Kconfig entries related to native IPv6
stack should not be enabled. Otherwise, circular dependencies can be
created if native stack is disabled, as in case of recent changes in
NET_IPV6_RA_RDNSS option (where a dependency for a native stack module
was enabled).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-21 18:11:06 +00:00
Théo Battrel
a693b9b33b Bluetooth: Host: Add Encrypted Advertising Data
Create a new Bluetooth library and add Encrypted Advertising Data to it.

Encrypted Advertising Data is a new feature from the Bluetooth Core
Specification 5.4. It provides a way to communicate encrypted data in
advertising, scan response and EIR packets. To do that it introduce a
new advertising data type called `Encrypted Advertising Data`. Also, it
introduce a new characteristic called `Encrypted Data Key Material`,
this provides a way to share the key material.

The library add two main functions `bt_ead_encrypt` and
`bt_ead_decrypt`.

Two helper functions are added to `bluetooth.h`. `bt_data_get_len` and
`bt_data_serialize`, the first one allow the user to get the total size
of a set of `bt_data` structures; the second one generate a spec
compliant bytes array from a `bt_data` structure. The last one is useful
because `bt_ead_encrypt` take as input those kind of bytes array.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-21 13:39:09 +02:00
Vinayak Kariappa Chettimada
643723479f drivers: flash: nRF: Move sync ticker to Subsys Bluetooth Controller
Move the SoC Flash nRF sync ticker implementation into
Bluetooth Controller Subsystem folder, as internal headers
are included.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-21 12:33:32 +01:00
Vinayak Kariappa Chettimada
b9f9f1ba9c Bluetooth: Controller: Refactor CMakelists.txt for consistency
Refactor the Bluetooth Controller's CMakelists.txt to
consistently use zephyr_library_sources_ifdef() and
zephyr_library_include_directories_ifdef().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-21 12:33:32 +01:00
Mariusz Skamra
fef4c4e7ea Bluetooth: audio: ascs: Fix ASE release from QoS configured
This fixes ASE release from QoS configured state.
The `ops->released` callback was not called and the `bt_ascs_ase`
was not returned to the pool, because `stream` object was already
detached.

Fixes: #55900
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:38:16 +01:00
Mariusz Skamra
1ece7a6779 Bluetooth: audio_ ascs: Fix possible dereference of free'd ASE
This fixes possible dereference of free'd bt_ascs_ase object.
The ASE without ISO connection that goes to Releasing state will be
automously transitioned to Idle state. Thus, the `ase` object might not
be vaild anymore.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:38:16 +01:00
Mariusz Skamra
14bd189f00 Bluetooth: ascs: Fix ASE Codec Config PDU length validation
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.

ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
 length operation if the total length of all parameters written by the
 client is not equal to the total length of all fixed parameters plus
 the length of any variable length parameters for that operation"

Fixes: #55747
Fixes: #55748
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:37:40 +01:00
Joel Guittet
b6df4ec388 hawkbit: check mcuboot header version
Checking mcuboot header version prior to use the content of the header
structure.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2023-03-21 09:35:26 +01:00
Joel Guittet
a3d7fdafd6 hawkbit: fix memory issue with mcuboot_img_header size
Fix a memory issue when calling boot_read_bank_header the length should be
the size of `struct mcuboot_img_header`.
Fixes #54459.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2023-03-21 09:35:26 +01:00
Emil Gydesen
c97fa8fda3 Bluetooth: Audio: CAP initiator streamline procedure states
Add new helper functions to increase readability and to
ensure correctness when aborting procedures.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
3186fce98e Bluetooth: Audio: Shell: Use same streams and group for BAP and CAP
Use the same unicast streams and group for the BAP and CAP
shell commands. This results in maximum flexibility, as well
as the niceness of use from CAP, as well as less memory usage.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
3ab925ecef Bluetooth: Audio: CAP Initiator handle unexpected ASE changes
When performing the CAP Unicast Start procedure, the remote
server(s) may change the state of the ASE before the procedure
is complete.

If the state change is unexpected, we stop the procedure and
call the callback, and then the caller can decide what to
do after that (presumably call the stop procedure for the
streams that may be setup).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
90537df38a Bluetooth: Audio: Add CAP unicast stop shell command
Add shell command for the CAP unicast stop procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
9ce647ba79 Bluetooth: Audio: Implement CAP unicast stop procedure
Implements the CAP unicast stop procedures, which is used
to stop (either disable or release) multiple streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
67925d397a Bluetooth: Audio: Add CAP unicast update shell command
Add shell command for the CAP unicast update procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
f7f69b6ff0 Bluetooth: Audio: Implement CAP unicast metadata update
Implement the CAP unicast metadata update procedure.

The procedure lets an application update the metadata of one
or more CAP streams in a single function call, while also ensuring
that the provided metadata follows the requirement from CAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
6866cd30e8 Bluetooth: Audio: Add support for CAP unicast start in shell
This modifies the audio.c shell module to support
multiple connections.

This adds support for the cap_initiator unicast-start command,
which supports multiple endpoints on multiple devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
b71f9f2702 Bluetooth: Audio: Implement CAP unicast audio start
Implement the CAP unicast start procedure, which
will put one or more CAP streams from the idle state
to the streaming state, across or more ACL connections.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Fabio Baltieri
9889e8e20a input: move the listener section in common-rom
Move the input listener section declaration in common-rom-misc.ld
instead of using a custom input.ld file. This seems to be the common
practice for upstream iterable sections and seems to solve a
compatibility issue where the section was getting allocated incorrectly
on esp32 based platforms.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-20 12:56:18 -07:00
Krzysztof Chruscinski
369ffb4929 hal_nordic: Add protection against resource conflict (take 2)
Commit will be squeezed once agreement is reached.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Krzysztof Chruscinski
5af49c1e35 hal_nordic: Add protection against resource conflict
Add check in CMake files to prevent resource overlap for
TIMER0, TIMER1, RTC0.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Krzysztof Chruscinski
9a73b9c80d hal_nordic: Change scheme for RTC and TIMER reservation
In general, RTC and TIMER driver implements counter API but there
are exception when those peripherals are used in a custom way
(e.g. for system timer or bluetooth). In that case, system must
prevent using counter based on a reserved instance. Previously,
it was managed by Kconfig options but that cannot be maintained
when switching to devicetree configuration of the counter driver.

A new approach removes Kconfig options and instead adds static
asserts in the files which are using direct peripherals. Those
asserts check if given node is not enabled in the device tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Robert Lubos
66ae9153a6 net: sockets: Fix SO_SNDTIMEO handling
The TX timeout configured with SO_SNDTIMEO on a socket did not work
properly. If the timeout was set on a socket, the TX would work as if
the socket was put into non-blocking mode. This commit fixes this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Robert Lubos
616797c429 net: sockets: Add helper function for recalculating remaining timeout
The timeout recalculation logic was duplicated across several routines,
therefore it makes sense to make a helper function out of it,
especially, that the same functionality would be needed for the send
routines.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Robert Lubos
e67374e47a net: tcp: Rework TCP SO_RCVBUF/SO_SNDBUF option handling
SO_RCVBUF option processing at the TCP level was broken. The option
value was only checked once, when the TCP context was allocated. This
made little sense, as at this point the option would not even get a
chance to have custom value. If the user modified the option after the
socket (net_context) was created, it had no effect on the TCP operation.

This commit fixes this, by checking the option value whenever new packet
is processed, so that the configured window size is updated at the TCP
level before we report it in the TCP ACK. In order to achieve this,
introduce a new helper function, to refresh the configured window sizes,
to avoid bloating `tcp_in()` even further.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Sebastian Panceac
2e7c02bef6 Bluetooth: pairing: OOB: Separate LE SC OOB from legacy OOB logic
Some systems can support only legacy OOB pairing while others only
LE SC OOB pairing.

The existent API function "bt_set_oob_data_flag" was removed.

Two new API functions were added:

 * "bt_le_oob_set_legacy_flag" to signal that legacy OOB pairing is used
 * "bt_le_oob_set_sc_flag" to signal that LE SC OOB pairing is used

The code will now advertise the presence of OOB flag depending
on the type of pairing method(SC vs legacy)

Signed-off-by: Sebastian Panceac <sebastian.panceac@ext.grandcentrix.net>
2023-03-20 16:13:18 +01:00
Krzysztof Kopyściński
8194c34669 Bluetooth: Mesh: allow user to define BLOB ID for bt_mesh_dfu_cli_send
User can now use self-defined BLOB ID for transfer instead of using
random one each time. This allows to send multiple FW Update Start
messages with same BLOB ID, for example to resume previous one.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Krzysztof Kopyściński
b0e91368a2 Bluetooth: Mesh: fix FW Update procedure recovery on on DFU Server side
If device rebooted while in `BT_MESH_DFU_PHASE_TRANSFER_ACTIVE` phase
we should not recover into it, but set `BT_MESH_DFU_PHASE_TRANSFER_ERR`
instead. It's because we no longer remember which block is currently
transfered so new FW Update Start must be received and transfer
restarted.

If device rebooted while in `BT_MESH_DFU_PHASE_VERIFY_OK` it means
we didn't manage to apply image before reboot. We should enter
`BT_MESH_DFU_PHASE_VERIFY_FAIL` phase, which will allow to verify it
again and possibly apply. This is with agreement to specification
regarding receiving FW Update Start when FW is already received.

This commit also alligns handle_start with specification: when
FW is already received, we should set phase to
`BT_MESH_DFU_PHASE_VERIFY`, send Status message, then proceed to Verify.
Previously, `verify` was called before sending status, so status
contained phase set to `BT_MESH_DFU_PHASE_VERIFY_OK` or
`BT_MESH_DFU_PHASE_VERIFY_FAIL`. This would prevent DFU Client
enter refresh procedure.

`blob_recover` also expects BT_MESH_DFU_PHASE_TRANSFER_ERR now.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Krzysztof Kopyściński
51ff3e630b Bluetooth: Mesh: Do not transfer FW to targets in Verify Phase in DFU
These targets already received FW so there is no point to transfering
it again. What's more, these targets will not accept transfer and will
be dropped by DFU Client. If FW is already received DFU Client should
skip transfer and proceed to refresh procedure.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Emil Gydesen
b011c1e36c Bluetooth: BAP: Add missing Unicast client CB NULL check
Add missing check before calling unicast_client_cbs->release.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-20 13:38:33 +01:00
Krishna T
36c46afbb9 net: zperf: Make Zperf worker thread stack size configurable
All stack sizes should be configurable for memory adjustements.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 10:20:00 +00:00
Krishna T
d6e54a417a net: zperf: Make Zperf worker thread priority configurable
This helps us test impact of scheduling on traffic.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 10:20:00 +00:00
Emil Gydesen
c8e1b1e264 Bluetooth: Audio: Move audio shell to audio directory
Move all audio related shell implementations to the
audio directory, to use the same structure as Mesh.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-20 09:53:34 +01:00
Georges Oates_Larsen
3c6b7dc35a net: dummy L2 for offloaded ifaces
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-03-20 09:53:25 +01:00
Krishna T
5e6c733006 net: wifi: Use a macro for TWT wake interval
Remove the magic number 255, esp. now that we support 262.144ms.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Krishna T
65aae9cbfb net: wifi: Use micro seconds for precision for TWT intervals
In order to take granular input use micro seconds as input for TWT
intervals, this helps us in providing inputs such as 65.28ms without the
need of using floating points.

This also expands the TWT wake interval range to 262.144ms, earlier as
we want to use uint8, limited to 256ms.

Also, remove the units from the variable names, this is unnecessary and
also avoids doing breaking changes.

Update release notes as this is a breaking change, both type and
variable names are changed.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Aleksander Wasaznik
20d747815d Bluetooth: Shell: Remove ad-hoc CHAR_SIZE_MAX
Remove ad-hoc `CHAR_SIZE_MAX` in favor of `BT_ATT_MAX_ATTRIBUTE_LEN`.
The maximum size of an attribute is the same as the maximum size of a
characteristic.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-20 09:51:24 +01:00
Aleksander Wasaznik
6b6178be30 Bluetooth: Shell: Make gatt notify more general
Make `gatt notify` take the source handle and the data to send.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-20 09:51:24 +01:00
Dominik Ermel
abb93d4089 fs: Prevent mounting file system re-using private data
The commit changes the fs_mount to not allow mounting same system,
with the same private data pointer, at two different mount paths.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-20 09:51:10 +01:00
Tom Burdick
610d307fa0 rtio: Properly track last sqe in the queue
The pending_sqe logic to track where in the ring queue the concurrent
executor had left off was slightly flawed. It didn't account for starting
all sqes in the queue and ending back up at the beginning.

Instead track the last SQE in the queue, from which the next one in the
queue will the one to start next.

If we happen to sweep the last known SQE in the queue, reset it to NULL
so the next time prepare is called we start at the beginning of the queue
again.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-17 12:49:57 -05:00
Tom Burdick
3353342e5f rtio: Add transactional submissions
Transactional submissions treat a sequence of sqes as a single atomic
submission given to a single iodev and expect as a reply a single
completion.

This is useful for scatter gather like APIs that exist in Zephyr already
for I2C and SPI.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-17 12:49:57 -05:00
Vinayak Kariappa Chettimada
de9579f297 Bluetooth: Controller: Implement CIS abort_cb to flush tx/rx
Implement a custom abort_cb callback to perform Tx and Rx
flush and adjust the SN/NESN values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:07:09 +01:00
Vinayak Kariappa Chettimada
0d54ca8761 Bluetooth: Controller: Fix ull_prepare_dequeue for skipped events
Fix ull_prepare_dequeue to not skip events when preempt
does not match the event in the head of the prepare queue.
The head of the prepare queue does not match when
ull_prepare_dequeue has put the head of the queue to the
last of the queue when it is calling lll_resume interface.
This happens when there is already an active event which
needs a preempt timeout to be setup and there is another
non-resume event in the pipeline which now becomes the
head. The fix ensure to restore the order of the events
if a preempt timeout was to be setup.

Currently ull_prepare_dequeue loops through all events
before stopping at the original way the queue was. This is
not efficient and is a scope for improvement in future.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:06:54 +01:00
Vinayak Kariappa Chettimada
ceaddc81db Bluetooth: Controller: Fix connected ISO time reservation calculation
Fix Connected ISO time reservation that was missing the
event start and end overhead values.
Fix missing event end overhead values in ACL connection
time reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:06:32 +01:00
Morten Priess
00c9580914 Bluetooth: controller: Fix offset for CIG with CISes in different ACLs
Calculate CIS offset of secondary CIS(es) using CIG reference point.
This fixes issue with e.g. two CISes associated with separate ACL
connections.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-03-17 16:06:18 +01:00
Morten Priess
b8c7506681 Bluetooth: controller: Keep CIS/CIG instances until ll_cig_remove
This commit enables having multiple CIS/CIG setups/connects and
teardowns in sequence.

- For central, cig->lll.num_cis is initialized to cis_count and
  untouched until ll_cig_remove. The value shall indicate number of
  allocated instances, to ensure correct CIG traversal.
- Keep CIG/CIS instances for central until ll_cig_remove
- Initialize CIS instance state vars in ll_cis_create, similar to the
  peripheral flow.
- In ll_cig_remove, always release streams and CIG instance. Do not
  remove paths, as this is done from host at bt_iso_chan_disconnected.
- Remove unsued cis_count member in ll_conn_iso_group.
- Use correct function ull_iso_lll_ack_enqueue at LLL flush to have
  data path respected.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-03-17 16:06:18 +01:00
Andries Kruithof
4215854956 Bluetooth: controller: remove refs to LLCP_LEGACY after rebase
Some recent PRs included conditional compilation for
KCONFIG_BT_LL_SW_LLCP_LEGACY, which must be removed.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
e6a3def17b Bluetooth: controller: remove dependency for slot reservation
The slot reservation code is only valid for the refactored LLCP;
a guard was in place to ensure that it was not compiled in for
legacy controller code. This commit removes this guard

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
729c3e3d83 Bluetooth: controller: remove code related to advanced scheduling
This commit removes the code related to advanced scheduling from
ull_sched.c, since this code only works for the legacy controller.
Implementing advanced scheduling for the refactored LLCP is tracked
in its own issue

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
f6172f3159 Blueotooth: controller: removed delayed notification code
The code that was added for delaying notifications to the host,
which was only implemented for legacy controller, is removed
in this commit

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
2ada005d7c Bluetooth: controller: removing legacy LLCP code
This commit removes the legacy LLCP code including the
Kconfig option
It also updates the babblesim tests, and removes the
tests for the legacy controller

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Emil Gydesen
70e4e73998 Bluetooth: BAP: Shell: Fix problems with codec and qos config
The copying from the presets to the stream codec and qos
structs were not done in a way that worked. Fixed by doing
a more proper and deeper copy.

This also fixes a small issue with using the wrong
default preset.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 14:19:42 +01:00
Pavel Vasilyev
cf5ea49d23 Bluetooth: Mesh: Fix registering GATT Proxy service after reboot
After commit 3486f133e9
GATT Proxy service registration is broken because it is registered from
settings_load() in mesh_commit(). Because mesh_commit() is called before
sc_commit() is called in gatt.c, bt_gatt_service_register() can't be
called yet.

Use k_work to postpone the service registration.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-17 14:19:15 +01:00
Andrei Emeltchenko
e5091db1ad bluetooth: audio: Fix using wrong function check
Correct function check before calling it.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-17 14:18:57 +01:00
Emil Gydesen
d0b0bb43d3 Bluetooth: BAP: Remove BT_BAP_UNICAST_CLIENT_PAC_COUNT
The BT_BAP_UNICAST_CLIENT_PAC_COUNT is there due to a merge conflict
gone wrong. Removed again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 14:18:48 +01:00
Vinayak Kariappa Chettimada
1f52e70fe2 Bluetooth: Controller: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values, when computing and comparing
against unsigned variables.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Vinayak Kariappa Chettimada
9b3a3ee79b Bluetooth: Controller: Add additional LE Channel Selection tests
Add additional custom LE Channel Selection #2 tests to cover
event and subevent mapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Vinayak Kariappa Chettimada
c3e6edd402 Bluetooth: Controller: Remove redundant use of local variable
Remove redundant use of local variable chan_idx in the
lll_chan_iso_subevent() function.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Henrik Møller
86757f5ae5 Bluetooth: controller: Fix channel selection
For ISO-subevents channel selection must use remap table always
-regardless of channel is a mapped or unmapped channel.

Signed-off-by: Henrik Møller <heml@demant.com>
2023-03-17 11:48:26 +01:00
Emil Gydesen
64143fc881 Bluetooth: BAP: unicast released callback only after CIS disconnect
Ensure that the stream released callback is only called after
the CIS has disconnected. Since the ACL disconnect event
may come before the CIS disconnect event, we use the
unicast_client_ep_idle_state in the unicast_client_reset
function to use the existing state verification, and only
after both the ACL and CIS has disconnected, we
finalize the reset of the stream and call the released
callback, assuming that the CIS can be disconnected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:31:06 +01:00
Emil Gydesen
bb43c05dc8 Bluetooth: ISO: Set missing CIS disconnecting state
The BT_ISO_STATE_DISCONNECTING was never set when the
CIS was actually in the disconnecting state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:31:06 +01:00
Emil Gydesen
38095f8818 Bluetooth: BAP: Shell: Delete uni group when all streams released
Previously we assumed only a single stream, and deleted
the unicast group on the first stream released.

Now we wait for all the streams to be released before
deleting the group.

This still assumes that all streams are initiated by us
as the client, and will not work if using the
BAP unicast client and server role concurrently.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:58 +01:00
Emil Gydesen
cf737b510e Bluetooth: BAP: Remove bad LOG_ERR from unicast client
Remove a bad LOG_ERR that should never have been merged.

Added the valuet that was logged to the debug log statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:17 +01:00
Emil Gydesen
ed1cc603a7 Bluetooth: BAP: Fix bad ASSERT in ASCS disconn stream handler
The conditions of the assert were incorrect compared to the
text, and caused an assert to happen when it shouldn't.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:09 +01:00
Kumar Gala
831bd2f841 armclang: fix compiler warnings with isprint()
We get compile warnings of the form:

drivers/console/uart_console.c:508:8: error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint returns an int, change check to an explicit test against
the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-17 09:30:01 +01:00
Gregory Shue
5623f54a35 fff: Add fff_extensions.h, RETURN_HANDLED_CONTEXT()
Add supplementary header <zephyr/fff_extensions.h>.  Add macro
to fff_extensions.h for simplifying definition of custom fake functions
needing call-unique information for producing desired output data.
When an array of custom fake context structures is defined and
the return field within the first structure instance is registered
with the standard SET_RETURN_SEQ() macro of FFF, the
RETURN_HANDLED_CONTEXT() macro provides the inverse logic to
recover the context structure for this called instance. The body of
the custom fake handler is provided to the RETURN_HANDLED_CONTEXT()
macro for appropriate execution and access to the custom fake
parameters.

A test suite is also provided to verify macro implementation and
illustrate usage. It is at:
zephyr/tests/subsys/testsuite/fff_fake_contexts/

This code was verified by:

1. (Pass) west build -p always \
            -b unit_testing tests/subsys/testsuite/fff_fake_contexts/ && \
         ./build/testbinary
2. (Pass) west build -p always \
            -b native_posix tests/subsys/testsuite/fff_fake_contexts/ && \
         ./build/zephyr/zephyr.exe
3. (Pass) ./scripts/twister -p unit_testing \
            -T tests/subsys/testsuite/fff_fake_contexts/
4. (Pass) ./scripts/twister -p native_posix \
            -T tests/subsys/testsuite/fff_fake_contexts/
5. (Pass) cd doc && build html-fast

Fix #55246

Signed-off-by: Gregory Shue <gregory.shue@legrand.com>
2023-03-16 13:43:33 -04:00
Pavel Vasilyev
3e14c13d8d Bluetooth: Mesh: Use default provisioning protocol timeout in RPR Client
The timeout used upon opening the link with the server relates to the
PB-Remote Link Open procedure, but not to the whole provisioning
procedure. For the provisioning procedure, the timeout should be at
least 60 seconds as explained in section 5.4.4.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Pavel Vasilyev
e9a20cc3b6 Bluetooth: Mesh: Restart timer after sending PDU to RPR Server
This commit fixes an issue where the RPR Client gets stuck after sending
PDU to RPR Server (even with segmented flag), but doesn't hear anything
back from the server.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Pavel Vasilyev
3a0fa866e4 Bluetooth: Mesh: Fix timeout handling on link opening in RPR Client
This commit fixes an issue, where the RPR Client gets stuck forever
until reboot if it doesn't receive Link Status or Link Report message
when openinig the remote provisioning link.

The RPR_CLI_LINK_OPEN flag was used to control the remote provision link
and protect against receiving an unexpected message, but it didn't cover
a case when neither of messages were received from the RPR Server.
cli->link.state only changes by Link Status or Link Report message and
is set to BT_MESH_RPR_LINK_IDLE when opening the link. Therefore, when
the RPR Client's timer timed out, the client didn't reset its internal
states.

This commit adds an additional state to cover this intermediate state
when the client initiated the link opening but didn't receive any
response.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Tomáš Beneš
14138d4a34 Bluetooth: Controller: Add coexistence implementation
To enable Bluetooth controller coexistence feature, there is
implementation of ticker task, which aborts any ongoing radio events
during assertion of the grant pin. This solves the co-existence issue
in the role of the subordinate transceiver.

Signed-off-by: Tomáš Beneš <tomas@dronetag.cz>
2023-03-16 14:37:55 +01:00
Vinayak Kariappa Chettimada
947ef4c96b Bluetooth: Controller: Remove redundant EVENT_IFS_US in BIS timing
Remove redundant EVENT_IFS_US used in Control PDU timing
calculation. The BIG radio event ends with Control Subevent
and hence there is no need to add EVENT_IFS_US at the end
of the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-16 13:39:03 +01:00
Vinayak Kariappa Chettimada
ca44b34994 Bluetooth: Controller: Fix ISO Sync Receiver reception abort
Fix ISO Sync Receiver PDU reception to enqueue towards ULL
any PDUs that where received before the BIG event in
unreserved timespace is aborted due to overlap with other
radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-16 13:38:48 +01:00
Jonathan Rico
169270e911 Bluetooth: host: downgrade select log messages
In the case of a constrained system that uses dynamic channels (ie, not
much initial credits), the user's log would be flooded with those three
messages.

This is not really an error per se as the stack will handle it properly and
reschedule the sending of the buffers as soon as more credits arrive.

Thus downgrading the severity of
- the l2cap messages, as they are only compiled when dynamic channels are
enabled
- the conn message. Reporting the error belongs in the upper layers.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-16 12:56:48 +01:00
Luca Fancellu
6748d588ab net: zperf: allow TCP receiver to handle multiple connections
Currently the zperf_tcp_receiver can handle only one TCP connection
each time, modify the code to poll and handle multiple connections.

Take the occasion to unify the bind and listen part of the code
between ipv4 and ipv6 part using a structure introduced to handle
the multiple connections.

Now in case the zsock_recv fails, we can't stop every connection
and fail through the error label, so just print the error message
and report the failure through the callback.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-03-16 12:56:10 +01:00
Luca Fancellu
d485ef0231 net: zperf: Reduce the scope of input address variables
Reduce the scope of in4_addr_my and in6_addr_my pointer variables
that are currently global, but they are used only inside
tcp_receiver_thread.

Take the occasion to fix a typo in one error message.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-03-16 12:56:10 +01:00
Emil Gydesen
ac5e4fea90 Bluetooth: Audio: Unicast Client Log more of QoS pref
Add logging of some missing fields of the QoS preference
we receiver from the unicast server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 12:55:50 +01:00
Mariusz Skamra
871db2d277 Bluetooth: Move bt_data_parse to dedicated source file
This moves bt_data_parse function outside of hci_core.c.
Having it in separate file makes unit testing easier as the
function do not use kernel objects, thus can be used in unit tests
without a need for adding any mocks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-16 11:46:36 +01:00
Emil Gydesen
61559bfe3a Bluetooth: Audio: Explicit stream type of unicast client group stream
Make it more explicit that the streams that the value covers are CIS
and not BAP streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 11:46:20 +01:00
Wolfgang Puffitsch
b525db221c Bluetooth: controller: Avoid the use of weak functions for ISO data path
Avoid the use of weak functions and call the respective functions only
if vendor-specific data path is supported. The weak dummy functions
will not implement the desired behavior anyway. This change makes it
explicit that these functions need to be implemented by the vendor.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2023-03-16 11:46:05 +01:00
Emil Gydesen
f7cf252a8c Bluetooth: Audio: Add special handling of release cp notification
When releasing a stream as the unicast client, we may get
either the ASE state notification with state idle or
the control point notification first. If we get the
ASE state notification first, we pretend we get the
CP notification first, and call the release callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
88644a775c Bluetooth: Audio: Shell: Add unicast client operation callbacks
Add the unicast client operation callbacks to the shell, simply
printing the values sent by the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
68fa04788a Bluetooth: Audio: Add unicast client cp notify callbacks
Add callbacks for control point notifications sent by the
unicast server. These will allow the upper layers to know
if and why a specific operation failed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
a2057cde3c Bluetooth: Audio: Fixed naming of invalid length ASCS response
The "Invalid Length" response code was called truncated,
which does not match the spec definition.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Nirosharn Amarasinghe
b1fe487bb1 Bluetooth: controller: Release of padding PDUs for framed production
Implemented:
-- Released framed padding PDUs when data received in SDUs for a given
   event do not fully utilise BN.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-03-16 09:17:19 +01:00
Kumar Gala
0342deb5d9 Bluetooth: Mesh: Fix compiler warning
When building with an LLVM toolchain get the following warning:

bluetooth/mesh/pb_adv.c:774:4: error: expression which evaluates to zero
treated as a null pointer constant of type
'void *' [-Werror,-Wnon-literal-null-conversion]
                        PROV_BEARER_LINK_STATUS_SUCCESS);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by adding a cast to (void *).

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-16 09:15:38 +01:00
Anders Storrø
ce3557a958 Bluetooth: Mesh: Add SAR srv persistence storage
Adds persistent storage for SAR server RX and TX set cmd parameters.
Also ensures that SAR RX and TX parameters are set back to default values
upon reset of the mesh device.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-03-15 15:20:35 +01:00
Andrei Emeltchenko
7e63be14c3 bluetooth: shell: Fix NULL dereference
Fix NULL dereference when dereferencing txing_stream, which was used
instead of default_stream.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-15 15:03:12 +01:00
Jun Qing Zou
aae379f245 net: mqtt: Debug logging of pointers
Cast pointer to `void *` for `%p` parameter.
Otherwise lots of warnings in the log like below:

 `<wrn> cbprintf_package: (unsigned) char * used for %p argument.
 It's recommended to cast it to void * because it may cause
 misbehavior in certain configurations. String:"%s: (%p): >>
 length:0x%08x cur:%p, end:%p" argument:3`

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-03-15 15:02:47 +01:00
Vinayak Kariappa Chettimada
11ad5bf92c Bluetooth: Controller: Inherit BT_ISO_TX_BUF_COUNT value
Inherit BT_ISO_TX_BUF_COUNT value when BT_ISO is enabled
to set BT_CTLR_ISO_TX_BUFFERS count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-15 08:49:42 -04:00
Vinayak Kariappa Chettimada
c22f40a358 Bluetooth: Controller: Fix max PDU len radio config for BIS Ctrl PDUs
Fix missing radio configuration that limits the maximum PDU
len on reception to consider that Control PDU can be larger
than the max PDU size in the BIS parameters.
Use dedicated PDU buffer for transmission and reception of
BIG Control PDUs so that it is independent of maximum ISO
PDU length which can be less than BIG Control PDU length.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-15 08:49:42 -04:00
Mariusz Skamra
0b7a335864 Bluetooth: ascs: Fix uninitialized stream object
This fixes "Conditional jump or move depends on uninitialised value(s)"
error seen in valgrind.
The stream object that is allocated by application has to be initialized
as it may contain invalid data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 11:38:11 +01:00
Mariusz Skamra
b5465825f1 Bluetooth: ascs: Remove duplicated logic
The ase_stream_add does the same job as bt_bap_stream_attach that is
called right below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 11:38:11 +01:00
Ludvig Samuelsen Jordet
53091c5056 Bluetooth: Mesh: Fix confusing DFU slot doc
The word "valid" is already in use to mean slots that return true for
`bt_mesh_dfu_slot_is_valid`, whereas `bt_mesh_dfu_slot_foreach` iterates
over all added slots.

Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
2023-03-15 11:19:18 +01:00
Mariusz Skamra
5862c8263b net: buf: Factor out net_buf_simple to separate source file
This moves net_buf_simple related code to separate source file.
Having those in separate file makes unit testing easier as simple
network buffers do not use kernel objects, thus can be used
in unit tests without a need for adding any mocks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 10:50:16 +01:00
Mariusz Skamra
4a1d0782cb net: buf: Fix using incorrect logging macro
As there is dedicated NET_BUF_SIMPLE_* logging macros set,
NET_BUF_SIMPLE_DBG shall be used in this place instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 10:50:16 +01:00
Emil Gydesen
5704b83ea7 Bluetooth: Audio: Shell: Add location to cmd_config
Add support for setting the location value
(BT_CODEC_CONFIG_LC3_CHAN_ALLOC) in the codec configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
a02a1c19a1 Bluetooth: Audio: Shell: Refactor set_preset
The function is now called get_named_preset and only
returns a named preset. The QoS parameter handling
has been moved to a new function, cmd_stream_qos,
which can be used to set specific QoS for a stream.

The get_named_preset does also no longer set the default
preset, and cmd_preset must be used for that now.

This means that a function like cmd_config no longer
has any side effects, thus making it easier to set up
multiple streams with different presets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
b9a4deb429 Bluetooth: Audio: Shell: Replace hacky metadata handling
The hacky handle_metadata_update that copied the metadata to
a variable, since stream->codec->meta could not be modified,
has been replaced with a proper solution now that
stream->codec->meta can be modified.

It still only supports settings the streaming context, but
it is much easier to expand now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
2638a04214 Bluetooth: Audio: Shell: Make BAP shell presets constant
Make the BAP shell presets constant. This reflects more
what they represent, and make it not only possible, but also
easier, to modify the individual streams QoS and Codec
configurations, without affecting other streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
3588706d1a Bluetooth: Audio: Shell: Rename streams to unicast_streams
The streams array only contained unicast streams, and
the name should reflect that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Jonathan Rico
b23c330c63 Bluetooth: host: shrink bt_l2cap_le_chan size
Most of this struct is bookkeeping for the dynamic channels.
This isn't needed for e.g., a simple peripheral using GATT.

With a peripheral_hr build for nrf52840dk_nrf52840, we save
280 bytes of RAM.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-15 09:11:33 +01:00
Stig Bjørlykke
6862fdea1a net: dns: Check existing DNS servers before reconfigure
In dns_resolve_reconfigure() check if the DNS servers already exist
before cancel all ongoing queries. This will solve an issue with
getaddrinfo() returning DNS_EAI_CANCELED when receiving a retransmitted
DHCP offer and when receiving a IPv6 Router Advertisement.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-03-14 12:27:15 -04:00
Ajay Parida
43bd60a13a net: wifi_mgmt: Send TWT sleep status event to app
Send TWT sleep status(sleep/awake) event to the apps registered
for event.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-14 10:49:30 +01:00
Tomasz Bursztyka
8c89566993 subsys/disk: No need of runtime intialization for disk access part
Mutex and double-linked list can be statically initialized.

This removes a little bit of boot time overhead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-03-13 18:34:40 +00:00
Vibhor Meshram
4684006f1b Bluetooth: Audio: Remove "Input" from MICP naming
Removed "Input" from Microphone Input Control Profile.
Release notes kept unchanged.

Signed-off-by: Vibhor Meshram <vibhor69meshram@gmail.com>
2023-03-13 18:34:09 +00:00
Emil Gydesen
e80eca0239 Bluetooth: Audio: Shell: Add automatic receiver ready for server
When a stream for a sink ASE goes into the enabled
state we automatically execute the receiver start ready
operation as the unicast server.

This makes the shell easier to use as the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-13 14:04:33 +01:00
Aleksander Wasaznik
6648da731b Bluetooth: Host: SMP Keypress Notification
Add experimental support for SMP Keypress Notification.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-13 14:04:25 +01:00
Emil Gydesen
4fbabc14c5 Bluetooth: Audio: Shell: Fix bug with txing_stream and bap send
The bap send command would set txing_stream but the
pointer would never be reset.

The txing_stream is mainly to handling the start_sine,
so only {start|stop}_sine commands now sets this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-13 14:02:41 +01:00
Nicola Ochsenbein
eba73727ee modules: fs: Add reentrant zephyr support
This commit enables zephyr to configure the FatFs FF_FS_REENTRANT
option and support fs actions from multiple threads.
CONFIG_FS_FATFS_REENTRANT enables the option and provides zephyr
mutex wrappers.

Signed-off-by: Nicola Ochsenbein <Nicola.Ochsenbein@husqvarnagroup.com>
2023-03-13 11:58:57 +01:00
Michal Ciesielski
43c08d5c3f lwm2m: Fix multi res inst, create flags and post write callback for SWMGMT
The multi resource and create flags were reversed, meaning that resources
were defined as multi resource but weren't being created by default. That
doesn't reflect the LWM2M Software Management, which specifies which
objects can be multi resource and which are mandatory.

The post write callbacks were assigned to the validate callbacks.

Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
2023-03-13 11:58:29 +01:00
Julien D'Ascenzio
f76bfa5712 nvs: use NVS cache in write and gc functions
NVS cache was used only in read function. This commit add the usage of
NVS cache in write and gc functions.

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2023-03-13 09:21:22 +00:00
Julien Vermillard
a9349fe74d net: lwm2m: Typo in LWM2M_IPSO_TIMER description
Changed description to "IPSO Timer Support" in place of "Light Control
Support"

Signed-off-by: Julien Vermillard <julien@vermillard.com>
2023-03-11 08:46:22 +02:00
Lingao Meng
81847a57ff Bluetooth: Host: Refine assert message
Add opcode information for cmd timeout assert,
since BT_DBG usually not show in real product,
however we can't see any information just from
assert message.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-03-10 11:39:05 +01:00
Andries Kruithof
02eac5cbc2 Bluetooth: controller: fix compile error when VS cmds disabled
When vendor specific commands are disabled by setting
BT_HCI_VS=n the host still calls bt_read_static_addr,
but that function is not compiled in, resulting in a
build error.
Fixed by moving the code in controller/hci/hci.c
outside of the conditional compile

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-10 09:39:23 +01:00
Vidar Lillebø
ca3d0c8ee9 mbedtls: Remove dependency on MBEDTLS_BUILTIN for MBEDTLS_DEBUG
Allows using MBEDTLS_DEBUG functionality when not using MBEDTLS_BUILTIN.

Signed-off-by: Vidar Lillebø <vidar.lillebo@nordicsemi.no>
2023-03-10 09:30:32 +01:00
Erik Brockhoff
1028cab11e Revert "Bluetooth: controller: use RX node piggy-back for NTF when possible"
This reverts commit 6dbc446342.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-10 09:30:23 +01:00
Erik Brockhoff
a40434748c Revert "Bluetooth: controller: fixing CIS establish flow for refactored LLCP"
This reverts commit 1d8acfe5fa.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-10 09:30:23 +01:00
Krzysztof Chruscinski
68955ebdb6 logging: Increase package size limit to 2047
Package length was previously stored on 10 bits which limited
package size to 1023 bytes. Descriptor which contained package
length field had one unused bit which can be used to increase
package length field to 11 bits doubling the maximum package
length.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Krzysztof Chruscinski
a5979dcfa1 logging: Log warning and drop too big message
When packacge exceeds the limitation warning log is printed
and message is dropped.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Krzysztof Chruscinski
24ad096232 logging: Renamed internal defines to get rid of 2 suffix
Some internal macros were still using 2 suffix which comes from
time when there was v1 and v2. Cleaning up by removing the suffix.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Mariusz Skamra
f2d43cf0ac Bluetooth: ascs: Fix missing list initialization
This fixes missing initialization of active ASE list.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-09 17:23:46 +01:00
Pavel Vasilyev
6810e669e1 Bluetooth: Mesh: Reschedule dedicated relay adv sets immediately
Reschedule dedicated relay adv sets immediatey after finishing
advertising of the previous relay message. This allows a node to
relay messages as fast as possible when Relay Retransmit Count state
is zero using less relay adv sets.

When Relay Retransmit Count state is non-zero, the delay doesn't do
anything as the time between pushing a relay message to the host and
triggering adv_sent callback will be greater than this delay. In this
case the relay adv set will send a next message immediately.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-09 17:21:39 +01:00
Andrei Emeltchenko
c574bfcfd2 bluetooth: audio: Fix NULL dereference before NULL check
Fixes NULL dereference before NULL check for conn.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-09 17:21:26 +01:00
Emil Gydesen
bdbfcb12ca Bluetooth: Audio: Unicast stream start fix
The unicast client would attempt to send the
receiver start ready opcode to the server for
source ASEs before the CIS was connected, which
is a spec violation.

The code has been refactored to set a boolean,
and then send the receiver start ready opcode on
CIS connection instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-09 17:21:14 +01:00
Pavel Vasilyev
4a59107fc7 Bluetooth: Mesh: Fix compilation issue in access.c
This fixes compilation errors of BabbleSim tests generated by gcc-12
when MOD_REL_LIST_SIZE is zero.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-09 16:02:21 +01:00
Jonathan Rico
da97ab6ee8 Bluetooth: host: gatt: respect BT_GATT_ENFORCE_SUBSCRIPTION
A subscription check was still being done in the
gatt_notify_multiple_verify_params() fn, regardless of the value of
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION.

This could lead to getting this warning if BT_GATT_NOTIFY_MULTIPLE is
enabled, and the notifications not being sent to unsubscribed peers.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-09 11:49:34 +01:00
Szymon Janc
6ca2dac6a3 bluetooth: controller: Fix build with BT_HCI_VS_EXT disabled
[216/319] Building C object zephyr/subsys/bluetooth/controller/
  CMakeFiles/subsys__bluetooth__controller.dir/hci/hci.c.obj
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:
   In function 'hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459:17:
   warning: implicit declaration of function 'vs_set_min_used_chans';
   did you mean 'll_set_min_used_chans'? [-Wimplicit-function-declaration]
 5459 |                 vs_set_min_used_chans(cmd, evt);
      |                 ^~~~~~~~~~~~~~~~~~~~~
      |                 ll_set_min_used_chans
....
zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../
  ../../../arm-zephyr-eabi/bin/ld.exe: zephyr/subsys/bluetooth/controller/
  libsubsys__bluetooth__controller.a(hci.c.obj): in function
   `hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459: undefined
   reference to `vs_set_min_used_chans'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-09 11:49:14 +01:00
Mariusz Skamra
50d21999fe Bluetooth: ascs: Fix bt_ascs_ase missing cleanup
Once the bt_ascs_ase is taken from the mem_slab, it has to be memset to
override the junk data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-09 09:45:52 +00:00
Andy Ross
d20ab8c609 subsys/pm: Use correct timeout API
The z_set_timeout_expiry() function is a wrapper provided in the
timeout subsystem that has some corrections for timelicing.  But the
suspend code doesn't care; by definition there are no active threads
that might be timeslicing at the point where the OS is suspending.
Use the lower-level timer driver API instead.

(z_set_timeout_expiry() is also about to disappear)

Signed-off-by: Andy Ross <andyross@google.com>
2023-03-09 09:21:12 +01:00
Sebastian Arnd
3cd58c29bf net/lib: mqtt_sn: Fix MQTT-SN IPv6 Support and assertation in Example
1. `zsock_socket()` gets the right packet familiy.
2. `inet_pton()` returns 1 on success.

This should address #55193.

Signed-off-by: Sebastian Arnd <sebastianarnd@gmail.com>
2023-03-09 09:20:53 +01:00
Ajay Parida
ce4a809751 net: wifi_mgmt: Updated TWT setup response status
Display message updated for TWT setup response.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-08 15:33:30 +01:00
Chris Friedt
79d4107beb net: http: define http service and resource iterable sections
Provide a means of declaring zero or more HTTP services, each
with zero or more static HTTP resources.

Static HTTP resources are those which have fixed paths[1] which
are known prior to system initialization. Some examples of
static http resources would be

* a forwarder from '/' to '/index.html'
* a REST endpoint with fixed path '/api/foo' and detail
  pointing at some implementation-specific function
* a Javascript file in string form with fixed path '/js/util.js'
* a 'construction' image with path '/res/work.png'
* a gzip-compressed 'Hello' HTML file at '/hello.html'

Without describing in any detail how static HTTP resources are
organized or served by any given HTTP server, we can describe
what static resources exist on a system in a common way that
does not require any optional facilities (e.g. filesystem) and
relies only on addressable memory.

Additionally, for the purposes of simply allowing others
to implement custom HTTP servers in a consistent way, or
benchmarking implementations, or having a consistent testsuite
to use across multiple implementations, it is helpful to have
a common method to declare HTTP services and static resources
for Zephyr.

[1] https://en.wikipedia.org/wiki/URL

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-08 13:57:13 +00:00
Emil Gydesen
72d80b74be Bluetooth: Audio: Move stream_reset before released callback
In the unicast client we should reset the stream before calling
the released callback. This is so that we can reuse the stream object
in the released callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-08 11:07:40 +01:00
Emil Gydesen
136191e936 Bluetooth: Audio: Fix return value for VOCS invalid location
If the location was invalid, we return 0 instead of
an error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-08 11:07:00 +01:00
Mariusz Skamra
cf7bfc406c Bluetooth: audio: Remove redundant forward declaration
This removes redundant bt_bap_ep declaration, as the structure is
defined right below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-08 11:06:51 +01:00
Mariusz Skamra
cb1d36afca Bluetooth: audio: ascs: Remove unused includes
This removes unused includes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-08 11:06:36 +01:00
Tomasz Moń
5bd0f5ea8b usb: device_next: msc: handle MODE SENSE(10) command
USB Mass Storage Specification for Bootability requires MODE SENSE(10)
command. MODE SENSE(6) and MODE SENSE(10) generally access the same data
but differ in the maximum allocated length and LLBAA support. However
there is no point in extracting common handling because there no mode
pages are supported now.

Fail MODE SENSE requests if asking for anything other than supported
page codes (to which the essentially hardcoded response is valid).

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-08 10:53:55 +01:00
Mariusz Skamra
1a0e7fa57a Bluetooth: audio: ascs: Remove reference to conn internals
This removes using conn internal API in ASCS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-07 18:19:08 +01:00
Emil Gydesen
e36caf48b7 Bluetooth: Audio: Rename audio shell commands to bap
Change the shell commands from "audio ..." to "bap ...".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
26f8db4c61 Bluetooth: Audio: Rename stream.h -> bap_stream.h
Renamed the file to better match what it contains.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
099c13846e Bluetooth: Audio: Fix minor bt_audio -> bt_bap issues
Several places used the bt_audio prefix where it shouldn't.
Also moved the BAP documentation to its own file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
e2765d7bd5 Bluetooth: Audio: Rename bt_audio_iso to bt_bap_iso
Rename the internal bt_audio_iso struct and API to bt_bap_iso

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
271ff1d1a3 Bluetooth: Audio: Add new bap_lc3_preset and move macros
Added a new header file bap_lc3_preset.h which contains
the definitions of the LC3 (pre)sets defined by the
BAP spec.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
3326863267 Bluetooth: Audio: Rename bt_audio_ep to bt_bap_ep
Rename the bt_audio_ep struct and API to bt_bap_ep
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
4224b45838 Bluetooth: Audio: Rename bt_audio_unicast_group to bt_bap_...
Rename the bt_audio_unicast_group API to bt_bap_unicast_group
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
77853f43f2 Bluetooth: Audio: Rename bt_audio_stream to bt_bap_stream
Rename the bt_audio_stream API to bt_bap_stream
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
e0fc612c93 Bluetooth: Audio: Rename bt_audio_unicast_client to bt_bap_...
Rename the bt_audio_unicast_client API to bt_bap_unicast_client
and move the API to bap.h

Also adds the _bap_ infix to the bt_unicast_client functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
be42429f90 Bluetooth: Audio: Rename bt_audio_broadcast_source to bt_bap_...
Rename the bt_audio_broadcast_source API to bt_bap_broadcast_source
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
06d00ff5f9 Bluetooth: Audio: Rename bt_audio_broadcast_sink to bt_bap_...
Rename the bt_audio_broadcast_sink API to bt_bap_broadcast_sink
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
eeae1f096a Bluetooth: Audio: Rename bt_audio_unicast_server to bt_bap_...
Rename the bt_audio_audio_server API to bt_bap_unicast_server
and move API to bap.h.

This also adds the _bap_ infix for bt_unicast_server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
7fc051967f Bluetooth: Audio: Add bap prefix to BAP internal files
All internal files that implement BAP now has the
bap_ prefix.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Mariusz Skamra
e33705f64c Bluetooth: audio: ascs: Remove unused variable
This fixes compiler unused variable error

warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
  461 |         struct bt_ascs_ase_status *status;

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-07 15:54:58 +01:00
Tomasz Moń
4c97dd546a usb: device_next: msc: STALL OUT when waiting for reset
Mass Storage Class allows device to either silently discard OUT endpoint
data after receiving invalid CBW or to STALL the OUT endpoint (and keep
it STALLed regardless of host clearing halt) until Reset Recovery.

Switch from silently discarding to STALL in order to allow host realize
that device waits for Reset Recovery without transferring complete OUT
data.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-07 15:48:40 +01:00
Emil Gydesen
736ec47fb3 Bluetooth: Audio: Add ASCS delay for CIS disconnect
While both the server and client are allowed to terminate
the CIS when a stream is released, it is, per the BAP spec,
the client's responsibilty. This commit modifies it so that
the client will actually get a chance to do its responsibilty
by adding a small delay before our ASCS disconnects the CIS.

The CIS disconnection has kept with a delay, rather than
removed, in case that the Unicast Client is not properly
performing it's responsibility.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 11:12:40 +01:00
Vinayak Kariappa Chettimada
c7835e239f Bluetooth: Controller: Remove mesh low lat bsim test workaround
Remove mesh loopback group test workaround introduced in
commit 2a9cd8ffb1 ("Bluetooth: Controller: Add
EVENT_OVERHEAD_START_US when enabling states").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-07 11:12:23 +01:00
Vinayak Kariappa Chettimada
55c4084c8b Bluetooth: Controller: Fix scan window value corruption
Fix scan window value corruption due to modification of
stored ticks_window value when enabling continuous scan.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-07 11:12:23 +01:00
Emil Gydesen
59a9f8a3b0 Bluetooth: Audio: Add reason to BAP stream stopped callback
Forwards the reason parameter from the ISO disconnect to
the stream stopped callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 09:44:20 +01:00
Emil Gydesen
e75fc5e318 Bluetooth: Audio: Remove pac_cache from unicast_client
Removes the unused pac_pache from the unicast_client.

This moves the storing of the PAC records (in the form of
struct bt_codec) from the stack to the upper layers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 09:44:10 +01:00
Alberto Escolar Piedras
f6273e9cb5 Thread analyzer: Prevent on POSIX ARCH
The thread analyzer cannot be really used with the
POSIX architecture.

As:
* Code takes 0 simulated time to execute.
  So the analyzer will report 0 cycles being used.
* The stack allocated by Zephyr is not actually used
  (except for a tiny part used by the arch code itself
  to do a bit of thread bookkeeping).
  The POSIX architecture uses a separate stack
  (from an underlying Linux pthread) which Zephyr is blind
  about. So the thread analyzer is going to only report
  a tiny stack utilization.

Prevent users from selecting them together to avoid confusion.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-07 09:44:59 +02:00
Fabio Baltieri
3386e96515 input: add input subsystem
Initial commit introducing the input subsystem into Zephyr.

Includes the input_event data structure, the input_report_* APIs, an
iterables sections based subscription API and two operation modes:
synchronous, where the listeners are called directly, and asynchronous,
where the listeners are called in a dedicated thread.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-06 11:47:32 -08:00
Erik Brockhoff
1d8acfe5fa Bluetooth: controller: fixing CIS establish flow for refactored LLCP
Latest modification to LLCP removed 'monitoring' of cis->established
flag in LLCP, relying instead on signal through ULL.

For this to work properly the signal must also be generated, so this is
introduced. Note - checking of cis->established flag could be removed
if caller ensures only calling once (on establish condition)

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 17:08:42 +01:00
Krzysztof Kopyściński
392f95705c tests: bluetooth: mesh: add Proxy Solicitation to shell
This adds commands to advertise Solicitation PDUs, configure
On-Demand Private Proxy and manage Solicitation PDU RPL.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
d0995541fb Bluetooth: Mesh: add implementation for Proxy Solicitation
This is initial implementation of Proxy solicitation procedure.
This includes:
- support for sending and receiving Solicitation PDUs
- On-Demand Private Proxy functionality (Server and Client) controlling
  behaviour of node after receiving Solicitation PDU
- Solicitation PDU RPL Configuration (Server and Client), which manages
  Replay Protection List for Solicitation PDUs.

Proxy Solicitation allows to enable advertising of Proxy service on node
by sending Solicitation PDUs. These PDUs are not part of Mesh messages;
instead, these are non-connectable, undirected advertising PDUs with
their own format, containing Proxy Solicitation UUID.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michal Narajowski
d95fe3f52b Bluetooth: Mesh: Add support for Models Metadata Page 128
This patch adds for handling Models Metadata Get Page 128.

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
007bca7b63 Bluetooth: Mesh: Add Composition Data Page 1 to shell
Add parsing of Composition Data Page 1 and enable it's support.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
29f07abc89 Bluetooth: Mesh: Add Composition Data Page 1
Composition Data Page 1 contains information about relations between
models. Implementation saves relations into array of tuples
{ptr to base, ptr to extension, relation type} on model initialization
and uses this information to construct Composition Data Page 1.

Appropriate structures and methods were added to API, allowing user to
parse all received data into Composition Data Page 1 formats:
Composition Data Page 1 Element, Model Item, Model Extension Item.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
0bd0071e4a Bluetooth: Mesh: Add Opcodes Aggregator models to shell
- Add entry for client and server in composition data.
- Add Client commands to aggregate and send messages.

MESH/SR/AGG/BV-02-C requires more key slots.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
da5195ea97 Bluetooth: Mesh: Add support for Opcodes Aggregator models
Includes Opcodes Aggregator Server and Client. To use Opcodes Aggregator
client features with some client model, that client should support async
API.

Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Pavel Vasilyev
d46480c36b Bluetooth: Mesh: Add shell commands for Private Beacon Client
Add shell commands for Private Beacon Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
f9b19010ed Bluetooth: Mesh: Private Beacons
Adds support for private beacon sending and receiving.

Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
b5d6733d53 Bluetooth: Mesh: Add Transport SAR Configuration models to shell
Add Transport SAR Configuration models to shell.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
dd59a45c65 Bluetooth: Mesh: Transport SAR Configuration
Add support for:
- SAR Configuration Client and Server models
- Transport SAR configuration states
- Using SAR Transmitter/Receiver states in segmentation
and reassembly process.

Bsim tests fixes:
- Fix failing replay attack test. The replay attack test doesn't
consider retransmission attempts at the transport layer. When
retransmission happens, SeqNums get increased and the test logic
doesn't work anymore. The simplest fix would be to disable
retransmissions at the transport layer.
- Add device synchronization API to synchronize transport va test.
Device configuration may take different time on transmitter and
receiver. Add synchronisation barrier between devices.
- Fix msg_frnd test. Timing in transport sar behavior has been
changed, which affected test_friend_msg test. Now acknowledgments
are sent much faster and this needs to be considered in the test.
- Fix unicast_low_lat test. Increase number of retransmission
attempts when long segmented message is sent.
- Reduce timeout in kr_old_key test.
- Relax SAR RX state configuration in DFU and BLOB tests.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
8a60dfcd51 shell: Add Large Composition Data Server
- Adds Large Comp Data Server and Client
- Defines some dummy metadata for Health Server

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
df65592d94 Bluetooth: Mesh: Add support for Large Composition Data models
- Adds Large Composition Data Server and Client definitions
- Adds Client API definition
- Adds Health Server Metadata definition
- Refactors Composition Data processing (as a Server) to use common
 methods with Large Comp Data Server

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Stine Akredalen <stine.akredalen@nordicsemi.no>
Co-authored-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
f7f3241628 Bluetooth: Mesh: Shell support for remote provisioning
Adds commands in the mesh shell for remote provisioning client
operation, including scanning, provisioning and reprovisioning.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
3c185e1764 Bluetooth: Mesh: Remote provisioning
Adds remote provisioning models rpr_srv and rpr_cli, and exposes them as
a bearer for the provisioning process.

The remote provisioning models provide the following features:
- Remote provisioning of new devices, using a remote provisioning server
  as a proxy.
- Reprovisioning of existing devices, generating a new device key and
  changing addresses and composition data.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
85431fd69e Bluetooth: Mesh: Add composition data page 128
Composition data page 128 represents the new composition data after a
composition refresh procedure. The implementation stores the old
composition data (before applying a DFU or similar), and uses that as
page 0 if present. As the device has already rebooted by the time page
128 becomes active, its active composition data is page 128, while the
backed up data is the "old" data, which should be shown as page 0.

Co-authored-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
417d328796 Bluetooth: Mesh: DFU and BLOB models in shell
Adds conditional support for the BLOB and DFU models in the mesh shell.
Additionally creates a dummy BLOB stream for testing.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
b054ae364d Bluetooth: Mesh: DFD Server model
Adds support for the Device Firmware Distribution Server model from Mesh
Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
529860e72b Bluetooth: Mesh: DFU models
Adds DFU models from the Mesh Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
4302b568cc Bluetooth: Mesh: BLOB models
Adds support for the BLOB Models from Mesh Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Aleksandr Khromykh
ffddd9ffc0 Bluetooth: Mesh: enhanced provisioning authentication
Implementation of the enhanced provisioning authentication (EPA)
that is based on SHA256 and HMAC security algorithms.
OOB authentication mandates EPA usage.

Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Aleksandr Khromykh
5ffae6486b Bluetooth: Mesh: add mesh 1.1 global config option
All mesh 1.1 features are gathered behind a KConfig options.
Default is disabled.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
1b77e8bbf1 Bluetooth: Mesh: Add Model Receive testing callback
Add a callback similar to net_recv that notifies the application when a
message is received in access layer. This is is useful for testing
purposes (especially automated testing).

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
1c731c714c Bluetooth: Mesh: Refactor bt_mesh_model_recv
Pass only msg context as it is the only thing used from net_rx.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
08f0d1c742 Bluetooth: Mesh: Add a flag for DevKey-only based models
This prevents a Configuration Client from binding an app key to a model
that only supports DevKey-based security.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
7f1b296a0c Bluetooth: Mesh: Do not relay message rejected by Transport layer
Mesh Profile Specification Errata 11341

3.6.4.3 Message error procedure
When the Upper Transport layer receives a message that is not
understood, then the message shall be ignored.
A message that is not understood includes messages that met one or more
conditions listed below:
• The Transport Control message opcode is unknown by the receiving node.
• The Transport Control message size for the Transport Control opcode
is incorrect.
• The Transport Control message parameters contain values that are
Prohibited

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
62aad07968 Bluetooth: Mesh: Check for duplicates in friend queue
Mesh Profile Specification Errata 11302

Section 3.5.5.

When a Friend node receives a message that is destined for a Low Power
node (i.e., the destination of the message is a unicast address of an
element of the Low Power node or in the Friend Subscription List), and
the TTL field has a value of 2 or greater, then the message shall be
processed as follows: If the Friend Queue already contains a message
with the same SEQ and SRC fields as in the received message, or if the
SRC field of the received message is a unicast address of an element of
the Low Power node, then the message shall not be stored in the Friend
Queue. Otherwise, the TTL field value shall be decremented by 1, and
the message shall be stored in the Friend Queue.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
ee3e93148e Bluetooth: Mesh: Change IV Update duration requirement for new nodes
Mesh Profile specification errata 11627

Section 3.10.5:
When a node is added to a network, the node is given an IV Index.
If the node is added to a network when the network is in Normal
operation, then it shall operate in Normal operation for at least
96 hours. If a node is added to a network while the network is in
the IV Update in Progress state, then the node shall be given the
new IV Index value and operate in IV Update in Progress operation
without the restriction of being in this state for at least 96 hours.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
fa107b4b54 Bluetooth: Mesh: Set minimum publish period
Mesh Profile Errata 11392

Section 4.4.3.2.1 Current Fault state:

When the value of a Health FastPublish Period Divisor state is non-zero,
and a Current Fault Fault Array (see Section 4.2.15.1) for at least one
Company ID contains records, an unsolicited Health Current Status
message set to the value of that Company ID and the FaultArray field
containing a sequence of faults representing a sequence of faults in the
Current Fault Fault Array (see Section 4.2.15.1) shall be published
every number of seconds as defined by the value of the Publish Period
divided by the value represented by the Health Fast Period Divisor
state, or every 100 ms (the minimum Publish Period value whichever
is greater.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
91fa9194f0 Bluetooth: Mesh: Fix Heartbeat Pub/Sub Count/Period Log calculation
Mesh Profile Specification Errata 11737 specifies that
Period/Count Log value 0x11 is not defined Log field
transformation in Table 4.1.

Errata 11737 adds value 0x11 to Log field transformation
table with 2-octet value equal to 0x10000 which does not fit into
two octets. This patch changes period calculation to 32-bit precision.
There is also a special case for publication count. If the
log value is equal to 0x11 then the publication count value
should be 0xfffe. When sending Hearbeat Publication Status
message we should return the same value as the one received
in Publication Set so we have to add a case in hb_pub_count_log().

Co-authored-by: Alperen Sener <alperen.sener@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Dave Lacerte
96c8d16986 net: lwm2m: Add IPSO voltage sensor object
Add support fot the IPSO voltage sensor object

Signed-off-by: Dave Lacerte <lacerte.dave@hydroquebec.com>
2023-03-06 12:34:22 +01:00
Marc Lasch
072a5da433 net: lwm2m: Register callback for firmware update cancel
Allow to register a callback function which is called when a firmware
update is canceled by the cancel command.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2023-03-06 12:33:12 +01:00
Arkadiusz Kozdra
f5bf1cddda bluetooth: host: Check bounds on num_completed_packets event
If an event with corrupted length arrives, the extra check makes the
handler return early to avoid reading data out of bounds.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-03-06 11:16:42 +01:00
Erik Brockhoff
6dbc446342 Bluetooth: controller: use RX node piggy-back for NTF when possible
When possible re-use the already allocated RX node for notifications.
Store (retain) RX node and Link element on RX if NTF could occur.
Pass link element to LLCP (ull_cp_rx()) together with RX node.
New RX node type RETAIN introduced to signal retention

When no RX node is available allocate one and hold off TX on procedures
until such time that a node is available for NTF.

In case waiting for NTF buffer avail is needed, allocate and store TX
node to use for TX once NTF becomes available.

CIS Established (incl. timeout handling) is now handled entirely as a
specific event driven by ull_conn_iso - ie removal of procedure check
of cis->established and cis->expire, as this is doubling mechanism
in the conn_iso context.

Unit test and helpers updated to handle new node type.
Function ull_cp_release_ntf() was used only in unit test, so moved to
helper context.
Updating release_ntf to handle the fact that with piggy-backing in test
context the node used for NTF can be from two different memory pools

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 09:35:10 +01:00
Erik Brockhoff
80426ddbed Bluetooth: controller: removed unused code
LLCP data struct member fex.sent was set but not used so remove

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 09:35:10 +01:00
Emil Gydesen
835352c2bb Bluetooth: Shell: Add indication of default_conn in connections cmd
When doing "bt connections" the currently selected ACL (default_conn)
is now indicated with a "*" making it easier to determine which
of the connections is currently selected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-06 09:34:36 +01:00
Lucas Dietrich
c7f9eafeec net: http: Make http_client.c compile with CONFIG_NET_SOCKETS_POSIX_NAMES=n
Use internal constant ZSOCK_POLLIN instead of POLLIN to
 make the http_client source file compile without error with
CONFIG_NET_SOCKETS_POSIX_NAMES disabled.

 Fixes #55423

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2023-03-05 08:51:25 -05:00
Wojciech Slenska
6272ba2d5c shell: added function shell_use_vt100_set
Added function to enable/disable vt100 commands.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-03-04 18:36:39 +01:00
Wojciech Slenska
bbd428fd63 shell: shell_cmds: added vt100 commands
Added command for enablig/disablig vt100 shell commands.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-03-04 18:36:39 +01:00
Dmytro Semenets
e169f7cc12 subsys/storage/flash_map: remove unnecessary includes
Those files includes soc.h header which exists not for all boards.
soc.h consists soc-depended defenitions and need to be included by
soc-depended sources

Signed-off-by: Dmytro Semenets <dmytro_semenets@epam.com>
2023-03-03 15:34:59 +01:00
Ajay Parida
55ed46ff6d net: wifi_mgmt: Updated TWT setup response status
Updated TWT setup response status. Removed un-necessary
error strings, enum and values updated as per f/w.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-03 12:43:43 +01:00
Martin Sollie
e94c33d530 logging: add support for 64 bit timestamps with Linux format
Combining CONFIG_LOG_OUTPUT_FORMAT_LINUX_TIMESTAMP and
CONFIG_LOG_TIMESTAMP_64BIT results in a wrong timestamp, as the
Linux timestamp format print call assumes a 32 bit variable for
the seconds. Fix it by using a different print format for 64 bit
timestamps.

Fixes: #55372

Signed-off-by: Martin Sollie <ms@aziwell.no>
2023-03-03 11:36:14 +01:00
Jamie McCrae
533e312359 mgmt: updatehub: Change Kconfig select to depends on
Changes Kconfig symbols to depend on symbols rather than selecting
them, this avoids a cmake dependency loop.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Jamie McCrae
31201a7f61 mgmt: hawkbit: Change Kconfig select to depends on
Changes Kconfig symbols to depend on symbols rather than selecting
them, this avoids a cmake dependency loop.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Jamie McCrae
c3bfe7a6ba dfu: Change FLASH_MAP and STREAM_FLASH from select to depends on
This fixes a cmake dependency loop when selecting
CONFIG_MCUBOOT_IMG_MANAGER.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Chris Friedt
f923441146 lib: posix: move fnmatch from lib/util to lib/posix
The `fnmatch()` function is specified by POSIX and should be
a part of `lib/posix`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-03 17:40:14 +09:00
Vinayak Kariappa Chettimada
afd4346965 Bluetooth: ISO: Fix BT_ISO_TX_MTU range
In the Bluetooth Core Specification, the minimum
ISO_Data_Packet_Length is 0x0001, hence fix the
BT_ISO_TX_MTU range to allow a minimum value of 1.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-03 09:19:19 +01:00
Tom Burdick
3998f9f898 rtio: Shareable lock-free iodevs
By using an mpsc queue for each iodev, the iodev itself is shareable across
contexts. Since its lock free, submits may occur even from an ISR context.

Rather than a fixed size queue, and with it the possibility of running
out of pre-allocated spots, each iodev now holds a wait-free mpsc
queue head.

This changes the parameter of iodev submit to be a struct containing 4
pointers for the rtio context, the submission queue entry, and the mpsc
node for the iodevs submission queue.

This solves the problem involving busy iodevs working with real
devices. For example a busy SPI bus driver could enqueue, without locking,
a request to start once the current request is done.

The queue entries are expected to be owned and allocated by the
executor rather than the iodev. This helps simplify potential
tuning knobs to one place, the RTIO context and its executor an
application directly uses.

As the test case shows iodevs can operate effectively lock free
with the mpsc queue and a single atomic denoting the current task.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-03 09:18:09 +01:00
Jordan Yates
30dbaa83f7 logging: backend_uart: handle PM on panic
Handling panicking while in an ISR. Instead of attempting to call
`pm_device_get` for each character, ensure that the hardware is enabled
when `log_panic` is called.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-03 09:17:49 +01:00
Jordan Yates
997dce97bf logging: backend_uart: handle runtime PM
Allow the log_backend_uart char_out implementation to integrate with
'Device Runtime Power Management'.

Without using runtime PM, it is impossible for the application to manage
the power state of a UART instance, given that any module in the
application could theoretically LOG_* or printk at any point in time.

This removes the need to manually call `pm_device_state_set` when the
lowest power states must be reached, while still allowing log messages
to be output.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-03 09:17:49 +01:00
Michał Barnaś
e0fbd35fc0 usbc: explicitly declare sizes of state machines arrays
The asserts in the USB-C stack functions were causing compilation
errors when asserts were enabled in Kconfig.
This was caused because the asserts checked if the functions
parameters were within limits specified by the state machine arrays.
At the position of these asserts, these arrays were only declared
without specifying the size of them, what prohibited the asserts from
knowing the size of arrays and checking if specified value is within
limit of it.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-03-03 09:17:11 +01:00
Jeroen van Dooren
1be74ac6d7 net: dns: prevent crash on nullptr as callback
When a query is done, the query isn't set to NULL.
This can cause a nullptr exception in invoke_query_callback().

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-03-02 21:58:07 -05:00
Aleksander Wasaznik
5233fe5fb9 Bluetooth: Host: Log incomplete adv reports
This gives our users some indication of why they are not receiving
long advertisements.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-02 21:19:16 +01:00
Emil Gydesen
8333b12da7 Bluetooth: Host: Add ACL NULL check for ISO conn info
If getting the conn info of an ISO channel, the ISO channel may
not yet have an ACL connection, so we cannot get the
ACL source and destination addresses from the ACL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 17:57:17 +01:00
Simon Frank
5d9db9dc65 fb: cfb: cfb_shell command to set font kerning
Using `struct shell *shell` would be more consistent but triggers CI
check on MISRA rule 5.7 "A Tag name shall be a unique identifier"

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
Simon Frank
b50838c66f fb: cfb: add API to set font kerning
Font kerning was used but it was not possible to change it.
Also, font_idx was set to zero twice in init.

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
JP Sugarbroad
6d4266a451 usb: device: msc: support larger devices
Track LBA rather than byte offset in order to simplify the code and
support devices larger than 4GiB.

Signed-off-by: JP Sugarbroad <jpsugar@amazon.com>
2023-03-02 13:51:37 +01:00
Vinayak Kariappa Chettimada
afa8e6f23a Bluetooth: Controller: Fix extended scanning for BT_CTLR_LOW_LAT
Fix Extended Scanning support for BT_CTLR_LOW_LAT variant
of the Controller implementation by closing the scan window
for every ADV_EXT_IND PDU received that that ULL_LOW context
is enabled back and ticker job can process the request to
start auxiliary PDU reception. Without the change the
ticker job would only run at the end of the scan window that
caused the auxiliary scan prepare to assert due to delayed
ticker timeout expiry callback.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-02 13:46:59 +01:00
Emil Gydesen
6d0c53c959 Bluetooth: Audio: Add addition vol ctlr input checks
Add misisng function parameter input checks to verify
values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 10:56:27 +01:00
Robert Lubos
b6ae195390 net: dhcpv4: Fix potential packet leak in DHCPv4
Packet handlers registered with net_conn API should not use NET_CONTINUE
to report packet processing status. As they register for a specific
local port, it cannot be assumed someone else will handle the packet,
and for net_conn this status is not really handled differently from
NET_OK. Therefore, reporting NET_CONTINUE, and not freeing the packet,
can result in a packet leak.

Too short packets should not really be handled differently from other
malformed packets in DHCPv4 module, therefore report NET_DROP instead of
NET_CONTINUE.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-02 10:01:27 +01:00
Arkadiusz Kozdra
1e293a13bc bluetooth: sco: Error out early on null acl
Cleanup unrefs the ACL connection, so ensure it is never null in the
constructor.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-03-02 09:59:56 +01:00
Emil Gydesen
f2918b0109 Bluetooth: Audio: Fix MCC discover callback on reconnected issue
With BT_GATT_SUBSCRIBE_FLAG_NO_RESUB the MCC subscriptions would
be resent to the server on reconnection. Since this may trigger an
error, the error will trigger a call to the MCC discover complete
callback.

For MCP We can assume that the server stores the subscriptions if
we are bonded, and thus we can use BT_GATT_SUBSCRIBE_FLAG_NO_RESUB.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 09:03:32 +01:00
Emil Gydesen
4b0442ab57 Bluetooth: Audio: Fix missing call to BAP discover cb
If we discover both sink and source ASEs, then we attempt
to subscribe to the ASE CP characteristic twice. However,
if we are already subscribed, then the callback is not called,
and then the 2nd call to discover will not return properly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-01 15:58:15 +01:00
Tomasz Moń
7527b38ff5 usb: device_next: fail Mass Storage requests with invalid length
Fail Mass Storage control requests if wLength is incorrect.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-01 12:02:29 +01:00
Jonathan Rico
caa88b2cfd Bluetooth: host: gatt: don't use settings API in disconnect cb
When `CONFIG_BT_SETTINGS_DELAYED_STORE` is enabled, reschedule the storage
work immediately instead of processing it in the current context.

When that config is not enabled, process the storage in the current
context.

Processing this work (i.e. using the settings API and its likely
FLASH-based backend) in the current context (cooperative prio) may mess
with the real-time constraints of the application threads.

Fixes #55067.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-01 11:10:22 +01:00
Luca Fancellu
d61dcf2f1d net: zperf: improve code quality for tcp_received function
Currently, in tcp_received function defined in zperf_tcp_receiver
module, the assignment of session->state to STATE_COMPLETED is
overwritten on the same path to STATE_NULL and a session is
considered free for both STATE_COMPLETED and STATE_NULL, so remove
the assignment to STATE_NULL.
Remove the break from the STATE_COMPLETED case handling so that it
can fallthrough, in case the same session is used after finish.
Remove also the STATE_LAST_PACKET_RECEIVED case because this state
is never reached.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
7c4ea08db8 net: zperf: fix typo in error messages
Fix typo in error messages from the zperf_tcp_receiver where UDP
is written instead of TCP.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
910de7f83d net: zperf: unify get_session among TCP and UDP
The modules zperf_udp_receiver and zperf_tcp_receiver use two
different functions to get a zperf session to store the
statistics, there is a TODO comment in the zperf_session module
suggesting to unify that part.
So delete the get_tcp_session function and use get_session for
both TCP and UDP receiver module.
Delete sock field from struct session because it's not used
anymore.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
1a12a070eb net: zperf: add configurable for the zperf sessions number
Currently the maximum number of zperf sessions handled is hardcoded
to 4, create a Kconfig parameter, with default value 4, to make the
maximum number of sessions configurable.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Arkadiusz Kozdra
642548daeb bluetooth: host: Check bounds more explicitly
Co-authored-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 13:23:51 +01:00
Arkadiusz Kozdra
8848380dff bluetooth: host: Check bounds on le_adv_report event
If an event with corrupted length arrives, the extra check makes the
handler return early to avoid reading data out of bounds.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 13:23:51 +01:00
Arkadiusz Kozdra
a000c2e903 bluetooth: host: Check for NULL discovery callbacks
Fixes a segfault if a discovery event happens while discovery is not
active and the discovery callback is null.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 12:48:47 +01:00
Dawid Niedzwiecki
2d0a784c41 subsys/mgmt/ec_host_cmd: rework Host Command support
Rework the Host Command support. It includes:
-change API to backend
-change a way of defining rx and tx buffers
-fix synchronization between the handler and backend layer
-simplify the HC handler

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Dawid Niedzwiecki
b2674a4b34 subsys/mgmt/ec_host_cmd: rename peripheral to backend
Follow naming pattern in the subsystems(logging or shell) and name
the layer between generic handler and peripheral driver "backend".

The name doesn't suit that well to the SHI backend, because there isn't
SHI API itself and the SHI interface is used only for the host
communication. So the backend code includes the peripheral driver itself.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Dawid Niedzwiecki
e734adfb78 subsys/mgmt/ec_host_cmd: update directory structure
The Host Commands can be used with different transport layers e.g. SHI
or eSPI. The code that provides the peripheral API and allows sending
and receiving Host Commands via different transport layers is not
actually drivers of a peripheral, so move it to the
subsys/mgmt/ec_host_cmd folder.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Flavio Ceolin
72fbc8c56d pm: device_runtime: Early feature enabled check
Check if device runtime is enabled in the beginning of
runtime_suspend to avoid unnecessary checks.

This does not change the current behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-02-28 10:41:30 +01:00
Flavio Ceolin
c4258dbde3 pm: device_runtime: Early feature enabled check
Check if device runtime is enabled in the beginning of
pm_device_runtime_get to avoid unnecessary checks.

This does not change the current behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-02-28 10:41:30 +01:00
Jun Qing Zou
755f0b7d27 net: tftp: Add client context
Use client context to seperate buffer usage.
Use new `TFTP_EVT_DATA` event to send data to application.
Use new `TFTP_EVT_ERROR` event to report error to application.
Update `tftp_get()` and `tftp_put()` API to use the client context.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-28 10:29:30 +01:00
Emil Gydesen
838cc543d8 Bluetooth: Services: Set IAS alert level before callback
Fix the order of setting the alert level before the callback.
Without this fix, the alert level would be incorrect if
the upper layers ever tried to perform any other IAS operations
in the callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-27 13:20:33 +01:00
Stefan Schwendeler
596a3bd996 net: lwm2m: bugfix lwm2m shell exec command with optional parameter
Actually `execute_cb` is fed with an array of char* and the size of
that array, instead of a single char* buffer and its byte size.

This fix expects a single, already joined, optional shell argument and
feeds `execute_cb` with proper arguments.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-27 11:34:42 +01:00
Miika Karanki
549de77750 usb: device: fix k_usleep in isr in set_endpoint
set_device can be called in interrupt context at least with
stm32u5 soc. Calling k_usleep from there causes the isr
to run forever.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2023-02-27 11:34:33 +01:00
Jonathan Rico
298ae28707 Bluetooth: host: gatt: fix ifdef comment
Forgot to update the ifdef comment when adding another condition.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
1906b05b10 Bluetooth: host: use ATOMIC_DEFINE for GATT global flags
Use a single bit array instead of multiple atomic_t variables.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
3486f133e9 Bluetooth: host: prevent registering services in the wrong context
There is a touchy spot where registering a service might result in sending
service changed indications that are not necessary. This is due to a race
condition between the SC work and the GATT DB hash being calculated.

Only allow users to call this API when we know it is safe:
- either before BT is initialized
- or after settings have been loaded (and hash calculated)

Fixes #54047

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
02edcd6494 Bluetooth: host: calculate GATT DB hash on settings load
Prevent race condtions between the stack and the low-priority thread by
calculating the hash (and acting on it, e.g. for marking peers
change-aware, sending SC indications, etc) in the settings_load() context.

Fixes #54773

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
b3671666e1 Bluetooth: host: clear ATT pending flag on failure to send
`ATT_PENDING_SENT` wasn't cleared when L2CAP reported an error when sending
the packet. This resulted in the channel being unusable for ever, since we
only clear that bit on a response (that will never be sent).

Found when setting `CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768` in the
`notify_multiple` test. The kicker was the bug didn't manifest when EATT
wasn't enabled:
- we were queuing two unsubscribes back to back in the test
- on UATT we have to wait for a req-rsp pair before enqueuing a new one
- on UATT we only have one channel anyways

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:32:13 +01:00
Sjors Hettinga
c51cf4f08d net: websocket: Make sure the mbedtls_sha1 function is build in
In the header the websocket protocol needs a SHA1 hash. This is
implemented using the mbedtls_sha1 function. Select the option
MBEDTLS_MAC_SHA1_ENABLED from the Kconfig of websocket to ensure this
function is build in.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-02-24 18:12:14 +01:00
Tomasz Moń
509c033c1d usb: device_next: new USB Mass Storage implementation
Introduce new USB Mass Storage Bulk-Only Transport implementation
written from scratch. Main goal behind new implementation was to
separate USB and SCSI parts as clearly as possible.

Limited set of SCSI disk commands is implemented in separate source code
file that is internal to USB device stack. While it should be possible
to use the SCSI implementation by other components there is currently no
other user besides USB MSC and therefore SCSI header is kept private.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-02-24 15:19:20 +01:00
Johann Fischer
c51744c6ee usb: device_next: use consistent nil descriptor name
Use a consistent nil_desc name for the descriptor that
terminates a class (function) descriptor.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-24 14:02:37 +01:00
Yuval Peress
8ac822e69c emul: Cleanup emul directory
Avoid implementations in the subsys emul directory to keep the directory
focused on emulator subsystem instead of consumers. Consumers should be
implemented side-by-side to their drivers

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress
a6326f1f7f bmi160: move emulator to driver directory
Allow the emulator to sit in the same directory as the driver
implementation. This will make working on the emulator much easier and
keep the emulator subsystem directory clean by allowing it to focus on
the actual subsystem and not the use cases of the subsystem.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Krishna T
50c1f857e0 net: l2: wifi: Log packet errors
Log packet errors, this is handy for debugging.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-24 11:49:41 +01:00
Andries Kruithof
226c99b455 tests: bluetooth: add prefix to exposed API
In ull_llcp* some functions used in unittesting did not have
the llcp_ prefix
Although this is not a big issue since they are only used when
testing the module this commit adds the prefix so that we
have a more consistent naming

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 11:46:39 +01:00
Andries Kruithof
e6ba1eed90 bluetooth: controller: update unittests for LLCP to use proper ZTEST API
Update unittests for the following areas/controll procedures
- API
- collision handling
- invalid PDUs
- unsupported procedures
- buffer allocation
- TX queue
- Data Length Update
- PHY update
- Encryption
- Ping
- Version
- Channel map update
- Min. used channels
- Connection update
- SCA
- Terminate connection
- CTE request
- CIS create
- CIS terminate

Also moved the internal API tests from the ull_llcp* files
to the proper unittest C-file

Unused files  are removed

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 11:46:39 +01:00
Vinayak Kariappa Chettimada
ade92f4d28 Bluetooth: Controller: Fix mayfly priority check when in ZLI
Fix mayfly_prio_is_equal() function when BT_CTLR_ZLI is
enabled.

When Zero Latency IRQs are used, LLL execution priority
is the Zero Latency IRQ priority and will not be equal
to ULL execution priority.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-24 11:00:43 +01:00
Vinayak Kariappa Chettimada
e409aadf0c Bluetooth: Controller: Fix Peripheral CIS supervision timeout
Fix Peripheral CIS supervision timeout due to missing access
address timestamp capture in subsequent subevents when
anchor point was not sync in the first subevent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-24 11:00:36 +01:00
Zachary J. Fields
66aff25396 usb: usb_transfer.c: Address -Wextra warnings
Changed incrementing `for` loop counters to `size_t` from `int` to
eliminate warning, "warning: comparison of integer expressions of
different signedness: 'uint32_t' {aka 'unsigned int'} and 'int'
[-Wsign-compare]"

Signed-off-by: Zachary J. Fields <zachary_fields@yahoo.com>
2023-02-24 09:39:01 +01:00
TOKITA Hiroshi
cccfc8fc8f fb: cfb_shell: set pixel format as MONO10 or MONO01 on initializing
Set the display's pixel format to MONO10 or MONO01 that cfb supports
on cfb initializing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
TOKITA Hiroshi
279c722edb fb: cfb_shell: turn off display_blanking at initializing
Turn off display_blanking to make it able to refresh on a device
even when blanking default off.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
Emil Gydesen
5d5dffef76 Bluetooth: Audio: Fix ASCS check for streaming state
Add missing check for receiver_ready in the state
change to enabling state. This change makes the
the check in the state change similar to the check
in ascs_ep_iso_connected

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-24 09:24:34 +01:00
Johann Fischer
d17119c612 usb: device_next: add feature endpoint halt/clear state update API
Add USB device class API to notify class instances that an endpoint
has been halted or cleared due to a feature request.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-24 09:15:55 +01:00
Andries Kruithof
94cfb8dbcf Bluetooth: add decoding for BLE 5.4 version string
The BLE 5.4 specification was recently released. Here the
version strings are updated

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 09:13:18 +01:00
Andries Kruithof
b02ce97dd0 Bluetooth: controller: update bluetooth version to 5.4
The Bluetooth 5.4 specification was recently released, and has a new
version identifier (0x0D or decimal 13) assigned to it in the
Bluetooth Assigned Numbers.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 09:13:18 +01:00
Aaron Massey
107cb86bb3 ztest: Add initial zexpect API for delayed failing
Add the zexpect API, inspired by GoogleTest's EXPECT API. This API reports
test failures while allowing test execution to continue. This enables test
reports to show more than a singule failing property on a failing test.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-02-23 20:34:39 +01:00
Andrei Emeltchenko
8e84d840b5 usb: Fix build for 64 bit platforms
Use proper format for size_t type eliminating warnings of type:

...
error: format '%u' expects argument of type 'unsigned int', but
argument 2 has type 'size_t' {aka 'long unsigned int'}
[-Werror=format=]
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-02-23 17:51:31 +01:00
Emil Gydesen
300491af34 Bluetooth: Audio: Shell: Audio shell improvements
This commits allows for setting up multiple streams in
a single CIG as the unicast client.

It fixes an issue with the unicast server not using
the configured QoS when transmitting audio data.

Improves upon setting the preset for the different
type of streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 10:49:53 +01:00
Hubert Miś
2c3863160d ipc: multi-endpoint icmsg cleanup
The multi-endpoint backend of the ipc_service subsystem contains two
roles with separated implementations: initiator and follower. There
was many code duplications for both roles. This patch introduces a new
IPC library: icmsg_me containing common code extracted from both roles
and encapsulating access to common data fields.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2023-02-23 10:46:25 +01:00
Nick Ward
ca3a4f5f5b shell: backends: dummy: default to log level INF
This change fixes code to match the description in
https://github.com/zephyrproject-rtos/zephyr/pull/55061
(see commit 9ecef4b).

This preserves the previous default behaviour of the
shell dummy backend.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-02-23 09:55:11 +01:00
Robert Lubos
43a86b8138 net: tcp: Fix packet processing result reporting
TCP implementation abused the packet processing result reporting
mechanism, by reporting NET_DROP for every packet other than data
packets (which were passed to the application). This simplified the TCP
implementation a bit, as it didn't need to deal with packet releasing.
While technically it worked, it gave incorrect results when it comes to
packet statistics, as a lot of valid TCP packets were counted as
dropped.

This commit fixes this. Each packet that was properly processed by the
TCP stack is not either released at the TCP level, or passed to the
application. In both cases, NET_OK is returned to the network core,
indicating the packet has been properly processed and consumed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-23 09:07:52 +01:00
Emil Gydesen
4fcc3f0c1e Bluetooth: Audio: Add guard for bt_audio_codec_qos_to_iso_qos
The function are only used by the broadcast roles and
the unicast client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Emil Gydesen
f5f1664a41 Bluetooth: Audio: Move most of unicast client-only code from stream.c
Some operations such as Config, QoS, Enable and Stop
are only available for the unicast client, but since
they share the bt_audio_stream prefix, we leave the
agnostic part of it in stream.c, and move the actual
implementation to unicast_client.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Emil Gydesen
6303fa0c18 Bluetooth: Audio: Remove unicast server specific code from stream.c
stream.c had code that was only useful for the unicast server/
ASCS, and have been moved to ascs.c instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Stig Bjørlykke
b77c234691 net: icmpv6: Initialize dns sockaddr in RA RDNSS
Initialize struct sockaddr_in6 in RDNSS handling to avoid
uninitialized sin6_port or sin6_scope_id.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-22 14:26:39 +01:00
Seppo Takalo
abb3163d82 net: lwm2m: Clear out the timestamp when we start registration
There was a corner case that last registration timestamp was used
to detect if we can try UPDATE instead of full registration.

When timestamp was not cleared and DNS resolving failed, it might
cause engine to skip the resolving and continue retrying an UPDATE
message until timeout.

Fixes #54504

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
d8b8d53f5f net: lwm2m: Drop observations when falling back to registration
When we have establised an DTLS handshake and try LwM2M Update,
if the server rejects it, we fall back to sending full registration
but when doing so, we should also clear out any observations.

It was intentional that we don't go to ENGINE_DO_REGISTRATION
state as that would close the socket and cause DTLS handshake.

Fixes #54974

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
96a4bedd30 net: lwm2m: Don't ignore socket errors when sending
Only socket error that we should ignore is EAGAIN (EWOULDBLOCK),
others might be indicating that there are some serious errors
in network layer.
When network stack would block us, just drop the packet and
let CoAP layer handle the retrying.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
ea1eb28135 net: lwm2m: Fix build issue on time-series cache
This was only missing a variable declaration.

Fixes #55031

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Seppo Takalo
bf49540a8d net: lwm2m: Add const qualifier to many pointers
Various functions, mostly concerning time-series cache, were not
using const pointer while they still did not modify the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Emil Gydesen
b46edc7137 Bluetooth: Audio: Fix bad shell string formats
There was a couple of shell prints that was not
formatted correctly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-22 12:19:04 +01:00
Andries Kruithof
ddd83c3bc0 Bluetooth: controller: correct conditional compile for central FEX
In the switch statement there are two cases guarded by ifdef's.
These cases are not compiled in for the following Kconfig settings:
BT_PERIPHERAL=n
BT_CTRL_PER_INIT_FEAT_XCHG=n
The following function call then becomes dead code
This is fixed here by adding the proper guards around the whole case
statement

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-22 12:16:03 +01:00
Marco Argiolas
9ecef4b415 shell: backends: add init log level for dummy shell
Dummy shell was always started with log backend enabled with filter
 statically set to INFO level.
AFAIK no use of such log backend can be made, thus causing waste of
 resources.
The new changes keep INFO as the default filter level. In order to
 disable log backend to be attached to the Dummy shell,
 CONFIG_SHELL_DUMMY_INIT_LOG_LEVEL_NONE has to be set.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-02-22 12:15:24 +01:00
Fabio Baltieri
8c6137d7a7 build: sort and compact drivers and subsys CMakeLists and Kconfig
There are just list of child files to include, right now there's a hint
of that trying to be alphabetical but then entries have been added with
various logic, so one has to figure where stuff has to be added.

Rewrite these to:
- keep the list alphabetical, for CMakeLists unconditional first,
  conditional after so one just has to select and sort
- drop the spaces in the Kconfig
- use a single space between  target and directory
- rename from "Sub Systems" to "Subsystems" (single word)

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-22 10:25:11 +01:00
Stefan Schwendeler
4662c40888 net: lwm2m: read command uses hexdump as default print format
A default format that does always print something useful.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-22 08:50:56 +01:00
Sam Hurst
df117e563a usb_c: Add super state to handle Sender Response Timer
Any Power Delivery message state that expects a reply must
start a sender response timer. This change addes a super
state that implements the Sender Response Timer
functionality, from which Power Deleiver messages states
can inherit from.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-02-21 18:04:04 -05:00
Fabio Baltieri
9b30667c77 build: drop LEGACY_INCLUDE_PATH support
LEGACY_INCLUDE_PATH has been defaulting to "n" and marked as deprecated
in both v3.2 and v3.3. Drop the option entirely for v3.4.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-21 15:06:48 +01:00
Siyuan Cheng
b475e1fcbf zdsp: add ARC DSPLIB backend for zdsp
Introduce ARC DSPLIB backend zdsp library for ARC target.
Add agu and restrict attributes to map with ARC DSPLIB

Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
2023-02-21 15:06:06 +01:00
Stig Bjørlykke
0f71a130ef net: sockets: getaddrinfo: Minor refactoring
Minor refactoring in getaddrinfo() to make the code easier to
read and to make handling IPv4 and IPv6 support more equal.

- Move common wait and error handling code to exec_query()
- Use the same check for CONFIG_NET_IPV4 and CONFIG_NET_IPV6
- Add extra sanity check for family before exec_query()
- Do not set errno when return DNS_EAI_ADDRFAMILY

Fix issue with setting port number for all DNS servers.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-21 15:02:35 +01:00
Emil Gydesen
4f5e113dfd Bluetooth: Audio: Fix bad log statement in cap_initiator
Fix missing argument for a log statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-21 11:00:18 +01:00
Stig Bjørlykke
cb50d49f33 net: icmpv6: Implement IPv6 RA Recursive DNS Server option
Handle RA RDNSS and use the first DNS server fetched. This is needed
when building IPv6 only without static DNS server IP addresses.

This implementation does not handle the lifetime, because the current
resolve logic does not have support for a DNS server lifetime.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-21 10:59:18 +01:00
Ajay Parida
c69731a281 net: wifi_mgmt: Display TWT setup response status
Display the TWT setup response status.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-02-21 10:58:40 +01:00
Jeroen van Dooren
d20cceb48e net: ip: net_mgmt: Increase default queue size
There is no reason why the default size should be 2,
because an event is only a combination of

{uint32_t + void*} + info

Using 2 as default causes a high risk of loosing events,
setting the default to a more sensible value of 5 still
restricts memory usage but keeps it more safe.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-02-21 10:58:10 +01:00
Jeroen van Dooren
a63fcb67b6 net: ip: net_mgmt: Prevent loss of event
The current implementation doesn't handle
re-entrant calls correctly, causing events
to get lost.

Under specific conditions, re-entrancy happens
from event callback done by net_mgmt.c back into
'net_mgmt_event_notify_with_info' causing circular
buffer administration corruption.

These conditions are:

- llmnr_iface_event_handler
- mdns_iface_event_handler
- wifi_mgmt_raise_connect_result_event
- dhcpv4_immediate_timeout uses a workaround

Validated the fix on a Nucleo_H743ZI, using an
sample app.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-02-21 10:58:10 +01:00
Krishna T
55802e5e86 net: l2: ethernet: Fix double free
In the case of no ARP entry, the incoming packet is added to the ARP's
pending queue, while ARP is being resolved. Here a reference is taken
by the ARP layer to the packet to avoid it being freed, but the Ethernet
immediately puts down the reference and send the ARP packet to the
driver.

If the ARP request fails for some reason, L2 returns failure to net_if
which then puts down the reference and the packet will be freed as the
reference count is now zero.

But the packet is still in the ARP's pending queue and after timeout
ARP will put down the reference causing double free bus fault (double
free message is only seen if the CONFIG_NET_PKT_LOG_LEVEL_DBG is
enabled, so, a bit hard to debug.

Fix this by clearing the ARP entry and pending queue after taking a
reference and then free ARP packet, IP packets are either freed by ARP
pending queue drain or net_if layer.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 19:45:28 +01:00
Marcin Niestroj
830308e00f Bluetooth: host: increase BT_CONN_TX_USER_DATA_SIZE for 64bit platforms
Commit 2c00dd5fec ("Bluetooth: host: check net bufs have enough room in
user_data") added a build time check of user data size. This check does not
pass with default CONFIG_BT_CONN_TX_USER_DATA_SIZE=8 and with
`native_posix_64` platform, as 16 bytes are needed in order to store
`struct tx_meta`.

Select 16 as default value for 64bit platforms, so Bluetooth samples/tests
are buildable for `native_posix_64`.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-02-20 19:44:25 +01:00
Emil Gydesen
928e5bbcf0 Bluetooth: Audio: CAP inittiator broadcast stop procedure
Implemented support for stopping and deleting a
CAP broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
9d0ec99315 Bluetooth: Audio: CAP initiator broadcast metadata update
Add support for the update metadata for broadcast audio
procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
6f1bb59b26 Bluetooth: Audio: Implement bt_cap_initiator_broadcast_audio_start
Implement the CAP initiator broadcast audio start procedure.

This basically just verifies that the stream context
is set in the metadata, and then calls the BAP
procedure.

We define a new opaque struct, bt_cap_broadcast_source,
that is just an abstraction of the bt_audio_broadcast_source
but is used to indicate that these functions require a
broadcast source created by the CAP function (and not the
BAP) function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
17b7854961 Bluetooth: Audio: Fix for PA sync in broadcast sink
Fixes a bug where we cleanup the broadcast sink without
properly terminating the BIG sync first.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:22:15 +01:00
Vinayak Kariappa Chettimada
659294bc3f Bluetooth: Controller: Fix AUX_ADV_IND AUX_SYNC_IND radio utilization
Fix AUX_ADV_IND AUX_SYNC_IND radio utilization by having a
configurable offset.

Define an offset between AUX_ADV_IND and AUX_SYNC_IND when
using Advertising Interval for the Extended Advertising and
Periodic Advertising that are same or multiple of each
other, respectively.

Note, to get advertising intervals that are same or
multiple, the Periodic Advertising Interval shall be 10
millisecond more than the Extended Advertising Interval;
this is because the AUX_ADV_IND PDUs are scheduled as
periodic events of Extended Advertising Interval plus 10
milliseconds (Advertising Random Delay) as the periodic
interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 13:18:12 +01:00
Vinayak Kariappa Chettimada
a8862e2adb Bluetooth: Controller: Fix Close Isochronous Event implementation
Fix the Close Isochronous Event (CIE) implementation so that
it follows the Bluetooth Core Specification definition:
Link Layer implementations will normally end a CIS event
early when all scheduled payloads in both directions have
been transmitted and acknowledged.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 11:48:56 +01:00
Vinayak Kariappa Chettimada
e0f5675e70 Bluetooth: Controller: Rename lll_df_conf_cte_tx_disable()
Rename lll_df_conf_cte_tx_disable() to lll_df_cte_tx_disable()
so that it can be used as a common function between connection
and connectionless implementations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 11:36:58 +01:00
Emil Gydesen
9756aea801 Bluetooth: Audio: Ensure strtoX correctness in vcp_vol_rend.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
fe1d5a8177 Bluetooth: Audio: Ensure strtoX correctness in vcp_vol_ctlr.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
668ed75a22 Bluetooth: Audio: Shell: Fix VCP location check
The location value is a uint32_t, and not uint16_t.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
caf259af65 Bluetooth: Audio: Ensure strtoX correctness in tbs.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
d5e625ce9d Bluetooth: Audio: Ensure strtoX correctness in tbs_client.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
87cd6dd743 Bluetooth: Audio: Ensure strtoX correctness in mpl.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
97f14779a5 Bluetooth: Audio: Ensure strtoX correctness in micp_mic_dev.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
07f4c83610 Bluetooth: Audio: Ensure strtoX correctness in micp_mic_ctlr.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
1bf9aae455 Bluetooth: Audio: Ensure strtoX correctness in media_controller.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
f0ea061b3a Bluetooth: Audio: Ensure strtoX correctness in mcc.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
0c9180ef99 Bluetooth: ISO: Ensure strtoX correctness in iso.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
ab9d2c32c9 Bluetooth: Audio: Ensure strtoX correctness in csip_set_member.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
311476d5ce Bluetooth: Audio: Ensure strtoX correctness in csip_set_coordinator.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
774f607cfe Bluetooth: Audio: Ensure strtoX correctness in cap_acceptor.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
760e987529 Bluetooth: Audio: Ensure strtoX correctness in bap_scan_delegator.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
7bbddc14e3 Bluetooth: Audio: Ensure strtoX correctness in bap_broadcast_assistant.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
6fa4b00180 Bluetooth: Audio: Ensure strtoX correctness in audio.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Siddharth Chandrasekaran
011e784844 mgmt/osdp: More error handling and other cleanups
cp_build_command returns the length of the built packet and early
returns for errors. This means there is no need to keep track of return
code in a separate variable -- if we reached the end, we succeeded.

Along with this change, some more changes to enhance maintainability and
readability are also done.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
20f806de4e mgmt/osdp: cp: Rework CP state management
With changes to the phy layer and the way we build and dispatch
commands, we can now simplify some parts of CP state machine. This patch
builds on previous patches to reduce some state transitions and fixes
some bugs in those paths.

While at it, also implement an exponential back-off for PD offline after
a timeout. This is useful when there is a transient PD timeout but the
PD itself is not totally dead.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
d92c2e4ba1 mgmt/osdp: pd: Rework state machine to handle multiple packets
After the check_packet() split from decode_packet() for handling multiple
packets in the RX buffer, PD state machine needed to me modified to
start handling it correctly. While at it, simplify the states as PD does
not have as much state anyways.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
062a45ef35 mgmt/osdp: cp: Split build_packet and send_command
The method send_command was building the packet and also sending it.
This is a problem because even command build failures are reported as
command send failures; although the former can be mitigated by changing
kconfig parameters depending on use cases.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
ec53f2f6a8 mgmt/osdp: phy: Move packet checks out of decode_packet
To handle multiple packets in RX buffer, we need to perform checks on
the buffer first and determine the length of one packet and extact only
that many bytes from the RX buffer instead of pulling everything at
once and failing if there are bytes from the next packet in the buffer.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
b0cf5163d8 mgmt/osdp: cp: Move set PD online status to a method
When a PD is set online, we need to do other actions along with it. To
make this easier in future, move cp_set_state(pd, OSDP_CP_STATE_ONLINE)
to it's own method cp_set_online(pd).

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Jamie McCrae
1b4b979f87 mgmt: mcumgr: Change select to depends on in Kconfigs
Select in Kconfig causes many issues with dependency loops, this
resolves the issue by replacing most select with depends on for
MCUmgr, including updates to the sample smp_svr application and
tests.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 11:27:43 +01:00
Magdalena Kasenberg
e77b571ebd LE Audio: Fix response code expected by ASCS/SR/SPE/BI-18-C
When handling ASE Control operations requested by client,
first verify that the requested ID is within the allowed range.
If it does, lets assume that the NULL returned from ase_find()
means the ASE state is set to idle.

This will fix ASE Notification Response code expected by
the ASCS/SR/SPE/BI-18-C PTS test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 11:26:45 +01:00
Emil Gydesen
c0150c9ce5 Bluetooth: Audio: Ensure stream disconnect correctness for unicast client
Add a new function for the unicast client that verifies whether
or not the unicast client can terminate the CIS given the
state of any paired endpoint and the CIS state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
ad304697ab Bluetooth: Audio: Handle GATT/ISO race condition in unicast client
When releasing a stream causing the CIS to disconnect, there was
a race condition between the CIS disconnect event and the
idle state notification from the unicast server.

This ensures that if we are disconnecting a CIS as part of the
release, then we wait for the CIS disconnect event before calling
the "released" callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
d2dfc3c475 Bluetooth: Audio: Add addition ISO chan state check before disconnect
Add state check for BT_ISO_STATE_CONNECTING before disconnecting
the CIS, else we could end up in a race condition where we
did not disconnect the connecting CIS, and then still have
a CIS afterwards.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
984ce52ddb Bluetooth: ISO: Fix state checks for bt_iso_chan_disconnect
The behavior of bt_iso_chan_disconnect depends on the
state of the ISO channel.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
c67c7728a6 Bluetooth: Audio: Unicast client check ISO state before disconnect
Add a check to see if the ISO is connected before we attempt to
disconnect it. In the case where a stream was not in the streaming
state and was released, the CIS is unlikely to be connected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
fdc26eee78 Bluetooth: Audio: MCS reject long read if value changed
Add support for reject long read if a long value is
changed during the read.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
281d0a3fc8 Bluetooth: Audio: Add media player icon URL changed callback
Add support for notifying MCS a player icon URL change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
4d595014ab Bluetooth: Audio: Add media player name changed callback
Add support for notifying about a player name change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
89e907cb3d Bluetooth: Audio: Truncate MCS notifications per conn
When notifying a long (string) value in MCS, each
connection's MTU is taken into account when
(potentially) truncating the notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
788abf6811 Bluetooth: Audio: Fix truncation of MCS string notifications
The truncation of the MCS string notifications was incorrect.
As per the MCS specification, the MCS shall send ATT_MTU - 3
if the value cannot fit in the notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Sam Hurst
2d510fef8d usb_c: Notify DPM of Unsupported message reception
Notify the Device Policy Manager when an unsupported
message is received.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-02-20 11:24:07 +01:00
Robert Lubos
243af28a2f net: ipv4: Implement fallback to LL address
According to RFC3927, hosts with only IPv4 LL address should still be
able to send packets to destination w/o IPv4 LL address:

   A host with an IPv4 Link-Local address may send to a destination
   which does not have an IPv4 Link-Local address.  If the host is not
   multi-homed, the procedure is simple and unambiguous: Using ARP and
   forwarding directly to on-link destinations is the default route

This behaviour however was not possible with Zephyr, which only allowed
to use IPv4 LL source address for IPv4 LL destinations.

Fix this, by introducing a final fallback (only if IPv4 autoconf is
enabled), to select IPv4 LL address as a source address if no other
address is available.

Additionally, modify the ARP routine a bit if IPv4 LL address is in use.
There's no really point to forward the packet to gateway if IPv4 LL
address is used, as such addresses are not routable. Instead, try to
find the peer in local network in such case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-20 11:19:14 +01:00
Marco Argiolas
92a739e4b4 logging: shell command "disable" fails for "backend" subcommand
A fix to accept valid shell commands of the form `log backend
 shell_rtt_backend disable`, i.e. to affect all modules when no modules are
 specified.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-02-20 11:13:15 +01:00
Vinayak Kariappa Chettimada
3c0c9aca40 Bluetooth: Controller: Replace WFE use with k_cpu_atomic_idle()
Replace the use of WFE with Zephyr kernel supplied
k_cpu_atomic_idle() interface.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Vinayak Kariappa Chettimada
b46b833a7b Bluetooth: Controller: Reuse cpu_sleep interface
Reuse cpu_sleep() interface consistently in Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Vinayak Kariappa Chettimada
67fa62fe22 Bluetooth: Controller: Add a DSB in sleep interface
Add a DSB before doing WFE in cpu_sleep(), to ensure the
memory transactions are complete.

Add a note clarifying a dependency for the existing solution
(dependency is satisfied by ARCH code but is good to state
clearly).

Relates to commit f1264b7e47 ("drivers: entropy: nrf5: add
docs and a DSB in get_entropy_isr").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Jonathan Rico
3a9c825bab Net: Bluetooth: add enough room to user data
We need to make sure the user_data of the network buffer has enough room to
store the L2CAP metadata.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:53:51 +01:00
Jonathan Rico
2c00dd5fec Bluetooth: host: check net bufs have enough room in user_data
Since we accept buffers from external sources in L2CAP, we need to make
sure that we have enough room in user data to store the metadata necessary
for fragmentation over the HCI link.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:53:51 +01:00
Krishna T
b136676772 net: lib: zperf: Add support to disable Nagle's algorithm
This helps in benchmarking smaller packets, esp. as this is the default
behaviour of iperf.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 09:53:43 +01:00
Mingjie Shen
25e3f655f0 Bluetooth: L2CAP: Fix use of 'br_chan'
Assignment to br_chan should be placed after the call of server->accept().
Otherwise, br_chan will always be a null pointer.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-02-20 09:53:26 +01:00
Aleksandr Khromykh
dd1fc0dd03 Bluetooth: Mesh: fix access to uninitialized memory
Running bsim with Valgrind highlighted a couple of
places where read access to uninitialized memory happens.
Config client rewrites publication parameters with not
initialized uuid pointer. Bitfields those are allocated on
the stack keeps not used area uninitialized too.
Uninitialized area is stored in the persistent memory.
PR fixes that.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-02-20 09:53:14 +01:00
Jani Hirsimäki
f21051b728 net: iface: bypassing IP stack with SOCK_RAW sockets
Bypass the IP stack and go directly to L2 with
SOCK_RAW/IPPROTO_RAW sockets in net_if_send_data().

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2023-02-20 09:52:39 +01:00
Stig Bjørlykke
f3661487da settings: Make settings_subsys_init() thread safe
Multiple components may use the settings subsystem, so ensure
settings_subsys_init() is thread safe.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-20 09:52:26 +01:00
Aleksandr Khromykh
59edf5cae3 Bluetooth: Mesh: correction lpn rx delay
If extended advertiser is used, then advertiser sends callback
quite close to the real tx end time. No necessity to consider
advertisement time in lpn rx delay. It allows lpn to spend
less time in active scanning and save more power. Unfortunately,
legacy advertiser shows very slow precision. It is mandatory to
consider adv time for it. Additionally, unnecessary considering of
the advertisement duration has been removed for receive window in lpn.
It makes scanner window longer for a couple of milliseconds.
This is the responsibility of friend node to configure window that
it can manage.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-02-20 09:51:53 +01:00
Krishna T
92aa0e8ab6 net: shell: Log missing Ethernet errors
These error counters are helpful for data path debugging.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 09:51:23 +01:00
Sean Madigan
e79fee7a2e bluetooth: host: conn: Utilize conn_set_state in conn_destroy
Previously we would call conn_cleanup for all connections,
however this had multiple problems such as:
-Not destroying conn->tx_pending packets and causing an assert
-Calling conn_cleanup for connectable adv, triggering
disconnected callback

Now we will use bt_conn_set_state to manage the teardown of
connections correctly. First, if in connected or disconnecting,
set state to disconnect complete. Then for all states, set
state to disconnected. This will carry out proper cleanup
and teardown when required.

To do this, it was required to keep the tx_thread open as
this is used in disconnecting teardown, so this has been
moved to below the conn_cleanup_all call.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2023-02-20 09:50:48 +01:00
Jun Qing Zou
cd79b81d4d lib: tftp_client: Add TFTP PUT function
Add tftp_put() API to support TFTP WRITE request.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-20 09:50:23 +01:00
Jun Qing Zou
f7b0ccba0c lib: tftp_client: Receive file with arbitrary size
Add a callback for READ request to download files with arbitrary length.
Define TFTP_BLOCK_SIZE in API header for application to allocate buffer.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-20 09:50:23 +01:00
Mariusz Skamra
bfb2625818 Bluetooth: audio: has: Fix client context allocation
The client context shall be allocated once paired i.e. encryption is
enabled. This fixes issue that client context was allocated only for
bonded devices and as a result the ATT Unlikely Error was replied to
Control Point operation that paired remote requested.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-02-20 09:49:15 +01:00
Mariusz Skamra
668b40a5c2 Bluetooth: audio: has: Rename has_client struct member
This renames has_client.ntf_bonded to has_client.ntf_pending as this
field is valid for paired devices an contains the notification state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-02-20 09:49:15 +01:00
Magdalena Kasenberg
e26e8d1c07 shell: audio: Add print ASE info command
The command prints id, state and dir of all ASEs of default connection.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00
Magdalena Kasenberg
90ab1c56f5 LE Audio: Add helper functions to get endpoints info
The functions allow to return structure holding information of audio
stream endpoint.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00