Commit graph

18898 commits

Author SHA1 Message Date
Mariusz Skamra
88c20b9cdd Bluetooth: id: Fix uninitialized RPA
This fixes uninitialized RPA value for BT_ID_DEFAULT.
The regression has been introduced in
8d6b206064.
As the result, the private address was not created and the advertising
was started with 00:00:00:00:00:00 address.
In case of the other advertising ID's, those are initialized
from id_create context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-12 10:55:50 +03:00
Balaji Srinivasan
491628ae06 Bluetooth: host: Fix dangling reference in service changed
The bt_gatt_indicate() expects its parameters to remain valid while the
indicate procedure is active. But the `sc_range` variable was local to
the function. It is assigned to the `data` field and passed on to
bt_gatt_indicate(). The memory associated with `sc_range` goes out of
scope as soon as the function returns thereby breaking the contract of
the API. This dangling reference will lead to undefined behavior.
This is now fixed by making the `sc_range` array static and further
making it an array of arrays, as the sc_range may have different values
for each connection.

Found as violation of MISRA C:2012 and CERT DCL30-C by sonarcloud.

Signed-off-by: Balaji Srinivasan <balaji.srinivasan@nordicsemi.no>
2023-05-12 09:55:53 +03:00
Erik Brockhoff
b49ce8febe Bluetooth: controller: fixup HCI LE Create CIS 'parameter' checks
BT Core Spec states that feature exchange should be initiated if
not already performed. So in this case initiate feature exchange
and 'abort' enqueued CIS create if peer doesn't support CIS peripheral
feature

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Erik Brockhoff
105621bdce Bluetooth: controller: Only generate ntf on host initiated feature exch
Only generate notification when feature exchange was initiated by host

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Erik Brockhoff
c1b5aaecf8 Bluetooth: controller: confirm central role on CIS Create
Confirm that the 'requesting connection' is acting as central

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-12 08:43:46 +02:00
Johann Fischer
2dbccf0654 usb: device_next: do not set alternate 0 for non-existent interfaces
A request to set alternate zero for a non-existent interface
would succeed because of the inappropriate order of checks.
Move the check if the desired alternate is the same as the
current one after the check if interface exists.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Johann Fischer
aa5b6db0f4 usb: device_next: correct return type of get/set alternate value helper
Correct the return type of the helper function to get/set
current interface alternate value.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Johann Fischer
e3b17aa5ed usb: host: improve robustness of descriptors print
Check that the length of the packet is at least the size of
the descriptor head. Otherwise there may be unpleasant side effects.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 15:29:58 +02:00
Andrei Emeltchenko
a4341bbc2c bluetooth: audio: Fix logical check
I imagine that expression (req != 0 || req != 1) is always true. Fix
it changing '||' to '&&'.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-11 13:29:46 +02:00
Georges Oates_Larsen
62168b659e net: conn_mgr: connect/disconnect adjustments
Rather than raise error on connect if iface is down, just take the iface
up.

Rather than raise error on disconnect if iface is down, just ignore the
disconnection request.

Adjust tests and documentation accordingly.

This should make the API easier to use for applications and is more in
line with the original L2 agnostic connectivity RFC.

Also replace some instances of net_if_flag_is_set with
net_if_is_admin_up, which is cleaner and identical in function.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
068dc8ba6f net: conn_mgr: Simplify DAD handling
The current method for handling DAD directly tracks a DAD state for each
iface.

This does not reflect the fact that each individual IP has a separate
DAD state.

This also does not align with the logic in conn_mgr_initial_state, which
instead uses net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...).

Thus, the current approach falsely reports IPv6 ready when DAD adds
the link_addr, and also fails to report IPv6 ready if DAD is disabled.

This commit removes DAD tracking completely, and relies solely on
net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...), fixing both
problems, and simplifying the event tracking.

For consistency, slight modifications to IPv4 handling as well.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
74ba47bed0 net: conn_mgr: Fire events only on connectivity gain/loss
Currently, conn_mgr fires L4_CONNECTED and L4_DISCONNECTED events for
every individual iface that gains or loses connectivity.

After this commit, these events are only fired when the first iface gains
connectivity, and the last iface loses connectivity, respectively.

This is so that applications can rely on conn_mgr as a simple way to
track whether connectivity is available.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
b6897c211a net: conn_mgr: Ignore ifaces and L2s
Adds a flag to allow ifaces and L2s to be ignored.

This is so that applictions have better control over what ifaces they
want connectivity management for.

Enabling the flag forces conn_mgr to consider the iface
unready.

Also increase NET_CONNECTION_MANAGER_PRIORITY default value from 0 to 1
so that applications can register SYS_INIT callbacks that fire just
before conn_mgr initializes. This allows ignored ifaces to be configured
before conn_mgr starts, if needed.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
6cda221c53 net: conn_mgr: refactor event logic
In preparation for altering the conditions under which conn_mgr
fires NET_EVENT_L4_CONNECTED and NET_EVENT_L4_DISCONNECTED,
refactor the event logic without changing its behavior.

These changes do not alter the behavior of conn_mgr. They merely change
how that behavior is expressed so that it is easier to understand, and so
that upcoming changes are easier to implement.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
7afca97f9e net: conn_mgr: Add thread-safety
Current implementation does not prevent the net_mgmt thread from
preempting during state change handling and generating more
state changes. Add a mutex to protect internal state of conn_mgr

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
ad7e0d3712 net: conn_mgr: Rename flags
Rename internal flags for clarity

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
41d6a9bcec net: conn_mgr: relocate if_get_binding
Relocate conn_mgr_if_get_binding to conn_mgr_private.h so that it
can be used by test suites.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
716c19f7ef net: conn_mgr: Reorganize files
Since conn_mgr is a subsystem rather than a library, relocate it
directly into subsys/net rather than subsys/net/lib/

Rename header files to better match their function.

Remove net_ prefix from conn_mgr types, API, and files, since it is
unnecessary.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Vinayak Kariappa Chettimada
7eaf577772 Bluetooth: Controller: Fix Peripheral CIS supervision timeout
Fix premature Peripheral CIS supervision timeout due to
corrupted trx_performed_bitmask value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Vinayak Kariappa Chettimada
875349047e Bluetooth: Controller: Fix Peripheral CIS receive window size
Fix peripheral CIS receive window to consider that the
peripheral ACL could drift at the instant the CIS is being
established.

Hence add additional EVENT_TICKER_RES_MARGIN_US as receive
window length.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Vinayak Kariappa Chettimada
9338ecc5b8 Bluetooth: Controller: Fix Central CIS scheduling precision
Fix Central CIS offset scheduling to microsecond resolution
precision. CIS offset calculation was missing the ACL event
remainder value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 12:03:41 +02:00
Johann Fischer
71d9b0d5ff usb: device_next: add CDC ECM class implementation
Add CDC Ethernet Control Model class implementation for the
new experimental USB device support based on the existing
implementation subsys/usb/device/class/netusb/function_ecm.c.

The implementation forms virtual ethernet connection between
USB host and USB device and requires two corresponding MAC
addresses, one for the virtual interface on the device side,
and other for the host which is described by a string descriptor.
With upcoming changes it should also possible to use a real
ethernet controller as media access on the device side.

CDC ECM implementation supports multiple instances which are
specified using DT. The number of instances is limited by the
number of endpoints on the controller, two to three should usually
be possible.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-11 11:26:54 +02:00
Nithin Ramesh Myliattil
8d6b206064 subsys/bluetooth/host: Make rpa same for adv sets with same id
Add check to see if RPA is already generated for adv sets
with same id. If generated use the same address for all adv sets
with same id else create new RPA.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2023-05-11 08:31:24 +00:00
Emil Gydesen
563b66bc29 Bluetooth: BAP: Shell: Broadcast assistant compiler warning fixes
Fixes a few compiler warnings from the BAP Broadcast Assistant
shell modules.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-11 10:15:10 +02:00
Vinayak Kariappa Chettimada
a2a2b86665 Bluetooth: Controller: Fix uninitialized CIG num_bis member variable
Fix uninitialized CIG num_bis member variable on CIG Remove.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-11 10:05:55 +02:00
Emil Gydesen
117f6295d1 Bluetooth: BAP: Broadcast source validate subgroup count in create
Add proper validation check for the number of subgroups
attempted to be added to the broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-11 10:05:41 +02:00
Emil Gydesen
afd4161a84 Bluetooth: BAP: Broadcast start add missing NULL check for adv
Added missing NULL check for the advertising set pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 17:54:12 +02:00
Emil Gydesen
926219156b Bluetooth: Audio: Shell: Add preset copy functions
Add common preset copy functions for unicast streams and
broadcast sources.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 15:27:46 +02:00
Emil Gydesen
4d43101fa7 Bluetooth: Audio: Shell: Make broadcast source generic
Implement profile-agnostic broadcast source and broadcast
stream structs, similar to the unicast stream struct.

The purpose of these are to be able to use the same structs
for multiple profiles such as BAP, CAP and TMAP.

Since only the BAP shell implements broadcast support at this
moment, the changes are minimal, but makes it easier to implement
broadcast support for other profile shells.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 15:27:46 +02:00
Flavio Ceolin
942b99a322 usb: audio: kconfig: Fix experimental feature
select EXPERIMENTAL for experimental option.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-10 11:41:50 +02:00
Flavio Ceolin
9b1da61d6a lwm2m: kconfig: Fix experimental feature
select EXPERIMENTAL for experimental option.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-10 11:41:50 +02:00
Robert Lubos
ff0fd2d7a7 net: iface: Improve thread safety of net_if_ipv*_maddr_* functions
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Robert Lubos
45cb3f9813 net: if: Improve LL address access thread safety
As `net_if_get_link_addr()` returns a pointer to the link layer
structure, some extra protection is needed to prevent its contents from
being changed while accessed. Using the mutex lock associated with an
interface should do the trick.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Robert Lubos
838a94288e net: if: Rework interface locking
Instead of having a single global mutex, covering, in most cases
unrelated, access to all network interfaces, introduce a separate mutex
for each network interface.

Wherever interface function operates on an individual interface context
data, use local mutex protection instead. The global mutex remains only
to protect access to shared resources (IPv4/6 context pool, timer lists
etc.).

Finally, rework the timer expiry handlers, to prevent interface
functions from being called while the global lock is held (the global
mutex has to be held when iterating over the timer list, as lists are
not thread safe). The reason for this is to avoid possible deadlock
scenario. The global mutex is sometimes being locked, while inside
interface function (protected by a local mutex), so if it was allowed
the other way as well, a deadlock could occur.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00
Emil Gydesen
5ce5940ac5 Bluetooth: CSIP: Fix issue with ordered access without lock char
Fixed issue when performing the ordered access procedure on
a set of devices where none had the lock characteristics.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
41fd5b80df Bluetooth: CSIP: Add missing and fix Set Coordinator set info
The set info returned by the Set Coordinator did not contain
information about the lockable state. Furthermore the
set info was not properly initiated, as it was missing the
rank, which was set somewhere else.

This commit adds the lockable state to the set info.
This commit removes the rank from internal structure,
and uses a reference to the set info instead, and only
store the rank there.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
f3259daa8a Bluetooth: CSIP: Fix Set Member set size and rank param validation
The set size and rank validation did not allow setting e.g.
rank = 2 and set_size = 0, which should be allowed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
3f8daa6762 Bluetooth: CSIP: Add support for optional characteristics
Whenever a CSIS instance is registered with
bt_csip_set_member_register we now properly check if the
set size, rank and lock characteristics should be present.
If not, then remove them from the service declaration.

It is done this way, as it is easier (read: possible) to
remove characteristics from the service declarations,
than it is to add the optional characteristics, as the
optional characteristics may be present in some CSIS
instances, but not in others.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Emil Gydesen
8ae46910c8 Bluetooth: CSIP: Avoid multiple conn CBs registers
The bt_csip_set_member_register function would register
the connection, and connection auth info, callbacks for
each CSIS instance, which could give errors when/if the
callbacks are called too many times. In any case, they
should not be registered multiple times.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 10:14:56 +02:00
Georgij Cernysiov
464f6f6438 net: l2: ethernet: lldp: prevent slist corruption
LLDP start timer is executed when iface is up
at startup, then once more when iface up event
is received.

When iface is up before net_lldp_init call, then multiple
entries are added to the lldp_ifaces related to the
same iface.

That leads to continuous loop execution within
lldp_tx_timeout.

This commit checks if lldp tx_timer_start is set and
doesn't append new entry into the slist.
The tx_timer_start is set at startup and reset on
down event.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-05-10 16:54:44 +09:00
Emil Gydesen
8c2df1bfd5 Bluetooth: BAP: Add return error for sink cb register
Since the provided callback can be NULL which would
break things, add a check and a return value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 16:54:10 +09:00
Emil Gydesen
70b88378f9 Bluetooth: BAP: Limit broadcast sink streams to proper max value
The number of streams for a broadcast sink is maximum 31,
or the maixmum number of BIS we support.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-10 16:53:56 +09:00
Tom Burdick
ea8930bd78 rtio: Cleanup the various define macros
Reworks the zephyr macros and pools to be objects in their own right. Each
pool can be statically defined with a Z_ private macro. The objects can
then be initialized with an rtio instance statically.

This cleans up a lot of code that was otherwise doing little bits of
management around allocation/freeing and reduces the scope those functions
has to the data it needs.

This should enable sharing the pools of sqe, cqe, and mem blocks among rtio
instances in a future improvement easily.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Tom Burdick
e4b10328b4 rtio: Use mpsc for submission and completion queue
Rather than the rings, which weren't shared between userspace and kernel
space in Zephyr like they are in Linux with io_uring, use atomic mpsc
queues for submission and completion queues.

Most importantly this removes a potential head of line blocker in the
submission queue as the sqe would be held until a task is completed.

As additional bonuses this avoids some additional locks and restrictions
about what can be submitted and where. It also removes the need for
two executors as all chains/transactions are done concurrently.

Lastly this opens up the possibility for a common pool of sqe's to
allocate from potentially saving lots of memory.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Vinayak Kariappa Chettimada
92f0b5490c Bluetooth: Controller: Fix uninitialized ticks_slot in CIS create
Fix use of uninitialized ticks_slot value in calculation of
cis_offset_min when creating CIS. Calculate the ticks_slot
value earlier when committing the CIG parameters.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:31 +02:00
Vinayak Kariappa Chettimada
9c95dce9a4 Bluetooth: Controller: Fix incorrect use of rx buffer in Tx ISR
Do not enqueue node rx buffers for generating invalid ISO
data from Tx ISR while supplying the node rx buffer to
Radio. This causes node rx pool corruption and also MIC
failures in the central ISO LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
038c89b2c9 Bluetooth: Controller: Remove redundant CIS encryption code
Remove redundant unused CIS encryption related code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
0777583ca1 Bluetooth: Controller: Fix peripheral ISO data ack mechanism
Fix peripheral ISO data ack mechanism to correctly update
the SN when PDUs fail to be received.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
0b27981f94 Bluetooth: Controller: Do not disconnect all CIS on MIC failure
Fix implementation to not disconnect all CIS when one
connection has MIC failure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 17:25:14 +02:00
Vinayak Kariappa Chettimada
8a376a747e Bluetooth: Controller: Use strict cis_offset_min when CIG is active
When there is an active CIG for a new CIS create, then use
strict cis_offset_min/cis_offset_max so that the new CIS
is scheduled inside the active CIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 15:04:32 +02:00
Ajay Parida
7f9ba751e9 net: wifi_mgmt: Handle ps command error
Failure of setting ps param is handled with error string
at user/ app level.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
49e6b0c256 net: shell: Code cleanup for ps related commands
Setting ps_mode and ps_timeout related changes handled
in single power save op.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
bdef1bad78 net: wifi_mgmt: Configure ps wakeup mode
'ps_wakeup_mode' is used to set the wake up interval
to either 'dtim or 'listen_interval'. By default the
sta wakes up every dtim interval.
With 'ps_wakeup_mode' set to 'listen_interval' sta
will wake up for every listen interval period configured.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
68403669c6 net: wifi_mgmt: Configure listen interval
listen interval is the time periods the STAs may be in idle
without listening beacons.
By default STA wakes up for every DTIM period.
If listen interval based power save is used
STA uses configured listen interval period(default 10
beacon intervals) to wake up.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Dmitrii Golovanov
63fc307404 tests: ztress: Extend ZTRESS_EXECUTE() description
Add more details on the number of thread contexts possible
for ZTRESS_EXECUTE().

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-09 08:47:53 -04:00
Dmitrii Golovanov
130652efbd tests: ztest: ztress: Fix out-of-bounds at ztress_execute
Fix ztress_execute() out-of-bounds in case it is called with timer
and for maximum number of threads allowed (CONFIG_ZTRESS_MAX_THREADS).

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-09 08:47:53 -04:00
Mahesh Rao
d3010aae80 subsystem: sip_svc: Add SDM mailbox specific shell
Add shell based on sip_svc subsystem to access the SDM mailbox in
EL3 layer using ASYNC sip_svc request.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-05-09 08:46:50 -04:00
Mahesh Rao
dc9dc3d044 subsystem: sip_svc: Add ARM SiP SVC subsystem
Introduce a new SiP SVC subsystem to provide ARM Silicon Provider based
supervisory call services. SiP SVC service provides the capability to
send SMC/HVC call from kernel running at EL1 to hypervisor/
secure monitor firmware running at EL2/EL3 and also added SiP SVC shell
commands to exercise the service.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-05-09 08:46:50 -04:00
Jamie McCrae
aaed91ec4f mgmt: mcumgr: grp: img_mgmt: Only verify image if hash is valid
Prevents verifying the image has been uploaded successfully using
the hash provided at the start of the upload if the hash is not
the correct length of an SHA256 hash.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-09 14:29:05 +02:00
Herman Berget
688f5baded Bluetooth: Host: Fix warning from the logging subsystem
Cast `dhkey` to `void*` to avoid a warning from the logging subsystem:
```
<wrn> cbprintf_package: (unsigned) char * used for %p argument.
It's recommended to cast it to void * because it may cause misbehavior
in certain configurations
```

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-09 14:28:49 +02:00
Pavel Vasilyev
1fdf283531 Bluetooth: Mesh: Remove outdated RPL entries in settings work item
This allows to move flash operations from the context that triggered
IVI update to the mesh settings work item that runs on the system
workqueue. After this change, the outdated RPL entries will be removed
in the setting work item triggered by store_pending function in
mesh/settings.c. This is required to for a case where the mesh settings
work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-09 13:03:38 +02:00
Troels Nilsson
c743edaaa6 Bluetooth: Controller: Fix endianness handling for DID/SID struct
Bitsets across byte boundaries does not work properly for big-endian;
Converted to use two uint8's instead

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-05-09 13:03:28 +02:00
Vinayak Kariappa Chettimada
81c9795023 Bluetooth: Controller: Set Broadcast ISO related supported cmd bits
Set Broadcast ISO related HCI Read Supported Commands bits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-09 11:30:41 +02:00
Ajay Parida
bdec033889 net: shell: Display TWT response details
Show TWT response parameters details.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 09:24:30 +02:00
Krishna T
2b48c92742 net: wifi: Fix TWT interval
As we are using a generic validation function for limits, due to data
type mismatch the check for TWT interval overflow and fails.

Fix the data type and accordingly the maximum value in the help.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-09 16:24:10 +09:00
Aleksander Wasaznik
bb1ede6a9b Bluetooth: Use bt_addr_eq
Refactor. Using `bt_addr_eq` instead of `bt_addr_cmp`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-05-09 09:23:52 +02:00
Xudong Zheng
79c4c82baf logging: change log_output_timestamp_to_us() to take log_timestamp_t
If CONFIG_LOG_TIMESTAMP_64BIT is enabled, the timestamp will be 64-bit

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2023-05-08 16:57:02 -04:00
Emil Gydesen
68d1d7d1b4 Bluetooth: Audio: Shell: Add broadcast assistant add broadcast_id
Add command to add a source by the broadcast ID. This will
initiate scanning for the broadcast ID, making it unnecessary
for the user to keep track of both the broadcast ID, the SID
and the address, and just focus on the (properly) known
broadcast ID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
d97b0e1ea9 Bluetooth: Audio: Shell: fix missing opt arg for assistant scan_start
The command has an optional parameter that could not be used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
ed2d30e382 Bluetooth: Audio: Shell: cmd_bap_broadcast_assistant_broadcast_code use hex
The cmd_bap_broadcast_assistant_broadcast_code used decimal, instead
of hex, for the broadcast code, making it a lot harder to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
f24e9d9fcd Bluetooth: Audio: Shell: Print BIS Sync as hex
Since the value is a bitfield, printing it as hex makes it easier
to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
8a3aa4c289 Bluetooth: Audio: Shell: Remove name from bap_broadcast_assistant_scan_cb
The callback does not have the advertising data, so the name
would always just be empty.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
1ef2ce40d6 Bluetooth: Audio: Add PA sync broadcast shell commands
Add shell commands to add a PA sync as a broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a180c013db Bluetooth: Audio: Modify broadcast_id prints/logs to use 24-bit
Always print/log the 24-bits (as hex) of the broadcast ID to better
use it with e.g. the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
f2ce934209 Bluetooth: Audio: Add additional logging to broadcast assistant
Adds additional logging, as well as making the API param checks
more similar.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
043241d6fa Bluetooth: Audio: Broadcast Assistant: Fix subscribe issue
If starting the discovery procedure multiple times, the
subscribe function returns -EALREADY which needs to be handled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
fa70c86cd6 Bluetooth: Audio: Add common audio shell print commands to audio.h
Move common audio shell print functions into audio.h.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a431f5235b Bluetooth: Audio: Move the decode_base functionality to a public function
Moved the implementation of the pa_decode_base to a public
function, and modified it to return better error codes.

The implementation was moved to be publically
accessible, rather than internal in the Broadcast Sink,
as e.g. a Broadcast Assistant need to be able to decode the
BASE too. This wil also allow an application to decode it
itself, if it so wanted to.

This also adds a log module for the audio.c file, as logging
would otherwise not be supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
e23a5234a1 Bluetooth: Audio: Make broadcast assistant params const
Make the add and mod source parameters `const`, as well
as the broadcast code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
4e5a3b9e79 Bluetooth: Audio: Broadcast Assistant: Verify PAST support
Verify that PAST would be possible before providing
BT_BAP_BASS_PA_REQ_SYNC_PAST as the PA sync value to the
Scan Delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Emil Gydesen
a6bd893d55 Bluetooth: Audio: Make pa_sync boolean
Make the `pa_sync` field of the
bt_bap_broadcast_assistant_add_src_param and
bt_bap_broadcast_assistant_mod_src_param to boolean
instead of uint8_t, as it represents a boolean value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 13:27:33 +02:00
Herman Berget
1f43e126a8 Bluetooth: Host: Fix setting missing params in create connection v2.
The adv_handle and subevent were always set to 0.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-08 11:24:25 +02:00
Dmitrii Golovanov
4694b15605 net: pkt: Fix possible NULL dereference at net_pkt_cursor_operate()
Fix possible NULL dereference at net_pkt_cursor_operate() and
resolve 'Dereference after null check' warnings from the Coverity
static code analysis.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-05-08 17:40:41 +09:00
Fredrik Danebjer
da25ed53d0 Bluetooth: audio: Add paired_ep to endpoint info
Added paired_ep to bt_bap_ep_get_info, which would allow to check
whether an endpoint is paired with another endpoint, this would
indicate that its coupled to a bidirectional iso.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-05-08 10:25:07 +02:00
Piotr Jasiński
e010dcee5d net: update tfm dependency for psa
TFM is not the only provider for PSA API, which means
the PSA config shouldn't depend only on it.

Signed-off-by: Piotr Jasiński <piotr.jasinski@nordicsemi.no>
2023-05-08 10:23:18 +02:00
Emil Gydesen
4421b80dd1 Bluetooth: ASCS: Fix receiver_ready on state change
The receiver_ready field can only be set while in the enabling
state, and is a requirement to go into the streaming state.

If for any reason we go into a state that is not enabling
or streaming, then the receiver_ready field should be
cleared, as the circumstances are changed.

This also fixes an issue where if the CIS disconnects,
then we go from the streaming state to the
qos configured state, without clearing it, causing
incorrect behavior if we attempt to connect the streams
again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-08 09:59:44 +02:00
Marek Pieta
8df81737e0 mcumgr: img_mgmt: Let image version comparison use build number
Change allows using build number in image version comparison.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-05-08 09:59:19 +02:00
Marek Pieta
ce18ed05d1 mcumgr: img_mgmt: Fix check for upgrade-only
Change fixes check for upgrade-only to ensure that the the new image
version is greater than version of the currently running image.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-05-08 09:59:12 +02:00
Pavel Vasilyev
177e9b93bf Bluetooth: Mesh: Add API to store model's user data in settings work
Mesh models may have a data that needs to be stored persistently.
Currently, the models should call bt_mesh_model_data_store and the store
will happen in the calling context. Most likely that it will be called
in BT RX thread as this is the context from which model's opcodes
handlers are called. Thus, the thread will be blocked until the store is
finished.

Another issues is that some models may have states that changes
frequently. Triggering the store on every state change may wear out
flash. Therefore, the models need to implement some postpone mechanism
to reduce the flash wear out.

The mesh stack has already implemented the mechanism of deferred store
with its own settings. The models could use it instead of implementing
their own mechanism.

In combination with the mesh settings workqueue, the models can store
their data without blocking the stack work.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-08 09:58:21 +02:00
Pavel Vasilyev
e33a4ace0f Bluetooth: Mesh: Use separate workq for storing mesh settings
Currently mesh settings are stored in the system workqueue context.
Most of other stack functionality, such that advertisements (incl
relay), loopback, transport sar, beacons transmission, etc. is also
processed in the system workqueue context. When a massive amount of
data needs to be stored and in particularly when page erase needs to
be triggered by GC of NVS subsystem to allocate flash pages, the
execution of the stack (and other functionality that uses the system
workqueue) will be blocked until storing is finished. For example,
right after the provisioning of a erased device, a node may not be
responsive for up to 400ms before it can continue sending messages.
The waiting time may increase if there is a GATT connection in the
mean time.

When write or erase operation is triggered, the flash driver waits for
Bluetooth controller to allocate a time needed to perform the operation.
During the whole operation, the context from which the operation was
triggered is put to sleep. This allows other threads to run until
Bluetooth controller finds the time for the flash driver. In other words,
every settings_save_one or settings_delete should be considered as
rescheduling points.

Considering this, Bluetooth mesh can use another thread to store its
settings, thus releasing the system workqueue for other tasks including
the operation of the stack itself.

The consistency of the data to be stored is guaranteed by the current
implementation where the data is copied to another struct before calling
settings_save_one. The pending flag of a particular module is dropped in
settings.c before starting to store the corresponding data. Thus, if
during the sleep the node receives a message that triggers a change in a
module which data is currently being stored, the pending flag will be
restored and the new change will be stored eventually.

Having this option enabled including with the partial erase, will make
the node more responsive in the described situations.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-05-08 09:58:21 +02:00
Emil Gydesen
8d24d506b3 Bluetooth: Audio: Shell: Move audio defines to audio.h
The generic BT shell header, bt.h, contained quite a few things
related to audio, which should be put in the audio.h shell header
file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-05 16:17:59 +02:00
Vinayak Kariappa Chettimada
c01cd1c482 Bluetooth: Controller: Review rework changes for multiple CIS support
Assorted review rework changes for multiple CIS support
implementation commits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
94821ef04c Bluetooth: Controller: Preliminary multiple peripheral CIS support
Updated nRF5 Series LLL implementation to support multiple
peripheral CIS establishment from peer central devices.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
3306f3160f Bluetooth: Controller: Central multiple CIS using advanced scheduling
Central multiple CIS create implementation using advanced
scheduling to find the active CIG events and calculate the
CIS offset to be used in the LL_CIS_REQ PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
2007967553 Bluetooth: Controller: Use Conn ISO prepare latency to check timeout
Use accumulated connected ISO LLL prepare callback latencies
to check supervision timeout.

Also use the accumulated connected ISO LLL prepare callback
latencies to adjust SN and NESN values.

Connection establishment can cause short prepare callbacks
inserted before Connected ISO group prepare callbacks, that
cause the Connected ISO group prepare callbacks being
cancelled while being in prepare pipeline. Hence, it is
necessary to accumulate prepare callback latencies wherein
ticker callbacks are executed but prepare callbacks are
cancelled in the prepare pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
ef8b05e83a Bluetooth: Controller: Preliminary Central multiple CIS support
Implementation of preliminary Central with multiple CIS
create support in Lower Link Layer. Uses a simple CIS
offset calculation that works when ACL are created with
connection interval that is multiple of CIG ISO interval.
Each ACLs are offset using BT_CTLR_CENTRAL_SPACING hence
having the same CIG sync delay values for all the ACLs.
Advanced Scheduling to setup CIS in any order of ACL and
CIS combination, ACL placed anywhere in timeline and CIS
creation will come therein will be implemented in later
Pull Requests.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
5152672d06 Bluetooth: Controller: Include remainder when calculating cis_offset
Include ticker expire remainder value when calculating the
cis_offset to acheive fine timing in scheduling the CIG
radio events relative to its associated ACL radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
e09c2ddf7a Bluetooth: Controller: Use ticker_start_us for Central and ISO setup
Use the ticker_start_us() interface for Central and Central
ISO setup to acheive fine timing for the first expire
timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
4e65cae32a Bluetooth: Controller: Ticker first expire with remainder
To acheive microsecond or fine timing for first expire
timeout, pass remainder value of the coarse tick to a new
ticker_start_us() interface. The new interface is available
with BT_TICKER_EXT feature enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
285649c894 Bluetooth: Controller: Fix implementation of CIS Null PDU Indicator use
Fix implementation of CIS Null PDU Indicator use to meet the
BT Specification statement, that, if the source of the data
fails to provide a payload in time for a CIS subevent, then
the link layer shall transmit a CIS Null PDU instead.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9ccf70fd27 Bluetooth: Controller: Extended Advertising using ticker expire info
This is re-introduction of Extended, Periodic Advertising
and Broadcast ISO using ticker expire info feature to get
the aux, sync and BIG offsets.

Relates to commit 714d74b77b ("Bluetooth: controller: Use
new ticker feature to get offsets").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
6a1a93e587 Revert "Bluetooth: controller: Use new ticker feature to get offsets"
This reverts commit 714d74b77b.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9cada37d9b Bluetooth: Controller: Add BT_TICKER_EXT_EXPIRE_INFO Kconfig
Add BT_TICKER_EXT_EXPIRE_INFO Kconfig.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
52615afcf1 Bluetooth: Controller: Remainder and Lazy depends on match get
Ticker remainder and lazy get depends on match get interface
provided by BT_TICKER_NEXT_SLOT_GET_MATCH.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
e912a6589a Bluetooth: Controller: Remove redundant Kconfig range and default
Remove redundant range and default for BT_CTLR_ADV_AUX_SET
when supporting BT_CTLR_ADV_PERIODIC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
08c1b1749a Bluetooth: Controller: Fix BT_TICKER_NEXT_SLOT_GET select
Fix BT_TICKER_NEXT_SLOT_GET select, to depend on
BT_CTLR_SCHED_ADVANCED.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
9600c94c4b Bluetooth: Controller: Fix BT_TICKER_EXT BT_TICKER_LOW_LAT dependency
BT_TICKER_EXT is not supported with BT_TICKER_LOW_LAT.
Remove redundant select of BT_TICKER_EXT for
BT_CTLR_ADV_EXT.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Vinayak Kariappa Chettimada
3fb90bb601 Bluetooth: Controller: Group depends on together in Kconfig file
Group depends on clauses together in the Kconfig.ll_sw_split
file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-05-05 12:26:31 +02:00
Emil Gydesen
2a2f067333 Bluetooth: HAS: Add missing memset of read params
The missing memset caused invalid chan_opt when EATT was
enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-05 11:26:11 +02:00
Maurits Fassaert
42507c69c2 storage: flash_map list partition labels
Add the labels from the device tree fixed flash partitions
as a column to the flash_map list shell command.

Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
2023-05-05 10:02:19 +02:00
Herman Berget
a947af8ac3 Bluetooth: Host: Fix PHY translation from HCI
HCI events use different values for the PHYs than the GAP macros.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-04 20:50:58 +02:00
Erik Brockhoff
44df982d0b Bluetooth: controller: disallow enc start/pause when CIS established
Start/pause encryption should not be initiated on ACL with CIS
established (BT Core Spec 5.4, Vol 6, Part B, Sect. 5.1.3)
Adding test for the added procedure peek function

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-05-04 10:47:37 +02:00
Kumar Gala
b07be57875 logging: Use TYPE_SECTION macros for log dynamic
Clean up log_dynamic to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Kumar Gala
bae0a5b8b6 logging: Use TYPE_SECTION macros for log const
Clean up log_const to utilize macros for handling sections.

Update database_gen.py to match naming convention change.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Jonathan Rico
7d1a5f5554 Bluetooth: iso: use BT_ISO_SDU_BUF_SIZE()
Use BT_ISO_SDU_BUF_SIZE() instead of calculating manually.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
Jonathan Rico
fb10381328 Bluetooth: iso: use kconfig for userdata size
Use BT_CONN_TX_USER_DATA_SIZE when defining pools of buffers that will go
through `bt_conn_send_cb()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
Jonathan Rico
e460847b60 Bluetooth: host: don't fragment ISO if len <= MTU
MTU doesn't count against the ISO and ISO data headers.

Then a config with CONFIG_BT_ISO_TX_MTU ==
CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE should not fragment SDUs over HCI.

Also set the TS_Flag bit if a timestamp is present.

Fixes #56749

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-05-03 10:02:44 +02:00
romain pelletant
75dd2c9904 net: lwm2m: use path as block context retrieval
Replace block context retrieval using object path instead of token.
Update block context structure
Fix issue #57165

Signed-off-by: romain pelletant <romain.pelletant@fullfreqs.com>
2023-05-03 10:01:37 +02:00
Herman Berget
bf4e3fe2a4 Bluetooth: Host: Fix sync subevent cmd length
The subevents were not considered in the length of the command.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-05-02 16:56:01 +02:00
Nikolay Agishev
0d8292ab6b ARC: Add HS4x support
Minimal HSDK4xD support

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-05-02 16:54:24 +02:00
Hunter Searle
898a59eb80 Shell: Edit shell to store/retrieve return values
This change to the shell API enables the user to retrieve the
return code of the most recently run shell command. This is
useful both for users wanting specific information beyond the print
statements in a command, but especially for automated users
that prefer a simple return code to parsing human readable text.
This was tested using all default shell commands, as well as
eeprom, flash, and i2c, where specific errors could be forced.
In all cases, the correct return value was returned by the new
retval command.

Signed-off-by: Hunter Searle <hsearle@xes-inc.com>
2023-05-02 16:52:21 +02:00
Emil Gydesen
66f8ab5a28 Bluetooth: BAP: Add specific error code for stopping stopped sink
If the broadcast sink is already stopped (i.e. the streams have
all been disconnected), then we can return a more useful
error code than EINVAL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-02 09:35:11 -05:00
Jordan Yates
8e603d091c Bluetooth: controller: Kconfig TX power dBm
Adds a Kconfig symbol which contains the default controller TX power
directly in dBm. This allows code to directly display/use the configured
power, instead of having to manually iterate over all the
`BT_CTLR_TX_PWR` options.

```
  LOG_INF("BT controller configured for %ddBm TX power",
          CONFIG_BT_CTLR_TX_PWR_DBM);
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-05-02 10:12:23 +02:00
Yuval Peress
3fd0a1508b rtio: fix bug in mempool release API
It was previously assumed that the 'sys_mem_blocks' struct would maintain
information about contiguous blocks allocated so the release API only
took the starting address. This led to an issue where allocating 2+
blocks would end up with a memory leak because any block not being the
first would never be released.

Add the buffer length as an argument so the correct number of blocks can
be released. Also, ammend the tests to match and verify.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-01 09:26:06 -05:00
Paul He
322f5ad4ef storage: flash_map: shell: fix error 'sh' undeclared
Some of `shell` were missed to be updated with `sh`.

Signed-off-by: Paul He <pawpawhe@gmail.com>
2023-04-30 12:48:55 -05:00
Robert Lubos
d15f8e6337 net: shell: Print new flags with the net iface command
Print new NET_IF_IPV6_NO_ND and NET_IF_IPV6_NO_MLD flags when
the "net iface" command is used.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
ee1271f23c net: openthread: Disable ND/MLD for OpenThread interfaces
OpenThread networks do not use ND or MLD as they have their own set of
protocols to cover this functionality. So far, the use of OpenThread
with Zephyr relied on disabling those protocols support statically with
Kconfig, which prevented OT interfaces from being used along with other
IPv6 interfaces.

With the new network interface flags, it's now possible to disable ND
and MLD on individual interfaces, therefore disable them for OT
specifically.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
c349d53150 net: if: Add possibility to disable MLD per interface
Add new network interface flag, which allows to disable Multicast
Listener Discovery protocol from being used on the interface. This
allows to interfaces that do not support ND (like OpenThread) to
coexist with other IPv6 interfaces.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Robert Lubos
c43c408783 net: if: Add possibility to disable ND per interface
Add new network interface flag, which allows to disable Neighbour
Discovery protocol from being used on the interface. This allows to
interfaces that do not support ND (like OpenThread) to coexist with
other IPv6 interfaces.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-29 12:24:49 +02:00
Pavel Vasilyev
1113c2efd4 Bluetooth: Mesh: Store device key candidate asynchronously
This allows to move flash operations from the context that triggered
storing device key candidate to the mesh settings work item that runs
on the system workqueue. This is required to for a case where the mesh
settings work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-29 12:24:28 +02:00
Pavel Vasilyev
f3085ab95d Bluetooth: Mesh: Move storing of new prov data to settings work item
This allows to move flash operations from the context that triggered
bt_mesh_provision or bt_mesh_reprovision to the mesh settings work item
that runs on the system workqueue. This is required to for a case where
the mesh settings work item is running on a separate thread instead of
the system workqueue to unblock the system workqueue eventually.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-29 12:24:28 +02:00
Emil Obalski
169d8fafdc ipc: icmsg: Add mutual exclussion access to shmem
If the icmsg backend is sending the data from many
contexts, the send buffer must be accessed only by one
context at a time. Ensure that by adding mutex when
sending.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Emil Obalski
52e203f800 ipc: Remove internal API for clearing shared memory
Clearing of shared memory by one side of the communication
is no longer required after
commit 0620cb1fe1
("ipc: ipc_service: icmsg: Increase reliability of bonding")
was merged.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Stine Åkredalen
80158c1428 doc: Bluetooth: Mesh: update proxy solicitation docs
Updated related docs. Small fix in mesh/Kconfig and shell.rst.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-04-28 20:37:45 +02:00
Krishna T
30efd04060 net: Make net_mgmt queue timeout configurable
This helps us work with low queue depth of network management queue in
case the we have high rate events.

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

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-04-28 10:35:27 -05:00
Aleksander Wasaznik
67d6011851 Bluetooth: hci_raw: Fix a LOG_ERR message
The LOG_ERR was printing the wrong variable. `type` always has the value
`BT_BUF_H4` here, so there is no point in printing it.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-28 10:33:18 -05:00
Aaron Massey
07ee466591 emul: Migrate all emulation use to use DT_HAS_
Remove all enabling of CONFIG_EMUL_.* in favor of automatically enabling
peripheral emulators based on the compatible string presence in the device
tree and the one true CONFIG_EMUL.

Zephyr has long since moved to a model of enabling drivers based on the
presence of their associated IC's compatible string in the final devicetree
overlay. There is no reason that emulators can't align in just the same
way, and probably ought to to remove superfluous enabling of configs.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-04-28 08:37:33 -05:00
Herman Berget
5893606187 Bluetooth: Host: Use a valid disconnect reason
"Unspecified Error" is not a disconnect reason allowed by spec.

Fixes #56989

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 14:50:11 +02:00
Mariusz Skamra
292bf966be Bluetooth: audio: ascs: Make use of bt_bap_stream_reset
This deduplicates a code a bit by reusing existing bt_bap_stream_reset
function to unbind and detach the stream object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-28 14:49:25 +02:00
Mariusz Skamra
197e20e3c2 Bluetooth: audio: ascs: Remove redundant sessions pool
This removes redundant bt_ascs structure pool that held the list of
ases per connection. The memory usage can be reduced by moving the conn
reference to bt_ascs_ase structure. This change reduces flash and RAM
memory usage.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-28 14:49:16 +02:00
Herman Berget
d7218fe359 Bluetooth: Host: Add support for receiving connections while synced
The PAwR sync can receive a connection request from the PAwR
advertiser and become peripheral.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 11:00:48 +02:00
Herman Berget
c961e2c212 Bluetooth: Host: Add support for initiating connections from PAwR
This is known as the Periodic Advertising Connection Procedure.

The PAwR advertiser can initiate a connection to a synced device and
become the central.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-28 11:00:48 +02:00
Morten Priess
5b6198403c Bluetooth: controller: Fixes for CIG with two CISes and separate ACLs
Prevent referencing inactive CISes by clearing state variables
after teardown. This was seen as necessary when having CISes on
different ACLs, and disconnecting ACLs in random order.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-04-28 10:07:46 +02:00
Sam Hurst
0056249a13 usb-c: Add USB-C Subsystem Source PD Support
Add USB-C Power Delivery Source Support to USB-C
Subsystem

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
cb9a250579 usb-c: Refactor soft reset code
Refactor soft reset code

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
3851d3648d usb-c: Properly detect reception of first AMS message
Detect and flag the reception of the first AMS mesage

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Sam Hurst
d1cf8148cc usb_c: Transmit Error are not Protocol Errors
Transmit errors must be treated differently than Protocol Errors.
This change sets a flag that informs the stack of a Message
Transmit error.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Emil Gydesen
5076476cf5 Bluetooth: BAP: Fix missing remove of streams from slist
In the broadcast sink when the streams disconnected (without
the PA disconnecting), the streams were not properly
removed from the sink's list of streams. This allowed
the same stream to be added to the list twice, which
would cause a infinite loop as the stream would
point to itself as the next.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-27 20:19:58 +09:00
Jacob Siverskog
6cefad338b Bluetooth: BAP: Shell: Fix NULL pointer dereference
Make sure 'state' is valid.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2023-04-27 20:18:55 +09:00
Ajay Parida
a004a85ccf net: shell: Check connection & capabilities in any TWT operation
Connection status & AP capabilities checked before any TWT operation
is initiated.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-27 09:52:00 +02:00
Herman Berget
e745439c40 Bluetooth: Host: Fix periodic sync reassembly
The reassembly buffer for periodic sync was not initialized
if the sync was established via PAST.

Move the initialization of the reassembly buffer to a common place.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Herman Berget
95bc5cf8e5 Bluetooth: Host: Add support for PAwR Sync
Adds API for Periodic Advertising with Responses - Scanner:
 - Synchronize to a PAwR train
 - Choose which subevents to synchronize to
 - Receive advertising reports from subevents
 - Send responses

The support is enabled by CONFIG_BT_PER_ADV_SYNC_RSP, and requires
a controller that selects CONFIG_BT_CTLR_SYNC_PERIODIC_RSP_SUPPORT.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Herman Berget
9021e2f438 Bluetooth: Host: Add support for PAwR Advertiser
Adds API for Periodic Advertising with Responses - Advertiser:
 - Configure parameters
 - Receive subevent data requests
 - Set subevent data
 - Receive response reports

The support is enabled by CONFIG_BT_PER_ADV_RSP, and requires
a controller that selects CONFIG_BT_CTLR_ADV_PERIODIC_RSP_SUPPORT.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-04-26 20:08:16 +02:00
Dmitrii Golovanov
560b777fa8 net: dhcpv4: Fix NULL dereference at dhcpv4_create_message()
Fix dhcpv4_create_message() dereferenced NULL return value from
net_pkt_alloc_with_buffer() in case of no memory available.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-26 20:07:04 +02:00
Dominik Ermel
00f1639e38 mgmt/mcumgr: Fix image erase returning MGMT_ERR_EMSGSIZE
In case when CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR=n then
the image erase command would incorrectly return MGMT_ERR_EMSGSIZE,
even though no such error occurred.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-26 18:15:40 +02:00
Dmitrii Golovanov
f7331e0d66 net: ipv4: Fix fragmented packet NULL dereference possible
Fix net_ipv4_send_fragmented_pkt() dereference of NULL return value
from net_pkt_get_data() possible with non contiguous packet data.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-26 14:34:23 +02:00
Jonathan Rico
ece481d560 Bluetooth: host: att: clear ATT_PENDING_SENT
The ATT_PENDING_SENT flag was still not being cleared in all cases.

Also reset `data->att_chan` when not able to send on a given channel.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Jonathan Rico
2809bace65 Bluetooth: host: l2cap: send only 1 credit
The API doesn't allow the stack to make any guarantees about the number of
available buffers that the app has.

Only send 1 credit at a time, as that is the only guarantee the stack can
give to the peer.

We can send MTU/MPS's worth of credits once we have acquired an SDU buffer
from the application (that is, on the first PDU of the SDU). Though we
still have to cap that to the buffer size we have just acquired.

------

The testcase added here shows a scenario where the relationship
between the number of credits and the number of available buffers does not
hold true any more:

In this test, the app only has one buffer in its pool.

The central will queue SDUs that are bigger than the stack's
buffers (so the user allocator is necessary) but lower than the
channel's MTU.

The device receiving the SDU keeps a reference to the buffer before
returning from the `recv` callback. It releases that reference after a
small delay.

The central will still have credits, so it will queue another SDU, but the
peripheral will not be able to receive the next SDU (as the allocator will
fail) and will close the channel.

To see the test fail, just revert the `l2cap.{c,h}` changes.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Jonathan Rico
6cdb82cb59 Bluetooth: host: l2cap: trigger SDUs that get lost in limbo
Turns out the [first bugfix] was too naive: there is a case where resuming
all channels will not work on all queued SDUs, and the work handler will
give up and wait for the next sent SDU instead of trying to resume again.

This happens when the number of credits and conn contexts is very low for
the amount of data to send.

Always reschedule with a delay to avoid that situation.

[first bugfix]: https://github.com/zephyrproject-rtos/zephyr/pull/50476

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-04-26 13:53:08 +02:00
Anas Nashif
6388f5f106 xtensa: use sys_cache API instead of custom interfaces
Use sys_cache instead of custom and internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-26 07:31:22 -04:00
Ryan McClelland
b19c8fc3bc net: ip: net_shell: fix double-promotions warnings
Double promotion warnings are generated with the flag -Wdouble-promotion

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-04-26 12:58:36 +02:00
Kumar Gala
0090ad718a net: Fix build issues with arm-clang
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:

	Error: L6218E: Undefined symbol
	net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
	(referred from ethernet.o).

Fix by adding ifdef protection around promisc code.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-25 19:59:06 +02:00
Ajay Parida
5c023fbbb9 net: wifi_shell: Updated TWT flow id range
TWT flow id is of 3 bit value(maximum mnumber of flows
supported is 8). Flow id range limited to 0 to 7.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-25 12:21:35 +02:00
Mariusz Skamra
d384ef4e57 Bluetooth: audio: ascs: Fix handling arrayed parameters
This fixes loop over arrayed metadata/cc parameters. The paramaters have to
be pulled from the buffer, because in case the ASE_ID is invalid or in
invalid state, the next loop iteration would read invalid data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-25 12:21:23 +02:00
Emil Gydesen
303bcfdcb7 Bluetooth: Shell: Add testcases for AUDIO_RX and TX disabled
Add configurations where CONFIG_BT_AUDIO_TX and CONFIG_BT_AUDIO_RX
are disabled.

Fixes issues found in the BT shell implemented caused by these
configurations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Emil Gydesen
2c5a249fdd Bluetooth: BAP: Add guard before accessing qos->latency
The qos->latency is not available for broadcast sink-only
builds.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Emil Gydesen
32e8392400 Bluetooth: BAP: Move TX guard to not cover verify funcs
Move the BT_AUDIO_TX guard so that it does not cover the
verification functions for valid_codec and qos, as they
are also relevant for receivers to verify what remote
devices send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-25 12:20:38 +02:00
Dmitrii Golovanov
6ec39dca6b net: ZWP timeout explicit type on bit shift calculation
Fix tcp_send_zwp() retransmission timeout calculation to avoid sign
extension on bit shift operation: the uint16_t value was implicitly
promoted to 32-bit signed type with sign extension to uint64_t.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-25 12:19:45 +02:00
Pawel Osypiuk
4b7f156403 IPC: rpmsg: Changed method of checking bounded endpoints
Initially that was checked by presence of name and now is changed
to check the flag.

Signed-off-by: Pawel Osypiuk <pawelosyp@gmail.com>
2023-04-24 15:45:09 +02:00
Hein Wessels
2689e16670 net: sntp: support building without NET_SOCKETS_POSIX_NAMES
Fixes the compiler error that occurs when attempting to build
the SNTP library with CONFIG_NET_SOCKETS_POSIX_NAMES=n, while
using native_posix.

Closes #57133

Co-authored-by: Chris Friedt <cfriedt@meta.com>
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-04-24 09:23:17 -04:00
Krzysztof Kopyściński
0a55ec8d52 Bluetooth: Mesh: Add callback for received beacons
This adds callbacks for Secure and Private Network Beacons.
SNB callbacks are called after `secure_beacon_authenticate` ends
with success, and Private Beacon callback after Private Beacon
payload is decrypted succsessfully.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-24 13:36:12 +02:00
Mariusz Skamra
81532bf5f0 Bluetooth: audio: ascs: Remove ascs_cp_rsp_add function redundant param
This removes opcode from ascs_cp_rsp_add function parameters and moves
response buffer initialization to be done in Control Point write
function context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-24 13:34:59 +02:00
Mariusz Skamra
9ec93b5bd5 Bluetooth: audio: ascs: Fix using magic numbers
Use defined values instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-24 13:34:59 +02:00
Sihyun Noh
3788ce3b8b fs: change fatFS initialization to match littleFS.
Mounting the disk in a global function can lead to an issue
where fatFS cannot be mounted due to it not being registered beforehand.
To solve this problem, fatFS is now initialized in POST_KERNEL,
just like the littleFS initialization function.
fatfs_init must be called before attempting to mounte the disk.

Signed-off-by: Sihyun Noh <awake_noh@naver.com>
2023-04-24 13:34:12 +02:00
Pavel Vasilyev
c4fa085ec4 Bluetooth: Mesh: Add async API for Large Comp Data Client
Add asynchronous API for Large Composition Data Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Pavel Vasilyev
b99d4dbce2 Bluetooth: Mesh: Use bt_mesh_msg_ackd_send API in LCD Client
Use bt_mesh_msg_ackd_send API in LCD Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Pavel Vasilyev
60e874472c Bluetooth: Mesh: Use BT_MESH_MSG_CTX_INIT_DEV macro in LCD Client
Use BT_MESH_MSG_CTX_INIT_DEV macro in LCD Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-24 13:31:27 +02:00
Aleksander Wasaznik
2091144c51 Host: ATT: Use bt_att_is_enhanced everywhere
Refactoring. All occurences of `atomic_test_bit((.*)->flags,
ATT_ENHANCED)` are replaced with `bt_att_is_enhanced($1)`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
af5103bdc3 Bluetooth: ATT: Set correct MTU for EATT L2CAP channel
The EATT MTU in Zephyr is static. We know it at channel creation time,
so we should communicate the MTU as part of channel creation.

Side note: With this approach, it should no longer be neccessary or
useful to do a channel reconfigure.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
3de6f7c99d Bluetooth: ATT: Move setting of initial MTU to att_chan_new
The L2CAP MTU can and should be set already during the channel setup.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
a2dc61a465 Bluetooth: ATT: MTU min instead of cap
The previous approach with `cap_eatt` was flawed. It would overwrite
`le_chan->tx.mtu`, losing its true value. (It is supposed to be the
L2CAP MTU as reported by the remote side.)

The previous approach worked out for UATT because the locally triggered
exchange always carries the remote MTU in the response, so we did not
need to keep track of the remote MTU.

But, unlike the UATT MTU exchange, the L2CAP reconfigure only exchanges
the MTU in one direction. If the remote does the first reconfigure, we
would correctly cap the ATT MTU to our local MTU. But, we would
incorrectly store this as the remote's MTU. When we then increase our
local MTU using `bt_eatt_reconfigure`, we correctly set and send our
MTU.  But we have an incorrect notion that the remote MTU is the value
that we ourselves limited. And mistake would incorrectly limit the
negotiated ATT MTU locally.

The simplest solution is to not mess with `le_chan->tx.mtu` and just
calculate the ATT MTU like Spec intended.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
fa9d41f39b Bluetooth: Host: Add helper bt_att_is_enhanced
This is a refactor. Hopefully, it makes the code easier to maintain.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
d4d0956516 Bluetooth: ATT: Split BT_ATT_MTU for UATT/EATT
This is a refactor. There is no behavioral change because
`BT_LOCAL_ATT_MTU_UATT` is `BT_LOCAL_ATT_MTU_EATT + 2` is
`BT_ATT_BUF_SIZE` is the old `BT_ATT_MTU`.

The old `BT_ATT_MTU` was wrong for EATT bearers. EATT MTU is two bytes
less because of ECRED overhead.

Instead of the old `BT_ATT_MTU`, we define one for each bearer type. We
also define the max of them to use as a convenience for allocating
buffers that fit either.

To avoid confusion, 'LOCAL' has been added to the name. This is to
differentiate it from what the spec calls 'ATT MTU', which is a
negotiated property. (It is the minimum of the two side's local ATT
MTU.)

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
46646452fe Bluetooth: L2CAP: Add missing req_mtu assert in l2cap_ecred_conn_req
There is an assert that `req_psm` is the same for all channels in the
same connection request because HCI requires this. The same is true for
`req_mtu`. This adds the obviously missing assert.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Aleksander Wasaznik
3148389695 Bluetooth: ATT: Introduce bt_att_mtu
This is a refactoring, only visible inside `att.c`.

Give the expression `chan->chan.tx.mtu` the name `bt_att_mtu`. Use it
when the intention is to get the ATT MTU property of a channel.

This is done in preparation a more complex expression for `bt_att_mtu`,
since the expression currently incorrect. The fix will come in a later
commit in the same PR.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-04-24 13:31:18 +02:00
Dominik Ermel
783f8666fc mgmt/mcumgr: Add zcbor_map_decode_bulk_reset utility function
The function should be used to reset map decoding state
between calls to zcbor_map_decode_bulk, while using the same map
for different buffers.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:49 +02:00
Dominik Ermel
4878eebebb mgmt/mcumgr: Add missing initialization of internal state
There was missing initialization for found member of
zcbor_map_decode_key_val structure.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:49 +02:00
Dominik Ermel
a48e6b926c mgmt/mcumgr: Fix failure to confirm active image not reported
Due to broken logic in img_mgmt_state_confirm failure to confirm
was not reported to caller.
If hooks were enabled confirmation event would be passed regardless
whether it has been successful.

Fixes #56617

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-24 13:28:09 +02:00
Jamie McCrae
4cdfa7bdd5 retention: Add optional mutex disablement
Adds an optional Kconfig to disable use of mutexes in the
retention subsystem.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
5e8b067364 dfu: mcuboot_shell: Add command to enter serial recovery
Adds a command which can be used to enter mcuboot's serial recovery
mode when the retention subsystem is enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
7e11b6392b retention: Add boot mode system
Adds a boot mode system which allows for redirecting the boot
target of a device depending upon the state of a retained value.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
64f4404481 retention: Add retention system
Adds a retention system which builds on top of retained_mem
drivers to allow partitioning of areas and data integrity with
magic header prefixes and checksum of stored data.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Jamie McCrae
c8a0e8c598 mgmt: mcumgr: grp: img_mgmt: Remove dummy header
The dummy header was an opt-in feature to allow testing without a
real image but since we support testing on Qemu in CI which
supports flash partitions, there isn't a need for this option. Not
being deprecated as Kconfig would only have been used as part of
CI, not user applications.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-21 16:33:30 +02:00
Dawid Niedzwiecki
7f7e48e66e mgmt: ec_host_cmd: create chosen string per backend
Create strings to set the chosen node per backend. It is done for
better clarity.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-21 16:29:59 +02:00
Dawid Niedzwiecki
1d62002bba mgmt: ec_host_cmd: update configs naming
Just use better namings for the buffer sizes configs.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-21 16:29:59 +02:00
Emil Gydesen
5ab585d1af Bluetooth: ASCS: Log missing fields of qos_pref
Added logging of the pref_pd_min and pref_pd_max field.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 16:29:08 +02:00
Dominik Ermel
d4ab079cd9 mgmt/mcumgr: Add zcbor_map_decode_bulk_key_found utility function
Function allows to check whether given key has been found
during map decoding with zcbor_map_decode_bulk.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-21 16:28:34 +02:00
Emil Gydesen
4b8574d7b1 Bluetooth: BAP: Shell: Fix bad arg to CAP acceptor ad data
The data array was using the wrong index.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 16:23:27 +02:00
Mariusz Skamra
f35959a261 Bluetooth: ascs: Fix ASE Control Point PDU length validation
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.

ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
length operation if the total length of all parameters written by the
client is not equal to the total length of all fixed parameters plus
the length of any variable length parameters for that operation"

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 13:01:42 +02:00
Mariusz Skamra
3b57b2014c Bluetooth: audio: ascs: Fix invalid Response_Code in notification
This fixes sending proper Response_Code in ASE Control Point
notification in case the client initiates Receiver Start/Stop Ready
operation on Sink ASE.
The response that shall be sent according to the specification is
"Invalid ASE direction", while the implementation sent "Invalid ASE state"
instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 12:55:46 +02:00
Johann Fischer
75ab9f81e3 usb: device: fix control endpoint handling with MPS of 8 bytes
The possible control endpoint MPS for USB 2.0 FS devices is
8, 16, 32, or 64 bytes. Typically, USB2.0 compliant devices support MPS
up to 64 bytes, and we have not had the need to support other MPS.

This patch implements a mechanism to fall back to the minimum allowed
MPS when a controller is likely a USB 1.1 compliant device and does
not support control endpoint MPS of 64 bytes.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-21 12:45:57 +02:00
Emil Gydesen
8e7757275e Bluetooth: BAP: Guard bt_bap_stream_send with CONFIG_BT_AUDIO_TX
Modify the guard of bt_bap_stream_send to use the
CONFIG_BT_AUDIO_TX.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 09:40:39 +02:00
Emil Gydesen
3d877338e6 Bluetooth: BAP: Fix missing guards of sent and recv in uni cli
The unicast client did not properly guard the sent and recv
callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-21 09:40:39 +02:00
Theo Gasteiger
ce2ac63953 Bluetooth: Fix CONFIG_BT_CTLR_DEBUG_PINS_CPUAPP compile error
Fix appcore compile error when enabling CONFIG_BT_CTLR_DEBUG_PINS_CPUAPP.

Signed-off-by: Theo Gasteiger <gatcode@wdw.one>
2023-04-20 16:10:42 +02:00
Kumar Gala
caea9dc196 logging: Use TYPE_SECTION macros for log strings
Clean up log_strings to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:52:07 +02:00
Kumar Gala
301d0c4712 net: buf: cleanup net_buf_pool use of iterable section
Cleanup linker scripts for net_buf_pool section to use the linker
script related iterable section macros.

Also replace _net_buf_pool_list with macro's instead to complete
iterable section usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:50:04 +02:00
Emil Gydesen
fa95a7add2 Bluetooth: BAP: Add missing Broadcast source param checks
Several input parameter checks were missing in the BAP broadcast
source API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-20 10:47:10 +02:00
Martin Rieva
ddf518e706 Bluetooth: Shell: Extend the shell output of scan data
Add verbose output of scan data to output all received data types as
hex values. This is turned off by default and can be toggled using
the bt scan-verbose-output <on|off> command.

Signed-off-by: Martin Rieva <mrrv@demant.com>
2023-04-20 10:32:55 +02:00
Pieter De Gendt
7de95b76a6 net: lib: dns: mdns_responder: Fix ipv4/ipv6 address handling
This commit simplifies the arguments for sending dns responses
and fixes an issue where both the ipv4 and ipv6 member of a header
union were accessed.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Pieter De Gendt
292bb97f0d net: lib: dns: mdns_responder: Simplify setup_dns_addr
The setup_dns_addr function packet argument can be reduced to
a socket address family.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Pieter De Gendt
e5b52ac034 net: lib: dns: dns_sd: Improve debug prints
Duplicate logging prints make it hard to find the origin.
This commit does a cleanup of the debug messages printed.

Also change the level of an invalid record to debug as this
is out of our control.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-19 11:55:40 -04:00
Kumar Gala
eec299c130 pm: Use TYPE_SECTION macros for pm_device_slots
Clean up pm_device_slots to utilize TYPE_SECTION macros for handling
sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:15:29 +02:00
Wojciech Slenska
c3575fbd2e net: sockets: fix POLLOUT for offloaded iface
For offloaded iface net_tcp_get is never called, so context->tcp
is always NULL. In that case net_tcp_tx_sem_get will return wrong pointer.
For pollout k_poll will be called with NULL semph,
which cause HardFault.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-04-19 17:15:12 +02:00
Kumar Gala
47cf00058e fb: cfb: Use TYPE_SECTION macros for cfb_fonts
Clean up cfb_fonts to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:54 +02:00
Emil Gydesen
754a5da2ff Bluetooth: MICP: Shell: Add missing "mic_dev" for MICP cmds
The MICP Microphone Device commands were missing the proper
role name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 17:14:30 +02:00
Emil Gydesen
12e82347b4 Bluetooth: BAP: Shell: Scan Delegator prefer past by default
Change the default value of past_preference to true, to prefer
PAST by default when using the scan delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:55:09 -04:00
Emil Gydesen
66af395726 Bluetooth: BAP: Broadcast source fix invalid data pointer
When copying the stream specific codec configuration data,
the value pointer in the bt_data struct was not properly
updated, causing possible invalid data access.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:54:53 -04:00
Emil Gydesen
80bf8c0f7d Bluetooth: CAP: Add missing NULL checks for CAP broadcast start
Add missing checks for param and adv.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 04:54:37 -04:00
Emil Gydesen
dda3703755 Bluetooth: CAP: Add missing NULL check for unicast_audio_update
The bt_cap_initiator_unicast_audio_update function was missing
NULL and 0 checks for input parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-19 10:00:45 +02:00
Gerard Marull-Paretas
1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Vinayak Kariappa Chettimada
4b90d01398 Bluetooth: Controller: Fix cis_offset_min used in CIS Create Response
Use the minimum supported cis_offset_min considering that
ACL radio event does not overlap with CIG event. Use the
calculated maximum of local and remote cis_offset_min in the
Response PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-19 03:47:19 -04:00
Øyvind Rønningstad
31c10f5fe1 lwm2m_senml_cbor_encode.c: Manually edit whitespace
since it crossed the 100 column cutoff, even after clang-format.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad
d0c278af78 lwm2m_senml_cbor: Regenerate code files using zcbor 0.7.0
and the _regenerate.sh script.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad
e9eb61bd14 lwm2m_senml_cbor: Update the regenerate script and the patch file
Do patch file application before clang-format.
Add copyright to generated files using the --file-header option in zcbor.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Kumar Gala
6b5139c4bb shell: Convert to using iterable sections
Convert handling of shell_root_cmds, shell_subcmds, and
shell_dynamic_subcmds to use iterable section macros.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-18 12:48:16 +02:00
Georges Oates_Larsen
7c4397ae79 net: conn_mgr: connectivity API
Allows L2s to declare generic association/connection routines
that can be bound by name to ifaces.

Allows L2-agnostic control over connectivity/association for
iface that support it.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-04-18 09:31:53 +02:00
Aleksandr Khromykh
e7f1856143 Bluetooth: Mesh: add experimental support mbedtls psa
Commit adds experimental support mbedtls psa as crypto
backend for ble mesh. It were run only on bsim tests.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Aleksandr Khromykh
77c72aa67b Bluetooth: Mesh: get rid of host dependency for dh key for mesh
Commit gets rid of host dependency to generate DH key.
Mesh uses its own function for it that has synchronous
behavior and correct endianism. It simplifies the provisioning
state machine since it doesn't require waiting for the host HCI
handler.
Also, it removes hidden cross-dependency between BLE Mesh and
SMP in the aspect of competition for the same DH key
(https://github.com/zephyrproject-rtos/zephyr/issues/23292)

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Aleksandr Khromykh
3f08bd335f Bluetooth: Mesh: split crypto on seclib dependent and independent parts
Commit splits mesh crypto module on security library dependent
and independent parts.
Independent part includes security toolbox implementation.
Dependent part includes security algorithms usage based on
API third party security library.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-17 16:31:20 +02:00
Daniel Nejezchleb
663b684fea net: socket: fix hanging net contexts
Calls put instead of unref on net contexts
in the socket accept function.
Mere unref didn't subtract the reference
count of net context which leaves
it in used state. This situation happens
in case of accepting already
closed connection.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-04-17 15:12:41 +02:00
Daniel Nejezchleb
ee720b5412 net: socket: asynchronous connect
Added a feature of socket connect
being asynchronous. If socket is set
to nonblock with O_NONBLOCK flag,
then connect() is non-blocking aswell.
App can normally poll the socket to
test when the connection is established.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-04-17 11:35:20 +02:00
Johann Fischer
0ad1eef4b7 usb: device: Revert "fix possible deadlock in usb_transfer_sync()"
This reverts commit cd7461495f,
introduced to fix possible deadlock as result of changes in
commit f206170c65
("usb: device: Do not call callback when transfer is cancelled")
which is now reverted.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-17 11:30:48 +02:00
Nickolas Lapp
81e4934ebd usb: device: Revert "Do not call callback when transfer is cancelled"
This reverts commit f206170c65
introduced as workaround for nRF USBD device controller in PR
https://github.com/zephyrproject-rtos/zephyr/pull/16193.

This commit may be reverted due to changes made in
commit e326c58399
("usb: device: Do not cancel transfers on suspend").

Signed-off-by: Nickolas Lapp <nickolaslapp@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-04-17 11:30:48 +02:00
romain pelletant
eab19663a9 net: lwm2m: add callback for send confirmation
Issue #52328

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-04-17 11:29:14 +02:00
Vinayak Kariappa Chettimada
64b4c6ddbd Bluetooth: Controller: Fix Adv PDU RAM usage for direction finding
Fix Advertising PDU size calculation when direction finding
feature is enabled and PDU fragment count includes the
maximum CTE PDU chained. Fix removes redundant PDU count
included for Extended Advertising. Only Periodic advertising
PDUs chain CTE requires number of additional PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-17 11:22:00 +02:00
Rubin Gerritsen
19547e815b Bluetooth: Increase HCI CMD buffer size when ISO Central is used
When ISO Central is enabled it is allowed to configure many CISes at
once. For this a large command buffer is needed. This is also tested
by HCI/CIS/BI-05-C.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-04-17 10:18:27 +02:00
Kenny Johansson
353e5f2577 net: tcp: Fix IPv6 TCP MSS issue
Fixes #56657, incorrect TCP MSS calculation for IPv6.

Previously the supported MSS would incorrectly returned as the MTU if it
was less than the MTU, probably to account for the case where
the network interface MTU check returns 0.

New behaviour is to return the supported MSS as MTU minus header length,
using default MTU for this calculation if network interface MTU check
returns 0.

Signed-off-by: Kenny Johansson <wirehell@gmail.com>
2023-04-17 10:17:09 +02:00
Krzysztof Kopyściński
0d5c33b045 Bluetooth: Mesh: Fix recovery of WAITING_FOR_START BLOB Server state
If device running BLOB Server called `bt_mesh_blob_srv_recv`,
but rebooted before it received `XFER_START` message from BLOB Client,
it was wrongly "recovered" into Suspended phase, which would lead to
Server try to resume transfer on `XFER_START`. It would not be possible,
because `srv->state.xfer` was not set with acual values yet.

Set phase again to BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START, which will
allow to accept new transfer.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-17 10:15:56 +02:00
Stine Åkredalen
938c59c063 ztest: mock: fix failed test printed message.
Corrected printed message on failing test with expected or received
NULL pointer in ztest_check_expected_data.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-04-14 12:39:52 -04:00
Erik Brockhoff
3cb42157c4 Bluetooth: controller: removing (invalid) ASSERT on invalid PDU
A case of an invalid PDU was seen leading to a hit on this ASSERT, ie
this COULD happen. Refactoring of the state handling re. expectedness
in remote vs local request machines combined with ensuring the local
request machine ceases to expect PDUs when remote procedure 'takes over'

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-04-14 14:03:55 +02:00
Vinayak Kariappa Chettimada
2579690be7 Bluetooth: Controller: Fix connection update window offset data type
Fix regression in refactored LLCP using uint16_t instead of
uint32_t in storing the win_offset_us value. This caused
connection update to fail with incorrect window offset being
used to schedule the connection radio events.

Regression since commit e1c2c36f56 ("Bluetooth: controller:
llcp: set refactored as default").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-14 12:57:00 +02:00
Gerard Marull-Paretas
a86ad87d84 shell: add missing blank line after declaration
Fix checkpatch compliance issue by adding a blank line after
declaration.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
404b2ba474 shell: signal is a reserved identifier use sig instead.
Rule 21.2 "A reserved identifier or macro name shall not be declared"

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
b2d442ee87 shell: fix MISRA 5.7 violations on struct tm
s/struct tm *tm/struct tm *t/ to fix MISRA 5.7 rule violation
(uniqueness of tag identifiers).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Gerard Marull-Paretas
667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Kumar Gala
c7c8ea6a45 logging: Fix build issues with arm-clang
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Fixes #56630
Fixes #56628

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-14 06:04:11 -04:00
Keith Packard
0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Andrei Emeltchenko
37575def5f mgmt: Fix comparing usigned < 0
Fix type from size_t to ssize_t.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-04-13 11:05:47 -04:00
Kumar Gala
d3b3a4f293 bluetooth: audio: Only build code if BT_CONN is enabled
The audio code utilizes BT_CONN so ensure its only built if
CONFIG_BT_CONN is set.  This is to fix a build issue we see
with arm-clang for:

sample.bluetooth.broadcast_audio_source

which fails to link since bt_conn_get_info is missing.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-13 16:13:52 +02:00
Vinayak Kariappa Chettimada
6551630c2c Bluetooth: Controller: Fix window offset calculation
Fix window offset calculation which is missing the radio
rx ready delay timing be subtracted because the connection
offset from the start of the radio for scan window to the
end of the ADV_IND PDU includes the radio rx ready delay
timing, where as the determined window offset by advanced
scheduling calculates the offset from the ticks_at_expire
of the scan window to an active central connection's
ticks_at_expire.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
9d5ecd5bc9 Bluetooth: Controller: Use remainder in win_offset_us calculation
Update Advanced Scheduling implementation to use remainder
value in precisely calculating the connection request window
offset in microseconds.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
205406820f Bluetooth: Controller: Move rx chain delay use into prepare_connect_req
Move the use of rx chain delay value used to calculate the
window offset into lll_scan_prepare_connect_req() instead of
current two places, one for legacy and other for extended
connection setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Vinayak Kariappa Chettimada
d1d58de94c Bluetooth: Controller: Match Central roles for BT_CTLR_CENTRAL_SPACING
Find and match only Central role ticker when applying the
BT_CTLR_CENTRAL_SPACING value.

Use the EVENT_TICKER_RES_MARGIN_US value as +/- jitter
margin when ticker advanced scheduling is used to group
radio events.

When using CONFIG_BT_CTLR_CENTRAL_SPACING, do not add the
+/- jitter to the ticks_slot.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-13 16:12:58 +02:00
Nirosharn Amarasinghe
11ce28f8f7 Bluetooth: controller: Consideration for SDU interval in fragmentation
Included consideration for the packet sequence number and time stamps
together with the SDU interval in matching the event for fragmentation
of SDUs to unframed PDUs.

Implemented:
-- Increase in kconfig limit of BT_CTLR_ISO_TX_BUFFERS to allow full 32
   buffers to be available for LL/CIS/PER/BV-39C
-- ISO-AL microsecond time wrapping exposed to be used externally to
   adjust incoming Group Reference Points and Time-stamps where required
-- Function that handles adjustment of payload number according to
   incoming SDU exposed for external use to allow next payload number to
   be accessed by ISO transmit tests
-- Changed internal fragmentation source identification parameter from
   the source structure pointer to the source handle so that only the
   source handle needs to be used for external calls

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-04-13 16:09:39 +02:00
Maurits Fassaert
6bfb663167 shell: backends: add SHELL_BACKEND_RTT_BUFFER option
This new configuration option, SHELL_BACKEND_RTT_BUFFER, allows selecting
an alternative buffer for the Shell's RTT backend. By default buffer 0 is
used, which conflicts with the default logging subsystem RTT backend
buffer.
This option is the counterpart to the logger's LOG_BACKEND_RTT_BUFFER.

Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
2023-04-13 11:43:28 +02:00
Pavel Vasilyev
8dd24bf9c3 Bluetooth: Mesh: Restore PRB state after reboot
Add missing code for restoring Private Beacon state after reboot.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Pavel Vasilyev
95d6e66ec3 Bluetooth: Mesh: Don't process PRB when mesh-1.1 disabled
Private Beacons are mesh-1.1 feature and without mesh-1.1 spec enabled,
the node shall not process such beacons.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Pavel Vasilyev
c36fdf251f Bluetooth: Mesh: Allow sending SNB and PRB in parallel
Private Beacons and Secure Network Beacons are not mutually exclusive by
spec. This means both beacons can be sent simultaneously. For both
beacons spec defines their own observation intervals and related
parameters, which means we need to monitor both beacons types
separately.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-13 10:00:16 +02:00
Kumar Gala
0686476310 bluetooth: Fix compiler warning with arm-clang
Since we enable -fshort-enums for arm-clang we get the following
warning:

subsys/bluetooth/mesh/pb_adv.c:139:40: warning: cast to smaller
integer type 'enum prov_bearer_link_status' from
 'void *' [-Wvoid-pointer-to-enum-cast]

Fix this by first casting to an int to grow the size of the type.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-12 16:03:11 -04:00
Jiapeng Li
2568ab661d canbus: isotp: fix single frame state machine stuck issue
it is too late to set ctx->state to ISOTP_TX_WAIT_FIN after send_sf
because send_state_machine could be called just between `send_sf` and
`ctx->state = ISOTP_TX_WAIT_FIN;`  in extremely case. like below:
```c
	ret = send_sf(ctx);
	-> send_state_machine (irq handler)
	ctx->state = ISOTP_TX_WAIT_FIN;
```
it will cause isotp_send never return.

Signed-off-by: Jiapeng Li <mail@jiapeng.me>
2023-04-12 17:45:04 +02:00
Seppo Takalo
1dd9d514f1 net: lwm2m: Move utility functions from engine
Some utility functions belong to lwm2m_util.c.
Block contexts belong to lwm2m_message_handling.c

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-12 17:44:37 +02:00
Fredrik Danebjer
7e416c8ec0 Bluetooth: audio: csis: Fix Big Endianness for RSI generation
This changes so that generation of RSI now uses LE arrays instead of
uint32 words. Both input and output of rsi and sih genration now uses
LE. This also fixes the generation of RSI for BE systems, which
wasn't working.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2023-04-12 17:44:29 +02:00
Gerard Marull-Paretas
cb067800b4 ztest: mock: fix UNNECESSARY_INT compliance issue
Fix checkpatch issue: UNNECESSARY_INT: Prefer 'unsigned long' over
'unsigned long int' as the int is unnecessary

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 16:42:29 +02:00
Gerard Marull-Paretas
4863c5f05b sys/util: extend usage of DIV_ROUND_UP
Many areas of Zephyr divide and round up without using the DIV_ROUND_UP
macro. Make use of it, so that we make use of a tested system macro and
at the same time we make code more readable.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 16:42:29 +02:00
Gerard Marull-Paretas
a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Jiapeng Li
9d47a3f6d9 mgmt: mcumgr: grp: fs_mgmt: set .upload flag in file_access_data
minor fix, set .upload true if uploading

Signed-off-by: Jiapeng Li <mail@jiapeng.me>
2023-04-12 14:25:14 +02:00
Vinayak Kariappa Chettimada
51a7de2beb Bluetooth: Controller: Fix BIG handle when operation cancelled by Host
Fix the BIG handle in the HCI LE BIG Sync Established event
when BIG Create Sync operation is cancelled by Host.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-12 13:10:39 +02:00
Mariusz Skamra
13341a3e7e Bluetooth: audio: ascs: Fix missing ISO state check
This fixes missing ISO connection state check, as there might be no ISO
connection when Receiver Stop Ready has been received. This might happen
on ASE state transition from Enabling to Disabling.
Without this check the code asserts in ascs_disconnect_stream_work_handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-12 13:05:20 +02:00
Aleksandr Khromykh
4b5be77531 Bluetooth: Mesh: check buffer tailroom before relaying proxy message
PR adds checking proxy buffer tailroom before adding
a relayed message. That prevents potential proxy trash attacks.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-04-12 13:04:56 +02:00
Anders Storrø
fc49ad3ac6 Bluetooth: Mesh: Shell: Align parameter docs
Aligns Bluetooth mesh shell parameter documentation to use the
same syntax, abbrevations and formating.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-04-12 13:04:42 +02:00
Anders Storrø
1026ec5b38 Bluetooth: Mesh: Shell: Change pub cmd period arg
Changes the implementation and documentation in config client shell
command for Config Model Publication Set and Config Model Publication
Virtual Address Set to accept period resolution and period steps as
separate arguments to make it more user friendly.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-04-12 13:04:42 +02:00
Robert Lubos
afaf4cddd2 net: sockets: tls: Implement handshake timeout
Currently, the handshake operation could only be fully blocking or
non-blocking. This did not play well if SO_RCVTIMEO was set for DTLS
server, as the recv() call where the blocking handshake was used, could
block indefinitely, ignoring the timeout parameter. Fix this, by
allowing for the handshake operation to timeout.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
9082d4b98e net: sockets: tls: Implement TLS/DTLS socket TX/RX timeout
As the underlying socket operations for TLS/DTLS are now non-blocking,
it's no longer possible to rely on the underlying socket timeout
handling. Instead, implement SO_RCVTIMEO/SO_SNDTIMEO at the TLS socket
layer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
81be0f6d73 net: sockets: tls: Switch DTLS to use non-blocking socket operations
As for TLS, switch to use non-blocking operations on underlying socket.
This is a bit tricker for DTLS, as there were not truly blocking bio
(binary input/output) function for DTLS, as timeout had to been
implemented. It is possible though to implement non-blocking mbedTLS bio
function instead, and handle timeout outside of mbedTLS context, which
has been done in this commit.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
ee48ddc205 net: sockets: tls: Switch TLS to use non-blocking socket operations
Switch TLS sockets to use non-blocking socket operations underneath.
This allows to implement the socket blocking outside of the mbedTLS
context (using poll()), and therefore release the mutex for the time the
underlying socket is waiting for data. In result, it's now possible to
do blocking TLS RX/TX operations simultaneously from separate threads.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Robert Lubos
96e14ba91f net: sockets: tls: Implement ZFD_IOCTL_SET_LOCK handling
Implement ZFD_IOCTL_SET_LOCK so that TLS socket layer gets access to the
mutex protecting socket calls.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-12 11:09:58 +02:00
Théo Battrel
b48a69023a Bluetooth: Logging: Make BT_LOG and BT_LOG_LEGACY hidden symbols
Make `BT_LOG` and `BT_LOG_LEGACY` hidden Kconfig symbols.

They should not be used by the user to configure the Bluetooth logging
system. If the user want to completely disable Bluetooth logging, they
should use `BT_LOG_LEVEL_OFF=y`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-04-12 10:23:04 +02:00
Krzysztof Kopyściński
1993c5facd Bluetooth: Mesh: Link Close without success should fail NPPI procedure
When we receive `RPR_OP_LINK_CLOSE` message with reason other than
`SUCCESS` we should fail NPPI refresh procedure, not complete it.
Dropping `COMPLETE` flag will result in calling `reprovision_fail`
in `prov_link_closed`, not `reprovision_complete`.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-12 10:22:27 +02:00
Luca Fancellu
e25d484b6f net: ip: Kconfig for TCP packet allocation timeout
TCP packet allocation timeout is currently 100ms, but there are cases
where it is not enough and as a side effect, the kernel internals are
printing some errors on the log before retrying again, create a
Kconfig parameter to be able to tune this value.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-04-12 10:22:12 +02:00
Johan Hedberg
a6e5755da8 Bluetooth: Fix clearing sent_cmd pointer when allocating event buffer
We should clear the bt_dev.sent_cmd pointer after using it to allocate a
new HCI event buffer in the bt_buf_get_cmd_complete() function.
Otherwise, there is a risk of reusing the same stored net_buf for
multiple consecutive HCI events in case the controller sents duplicate
or invalid event packets.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-04-11 16:57:37 +02:00
Gerard Marull-Paretas
0ebe14beb4 sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +02:00
Emil Gydesen
d2d3c49f39 Bluetooth: Audio: Shell: BAP scan delegator term sync cmd
Added command to terminate the PA sync as the scan delegator.
This can also be used to cancel any pending PA syncs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
65bbc3673e Bluetooth: Audio: Add bis_sync_req scan delegator callback
Add callback to notify the application about which
BIS it should sync to when requested by the Broadcast
Asssitant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
56d0947c92 Bluetooth: Audio: Add broadsink sink create
Add support to create a broadcast sink from a PA sync, rather
than using the broadcast sink scan functions.

This allows for the scan delegator implementation to
autonoumsly add broadcast sinks.

This refactors how the broadcast sink uses flags, to
ensure thread safetyness.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
7b9ddc24c0 Bluetooth: Audio: Integrate scan deletagor and broadcast sink
This integrates the Scan Delegator functionality with the
Broadcast Sink functionality. The Broadcast Sink will
automatically update the receive state for the PA and BIG
sync values, based on state of the Broadcast Sink.

Similarly, a request to terminate the BIG or PA sync from
a Broadcast Assistant will terminate the Broadcast Sinks'
PA or BIG syncs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
df490ea222 Bluetooth: Audio: Add Scan Delegator receive state iterate functions
Add bt_bap_scan_delegator_foreach_state and
bt_bap_scan_delegator_find_state to support finding
specific receive states.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
fe75a41134 Bluetooth: Audio: Remove enc_state from scan_delegator_set_bis_sync_state
The field is added/modified by bt_bap_scan_delegator_add_src
and bt_bap_scan_delegator_mod_src. This makes it easier
to modify the BIG sync state, without worrying about
the encryption state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
76002eb025 Bluetooth: Audio: Add cmd_bap_scan_delegator_rem_src
Add the cmd_bap_scan_delegator_rem_src to remove
receive state sources locally as the Scan Delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
43dd0f884e Bluetooth: Audio: Add cmd_bap_scan_delegator_mod_src
Add cmd_bap_scan_delegator_mod_src to modify a BASS
receive state source as the scan delegator in the
shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
d35c5540c3 Bluetooth: Audio: Add cmd_bap_scan_delegator_add_src
Add command for the scan delegator to add a source
locally based on a PA sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
60da9747c8 Bluetooth: Audio: Scan delegator mod source added
Add function for the scan delegator to modify the metadata
of a receive state locally.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
0005b85e16 Bluetooth: Audio: Fix issue with subgroup metadata for scan delegator
The scan delegator attempted to put the subgroup pointer into the
metadata data, instead of the metadata.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
315aa4dcd8 Bluetooth: Audio: Add BASS server sync test case
Add a test case that tests the scan delegator and
broadcast assistant features when the scan delegator
syncs to a PA without being asked to by the
broadcast assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
f0668550b8 Bluetooth: Audio: Fix bug in bis_syncs_unique_or_no_pref
The check did not work when aggregated_bis_syncs
was 0. Also modfied the function to be more readable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
781e6fc691 Bluetooth: Audio: Support local add_source for scan delegator
Add support for adding a source from the scan delegator itself.
This is useful if e.g. the broadcast sink syncs to a PA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
c1836e80da Bluetooth: Audio: Fix issue with bt_bap_scan_delegator_remove_source
The bt_bap_scan_delegator_remove_source failed due to invalid length,
as the buffer supplied to scan_delegator_rem_src should not
contain the opcode.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
42f1868189 Bluetooth: Audio: Move requested_bis_sync from recv_state to internal
The requested_bis_sync value is not part of the BASS receive
state. Moving the field makes it possible to use the
recv_state struct in more situations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
32cfcb9257 Bluetooth: Audio: Add scan delegator broadcast code callback
Add a callback that is called when the broadcast
assistant supplies a broadcast code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
b37985a898 Bluetooth: Audio: Remove PA sync handling from scan_delegator
The scan delegator will no longer be responsible for
handling the actual synchronization of the periodic
advertisers, and will offload this to higher layers.

The reason for this, is that scanning is a global state,
and should be avoided autonousmly by the stack. The
application is much better suited for handling this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
b99d989420 Bluetooth: Audio: Add receive_state_updated for scan delegator
Add the receive_state_updated callback for the scan delegator.
This callback will be called whenever a receive state is updated
by any means, giving the upper layers the option to always know
the latest changes.

This commit also refactors the name used for the internal
receive state (which contains additional information), for
the sake of readability.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
3348ed76be Bluetooth: Audio: Remove autonomous BIS sync from scan delegator
The Scan delegator will rely on upper layers calling
bt_bap_scan_delegator_set_bis_sync_state instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
ab1fd85c9e Bluetooth: Audio: Refactor scan delegator set sync state
The bt_bap_scan_delegator_set_sync_state has been refactored
to bt_bap_scan_delegator_set_bis_sync_state, as it will,
going forward, only be used to set the BIS sync states,
and not the PA sync state. The PA sync state will, in a future
commit, but autonousmly handled by the scan delegator
based on the PA sync callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
93045467b4 Bluetooth: Audio: Remove testing guard for scan delegator set sync state
The set sync state will be used for upper layers to set the BIS
sync state. This is due to the fact that the scan delegator cannot
automatically get this information from the ISO layer, unlike
the PA sync state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
e275e0f713 Bluetooth: Audio: Make scan delegator recv state const in API
Since the data is informative only, the struct should be
const.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Emil Gydesen
6bbda2cbfd Bluetooth: Audio: Add Scan Delegator dependency for Broadcast Sink
Per the BAP specification, if the Broadcast Sink role is
supported, then the Scan Delegator shall also be supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-11 11:26:28 +02:00
Yuval Peress
dbb470ea7a rtio: Add a managed memory pool for reads
- Introduce a new Kconfig to enable mempool in RTIO
- Introduce a new RTIO_DEFINE_WITH_MEMPOOL to allocate an RTIO context
  with an associated memory pool.
- Add a new sqe read function rtio_sqe_read_with_pool() for memory pool
  enabled RTIO contexts
- Allow IODevs to allocate only the memory they need via rtio_sqe_rx_buf()
- Allow the consumer to get the allocated buffer via
  rtio_cqe_get_mempool_buffer()
- Consumers need to release the buffer via rtio_release_buffer() when
  processing is complete.

Signed-off-by: Yuval Peress <peress@google.com>
2023-04-10 18:34:43 -04:00
Yuval Peress
80d70b4e96 rtio: Add cqe per each sqe in transaction
Update the policy such that every completed sqe has a parallel cqe.
This has the primary purpose of making any reads in the sqe visible
to the consumer (since they might have different buffers).

Signed-off-by: Yuval Peress <peress@google.com>
2023-04-10 18:34:43 -04:00
Kumar Gala
c09e8fae23 twister: Use pyelf to extract symbol information
For ztest twister would parse the symbol information that was
generated as part of the build (zephyr.symbols).  However the format
of the zephyr.symbols files is highly dependant on the toolchain.

Move to using pyelf to parse the symbol information directly from
zephyr.elf instead so that this works regardless of toolchain.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 18:37:52 +02:00
Marcin Niestroj
850ed72214 Bluetooth: logging: don't imply LOG_FUNC_NAME_PREFIX_*
By default there is only CONFIG_LOG_FUNC_NAME_PREFIX_DBG=y enabled. When
both Bluetooth (CONFIG_BT=y) and logging (CONFIG_LOG=y) subsystems are
enabled, then other CONFIG_LOG_FUNC_NAME_PREFIX_{INF,WRN,ERR}=y options are
pulled in as well using an 'imply' Kconfig command indirectly from
`CONFIG_BT_LOG`. This behavior was introduced recently as part of
commit af01a0f313 ("Bluetooth: Logging: Move all logging symbols
together") with no explicit reason provided.

Pulling in LOG_FUNC_NAME_PREFIX_* options automatically with (CONFIG_BT=y
&& CONFIG_LOG=y) blows up flash usage. As an example of downstream project
(nRF52840-based, with Bluetooth and WiFi connectivity), it increases flash
usage from 473668 bytes to 487856 bytes. This seems "only" 3% difference,
but this is actually a lot when there is no good reason why this happens.
Downstream users quite often compare flash sizes of subsequent Zephyr
releases and this 3% footprint increase might be a blocker at some point.
Additionally, it is not trivial to find the root cause of footprint
increase for most (non-expert) users.

The reason why there is so much footprint overhead because of
CONFIG_LOG_FUNC_NAME_PREFIX_*=y is because each function in the
codebase (be it Zephyr or downstream application) that contains logging
macros (LOG_{DBG,INF,WRN,ERR}()) is bloated because the function name has
to be included in the output image.

Remove 'imply LOG_FUNC_NAME_PREFIX_*' commands from 'menuconfig BT_LOG'
option, so that flash usage does not increase too much. Those logging
options are not enabled by other subsystems, so Bluetooth should not be an
exception here.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-04-08 12:34:07 +02:00
Kumar Gala
5c4d184016 emul: Use STRUCT_SECTION macros for emul devices
Clean up emulator code to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 12:33:54 +02:00
Pavel Vasilyev
0d7c7eb4c9 Bluetooth: Mesh: Remove incorrect opcode check in RPR Client
RPR Client doesn't send RPR_OP_LINK_REPORT and therefore it can't wait
for it using ack ctx. It should have been RPR_OP_PDU_OUTBOUND_REPORT
to cover a case where Outbound PDU transmission failed. But in this case
the link status will be non equal to BT_MESH_RPR_SUCCESS (see pb_error in
rpr_srv.c) and the link state will be set to idle. And the client will
reset the link together with ack ctx.

When bearer user (provisioner.c) sends an Outbound PDU, it uses the
callback (see bt_mesh_prov_send in provisioner.c) to send a next PDU,
but it doesn't check the error code even though it is provided through
the callback. Therefore calling the callback with error code would
require error handling in provisioner.c.

With ordinary provisioning PB-ADV doesn't call the callback in case of
error, but closes the link by timeout if doesn't receive ACK (see
prov_send_adv in pb_adv.c). PB-GATT always calls the callback with
error code 0 once the PDU is transmitted (see buf_send in pb_gatt.c).

Thus this change aligns RPR Client implementation with other bearers.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-07 13:38:36 +02:00
Szymon Janc
a7eee34339 Bluetooth: Host: Fix legacy OOB pairing as central
When central is sending SMP Pairing Request is it unknown if
pairing will be legacy or LE SC so set OOB flag if any OOB
data is present and assume to peer device provides OOB data
that will match pairing type.

This was affecting following qualification test cases:
SM/CEN/OOB/BI-01-C
SM/CEN/OOB/BV-01-C
SM/CEN/OOB/BV-03-C
SM/CEN/OOB/BV-09-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-04-07 13:36:41 +02:00
Krishna T
1e6e20f667 net: wifi: Log failure reason for AP mode
In case AP mode is not supported log the failure reason clearly.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-04-07 13:35:28 +02:00
Siddharth Chandrasekaran
cd116b22b5 mgmt/osdp: Clear secure channel base key from stack
Secure Channel Base Key (SCBK) is a secret key used to derive the session
keys used to encrypt and decrypt OSDP packets. Secure coding practice
requires us to clear such sensitive data from stack once we are done
needing it. This patch addresses this issue.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
814433d433 mgmt/osdp: Make sure we decrypt atleast one block
OSDP secure channel message blocks are terminated with a 0x80. This means
that even for zero length messages, we would have at least one block of
encrypted data to decrypt (since message blocks are rounded up to the next
16 byte boundary). The current length assertion checks for 16 byte
alignment but a malicious peer could send a specially crafted packet with
zero length blocks. Fix this issue by adding check for length == 0 case.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
0effd82b7a mgmt/osdp: discard secure channel if KEYSET is ACKed in plaintext
HID readers are responding to a KEYSET command with an ACK in plaintext
instead of using the current session keys to acknowledge this command
(which is the reasonable thing to do as the command itself was received
encrypted with the old key). Since the spec doesn't say anything about
this, both methods are technically correct.

Make changes to CP so it allows ACKs in plaintext for KEYSET command in
particular and make the PD implementation do this too as it makes the code
look cleaner there (perhaps HID did it for the same reasons :D).

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
a1edd3e74d mgmt/osdp: phy: Allow non-conformant, 0 length, encrypted data blocks
If command or reply has no data, PD "should" use secure message types
SCS_15 or SCS_16. But some PD seem to not implement this correctly. We
will be tolerant towards those faulty implementations.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
1648e86f4b mgmt/osdp: Rework secure channel key management
OSDP command KEYSET is used to set the secure channel base key for all
connected PDs. This key is then used to derive the session keys for each
secure channel session. When the app wants to set the this key, it has
to issue a command and then both the CP/PD has to be notified of this
change so they can store this key in a non-volatile medium for future
operations across power cycles.

The current implementation of OSDP had limited support for key
management. This patch adds all the bells and whistles needed to handle
keyset command/event in the CP/PD application.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Siddharth Chandrasekaran
431cac80f4 mgmt/osdp: sc: Restructure loop to avoid a bunch of -1s
Hoisting a `length--` helps simplify a lot of code which has ad-hoc -1s
in a  bunch of places. Also, fix some formatting issues and remove
unnecessary log lines.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-04-07 13:26:36 +02:00
Wojciech Slenska
df98af0c23 shell: backends: telnet: init structure before first function call
Struct sh_telnet should be initialised before first function call.

Right now there is a possibility that telnet_accept function will
be called before memset.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-04-07 13:24:32 +02:00
Dawid Niedzwiecki
4ef47888ef ec_host_cmd: add UART backend
Add a new backend for Host Commands that uses UART. The backend bases
asynchronous UART API.

The UART backend is mainly used by FPMCU.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-07 13:05:59 +02:00
Dawid Niedzwiecki
7490adcd2a ec_host_cmd: update Kconfig help message
The help messages for max request/response SHI sizes were adjusted only
for NPCX, update it.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-04-07 13:05:59 +02:00
Emil Gydesen
3d3e692190 Bluetooth: Audio: Add missing null checks in mpl
There were a missing NULL check for the track segment in
paused_state_command_handler when performing the segment
operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
695f85e29d Bluetooth: Audio: Add MCC verification of read object IDs
Add check to verify that the object IDs we receive from
the server are valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9c129c5bc7 Bluetooth: Audio: MCC memset discover params for included
The discovery parameters may contain values from previous
discovery calls. The simply and future proof solution to
this is to simply memset it before using it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
b7c2629a6f Bluetooth: Audio: Add value_handle check to MCC subscribe cb
If the subscribed callback is called with value_handle = 0,
then it should not be treated as a subscription complete.

This will happen when bt_mcc_discover_mcs is called, as
reset_mcs_inst unsubscribed to all characteristics before
discovering again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9e823184e2 Bluetooth: Audio: Add value check for bt_mcc_set_playing_order
Add check for the (playing) order value, to verify that is it
a valid value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
9ebad924ac Bluetooth: Audio: Add input validation for bt_mcc_send_search
Add validation of the search pointer and len value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
e7770a6a7e Bluetooth: Audio: Add BT_MCS_VALID_OP
Add the BT_MCS_VALID_OP macro to verify MCS opcodes for
both the MCC and MCS implementations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
32cd16cfac Bluetooth: Audio: Add BT_MCS_VALID_OBJ_ID
Add macro BT_MCS_VALID_OBJ_ID to verify the OTS Object
ID before attempting any OTS operations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Emil Gydesen
67acec1d6f Bluetooth: Services: Add macro for verifying OTS object ID
Add BT_OTS_VALID_OBJ_ID which verifies if an object ID
is valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-07 11:29:54 +02:00
Seppo Takalo
1c6a853528 net: lwm2m: Default lifetime is also a minimum accepted lifetime
If server or bootstrap writes a lifetime value less than
configured default lifetime, client will automatically overwrite
the value with default one.

This gives better control for the application where client
behaviour is fine tuned on the Kconfig, but default values
from bootstrap server cannot be fine-tuned.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:15:04 -05:00
William MARTIN
e121ea28d9 canbus: isotp: Allow to override ISOTP_FIXED_ADDR_* constants
This patch allow to use isotp use_fixed_addr feature
with CAN identifier which not match SAE J1939 format.


Signed-off-by: William MARTIN <william.martin@power-lan.com>
2023-04-06 19:43:02 +02:00
TOKITA Hiroshi
47f14d6375 fb: cfb_shell: support area inverting
Extend the invert command to run cfb_invert_area when given four arguments.
Make a change to invert the screen immediately in case of run invert
without arguments.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
e2c946536e fb: cfb_shell: Add draw text command
Add the `draw text` command to execute the `cfb_draw_text()` API.

The command is similar to the `print` command. The difference is
`draw text` can render to coordinate that is not on tile boundaries.
The command is not run `cfb_framebuffer_clear()`,
So it allows rendering appendiceal with keeping already drawn image.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
7068587505 fb: cfb: support inverting with coordinates that do not align with the tile
Improve `cfb_invert_area()` able to invert even at a coordinate
not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
5634691d8c fb: cfb: Add cfb_draw_text() API
Add cfb_draw_text() API for rendering text.
It is similar to cfb_print(), the difference is cfb_draw_text() accepts
coordinate that is not on tile boundaries and don't wrap the line.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
ca5de12503 fb: cfb: support drawing to any coordinates
Implements dot-by-dot font rendering to make cfb_print() able to
draw text even at a coordinate that is not on tile boundaries.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
b4965d672b fb: cfb: add const modifier for argument of cfb_print
cfb_print does not modify either address and contents of
the pointer that is pointing drawing text.
Thus, it can add a const modifier.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
TOKITA Hiroshi
6663b558fa fb: cfb: Restore inverted framebuffer to make able to reuse
cfb_framebuffer_finalize() invert the framebuffer, and it still
leave as inverted after executing the function.

It restores the framebuffer at the end of the cfb_framebuffer_finalize()
for the continued drawing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-04-06 18:52:40 +02:00
Dölker Kim
3e5cca196c fb: cfb: fix cfb_framebuffer_clear() implementation
dev and clear_display parameter are unused and only
the framebuffer was cleared. A condition which calls
cfb_framebuffer_fanalize when clear_display is
true is implemented. Then not only the buffer,
but  buffer and display are cleared.

Signed-off-by: Dölker Kim <KDoelker@baumer.com>
2023-04-06 18:52:21 +02:00
Emil Gydesen
4bb8b2523f Bluetooth: shell: Guard adv_opt with CONFIG_BT_BROADCASTER
The advertising options are only valid if we are a
GAP broadcaster.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-06 15:37:30 +02:00
Seppo Takalo
3a241592b5 net: lwm2m: Remove lwm2m_path_to_string
This function had only one use in SenML CBOR formatter and it
contained some specific tweaks, so move the function to be a
static member of that module.

Fixes #53674

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 15:37:21 +02:00
Vinayak Kariappa Chettimada
8c3c33a970 Bluetooth: Controller: Fix compile error due to missing DF include
Fix compile error due to missing Direction Finding header
file include.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-04-06 12:57:20 +00:00
Tomasz Moń
59f33a6019 shell: uart: Fix wait for DTR before TX
Fail compilation when incorrect configuration is detected, i.e. when
SHELL_BACKEND_SERIAL_CHECK_DTR is set but UART_LINE_CTRL is not set.

Use periodic timer to wait for DTR instead of waiting in uart callback
to prevent blocking caller workqueue and/or sleeping in ISR.

DTR check was only ever supported with interrupt driven backend so add
appropriate depends on to Kconfig.

Fixes: e9f238889b ("shell: uart: Add waiting on DTR signal before
sending data")
Fixes: #47120
Fixes: #54705

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-04-06 14:21:57 +02:00
Seppo Takalo
567b2510b8 net: lwm2m: Allow stopping while paused
When LwM2M engine is paused, stop functionality just
marks the intent and when we resume, it will send the
de-registration if that was requested.
Otherwise it will stay in SUSPENDED state until resumed
and then goes into ENGINE_DEREGISTERED -> IDLE.

This also removes the blocking loop from lwm2m_rd_client_stop().
It does not need to block because lwm2m_rd_client_start()
is already checking if client is in IDLE.

Fixes #56254

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:21:49 +02:00
Kumar Gala
804af856f8 bluetooth: Fix linking issues with armclang
Various bluetooth tests fails to link because bt_le_ext_adv_set_data
can't be resolved.  Solve this by adding a check CONFIG_BT_EXT_ADV
around use of bt_le_ext_adv_set_data.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-05 19:32:34 +02:00
Robert Lubos
162c0f64c2 tests: net: websocket: Fix test execution on 64-bit platforms
Instead of passing the test parameters to the websocket function, by
casting the pointer to integer (which may not work on 64-bit platform
due to int/pointer size mismatch), let the test allocate a file
descriptor, and initialize it with test context. The tested functions
expect a file descriptor as an argument anyway, so it's a more intuitive
approach.

The conditional test code within WS implementation can retrieve the test
context by using FD APIs to obtain the object represented by the FD.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-05 15:01:50 +02:00
Kamil Kasperczyk
6fe83ea810 logging: Changed log template to consider default log level
Added using LOG_DEFAULT_LEVEL kconfig option in log module
template for assigning the default log level to newly created
module instance, instead of assuming always INFO level.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2023-04-05 13:47:06 +02:00
Pieter De Gendt
6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Keith Packard
3f3224d880 subsys/net: Labels cannot be applied to declarations
C only permits labels on statements, not declarations.  Separate the
declarations from the assignments so that the labels can target
statements instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-05 10:38:34 +02:00
Anas Nashif
ef1a589f61 ztest: add macro for custom testcase result
Some cases, especially those dealing with faults need to inject output
manually, so provied a macro for special case.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Jakub Rzeszutko
336c0ed98f shell: fix assert when bypass mode is set
For the duration of the bypass function shell sets the command context.

Fixes: #51637

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2023-04-05 10:03:11 +02:00
Manuel Arguelles
09dd8c74ae littlefs: translate error code when mount fails
When lfs mount fails and there is no formatting requested, the return
code must be translated to errno before being passed to the application
layer.

Additionally, only log a warning that the FS will be formatted, when the
system is not read-only.

Fixes #56378

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-04-04 18:22:10 +02:00
Pavel Vasilyev
62191ba8fd Bluetooth: Mesh: Add async API to Private Beacon Client
Add asynchronous API to Private Beacon Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-04 14:32:57 +02:00
Pavel Vasilyev
3a2dc591d4 Bluetooth: Mesh: Use bt_mesh_msg_ackd_send API in Private Beacon Cli
Replace duplicate code in Private Beacon client with
bt_mesh_msg_ackd_send API.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-04-04 14:32:57 +02:00
Emil Gydesen
856a20bcc6 Bluetooth: Add missing dependency for PAST feature
The PAST sender needs to support periodic advertising
and the PAST receiver needs to support periodic advertising
sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 14:31:17 +02:00
Emil Gydesen
f3af19618b Bluetooth: BAP: Shell: Add check for uuid sizes
The check is very unlikely to be needed, but fixing
warning about assigning ARRAY_SIZE to an uint8_t value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 14:30:34 +02:00
Kumar Gala
762b109179 shell: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 13:47:14 +02:00
Hein Wessels
8735d0f653 logging: support custom timestamp formatting
This feature adds support for using a custom function to format
the timestamp used for all logging backends. When the kconfig
option LOG_OUTPUT_FORMAT_CUSTOM_TIMESTAMP is set the custom
formatting function will always be used.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-04-04 13:41:17 +02:00
Emil Gydesen
6dface9947 Bluetooth: Audio: Add select BT_GATT_DYNAMIC_DB for audio services
Many/most LE Audio services are dynamically registered,
but have been enabled without BT_GATT_DYNAMIC_DB.

Add select BT_GATT_DYNAMIC_DB for the services. Select
was used instead of depends on to make it simpler
to enable them.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-04-04 13:36:26 +02:00
Mariusz Skamra
05540b2c4d Bluetooth: audio: iso: Remove code duplicates
This removes duplicated code related to bap iso binding/unbinding.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:36:17 +02:00
Mariusz Skamra
9cddbabc6f Bluetooth: audio: endpoint: Remove redundant conditional
This fixes redundant check, as CONFIG_BT_BAP_UNICAST_CLIENT
enables CONFIG_BT_BAP_UNICAST.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:36:08 +02:00
Mariusz Skamra
92d6b78fe6 Bluetooth: audio: Introduce helper BT_AUDIO_RX(TX) flags
This adds new hidden compilation flags that indicate whether the
implementation is configured to be able to receive/transmit audio data.
The flags are profile agnostic to loosen dependencies between
modules/services.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-04 13:35:56 +02:00
Jamie McCrae
e00cf28001 mgmt: mcumgr: grp: fs_mgmt: Improve upload and download performance
This vastly increases the performance of file transfers using the
fs_mgmt group over MCUmgr by allowing the file handle to remain open
between commands instead of having to open, feek, read/write then
close the file handle for each invocation.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-04 11:51:43 +02:00
Victor Chavez
649570ebc4 logging: Fixed BLE backend when used alone
There was a bug in the BLE backend when it was the only enabled
backend. Instead of using the API `log_backend_activate` to
activate the backend, the logger requires the first time to be
enabled with `log_backend_enable`.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-04-04 08:53:25 +00:00
Radoslaw Koppel
61ce27a12e ipc: ipc_service: Remove the race condition from bonding
This commit removes the possible race condition when notifying
the bonding request.
When the race condition appears there is possibility that
one of the cores would never send notification for bonding.
This change makes it sure that the notification would be sent
at least once.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2023-04-04 10:30:47 +02:00
Victor Chavez
a18aa915ce logging: Added BLE Backend Service
Added a new logger backend to recieve data over a BLE
notification characteristic.
The characteristic is based on the UUID from the Nordic connect SDK
service NUS, which allows to have a UART shell over BLE.
The idea behind this, is that this logger can be used directly
with the NRF apps or any other BLE UART terminal app.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-04-03 15:17:57 +02:00
Emil Obalski
5143db540c ipc: Fix icmsg deregister functionality
This change fixes the deregister functionality for
icmsg backend. There are two changes:

Memory access layer was not initialized properly
when the endpoint was registered again. This lead to
memory fault when attepmt to write to the buffer was
done.

Mbox driver was initialized before memory access layer
was initialized. This could lead to race condition
where immediately after the mbox driver was initialized,
the receiving work is scheduled due to pending interrupt.
In that case an attempt to read from garbage address will
occur.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-03 11:29:08 +02:00
Tom Burdick
a539d9c904 rtio: Add transceive op
Adds the transceive op which is needed for full SPI support. Notably
in RTIO transceive is expected to be a balanced buffer pair of the same
length and have non-null tx/rx bufs.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Tom Burdick
912e7ff863 rtio: Add callback op
Adds a callback op to RTIO enabling C logic to be interspersed with
I/O operations. This is not safe from userspace but allowable in kernel
space.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Tom Burdick
bb72809326 rtio: Add tiny write op
When sending small buffers out it makes sense to copy rather than
reference to avoid having to keep the small buffer around for the
lifetime of the write request.

Adjusts the op numbers to always be +1 from the previously defined op
id making it easier to re-arrange if needed in the future.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Daniel Leung
8dda1fe154 pm: mark pm_device_runtime_auto_enable as boot function
When demand paging is enabled, only a minimal set of functions
are available at boot. Anything not marked as boot functions
would not be loading in memory at boot which would result in
page faults when jumping to those functions. However, at early
boot, demand paging has not been enabled yet. So we need to
mark necessary functions as boot functions so they are placed
in the correct linker section where they are loaded at boot.

Fixes #56414

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-31 14:31:52 -04:00
Théo Battrel
ff10a9cf23 Bluetooth: Host: Remove unnecessary guarding
Remove unnecessary guarding. With `BT_DEBUG` removed, those conditions
were not needed anymore.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-31 14:01:33 +02:00
Kumar Gala
b9a63b805e lwm2m: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 14:01:24 +02:00
Szymon Czapracki
33bf1fa0c6 Bluetooth: audio: Expand AICS API
This commit adds new API functions for AICS
Setting automatic/manual only gain modes
Setting mute disabled
Use new functions in btp.vcp

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-03-31 09:20:15 +02:00
Kumar Gala
b4d4e30e9b bluetooth: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 09:19:16 +02:00
Kumar Gala
19b6b1fb30 dns: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 09:19:09 +02:00
Tom Burdick
f09685e1ac shell: Provide runtime power management toggling
Adds a device pm_toggle shell command which calls pm_runtime_device
functions put and get to toggle the runtime power state.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-30 17:33:22 -04:00
Mariusz Skamra
fc54859645 Bluetooth: audio: ascs: Handle ascs_ase_read with NULL conn
If the callback is called with NULL conn, just return ASE Idle state
value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-30 13:48:22 +02:00
Mariusz Skamra
f38c2633e7 Bluetooth: ascs: Remove redundant ase_id check
The ASE_ID is assigned locally via preprocessor macro, thus it's ensured
to be valid.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-30 13:48:22 +02:00
Emil Gydesen
630f6a7d82 Bluetooth: BAP: Store biginfo data in broadcast_sink->codec_qos
Store information from the biginfo in a
broadcast_sink->codec_qos struct, and add a reference to that struct
when syncing, so that the stream->qos contains a valid struct
with properly initialized information.

This also adds a guard for the codec_qos.latency as that
is not set nor used by the broadcast sink (as it is
not available).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-30 10:40:13 +00:00
Emil Gydesen
114e45eb2a Bluetooth: BAP: Broadcast Sink BASE contains presentation delay
The presentation delay is now properly stored in
the BASE struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-30 10:40:13 +00:00
Théo Battrel
9b8b58c70b Bluetooth: Logging: Remove BT_DEBUG
Remove Kconfig symbol `BT_DEBUG`. It was not useful anymore with the
previous logging updates.

Replace it, where it was used, by the file local debug symbol.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-30 10:40:01 +00:00
Jordan Yates
db3d51bb7d pm: device_runtime: add zephyr,pm-device-runtime-auto
Add the `zephyr,pm-device-runtime-auto` flag to `pm.yaml` and
`struct pm_device`.

This flag is intended to signify to the boot system that device runtime
PM should be automatically enabled on the device after the init function
has run.

Only run `pm_device_runtime_auto_enable` function on a device if
initialisation succeeded. This prevents actions being run on devices
that are not ready.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-29 12:21:13 -04:00
Szymon Janc
ee48754af3 bluetooth: host: Fix checking if LTK is present
conn->le.keys are set on-demand when actual security action happens and
it is possible that permission check needs to happen before those.

This fix regression in following qualification test cases:
GAP/SEC/AUT/BV-23-C
L2CAP/LE/CFC/BV-25-C
L2CAP/ECFC/BV-32-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-29 15:54:47 +00:00
Szymon Czapracki
6fd7b3bac6 bluetooth: audio: Fix TBS call stale state
This commits fixes a call staying in dialing state
after originate.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-03-29 15:52:32 +00:00
Manuel Arguelles
884e6b98f4 debug: arm64: add FPU context offset in thread info
When FPU is enabled for Arm64, the saved_fp_context must be tracked by
thread info to visualize correctly the FPU context of threads.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-03-29 09:28:57 -04:00
Dominik Ermel
fcef8bb781 mgmt/mcumgr/img_mgmt: Fix upgrade accepting equal version
As name suggest upgrade only should allow image upgrades onlu, but due
to greater or eqal sign used in version comparison, upgrade actually
also accepted current version.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-29 11:31:19 +02:00
Jamie McCrae
0cf14d5ae9 mgmt: mcumgr: transport: shell: Add optional input expiration
Adds an optional feature that can be used to time out a partially
received MCUmgr packet over the shell interface. Prior to this
change, if a header was received, then the whole shell would be
unavailable until the module is rebooted or additional full MCUmgr
packet was sent.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-29 11:30:55 +02:00
Jordan Yates
c6191858c3 pm: device_runtime: PM unsupported is not an error
Returning an error code when PM is not supported for a device only makes
writing drivers harder, as instead of checking for failures with `< 0`,
they also need to check for `-ENOTSUP`.

From the point of view of a driver, an `-ENOTSUP` return value is
equivalent to success, as if the device it is trying to turn on doesn't
support PM, by definition it is already enabled. This is equivalent to
the API behaviour when `CONFIG_PM_DEVICE_RUNTIME=n`.

Whether a device supports PM or not can still be determined at runtime
by inspecting the return code of `pm_device_runtime_enable` if
necessary.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-28 17:36:32 -04:00
Jordan Yates
2ef95ecd8f pm: device_runtime: balanced power domain operations
Only run `pm_device_runtime_put` on the dependent domain if the original
claim operation succeeded. This fixes unbalanced operations when running
```
pm_device_runtime_get(dev);
pm_device_runtime_put(dev);
```
On a device that does not have PM enabled but does have a power domain.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-28 17:36:16 -04:00
Szymon Janc
8fe734c7ac bluetooth: host: Add common helper for checking LTK presence
Both L2CAP and GATT have same requirements with regards to error code
on no encryption when LTK is or isn't present.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-28 16:15:58 +00:00
Szymon Janc
dc1ca29ca0 Bluetooth: host: Fix ATT error code on GATT authentication procedure
“Insufficient Encryption” shall be returned only if link is not
encrypted and proper LTK is present, otherwise “Insufficient
Authentication” shall be used.

Core Specification 5.4 Vol. 3 Part C 10.3.1

"If neither an LTK nor an STK is available, the service
request shall be rejected with the error code
“Insufficient Authentication”.
Note: When the link is not encrypted, the error code
“Insufficient Authentication” does not indicate that
MITM protection is required.
If an LTK or an STK is available and encryption is
required (LE security mode 1) but encryption is not
enabled, the service request shall be rejected with
the error code “Insufficient Encryption”."

This was affecting GAP/SEC/AUT/BV-11-C qualification test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-28 16:15:58 +00:00
Mariusz Skamra
6ba2839f6f Bluetooth: audio: ascs: Unbind endpoint in idle state
This moves duplicated bt_bap_iso_unbind_ep function call to
be handled when ASE enters BT_BAP_EP_STATE_IDLE state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
4d1f9973ed Bluetooth: audio: ascs: Fix double bt_bap_stream_detach call
This fixes possible double bt_bap_stream_detach() function call.
The bt_bap_stream_detach() called from ascs_ep_set_state
state BT_BAP_EP_STATE_IDLE handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
a6cdb12572 Bluetooth: audio: bap_stream: Remove reference to conn internals
This removes the usage of conn internal API in bap_stream.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
1abee09a8b Bluetooth: audio: Fix declaring conn type object in header file
The fact of having such extern in iso_internal.h forces the source files
that include this header to include conn_internal.h. This breaks the
encapsulation of conn object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
43d8e92bdd Bluetooth: audio: ascs: Fix ISO server listen incorrect behavior
This fixes incorrect behavior of ISO server listen that was not handling
the case of two endpoints sharing the same CIS/CIG and the endpoints
belonging to different connections.

Fixes: #51552
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
58de595c70 Bluetooth: audio: ascs: Register ISO server on ASCS init
This moves the ISO server registration to bt_ascs_init.
When the ASCS gets cleaned up (the callbacks are unregistered), the ISO
server gets unregistered.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
08aedc66dd Bluetooth: audio: ascs: Make use of SYS_SLIST_FOR_EACH_CONTAINER_* macros
This cleans up the code a bit by replacing the occurences of
SYS_SLIST_FOR_EACH_NODE with SYS_SLIST_FOR_EACH_CONTAINER(_SAFE)
so that the explicit CONTAINER_OF() usage is not needed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
710103db1d Bluetooth: iso: Add bt_iso_server_unregister function
This adds function that unregisters previously registered ISO server.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
f5b31c21a9 Bluetooth: audio: ascs: Fix Response_Code for mandatory opcodes
This fixes invalid Unsupported Opcode Response_Code that
happened to be sent in ASE Control Point notification
as the response to operation initiated with Mandatory opcode
to support.
When the Unicast Server callbacks are not registered, every
operation that is initiated by client will fail with
Unspecified Error instead.

Fixes: #56139
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
e9a878c072 Bluetooth: audio: ascs: Fix ASE leak if codec config failed
This fixes ASE that is not returned to pool when Codec Config
operation failed. The ASE is allocated in Codec Config operation
context. With this fix, if the operation failed to complete,
the ASE is returned back to the pool, so that it can be allocated
again by this or other client.

Fixes: #56138
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
5909a00a00 Bluetooth: audio: ascs: Minor refactor of ASE allocation
This removes redundant bt_ascs_ase_get_from_slab function and moves it's
functionality to ase_new(). It's sane, because the ASE shall be
allocated from ase_new() function context only.
bt_ascs_ase_return_to_slab() has been renamed to ase_free() to follow
the naming convention. Furthermore, few logs have been fixed/added.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
ee754fd020 Bluetooth: audio: ascs: Remove redundant check
The ID is ensured to be valid before ase_new() function is called, as
the client request is already validated.
On the other hand, if function is called from server initiated procedure
context, the assert shall occur as it indicates stack issue.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Mariusz Skamra
31aa555890 Bluetooth: audio: ascs: Cleanup ASCS on callback unregister
This adds cleanup of ASCS that is called when upper layer unregisters
it's callbacks. Without callbacks registered, the service is unusable.
The ASE's that were in non-idle state stay in this state, because the
implementation returns an error on every operation that is performed by
the client. The cleanup added moves all the ASE's to idle state.

Fixes: #56111
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-28 15:07:09 +02:00
Krzysztof Kopyściński
3322bdce10 Bluetooth: Mesh: fix blob_cli.c build with Clang
There should be logic OR, not bitwise OR in update_missing_chunks.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-28 15:06:44 +02:00
Krzysztof Kopyściński
fc2dcc4665 Bluetooth: Mesh: save stream mode in io_open()
Mode affects access to flash aread for `block_start`. When mode is set
to `BT_MESH_BLOB_READ` function return early, and because
`BT_MESH_BLOB_READ = 0` this is default behaviour. For write flash area
must be erased to allow driver to write there new data - bits can only
be pulled down, so overwrite will not be permitted.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-28 15:06:44 +02:00
Andreas Chmielewski
357181be23 net: lwm2m: Add is_suspended() routine
Add is_suspended() routine to have control over the rd client from the
outside whether it is suspended.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-03-28 15:06:15 +02:00
Théo Battrel
9c69f29d0d Bluetooth: Logging: Deprecate BT_DEBUG_LOG
Deprecate Kconfig symbol `BT_DEBUG_LOG`. With the new `BT_LOG` having
the same effect, `BT_DEBUG_LOG` is not useful anymore and shouldn't be
used.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-28 10:33:24 +02:00
Théo Battrel
af01a0f313 Bluetooth: Logging: Move all logging symbols together
Move all Kconfig symbols related to Bluetooth logging into the newly
created `Kconfig.logging`. The logging symbols are now grouped by into a
menu "Bluetooth logging". Closely related symbols are grouped with each
others. For example, audio related logging symbol are found behind a
submenu "Audio" inside the "Bluetooth logging".

The deprecated logging symbols have also been moved in a submenu of
"Bluetooth logging", it's easier to avoid them so.

Behavior of the Bluetooth logging system:

When `LOG` symbol is selected, if Bluetooth is enabled (`BT` symbol
selected), the Bluetooth logging is enabled.

If the user does not set any log level, the Bluetooth logging symbols
will inherit the log level of `BT_LOG_LEVEL`. If the user does not set
the level of `BT_LOG_LEVEL`, the default log level will be the one
defined by the logging subsystem. Which currently is `LOG_LEVEL_INF`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-28 10:33:24 +02:00
Alexander Svensen
674e23820f sd: Return ret if error in sdmmc_spi_read_cxd
- Check OCR when sending CMD58, reject if 0

Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
2023-03-28 09:23:47 +02:00
Aleksandr Khromykh
9011a067f2 Bluetooth: Mesh: split rpr cli ack ctx for provisionning and scanning
PR adds 2 acknowledgment contexts to RPR client to handle
scanning and provisioning in parallel.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-03-27 13:20:33 +00:00
Chris St John
1c0ade0051 Bluetooth: Audio: fix possible overflow in BASE LTV decode
Consistently process BIS data, codec data and codec metadata.
Range check count of data received so that buffer overflow cannot occur.

Signed-off-by: Chris St John <chris_st._john@bose.com>
2023-03-27 09:49:58 +02:00
Daniel Nejezchleb
6898094111 net: shell: Fix shell freeze
Adds clean up after failed ping from shell,
so it does not freeze the output.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-03-25 07:49:18 -04:00
Chris Friedt
ff2efd7ae5 net: socket: socketpair: remove experimental status
Socketpair functionality has matured enough to be used in a
consistent way now regardless of architecture or platform,
even on `native_posix`.

Remove the experimental status to reflect that.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-25 07:05:53 -04:00
Vinayak Kariappa Chettimada
ae5b424a2b Bluetooth: Host: Fix handling of incomplete data status adv reports
When receiving extended advertising reports with incomplete
data status, it is not necessary to mark for recovering from
currently assembled fragments, but rather drop them and
start a fresh assembly of subsequently received extended
advertising reports.

Timing changes in the Controller cause Periodic Advertising
PDUs AUX_SYNC_IND + AUX_CHAIN_IND to be placed between
primary channel ADV_EXT_IND and AUX_ADV_IND. This causes the
Controller to generate alternating incomplete and complete
data status reports, exposing the Host bug that is fixed in
this commit.

Relates to commit ba09a252ec ("bluetooth: host: refactor
bt_hci_le_per_adv_report data reassembly").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 17:36:32 +00:00
Emil Gydesen
dd5e476f86 Bluetooth: Audio: Shell: Add CAP Acceptor Set Member AD data
Add automatic adding of the CAP Acceptor Set Member AD data.

This also moves the CAP Acceptor service data into the
cap_acceptor.c shell implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-24 17:35:11 +00:00
Fabio Baltieri
5b36b4fa16 input: add a longpress device
Add an input device to take input key events as an input and generates
short press or long press devices as output.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-24 13:48:28 +00:00
Vinayak Kariappa Chettimada
b161c7fca4 Bluetooth: Controller: Fix ticker to reduce RTC min compare offset
Fix ticker to explicitly trigger worker when ticks_to_expire
is less than or equal to elapsed time.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 12:10:37 +01:00
Vinayak Kariappa Chettimada
925066ae1f Bluetooth: Controller: Continuous scan with ticks_slot_window
Use ticks_slot_window for continuous scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 11:32:42 +01:00
Vinayak Kariappa Chettimada
852b3e9e17 Bluetooth: Controller: Reschedule unreserved ticker with slot window
Update ticker implementation to reschedule unreserved ticker
that use ticks_slot_window.

This will avoid unreserved ticker from continuously
overlapping with reserved tickers. And the change is
required to reduce processing overheads before reserve
ticker timeout callback executes.

Unreserved tickers with ticks_slot_window will always yield
to any colliding reserved or unreserved tickers.

The implementation moves unreserved tickers (no ticks_slot
value, in this case continuous scan window) to end of a
colliding reserved/unreserved ticker so that reserved
tickers (like central role) do not have high overheads due
to unreserved ticker's prepare (scanner) be preempted
everytime before reserved ticker's prepare (central).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-24 11:32:42 +01:00
Emil Gydesen
b7e265265d Bluetooth: BAP: Do not allow start op when CIS is connecting
When the CIS is connecting we should not allow sending the
receiver start ready command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-24 09:17:07 +01:00
Anders Storrø
09a32928aa Bluetooth: Mesh: RPR cli @ mod elem 0 check
Add check to the Remote Provisioning Client model init call
that verifies that the model is located at the root element.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-03-23 15:43:29 +01:00
Johann Fischer
ad81b3b797 drivers: udc: move transfer status to buffer info structure
This allows us to get the result of synchronous transfer without
any hacks, just from the net_buf structure.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-03-23 10:08:03 +01:00
Emil Gydesen
6fc8ca7863 Bluetooth: iso: Add misisng bt_conn_unref in error cases
The ISO hci_le_cis_req event handler was missing
calls to bt_conn_unref and bt_iso_cleanup_acl to properly
clearn up the reference counters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Emil Gydesen
7ec4a6a19e Bluetooth: host: df: Add missing bt_conn_unref in error cases
Added missing bt_conn_unref where bt_conn_lookup_handle is
called, but where the function returns without providing the
conn pointer to the caller.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Emil Gydesen
317bd5af30 Bluetooth: Host: Missing unref for PAST sync_info
When we supply the conn pointer of the remote device that
provides the PAST information, we do a lookup on the
conn_handle using bt_conn_lookup_handle which takes a
reference count. This count is never dereferenced again.

This commit adds calls to bt_conn_unref to ensure that we
do not keep the reference count after the function
returns.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-23 08:56:07 +00:00
Jonathan Rico
c84fdfe438 Bluetooth: controller: fix kconfig dependency
BT_TICKER_EXT is being selected undiscriminately, but it's a Zephyr
controller feature.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-22 21:20:22 +01:00
Franciszek Zdobylak
3ff1e97367 fs: Fix Kconfig formatting
- use tabs instead of spaces in indentation
- use 2 spaces instead of tab in help message

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-03-22 13:52:07 +01:00
Szymon Janc
1ebb49eeee bluetooth: ascs: Fix NULL pointer dereference in ascs_ase_read
"The (ATT attribute read) callback can also be used locally to
read the contents of the attribute in which case no connection
will be set."

This means that callback may be called with NULL conn. Since
for ascs_ase_read NULL conn object have no meaning just return
error.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-22 13:51:58 +01:00
Mariusz Skamra
b8d441842a Bluetooth: audio: ascs: Add cleanup function
This adds ascs_cleanup() function guarded by ZTEST_UNITTEST. The purpose
of it is to clean up the ASCS between the tests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-22 11:39:18 +01:00
Omkar Kulkarni
a5057e96d1 bluetooth: mesh: Do not skip PDU forwarding on ADV
Fixes a bug where goto statement results into network layer skipping
the forwarding of unicast message on the ADV bearer, if the message
gets succesfully sent on the GATT bearer. This is undesirable. Node
has no knowledge of which external entity has which unicast address.
It may be possible that Proxy node can deliberately add unicast
addresses of other nodes to the whitelist to receive some traffic
for sniffing.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2023-03-22 11:38:51 +01:00
Magdalena Kasenberg
57784df5f0 LE Audio: Refactor server ASE callbacks to return rsp object
From now app layer is able to return explicit response code and
reason that will appear in ASE Control Point notification.

Fixes issues of ASCS/SR/SPE/BI-(07/08/09)-C PTS test cases, where
PTS was receiving wrong response codes and reasons.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-03-22 11:38:37 +01:00
Troels Nilsson
714d74b77b Bluetooth: controller: Use new ticker feature to get offsets
Updated the 3 places in extended advertising where the ticker was
previously inquired about the expiration of another ticker ID in a
separate mayfly (adv_aux, adv_sync and adv_iso). It will now use the
new ticker feature where another ticker IDs expiration info will be
added to the callback.

Channel map updates are now handled in ticker_cb and applied immediately
if the ticker is not running

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-03-22 08:57:37 +00:00
Troels Nilsson
e990ab941d Bluetooth: controller: Add option for ticker to return expiration info
It is now possible (via the extended ticker interface) to ask for
expiration information for another ticker ID to be returned in the
ticker callback. This utilises the extended ticker interface and a
callback function with a different context to keep the current ticker
interface as unchanged as possible.

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-03-22 08:57:37 +00:00
Pavel Vasilyev
08f4a82038 Bluetooth: Mesh: Remove deprecated health API
Deprecated Health client and server API has been deprecated for two
releases: 3.2.0 and 3.3.0.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-22 09:35:01 +01:00
Ahmed Moheb
fac21b3616 tests: bluetooth: host: Add UT for bt_pub_key_gen()
Unit test project for bt_pub_key_gen().
This is part of subsys/bluetooth/host/ecc.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Ahmed Moheb
3c76bd06e4 tests: bluetooth: host: Add mocks for ecc.c
Add required mocks to be able to compile/test /bluetooth/host/ecc.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-03-22 09:33:42 +01:00
Théo Battrel
483126f492 Bluetooth: Host: Move new bt_data functions to data.c
Move newly added `bt_data_get_len` and `bt_data_serialize` from `ead.c`
to `data.c`.

Also, removed unnecessary include of `zephyr/kernel.h`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-21 18:17:52 +00:00
Robert Lubos
dc8f023098 net: ipv6: Fix Kconfig dependencies when native IPv6 is disabled
In case native IPv6 is disabled, Kconfig entries related to native IPv6
stack should not be enabled. Otherwise, circular dependencies can be
created if native stack is disabled, as in case of recent changes in
NET_IPV6_RA_RDNSS option (where a dependency for a native stack module
was enabled).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-21 18:11:06 +00:00
Théo Battrel
a693b9b33b Bluetooth: Host: Add Encrypted Advertising Data
Create a new Bluetooth library and add Encrypted Advertising Data to it.

Encrypted Advertising Data is a new feature from the Bluetooth Core
Specification 5.4. It provides a way to communicate encrypted data in
advertising, scan response and EIR packets. To do that it introduce a
new advertising data type called `Encrypted Advertising Data`. Also, it
introduce a new characteristic called `Encrypted Data Key Material`,
this provides a way to share the key material.

The library add two main functions `bt_ead_encrypt` and
`bt_ead_decrypt`.

Two helper functions are added to `bluetooth.h`. `bt_data_get_len` and
`bt_data_serialize`, the first one allow the user to get the total size
of a set of `bt_data` structures; the second one generate a spec
compliant bytes array from a `bt_data` structure. The last one is useful
because `bt_ead_encrypt` take as input those kind of bytes array.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-03-21 13:39:09 +02:00
Vinayak Kariappa Chettimada
643723479f drivers: flash: nRF: Move sync ticker to Subsys Bluetooth Controller
Move the SoC Flash nRF sync ticker implementation into
Bluetooth Controller Subsystem folder, as internal headers
are included.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-21 12:33:32 +01:00
Vinayak Kariappa Chettimada
b9f9f1ba9c Bluetooth: Controller: Refactor CMakelists.txt for consistency
Refactor the Bluetooth Controller's CMakelists.txt to
consistently use zephyr_library_sources_ifdef() and
zephyr_library_include_directories_ifdef().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-21 12:33:32 +01:00
Mariusz Skamra
fef4c4e7ea Bluetooth: audio: ascs: Fix ASE release from QoS configured
This fixes ASE release from QoS configured state.
The `ops->released` callback was not called and the `bt_ascs_ase`
was not returned to the pool, because `stream` object was already
detached.

Fixes: #55900
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:38:16 +01:00
Mariusz Skamra
1ece7a6779 Bluetooth: audio_ ascs: Fix possible dereference of free'd ASE
This fixes possible dereference of free'd bt_ascs_ase object.
The ASE without ISO connection that goes to Releasing state will be
automously transitioned to Idle state. Thus, the `ase` object might not
be vaild anymore.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:38:16 +01:00
Mariusz Skamra
14bd189f00 Bluetooth: ascs: Fix ASE Codec Config PDU length validation
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.

ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
 length operation if the total length of all parameters written by the
 client is not equal to the total length of all fixed parameters plus
 the length of any variable length parameters for that operation"

Fixes: #55747
Fixes: #55748
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-21 09:37:40 +01:00
Joel Guittet
b6df4ec388 hawkbit: check mcuboot header version
Checking mcuboot header version prior to use the content of the header
structure.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2023-03-21 09:35:26 +01:00
Joel Guittet
a3d7fdafd6 hawkbit: fix memory issue with mcuboot_img_header size
Fix a memory issue when calling boot_read_bank_header the length should be
the size of `struct mcuboot_img_header`.
Fixes #54459.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2023-03-21 09:35:26 +01:00
Emil Gydesen
c97fa8fda3 Bluetooth: Audio: CAP initiator streamline procedure states
Add new helper functions to increase readability and to
ensure correctness when aborting procedures.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
3186fce98e Bluetooth: Audio: Shell: Use same streams and group for BAP and CAP
Use the same unicast streams and group for the BAP and CAP
shell commands. This results in maximum flexibility, as well
as the niceness of use from CAP, as well as less memory usage.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
3ab925ecef Bluetooth: Audio: CAP Initiator handle unexpected ASE changes
When performing the CAP Unicast Start procedure, the remote
server(s) may change the state of the ASE before the procedure
is complete.

If the state change is unexpected, we stop the procedure and
call the callback, and then the caller can decide what to
do after that (presumably call the stop procedure for the
streams that may be setup).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
90537df38a Bluetooth: Audio: Add CAP unicast stop shell command
Add shell command for the CAP unicast stop procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
9ce647ba79 Bluetooth: Audio: Implement CAP unicast stop procedure
Implements the CAP unicast stop procedures, which is used
to stop (either disable or release) multiple streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
67925d397a Bluetooth: Audio: Add CAP unicast update shell command
Add shell command for the CAP unicast update procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
f7f69b6ff0 Bluetooth: Audio: Implement CAP unicast metadata update
Implement the CAP unicast metadata update procedure.

The procedure lets an application update the metadata of one
or more CAP streams in a single function call, while also ensuring
that the provided metadata follows the requirement from CAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
6866cd30e8 Bluetooth: Audio: Add support for CAP unicast start in shell
This modifies the audio.c shell module to support
multiple connections.

This adds support for the cap_initiator unicast-start command,
which supports multiple endpoints on multiple devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Emil Gydesen
b71f9f2702 Bluetooth: Audio: Implement CAP unicast audio start
Implement the CAP unicast start procedure, which
will put one or more CAP streams from the idle state
to the streaming state, across or more ACL connections.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-21 09:35:05 +01:00
Fabio Baltieri
9889e8e20a input: move the listener section in common-rom
Move the input listener section declaration in common-rom-misc.ld
instead of using a custom input.ld file. This seems to be the common
practice for upstream iterable sections and seems to solve a
compatibility issue where the section was getting allocated incorrectly
on esp32 based platforms.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-20 12:56:18 -07:00
Krzysztof Chruscinski
369ffb4929 hal_nordic: Add protection against resource conflict (take 2)
Commit will be squeezed once agreement is reached.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Krzysztof Chruscinski
5af49c1e35 hal_nordic: Add protection against resource conflict
Add check in CMake files to prevent resource overlap for
TIMER0, TIMER1, RTC0.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Krzysztof Chruscinski
9a73b9c80d hal_nordic: Change scheme for RTC and TIMER reservation
In general, RTC and TIMER driver implements counter API but there
are exception when those peripherals are used in a custom way
(e.g. for system timer or bluetooth). In that case, system must
prevent using counter based on a reserved instance. Previously,
it was managed by Kconfig options but that cannot be maintained
when switching to devicetree configuration of the counter driver.

A new approach removes Kconfig options and instead adds static
asserts in the files which are using direct peripherals. Those
asserts check if given node is not enabled in the device tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-20 16:59:40 +01:00
Robert Lubos
66ae9153a6 net: sockets: Fix SO_SNDTIMEO handling
The TX timeout configured with SO_SNDTIMEO on a socket did not work
properly. If the timeout was set on a socket, the TX would work as if
the socket was put into non-blocking mode. This commit fixes this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Robert Lubos
616797c429 net: sockets: Add helper function for recalculating remaining timeout
The timeout recalculation logic was duplicated across several routines,
therefore it makes sense to make a helper function out of it,
especially, that the same functionality would be needed for the send
routines.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Robert Lubos
e67374e47a net: tcp: Rework TCP SO_RCVBUF/SO_SNDBUF option handling
SO_RCVBUF option processing at the TCP level was broken. The option
value was only checked once, when the TCP context was allocated. This
made little sense, as at this point the option would not even get a
chance to have custom value. If the user modified the option after the
socket (net_context) was created, it had no effect on the TCP operation.

This commit fixes this, by checking the option value whenever new packet
is processed, so that the configured window size is updated at the TCP
level before we report it in the TCP ACK. In order to achieve this,
introduce a new helper function, to refresh the configured window sizes,
to avoid bloating `tcp_in()` even further.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Sebastian Panceac
2e7c02bef6 Bluetooth: pairing: OOB: Separate LE SC OOB from legacy OOB logic
Some systems can support only legacy OOB pairing while others only
LE SC OOB pairing.

The existent API function "bt_set_oob_data_flag" was removed.

Two new API functions were added:

 * "bt_le_oob_set_legacy_flag" to signal that legacy OOB pairing is used
 * "bt_le_oob_set_sc_flag" to signal that LE SC OOB pairing is used

The code will now advertise the presence of OOB flag depending
on the type of pairing method(SC vs legacy)

Signed-off-by: Sebastian Panceac <sebastian.panceac@ext.grandcentrix.net>
2023-03-20 16:13:18 +01:00
Krzysztof Kopyściński
8194c34669 Bluetooth: Mesh: allow user to define BLOB ID for bt_mesh_dfu_cli_send
User can now use self-defined BLOB ID for transfer instead of using
random one each time. This allows to send multiple FW Update Start
messages with same BLOB ID, for example to resume previous one.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Krzysztof Kopyściński
b0e91368a2 Bluetooth: Mesh: fix FW Update procedure recovery on on DFU Server side
If device rebooted while in `BT_MESH_DFU_PHASE_TRANSFER_ACTIVE` phase
we should not recover into it, but set `BT_MESH_DFU_PHASE_TRANSFER_ERR`
instead. It's because we no longer remember which block is currently
transfered so new FW Update Start must be received and transfer
restarted.

If device rebooted while in `BT_MESH_DFU_PHASE_VERIFY_OK` it means
we didn't manage to apply image before reboot. We should enter
`BT_MESH_DFU_PHASE_VERIFY_FAIL` phase, which will allow to verify it
again and possibly apply. This is with agreement to specification
regarding receiving FW Update Start when FW is already received.

This commit also alligns handle_start with specification: when
FW is already received, we should set phase to
`BT_MESH_DFU_PHASE_VERIFY`, send Status message, then proceed to Verify.
Previously, `verify` was called before sending status, so status
contained phase set to `BT_MESH_DFU_PHASE_VERIFY_OK` or
`BT_MESH_DFU_PHASE_VERIFY_FAIL`. This would prevent DFU Client
enter refresh procedure.

`blob_recover` also expects BT_MESH_DFU_PHASE_TRANSFER_ERR now.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Krzysztof Kopyściński
51ff3e630b Bluetooth: Mesh: Do not transfer FW to targets in Verify Phase in DFU
These targets already received FW so there is no point to transfering
it again. What's more, these targets will not accept transfer and will
be dropped by DFU Client. If FW is already received DFU Client should
skip transfer and proceed to refresh procedure.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-20 13:38:40 +01:00
Emil Gydesen
b011c1e36c Bluetooth: BAP: Add missing Unicast client CB NULL check
Add missing check before calling unicast_client_cbs->release.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-20 13:38:33 +01:00
Krishna T
36c46afbb9 net: zperf: Make Zperf worker thread stack size configurable
All stack sizes should be configurable for memory adjustements.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 10:20:00 +00:00
Krishna T
d6e54a417a net: zperf: Make Zperf worker thread priority configurable
This helps us test impact of scheduling on traffic.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 10:20:00 +00:00
Emil Gydesen
c8e1b1e264 Bluetooth: Audio: Move audio shell to audio directory
Move all audio related shell implementations to the
audio directory, to use the same structure as Mesh.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-20 09:53:34 +01:00
Georges Oates_Larsen
3c6b7dc35a net: dummy L2 for offloaded ifaces
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-03-20 09:53:25 +01:00
Krishna T
5e6c733006 net: wifi: Use a macro for TWT wake interval
Remove the magic number 255, esp. now that we support 262.144ms.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Krishna T
65aae9cbfb net: wifi: Use micro seconds for precision for TWT intervals
In order to take granular input use micro seconds as input for TWT
intervals, this helps us in providing inputs such as 65.28ms without the
need of using floating points.

This also expands the TWT wake interval range to 262.144ms, earlier as
we want to use uint8, limited to 256ms.

Also, remove the units from the variable names, this is unnecessary and
also avoids doing breaking changes.

Update release notes as this is a breaking change, both type and
variable names are changed.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Aleksander Wasaznik
20d747815d Bluetooth: Shell: Remove ad-hoc CHAR_SIZE_MAX
Remove ad-hoc `CHAR_SIZE_MAX` in favor of `BT_ATT_MAX_ATTRIBUTE_LEN`.
The maximum size of an attribute is the same as the maximum size of a
characteristic.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-20 09:51:24 +01:00
Aleksander Wasaznik
6b6178be30 Bluetooth: Shell: Make gatt notify more general
Make `gatt notify` take the source handle and the data to send.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-20 09:51:24 +01:00
Dominik Ermel
abb93d4089 fs: Prevent mounting file system re-using private data
The commit changes the fs_mount to not allow mounting same system,
with the same private data pointer, at two different mount paths.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-20 09:51:10 +01:00
Tom Burdick
610d307fa0 rtio: Properly track last sqe in the queue
The pending_sqe logic to track where in the ring queue the concurrent
executor had left off was slightly flawed. It didn't account for starting
all sqes in the queue and ending back up at the beginning.

Instead track the last SQE in the queue, from which the next one in the
queue will the one to start next.

If we happen to sweep the last known SQE in the queue, reset it to NULL
so the next time prepare is called we start at the beginning of the queue
again.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-17 12:49:57 -05:00
Tom Burdick
3353342e5f rtio: Add transactional submissions
Transactional submissions treat a sequence of sqes as a single atomic
submission given to a single iodev and expect as a reply a single
completion.

This is useful for scatter gather like APIs that exist in Zephyr already
for I2C and SPI.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-17 12:49:57 -05:00
Vinayak Kariappa Chettimada
de9579f297 Bluetooth: Controller: Implement CIS abort_cb to flush tx/rx
Implement a custom abort_cb callback to perform Tx and Rx
flush and adjust the SN/NESN values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:07:09 +01:00
Vinayak Kariappa Chettimada
0d54ca8761 Bluetooth: Controller: Fix ull_prepare_dequeue for skipped events
Fix ull_prepare_dequeue to not skip events when preempt
does not match the event in the head of the prepare queue.
The head of the prepare queue does not match when
ull_prepare_dequeue has put the head of the queue to the
last of the queue when it is calling lll_resume interface.
This happens when there is already an active event which
needs a preempt timeout to be setup and there is another
non-resume event in the pipeline which now becomes the
head. The fix ensure to restore the order of the events
if a preempt timeout was to be setup.

Currently ull_prepare_dequeue loops through all events
before stopping at the original way the queue was. This is
not efficient and is a scope for improvement in future.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:06:54 +01:00
Vinayak Kariappa Chettimada
ceaddc81db Bluetooth: Controller: Fix connected ISO time reservation calculation
Fix Connected ISO time reservation that was missing the
event start and end overhead values.
Fix missing event end overhead values in ACL connection
time reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 16:06:32 +01:00
Morten Priess
00c9580914 Bluetooth: controller: Fix offset for CIG with CISes in different ACLs
Calculate CIS offset of secondary CIS(es) using CIG reference point.
This fixes issue with e.g. two CISes associated with separate ACL
connections.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-03-17 16:06:18 +01:00
Morten Priess
b8c7506681 Bluetooth: controller: Keep CIS/CIG instances until ll_cig_remove
This commit enables having multiple CIS/CIG setups/connects and
teardowns in sequence.

- For central, cig->lll.num_cis is initialized to cis_count and
  untouched until ll_cig_remove. The value shall indicate number of
  allocated instances, to ensure correct CIG traversal.
- Keep CIG/CIS instances for central until ll_cig_remove
- Initialize CIS instance state vars in ll_cis_create, similar to the
  peripheral flow.
- In ll_cig_remove, always release streams and CIG instance. Do not
  remove paths, as this is done from host at bt_iso_chan_disconnected.
- Remove unsued cis_count member in ll_conn_iso_group.
- Use correct function ull_iso_lll_ack_enqueue at LLL flush to have
  data path respected.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-03-17 16:06:18 +01:00
Andries Kruithof
4215854956 Bluetooth: controller: remove refs to LLCP_LEGACY after rebase
Some recent PRs included conditional compilation for
KCONFIG_BT_LL_SW_LLCP_LEGACY, which must be removed.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
e6a3def17b Bluetooth: controller: remove dependency for slot reservation
The slot reservation code is only valid for the refactored LLCP;
a guard was in place to ensure that it was not compiled in for
legacy controller code. This commit removes this guard

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
729c3e3d83 Bluetooth: controller: remove code related to advanced scheduling
This commit removes the code related to advanced scheduling from
ull_sched.c, since this code only works for the legacy controller.
Implementing advanced scheduling for the refactored LLCP is tracked
in its own issue

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
f6172f3159 Blueotooth: controller: removed delayed notification code
The code that was added for delaying notifications to the host,
which was only implemented for legacy controller, is removed
in this commit

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Andries Kruithof
2ada005d7c Bluetooth: controller: removing legacy LLCP code
This commit removes the legacy LLCP code including the
Kconfig option
It also updates the babblesim tests, and removes the
tests for the legacy controller

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-17 15:05:05 +01:00
Emil Gydesen
70e4e73998 Bluetooth: BAP: Shell: Fix problems with codec and qos config
The copying from the presets to the stream codec and qos
structs were not done in a way that worked. Fixed by doing
a more proper and deeper copy.

This also fixes a small issue with using the wrong
default preset.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 14:19:42 +01:00
Pavel Vasilyev
cf5ea49d23 Bluetooth: Mesh: Fix registering GATT Proxy service after reboot
After commit 3486f133e9
GATT Proxy service registration is broken because it is registered from
settings_load() in mesh_commit(). Because mesh_commit() is called before
sc_commit() is called in gatt.c, bt_gatt_service_register() can't be
called yet.

Use k_work to postpone the service registration.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-17 14:19:15 +01:00
Andrei Emeltchenko
e5091db1ad bluetooth: audio: Fix using wrong function check
Correct function check before calling it.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-17 14:18:57 +01:00
Emil Gydesen
d0b0bb43d3 Bluetooth: BAP: Remove BT_BAP_UNICAST_CLIENT_PAC_COUNT
The BT_BAP_UNICAST_CLIENT_PAC_COUNT is there due to a merge conflict
gone wrong. Removed again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 14:18:48 +01:00
Vinayak Kariappa Chettimada
1f52e70fe2 Bluetooth: Controller: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values, when computing and comparing
against unsigned variables.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Vinayak Kariappa Chettimada
9b3a3ee79b Bluetooth: Controller: Add additional LE Channel Selection tests
Add additional custom LE Channel Selection #2 tests to cover
event and subevent mapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Vinayak Kariappa Chettimada
c3e6edd402 Bluetooth: Controller: Remove redundant use of local variable
Remove redundant use of local variable chan_idx in the
lll_chan_iso_subevent() function.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-17 11:48:26 +01:00
Henrik Møller
86757f5ae5 Bluetooth: controller: Fix channel selection
For ISO-subevents channel selection must use remap table always
-regardless of channel is a mapped or unmapped channel.

Signed-off-by: Henrik Møller <heml@demant.com>
2023-03-17 11:48:26 +01:00
Emil Gydesen
64143fc881 Bluetooth: BAP: unicast released callback only after CIS disconnect
Ensure that the stream released callback is only called after
the CIS has disconnected. Since the ACL disconnect event
may come before the CIS disconnect event, we use the
unicast_client_ep_idle_state in the unicast_client_reset
function to use the existing state verification, and only
after both the ACL and CIS has disconnected, we
finalize the reset of the stream and call the released
callback, assuming that the CIS can be disconnected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:31:06 +01:00
Emil Gydesen
bb43c05dc8 Bluetooth: ISO: Set missing CIS disconnecting state
The BT_ISO_STATE_DISCONNECTING was never set when the
CIS was actually in the disconnecting state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:31:06 +01:00
Emil Gydesen
38095f8818 Bluetooth: BAP: Shell: Delete uni group when all streams released
Previously we assumed only a single stream, and deleted
the unicast group on the first stream released.

Now we wait for all the streams to be released before
deleting the group.

This still assumes that all streams are initiated by us
as the client, and will not work if using the
BAP unicast client and server role concurrently.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:58 +01:00
Emil Gydesen
cf737b510e Bluetooth: BAP: Remove bad LOG_ERR from unicast client
Remove a bad LOG_ERR that should never have been merged.

Added the valuet that was logged to the debug log statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:17 +01:00
Emil Gydesen
ed1cc603a7 Bluetooth: BAP: Fix bad ASSERT in ASCS disconn stream handler
The conditions of the assert were incorrect compared to the
text, and caused an assert to happen when it shouldn't.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-17 09:30:09 +01:00
Kumar Gala
831bd2f841 armclang: fix compiler warnings with isprint()
We get compile warnings of the form:

drivers/console/uart_console.c:508:8: error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint returns an int, change check to an explicit test against
the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-17 09:30:01 +01:00
Gregory Shue
5623f54a35 fff: Add fff_extensions.h, RETURN_HANDLED_CONTEXT()
Add supplementary header <zephyr/fff_extensions.h>.  Add macro
to fff_extensions.h for simplifying definition of custom fake functions
needing call-unique information for producing desired output data.
When an array of custom fake context structures is defined and
the return field within the first structure instance is registered
with the standard SET_RETURN_SEQ() macro of FFF, the
RETURN_HANDLED_CONTEXT() macro provides the inverse logic to
recover the context structure for this called instance. The body of
the custom fake handler is provided to the RETURN_HANDLED_CONTEXT()
macro for appropriate execution and access to the custom fake
parameters.

A test suite is also provided to verify macro implementation and
illustrate usage. It is at:
zephyr/tests/subsys/testsuite/fff_fake_contexts/

This code was verified by:

1. (Pass) west build -p always \
            -b unit_testing tests/subsys/testsuite/fff_fake_contexts/ && \
         ./build/testbinary
2. (Pass) west build -p always \
            -b native_posix tests/subsys/testsuite/fff_fake_contexts/ && \
         ./build/zephyr/zephyr.exe
3. (Pass) ./scripts/twister -p unit_testing \
            -T tests/subsys/testsuite/fff_fake_contexts/
4. (Pass) ./scripts/twister -p native_posix \
            -T tests/subsys/testsuite/fff_fake_contexts/
5. (Pass) cd doc && build html-fast

Fix #55246

Signed-off-by: Gregory Shue <gregory.shue@legrand.com>
2023-03-16 13:43:33 -04:00
Pavel Vasilyev
3e14c13d8d Bluetooth: Mesh: Use default provisioning protocol timeout in RPR Client
The timeout used upon opening the link with the server relates to the
PB-Remote Link Open procedure, but not to the whole provisioning
procedure. For the provisioning procedure, the timeout should be at
least 60 seconds as explained in section 5.4.4.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Pavel Vasilyev
e9a20cc3b6 Bluetooth: Mesh: Restart timer after sending PDU to RPR Server
This commit fixes an issue where the RPR Client gets stuck after sending
PDU to RPR Server (even with segmented flag), but doesn't hear anything
back from the server.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Pavel Vasilyev
3a0fa866e4 Bluetooth: Mesh: Fix timeout handling on link opening in RPR Client
This commit fixes an issue, where the RPR Client gets stuck forever
until reboot if it doesn't receive Link Status or Link Report message
when openinig the remote provisioning link.

The RPR_CLI_LINK_OPEN flag was used to control the remote provision link
and protect against receiving an unexpected message, but it didn't cover
a case when neither of messages were received from the RPR Server.
cli->link.state only changes by Link Status or Link Report message and
is set to BT_MESH_RPR_LINK_IDLE when opening the link. Therefore, when
the RPR Client's timer timed out, the client didn't reset its internal
states.

This commit adds an additional state to cover this intermediate state
when the client initiated the link opening but didn't receive any
response.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-16 16:42:24 +01:00
Tomáš Beneš
14138d4a34 Bluetooth: Controller: Add coexistence implementation
To enable Bluetooth controller coexistence feature, there is
implementation of ticker task, which aborts any ongoing radio events
during assertion of the grant pin. This solves the co-existence issue
in the role of the subordinate transceiver.

Signed-off-by: Tomáš Beneš <tomas@dronetag.cz>
2023-03-16 14:37:55 +01:00
Vinayak Kariappa Chettimada
947ef4c96b Bluetooth: Controller: Remove redundant EVENT_IFS_US in BIS timing
Remove redundant EVENT_IFS_US used in Control PDU timing
calculation. The BIG radio event ends with Control Subevent
and hence there is no need to add EVENT_IFS_US at the end
of the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-16 13:39:03 +01:00
Vinayak Kariappa Chettimada
ca44b34994 Bluetooth: Controller: Fix ISO Sync Receiver reception abort
Fix ISO Sync Receiver PDU reception to enqueue towards ULL
any PDUs that where received before the BIG event in
unreserved timespace is aborted due to overlap with other
radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-16 13:38:48 +01:00
Jonathan Rico
169270e911 Bluetooth: host: downgrade select log messages
In the case of a constrained system that uses dynamic channels (ie, not
much initial credits), the user's log would be flooded with those three
messages.

This is not really an error per se as the stack will handle it properly and
reschedule the sending of the buffers as soon as more credits arrive.

Thus downgrading the severity of
- the l2cap messages, as they are only compiled when dynamic channels are
enabled
- the conn message. Reporting the error belongs in the upper layers.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-16 12:56:48 +01:00
Luca Fancellu
6748d588ab net: zperf: allow TCP receiver to handle multiple connections
Currently the zperf_tcp_receiver can handle only one TCP connection
each time, modify the code to poll and handle multiple connections.

Take the occasion to unify the bind and listen part of the code
between ipv4 and ipv6 part using a structure introduced to handle
the multiple connections.

Now in case the zsock_recv fails, we can't stop every connection
and fail through the error label, so just print the error message
and report the failure through the callback.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-03-16 12:56:10 +01:00
Luca Fancellu
d485ef0231 net: zperf: Reduce the scope of input address variables
Reduce the scope of in4_addr_my and in6_addr_my pointer variables
that are currently global, but they are used only inside
tcp_receiver_thread.

Take the occasion to fix a typo in one error message.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-03-16 12:56:10 +01:00
Emil Gydesen
ac5e4fea90 Bluetooth: Audio: Unicast Client Log more of QoS pref
Add logging of some missing fields of the QoS preference
we receiver from the unicast server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 12:55:50 +01:00
Mariusz Skamra
871db2d277 Bluetooth: Move bt_data_parse to dedicated source file
This moves bt_data_parse function outside of hci_core.c.
Having it in separate file makes unit testing easier as the
function do not use kernel objects, thus can be used in unit tests
without a need for adding any mocks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-16 11:46:36 +01:00
Emil Gydesen
61559bfe3a Bluetooth: Audio: Explicit stream type of unicast client group stream
Make it more explicit that the streams that the value covers are CIS
and not BAP streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 11:46:20 +01:00
Wolfgang Puffitsch
b525db221c Bluetooth: controller: Avoid the use of weak functions for ISO data path
Avoid the use of weak functions and call the respective functions only
if vendor-specific data path is supported. The weak dummy functions
will not implement the desired behavior anyway. This change makes it
explicit that these functions need to be implemented by the vendor.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2023-03-16 11:46:05 +01:00
Emil Gydesen
f7cf252a8c Bluetooth: Audio: Add special handling of release cp notification
When releasing a stream as the unicast client, we may get
either the ASE state notification with state idle or
the control point notification first. If we get the
ASE state notification first, we pretend we get the
CP notification first, and call the release callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
88644a775c Bluetooth: Audio: Shell: Add unicast client operation callbacks
Add the unicast client operation callbacks to the shell, simply
printing the values sent by the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
68fa04788a Bluetooth: Audio: Add unicast client cp notify callbacks
Add callbacks for control point notifications sent by the
unicast server. These will allow the upper layers to know
if and why a specific operation failed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Emil Gydesen
a2057cde3c Bluetooth: Audio: Fixed naming of invalid length ASCS response
The "Invalid Length" response code was called truncated,
which does not match the spec definition.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-16 09:18:00 +01:00
Nirosharn Amarasinghe
b1fe487bb1 Bluetooth: controller: Release of padding PDUs for framed production
Implemented:
-- Released framed padding PDUs when data received in SDUs for a given
   event do not fully utilise BN.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-03-16 09:17:19 +01:00
Kumar Gala
0342deb5d9 Bluetooth: Mesh: Fix compiler warning
When building with an LLVM toolchain get the following warning:

bluetooth/mesh/pb_adv.c:774:4: error: expression which evaluates to zero
treated as a null pointer constant of type
'void *' [-Werror,-Wnon-literal-null-conversion]
                        PROV_BEARER_LINK_STATUS_SUCCESS);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by adding a cast to (void *).

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-16 09:15:38 +01:00
Anders Storrø
ce3557a958 Bluetooth: Mesh: Add SAR srv persistence storage
Adds persistent storage for SAR server RX and TX set cmd parameters.
Also ensures that SAR RX and TX parameters are set back to default values
upon reset of the mesh device.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-03-15 15:20:35 +01:00
Andrei Emeltchenko
7e63be14c3 bluetooth: shell: Fix NULL dereference
Fix NULL dereference when dereferencing txing_stream, which was used
instead of default_stream.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-15 15:03:12 +01:00
Jun Qing Zou
aae379f245 net: mqtt: Debug logging of pointers
Cast pointer to `void *` for `%p` parameter.
Otherwise lots of warnings in the log like below:

 `<wrn> cbprintf_package: (unsigned) char * used for %p argument.
 It's recommended to cast it to void * because it may cause
 misbehavior in certain configurations. String:"%s: (%p): >>
 length:0x%08x cur:%p, end:%p" argument:3`

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-03-15 15:02:47 +01:00
Vinayak Kariappa Chettimada
11ad5bf92c Bluetooth: Controller: Inherit BT_ISO_TX_BUF_COUNT value
Inherit BT_ISO_TX_BUF_COUNT value when BT_ISO is enabled
to set BT_CTLR_ISO_TX_BUFFERS count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-15 08:49:42 -04:00
Vinayak Kariappa Chettimada
c22f40a358 Bluetooth: Controller: Fix max PDU len radio config for BIS Ctrl PDUs
Fix missing radio configuration that limits the maximum PDU
len on reception to consider that Control PDU can be larger
than the max PDU size in the BIS parameters.
Use dedicated PDU buffer for transmission and reception of
BIG Control PDUs so that it is independent of maximum ISO
PDU length which can be less than BIG Control PDU length.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-15 08:49:42 -04:00
Mariusz Skamra
0b7a335864 Bluetooth: ascs: Fix uninitialized stream object
This fixes "Conditional jump or move depends on uninitialised value(s)"
error seen in valgrind.
The stream object that is allocated by application has to be initialized
as it may contain invalid data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 11:38:11 +01:00
Mariusz Skamra
b5465825f1 Bluetooth: ascs: Remove duplicated logic
The ase_stream_add does the same job as bt_bap_stream_attach that is
called right below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 11:38:11 +01:00
Ludvig Samuelsen Jordet
53091c5056 Bluetooth: Mesh: Fix confusing DFU slot doc
The word "valid" is already in use to mean slots that return true for
`bt_mesh_dfu_slot_is_valid`, whereas `bt_mesh_dfu_slot_foreach` iterates
over all added slots.

Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
2023-03-15 11:19:18 +01:00
Mariusz Skamra
5862c8263b net: buf: Factor out net_buf_simple to separate source file
This moves net_buf_simple related code to separate source file.
Having those in separate file makes unit testing easier as simple
network buffers do not use kernel objects, thus can be used
in unit tests without a need for adding any mocks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 10:50:16 +01:00
Mariusz Skamra
4a1d0782cb net: buf: Fix using incorrect logging macro
As there is dedicated NET_BUF_SIMPLE_* logging macros set,
NET_BUF_SIMPLE_DBG shall be used in this place instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-15 10:50:16 +01:00
Emil Gydesen
5704b83ea7 Bluetooth: Audio: Shell: Add location to cmd_config
Add support for setting the location value
(BT_CODEC_CONFIG_LC3_CHAN_ALLOC) in the codec configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
a02a1c19a1 Bluetooth: Audio: Shell: Refactor set_preset
The function is now called get_named_preset and only
returns a named preset. The QoS parameter handling
has been moved to a new function, cmd_stream_qos,
which can be used to set specific QoS for a stream.

The get_named_preset does also no longer set the default
preset, and cmd_preset must be used for that now.

This means that a function like cmd_config no longer
has any side effects, thus making it easier to set up
multiple streams with different presets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
b9a4deb429 Bluetooth: Audio: Shell: Replace hacky metadata handling
The hacky handle_metadata_update that copied the metadata to
a variable, since stream->codec->meta could not be modified,
has been replaced with a proper solution now that
stream->codec->meta can be modified.

It still only supports settings the streaming context, but
it is much easier to expand now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
2638a04214 Bluetooth: Audio: Shell: Make BAP shell presets constant
Make the BAP shell presets constant. This reflects more
what they represent, and make it not only possible, but also
easier, to modify the individual streams QoS and Codec
configurations, without affecting other streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Emil Gydesen
3588706d1a Bluetooth: Audio: Shell: Rename streams to unicast_streams
The streams array only contained unicast streams, and
the name should reflect that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-15 09:12:33 +01:00
Jonathan Rico
b23c330c63 Bluetooth: host: shrink bt_l2cap_le_chan size
Most of this struct is bookkeeping for the dynamic channels.
This isn't needed for e.g., a simple peripheral using GATT.

With a peripheral_hr build for nrf52840dk_nrf52840, we save
280 bytes of RAM.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-15 09:11:33 +01:00
Stig Bjørlykke
6862fdea1a net: dns: Check existing DNS servers before reconfigure
In dns_resolve_reconfigure() check if the DNS servers already exist
before cancel all ongoing queries. This will solve an issue with
getaddrinfo() returning DNS_EAI_CANCELED when receiving a retransmitted
DHCP offer and when receiving a IPv6 Router Advertisement.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-03-14 12:27:15 -04:00
Ajay Parida
43bd60a13a net: wifi_mgmt: Send TWT sleep status event to app
Send TWT sleep status(sleep/awake) event to the apps registered
for event.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-14 10:49:30 +01:00
Tomasz Bursztyka
8c89566993 subsys/disk: No need of runtime intialization for disk access part
Mutex and double-linked list can be statically initialized.

This removes a little bit of boot time overhead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-03-13 18:34:40 +00:00
Vibhor Meshram
4684006f1b Bluetooth: Audio: Remove "Input" from MICP naming
Removed "Input" from Microphone Input Control Profile.
Release notes kept unchanged.

Signed-off-by: Vibhor Meshram <vibhor69meshram@gmail.com>
2023-03-13 18:34:09 +00:00
Emil Gydesen
e80eca0239 Bluetooth: Audio: Shell: Add automatic receiver ready for server
When a stream for a sink ASE goes into the enabled
state we automatically execute the receiver start ready
operation as the unicast server.

This makes the shell easier to use as the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-13 14:04:33 +01:00
Aleksander Wasaznik
6648da731b Bluetooth: Host: SMP Keypress Notification
Add experimental support for SMP Keypress Notification.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-13 14:04:25 +01:00
Emil Gydesen
4fbabc14c5 Bluetooth: Audio: Shell: Fix bug with txing_stream and bap send
The bap send command would set txing_stream but the
pointer would never be reset.

The txing_stream is mainly to handling the start_sine,
so only {start|stop}_sine commands now sets this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-13 14:02:41 +01:00
Nicola Ochsenbein
eba73727ee modules: fs: Add reentrant zephyr support
This commit enables zephyr to configure the FatFs FF_FS_REENTRANT
option and support fs actions from multiple threads.
CONFIG_FS_FATFS_REENTRANT enables the option and provides zephyr
mutex wrappers.

Signed-off-by: Nicola Ochsenbein <Nicola.Ochsenbein@husqvarnagroup.com>
2023-03-13 11:58:57 +01:00
Michal Ciesielski
43c08d5c3f lwm2m: Fix multi res inst, create flags and post write callback for SWMGMT
The multi resource and create flags were reversed, meaning that resources
were defined as multi resource but weren't being created by default. That
doesn't reflect the LWM2M Software Management, which specifies which
objects can be multi resource and which are mandatory.

The post write callbacks were assigned to the validate callbacks.

Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
2023-03-13 11:58:29 +01:00
Julien D'Ascenzio
f76bfa5712 nvs: use NVS cache in write and gc functions
NVS cache was used only in read function. This commit add the usage of
NVS cache in write and gc functions.

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2023-03-13 09:21:22 +00:00
Julien Vermillard
a9349fe74d net: lwm2m: Typo in LWM2M_IPSO_TIMER description
Changed description to "IPSO Timer Support" in place of "Light Control
Support"

Signed-off-by: Julien Vermillard <julien@vermillard.com>
2023-03-11 08:46:22 +02:00
Lingao Meng
81847a57ff Bluetooth: Host: Refine assert message
Add opcode information for cmd timeout assert,
since BT_DBG usually not show in real product,
however we can't see any information just from
assert message.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-03-10 11:39:05 +01:00
Andries Kruithof
02eac5cbc2 Bluetooth: controller: fix compile error when VS cmds disabled
When vendor specific commands are disabled by setting
BT_HCI_VS=n the host still calls bt_read_static_addr,
but that function is not compiled in, resulting in a
build error.
Fixed by moving the code in controller/hci/hci.c
outside of the conditional compile

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-03-10 09:39:23 +01:00
Vidar Lillebø
ca3d0c8ee9 mbedtls: Remove dependency on MBEDTLS_BUILTIN for MBEDTLS_DEBUG
Allows using MBEDTLS_DEBUG functionality when not using MBEDTLS_BUILTIN.

Signed-off-by: Vidar Lillebø <vidar.lillebo@nordicsemi.no>
2023-03-10 09:30:32 +01:00
Erik Brockhoff
1028cab11e Revert "Bluetooth: controller: use RX node piggy-back for NTF when possible"
This reverts commit 6dbc446342.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-10 09:30:23 +01:00
Erik Brockhoff
a40434748c Revert "Bluetooth: controller: fixing CIS establish flow for refactored LLCP"
This reverts commit 1d8acfe5fa.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-10 09:30:23 +01:00
Krzysztof Chruscinski
68955ebdb6 logging: Increase package size limit to 2047
Package length was previously stored on 10 bits which limited
package size to 1023 bytes. Descriptor which contained package
length field had one unused bit which can be used to increase
package length field to 11 bits doubling the maximum package
length.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Krzysztof Chruscinski
a5979dcfa1 logging: Log warning and drop too big message
When packacge exceeds the limitation warning log is printed
and message is dropped.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Krzysztof Chruscinski
24ad096232 logging: Renamed internal defines to get rid of 2 suffix
Some internal macros were still using 2 suffix which comes from
time when there was v1 and v2. Cleaning up by removing the suffix.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-03-09 15:10:06 -08:00
Mariusz Skamra
f2d43cf0ac Bluetooth: ascs: Fix missing list initialization
This fixes missing initialization of active ASE list.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-09 17:23:46 +01:00
Pavel Vasilyev
6810e669e1 Bluetooth: Mesh: Reschedule dedicated relay adv sets immediately
Reschedule dedicated relay adv sets immediatey after finishing
advertising of the previous relay message. This allows a node to
relay messages as fast as possible when Relay Retransmit Count state
is zero using less relay adv sets.

When Relay Retransmit Count state is non-zero, the delay doesn't do
anything as the time between pushing a relay message to the host and
triggering adv_sent callback will be greater than this delay. In this
case the relay adv set will send a next message immediately.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-09 17:21:39 +01:00
Andrei Emeltchenko
c574bfcfd2 bluetooth: audio: Fix NULL dereference before NULL check
Fixes NULL dereference before NULL check for conn.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-09 17:21:26 +01:00
Emil Gydesen
bdbfcb12ca Bluetooth: Audio: Unicast stream start fix
The unicast client would attempt to send the
receiver start ready opcode to the server for
source ASEs before the CIS was connected, which
is a spec violation.

The code has been refactored to set a boolean,
and then send the receiver start ready opcode on
CIS connection instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-09 17:21:14 +01:00
Pavel Vasilyev
4a59107fc7 Bluetooth: Mesh: Fix compilation issue in access.c
This fixes compilation errors of BabbleSim tests generated by gcc-12
when MOD_REL_LIST_SIZE is zero.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-09 16:02:21 +01:00
Jonathan Rico
da97ab6ee8 Bluetooth: host: gatt: respect BT_GATT_ENFORCE_SUBSCRIPTION
A subscription check was still being done in the
gatt_notify_multiple_verify_params() fn, regardless of the value of
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION.

This could lead to getting this warning if BT_GATT_NOTIFY_MULTIPLE is
enabled, and the notifications not being sent to unsubscribed peers.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-09 11:49:34 +01:00
Szymon Janc
6ca2dac6a3 bluetooth: controller: Fix build with BT_HCI_VS_EXT disabled
[216/319] Building C object zephyr/subsys/bluetooth/controller/
  CMakeFiles/subsys__bluetooth__controller.dir/hci/hci.c.obj
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:
   In function 'hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459:17:
   warning: implicit declaration of function 'vs_set_min_used_chans';
   did you mean 'll_set_min_used_chans'? [-Wimplicit-function-declaration]
 5459 |                 vs_set_min_used_chans(cmd, evt);
      |                 ^~~~~~~~~~~~~~~~~~~~~
      |                 ll_set_min_used_chans
....
zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../
  ../../../arm-zephyr-eabi/bin/ld.exe: zephyr/subsys/bluetooth/controller/
  libsubsys__bluetooth__controller.a(hci.c.obj): in function
   `hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459: undefined
   reference to `vs_set_min_used_chans'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-03-09 11:49:14 +01:00
Mariusz Skamra
50d21999fe Bluetooth: ascs: Fix bt_ascs_ase missing cleanup
Once the bt_ascs_ase is taken from the mem_slab, it has to be memset to
override the junk data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-09 09:45:52 +00:00
Andy Ross
d20ab8c609 subsys/pm: Use correct timeout API
The z_set_timeout_expiry() function is a wrapper provided in the
timeout subsystem that has some corrections for timelicing.  But the
suspend code doesn't care; by definition there are no active threads
that might be timeslicing at the point where the OS is suspending.
Use the lower-level timer driver API instead.

(z_set_timeout_expiry() is also about to disappear)

Signed-off-by: Andy Ross <andyross@google.com>
2023-03-09 09:21:12 +01:00
Sebastian Arnd
3cd58c29bf net/lib: mqtt_sn: Fix MQTT-SN IPv6 Support and assertation in Example
1. `zsock_socket()` gets the right packet familiy.
2. `inet_pton()` returns 1 on success.

This should address #55193.

Signed-off-by: Sebastian Arnd <sebastianarnd@gmail.com>
2023-03-09 09:20:53 +01:00
Ajay Parida
ce4a809751 net: wifi_mgmt: Updated TWT setup response status
Display message updated for TWT setup response.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-08 15:33:30 +01:00
Chris Friedt
79d4107beb net: http: define http service and resource iterable sections
Provide a means of declaring zero or more HTTP services, each
with zero or more static HTTP resources.

Static HTTP resources are those which have fixed paths[1] which
are known prior to system initialization. Some examples of
static http resources would be

* a forwarder from '/' to '/index.html'
* a REST endpoint with fixed path '/api/foo' and detail
  pointing at some implementation-specific function
* a Javascript file in string form with fixed path '/js/util.js'
* a 'construction' image with path '/res/work.png'
* a gzip-compressed 'Hello' HTML file at '/hello.html'

Without describing in any detail how static HTTP resources are
organized or served by any given HTTP server, we can describe
what static resources exist on a system in a common way that
does not require any optional facilities (e.g. filesystem) and
relies only on addressable memory.

Additionally, for the purposes of simply allowing others
to implement custom HTTP servers in a consistent way, or
benchmarking implementations, or having a consistent testsuite
to use across multiple implementations, it is helpful to have
a common method to declare HTTP services and static resources
for Zephyr.

[1] https://en.wikipedia.org/wiki/URL

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-08 13:57:13 +00:00
Emil Gydesen
72d80b74be Bluetooth: Audio: Move stream_reset before released callback
In the unicast client we should reset the stream before calling
the released callback. This is so that we can reuse the stream object
in the released callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-08 11:07:40 +01:00
Emil Gydesen
136191e936 Bluetooth: Audio: Fix return value for VOCS invalid location
If the location was invalid, we return 0 instead of
an error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-08 11:07:00 +01:00
Mariusz Skamra
cf7bfc406c Bluetooth: audio: Remove redundant forward declaration
This removes redundant bt_bap_ep declaration, as the structure is
defined right below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-08 11:06:51 +01:00
Mariusz Skamra
cb1d36afca Bluetooth: audio: ascs: Remove unused includes
This removes unused includes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-08 11:06:36 +01:00
Tomasz Moń
5bd0f5ea8b usb: device_next: msc: handle MODE SENSE(10) command
USB Mass Storage Specification for Bootability requires MODE SENSE(10)
command. MODE SENSE(6) and MODE SENSE(10) generally access the same data
but differ in the maximum allocated length and LLBAA support. However
there is no point in extracting common handling because there no mode
pages are supported now.

Fail MODE SENSE requests if asking for anything other than supported
page codes (to which the essentially hardcoded response is valid).

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-08 10:53:55 +01:00
Mariusz Skamra
1a0e7fa57a Bluetooth: audio: ascs: Remove reference to conn internals
This removes using conn internal API in ASCS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-07 18:19:08 +01:00
Emil Gydesen
e36caf48b7 Bluetooth: Audio: Rename audio shell commands to bap
Change the shell commands from "audio ..." to "bap ...".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
26f8db4c61 Bluetooth: Audio: Rename stream.h -> bap_stream.h
Renamed the file to better match what it contains.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
099c13846e Bluetooth: Audio: Fix minor bt_audio -> bt_bap issues
Several places used the bt_audio prefix where it shouldn't.
Also moved the BAP documentation to its own file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
e2765d7bd5 Bluetooth: Audio: Rename bt_audio_iso to bt_bap_iso
Rename the internal bt_audio_iso struct and API to bt_bap_iso

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
271ff1d1a3 Bluetooth: Audio: Add new bap_lc3_preset and move macros
Added a new header file bap_lc3_preset.h which contains
the definitions of the LC3 (pre)sets defined by the
BAP spec.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
3326863267 Bluetooth: Audio: Rename bt_audio_ep to bt_bap_ep
Rename the bt_audio_ep struct and API to bt_bap_ep
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
4224b45838 Bluetooth: Audio: Rename bt_audio_unicast_group to bt_bap_...
Rename the bt_audio_unicast_group API to bt_bap_unicast_group
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
77853f43f2 Bluetooth: Audio: Rename bt_audio_stream to bt_bap_stream
Rename the bt_audio_stream API to bt_bap_stream
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
e0fc612c93 Bluetooth: Audio: Rename bt_audio_unicast_client to bt_bap_...
Rename the bt_audio_unicast_client API to bt_bap_unicast_client
and move the API to bap.h

Also adds the _bap_ infix to the bt_unicast_client functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
be42429f90 Bluetooth: Audio: Rename bt_audio_broadcast_source to bt_bap_...
Rename the bt_audio_broadcast_source API to bt_bap_broadcast_source
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
06d00ff5f9 Bluetooth: Audio: Rename bt_audio_broadcast_sink to bt_bap_...
Rename the bt_audio_broadcast_sink API to bt_bap_broadcast_sink
and move the API to bap.h

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
eeae1f096a Bluetooth: Audio: Rename bt_audio_unicast_server to bt_bap_...
Rename the bt_audio_audio_server API to bt_bap_unicast_server
and move API to bap.h.

This also adds the _bap_ infix for bt_unicast_server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Emil Gydesen
7fc051967f Bluetooth: Audio: Add bap prefix to BAP internal files
All internal files that implement BAP now has the
bap_ prefix.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 16:21:44 +01:00
Mariusz Skamra
e33705f64c Bluetooth: audio: ascs: Remove unused variable
This fixes compiler unused variable error

warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
  461 |         struct bt_ascs_ase_status *status;

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-03-07 15:54:58 +01:00
Tomasz Moń
4c97dd546a usb: device_next: msc: STALL OUT when waiting for reset
Mass Storage Class allows device to either silently discard OUT endpoint
data after receiving invalid CBW or to STALL the OUT endpoint (and keep
it STALLed regardless of host clearing halt) until Reset Recovery.

Switch from silently discarding to STALL in order to allow host realize
that device waits for Reset Recovery without transferring complete OUT
data.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-07 15:48:40 +01:00
Emil Gydesen
736ec47fb3 Bluetooth: Audio: Add ASCS delay for CIS disconnect
While both the server and client are allowed to terminate
the CIS when a stream is released, it is, per the BAP spec,
the client's responsibilty. This commit modifies it so that
the client will actually get a chance to do its responsibilty
by adding a small delay before our ASCS disconnects the CIS.

The CIS disconnection has kept with a delay, rather than
removed, in case that the Unicast Client is not properly
performing it's responsibility.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 11:12:40 +01:00
Vinayak Kariappa Chettimada
c7835e239f Bluetooth: Controller: Remove mesh low lat bsim test workaround
Remove mesh loopback group test workaround introduced in
commit 2a9cd8ffb1 ("Bluetooth: Controller: Add
EVENT_OVERHEAD_START_US when enabling states").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-07 11:12:23 +01:00
Vinayak Kariappa Chettimada
55c4084c8b Bluetooth: Controller: Fix scan window value corruption
Fix scan window value corruption due to modification of
stored ticks_window value when enabling continuous scan.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-07 11:12:23 +01:00
Emil Gydesen
59a9f8a3b0 Bluetooth: Audio: Add reason to BAP stream stopped callback
Forwards the reason parameter from the ISO disconnect to
the stream stopped callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 09:44:20 +01:00
Emil Gydesen
e75fc5e318 Bluetooth: Audio: Remove pac_cache from unicast_client
Removes the unused pac_pache from the unicast_client.

This moves the storing of the PAC records (in the form of
struct bt_codec) from the stack to the upper layers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-07 09:44:10 +01:00
Alberto Escolar Piedras
f6273e9cb5 Thread analyzer: Prevent on POSIX ARCH
The thread analyzer cannot be really used with the
POSIX architecture.

As:
* Code takes 0 simulated time to execute.
  So the analyzer will report 0 cycles being used.
* The stack allocated by Zephyr is not actually used
  (except for a tiny part used by the arch code itself
  to do a bit of thread bookkeeping).
  The POSIX architecture uses a separate stack
  (from an underlying Linux pthread) which Zephyr is blind
  about. So the thread analyzer is going to only report
  a tiny stack utilization.

Prevent users from selecting them together to avoid confusion.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-07 09:44:59 +02:00
Fabio Baltieri
3386e96515 input: add input subsystem
Initial commit introducing the input subsystem into Zephyr.

Includes the input_event data structure, the input_report_* APIs, an
iterables sections based subscription API and two operation modes:
synchronous, where the listeners are called directly, and asynchronous,
where the listeners are called in a dedicated thread.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-06 11:47:32 -08:00
Erik Brockhoff
1d8acfe5fa Bluetooth: controller: fixing CIS establish flow for refactored LLCP
Latest modification to LLCP removed 'monitoring' of cis->established
flag in LLCP, relying instead on signal through ULL.

For this to work properly the signal must also be generated, so this is
introduced. Note - checking of cis->established flag could be removed
if caller ensures only calling once (on establish condition)

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 17:08:42 +01:00
Krzysztof Kopyściński
392f95705c tests: bluetooth: mesh: add Proxy Solicitation to shell
This adds commands to advertise Solicitation PDUs, configure
On-Demand Private Proxy and manage Solicitation PDU RPL.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
d0995541fb Bluetooth: Mesh: add implementation for Proxy Solicitation
This is initial implementation of Proxy solicitation procedure.
This includes:
- support for sending and receiving Solicitation PDUs
- On-Demand Private Proxy functionality (Server and Client) controlling
  behaviour of node after receiving Solicitation PDU
- Solicitation PDU RPL Configuration (Server and Client), which manages
  Replay Protection List for Solicitation PDUs.

Proxy Solicitation allows to enable advertising of Proxy service on node
by sending Solicitation PDUs. These PDUs are not part of Mesh messages;
instead, these are non-connectable, undirected advertising PDUs with
their own format, containing Proxy Solicitation UUID.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michal Narajowski
d95fe3f52b Bluetooth: Mesh: Add support for Models Metadata Page 128
This patch adds for handling Models Metadata Get Page 128.

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
007bca7b63 Bluetooth: Mesh: Add Composition Data Page 1 to shell
Add parsing of Composition Data Page 1 and enable it's support.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Krzysztof Kopyściński
29f07abc89 Bluetooth: Mesh: Add Composition Data Page 1
Composition Data Page 1 contains information about relations between
models. Implementation saves relations into array of tuples
{ptr to base, ptr to extension, relation type} on model initialization
and uses this information to construct Composition Data Page 1.

Appropriate structures and methods were added to API, allowing user to
parse all received data into Composition Data Page 1 formats:
Composition Data Page 1 Element, Model Item, Model Extension Item.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
0bd0071e4a Bluetooth: Mesh: Add Opcodes Aggregator models to shell
- Add entry for client and server in composition data.
- Add Client commands to aggregate and send messages.

MESH/SR/AGG/BV-02-C requires more key slots.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
da5195ea97 Bluetooth: Mesh: Add support for Opcodes Aggregator models
Includes Opcodes Aggregator Server and Client. To use Opcodes Aggregator
client features with some client model, that client should support async
API.

Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Pavel Vasilyev
d46480c36b Bluetooth: Mesh: Add shell commands for Private Beacon Client
Add shell commands for Private Beacon Client.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
f9b19010ed Bluetooth: Mesh: Private Beacons
Adds support for private beacon sending and receiving.

Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
b5d6733d53 Bluetooth: Mesh: Add Transport SAR Configuration models to shell
Add Transport SAR Configuration models to shell.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
dd59a45c65 Bluetooth: Mesh: Transport SAR Configuration
Add support for:
- SAR Configuration Client and Server models
- Transport SAR configuration states
- Using SAR Transmitter/Receiver states in segmentation
and reassembly process.

Bsim tests fixes:
- Fix failing replay attack test. The replay attack test doesn't
consider retransmission attempts at the transport layer. When
retransmission happens, SeqNums get increased and the test logic
doesn't work anymore. The simplest fix would be to disable
retransmissions at the transport layer.
- Add device synchronization API to synchronize transport va test.
Device configuration may take different time on transmitter and
receiver. Add synchronisation barrier between devices.
- Fix msg_frnd test. Timing in transport sar behavior has been
changed, which affected test_friend_msg test. Now acknowledgments
are sent much faster and this needs to be considered in the test.
- Fix unicast_low_lat test. Increase number of retransmission
attempts when long segmented message is sent.
- Reduce timeout in kr_old_key test.
- Relax SAR RX state configuration in DFU and BLOB tests.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
8a60dfcd51 shell: Add Large Composition Data Server
- Adds Large Comp Data Server and Client
- Defines some dummy metadata for Health Server

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
df65592d94 Bluetooth: Mesh: Add support for Large Composition Data models
- Adds Large Composition Data Server and Client definitions
- Adds Client API definition
- Adds Health Server Metadata definition
- Refactors Composition Data processing (as a Server) to use common
 methods with Large Comp Data Server

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Stine Akredalen <stine.akredalen@nordicsemi.no>
Co-authored-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
f7f3241628 Bluetooth: Mesh: Shell support for remote provisioning
Adds commands in the mesh shell for remote provisioning client
operation, including scanning, provisioning and reprovisioning.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
3c185e1764 Bluetooth: Mesh: Remote provisioning
Adds remote provisioning models rpr_srv and rpr_cli, and exposes them as
a bearer for the provisioning process.

The remote provisioning models provide the following features:
- Remote provisioning of new devices, using a remote provisioning server
  as a proxy.
- Reprovisioning of existing devices, generating a new device key and
  changing addresses and composition data.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
85431fd69e Bluetooth: Mesh: Add composition data page 128
Composition data page 128 represents the new composition data after a
composition refresh procedure. The implementation stores the old
composition data (before applying a DFU or similar), and uses that as
page 0 if present. As the device has already rebooted by the time page
128 becomes active, its active composition data is page 128, while the
backed up data is the "old" data, which should be shown as page 0.

Co-authored-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
417d328796 Bluetooth: Mesh: DFU and BLOB models in shell
Adds conditional support for the BLOB and DFU models in the mesh shell.
Additionally creates a dummy BLOB stream for testing.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
b054ae364d Bluetooth: Mesh: DFD Server model
Adds support for the Device Firmware Distribution Server model from Mesh
Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
529860e72b Bluetooth: Mesh: DFU models
Adds DFU models from the Mesh Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Trond Einar Snekvik
4302b568cc Bluetooth: Mesh: BLOB models
Adds support for the BLOB Models from Mesh Model specification v1.1.

Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Co-authored-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Co-authored-by: Mia Koen <mia.koen@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Aleksandr Khromykh
ffddd9ffc0 Bluetooth: Mesh: enhanced provisioning authentication
Implementation of the enhanced provisioning authentication (EPA)
that is based on SHA256 and HMAC security algorithms.
OOB authentication mandates EPA usage.

Co-authored-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Aleksandr Khromykh
5ffae6486b Bluetooth: Mesh: add mesh 1.1 global config option
All mesh 1.1 features are gathered behind a KConfig options.
Default is disabled.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Michał Narajowski
1b77e8bbf1 Bluetooth: Mesh: Add Model Receive testing callback
Add a callback similar to net_recv that notifies the application when a
message is received in access layer. This is is useful for testing
purposes (especially automated testing).

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
1c731c714c Bluetooth: Mesh: Refactor bt_mesh_model_recv
Pass only msg context as it is the only thing used from net_rx.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
08f0d1c742 Bluetooth: Mesh: Add a flag for DevKey-only based models
This prevents a Configuration Client from binding an app key to a model
that only supports DevKey-based security.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
7f1b296a0c Bluetooth: Mesh: Do not relay message rejected by Transport layer
Mesh Profile Specification Errata 11341

3.6.4.3 Message error procedure
When the Upper Transport layer receives a message that is not
understood, then the message shall be ignored.
A message that is not understood includes messages that met one or more
conditions listed below:
• The Transport Control message opcode is unknown by the receiving node.
• The Transport Control message size for the Transport Control opcode
is incorrect.
• The Transport Control message parameters contain values that are
Prohibited

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
62aad07968 Bluetooth: Mesh: Check for duplicates in friend queue
Mesh Profile Specification Errata 11302

Section 3.5.5.

When a Friend node receives a message that is destined for a Low Power
node (i.e., the destination of the message is a unicast address of an
element of the Low Power node or in the Friend Subscription List), and
the TTL field has a value of 2 or greater, then the message shall be
processed as follows: If the Friend Queue already contains a message
with the same SEQ and SRC fields as in the received message, or if the
SRC field of the received message is a unicast address of an element of
the Low Power node, then the message shall not be stored in the Friend
Queue. Otherwise, the TTL field value shall be decremented by 1, and
the message shall be stored in the Friend Queue.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
ee3e93148e Bluetooth: Mesh: Change IV Update duration requirement for new nodes
Mesh Profile specification errata 11627

Section 3.10.5:
When a node is added to a network, the node is given an IV Index.
If the node is added to a network when the network is in Normal
operation, then it shall operate in Normal operation for at least
96 hours. If a node is added to a network while the network is in
the IV Update in Progress state, then the node shall be given the
new IV Index value and operate in IV Update in Progress operation
without the restriction of being in this state for at least 96 hours.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
fa107b4b54 Bluetooth: Mesh: Set minimum publish period
Mesh Profile Errata 11392

Section 4.4.3.2.1 Current Fault state:

When the value of a Health FastPublish Period Divisor state is non-zero,
and a Current Fault Fault Array (see Section 4.2.15.1) for at least one
Company ID contains records, an unsolicited Health Current Status
message set to the value of that Company ID and the FaultArray field
containing a sequence of faults representing a sequence of faults in the
Current Fault Fault Array (see Section 4.2.15.1) shall be published
every number of seconds as defined by the value of the Publish Period
divided by the value represented by the Health Fast Period Divisor
state, or every 100 ms (the minimum Publish Period value whichever
is greater.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2023-03-06 13:52:15 +01:00
Michał Narajowski
91fa9194f0 Bluetooth: Mesh: Fix Heartbeat Pub/Sub Count/Period Log calculation
Mesh Profile Specification Errata 11737 specifies that
Period/Count Log value 0x11 is not defined Log field
transformation in Table 4.1.

Errata 11737 adds value 0x11 to Log field transformation
table with 2-octet value equal to 0x10000 which does not fit into
two octets. This patch changes period calculation to 32-bit precision.
There is also a special case for publication count. If the
log value is equal to 0x11 then the publication count value
should be 0xfffe. When sending Hearbeat Publication Status
message we should return the same value as the one received
in Publication Set so we have to add a case in hb_pub_count_log().

Co-authored-by: Alperen Sener <alperen.sener@nordicsemi.no>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-03-06 13:52:15 +01:00
Dave Lacerte
96c8d16986 net: lwm2m: Add IPSO voltage sensor object
Add support fot the IPSO voltage sensor object

Signed-off-by: Dave Lacerte <lacerte.dave@hydroquebec.com>
2023-03-06 12:34:22 +01:00
Marc Lasch
072a5da433 net: lwm2m: Register callback for firmware update cancel
Allow to register a callback function which is called when a firmware
update is canceled by the cancel command.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2023-03-06 12:33:12 +01:00
Arkadiusz Kozdra
f5bf1cddda bluetooth: host: Check bounds on num_completed_packets event
If an event with corrupted length arrives, the extra check makes the
handler return early to avoid reading data out of bounds.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-03-06 11:16:42 +01:00
Erik Brockhoff
6dbc446342 Bluetooth: controller: use RX node piggy-back for NTF when possible
When possible re-use the already allocated RX node for notifications.
Store (retain) RX node and Link element on RX if NTF could occur.
Pass link element to LLCP (ull_cp_rx()) together with RX node.
New RX node type RETAIN introduced to signal retention

When no RX node is available allocate one and hold off TX on procedures
until such time that a node is available for NTF.

In case waiting for NTF buffer avail is needed, allocate and store TX
node to use for TX once NTF becomes available.

CIS Established (incl. timeout handling) is now handled entirely as a
specific event driven by ull_conn_iso - ie removal of procedure check
of cis->established and cis->expire, as this is doubling mechanism
in the conn_iso context.

Unit test and helpers updated to handle new node type.
Function ull_cp_release_ntf() was used only in unit test, so moved to
helper context.
Updating release_ntf to handle the fact that with piggy-backing in test
context the node used for NTF can be from two different memory pools

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 09:35:10 +01:00
Erik Brockhoff
80426ddbed Bluetooth: controller: removed unused code
LLCP data struct member fex.sent was set but not used so remove

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-03-06 09:35:10 +01:00
Emil Gydesen
835352c2bb Bluetooth: Shell: Add indication of default_conn in connections cmd
When doing "bt connections" the currently selected ACL (default_conn)
is now indicated with a "*" making it easier to determine which
of the connections is currently selected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-06 09:34:36 +01:00
Lucas Dietrich
c7f9eafeec net: http: Make http_client.c compile with CONFIG_NET_SOCKETS_POSIX_NAMES=n
Use internal constant ZSOCK_POLLIN instead of POLLIN to
 make the http_client source file compile without error with
CONFIG_NET_SOCKETS_POSIX_NAMES disabled.

 Fixes #55423

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2023-03-05 08:51:25 -05:00
Wojciech Slenska
6272ba2d5c shell: added function shell_use_vt100_set
Added function to enable/disable vt100 commands.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-03-04 18:36:39 +01:00
Wojciech Slenska
bbd428fd63 shell: shell_cmds: added vt100 commands
Added command for enablig/disablig vt100 shell commands.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-03-04 18:36:39 +01:00
Dmytro Semenets
e169f7cc12 subsys/storage/flash_map: remove unnecessary includes
Those files includes soc.h header which exists not for all boards.
soc.h consists soc-depended defenitions and need to be included by
soc-depended sources

Signed-off-by: Dmytro Semenets <dmytro_semenets@epam.com>
2023-03-03 15:34:59 +01:00
Ajay Parida
55ed46ff6d net: wifi_mgmt: Updated TWT setup response status
Updated TWT setup response status. Removed un-necessary
error strings, enum and values updated as per f/w.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-03 12:43:43 +01:00
Martin Sollie
e94c33d530 logging: add support for 64 bit timestamps with Linux format
Combining CONFIG_LOG_OUTPUT_FORMAT_LINUX_TIMESTAMP and
CONFIG_LOG_TIMESTAMP_64BIT results in a wrong timestamp, as the
Linux timestamp format print call assumes a 32 bit variable for
the seconds. Fix it by using a different print format for 64 bit
timestamps.

Fixes: #55372

Signed-off-by: Martin Sollie <ms@aziwell.no>
2023-03-03 11:36:14 +01:00
Jamie McCrae
533e312359 mgmt: updatehub: Change Kconfig select to depends on
Changes Kconfig symbols to depend on symbols rather than selecting
them, this avoids a cmake dependency loop.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Jamie McCrae
31201a7f61 mgmt: hawkbit: Change Kconfig select to depends on
Changes Kconfig symbols to depend on symbols rather than selecting
them, this avoids a cmake dependency loop.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Jamie McCrae
c3bfe7a6ba dfu: Change FLASH_MAP and STREAM_FLASH from select to depends on
This fixes a cmake dependency loop when selecting
CONFIG_MCUBOOT_IMG_MANAGER.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-03 10:49:32 +01:00
Chris Friedt
f923441146 lib: posix: move fnmatch from lib/util to lib/posix
The `fnmatch()` function is specified by POSIX and should be
a part of `lib/posix`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-03 17:40:14 +09:00
Vinayak Kariappa Chettimada
afd4346965 Bluetooth: ISO: Fix BT_ISO_TX_MTU range
In the Bluetooth Core Specification, the minimum
ISO_Data_Packet_Length is 0x0001, hence fix the
BT_ISO_TX_MTU range to allow a minimum value of 1.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-03 09:19:19 +01:00
Tom Burdick
3998f9f898 rtio: Shareable lock-free iodevs
By using an mpsc queue for each iodev, the iodev itself is shareable across
contexts. Since its lock free, submits may occur even from an ISR context.

Rather than a fixed size queue, and with it the possibility of running
out of pre-allocated spots, each iodev now holds a wait-free mpsc
queue head.

This changes the parameter of iodev submit to be a struct containing 4
pointers for the rtio context, the submission queue entry, and the mpsc
node for the iodevs submission queue.

This solves the problem involving busy iodevs working with real
devices. For example a busy SPI bus driver could enqueue, without locking,
a request to start once the current request is done.

The queue entries are expected to be owned and allocated by the
executor rather than the iodev. This helps simplify potential
tuning knobs to one place, the RTIO context and its executor an
application directly uses.

As the test case shows iodevs can operate effectively lock free
with the mpsc queue and a single atomic denoting the current task.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-03 09:18:09 +01:00
Jordan Yates
30dbaa83f7 logging: backend_uart: handle PM on panic
Handling panicking while in an ISR. Instead of attempting to call
`pm_device_get` for each character, ensure that the hardware is enabled
when `log_panic` is called.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-03 09:17:49 +01:00
Jordan Yates
997dce97bf logging: backend_uart: handle runtime PM
Allow the log_backend_uart char_out implementation to integrate with
'Device Runtime Power Management'.

Without using runtime PM, it is impossible for the application to manage
the power state of a UART instance, given that any module in the
application could theoretically LOG_* or printk at any point in time.

This removes the need to manually call `pm_device_state_set` when the
lowest power states must be reached, while still allowing log messages
to be output.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-03 09:17:49 +01:00
Michał Barnaś
e0fbd35fc0 usbc: explicitly declare sizes of state machines arrays
The asserts in the USB-C stack functions were causing compilation
errors when asserts were enabled in Kconfig.
This was caused because the asserts checked if the functions
parameters were within limits specified by the state machine arrays.
At the position of these asserts, these arrays were only declared
without specifying the size of them, what prohibited the asserts from
knowing the size of arrays and checking if specified value is within
limit of it.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-03-03 09:17:11 +01:00
Jeroen van Dooren
1be74ac6d7 net: dns: prevent crash on nullptr as callback
When a query is done, the query isn't set to NULL.
This can cause a nullptr exception in invoke_query_callback().

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-03-02 21:58:07 -05:00
Aleksander Wasaznik
5233fe5fb9 Bluetooth: Host: Log incomplete adv reports
This gives our users some indication of why they are not receiving
long advertisements.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-03-02 21:19:16 +01:00
Emil Gydesen
8333b12da7 Bluetooth: Host: Add ACL NULL check for ISO conn info
If getting the conn info of an ISO channel, the ISO channel may
not yet have an ACL connection, so we cannot get the
ACL source and destination addresses from the ACL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 17:57:17 +01:00
Simon Frank
5d9db9dc65 fb: cfb: cfb_shell command to set font kerning
Using `struct shell *shell` would be more consistent but triggers CI
check on MISRA rule 5.7 "A Tag name shall be a unique identifier"

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
Simon Frank
b50838c66f fb: cfb: add API to set font kerning
Font kerning was used but it was not possible to change it.
Also, font_idx was set to zero twice in init.

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2023-03-02 13:51:55 +01:00
JP Sugarbroad
6d4266a451 usb: device: msc: support larger devices
Track LBA rather than byte offset in order to simplify the code and
support devices larger than 4GiB.

Signed-off-by: JP Sugarbroad <jpsugar@amazon.com>
2023-03-02 13:51:37 +01:00
Vinayak Kariappa Chettimada
afa8e6f23a Bluetooth: Controller: Fix extended scanning for BT_CTLR_LOW_LAT
Fix Extended Scanning support for BT_CTLR_LOW_LAT variant
of the Controller implementation by closing the scan window
for every ADV_EXT_IND PDU received that that ULL_LOW context
is enabled back and ticker job can process the request to
start auxiliary PDU reception. Without the change the
ticker job would only run at the end of the scan window that
caused the auxiliary scan prepare to assert due to delayed
ticker timeout expiry callback.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-02 13:46:59 +01:00
Emil Gydesen
6d0c53c959 Bluetooth: Audio: Add addition vol ctlr input checks
Add misisng function parameter input checks to verify
values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 10:56:27 +01:00
Robert Lubos
b6ae195390 net: dhcpv4: Fix potential packet leak in DHCPv4
Packet handlers registered with net_conn API should not use NET_CONTINUE
to report packet processing status. As they register for a specific
local port, it cannot be assumed someone else will handle the packet,
and for net_conn this status is not really handled differently from
NET_OK. Therefore, reporting NET_CONTINUE, and not freeing the packet,
can result in a packet leak.

Too short packets should not really be handled differently from other
malformed packets in DHCPv4 module, therefore report NET_DROP instead of
NET_CONTINUE.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-02 10:01:27 +01:00
Arkadiusz Kozdra
1e293a13bc bluetooth: sco: Error out early on null acl
Cleanup unrefs the ACL connection, so ensure it is never null in the
constructor.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-03-02 09:59:56 +01:00
Emil Gydesen
f2918b0109 Bluetooth: Audio: Fix MCC discover callback on reconnected issue
With BT_GATT_SUBSCRIBE_FLAG_NO_RESUB the MCC subscriptions would
be resent to the server on reconnection. Since this may trigger an
error, the error will trigger a call to the MCC discover complete
callback.

For MCP We can assume that the server stores the subscriptions if
we are bonded, and thus we can use BT_GATT_SUBSCRIBE_FLAG_NO_RESUB.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-02 09:03:32 +01:00
Emil Gydesen
4b0442ab57 Bluetooth: Audio: Fix missing call to BAP discover cb
If we discover both sink and source ASEs, then we attempt
to subscribe to the ASE CP characteristic twice. However,
if we are already subscribed, then the callback is not called,
and then the 2nd call to discover will not return properly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-03-01 15:58:15 +01:00
Tomasz Moń
7527b38ff5 usb: device_next: fail Mass Storage requests with invalid length
Fail Mass Storage control requests if wLength is incorrect.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-01 12:02:29 +01:00
Jonathan Rico
caa88b2cfd Bluetooth: host: gatt: don't use settings API in disconnect cb
When `CONFIG_BT_SETTINGS_DELAYED_STORE` is enabled, reschedule the storage
work immediately instead of processing it in the current context.

When that config is not enabled, process the storage in the current
context.

Processing this work (i.e. using the settings API and its likely
FLASH-based backend) in the current context (cooperative prio) may mess
with the real-time constraints of the application threads.

Fixes #55067.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-03-01 11:10:22 +01:00
Luca Fancellu
d61dcf2f1d net: zperf: improve code quality for tcp_received function
Currently, in tcp_received function defined in zperf_tcp_receiver
module, the assignment of session->state to STATE_COMPLETED is
overwritten on the same path to STATE_NULL and a session is
considered free for both STATE_COMPLETED and STATE_NULL, so remove
the assignment to STATE_NULL.
Remove the break from the STATE_COMPLETED case handling so that it
can fallthrough, in case the same session is used after finish.
Remove also the STATE_LAST_PACKET_RECEIVED case because this state
is never reached.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
7c4ea08db8 net: zperf: fix typo in error messages
Fix typo in error messages from the zperf_tcp_receiver where UDP
is written instead of TCP.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
910de7f83d net: zperf: unify get_session among TCP and UDP
The modules zperf_udp_receiver and zperf_tcp_receiver use two
different functions to get a zperf session to store the
statistics, there is a TODO comment in the zperf_session module
suggesting to unify that part.
So delete the get_tcp_session function and use get_session for
both TCP and UDP receiver module.
Delete sock field from struct session because it's not used
anymore.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Luca Fancellu
1a12a070eb net: zperf: add configurable for the zperf sessions number
Currently the maximum number of zperf sessions handled is hardcoded
to 4, create a Kconfig parameter, with default value 4, to make the
maximum number of sessions configurable.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2023-02-28 18:12:52 +01:00
Arkadiusz Kozdra
642548daeb bluetooth: host: Check bounds more explicitly
Co-authored-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 13:23:51 +01:00
Arkadiusz Kozdra
8848380dff bluetooth: host: Check bounds on le_adv_report event
If an event with corrupted length arrives, the extra check makes the
handler return early to avoid reading data out of bounds.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 13:23:51 +01:00
Arkadiusz Kozdra
a000c2e903 bluetooth: host: Check for NULL discovery callbacks
Fixes a segfault if a discovery event happens while discovery is not
active and the discovery callback is null.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-02-28 12:48:47 +01:00
Dawid Niedzwiecki
2d0a784c41 subsys/mgmt/ec_host_cmd: rework Host Command support
Rework the Host Command support. It includes:
-change API to backend
-change a way of defining rx and tx buffers
-fix synchronization between the handler and backend layer
-simplify the HC handler

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Dawid Niedzwiecki
b2674a4b34 subsys/mgmt/ec_host_cmd: rename peripheral to backend
Follow naming pattern in the subsystems(logging or shell) and name
the layer between generic handler and peripheral driver "backend".

The name doesn't suit that well to the SHI backend, because there isn't
SHI API itself and the SHI interface is used only for the host
communication. So the backend code includes the peripheral driver itself.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Dawid Niedzwiecki
e734adfb78 subsys/mgmt/ec_host_cmd: update directory structure
The Host Commands can be used with different transport layers e.g. SHI
or eSPI. The code that provides the peripheral API and allows sending
and receiving Host Commands via different transport layers is not
actually drivers of a peripheral, so move it to the
subsys/mgmt/ec_host_cmd folder.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-02-28 10:42:23 +01:00
Flavio Ceolin
72fbc8c56d pm: device_runtime: Early feature enabled check
Check if device runtime is enabled in the beginning of
runtime_suspend to avoid unnecessary checks.

This does not change the current behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-02-28 10:41:30 +01:00
Flavio Ceolin
c4258dbde3 pm: device_runtime: Early feature enabled check
Check if device runtime is enabled in the beginning of
pm_device_runtime_get to avoid unnecessary checks.

This does not change the current behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-02-28 10:41:30 +01:00
Jun Qing Zou
755f0b7d27 net: tftp: Add client context
Use client context to seperate buffer usage.
Use new `TFTP_EVT_DATA` event to send data to application.
Use new `TFTP_EVT_ERROR` event to report error to application.
Update `tftp_get()` and `tftp_put()` API to use the client context.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-28 10:29:30 +01:00
Emil Gydesen
838cc543d8 Bluetooth: Services: Set IAS alert level before callback
Fix the order of setting the alert level before the callback.
Without this fix, the alert level would be incorrect if
the upper layers ever tried to perform any other IAS operations
in the callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-27 13:20:33 +01:00
Stefan Schwendeler
596a3bd996 net: lwm2m: bugfix lwm2m shell exec command with optional parameter
Actually `execute_cb` is fed with an array of char* and the size of
that array, instead of a single char* buffer and its byte size.

This fix expects a single, already joined, optional shell argument and
feeds `execute_cb` with proper arguments.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-27 11:34:42 +01:00
Miika Karanki
549de77750 usb: device: fix k_usleep in isr in set_endpoint
set_device can be called in interrupt context at least with
stm32u5 soc. Calling k_usleep from there causes the isr
to run forever.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2023-02-27 11:34:33 +01:00
Jonathan Rico
298ae28707 Bluetooth: host: gatt: fix ifdef comment
Forgot to update the ifdef comment when adding another condition.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
1906b05b10 Bluetooth: host: use ATOMIC_DEFINE for GATT global flags
Use a single bit array instead of multiple atomic_t variables.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
3486f133e9 Bluetooth: host: prevent registering services in the wrong context
There is a touchy spot where registering a service might result in sending
service changed indications that are not necessary. This is due to a race
condition between the SC work and the GATT DB hash being calculated.

Only allow users to call this API when we know it is safe:
- either before BT is initialized
- or after settings have been loaded (and hash calculated)

Fixes #54047

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
02edcd6494 Bluetooth: host: calculate GATT DB hash on settings load
Prevent race condtions between the stack and the low-priority thread by
calculating the hash (and acting on it, e.g. for marking peers
change-aware, sending SC indications, etc) in the settings_load() context.

Fixes #54773

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:48:15 +01:00
Jonathan Rico
b3671666e1 Bluetooth: host: clear ATT pending flag on failure to send
`ATT_PENDING_SENT` wasn't cleared when L2CAP reported an error when sending
the packet. This resulted in the channel being unusable for ever, since we
only clear that bit on a response (that will never be sent).

Found when setting `CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768` in the
`notify_multiple` test. The kicker was the bug didn't manifest when EATT
wasn't enabled:
- we were queuing two unsubscribes back to back in the test
- on UATT we have to wait for a req-rsp pair before enqueuing a new one
- on UATT we only have one channel anyways

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-27 10:32:13 +01:00
Sjors Hettinga
c51cf4f08d net: websocket: Make sure the mbedtls_sha1 function is build in
In the header the websocket protocol needs a SHA1 hash. This is
implemented using the mbedtls_sha1 function. Select the option
MBEDTLS_MAC_SHA1_ENABLED from the Kconfig of websocket to ensure this
function is build in.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-02-24 18:12:14 +01:00
Tomasz Moń
509c033c1d usb: device_next: new USB Mass Storage implementation
Introduce new USB Mass Storage Bulk-Only Transport implementation
written from scratch. Main goal behind new implementation was to
separate USB and SCSI parts as clearly as possible.

Limited set of SCSI disk commands is implemented in separate source code
file that is internal to USB device stack. While it should be possible
to use the SCSI implementation by other components there is currently no
other user besides USB MSC and therefore SCSI header is kept private.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-02-24 15:19:20 +01:00
Johann Fischer
c51744c6ee usb: device_next: use consistent nil descriptor name
Use a consistent nil_desc name for the descriptor that
terminates a class (function) descriptor.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-24 14:02:37 +01:00
Yuval Peress
8ac822e69c emul: Cleanup emul directory
Avoid implementations in the subsys emul directory to keep the directory
focused on emulator subsystem instead of consumers. Consumers should be
implemented side-by-side to their drivers

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress
a6326f1f7f bmi160: move emulator to driver directory
Allow the emulator to sit in the same directory as the driver
implementation. This will make working on the emulator much easier and
keep the emulator subsystem directory clean by allowing it to focus on
the actual subsystem and not the use cases of the subsystem.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Krishna T
50c1f857e0 net: l2: wifi: Log packet errors
Log packet errors, this is handy for debugging.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-24 11:49:41 +01:00
Andries Kruithof
226c99b455 tests: bluetooth: add prefix to exposed API
In ull_llcp* some functions used in unittesting did not have
the llcp_ prefix
Although this is not a big issue since they are only used when
testing the module this commit adds the prefix so that we
have a more consistent naming

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 11:46:39 +01:00
Andries Kruithof
e6ba1eed90 bluetooth: controller: update unittests for LLCP to use proper ZTEST API
Update unittests for the following areas/controll procedures
- API
- collision handling
- invalid PDUs
- unsupported procedures
- buffer allocation
- TX queue
- Data Length Update
- PHY update
- Encryption
- Ping
- Version
- Channel map update
- Min. used channels
- Connection update
- SCA
- Terminate connection
- CTE request
- CIS create
- CIS terminate

Also moved the internal API tests from the ull_llcp* files
to the proper unittest C-file

Unused files  are removed

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 11:46:39 +01:00
Vinayak Kariappa Chettimada
ade92f4d28 Bluetooth: Controller: Fix mayfly priority check when in ZLI
Fix mayfly_prio_is_equal() function when BT_CTLR_ZLI is
enabled.

When Zero Latency IRQs are used, LLL execution priority
is the Zero Latency IRQ priority and will not be equal
to ULL execution priority.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-24 11:00:43 +01:00
Vinayak Kariappa Chettimada
e409aadf0c Bluetooth: Controller: Fix Peripheral CIS supervision timeout
Fix Peripheral CIS supervision timeout due to missing access
address timestamp capture in subsequent subevents when
anchor point was not sync in the first subevent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-24 11:00:36 +01:00
Zachary J. Fields
66aff25396 usb: usb_transfer.c: Address -Wextra warnings
Changed incrementing `for` loop counters to `size_t` from `int` to
eliminate warning, "warning: comparison of integer expressions of
different signedness: 'uint32_t' {aka 'unsigned int'} and 'int'
[-Wsign-compare]"

Signed-off-by: Zachary J. Fields <zachary_fields@yahoo.com>
2023-02-24 09:39:01 +01:00
TOKITA Hiroshi
cccfc8fc8f fb: cfb_shell: set pixel format as MONO10 or MONO01 on initializing
Set the display's pixel format to MONO10 or MONO01 that cfb supports
on cfb initializing.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
TOKITA Hiroshi
279c722edb fb: cfb_shell: turn off display_blanking at initializing
Turn off display_blanking to make it able to refresh on a device
even when blanking default off.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-02-24 09:26:30 +01:00
Emil Gydesen
5d5dffef76 Bluetooth: Audio: Fix ASCS check for streaming state
Add missing check for receiver_ready in the state
change to enabling state. This change makes the
the check in the state change similar to the check
in ascs_ep_iso_connected

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-24 09:24:34 +01:00
Johann Fischer
d17119c612 usb: device_next: add feature endpoint halt/clear state update API
Add USB device class API to notify class instances that an endpoint
has been halted or cleared due to a feature request.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-24 09:15:55 +01:00
Andries Kruithof
94cfb8dbcf Bluetooth: add decoding for BLE 5.4 version string
The BLE 5.4 specification was recently released. Here the
version strings are updated

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 09:13:18 +01:00
Andries Kruithof
b02ce97dd0 Bluetooth: controller: update bluetooth version to 5.4
The Bluetooth 5.4 specification was recently released, and has a new
version identifier (0x0D or decimal 13) assigned to it in the
Bluetooth Assigned Numbers.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-24 09:13:18 +01:00
Aaron Massey
107cb86bb3 ztest: Add initial zexpect API for delayed failing
Add the zexpect API, inspired by GoogleTest's EXPECT API. This API reports
test failures while allowing test execution to continue. This enables test
reports to show more than a singule failing property on a failing test.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-02-23 20:34:39 +01:00
Andrei Emeltchenko
8e84d840b5 usb: Fix build for 64 bit platforms
Use proper format for size_t type eliminating warnings of type:

...
error: format '%u' expects argument of type 'unsigned int', but
argument 2 has type 'size_t' {aka 'long unsigned int'}
[-Werror=format=]
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-02-23 17:51:31 +01:00
Emil Gydesen
300491af34 Bluetooth: Audio: Shell: Audio shell improvements
This commits allows for setting up multiple streams in
a single CIG as the unicast client.

It fixes an issue with the unicast server not using
the configured QoS when transmitting audio data.

Improves upon setting the preset for the different
type of streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 10:49:53 +01:00
Hubert Miś
2c3863160d ipc: multi-endpoint icmsg cleanup
The multi-endpoint backend of the ipc_service subsystem contains two
roles with separated implementations: initiator and follower. There
was many code duplications for both roles. This patch introduces a new
IPC library: icmsg_me containing common code extracted from both roles
and encapsulating access to common data fields.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2023-02-23 10:46:25 +01:00
Nick Ward
ca3a4f5f5b shell: backends: dummy: default to log level INF
This change fixes code to match the description in
https://github.com/zephyrproject-rtos/zephyr/pull/55061
(see commit 9ecef4b).

This preserves the previous default behaviour of the
shell dummy backend.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-02-23 09:55:11 +01:00
Robert Lubos
43a86b8138 net: tcp: Fix packet processing result reporting
TCP implementation abused the packet processing result reporting
mechanism, by reporting NET_DROP for every packet other than data
packets (which were passed to the application). This simplified the TCP
implementation a bit, as it didn't need to deal with packet releasing.
While technically it worked, it gave incorrect results when it comes to
packet statistics, as a lot of valid TCP packets were counted as
dropped.

This commit fixes this. Each packet that was properly processed by the
TCP stack is not either released at the TCP level, or passed to the
application. In both cases, NET_OK is returned to the network core,
indicating the packet has been properly processed and consumed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-23 09:07:52 +01:00
Emil Gydesen
4fcc3f0c1e Bluetooth: Audio: Add guard for bt_audio_codec_qos_to_iso_qos
The function are only used by the broadcast roles and
the unicast client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Emil Gydesen
f5f1664a41 Bluetooth: Audio: Move most of unicast client-only code from stream.c
Some operations such as Config, QoS, Enable and Stop
are only available for the unicast client, but since
they share the bt_audio_stream prefix, we leave the
agnostic part of it in stream.c, and move the actual
implementation to unicast_client.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Emil Gydesen
6303fa0c18 Bluetooth: Audio: Remove unicast server specific code from stream.c
stream.c had code that was only useful for the unicast server/
ASCS, and have been moved to ascs.c instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-23 08:58:52 +01:00
Stig Bjørlykke
b77c234691 net: icmpv6: Initialize dns sockaddr in RA RDNSS
Initialize struct sockaddr_in6 in RDNSS handling to avoid
uninitialized sin6_port or sin6_scope_id.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-22 14:26:39 +01:00
Seppo Takalo
abb3163d82 net: lwm2m: Clear out the timestamp when we start registration
There was a corner case that last registration timestamp was used
to detect if we can try UPDATE instead of full registration.

When timestamp was not cleared and DNS resolving failed, it might
cause engine to skip the resolving and continue retrying an UPDATE
message until timeout.

Fixes #54504

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
d8b8d53f5f net: lwm2m: Drop observations when falling back to registration
When we have establised an DTLS handshake and try LwM2M Update,
if the server rejects it, we fall back to sending full registration
but when doing so, we should also clear out any observations.

It was intentional that we don't go to ENGINE_DO_REGISTRATION
state as that would close the socket and cause DTLS handshake.

Fixes #54974

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
96a4bedd30 net: lwm2m: Don't ignore socket errors when sending
Only socket error that we should ignore is EAGAIN (EWOULDBLOCK),
others might be indicating that there are some serious errors
in network layer.
When network stack would block us, just drop the packet and
let CoAP layer handle the retrying.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo
ea1eb28135 net: lwm2m: Fix build issue on time-series cache
This was only missing a variable declaration.

Fixes #55031

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Seppo Takalo
bf49540a8d net: lwm2m: Add const qualifier to many pointers
Various functions, mostly concerning time-series cache, were not
using const pointer while they still did not modify the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Emil Gydesen
b46edc7137 Bluetooth: Audio: Fix bad shell string formats
There was a couple of shell prints that was not
formatted correctly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-22 12:19:04 +01:00
Andries Kruithof
ddd83c3bc0 Bluetooth: controller: correct conditional compile for central FEX
In the switch statement there are two cases guarded by ifdef's.
These cases are not compiled in for the following Kconfig settings:
BT_PERIPHERAL=n
BT_CTRL_PER_INIT_FEAT_XCHG=n
The following function call then becomes dead code
This is fixed here by adding the proper guards around the whole case
statement

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-02-22 12:16:03 +01:00
Marco Argiolas
9ecef4b415 shell: backends: add init log level for dummy shell
Dummy shell was always started with log backend enabled with filter
 statically set to INFO level.
AFAIK no use of such log backend can be made, thus causing waste of
 resources.
The new changes keep INFO as the default filter level. In order to
 disable log backend to be attached to the Dummy shell,
 CONFIG_SHELL_DUMMY_INIT_LOG_LEVEL_NONE has to be set.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-02-22 12:15:24 +01:00
Fabio Baltieri
8c6137d7a7 build: sort and compact drivers and subsys CMakeLists and Kconfig
There are just list of child files to include, right now there's a hint
of that trying to be alphabetical but then entries have been added with
various logic, so one has to figure where stuff has to be added.

Rewrite these to:
- keep the list alphabetical, for CMakeLists unconditional first,
  conditional after so one just has to select and sort
- drop the spaces in the Kconfig
- use a single space between  target and directory
- rename from "Sub Systems" to "Subsystems" (single word)

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-22 10:25:11 +01:00
Stefan Schwendeler
4662c40888 net: lwm2m: read command uses hexdump as default print format
A default format that does always print something useful.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-22 08:50:56 +01:00
Sam Hurst
df117e563a usb_c: Add super state to handle Sender Response Timer
Any Power Delivery message state that expects a reply must
start a sender response timer. This change addes a super
state that implements the Sender Response Timer
functionality, from which Power Deleiver messages states
can inherit from.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-02-21 18:04:04 -05:00
Fabio Baltieri
9b30667c77 build: drop LEGACY_INCLUDE_PATH support
LEGACY_INCLUDE_PATH has been defaulting to "n" and marked as deprecated
in both v3.2 and v3.3. Drop the option entirely for v3.4.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-21 15:06:48 +01:00
Siyuan Cheng
b475e1fcbf zdsp: add ARC DSPLIB backend for zdsp
Introduce ARC DSPLIB backend zdsp library for ARC target.
Add agu and restrict attributes to map with ARC DSPLIB

Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
2023-02-21 15:06:06 +01:00
Stig Bjørlykke
0f71a130ef net: sockets: getaddrinfo: Minor refactoring
Minor refactoring in getaddrinfo() to make the code easier to
read and to make handling IPv4 and IPv6 support more equal.

- Move common wait and error handling code to exec_query()
- Use the same check for CONFIG_NET_IPV4 and CONFIG_NET_IPV6
- Add extra sanity check for family before exec_query()
- Do not set errno when return DNS_EAI_ADDRFAMILY

Fix issue with setting port number for all DNS servers.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-21 15:02:35 +01:00
Emil Gydesen
4f5e113dfd Bluetooth: Audio: Fix bad log statement in cap_initiator
Fix missing argument for a log statement.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-21 11:00:18 +01:00
Stig Bjørlykke
cb50d49f33 net: icmpv6: Implement IPv6 RA Recursive DNS Server option
Handle RA RDNSS and use the first DNS server fetched. This is needed
when building IPv6 only without static DNS server IP addresses.

This implementation does not handle the lifetime, because the current
resolve logic does not have support for a DNS server lifetime.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-21 10:59:18 +01:00
Ajay Parida
c69731a281 net: wifi_mgmt: Display TWT setup response status
Display the TWT setup response status.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-02-21 10:58:40 +01:00
Jeroen van Dooren
d20cceb48e net: ip: net_mgmt: Increase default queue size
There is no reason why the default size should be 2,
because an event is only a combination of

{uint32_t + void*} + info

Using 2 as default causes a high risk of loosing events,
setting the default to a more sensible value of 5 still
restricts memory usage but keeps it more safe.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-02-21 10:58:10 +01:00
Jeroen van Dooren
a63fcb67b6 net: ip: net_mgmt: Prevent loss of event
The current implementation doesn't handle
re-entrant calls correctly, causing events
to get lost.

Under specific conditions, re-entrancy happens
from event callback done by net_mgmt.c back into
'net_mgmt_event_notify_with_info' causing circular
buffer administration corruption.

These conditions are:

- llmnr_iface_event_handler
- mdns_iface_event_handler
- wifi_mgmt_raise_connect_result_event
- dhcpv4_immediate_timeout uses a workaround

Validated the fix on a Nucleo_H743ZI, using an
sample app.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-02-21 10:58:10 +01:00
Krishna T
55802e5e86 net: l2: ethernet: Fix double free
In the case of no ARP entry, the incoming packet is added to the ARP's
pending queue, while ARP is being resolved. Here a reference is taken
by the ARP layer to the packet to avoid it being freed, but the Ethernet
immediately puts down the reference and send the ARP packet to the
driver.

If the ARP request fails for some reason, L2 returns failure to net_if
which then puts down the reference and the packet will be freed as the
reference count is now zero.

But the packet is still in the ARP's pending queue and after timeout
ARP will put down the reference causing double free bus fault (double
free message is only seen if the CONFIG_NET_PKT_LOG_LEVEL_DBG is
enabled, so, a bit hard to debug.

Fix this by clearing the ARP entry and pending queue after taking a
reference and then free ARP packet, IP packets are either freed by ARP
pending queue drain or net_if layer.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 19:45:28 +01:00
Marcin Niestroj
830308e00f Bluetooth: host: increase BT_CONN_TX_USER_DATA_SIZE for 64bit platforms
Commit 2c00dd5fec ("Bluetooth: host: check net bufs have enough room in
user_data") added a build time check of user data size. This check does not
pass with default CONFIG_BT_CONN_TX_USER_DATA_SIZE=8 and with
`native_posix_64` platform, as 16 bytes are needed in order to store
`struct tx_meta`.

Select 16 as default value for 64bit platforms, so Bluetooth samples/tests
are buildable for `native_posix_64`.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-02-20 19:44:25 +01:00
Emil Gydesen
928e5bbcf0 Bluetooth: Audio: CAP inittiator broadcast stop procedure
Implemented support for stopping and deleting a
CAP broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
9d0ec99315 Bluetooth: Audio: CAP initiator broadcast metadata update
Add support for the update metadata for broadcast audio
procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
6f1bb59b26 Bluetooth: Audio: Implement bt_cap_initiator_broadcast_audio_start
Implement the CAP initiator broadcast audio start procedure.

This basically just verifies that the stream context
is set in the metadata, and then calls the BAP
procedure.

We define a new opaque struct, bt_cap_broadcast_source,
that is just an abstraction of the bt_audio_broadcast_source
but is used to indicate that these functions require a
broadcast source created by the CAP function (and not the
BAP) function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:24:34 +01:00
Emil Gydesen
17b7854961 Bluetooth: Audio: Fix for PA sync in broadcast sink
Fixes a bug where we cleanup the broadcast sink without
properly terminating the BIG sync first.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 13:22:15 +01:00
Vinayak Kariappa Chettimada
659294bc3f Bluetooth: Controller: Fix AUX_ADV_IND AUX_SYNC_IND radio utilization
Fix AUX_ADV_IND AUX_SYNC_IND radio utilization by having a
configurable offset.

Define an offset between AUX_ADV_IND and AUX_SYNC_IND when
using Advertising Interval for the Extended Advertising and
Periodic Advertising that are same or multiple of each
other, respectively.

Note, to get advertising intervals that are same or
multiple, the Periodic Advertising Interval shall be 10
millisecond more than the Extended Advertising Interval;
this is because the AUX_ADV_IND PDUs are scheduled as
periodic events of Extended Advertising Interval plus 10
milliseconds (Advertising Random Delay) as the periodic
interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 13:18:12 +01:00
Vinayak Kariappa Chettimada
a8862e2adb Bluetooth: Controller: Fix Close Isochronous Event implementation
Fix the Close Isochronous Event (CIE) implementation so that
it follows the Bluetooth Core Specification definition:
Link Layer implementations will normally end a CIS event
early when all scheduled payloads in both directions have
been transmitted and acknowledged.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 11:48:56 +01:00
Vinayak Kariappa Chettimada
e0f5675e70 Bluetooth: Controller: Rename lll_df_conf_cte_tx_disable()
Rename lll_df_conf_cte_tx_disable() to lll_df_cte_tx_disable()
so that it can be used as a common function between connection
and connectionless implementations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 11:36:58 +01:00
Emil Gydesen
9756aea801 Bluetooth: Audio: Ensure strtoX correctness in vcp_vol_rend.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
fe1d5a8177 Bluetooth: Audio: Ensure strtoX correctness in vcp_vol_ctlr.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
668ed75a22 Bluetooth: Audio: Shell: Fix VCP location check
The location value is a uint32_t, and not uint16_t.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
caf259af65 Bluetooth: Audio: Ensure strtoX correctness in tbs.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
d5e625ce9d Bluetooth: Audio: Ensure strtoX correctness in tbs_client.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
87cd6dd743 Bluetooth: Audio: Ensure strtoX correctness in mpl.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
97f14779a5 Bluetooth: Audio: Ensure strtoX correctness in micp_mic_dev.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
07f4c83610 Bluetooth: Audio: Ensure strtoX correctness in micp_mic_ctlr.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
1bf9aae455 Bluetooth: Audio: Ensure strtoX correctness in media_controller.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
f0ea061b3a Bluetooth: Audio: Ensure strtoX correctness in mcc.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
0c9180ef99 Bluetooth: ISO: Ensure strtoX correctness in iso.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
ab9d2c32c9 Bluetooth: Audio: Ensure strtoX correctness in csip_set_member.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
311476d5ce Bluetooth: Audio: Ensure strtoX correctness in csip_set_coordinator.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
774f607cfe Bluetooth: Audio: Ensure strtoX correctness in cap_acceptor.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
760e987529 Bluetooth: Audio: Ensure strtoX correctness in bap_scan_delegator.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
7bbddc14e3 Bluetooth: Audio: Ensure strtoX correctness in bap_broadcast_assistant.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Emil Gydesen
6fa4b00180 Bluetooth: Audio: Ensure strtoX correctness in audio.c
Verify all values returned by calls to strtoX and convert
to the shell_strtoX functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:29:44 +01:00
Siddharth Chandrasekaran
011e784844 mgmt/osdp: More error handling and other cleanups
cp_build_command returns the length of the built packet and early
returns for errors. This means there is no need to keep track of return
code in a separate variable -- if we reached the end, we succeeded.

Along with this change, some more changes to enhance maintainability and
readability are also done.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
20f806de4e mgmt/osdp: cp: Rework CP state management
With changes to the phy layer and the way we build and dispatch
commands, we can now simplify some parts of CP state machine. This patch
builds on previous patches to reduce some state transitions and fixes
some bugs in those paths.

While at it, also implement an exponential back-off for PD offline after
a timeout. This is useful when there is a transient PD timeout but the
PD itself is not totally dead.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
d92c2e4ba1 mgmt/osdp: pd: Rework state machine to handle multiple packets
After the check_packet() split from decode_packet() for handling multiple
packets in the RX buffer, PD state machine needed to me modified to
start handling it correctly. While at it, simplify the states as PD does
not have as much state anyways.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
062a45ef35 mgmt/osdp: cp: Split build_packet and send_command
The method send_command was building the packet and also sending it.
This is a problem because even command build failures are reported as
command send failures; although the former can be mitigated by changing
kconfig parameters depending on use cases.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
ec53f2f6a8 mgmt/osdp: phy: Move packet checks out of decode_packet
To handle multiple packets in RX buffer, we need to perform checks on
the buffer first and determine the length of one packet and extact only
that many bytes from the RX buffer instead of pulling everything at
once and failing if there are bytes from the next packet in the buffer.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Siddharth Chandrasekaran
b0cf5163d8 mgmt/osdp: cp: Move set PD online status to a method
When a PD is set online, we need to do other actions along with it. To
make this easier in future, move cp_set_state(pd, OSDP_CP_STATE_ONLINE)
to it's own method cp_set_online(pd).

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-02-20 11:29:23 +01:00
Jamie McCrae
1b4b979f87 mgmt: mcumgr: Change select to depends on in Kconfigs
Select in Kconfig causes many issues with dependency loops, this
resolves the issue by replacing most select with depends on for
MCUmgr, including updates to the sample smp_svr application and
tests.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 11:27:43 +01:00
Magdalena Kasenberg
e77b571ebd LE Audio: Fix response code expected by ASCS/SR/SPE/BI-18-C
When handling ASE Control operations requested by client,
first verify that the requested ID is within the allowed range.
If it does, lets assume that the NULL returned from ase_find()
means the ASE state is set to idle.

This will fix ASE Notification Response code expected by
the ASCS/SR/SPE/BI-18-C PTS test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 11:26:45 +01:00
Emil Gydesen
c0150c9ce5 Bluetooth: Audio: Ensure stream disconnect correctness for unicast client
Add a new function for the unicast client that verifies whether
or not the unicast client can terminate the CIS given the
state of any paired endpoint and the CIS state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
ad304697ab Bluetooth: Audio: Handle GATT/ISO race condition in unicast client
When releasing a stream causing the CIS to disconnect, there was
a race condition between the CIS disconnect event and the
idle state notification from the unicast server.

This ensures that if we are disconnecting a CIS as part of the
release, then we wait for the CIS disconnect event before calling
the "released" callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
d2dfc3c475 Bluetooth: Audio: Add addition ISO chan state check before disconnect
Add state check for BT_ISO_STATE_CONNECTING before disconnecting
the CIS, else we could end up in a race condition where we
did not disconnect the connecting CIS, and then still have
a CIS afterwards.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
984ce52ddb Bluetooth: ISO: Fix state checks for bt_iso_chan_disconnect
The behavior of bt_iso_chan_disconnect depends on the
state of the ISO channel.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
c67c7728a6 Bluetooth: Audio: Unicast client check ISO state before disconnect
Add a check to see if the ISO is connected before we attempt to
disconnect it. In the case where a stream was not in the streaming
state and was released, the CIS is unlikely to be connected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:26:25 +01:00
Emil Gydesen
fdc26eee78 Bluetooth: Audio: MCS reject long read if value changed
Add support for reject long read if a long value is
changed during the read.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
281d0a3fc8 Bluetooth: Audio: Add media player icon URL changed callback
Add support for notifying MCS a player icon URL change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
4d595014ab Bluetooth: Audio: Add media player name changed callback
Add support for notifying about a player name change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
89e907cb3d Bluetooth: Audio: Truncate MCS notifications per conn
When notifying a long (string) value in MCS, each
connection's MTU is taken into account when
(potentially) truncating the notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Emil Gydesen
788abf6811 Bluetooth: Audio: Fix truncation of MCS string notifications
The truncation of the MCS string notifications was incorrect.
As per the MCS specification, the MCS shall send ATT_MTU - 3
if the value cannot fit in the notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 11:25:42 +01:00
Sam Hurst
2d510fef8d usb_c: Notify DPM of Unsupported message reception
Notify the Device Policy Manager when an unsupported
message is received.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-02-20 11:24:07 +01:00
Robert Lubos
243af28a2f net: ipv4: Implement fallback to LL address
According to RFC3927, hosts with only IPv4 LL address should still be
able to send packets to destination w/o IPv4 LL address:

   A host with an IPv4 Link-Local address may send to a destination
   which does not have an IPv4 Link-Local address.  If the host is not
   multi-homed, the procedure is simple and unambiguous: Using ARP and
   forwarding directly to on-link destinations is the default route

This behaviour however was not possible with Zephyr, which only allowed
to use IPv4 LL source address for IPv4 LL destinations.

Fix this, by introducing a final fallback (only if IPv4 autoconf is
enabled), to select IPv4 LL address as a source address if no other
address is available.

Additionally, modify the ARP routine a bit if IPv4 LL address is in use.
There's no really point to forward the packet to gateway if IPv4 LL
address is used, as such addresses are not routable. Instead, try to
find the peer in local network in such case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-20 11:19:14 +01:00
Marco Argiolas
92a739e4b4 logging: shell command "disable" fails for "backend" subcommand
A fix to accept valid shell commands of the form `log backend
 shell_rtt_backend disable`, i.e. to affect all modules when no modules are
 specified.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-02-20 11:13:15 +01:00
Vinayak Kariappa Chettimada
3c0c9aca40 Bluetooth: Controller: Replace WFE use with k_cpu_atomic_idle()
Replace the use of WFE with Zephyr kernel supplied
k_cpu_atomic_idle() interface.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Vinayak Kariappa Chettimada
b46b833a7b Bluetooth: Controller: Reuse cpu_sleep interface
Reuse cpu_sleep() interface consistently in Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Vinayak Kariappa Chettimada
67fa62fe22 Bluetooth: Controller: Add a DSB in sleep interface
Add a DSB before doing WFE in cpu_sleep(), to ensure the
memory transactions are complete.

Add a note clarifying a dependency for the existing solution
(dependency is satisfied by ARCH code but is good to state
clearly).

Relates to commit f1264b7e47 ("drivers: entropy: nrf5: add
docs and a DSB in get_entropy_isr").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-20 10:34:27 +01:00
Jonathan Rico
3a9c825bab Net: Bluetooth: add enough room to user data
We need to make sure the user_data of the network buffer has enough room to
store the L2CAP metadata.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:53:51 +01:00
Jonathan Rico
2c00dd5fec Bluetooth: host: check net bufs have enough room in user_data
Since we accept buffers from external sources in L2CAP, we need to make
sure that we have enough room in user data to store the metadata necessary
for fragmentation over the HCI link.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:53:51 +01:00
Krishna T
b136676772 net: lib: zperf: Add support to disable Nagle's algorithm
This helps in benchmarking smaller packets, esp. as this is the default
behaviour of iperf.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 09:53:43 +01:00
Mingjie Shen
25e3f655f0 Bluetooth: L2CAP: Fix use of 'br_chan'
Assignment to br_chan should be placed after the call of server->accept().
Otherwise, br_chan will always be a null pointer.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-02-20 09:53:26 +01:00
Aleksandr Khromykh
dd1fc0dd03 Bluetooth: Mesh: fix access to uninitialized memory
Running bsim with Valgrind highlighted a couple of
places where read access to uninitialized memory happens.
Config client rewrites publication parameters with not
initialized uuid pointer. Bitfields those are allocated on
the stack keeps not used area uninitialized too.
Uninitialized area is stored in the persistent memory.
PR fixes that.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-02-20 09:53:14 +01:00
Jani Hirsimäki
f21051b728 net: iface: bypassing IP stack with SOCK_RAW sockets
Bypass the IP stack and go directly to L2 with
SOCK_RAW/IPPROTO_RAW sockets in net_if_send_data().

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2023-02-20 09:52:39 +01:00
Stig Bjørlykke
f3661487da settings: Make settings_subsys_init() thread safe
Multiple components may use the settings subsystem, so ensure
settings_subsys_init() is thread safe.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2023-02-20 09:52:26 +01:00
Aleksandr Khromykh
59edf5cae3 Bluetooth: Mesh: correction lpn rx delay
If extended advertiser is used, then advertiser sends callback
quite close to the real tx end time. No necessity to consider
advertisement time in lpn rx delay. It allows lpn to spend
less time in active scanning and save more power. Unfortunately,
legacy advertiser shows very slow precision. It is mandatory to
consider adv time for it. Additionally, unnecessary considering of
the advertisement duration has been removed for receive window in lpn.
It makes scanner window longer for a couple of milliseconds.
This is the responsibility of friend node to configure window that
it can manage.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-02-20 09:51:53 +01:00
Krishna T
92aa0e8ab6 net: shell: Log missing Ethernet errors
These error counters are helpful for data path debugging.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-20 09:51:23 +01:00
Sean Madigan
e79fee7a2e bluetooth: host: conn: Utilize conn_set_state in conn_destroy
Previously we would call conn_cleanup for all connections,
however this had multiple problems such as:
-Not destroying conn->tx_pending packets and causing an assert
-Calling conn_cleanup for connectable adv, triggering
disconnected callback

Now we will use bt_conn_set_state to manage the teardown of
connections correctly. First, if in connected or disconnecting,
set state to disconnect complete. Then for all states, set
state to disconnected. This will carry out proper cleanup
and teardown when required.

To do this, it was required to keep the tx_thread open as
this is used in disconnecting teardown, so this has been
moved to below the conn_cleanup_all call.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2023-02-20 09:50:48 +01:00
Jun Qing Zou
cd79b81d4d lib: tftp_client: Add TFTP PUT function
Add tftp_put() API to support TFTP WRITE request.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-20 09:50:23 +01:00
Jun Qing Zou
f7b0ccba0c lib: tftp_client: Receive file with arbitrary size
Add a callback for READ request to download files with arbitrary length.
Define TFTP_BLOCK_SIZE in API header for application to allocate buffer.

Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
2023-02-20 09:50:23 +01:00
Mariusz Skamra
bfb2625818 Bluetooth: audio: has: Fix client context allocation
The client context shall be allocated once paired i.e. encryption is
enabled. This fixes issue that client context was allocated only for
bonded devices and as a result the ATT Unlikely Error was replied to
Control Point operation that paired remote requested.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-02-20 09:49:15 +01:00
Mariusz Skamra
668b40a5c2 Bluetooth: audio: has: Rename has_client struct member
This renames has_client.ntf_bonded to has_client.ntf_pending as this
field is valid for paired devices an contains the notification state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-02-20 09:49:15 +01:00
Magdalena Kasenberg
e26e8d1c07 shell: audio: Add print ASE info command
The command prints id, state and dir of all ASEs of default connection.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00
Magdalena Kasenberg
90ab1c56f5 LE Audio: Add helper functions to get endpoints info
The functions allow to return structure holding information of audio
stream endpoint.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00
Magdalena Kasenberg
5d2fb499af LE Audio: Allow server to initiate Codec Config procedure
Required by ASCS/SR/ACP/BV-07-C PTS test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-20 09:49:09 +01:00
Jamie McCrae
7c6f6cd080 fs: fs_shell: Add read test
Adds an optional shell command for testing the speed of the flash
device and file system, which outputs a rough speed for reading a
file.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 09:48:24 +01:00
Jamie McCrae
cef77afba5 fs: fs_shell: Add erase/write test
Adds an optional shell command for testing the speed of the flash
device and file system, which outputs a rough speed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 09:48:24 +01:00
Paul Adelsbach
4d8160d680 Bluetooth: host: suppress adv timeout warning when successful
The warning was visible even when `bt_le_adv_stop()` was successful, which
is confusing to end-users.

Signed-off-by: Paul Adelsbach <paul@boxsection.org>
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-20 09:48:17 +01:00
Emil Gydesen
277e162d82 Bluetooth: Audio: Avoid error log for bidirectional CIS
In the case that the CIS has been setup as bidirectional, and
only one of the directions have an ASE configured yet,
we should only care about valid ISO packets when doing this
check. The reason is that some controllers send HCI ISO data
packets to the host, even if no SDU was sent on the remote
side. This basically means that empty PDUs are sent to the
host as HCI ISO data packets, which we should just ignore.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 09:47:49 +01:00
Emil Gydesen
b9882e2368 Bluetooth: Audio: Guard ep status debug with debug stream data
In the unicast audio streams, there can be a mismatch
between the CIS state and the endpoint state. This
was previously logged, but since this would be logged
continously, we guard it with CONFIG_BT_AUDIO_DEBUG_STREAM_DATA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 09:47:49 +01:00
Ravi Dondaputi
1c547580e4 wifi: shell: Print beacon interval and DTIM period
Print beacon interval and DTIM period as part of Wi-Fi
status output.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-02-20 09:46:34 +01:00
Emil Gydesen
e71460cdb8 Bluetooth: Audio: Only allow receiver to send start command
Only the receiver of the audio is allowed to send the
receiver start ready command.

Furthermore, this removes the automated transition to the
streaming state on the server, as the server now shall
call bt_audio_stream_start to put the stream into the
streaming state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 09:45:18 +01:00
Dominik Ermel
1e0f36e896 fs/fatfs: Move FF_USE_LFN logic to Kconfig
Commit add hidden Kconfig option CONFIG_FS_FATFS_FF_USE_LFN
that is passed to ELM FAT to define FF_USE_LFN configuration.
The FF_USE_LFN still depends, indirectly, on choice
CONFIG_FS_FATFS_LFN_MODE config options
CONFIG_FS_FATFS_LFN_MODE_BSS, FS_FATFS_LFN_MODE_STACK and
FS_FATFS_LFN_MODE_HEAP, but the logic has been moved out of
zephyr_fatfs_config.h into Kconfig file.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-02-20 09:44:18 +01:00
Kumar Gala
5af7ff4558 Bluetooth: Mesh: Cfg_cli: Remove deprecated functions
Remove deprecated functions that have been deprecated for at least
two releases now.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-19 20:48:06 -05:00
Juha Ylinen
fdffdedc41 net: lwm2m: Add event LWM2M_RD_CLIENT_EVENT_REG_UPDATE
New event LWM2M_RD_CLIENT_EVENT_REG_UPDATE to indicate
application that engine starts registration update.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-02-19 20:44:02 -05:00
Rajavardhan Gundi
c71ab5699a tests: drivers: sbs_gauge: Include additional properties
Include tests for Fuel Gauge mode, status, charge current,
charge voltage, design capacity and design voltage.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2023-02-19 20:42:10 -05:00
Tommi Kangas
a25bcfdc59 shell: modules: kernel: add shell command for system heap stats
Added a shell command to print kernel system heap usage statistics.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2023-02-19 20:40:48 -05:00
Mikhail Siomin
b608ddc40f logging: the 'log backend' shell cmd will result in the infinite loop.
The backend_name_get() function always sets 'entry->syntax' to
the name of the last backend, but a calling function iterates
over the idx until 'entry->syntax' is null.
Solution: Added a check that the index is less than the number
of backends and added getting the name of the backend
by the given index.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
2023-02-19 20:37:53 -05:00
Robert Lubos
a28dba2503 net: ip: 6lo: Fix corner case with packet format after IPHC
IEEE802154 drivers expect, that a complete 802.15.4 frame fits into a
single net_buf provided in a net_pkt.

There is a corner case with header compression when this could not be
the case. If the IPv6 packet before IPHC exceeded 802.15.4 MTU, it'd
consist of several net_buf's. This was not an issue, if the IPv6 packet
after header compression still required fragmentation, as the
fragmentation module took care of formatting individual net_buf's
properly.

For short range of packet sizes however this was no the case. The IPv6
packet, after header compression, might not require fragmentation any
more. As the IPHC logic only modified the IPv6 header part, by trimming
the buffer in front of the net_buf, such a packet would still consist of
two net_bufs, even though it should fit into a single 15.4 frame. Such
packet was passed to the driver, causing the driver to send only part of
the packet, from the first net_buf.

Fix this, by using net_pkt functions to manipulate the packet, instead
of operating on net_buf directly. net_pkt_pull() will not trim the
buffer in front, but rather move the entire packet content to the front.
On the other hand, net_pkt_compact() will assure that there's no gaps in
the net_bufs. In result, packets that do not require fragmentation,
should be placed into a single net_buf, as expected by drivers.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-19 20:33:36 -05:00
Théo Battrel
ac3dec5212 Bluetooth: Host: Check returned value by LE_READ_BUFFER_SIZE
`rp->le_max_num` was passed unchecked into `k_sem_init()`, this could
lead to the value being uninitialized and an unknown behavior.

To fix that issue, the `rp->le_max_num` value is checked the same way as
`bt_dev.le.acl_mtu` was already checked. The same things has been done
for `rp->acl_max_num` and `rp->iso_max_num` in
`read_buffer_size_v2_complete()` function.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-02-18 00:09:13 +09:00
Marek Pieta
aed165df61 Bluetooth: host: Fix SC indication on encrypt change
The SC indication can be sent only if the GATT Service Changed is
enabled in the configuration. Change fixes build issues related to
implicit sc_indicate declaration when Service Changed is disabled.

Fixes: #54813

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Marek Pieta
32e534c935 Bluetooth: host: Remove GATT Client dependency for storing CCC and CF
Change removes GATT Client dependency for storing CCC and CF on pairing
complete and identity resolved. These features are needed also if GATT
Client role is disabled.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Jonathan Rico
a0614b6cd1 Bluetooth: host: save CF and CCC values written before bonding
On bond establishment: save the CF and CCC data that have been written
before the peer was bonded.

On identity resolved: update the CF data to use the peer's identity address
instead of its private address (same as is currently done for the CCC).

Fixes #54770.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Jonathan Rico
5d46a0c398 Bluetooth: host: fix subtle bug in db_hash_process
Fixes a bug introduced in the previous refactoring: we would always mark
all peers as change-unaware. Now we only do so when the hash has been
recalculated.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-16 00:21:07 +09:00
Jonathan Rico
2a15a63509 Bluetooth: host: don't store hash in db_hash_gen()
Move out the storage of the calculated hash from the fn that calculates
it (db_hash_gen).

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Jonathan Rico
b60b0f3505 Bluetooth: host: don't overwrite GATT DB hash before settings_load
Previously, if the app registered a bunch of services at boot before
calling `settings_load()`, then the hash would be silently overwritten.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Jonathan Rico
e8f3ef29a4 Bluetooth: host: store GATT change-aware status in settings
The spec says we have to persist the change-aware status of bonded peers
between resets.
This stores it at the end of the CF storage that we currently have.

Fixes #54173

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Jonathan Rico
4772e5695f Bluetooth: host: Store Client Supported Features on write
Store the Client supported features value when it is written to, instead of
only on disconnection/identity resolved.

Works around the situation where a user bonds, CF is written and the device
is abruptly powered off, discarding the CF value, but keeping the bond.

Fixes #54172.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-13 12:55:02 +01:00
Magdalena Kasenberg
3c00629bb6 LE Audio: Map EALREADY error of ase_stream_qos()
to send response with code 0x09 = Invalid Configuration Parameter
Value and reason 0x0a = Invalid_ASE_CIS_Mapping.

Previous response code was BT_ASCS_RSP_UNSPECIFIED (0x0e) and
reason BT_ASCS_REASON_NONE (0x00).

Fixes ASCS/SR/SPE/BI-15-C and ASCS/SR/SPE/BI-16-C PTS test cases.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-02-11 08:21:13 +09:00
Georgij Cernysiov
d7cf297d98 usb: device: class: rndis: remove CDC descriptors
RNDIS is not a CDC class.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-02-11 08:19:32 +09:00
Georgij Cernysiov
3055a8326d usb: device: class: rndis: correct IAD and IF0 descriptors
Use descriptors as dictated by Microsoft and USB-IF.
That allows the RNDIS device to be correctly detected on Windows.

* Microsoft: https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/supported-usb-classes
* USB-IF Defined Class Codes: https://www.usb.org/defined-class-codes

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-02-11 08:19:32 +09:00
Georgij Cernysiov
fd1f28efb6 usb: device: class: rndis: correct packet reception
Allows receive packets that are bigger than
CONFIG_RNDIS_BULK_EP_MPS.

Considering:
* MaxPacketsPerTransfer is 1
* MaxTransferSize is 1558
* PacketAlignmentFactor is 0 (20=1)

The rndis_bulk_out shall be able to receive transfer
up to 1558 bytes (inclusive).

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-02-10 15:34:05 +01:00
Morten Priess
3712094417 Bluetooth: controller: Fix CIS establishment procedures
Fixing typo in llcp_lp_cc_established revealed the need for completing
the CIS establishment procedure by additional call to local/remote
check_done function.

Fixed by exposing lr_check_done and rr_check_done with naming update and
calling after injecting the CIS_ESTABLISHED event.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-02-10 15:28:35 +01:00
Morten Priess
98161bd1d3 Bluetooth: controller: Enable CIS establishment in same ACL instant
If CIS offset in LL_CIS_IND is less than EVENT_OVERHEAD_START_US, the
controller is not able to establish the CIS in the ACL connection event
specified, but needs to start setup one connection event earlier.

With this commit, if offset is larger than EVENT_OVERHEAD_START_US the
first CIS event can be prepared in due time immediately.

This enables the controller to setup first CIS, even when instant is
equal to the ACL event_counter.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-02-10 15:28:35 +01:00
Vinayak Kariappa Chettimada
220170a549 Bluetooth: Controller: Fix Periodic Advertising time reservation
Fix Periodic Advertising time reservation when enabling with
ADI support. As the PDU is updated, use the updated PDU to
calculate the time reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
1ed9bda92d Bluetooth: Controller: Schedule BIG event after Periodic Advertising
Add implementation to schedule BIG events after Periodic
Advertising when Periodic Advertising is enabled after
Extended Advertising has already been enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
2ae86f4e8d Bluetooth: Controller: Use context specific get interface
As the range of ticker_id has been checked, context specific
get interface be used instead of doing range check again in
ull_hdr_get_cb().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
d93bc9dbd8 Bluetooth: Controller: Fix auxiliary PDU time reservation calculation
Fix auxiliary PDU time reservation calculation to reserve
for possible increase in PDU len due to updates to data in
the Common Extended Header Format of the PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
f4a0543bf4 Bluetooth: Controller: Refactor duplicate aux_time_get implementation
Refactor duplicate aux_time_get() implementation and reuse
the same code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
82ad0777c0 Bluetooth: Controller: Minor rename to sync_time_get()
Minor rename of file static function sync_time_get().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
2fabaf37ef Bluetooth: Controller: Fix assertion scheduling first BIG event
Fix assertion due to delayed prepare of first BIG event when
supporting encryption. Crypto calculation introduce extra
processing delay causing the scheduling of first BIG event
to be delayed. Detect such delay and skip to next ISO
interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
6dbe82a7db Bluetooth: Controller: Relax radio_tmr_start_us assert on win widening
Relax radio_tmr_start_us() delayed start assertion when
window widening in progress.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
11cfd8acc3 Bluetooth: Controller: Fix radio_tmr_aa_save() value for ISO receive
Fix the access address and radio ready timestamp to derive
the value of the first subevent, so that correct anchor
point reference is used in scheduling subsequent subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
64979d7b6b Bluetooth: Controller: Fix uninitialized CIS LLL member variables
Fix uninitialized CIS LLL structure member variables,
uninitialised CIS acl_handle causes HCI command disallowed
for acl_handle's other than 0x0000.
Initialize other variables like sn, nesn etc. when create
CIS control procedure is performed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Vinayak Kariappa Chettimada
09897e2c8d Bluetooth: Controller: Fix GPIO debug pins for ISO Central
Fix the GPIO debug pin assignment for ISO central role.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-10 15:09:02 +01:00
Jamie McCrae
fce2cadcde shell: backend: Set RX size default to 256 if shell MCUmgr is enabled
This fixes an issue whereby when USB CDC is used for receiving MCUmgr
commands, the commands are corrupted, invalid or messed up by
increasing the receive buffer size so that it can handle at least 1
full MCUmgr fragment.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-10 22:25:21 +09:00
Herman Berget
cc9d2102f2 Bluetooth: Fix enabling PAST as advertiser
It is possible to do PAST as advertiser without support for periodic sync.

Fixes #54613.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-02-09 13:22:57 +01:00
Pierce Lowe
ba09a252ec bluetooth: host: refactor bt_hci_le_per_adv_report data reassembly
Refactoring the periodic advertisment report receive function
to make the handling of data reassembly more readable.

Signed-off-by: Pierce Lowe <pierce.lowe@nordicsemi.no>
2023-02-09 13:12:24 +01:00
Pierce Lowe
a7c1c27e38 bluetooth: host: drop incomplete data in periodic scanner
This changes the periodic scanner to drop periodic adv
reports with incomplete data. This avoids incorrect data
being sent to application in the case where the periodic
adv data is not successfully received by the scanner.

Fixes zephyrproject-rtos#54072

Signed-off-by: Pierce Lowe <pierce.lowe@nordicsemi.no>
2023-02-09 13:12:24 +01:00
Szymon Czapracki
6c374215d0 bluetooth: audio: Fix typo in PACS
A simple typo fix.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-02-09 13:09:46 +01:00
Robert Lubos
05ca67c9ba net: ipv6: mld: Don't attempt to send a MLD query if iface is down
Simply return early returning respective error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-08 11:26:42 +01:00
Robert Lubos
e8803ddaae net: dhcpv4: Do not proceed with DHCPv4 when interface is down
It should be possible to configure/initialize the DHCPv4 for an
interface when the interface is down, the DHCPv4 however should not
proceed with the procedure in such case.

Add a simple check to prevent DHCPv4 from sending packets when interface
is down. As the module registers to the NET_IF_UP event, the procedure
will be restarted when the interface goes up.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-08 11:26:42 +01:00
Robert Lubos
004955f715 net: config: Unify the init behaviour when timeout is enabled and not
Currently, if timeout is not configured for the network initialization in
the config module, the initialization function will configure IPv4/IPv6/
DHCPv4 regardless of the interface status. This is not the case when the
timeout is set, and the interface was not brought up during the timeout
period. This lead to ambiguity in terms of interface initialization.

This commits unifies the behaviour between these two cases. The
aforementioned initializations will always take place, regardless of the
interface status. The IPv4/IPv6 and DHCPv4 routines should be prepared
to deal with interfaces that are not brought up. The only difference
now, between timeout and no timeout scenario, is that the former will
report an error in case the timeout occurs wile waiting for the expected
events.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-08 11:26:42 +01:00
Seppo Takalo
437bfc58d9 net: lwm2m: Fix deregistration timeout state handling
Socket faults or timeouts in CoAP deregistration messages
caused RD client state machine to restart registration.

Fixes #54136

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-08 11:20:00 +01:00
Ryan Erickson
d19e99b6d7 net: DHCPv4: Filter NAK during requesting state
During the requesting state, ignore NAKs from any
non-requesting server.  This gives the requesting
server a chance to ACK the request.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2023-02-08 19:05:13 +09:00
Johan Hedberg
9c459b33fb Bluetooth: SMP: Fix setting key distribution bits for no-bonding
9.4.2 section, Part C, Vol 3 of the Bluetooth Core specification v5.3
states the following in the case that the device is in non-bondable
mode:

If Security Manager pairing is supported, the Host shall set the
Bonding_Flags to ‘No Bonding’ as defined in [Vol 3] Part H, Section
3.5.1 and bonding information shall not be exchanged or stored.

Fixes #54104

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-02-08 19:04:51 +09:00
Chris Friedt
c093678784 net: sockets: fix fcntl.h usage
If we are using `CONFIG_ARCH_POSIX`, then include
`<fcntl.h>`. Otherwise, include `<zephyr/posix/fcntl.h>`
since there are no requirements to use `CONFIG_POSIX_API`
internally.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-08 19:04:25 +09:00
Chris Friedt
ac3efe70cd net: sockets: socketpair: header fixups
* include `<zephyr/posix/fcntl.h>` instead of `<fcntl.h>`
* drop unused logging header and module declaration
* reorder headers alphabetically

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-08 19:04:25 +09:00
Wolfgang Puffitsch
c8c81d28b7 Bluetooth: controller: Only allow supported feature bits to be set by host
Redefine mask of host-controlled feature bits to include only features
that are supported by the controller. This fixes a conformance test
failure where setting an unsupported host-controlled feature bit was
not rejected as it should.

Set the Connected Isochronous Streams (Host Support) bit from the host
only if unicast support is configured to avoid failures in
broadcast-only configurations.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2023-02-08 01:16:10 +09:00
Théo Battrel
6dfe5b0e9c Bluetooth: Small fixes for some Bluetooth Shell commands
Update help message of some commands of the Bluetooth Shell that were
inconsistent.

Also add the `dir-rpa` parameter to the advertiser parameters to fully
support directed advertisment parameters.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-02-07 11:58:00 +01:00
Vinayak Kariappa Chettimada
3d54d46bbc Bluetooth: Controller: Fix Central from overlapping BIG events
Fix advanced scheduling to consider active BIG events when
establishing new Central connections. This will schedule
AUX_ADV_IND, AUX_SYNC_IND and Central connections of similar
interval to be non-overlapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-06 22:06:16 +09:00
Vinayak Kariappa Chettimada
d91b20dd3f Bluetooth: Controller: Fix overlapping multiple BIG events
Update advanced scheduling implementation to consider other
active BIG events when scheduling new BIG instances.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-06 22:05:40 +09:00
Emil Gydesen
9d3e287572 Bluetooth: Audio: Fix ASCS CP subscribe in discovery
During discovery the unicast client subscribes to the
ASCS CP characteristic. However, this was done asynchronously
at the end of the discovery, and the discovery complete
callback was called before the subscription was done.

Since the unicast client relies on the auto CCC discovery,
the actual subscription takes place a few connection intervals
after the unicast_client_ep_set_cp function was called. The
result of this is that the actual subscription was missing
when the unicast client application starts performing
BAP operations.

The change done here postpones the discovery callback
until after the CP subscription has taken place, ensuring
that the unicast client correctly receives the CP notifications
when performing BAP operations. This also allows the unicast
client to use the discovery parameter in the
bt_audio_discover_params struct, rather than yet another
discovery parameter struct, saving some memory.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-06 22:05:15 +09:00
Robert Lubos
f39ba57474 net: ipv4: Fix subnet mask setting when autoconf is used
When IPv4 autoconf is enabled and IPv4 LL address is configured on an
interface, the subnet mask should be updated accordingly, otherwise it
can lead to unexpected behaviour (like for example not identifying peer
LL address as a part of the same subnet).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-06 10:10:54 +01:00
Lingao Meng
b3eeb91869 Bluetooth: Mesh: Remove meaningless condition
Since `schedule_send` always have no-null params.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-02-06 10:08:22 +01:00
Krishna T
8069d47c5e net: pkt: Allow zero payload for non-IPv4/v6 frames
For socket families that are niether INET/INET6 e.g., PACKET, we cannot
estimate header length, so, if the payload is zero as well, networking
stack drop the packet.

Instead, allow for zero header + payload packets and let L2 take care of
handling them, for some L2's this is still a valid frame.

E..g, In case of Wi-Fi this is sent as 802.11 Header + LLC Header
(no payload).

Add unittests for both AF_INET + Zero payload and AF_PACKET + Zero
payload.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-06 10:04:03 +01:00
Emil Gydesen
c4d80f7760 Bluetooth: Audio: Shell: Fix issue with setting contexts
There was a bug where BT_AUDIO_DIR_SINK should have been
BT_AUDIO_DIR_SOURCE when setting supported contexts.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-06 10:03:43 +01:00
Andrei Emeltchenko
250f212688 modbus: Remove redundant check
ctx is the result of pointer math and never NULL.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-02-06 10:03:20 +01:00
Lukas Woodtli
6a5260394b net: coap: Allow insertion of an option at arbitrary position
The insertion moves the data in the message buffer to make space for
the new option.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-02-06 10:02:19 +01:00
Robert Lubos
432ff20a72 net: websockets: Fix websocket close procedure
The websocket implementation did not comply with the RFC 6455 when it
comes to connection close. The websocket should send in such case Close
control frame. This commit fixes this behaviour.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-03 10:37:57 -08:00
Robert Lubos
7f0219985d net: websockets: Fix ZFD_IOCTL_SET_LOCK handling
The websocket "socket" layer did not handle ZFD_IOCTL_SET_LOCK command,
and just forwarded it to the underlying socket. This overwritten the
mutex pointer used by the underlying socket, resulting in erroneous
behaviour in certain cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-03 10:37:57 -08:00
Vinayak Kariappa Chettimada
f00da4b0d4 Bluetooth: Controller: Fix ISO Data sn nesn on flush
Fix sn and nesn values of ISO data when starting a new burst.
When central retransmitted but did not get an ack, it did
not update the sn correctly causing the peripheral to drop
the next ISO data PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-03 20:54:20 +09:00
Vinayak Kariappa Chettimada
278b07c971 Bluetooth: Controller: Fix addr type in PA sync established event
The address type in the periodic adveritising sync
established event is incorrectly set to 0x01
(BT_ADDR_LE_RANDOM) when the address is a resolved one,
where it should have been BT_ADDR_LE_RANDOM_ID.

The address type has been fixed by offsetting by 2 to get
BT_ADDR_LE_PUBLIC_ID or BT_ADDR_LE_RANDOM_ID when the
address has been resolved.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-03 02:26:42 +09:00
Armin Brauns
22430ef8c4 net: ipv6_nbr: count outgoing ND packets as sent ICMP packets
This mirrors the behaviour of MLD packets, the only other ICMPv6 subtype
that is tracked separately.

Inbound ND packets are already counted as received ICMP packets by way of
going through the ICMP receive path.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-02-03 02:25:14 +09:00
Armin Brauns
abd4dd4cc5 net: ipv6_nbr: don't count incoming Neighbour Advertisements in sent stats
This caused outgoing MAC address lookups to count as one received and two
sent Neighbour Discovery packets, when it's really one sent Neighbour
Solicitation and one received Neighbour Advertisement.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-02-03 02:25:14 +09:00
Robert Lubos
e540a98331 net: shell: Validate pointer provided with net pkt command
The net_pkt pointer provided to net pkt commands was not validated in
any way. Therefore it was fairly easy to crash an application by
providing invalid address.

This commit adds the pointer validation. It's checked whether the
pointer provided belongs to any net_pkt pools known to the net stack,
and if the pointer offset within the slab actually points to the
beginning of the net_pkt structure.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-02-03 02:14:32 +09:00
Jonathan Rico
c2e4029aad Bluetooth: host: resume advertising even when BT_EXT_ADV=y
When using extended advertising commands, the advertising set is not
considered to be over until we receive `BT_HCI_EVT_LE_ADV_SET_TERMINATED`
from the controller. Only then do we clear the `BT_ADV_ENABLED` flag.

The problem is that `bt_le_adv_resume` is called on connection established,
which can happen before adv set terminated, and in that case it will
early-return because `BT_ADV_ENABLED` is still set.

This change triggers `bt_le_adv_resume` when we get
`BT_HCI_EVT_LE_ADV_SET_TERMINATED`.

Fixes #53048

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-02-02 17:05:48 +02:00
Peter Mitsis
cbc3e5c999 tracing: Add event tracing to sysview
Adds event tracing to sysview. This will allow the event related
tracing symbols to be found when CONFIG_SEGGER_SYSTEMVIEW is
enabled.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-02-02 20:21:12 +09:00
Peter Mitsis
bdb49f21ad tracing: Resolve undefined event symbols
Fixes various unresolved symbols when kernel event object tracking
is enabled via CONFIG_TRACING=y.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-02-02 20:21:12 +09:00
Seppo Takalo
d0dc67a72d net: lwm2m: Fix native_posix fcntl() calls
Native POSIX target still needs to use the <fcntl.h> header
instead of <zephyr/posix/fcntl.h>

Also removed the include from various files that did not use it.

Also changed fcntl() calls to zsock_fcntl() because we directly
use zsock_* calls elsewhere.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-02 20:05:08 +09:00
Vinayak Kariappa Chettimada
de2029ac58 Bluetooth: Controller: Fix missing DF related radio register reset
Fix missing DF related Radio register reset on radio_reset().

Regression in commit 465a96181d ("Bluetooth: Controller:
Explicitly set all bits of used radio registers") due to the
removal of NRF_RADIO->POWER register use that was used to
reset all Radio registers on every new Radio Event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-02-02 11:15:44 +01:00
Andrei Emeltchenko
f9ced67170 bluetooth: audio: Fix dereference before NULL check
Dereference only after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-30 23:47:55 +00:00
Andrei Emeltchenko
2782d6996a bluetooth: Fix duplicated parameter check
Parameter count is checked several lines below this line.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-30 23:47:55 +00:00
Andrei Emeltchenko
dcb199f581 bluetooth: audio: Fix NULL dereference
Fixes NULL dereference right after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-30 23:46:25 +00:00
Emil Gydesen
8512bd18c6 Bluetooth: Shell: Fix unintialized ad_len bug
`ad_len` was never initiatialized before we started
incremetenting and using it.

We would also override any user data in ad_init, which
is fixed by using the length of the user data as an
offset into the array.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-30 10:08:00 +00:00
Jared Baumann
5a62f2592f net: lib: Fix build warning for sockets_tls
Fixes issue where a build warning would be emmited for sockets_tls.c due
to usage of the deprecated fcntl.h header file.

Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
2023-01-28 08:01:03 -05:00
Andrei Emeltchenko
62ab576a6a logging: shell: Fix using uninitialized variables
Fixes using uninitialized variables using returns with correct return
code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-28 08:55:41 +09:00
Seppo Takalo
ec8884d58f net: lwm2m: lwm2m_client: Fix fcntl header path
We don't default to POSIX_API so use Zephyr's
path for fcntl.h

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-01-27 10:41:19 -06:00
Andrei Emeltchenko
8e72f117e3 net: ieee802154: Remove unneeded check
Fixes dead code warning. At this point we have already checked for
broadcast and it is set to false.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-27 10:38:49 -06:00
Andrei Emeltchenko
3c8c903a2d net: ieee802154: Fix dereference before NULL check
Fixes dereference of sec_ctx->level before checking sec_ctx for NULL.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-27 10:38:49 -06:00
Johann Fischer
9ea25d85cf usb: device_next: update bMaxPacketSize0 based on controller capability
Update bMaxPacketSize0 field of the device descriptor based on
controller capability.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-27 16:11:20 +01:00
Johann Fischer
5c60209e79 usb: device_next: trigger dequeue of control IN endpoint on reset event
There might be pending data stage transfer not finished
while host performs a bus reset.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-27 16:11:20 +01:00
Vinayak Kariappa Chettimada
595860567b Bluetooth: Controller: Workaround sequence number misalignment
Workaround sequence number misalignment to ISO event count
when ISO data is supplied in bursts, example through USB.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
6dfbf7c110 Bluetooth: Remove BT_HCI_DATAPATH_ID_DISABLED define
Remove BT_HCI_DATAPATH_ID_DISABLED define as 0xFF, which is
reserved for future value for Data_Path_Id parameter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
3a37834aa7 Bluetooth: Controller: Add ISO Broadcast and Receive ISR Profiling
Add implementation to generate ISR profiling of Broadcast
ISO and ISO Receive usecase.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Carl Stehle
714f80d225 Bluetooth: Controller: Integrate ISOAL for ISO Broadcast
- Include ISO stream count in ISO streams definitions in
  controller.
- Create ISOAL source on controller when ISO data path is
  setup.
- Send broadcast data buffers transferred from host over
  HCI to ISOAL as ISO SDU fragments.
- Allow bot conn and ISO data to use data_buf_overflow.
- Store ISO interval during BIG create.
- Remove ISO data path for each BIS during BIG terminate
  procedure.
- Set value (temporarily) for ISOAL target_event enabling
  it to Tx data.
- Check status of data fragment sent to ISOAL for memory
  allocation and other errors.
- Destroy ISOAL source when ISO stream released.
- Use ISO Advertising handle, not stream handle to destroy
  ISO data path.
- Remove extra ISOAL sink destroy call when removing ISO
  data path.
- Add FIXME comment as reminder to address LL_ASSERT on
  isoal_status error.

Signed-off-by: Carl Stehle <droid@appception.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
532cf9ba2b Bluetooth: Controller: Fix ISO interval based on Max Transport Latency
Fix calculation of ISO interval such that multiple bursts
can be transmitted per ISO interval. This means we can now
have SDU_Interval < ISO_Interval and more than one SDU will
be transmitted in each ISO_Interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
5fbb3bf42b Bluetooth: Controller: Fix BIS Control PDU being dispatched as ISO Data
Fix missing jump to Rx ISR done that caused the Control PDU
to be enqueued as ISO data PDU, causing the ISOAL to assert
on receiving invalid LLID.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
c32ff9608b Bluetooth: Controller: Fix ISO timestamp wrap around
Fix ISO timestamp wrap around which caused ISOAL to assert
checking for valid timestamp.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
27206e17af Bluetooth: Controller: Initial CIG with 1 CIS support in LLL
Add initial support for CIG with 1 CIS in nRF5 SoC's LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
9d01c16c47 Bluetooth: Controller: Define a internal BT_CTLR_ISO_TX_BUFFERS
Define a internal BT_CTLR_ISO_TX_BUFFERS to allocate ISO Tx
buffers used for Broadcast and Connected ISO.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
479ba351d2 Bluetooth: Controller: Fix Ctrl to Host flow control assertion
Fix Controller to Host flow control assertion handling ISO
stream disconnection.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
069a7c0cbd Bluetooth: Controller: Fix isoal_tx_pdu_emit/source_deallocate race
Fix race between isoal_source_deallocate() and
isoal_tx_pdu_emit(). Initiating a local initiated terminate
triggers NULL pointer dereference.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
cd2796e047 Bluetooth: Controller: Refactor ll_setup_iso_path
Refactor ll_setup_iso_path to support Synchronous Receiver
and Connected ISO to be built together.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
362826ea03 Bluetooth: Controller: Code review rework changes
Assorted code review rework changes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
4f36f95e5f Bluetooth: Controller: Fix uninitialized CIG ULL reference count
Fix uninitialized CIG ULL reference count when creating a
CIG after a previous disconnection.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
ab89f7d1e6 Bluetooth: Controller: Fix CIS and CIG teardown
Fix CIS and CIG teardown in Central and Peripheral Role.
cig->lll.num_cis value is used in peripheral role to count
active CISes, and cig->cis_count is used in central role.
Both central and peripheral will stop ticker for CIG when
num_cis and/or cis_count is zero, respectively, but only
peripheral role will release a CIG context. The Central
will keep the CIG context allocated and only mark it as
not started. Remove CIG command will be used for central
role to release a CIG context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
19c80b1020 Bluetooth: Controller: Fix CIS ISO Tx buffer leak on terminate
Fix CIS ISO Tx buffer leak on terminate when the datapath
has been deallocated.

Add a FIXME comment regarding ll_tx_ack_put() being called
from LLL execution context, while it is a ULL callable used
by ACL connections to dispatch ack.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
c7724f00e5 Bluetooth: Controller: Fix k_is_in_isr() assert calling util_aa_le32()
Do not call util_aa_le32() from ISR context as random number
generation in entropy driver on nRF5x series invokes
k_sem_take.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
93f9d9bc6d Bluetooth: Controller: Fix assertion on link_tx_free on CIS re-create
Fix assertion check on link_tx_free when CIS is created a
second time. The Tx mem queue has to be initialized on every
new CIS create as CIS disconnect does the deinitialization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
e5d9ad17bb Bluetooth: Controller: Reorder the functions in ull_central_iso file
Reorder the functions in ull_central_iso file to match the
order of HCI commands in the BT Spec.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
00e31f5e65 Bluetooth: Controller: Workaround datapath field access after release
Workaround the access that check if datapath is NULL when
the stream has already been released. Memory Pool overwrites
first 8 bytes to maintain the free list and free count. This
causes the datapath fields if placed in the first 8 bytes to
not be NULL after the memory is freed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
bb92b018dd Bluetooth: Controller: Code to generate ISO data buffer overflow event
Add code to generate ISO data buffer overflow event if more
than allocated ISO data PDU buffers are tried to be
requested by host or for SDU fragmentation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
8cf58edb8b Bluetooth: Controller: Use instant_latency to detect event skipped
Use instant_latency at the CIG start event count to detect
skipped connection event around the instant. In the future
add implementation to compensate for skipped ACL connection
event and adjust the CIS event count at CIG start.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
149f857f8a Bluetooth: Controller: Reuse ull_conn_event_counter() in LLCP
Reuse ull_conn_event_counter() function in LLCP
implementation to get the current radio event counter value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
aba5176340 Bluetooth: Controller: Fix CIG offset and add time reservations
Fix CIG offset such that it follows after the ACL connection
time reservation to avoid overlapping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
b16e5baf80 Bluetooth: Controller: Rename to trx_performed_bitmap
Rename trx_performed_mask to trx_performed_bitmap and add
conditional compilation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
a155b3b37d Bluetooth: Controller: Add LLL required ULL interfaces
Add LLL interfaces implemented by ULL to get group by stream
and to get stream by group iterator functions.
Rename function to set CIS established to reflect that it is
LLL accessible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
53db4a0b1d Bluetooth: Controller: Fix channel indices calculaton cond compile
Fix channel indices calculation implementations conditional
compile so that it can be reused for Connection ISO events
and subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
6f0b6ec90b Bluetooth: Controller: Fix ISO Buffer allocation for SDU fragmentation
Fix ISO Tx Buffer allocation counts considering required SDU
fragmentations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
a949fa7250 Bluetooth: Controller: Use define for packet timer capture
Use the sample capture index define for capturing packet
timer timestamp.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
9119e817fa Bluetooth: Controller: Separate Tx and Rx packet timer status reset
Add interface to have separate Tx and Rx packet timer status
reset, so that packet timer can be setup ahead in time for
starting the Tx or Rx subevent and status reset only clears
the respective PPI/DPPI that was used when Tx or Rx
completes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
bcc4fa4f44 Bluetooth: Controller: Use spec. defined abbrev. for nse, bn, and ft
Use BT Spec. defined abbreviations for number of subevents
(nse), burst number (bn), flush timeout (ft) etc.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
9456a0ecd9 Bluetooth: Controller: List Central and Peripheral ISO supported
Update Kconfig to list Central and Peripheral ISO as
supported. Will continue to be listed as Experimental.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
efd80f4ec1 Bluetooth: Controller: Add conditional compiles for Peripheral ISO
Add conditional compilation for Peripheral ISO support,
use CONFIG_BT_CTLR_PERIPHERAL_ISO.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
863fc7373b Bluetooth: Controller: Re-arrange include in ull_peripheral_iso file
Re-arrange include in ull_peripheral_iso file to be
consistent with other similar files (ull_central_iso).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
5398ae0710 Bluetooth: Controller: Add LL_CIS_HANDLE_LAST, IDX_FROM_HANDLE define
Rename LAST_VALID_CIS_HANDLE to LL_CIS_HANDLE_LAST, to be
consistent naming with LL_CIS_HANDLE_BASE.
Add IDX_FROM_HANDLE defines.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
8e48de8f58 Bluetooth: Controller: Minor refactor of Connected ISO group and stream
Refactor the Connected ISO group and Connected ISO stream
context to be consistent in defining the bitfields and also
rearrange structure members.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Vinayak Kariappa Chettimada
66834e9860 Bluetooth: Controller: Fix missing BT_LL_SW_LLCP_LEGACY cond compile
Fix missing BT_LL_SW_LLCP_LEGACY cond compile causing
compile error when building Peripheral ISO samples with
legacy control procedure implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-27 23:04:45 +09:00
Siddharth Chandrasekaran
ac9510230b mgmt/osdp: Use memcpy instead of raw loops in many places
This patch replaces many instances where raw loops were used to copy bytes
with memcpy calls.

No functional change intended.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
4386dc355b mgmt/osdp: pd: Fix device capabilities report
Do not check or send the first entry in the pd->cp[] device capability
table which is for function code 0 which is not a defined function code.

Signed-off-by: David Vucich <dave@alcatraz.ai>
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
39bf1264e9 mgmt/osdp: pd: Fix error reply code for CMD_KEYSET
By default, on errors, pd_decode_command replies with osdp_NAK with
sub-error code set to OSDP_PD_NAK_CMD_LEN (achieved using the ret ==
OSDP_PD_ERR_GENERIC check before return). This is works for all packet
framing errors; but when a more specific error code needs to be sent, ret
has to be set to something other than OSDP_PD_ERR_GENERIC (a suitable error
code happens to be OSDP_PD_ERR_REPLY) to prevent the tail check from
overwriting the error info.

In CMD_KEYSET, we fill a more specific error code but do not set the ret to
OSDP_PD_ERR_REPLY. It causes this error to be reported as a framing
error hence loosing some extended info about the error. Fix this issue by
reordering the checks a bit.

Fixes: 7f4d2c741b "mgmt/osdp: Add support for Secure Channel"
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
7f70d5e0e0 mgmt/osdp: Remove unused STR() macro
Initially, subsys/mgmt had its own STR() macro for string pasting which was
replaced with the zephry provided STRINGIFY(). The definition of this macro
seems to have lingered on so remove it.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
514ccabc44 mgmt/osdp: phy: Catch out-of-order SC packets and fail
During handshake, only certain types of secure block types (<= SCS_14)
are allowed. A rouge CP/PD can try to bypass the handshake by directly
sending a secure block type ahead of the sequence and gain a secure
channel. Fix this by adding a check in packet decode time.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
a233dea285 mgmt/osdp: phy: Rework MARK byte handling
OSDP specification section 5.7 states that a transmitting device has to
drive the transmission line to a marking state for a period of one char
in the current baud rate. This can be achieved by sending 0xFF. Since
this is not mentioned in the packet structure definition, many commercial
implementations of OSDP out in the wild do not send/expect this byte.

To work with such non-conforming devices, we will try to be as flexible
as possible in the PD: send mark byte only if the other side sent one. In
case of CP, we have no option but to send the mark byte to be as close
to the specification as possible. If a particular use case needs the CP
to not send it, we will provide a Kconfig option to disable it.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
d44bdb50f0 mgmt/osdp: pd: Add support for key press and card read events
Now that we have the necessary infrastructure to collect events from PD
apps, we can use them to translate it to OSDP packet sequence for card
reads and key press events.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
c9e64e0dd9 mgmt/osdp: pd: Add capability checks on incoming commands
OSDP compliant devices communicate their capabilities and discover what
their peer can and cannot do. Right now, PD advertises these capabilities
and expects CP to honor them. Although this is not known to cause any
issues, it is not desirable to allow such accesses.

Add a check of incoming commands to to validate that the corresponding
capability was enabled and advertised.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Siddharth Chandrasekaran
a369bf7f08 mgmt/osdp: Rename cmd_data as ephemeral_data
Since cmd_data member is used by both commands and events to store the
contents of current transaction, rename it to ephemeral_data which
better reflects the purpose of the variable.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-27 20:28:34 +09:00
Robert Lubos
4234e801b5 net: sockets: Fix TLS_HOSTNAME option length inconsistency
The TLS_HOSTNAME socket option expects a NULL terminated string and
doesn't really care about the optlen provided. However, as the option
expects that the string is NULL terminated, the optlen value should take
NULL character into account, for consistency across the codebase.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-27 19:23:36 +09:00
Théo Battrel
7f9cd24814 Bluetooth: Stop sending SMP PDUs outside of pairing procedure
Stop sending the unnecessary 'pairing failed' SMP PDUs outside of the
pairing procedure.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-01-27 19:23:03 +09:00
Troels Nilsson
9f92dff354 Bluetooth: controller: Fix issue with duration/max number of adverts
When a maximum duration or number of advertisements has been set for an
advertisement set, we will exceed that limit if the last advertisements
happen to be overlapping (ie. we have two primary advertisements pointing
to the same AUX_ADV_IND).

We now have a check in the ticker_cb that will ignore the callback if the
state is such that advertisement would have been stopped if ull_adv_done()
had been allowed to run in the meantime.

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-01-27 19:22:30 +09:00
Emil Gydesen
e5890fc779 Bluetooth: Audio: Broadcast source reconfigure missing streaming QoS
When executing the bt_audio_broadcast_source_reconfig the streams
did not get assigned the new QoS, the ISO parameters were not
properly updated and the codec was not set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-27 18:10:34 +09:00
Nicolas Pitre
d7f9e26433 rand32_timer: make it more random-like for tests to pass
I get a high failure rate for tests/kernel/mem_protect/stack_random
because the default rand32_timer used with QEMU is just too mediocre.
Make it more random looking.

Reference: https://nuclear.llnl.gov/CNP/rng/rngman/node4.html

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-27 17:38:26 +09:00
Emil Gydesen
3ead1cfa2c Bluetooth: Audio: Call stream released on ACL disconnect
If the ACL disconnects, then the unicast server cannot send
a notification to the client about the endpoint and
stream being released. We now call the released callback
if the stream's endpoint was not idle before the disconnection.

Similarly the unicast server (ASCS) did also not call the
released callback if the ACL disconnection causes a endpoint
release.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-27 17:35:51 +09:00
Trent Piepho
c09f6918fa i2c: Allow dumping the data of read messages
Add an argument to i2c_dump_msgs() to log the data from reads too.  And
then rename the function to i2c_dump_msgs_rw() so the API doesn't
change.  If the dump is done after a transaction is processed, as
opposed to before, then the read data is valid and can be very useful.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-26 14:55:44 -05:00
Johann Fischer
a06d9769ce usb: device_next: update IAD during CDC ACM initialization
Set bFirstInterface of IAD and update CDC Union descriptor
during class initialization.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-26 09:37:03 -08:00
Keith Short
6062914cf2 emul: Add support for backend APIs
The emulator structure currently initializes a bus-level API that is
used to communicated register accesses to the emulator from the parent
bus.

Add support for declaring a backend API for emulators. This provides
tests a common way to interact with emulators of the same device type.

Signed-off-by: Keith Short <keithshort@google.com>
2023-01-27 01:01:06 +09:00
Johann Fischer
5c077d72b5 usb: device_next: add BT HCI USB transport layer
Add Bluetooth HCI USB transport layer implementation for the new
experimental USB device support based on the existing implementation
subsys/usb/device/class/bluetooth.c.

This implementation, unlike existing one, contains the interface
descriptors for isochronous endpoints. Since we do not support voice
channels, these are just there to avoid issues with Linux kernel btusb
driver when this implementation is part of a composite configuration.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-27 00:57:22 +09:00
Raphael Treccani-Chinelli
3e937da264 bluetooth: host: Added extra options to PAST subscribe
allow disabling reports (synchronise but don't generate sync reports)
and allows enabling sync reporting with filtering of duplicates.
the default option remains to establish sync, with sync reports,
but without duplicate filtering.

Signed-off-by: Raphael Treccani-Chinelli <raphael.treccani@nordicsemi.no>
2023-01-26 07:29:19 -08:00
Nicolas VINCENT
06d53b1343 settings fcb: Increase buffer for mcu with large write block size
Devices with write block size greater than 16 could not use settings_fcb
due to small buffer size.
Update value in test as well.

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2023-01-26 22:50:40 +09:00
Jamie McCrae
4516e7161c mgmt: mcumgr: transport: smp_bt: Fix wrongly enabling Bluetooth
Bluetooth does not need to be enabled to register services,
therefore the newly introduced automatic bluetooth SMP transport
registration system can be simplified by returning enabling of
bluetooth back to the application.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 12:36:16 +00:00
Robert Lubos
9fef0c521d net: tcp: Remove net_tcp_unref()
There is a pending TODO regarding unifying net_tcp_unref() and
net_tcp_put(). Given that net_tcp_unref() is no longer used by the upper
layer (it should only use get/put APIs), the function can be removed
from external TCP API, as referencing/dereferencing is now only used
internally by the TCP stack.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-26 12:34:04 +00:00
Robert Lubos
79461a378c net: tcp: Fix TCP connection ref counting
The net_context/TCP connection context ref counting needed to be fixed,
to avoid situation where TCP connection context could be released
before net_context is released.

Generally, this commit modifies the ref counting of the above as
follows:
* net_context is referenced both by the application and TCP stack, when
  created.
* TCP context is referenced by the application when created. The TCP
  stack adds ref to the TCP context only after connection has been
  established.
* TCP stack needs to call the final upper layer callback when connection
  is closed, but before the TCP context is released (i. e. to give upper
  layer chance to dereference the context on its side). For this,
  tcp_conn_close() was introduced which is called from within TCP stack
  instead of directly dereferencing the TCP context.
* TCP stack dereferences the net_context only after the TCP context has
  been released (i. e. upper layer has dereferenced TCP context on it's
  side and connection has been tear down, if established).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-26 12:34:04 +00:00
Vinayak Kariappa Chettimada
47921588b4 Bluetooth: Controller: Broadcast ISO encryption support
Implementation of Broadcast ISO encryption using crypto
toolbox function h8. And support for encryption in lower
link layer for nRF5x series.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
4d3f8697a3 Bluetooth: Controller: Make PDU octet3 vendor specific
Make Data, ISO, BIS and CIS PDU structure's octet 3 vendor
specific.

This will allow vendors not supporting the octet 3 or
CTEInfo (8 bits) to save 1 octet in their PDU structures.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
117bdbbf64 Bluetooth: Controller: Use len instead of length in PDU structs
To be consistent in naming as len instead of length in PDU
struct definitions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
f4b4f30596 Bluetooth: Controller: Parse and find BIGInfo to setup ISO sync
Add implementation to parse ACAD and find the BIGInfo before
setting up Broadcast ISO Synchronization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
c8f75de1a5 Bluetooth: Controller: Add packing sequential or interleaved comment
Add code comment related to BIG packing sequential or
interleaved being used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Vinayak Kariappa Chettimada
cc1f937d61 Bluetooth: Fix endianness of cryptographic toolbox function h8
Convert endianness of supplied parameters before calculating
the AES-CMAC. Bluetooth stores values in little-endian and
crypto traditionally operates on big-endian storage.

Relates to commit e9c542ab5b ("Bluetooth: Add the
cryptographic toolbox function h8").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 13:25:11 +01:00
Jonathan Rico
a7746ad55e Bluetooth: Host: Re-subscribe only after encrypt change
Wait until encrypt change to trigger the re-subscription quirk.
Otherwise it could fail with insufficient security.

Also gate it behind a kconfig to make apparent its dependencies:

If `add_subscriptions()` is executed in the first place, that means that
the device was bonded and thus that it has to encrypt the link eventually.

`BT_GATT_AUTO_SEC_REQ` should take care of that.

Also add a new flag to `bt_gatt_subscribe_params` to not send the same CCC
write multiple times in some cases.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-01-26 10:05:13 +00:00
Alberto Escolar Piedras
8a5273525e nrf52_bsim: Convert from a nRF52832 to a nRF52833
The nRF HW models have been updated to correspond to a 52833 instead
of a 52832. Let's follow them.

The motivation for the change is to enable proper BIS encryption support
(for BT LE Audio ISO).

Changes:

* Point in manifest to latest HW models

* SOC_COMPATIBLE_NRF52832 has been removed, and SOC_COMPATIBLE_NRF52833
added in its place (with no uses at this point)

* Where SOC_COMPATIBLE_NRF52832 was used to set encryption like for a 52832
(to avoid using the MAXPACKETLENGHT), we set the condition to just
SOC_NRF52832.
Note: The MAXPACKETLENGHT register exists in the new simulated nrf52833,
thought it does nothing.

* In the BLE ctrl LLL radio HAL, all macros are renamed accordingly
(timings are NOT changed).

* Board dts definition now refers to the 52833 soc definition. New 52833
features set as not supported by now.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-01-26 09:29:18 +01:00
Vinayak Kariappa Chettimada
c325347816 Bluetooth: Controller: Fix missing node rx release on legacy CPR reject
Legacy Control Procedure fix. Fix missing release of the
node rx allocation that was reserved at the start of the
LE Connection Parameter Request procedure and the procedure
ends with reject indication transmitted to the initiating
peer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-26 09:07:45 +01:00
Juha Heiskanen
1f84409b48 net: lwm2m: Trace clean
Cleaned Trace message print.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-25 15:08:07 +00:00
Chamira Perera
ce49beb297 net: ethernet: Fixes for ethernet stats reporting.
The following fixes were applied:
 - Multicast Rx packets stats were not recorded due not parsing the
ethernet header. The function that tried to parse the ethernet header
was parsing the ethernet packet beyond the ethernet header.
 - Added a new stats for unknown protocol which gets updated when the
ethernet layer encounters an unknown ethernet packet type.

Fixes #53994

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2023-01-25 15:01:14 +00:00
Jordan Yates
fb1ee429a2 pm: device: rework pm_device_children_action_run
Rework the implementation of `pm_device_children_action_run` to use the
common `device_supported_foreach` iterator.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-25 14:58:52 +00:00
Andreas Chmielewski
022ff636da net: lwm2m: rd_client: added init function
To write tests it is necessary to offer init function for the RDClient
to define custom fakes before.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-01-25 14:55:02 +00:00
Nicolas Pitre
90ae60078e ztest: make the FPU flush workaround more generic
In addition to ARM64, it must apply to RISC-V too now.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-24 15:26:18 +01:00
Aleksander Wasaznik
4b675f34db Revert "Bluetooth: Host: Disable host-based RPA resolution when !BT_PRIVACY"
This reverts commit 5824ac90ecd8dd06d9ea117d345dbc6b069e5840.

The resulting revert takes into account changes to the predicate that
guards the use of `resp_addr`.

In the resulting revert, the predicate guarding the use of `resp_addr`
is differs from the naive revert because the intention of that predicate
is to know when `conn.c:bt_conn_le_create` decided to use the Host
resolver. And, the logic in `conn.c:bt_conn_le_create` has changed. The
changes to the logic in `conn.c` are in the following commits:

89780d715d
5a09325ba9

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-01-24 15:13:36 +01:00
Vinayak Kariappa Chettimada
c104fda34f Bluetooth: Controller: Fix filter accept list and privacy default
Fix filter accept list and privacy feature Kconfig default
based on whether host has them enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-24 15:13:36 +01:00
Vinayak Kariappa Chettimada
00dbf6188c Revert "Bluetooth: Controller: Fix filter accept list and privacy default"
This reverts commit 59eef60665.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-24 15:13:36 +01:00
Wouter Cappelle
aaefd3db7e net: http: Use poll for http timeout instead of shutdown
Change the http timeout mechanism to use poll instead of shutdown.
This should fix a problem where the shutdown will be called in a
different thread context which can lead to deadlocks on certain
driver implementations like offloaded modem drivers.
Fixes #53967

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2023-01-24 14:50:11 +01:00
Morten Priess
cb7c4d3850 Bluetooth: controller: Fix ll_cig_remove not cleaning up
When removing a CIG, the instance and associated CIS instances were not
always released. This causes repeated Create_CIG/Remove_CIG operations
to fail assertion with resource error.
Enables CONFIG_BT_CTLR_CENTRAL_ISO in bsim_test_audio.

Fixes issue #53301.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 14:49:43 +01:00
Emil Gydesen
0f394c5958 Bluetooth: Audio: Shell: Add missing metadata type
In handle_metadata_update the metadata type was never copied,
causing it to always be 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:25 +01:00
Emil Gydesen
5357bd5d0f Bluetooth: Shell: add pa_ad_init for cmd_per_adv_data
Similar to the ad_init that automatically adds advertising data
from other modules, pa_ad_init has been added to do the same
for periodic advertising.

The only use case so far is the BAP broadcast source
data, if enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Emil Gydesen
d115bafd40 Bluetooth: Audio: Shell: Split audio_ad_data_add into two
The call to audio_ad_data_add will now either call
connectable_ad_data_add for connectable advertising, or
unconnectable_ad_data_add for unconnectbale advertising.

Most service UUIDs etc. does not make sense to advertise if
not connectable.

This also adds the BAP broadcast advertising data to
unconnectable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Emil Gydesen
f0b104346a Bluetooth: Audio: Shell: Fix off-by-one issue with the HAS uuid
If the advertising is connectable, and we have privacy,
then according to the HAP spec, we should not advertise
the HAS uuid.

This was done by simply truncating the advertising data, but
it was only truncated by 1, instead of by the size of the
UUID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Morten Priess
60b1f2b36b Bluetooth: controller: Reduce ISO peripheral CIS establishement delay
New LLCP will process the CIS establishement in the TX path, meaning it
will only process once every ACL connection interval.
If ACL connection interval is significantly longer than the ISO
interval, CIS packets corresponding to the ACL connection interval will
be lost. This may cause latency in audio rendition.

By processing the CIS establishment in the RX path, notification will be
sent immediately, and audio path is enabled fast to reduce latency.

When a CIS fails to establish, the controller shall complete the
procedure by sending a CIS_ESTABLISHED event containing the error.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess
90d0d93a9c Bluetooth: controller: Fix missing CIS disconnect on MIC failure
Disconnect CIS immediately if event done extra status indicates MIC
failure. Return reason BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL.

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

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess
78c3bf569b Bluetooth: controller: Implement CIS offset equivalent calculation
When the 'instant' of a CIS is postponed by increasing the conn_event of
the CIS_RSP compared to CIS_REQ, the CIS offset shall be calculated as
an equivalent window offset by an integer number of ISO intervals.
This is obtained by increasing the CIS_Offset_Min and CIS_Offset_Max by
the modulus of the connection interval delay time.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess
a982c9f9f6 Bluetooth: controller: Start CIG immediately if instant is next event
To be able to timely start the first CIS/CIG, if the requested instant
is the next connection event, call ull_peripheral_iso_start directly
from rp_cc_state_wait_rx_cis_ind instead of waiting for next time
through the state machine.

To enable ULL/LLL to prevent adding latency when LLCP is waiting for
instant, local- and remote procedures with instant now expose a function
for checking this state.

Fixed event_counter function to prevent one-off in RX path. Unified to
use single function ull_conn_event_counter.

Fixed LLCP unit tests and added new mock function.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Tomasz Moń
7608f54433 usb: device_next: Do not leak memory on set address
USB stack did leak memory on every SET ADDRESS request. UDC control
allocator could cope with up to 13 leaked allocations. Therefore,
issuing bus reset 13 times in a row (in addition to automatic reset
after connecting the USB cable) was enough to exhaust memory and
thus drive USB stack inoperable.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-01-24 09:43:00 +01:00
Emil Gydesen
728384992f Bluetooth: Audio: Unicast client add disabled callback for sink ASE
The sink ASE does not have a disabling state, but since the
stream callbacks does not necessarily match the ASE states,
we need to do our own check to see if a sink ASE has been
disabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:55:49 -08:00
Emil Gydesen
13a48de72f Bluetooth: Audio: HAS: Fix notifications/indications
Before this commit we simply always notified/indicated
all presets and active index to any bonded device, even
if they never subscribed to anything, or even if we never
registered HAS.

This commit modifies that, so that only the proper
connected clients will get the notifications/indications,
and that we only send them if something has changed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen
50a0f62df2 Bluetooth: Audio: HAS: Remove unused control_point_work_sync
Remove unused control_point_work_sync field in the has_client
struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen
ea858f26c5 Bluetooth: Audio: HAS: Fix active_preset_work initialization
The security_changed callback may be called before
bt_has_register has been called, thus making the active_preset_work
handler uninitailized, causing an ASSERT when the work is submitted
in the security changed callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen
d6055f9938 Bluetooth: Audio: Fix HAS double register
Calling bt_has_register multiple times would cause attempts
to register a HAS multiple times. Fixed by adding a check
and return with EALREADY if it is already registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Chris Friedt
c2a62f4ad7 net: sockets: conditionally include zephyr/posix/fcntl.h
Only include `<fcntl.h>` for `CONFIG_ARCH_POSIX`. Otherwise,
include `<zephyr/posix/fcntl.h>`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt
6ac402bb3a net: socket: additional POSIX constants
The POSIX spec requires that `SO_LINGER`, `SO_RCVLOWAT`,
and `SO_SNDLOWAT`, and `SOMAXCONN` are defined in
`<sys/socket.h>`. However, most of the existing socket
options and related constants are defined in
`<zephyr/net/socket.h>`.

For now, we'll co-locate them. It would be
good to properly namespace things.

Additionally, a no-op for setsockopt for `SO_LINGER` to
make things Just Work (TM) for now.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Vinayak Kariappa Chettimada
02ee85c893 Bluetooth: Controller: FIXME comment for chain PDU time reservation
Add FIXME comments to handle additional time reservations
required for advertising auxiliary channel chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-23 13:08:34 +01:00
Julien D'Ascenzio
740f915721 nvs: use CRC8 if cache size is 256
When cache size is 256, we can use CRC8

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2023-01-23 12:04:55 +00:00
Andrei Emeltchenko
270668b752 bluetooth: controller: Prevent Out of band access
Add check preventing Out of band access. There are tests trying to
access out of band handle like:

test_sink_invalid_ref and test_source_invalid_ref trying to access
handle 99.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-23 12:04:25 +00:00
Andrei Emeltchenko
02fa6ba7e6 bluetooth: shell: Correct ad_len type
Fixes warning when comparing that size_t is negative.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-23 13:26:59 +02:00
Gerson Fernando Budke
eb9460ce5e mgmt: updatehub: Add no memory check at cmd_info
The updatehub shell cmd_info allocate memory but not checks function
return. This add missing checks and proper error handle.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Gerson Fernando Budke
647c48c574 mgmt: updatehub: Add userspace syscalls
The current updatehub version forces user application to run in kernel
mode. This add necessary api syscalls to isolate userspace from kernel.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Gerson Fernando Budke
000257dad0 mgmt: updatehub: Move updatehub.h to header directory
This moves updatehub.h file from subsys to public header include
folder.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Gerson Fernando Budke
22e0a1faa6 mgmt: updatehub: Preparation to move public api
This prepares updatehub.h file to be moved to the public header
directory.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-23 10:24:07 +00:00
Ajay Parida
ba39235275 net: wifi_mgmt: Add support for power save timeout configuration
Add support for configuring power save timeout in Wi-Fi chipsets.
Changes to configure power save inactivity timer.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-01-23 10:08:01 +00:00
Mahesh Mahadevan
ae97eae8c2 pm: Error with handling z_cpus_active count
z_cpus_active count becomes incorrect when the state is
PM_STATE_RUNTIME_IDLE and CONFIG_PM_DEVICE is enabled.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-01-23 10:06:17 +00:00
Martin Jäger
3b9ba15096 lorawan: services: add Application Layer Clock Synchronization
This service allows to synchronize the clock with the application
server.

Synchronization requests are initiated by the device in a regular
interval, configurable via Kconfig.

The implementation only supports TS003-2.0.0, as the previous revision
TS003-1.0.0 requested to temporarily disable ADR and and set nb_trans
to 1. This causes issues on the server side and is not recommended
anymore.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-01-23 10:05:49 +00:00
Martin Jäger
a9dc566a18 lorawan: add common backend for services
This is a prepartion for adding actual services needed for firmware
upgrade over the air (FUOTA).

The services run in a dedicated work queue.

This commit introduces code that initializes the work queue and
provides functions to schedule uplink messages after a given timeout.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-01-23 10:05:49 +00:00
Szymon Czapracki
77c8cffae0 Bluetooth: Audio: Ignore RFU VOCS location
This commit changes VOCS set location behavior.
When an RFU location is written, VOCS ignores it.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-01-20 16:11:31 +01:00
Sam Hurst
ee9903005a usb_c: Refactor Sink common code
Move non-sink specific code into common code

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-20 12:17:44 +01:00
Vinayak Kariappa Chettimada
d6c3e04eb8 Bluetooth: Controller: Central maximum data PDU size time spacing
Use the maximum data PDU size time reservation space
considering the Data length could be updated from default
27 bytes to maximum support size.

If maximum time reservation is disabled then time space
reservation corresponding to the default data length at the
time of the start/enable of Central role is used.

Note, currently this value is only used to space multiple central
connections and not for actual ticker time reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-20 12:16:43 +01:00
Vinayak Kariappa Chettimada
680e29dd0e Bluetooth: Controller: legacy: Fix conn param request to be cacheable
Fix connection parameter request  procedure to be cacheable
if a remote control procedure is in progress.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-20 12:16:43 +01:00
Vinayak Kariappa Chettimada
5e848761c5 Bluetooth: Controller: legacy: Fix conn upd instant passed on data tx
Fix legacy control procedure implementation to avoid
connection update procedure with reason instant passed
(0x28).

Connection Update Indication PDU is enqueued after data
enqueue to LLL context is paused and the enqueue resumes
when already enqueued data PDUs are all acknowledged.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-20 12:16:43 +01:00
Jamie McCrae
df0fa6d965 mgmt: mcumgr: Add logging output
Adds logging to mcumgr commands for debug and error reporting

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-20 11:57:59 +01:00
Emil Gydesen
50446afe6c Bluetooth: Audio: Shell: Remove csip_set_coordinator init command
Remove the init command for teh CSIP Set Coordinator.
The main reason for this is that we want to ensure that we
register the conn callbacks early so that `conns` array is
properly filled.

The other callbacks registered in the init function
can easily be moved to where they are needed, and even
unregistered to avoid parsing more data than we need.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-20 09:03:51 +01:00
Julien D'Ascenzio
b7c2b3fc3a nvs: NVS cache always rebuild on successful NVS initialization
During the NVS initialization, if gc had to be done, the NVS cache
rebuild wasn't called.

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2023-01-19 17:14:55 +01:00
Ajay Parida
057e2fc59c net: wifi_shell: Display correct power save status
Display power save status correctly.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-01-19 13:48:24 +01:00
Sören Tempel
cf34afd2cc testsuite: coverage: fix -Wcast-align warning
While porting the coverage.c file from RIOT to Zephyr, which employs
different compiler flags, I noticed several -Wcast-align GCC warnings on
arm. I think, as is, the current implementation may perform unaligned
memory accesses which may not be supported on certain platforms. To
workaround that, I have rewritten the code for RIOT using
bytewise-writes with `memcpy`.

Signed-off-by: Sören Tempel <tempel@uni-bremen.de>
2023-01-19 06:51:44 -05:00
Veijo Pesonen
f0258dbe4d net: lwm2m: Sufficient memory for resource names
Full resource names aren't as long as combined basename- and name-buffer
sizes but the compiler doesn't know it. Increasing the buffer size to
avoid the compiler warning.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2023-01-19 12:03:27 +01:00
Andries Kruithof
584bd4069f Bluetooth: controller: Kconfig for event length update
Since the event length update is not necessarily an improvement
in all situations a Kconfig option is added so that it can
be disabled for the users that do not need it.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-01-19 11:18:51 +01:00
Andries Kruithof
e7d60e3ed6 Bluetooth: controller: fix post DLE/PHY update event length
Fix the controller implementation to perform connection
event length reservation based on the completed Data Length
Update and/or PHY Update Procedure.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-01-19 11:18:51 +01:00
Chamira Perera
1c51f7cbbf net: ipv4: Using a different API to ensure that IPv4 is enabled
When init_igmp is called the ipv4 pointer was not initialised.
Therefore, a different API needs to be used to ensure that IPv4
is enabled when calling init_igmp.

Fixes #53913

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2023-01-19 10:35:44 +01:00
Jarno Lämsä
abafd7e810 net: lib: lwm2m: Replace deprecated function calls
Replace calls to deprecated functions with new ones.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
3b3463ecba net: lib: lwm2m: Deprecate string based enable cache
Deprecate the old API and replace with new one which uses
the lwm2m_obj_path struct instead of a string.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
460dd6530f net: lib: lwm2m: Deprecate string based send
Deprecate send API using the string references as paths.
Replace it with one using path structs.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
49cf96858f net: lib: lwm2m: Deprecate buffer set get API
Deprecate old API and make new API using path structs
instead of using old string reference based paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
bca0550413 net: lib: lwm2m: Deprecate callback registration API
Deprecate old API and create new API using path structs
instead of string references to paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
a2e52c5607 net: lib: lwm2m: Deprecate observation API
Add new APIs using the lwm2m path structs instead of
string references to paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
5c80be9379 net: lib: lwm2m: Deprecate object and resource API
Deprecate old API and offer a new API for object and resource
creation and deletion. The new API uses path struct instead
of using a string as a reference to a path.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä
15d81a8914 net: lib: lwm2m: Deprecate string based set get API
Use the lwm2m_obj_path struct instead and deprecate old.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Erik Brockhoff
ad06dfc784 Revert "Bluetooth: controller: Reject CIS_TERMINATE when unsupported for role"
This reverts commit ee2a43b5dc.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-01-18 22:19:57 +00:00
Erik Brockhoff
e096ccca8d Bluetooth: controller: fix UNKNOWN_RSP vs. role re CIS TERMINATE support
Proper handling re. non-supported CIS TERMINATE

This fixes EBQ test LL/PAC/CEN/BV-01-C on the general level.
'Replaces' #ee2a43b5dcf884730130345c402d87b2bce9dba1

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-01-18 22:19:57 +00:00
Eivind Jølsgard
cfa1ba1261 fs: fcb: add option to disable CRC for fcb entries
Add option to disable CRC for fcb entries. This improves the write
throughput significantly at the cost of not detecting corrupted data
in flash. This is beneficial for aplications that needs the extra
write throughput, where error detection is done elsewhere.

Allow the FCB entries in flash to have a valid CRC when CRC is
disabled in the FCB. This allows existing solutions to disable
CRC checking, while keeping the CRC areas intact. Note that this
is a one-way option.

Fixes #53707

Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
2023-01-18 22:18:37 +00:00
Andrei Emeltchenko
33b0c0db38 bluetooth: ias: Fix dereferencing before NULL check
It does make sense to dereference after NULL check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-18 07:27:00 -05:00
Andrei Emeltchenko
1ec44b6160 bluetooth: Fix using size instead of len
Fix using wrong field.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-18 07:27:00 -05:00
Tomasz Moń
e326c58399 usb: device: Do not cancel transfers on suspend
Cancelling transfers on suspend contradicts Universal Serial Bus
Specification Revision 2.0, 9.1.1.6 Suspended:
  * When suspended, the USB device maintains any internal status,
    including its address and configuration.

The internal status definitely includes any pending USB transfers.
If there is a class that wants to cancel transfer on suspend, then the
cancel should be initiated by the class, not the device stack itself.

Update hal_nordic to a version that does not abort all endpoints at
suspend. It seems that aborting endpoints on suspend in nrfx driver was
the actual reason why transfers were canceled on suspend.

Remove transfer retriggering on resume from CDC ACM and Bluetooth class
implementations because transfers are no longer cancelled on suspend.
Other classes do not have any suspend related workarounds implemented.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-01-18 11:48:13 +01:00
Pavel Vasilyev
46b78bb1d5 Bluetooth: Mesh: Stop scanner before resetting mesh
When we receive Node Reset message, we schedule work in the system
workqueue to call bt_mesh_reset(). In bt_mesh_reset() we call
bt_conn_disconnect() to disconnect proxy client. bt_conn_disconnect()
will put a buffer to a pool and call k_sem_take to let BT HCI TX thread
process this buffer. Because we stop scanner after disconnecting the
proxy, we can still receive a message at this point. Since BT RX thread
has higher priority than the system workqueue, if we receive a message
while in bt_mesh_reset(), it will be processed when we call
bt_conn_disconnect().

Stop scanner before resetting the mesh to avoid processing of a received
mesh message while in the process of resetting mesh.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-18 10:47:44 +01:00
Pavel Vasilyev
6dfc9ecc03 Bluetooth: Mesh: Invalidate pending entries before calling settings API
If, while storing app or net key, or changing cdb, we receive another
mesh message that affects setting of the same key that the mesh
currently stores, the new change won't be stored.

The settings subsystem API has rescheduling point inside. The mesh
settings are stored in the system workqueue and by default mesh messages
are processed from BT RX thread which has higher priority than the
system workqueue.

When the case above happens, a new change will be written to the same
cache entry. But this cache entry will be invalidated after leaving
settings API, which in turns will invalidate the new change:

- Receive Config AppKey Add message
cfg_srv.c -> app_keys.c: bt_mesh_app_key_add()
app_keys.c: update_app_key_settings()
app_keys.c: bt_mesh_settings_store_schedule()
- store_pending() in settings.c is scheduled
settings.c -> app_keys.c: bt_mesh_app_key_pending_store()
app_keys.c: store_app_key() called to store new app key
app_keys.c: settings_save_one() calls flash driver and sleeps
- Receive Config AppKey Delete message while in sleep,
  which wakes up BT RX thread before returning to the system workqueue
cfg_srv.c -> app_keys.c: bt_mesh_app_key_del()
app_keys.c: update_app_key_settings()
app_keys.c: app_key_update_find() finds entry and returns it
app_keys.c: update->clear = 1
app_keys.c: bt_mesh_settings_store_schedule()
- returning back to bt_mesh_app_key_pending_store() from
  settings_save_one()
app_keys.c: update->valid = 0
- the key won't be deleted next time store_pending() is scheduled.

This change moves entry invalidation before calling settings API so that
after returning from settings API, a new change won't be unintentionally
invalidated.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-18 10:47:44 +01:00
Mariusz Skamra
36058480e7 Bluetooth: audio: Improve stream coupling for CIS as the unicast client
Allow  the streams to be paired when creating unicast group. This will
allow to reuse the same ISO for the paired streams.

Fixes: #51796
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-18 09:56:52 +01:00
Andrei Emeltchenko
69a9ae61b4 bluetooth: shell: Fix using wrong field
Fix using data instead of meta field.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-17 21:50:16 +00:00
Dominik Ermel
718be64e14 mgmt/mcumgr: Don't add unused slots in img_mgmt_flash_area_id
The img_mgmt_flash_area_id would add processing of
slot2_partition and slot3_partition if they only exist, even if
not used at all.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-01-17 21:49:46 +00:00
Emil Gydesen
6dc20d5ced Bluetooth: Audio: Add BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED as default ctx
Add BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED as the default supported
context. This is primarily due to the requirement that it
shall always be supported, and the value 0 (previous
default) was invalid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-17 13:17:03 +01:00
Emil Gydesen
2cc1fe259a Bluetooth: Audio: Fix invalid value for setting src supported ctxs
The call to set_supported_contexts in set_src_supported_contexts
gave the wrong value by reference.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-17 13:17:03 +01:00
Ahmed Moheb
60345c1ddc tests: bluetooth: host: Add UT for bt_keys_update_usage()
Unit test project for bt_keys_update_usage().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:02 +01:00
Robert Lubos
6425f0be0a net: ppp: Fix PPP connection with host
A follow up to commit 1d7a077e11 - apparently the PPP interface should
not be brought entirely down internally, as this can break further
communication with the host. Because of that, reintroduce functionality
that used to be covered by net_if_carrier_down() (which basically
skips the L2 enable(false) call), but limited to PPP scope only.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-17 11:28:10 +01:00
Saleh Mehdikhani
a4890f954a Bluetooth: Controller: Fix slot_plus_us by converting max CTE len to us
Fixes #53786
The variable slot_plus_us is assumed to be a number in us unit.
To assign the maximum possible CTE length to this variable,
BT_HCI_LE_CTE_LEN_MAX has been used while this parameter is defined
in a 8us units (it's 0x14=20 that corresponds to 160us).
To convert this number to us, it's needed to be multiplied by 8.

Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
2023-01-17 11:27:36 +01:00
Mariusz Skamra
80f87b9480 Bluetooth: has: Fix HAS features value
The bt_has_register_param's preset_sync_support and independent_presets
make sense only if CONFIG_BT_HAS_PRESET_COUNT is non-zero meaning the
CONFIG_BT_HAS_PRESET_SUPPORT is enabled.
Otherwise, those parameters shall be skipped.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-16 16:53:39 +01:00
Emil Gydesen
2971c0a588 Bluetooth: Shell: Add cmd_per_adv_set_info_transfer
Add command to perform the Periodic Advertising Set
Info Transfer procedure, which transfers information
about a periodic advertising set to a connected device.

In essence this is just PAST but from the advertiser
instead of a 3rd device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-16 16:53:15 +01:00
Emil Gydesen
b43f1351ed Bluetooth: Audio: Fix issue with invalid bt_conn_ref in ASCS
In ascs.c we had a case where we assigned stream->conn
without taking the ref.

In bt_audio_stream_attach we did not check if stream->conn
was NULL before taking a reference, causing multiple calls
to ase_config to take multiple references.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-16 16:53:03 +01:00
Anders Storrø
c819f0f8d6 Bluetooth: Mesh: Separate adv tag/set for friend
The purpose of this commit is to facilitate future improvements to the
LPN and friendship feature. By being able to identify friendship related
messages on the advertising layer, it will be possible to treat these in
a specific manner so that message exchange between LPN and friend
devices can be conducted in a more power efficient manner.

This commit adds the following:
   - A separate tag for friendship related messages
   - A optional separate advertising set for friend related messages

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-01-16 14:40:54 +01:00
Anders Storrø
bedace2105 Bluetooth: Mesh: Config opt for friend adv latency
Adds Kconfig option to enable tuning the Friend receive delay window.

Friend poll events can be made more efficient by compensating for the
time the non-ideal advertising latency otherwise would add to the receive
delay.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-01-16 14:40:54 +01:00
Tom Burdick
3d6f3a52cf tracing: Fix systemview tracing ids
Fixes the overlapping tracing id for thread name set and pm system suspend

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-16 10:05:01 +01:00
Jamie McCrae
571273b78c mgmt: mcumgr: Change transport select to depends on
This changes some of the MCUmgr transport CMake select statements
to depends on, this is to align with other in-tree symbols that
do not pull in whole subsystems and instead only allow selection
if those subsystems are already enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-16 10:04:45 +01:00
Declan Snyder
bb41f7dc9d sd: Enable eMMC cache
Use cache on eMMC

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
a0bfcb737c sd: Support eMMC HS200/400 Timing Mode
Support for eMMC HS200 and HS400 Timing Modes.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
496ded03f1 sd: Enables High Speed Timing for MMC protocol
- Enables HS Timing Mode for MMC protocol.
- Reads data about HS modes from EXT_CSD for MMC.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
c89b2b08ce sd: Enables eMMC in Zephyr
Enables eMMC protocol in Zephyr

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
fea01b4254 tests: sd: Adds MMC test and Kconfigs
Adds MMC test and Kconfigs for MMC
Note: MMC not yet implemented as of this commit

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
cad243d59e sd: Changes framework to support MMC
- Adds mmc.c
- Edits sd.c to init and probe MMC
- Adds mmc init to sd_init
- Some functions from sdmmc.c should be in sd_ops because
they can be used by both sdmmc and mmc.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
9fe18e05b4 sd: Changed Init Header Structure
In sd subsystem, made one header for all the init functions
instead of having a bunch of header files with one function.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Declan Snyder
a838eef33b sd: Changed KConfig Structure
Changed KConfig structure for SD:
- Better Menu Interface
- Changed symbol dependency structure

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Daniel DeGrasse
94c858ed86 sd: split sdmmc common functions into sd_ops.c
split reusable portions of SDMMC protocol code into sd_ops.c, so other
SD protocols can use these functions directly without compiling in the
SDMMC subsystem.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-14 09:22:22 +01:00
Daniel DeGrasse
b7cd970493 sd: add stub for SDIO support
Add stub code for SDIO support, capable of verifying card responds to CMD5.
This commit also changes the architecture of the SDIO probe step to make
adding new protocol support more streamlined, and enable compiling out
support for undesired protocols.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-14 09:22:22 +01:00
Stephanos Ioannidis
4a64bfe351 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis
feaab27c1b lib: cpp: Relocate subsys/cpp to lib/cpp
This commit moves the files under `subsys/cpp` directory to the
`lib/cpp` directory because the C++ ABI runtime library and the
standard C++ library components are not a "subsystem" (aka. API) in
conventional sense and is better described as a "library."

Classifying the C++ ABI runtime library and the standard C++ library as
"libraries" instead of "subsystems" also better aligns with how the
existing C standard library implementation (`lib/libc`) is handled.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Krishna T
fadb1fd168 net: wifi: Add support for regulatory domain configuration
Wi-Fi bands are regulated by a governing body depending on operating
country, add support for the user to provide a country of operation as a
hint to the Wi-Fi chipset.

Ideally if the chipset supports this is all handled internally, in that
case "get" is useful but for testing and other usecases add a "set" as
well, similar to "iw reg set" or "country_code=" configuration in
hostapd/wpa_supplicant in Linux world.

This add a new offload API operation "reg_domain" that can be used to
either get or set the regulatory information.

The validation is left to the underlying chipset, shell only does basic
validation, (XY/00).

This is just a regulatory hint to the chipset, there could be other
regulatory hints e.g., beacon that can override this configuration, so,
an additional option to force this setting despite other hints is also
given for testing purposes.

FYI, the standard database used is [1].

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/tree/db.txt

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-13 13:37:14 +00:00
Krishna T
324a45568a net: wifi: Fix unnecessary intermediate variable
Directly return the function return value.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-13 13:37:14 +00:00
Pascal Brogle
6ac281887c net: lwm2m: fix observation path list ordering
under certain conditions the current implementation did not maintain
the desired sort order.

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 13:47:27 +01:00
Szymon Czapracki
35bd427927 Bluetooth: audio: Add configurable PACS supported contexts
Add the ability to change supported contexts in PACS.
Enhance the context command in the shell module to make it configurable.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-01-13 13:47:19 +01:00
Pascal Brogle
cc40bc33ba net: lwm2m: fix senml max name size
base name or name can contain up to two shorts.
(object id & object intstance or resource id & resource instance id)

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
Pascal Brogle
b6bc324a1d net: lwm2m: rename path size define
Rename max path constant to prevent string length vs data size confusion

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
Pascal Brogle
b178ff5246 net: lwm2m: fix senml cbor compiler warning
use size_t instead of assuming uint32_t

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:00:13 +00:00
Chamira Perera
b71b514e93 net: ipv4: Added mechanism to add 224.0.0.1 address to a multicast filter
The purpose of the change was to have the Zephyr network stack
internally add the IGMP all systems 224.0.0.1 multicast address to a
multicast membership list so that multicast hash filter implementations
can add this address to the hash filter.

Fixes #53548

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2023-01-13 09:44:10 +01:00
Andrei Emeltchenko
86f48609fb doc: ztest: Include ztress to API reference
Include ztress documentation to ztest API section.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-13 09:43:40 +01:00
Andries Kruithof
1200fd9314 Bluetooth: host: fix conditional compile for broadcaster role
The call to bt_adv_reset_adv_pool is only required in the
broadcaster role, and not in the observer role, regardless
of the setting of CONFIG_BT_EXT_ADV
As the code was this call was also made for the observer.

Note: handling of the setting of CONFIG_BT_EXT_ADV
is already handled in the bt_adv_reset_adv_pool function

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-01-13 09:43:18 +01:00
Guillaume Lager
e67e6d5af6 mcuboot: Remove public dependency on bootutil
BOOT_MAGIC_SZ and BOOT_MAX_ALIGN were used in the header without
including bootutil/bootutil_public.h. This change remove the need of
the inclusion by making the dependency private.
Fixes #52095

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2023-01-12 19:08:23 +01:00
Ravi Dondaputi
551f8c40b2 net: shell: Support IPv6 address and route config
Add and delete options to configure IPv6 address
 and route from shell.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-01-12 19:08:14 +01:00
Ravi Dondaputi
d11ae3a4c8 net: shell: Add support to configure IP address
Add support to configure IP address using net shell.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-01-12 19:08:14 +01:00
Krishna T
bc80b0a232 net: shell: Use net management API for MAC address configuration
Fix a bug in setting MAC address using net_if API, the API doesn't do a
memcpy but just stores the pointer and shell was passing stack pointer.

We can use dynamic allocation but freeing the memory for the MAC address
would be trickier, so, use the net management API and let the underlying
drivers figure out the MAC address memory management.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-12 19:07:44 +01:00
Krishna T
7952197a89 net: shell: Add MAC address validation
Validate MAC address before setting, add new helper APIs to cover all
cases.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-12 19:07:44 +01:00
Emil Gydesen
baad0c300f BluetootH: Host: add helper functions for resolved addresses
There is special handling done for resolved addresses to convert
them to "regular" addresses for the upper layers.
This commits adds two helper functions to check if they are
resolved, and if so, then properly copied.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-12 13:31:12 +01:00
Emil Gydesen
4af1c99f9d Bluetooth: Host: Translate id addr type for PA sync
We only expose random/public address types to the upper layers.
This is done by checking if the address type of events are
resolved addresses, and if so, then we translate them to
public/random.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-12 13:31:12 +01:00
Florian Grandel
e854314928 net: l2: ieee802154: fix double address swap
As we have to provide LL addresses in big endian to userspace to be
POSIX compliant and we also do not want to reserve extra space for
such addresses, bff6a5cce5 introduced
a change that swaps address bytes in place in the packet before
returning the packet with LL address pointers to userspace.

Unfortunately a regression sneaked into the code base while doing
so: The byte swapping was duplicated when using 6LoWPAN compression
and the byte swapping caused decryption to fail in some cases,
see #53630. This commit fixes the problem.

Fixes: #53630

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2023-01-12 12:46:18 +01:00
Krishna T
02ab878704 net: ethernet: Check return value for start/stop
The L2 networking layer checks for return value from enable, but
Ethernet is not checking and always returns 0, so, relay the return
value from the Ethernet driver to networking stack.

This fixes the issue of interface start failing but interface still
being up.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-12 12:14:55 +01:00
Gerson Fernando Budke
ff6b526a14 mgmt: updatehub: Add storage abstraction
This add storage abstraction to allow switch between different flash
APIs. This remove the erase command at updatehub core and move it to
storage init phase.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Gerson Fernando Budke
eb39f1f12e mgmt: updatehub: Clean-up mcuboot & system dependencies
Currently MCUboot and system reset are invoked directly in the sample
applicatiion. This introduce 2 new methods to isolate system from
application.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Gerson Fernando Budke
689d7cb085 mgmt: updatehub: Clean-up firmware headers
Move header includes to source file. Currently firmware source files
have a hardcode partition identificator. This moves identificators
to updatehub core.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Gerson Fernando Budke
f3159e3885 mgmt: updatehub: Clean-up device headers
Move headers from header includes to source file.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-12 12:11:31 +01:00
Siddharth Chandrasekaran
73809472f8 mgmt/osdp: Add support for event delivery and notifications
The CP app sends PD a "command" and the PD responds to it. Some times,
the PD has something that it wants to tell the PD which it does so in
response to POLL command. Both CP and PD apps need a way to exchange
these info over the OSDP bus. To archive this we will introduce what are
called "events" that allow the PD app to enqueue and CP app to get
notified.

This is analogous to the incumbent "commands" abstraction where, the CP
app enqueues a command and the PD app gets notified of it.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
c7fec71193 mgmt/osdp: Add length checks for commands and replies
For all commands and replies, the buffer length needed to build or the
length of data needed to decode needs to be checked and asserted. Right now
we do this by ad-hoc if-s. Add macros that do this at a common location.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
f4e3f2b828 mgmt/osdp: Add inline methods for flag checks
The raw, flags check has become a bit excessive and has begun to affect
code readability. Provide inline functions for those accesses that are
frequent. Also, get rid of `struct osdp_cp` as it can be fully represented
by `struct osdp` itself.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
b31e708c03 mgmt/osdp: Rename pd offset as index
CP has an array of PDs and pd->offset was the position of the PD in CP's
list. Since offset has many meanings, rename it to pd->idx.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
059abd8d8b mgmt/osdp: Flush RX buffer before sending data
Partial packets in the RX buffers cause the subsequent packet to be
treated as malformed. The RX buffer can have partial data if the sender
is too slow in sending the packet of if there is an interruption in
transmission mid-way.

To avoid any issues due to such partials, flush the uart channel before
sending the command/response.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Siddharth Chandrasekaran
a1f3c7631f mgmt/osdp: Cleanup log messages and return codes
The log lines in CP and PD had a prefix such as "CP: " and "PD: " that
does not add too much value as a given device an either be CP or PD
only. This patch removes those and enhances some other log lines while
at it.

It also adds a enum for return values throughout the module to improve
code quality.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Sam Hurst
d9c4ec31fc usb_c: Fix comments before "else" statements
Move comments that precede an "else" into the "else"
statement.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-11 18:55:18 +01:00
Sam Hurst
f84ee58abd usb_c: Add protocol error flag
Use a flag to report a protocol error to the states. This keeps
state specific actions in the state. Currently, those state
specific actions are handled in the pe_report_error function.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-11 18:55:18 +01:00
Johann Fischer
98770caf2a usb: device_next: remove workaround for the UDC enqueue bug
Remove workaround for the UDC enqueue bug in experimental
CDC ACM implementation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-11 17:44:50 +01:00
Johann Fischer
e9bab613cc usb: device_next: rename Kconfig template instances count
The name and wording used in template can be misleading.
Use more accurate word instance instead of device since
an implementation does not necessarily have to implement
a device (in the sense of Zephyr device model), and if it
does then devicetree should be used to describe number of
instances as in the case of CDC ACM implementation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-11 17:44:27 +01:00
Emil Gydesen
c8014d181e Bluetooth: Audio: Remove unicast_group_valid_qos
The function checked several value, but the BAP spec does
not specify that these cannot be different from stream to
stream in the CIG. The function thus did nothing but needlessly
restrict the upper layers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-11 17:07:11 +01:00
Pavel Vasilyev
ffc4e716f0 Bluetooth: Mesh: Add extra flag to control seg msg in frnd queue
This commit fixes issue introduced in
5d059117fd.

Use extra flag stored in user data of net_buf to control segmented
messages in Friend Queue. The initial idea with using fragments didn't
work.

This fixes the following PTS tests:
- MESH/NODE/FRND/FN/BV-08-C
- MESH/NODE/FRND/FN/BV-19-C
- MESH/NODE/CFG/HBS/BV-05-C

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-11 10:47:06 +00:00
Pavel Vasilyev
7b4f94220d Revert "bluetooth: mesh: Remove illegal use of NET_BUF_FRAG in friend.c"
This reverts commit 5d059117fd.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-01-11 10:47:06 +00:00
Robert Lubos
a64be51391 net: stats: Fix UDP packet counter for DHCPv4 TX
Fix UDP TX packet count when DHCPv4 is used. Currently UDP TX counter
is only updated when net context is in use. DHCPv4 however does not use
net_context underneath, therefore it needs to update UDP TX stats on its
own.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-11 11:26:08 +01:00
Michał Barnaś
3ae105e76b ec_host_cmd: add NPCX SHI peripheral for the host commands
This commit adds the support for host commands being transported
by the Serial Host Interface on the NPCX SoC.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-01-11 09:38:45 +01:00
Robert Lubos
76dd77df7e net: zperf: Fix potential build warning
A variable was defined directly after a label in two case statements,
resulting in build warning with certain compilers.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-10 14:07:21 +00:00
Troels Nilsson
d7acb9355c Bluetooth: controller: Fix JIT rescheduling for ext. advertising
Fixes two issues with the JIT scheduler:

Rescheduling of primary advertising packets for extended advertising
when using the JIT scheduler did not work, since the done events for
the primary events never made it into the reschedule logic

The EVENT_DONE_EXTRA_TYPE_ADV_AUX event (for auxillary packets) could
cause a "reschedule" for a primary event that was actually sent
successfully (causing it to be sent twice)

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-01-10 14:05:42 +00:00
Jamie McCrae
b8ef838069 mgmt: mcumgr: Select console if using UART transport
This prevents a configuration error by selecting the console if
the UART MCUmgr transport is used, which is actually a dependency
for this transport.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-10 13:49:17 +01:00
Daniel DeGrasse
9a63abc5c6 sd: utilize sdmmc_wait_ready with SPI mode.
Update sdmmc framework to use sdmmc_wait_ready when accessing card in
SPI mode. this will allow cards that do not return to ready to be polled
for busy status until the SD data timeout expires

Fixes #52931

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-10 13:29:32 +01:00
Krishna T
b59c89123c net: shell: Add support to set Ethernet MAC address
Add a shell command to set Ethernet MAC address, useful in configuring
custom/local MAC addresses.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 13:29:22 +01:00
Krishna T
6e3e10e6cd net: shell: Fix duplicate tag
Recently introduced MISRA-C CI check complains about use of a duplicte
tag, so, shorten the variable from shell->sh to avoid same name as the
structure.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 13:29:22 +01:00
Nick Ward
583545b662 net: openthread: Add state change callback list
Add a new callback list structure for state change information.

These APIs are meant to eventually replace the single callback API
provided by openthread_set_state_changed_cb().

This will allow multiple users to gain information about
OpenThread stage changes.

Note CONFIG_OPENTHREAD_MAX_STATECHANGE_HANDLERS
with OpenThread's otSetStateChangedCallback() API can also be
used to enable registration of multiple callbacks of this type but this
cannot be modified if a certified OpenThread binary is used in the
build.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2023-01-10 13:29:15 +01:00
Johann Fischer
7a90b221a5 usb: device: bluetooth: remove USB_TRANS_NO_ZLP for OUT transfers
USB_TRANS_NO_ZLP flag has no meaning for usb_transfer() in
host-to-device direction (USB_TRANS_READ).

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-10 10:30:46 +01:00
Pirun Lee
1e6f36cca7 Bluetooth: OTS - Add Calculate Checksum support
OTS add Calculate checksum feature support.
OTS client add object calculate checksum function.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2023-01-10 09:59:36 +01:00
Emil Gydesen
4716438c20 Bluetooth: Audio: Modify the compile guard for audio_iso.c
audio_iso.c should only be compiled if we require any streams,
so it is now guarded by CONFIG_BT_AUDIO_STREAM.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-10 09:58:54 +01:00
Krishna T
d796f23e0e net: wifi_mgmt: Add support for power save configuration
Add support for configuring power-save in Wi-Fi chipsets, supports
Legacy, WMM and TWT.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 09:52:11 +01:00
Krishna T
3f4597d0c9 net: l2: wifi: Arrange commands in alphabetical order
This helps find the command needed easily.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 09:52:11 +01:00
Sjors Hettinga
1be1b472cd net: tcp: Extend TCP receive queue timeout
After several fixes of the re-ordering logic in TCP, the receive queue
works as intended and cleans itself up properly. Previously the default
timeout was 100 ms, which pretty much disables it for real applications.

Increase the timeout to 2 seconds to actually enable it for in practice.
This should help pass much more of the Maxwell Pro tests.

This is the first step before removing the timeout completely.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-01-10 09:26:28 +01:00
Emil Gydesen
ce9385b388 Bluetooth: Audio: Shell: Fix compile warning for 0 client snk/src ASE
In case that CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT or
CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT is set to NULL, the
unicast client implementation in the shell would have compile
warnings, since the arrays would be 0 and we would attempt to
access it some places (or rather the compiler/linker would
think that, but it would never happen at runtime).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-10 09:25:36 +01:00
PawelX Dobrowolski
07052aba13 logging: days in months calculation fix
Array 'days_in_month' of size 12 may use index value bigger then
count of its elements.

Signed-off-by: PawelX Dobrowolski <pawelx.dobrowolski@intel.com>
2023-01-10 09:23:35 +01:00
PawelX Dobrowolski
20ed64be62 logging: prevent of NULL pointer comparison
Add prevent dereference NULL in strcmp

Signed-off-by: PawelX Dobrowolski <pawelx.dobrowolski@intel.com>
2023-01-10 09:23:35 +01:00
Jamie McCrae
d0e421225a mgmt: mcumgr: callbacks: Fix not checking event ID properly
Fixes an issue whereby event ID was not checked properly, meaning
that OR'd events would not work as one would expect.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-09 17:36:04 -08:00
Yong Cong Sin
20a05b6838 subsys/settings/fcb: removed unused var
Removed the `wbs` var since it isn't used.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2023-01-09 23:19:00 +00:00
Jani Hirsimäki
e92b067b7f net: ip: net_context: AF_PACKET/SOCK_RAW/IPPROTO_RAW: set pkt family
Setting a detected packet family (ipv4 or ipv6) in net_context level
instead in lower layers for AF_PACKET/SOCK_RAW/IPPROTO_RAW type sockets
when sending data.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2023-01-09 19:21:18 +01:00
Jonathan Rico
e6aba3e9af Bluetooth: host: clear ATT_CONNECTED flag on detach
Clear the `ATT_CONNECTED` flag when a channel is detached (could be after
an ATT timeout).

Also convert the assert checking it in `chan send` to an `if` test, since
the channel could be disconnected from a different thread than the one
triggering `chan_send`.

Fixes #53247.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-01-09 19:19:39 +01:00
Flavio Ceolin
a2a2c62abd tracing: none: Remove unnecessary headers
This file does not need any header, remove all of them.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-09 12:07:28 -05:00
Emil Gydesen
d37613d20a Bluetooth: Audio: Audio ISO use log_config_inherit
Change the BT_AUDIO_ISO logging module to use
log_config_inherit to be consistent with the other LE Audio
logging modules.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Emil Gydesen
a9071b361f Bluetooth: Audio: Add missing codec debug Kconfig
Add misisng codec debug Kconfig for the codec.c file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Emil Gydesen
6ca40703d1 Bluetooth: Audio: Fix CAP initiator debug level
Add missing debug level Kconfig option and use it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Emil Gydesen
5e49282dab Bluetooth: Audio: Fix CAP Acceptor Debug log level
The implementation did not use the defined log level
Kconfig.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 15:27:28 +00:00
Gerson Fernando Budke
313049e325 mgmt: updatehub: Rework check integrity
The TinyCrypt is the current library used by UpdateHub to perform
SHA-256 integrity check. This refactor code and add support to
mbedTLS library. It changes default library to mbedTLS to use
hardware accelerator when available.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-09 15:24:10 +00:00
Gerson Fernando Budke
358ad431b8 storage: flash_map: Add name for select integrity backend
Currently choice for FLASH_AREA_CHECK_INTEGRITY does not have a
denomination. Without that it is not possible select a default
backend hash backend for integrity check at project configuration.
This add a name to allow select flash area check integrity backend.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2023-01-09 15:24:10 +00:00
Vinayak Kariappa Chettimada
9aa4cdbb67 Bluetooth: Host: Fix access of uninitialized bt_dev.le.acl_pkts
ISO Synchronized Receiver only builds do not transmit and
hence may not have any tx buffers allocated in a
Controller, leaving bt_dev.le.acl_pkts semaphore
uninitialized or bt_conn_get_pkts() returning NULL.
Do not use the semaphore if no Tx buffers allocated in a
Controller.

Regression in commit ef19c64f1b ("Bluetooth: host: poll on
CTLR buffers instead of host TX queue").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-01-09 12:41:33 +01:00
Kim Sekkelund
78999f0db6 Bluetooth: Audio: TBS: Fix read buffer
Add common function to handle large GATT reads of strings.
Initialize the buffer pointers in the net_buf which is used for large
GATT reads by bt_tbs_client_read_call_state() and
bt_tbs_client_read_current_calls().
Define the size of the allocated buffer based on the enabled features.

Signed-off-by: Kim Sekkelund <ksek@oticon.com>
2023-01-09 12:18:55 +01:00
Emil Gydesen
489e99c091 Bluetooth: ISO: Fix bad handle of data path error for broadcast
The way that the braodcast clause for handling failing
ISO data path would end up in the __ASSERT. It has been
slightly modified to make it use if-else properly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 12:18:11 +01:00
Emil Gydesen
249d4774f3 Bluetooth: Audio: Add bt_audio_dir_str to improve logging of dir
The direction of a stream/endpoint/parameter has just been
logged as a unsigned integer. This commits adds a
value -> string internal function that would log
BT_AUDIO_DIR_SINK as "sink" and BT_AUDIO_DIR_SOURCE
as "source".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-09 12:18:03 +01:00
Henrik Brix Andersen
11aa8454f0 Revert "random: Change testing random generator"
This reverts commit d6881de3b3.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-09 19:29:50 +09:00
Declan Snyder
d6881de3b3 random: Change testing random generator
The old random timer test was not random-looking
enough on some platforms.

Replace with new test which is psuedo-xoshiro.

The generator is still deterministic
and does not depend on entropy at all,
but should look more random for testing.

Change name of generator tree-wide also.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-09 10:16:55 +01:00
Erik Brockhoff
2f61771948 Bluetooth: controller: consider host ctrl feature bits in feat exchange
Host controlled feature bits were not considered in feature exchange
procedure. This is fixed.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-01-08 19:48:38 +01:00
Aaron Massey
c4be38dec1 fuel_gauge: sbs_gauge: Enable MFR ACC write
Update the SBS Gauge driver that implements the fuel_gauge API to implement
a set_property function allowing the writing of an SBS word to the
manufacturer access register per the SBS spec.

Includes an update to the SBS Gauge emulator and SBS fuel gauge tests to
weakly verify the code runs.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-01-08 19:48:12 +01:00
Aaron Massey
48d5b6c1f1 emul: Correct emul_sbs_gauge to allow SBS word r/w
Fix SBS I2C transfer emulation to accept reads and writes of 16 bit words
as defined by the SBS spec. This change is tested by a following commit
that implements writing and subsequently reading a written SBS property.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-01-08 19:48:12 +01:00
Aaron Massey
c0762d003a fuel_gauge: Implement sbs gauge read for mfr acc
Implement and weakly test fetching the manufacturer access word from an SBS
compatible fuel gauge.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-01-08 19:48:12 +01:00
Emil Gydesen
57218eee31 Bluetooth: Host: Add BT_CONN_INTERVAL_TO_US
The macro BT_CONN_INTERVAL_TO_MS was used a fair amount
of places, but it often was used with integers. This meant
that sometimes the resulting (integer) value would be
incorrect, as something like 7.5ms interval would not
be properly stored as a integer in millisecond units.

Adding BT_CONN_INTERVAL_TO_US allows users to still use
integers to store the result, but in a more accurate unit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-08 19:47:03 +01:00
Emil Gydesen
8d86fa0125 Bluetooth: Audio: Add support for encrypted broadcast
Add support for adding a broadcast code to the broadcast
source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-06 10:35:25 +00:00
Robert Lubos
3fd0801a49 net: ipv4: Fix packet leak with IPv4 autoconf
The IPv4 autoconfiguration feature relies on the fact, that autoconf
ARP packets are always prepared by the ARP module. After recent ARP
refactoring though that could no longer be the case due to packet
queueing mechanism. This could lead to net pkt leaks in the autoconf
module.

Fix this by skipping the pending packet queue for autoconf packets.
Since for autoconf ARP requests there's no really a pending packet
to queue, it can be safely avoided. This results in the ARP request
being always sent for the autoconf case, preventing the packet leak.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-05 14:39:17 +00:00
Juha Ylinen
5e4eeb104d net: lwm2m: Verify data buffer size in lwm2m_engine_set()
Check data buffer size and return error if
     * buffer size is too small for opaque or string data type
     * buffer size is not equal to res data length when data type
       is fixed size

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-05 14:39:01 +00:00
Mariusz Skamra
8cd6c55d96 Bluetooth: audio: ascs: Fix possible race condition
This fixes possible ASE state race condition. The notification is sent
immediately once the ASE state changed that eliminates a situation where
the state was changed by user action (API function call) when the state
was not yet notified to the remote Unicast Client.

Fixes: BAP/USR/SCC/BV-158-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-05 12:43:32 +01:00
Pascal Brogle
60bf310aae net: lwm2m: fix senml cbor object link encoding
use text format instead of tlv format

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-05 12:43:24 +01:00
Juha Heiskanen
a70f420b2b net: lib: Patch file for generated code fix
Patch for generated lwm2m senml-cbor.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Juha Heiskanen
d939c79af1 net: lib: LwM2M SenML-Cbor regenrated files update
Patched and fixed regenerated code.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Juha Heiskanen
637c9bbf95 net: lib: regenerate cbor code using zcbor
with the updated cddl for object links.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Pascal Brogle
547c3063b9 net: lwm2m: support senml cbor object link
use "vlo" map key

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-05 12:43:24 +01:00
Juha Ylinen
eb914f45d1 net: lwm2m: Check return value from lwm2m_rd_client_pause/resume
Check return values from lwm2m_rd_client_pause() and
lwm2m_rd_client_resume() when engine thread suspend is requested.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-05 12:43:00 +01:00
Sam Hurst
983b693198 usb_c: Stop chunking_not_supported timer on exit
Stop chunking_not_supported timer on exit

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
0ed5c886c9 usb_c: Remove unnecessary PE_FLAGS_PROTOCOL_ERROR flag
Remove unnecessary PE_FLAGS_PROTOCOL_ERROR flag

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
77c7a51e4d usb_c: Remove unnecessary code from PE_Send_Soft_Reset
Remove unnecessary code from PE_Send_Soft_Reset

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
3af2752680 usb_c: Transition to Sink Ready on sender response timeout
Transition to pe_snk_ready state from pe_drs_send_swap_run,
on sender response timeout

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
24e18d46f1 usb_c: Properly handle Protocol Errors during DRS
From 8.3.3.4.2.1 PE_SNK_Send_Soft_Reset State, Error Recovery
should be performed if a Protocol Error happens during a Data
Role Swap.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
c27a3a31d3 usb_c: Fix DPM request handlers
Processing the common DPM request handler in the
Sink DPM request handler.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
f04da7f7ab usb_c: Check state machine array of states
Build time check that the number of states initialized
in the state machine array matches the number of enums
used to index said array.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
5b3155ff90 usb_c: Use atomic arrays for PE flags
Use atomic arrays for PE flags because the total number
of Policy Engine flags could exceed 32

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
914fed36d5 usb_c: run clang-format
Run clang-format

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst
7910c617be usb-c: Refactor USB-C Subsystem Sink
Refactor USB-C Subsystem Sink so that Power Delivery
Source support and be easily added.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Chris Friedt
4108e14740 ztest: provide sys_clock_tick_set syscall
Accurate timekeeping is something that is often taken for granted.

However, reliability of timekeeping code is critical for most core
and subsystem code. Furthermore, Many higher-level timekeeping
utilities in Zephyr work off of ticks but there is no way to modify
ticks directly which would require either unnecessary delays in
test code or non-ideal compromises in test coverage.

Since timekeeping is so critical, there should be as few barriers
to testing timekeeping code as possible, while preserving
integrity of the kernel's public interface.

With this, we expose `sys_clock_tick_set()` as a system call only
when `CONFIG_ZTEST` is set, declared within the ztest framework.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-04 21:12:58 +01:00
Mariusz Skamra
9148fb65d7 Bluetooth: att: Fix deadlock on meta data context allocation
This fixes deadlock that happened waiting for meta data in system
workqueue.
The meta data always get freed in the system workqueue,
so if we're in the same workqueue but there are no immediate
contexts available, there's no chance we'll get one by waiting.

Fixes: #53455
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-01-04 16:51:05 +01:00
Emil Gydesen
7d410c5cad Bluetooth: Audio: Fix issue with creating unidirectional CIS
As the unicast client, we would always create bidirectional
CIS to ensure that the PHY parameter is correctly set.
We can, however, just set the (required) PHY value and
leave the SDU and RTN values as 0, to avoid
creating bidirectional CIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
1e5be3f020 Bluetooth: Audio: Fix issue with unicast client src/snk ASE count
If either the sink or source ASE count was zero, calls to
ARRAY_SIZE(srcs) or ARRAY_SIZE(sinks) would cause a build warning.

The arrays should actually not be there at all if the respective
ASE count was 0, as that is just a waste of memory. The arrays,
and all uses of them, have been properly guarded.

This also adds a build assert to ensure that at least one
of them is non-zero, and that we also test building either
of them with the value 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
b9a6e04cb3 Bluetooth: Audio: Add AUDIO_ISO debug logging
Add a logging module for the audio_iso.c file, to enable
logging for that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
32ff1b671b Bluetooth: Audio: Add (un)bind of audio iso for streams
This allows us to allocate and bind the Audio ISO structs
to Audio Streams, thus allowing us to create the unicast group
before they have been configured.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Emil Gydesen
4c058402a5 Bluetooth: Audio: Fix issue with deleting unicast groups
There was a bug in bt_audio_iso_unbind_ep that caused an
assert, missing unbinding on stream released callback
and missing state check in bt_audio_unicast_group_delete

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-04 10:35:14 +01:00
Tomasz Moń
73e3fcabc0 usb: dfu: Schedule timer handler from USB workqueue
Use k_work_delayable instead of k_timer in order to execute timeout in
USB workqueue context instead of ISR context. This fixes Will-Detach on
targets where usb_dc_detach() uses functions not allowed in ISR context,
e.g. nrfx usb_dc_detach() acquires mutex.

Fixes: c27d48c89a ("usb: dfu: Support DFU with WinUSB on Windows")

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-01-04 10:33:35 +01:00
Juha Ylinen
c7a5f7fda7 net: lwm2m: Deprecate Kconfig for LwM2M RD Client
RD-Client is essential part of LwM2M specification and it can't
be disabled from LwM2M engine. This commit deprecates Kconfig
variable CONFIG_LWM2M_RD_CLIENT_SUPPORT and removes
all usages if it.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 13:23:46 +01:00
Hein Wessels
3210541c86 toolchain: gcc: rename popcount to avoid conflict with C++20
The macro conflicts with the C++20 feature std::popcount

fixes zephyrproject-rtos/zephyr#53421

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-01-03 11:06:45 +01:00
Marco Argiolas
2527320848 net: lib: sntp: add support for unspecified IP-family type
`sntp_simple()` was forcing to resolve SNTP-server's URL into IPv4 address
addresses. This was not allowing sntp_init() to succeed in case the system
 did not support IPv4 addresses (returning EPFNOSUPPORT, ie. Protocol
Family error).
Now by default SNTP has unspecified family type and it relies on
`net_getaddrinfo_addr_str()` to be able to resolve literal server URLs
into the supported IP family type.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-01-03 11:03:25 +01:00
Marco Argiolas
d51182d57d net: lib: sockets: support IPv6-only use case with AF_UNSPEC
Setting `hints.ai_family` to `AF_UNSPEC` was causing
`net_getaddrinfo_addr_str()` and in turn `getaddrinfo()` to resolve the
literal SNTP SERVER first into IPv4 and then (if supported) IPv6 addresses.
 This was causing useless waste of time and memory in case IPv4 was not
supported. In addition, in case IPv4 addresses were not supported, other
system components (eg. SNTP) could fail due to the DNS returning IP
addresses with unsupported family type (ie. IPv4).
Now, if address family is not explicitly set to `AF_INET` (ie. IPv4), then
 no attempt is made to resolve SNTP server address into an IPv4 address.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-01-03 11:03:25 +01:00
Juha Ylinen
7dfa2c8a2b net: lwm2m: Add shell commands
Add shell commands to read and write native time_t value.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:03:16 +01:00
Seppo Takalo
a33f3b6abb net: lwm2m: Add shell command to enable timeseries cache
Add shell command

  cache   :Enable data cache for resource
           cache PATH NUM
           PATH is LwM2M path
           NUM how many elements to cache

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Heiskanen
1800e629e6 net: lwm2m: LwM2M times series data update
Fixed problem for matching path url with or without '/'
by change time series data structure to use struct lwm2m_obj_path.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Heiskanen
3abd9c364a net: lwm2m: LwM2M Object path equal API
Added new API for check is 2 object path equal.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Ylinen
16b6892294 net: lwm2m: Refactor lwm2m_information_interface_send()
Call lwm2m_send_message_async() from function
lwm2m_information_interface_send() and remove duplicate code.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:02:44 +01:00
Juha Ylinen
1111184b74 net: lwm2m: Remove lwm2m_send_message() from public API
lwm2m_send_message() sends a message directly to the socket. Remove
the function from public API and combine the code with
socket_send_message().

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:02:44 +01:00
romain pelletant
5c14c56f2c net: lwm2m: add binaryappdatacontainer obj support
OMA LwM2M object 19 support for application specific binary data
Related issue #53340

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-01-03 11:02:09 +01:00
Krishna T
59842531d1 net: zperf: Make shell dependency optional
Now that we a proper API, shell is just optional, so, make the
dependency optional by refactoring the code.

Also, add a build test combination in twister.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-03 11:02:01 +01:00
Miquel Raynal
9ce8c26d34 net: l2: ieee802154: Add missing scan callback registration
Initializing an event callback with net_mgmt_init_event_callback() just
sets some of the callback fields but do not propagate those masks in the
core. If we want to use the callback, it is necessary to also call
net_mgmt_add_event_callback().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
6a11e79b4b net: l2: ieee802154: Fix a wrong channel change during association
The current association logic starts by changing the channel. The way it
is done is wrong because it dereferences req->channel which is simply
not initialized by the caller. But anyway, the command itself does not
support providing a channel so we must already be on the right one when
trying to associate. Hence, drop this channel change call.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
31b35973e3 net: l2: ieee802154: Change the hardware filters while associating
During an association, the peer we are trying to connect to will send us
an association response frame with the destination PAN ID set to the PAN
ID we try to join. If we do not update the hardware address filters
beforehands, it is likely that the hardware will just discard the
response and the association will fail.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
19e67800f9 net: l2: ieee802154: Avoid dangling MAC command bits
While the packet structures seem to always be reset when they are
allocated, it's apparently not the case of the data buffers. Indeed,
these are allocated differently and just attached to the packet
structure through a frag/buffer member.

Experience shows that we may get uninitialized buffers so let's set
all MAC parameter bits one by one, even the reserved ones.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
2fd336c5d2 net: l2: ieee802154: AR shall be provided in association requests
The spec clearly states: "association requests shall set the AR bit".

Even though Zephyr can currently only implement RFD devices which are
not expected to support incoming association requests, because this MAC
command is actually processed until being voluntarily ignored, let's
ensure the expected "ar" value is right to avoid failing because of a
wrong reason.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
fa05c60674 net: l2: ieee802154: Fix logic with address types
When validating a MAC command, the "src" and "dst" fields may be set to:
- IEEE802154_ADDR_MODE_SHORT (0x2)
- IEEE802154_ADDR_MODE_EXTENDED (0x3)
- IEEE802154_ADDR_MODE_SHORT | IEEE802154_ADDR_MODE_EXTENDED (0x3)
Hence when the mode check happens, any times the mode is set to SHORT
the check will fail while in practice it was meant to be valid because
the check is:

    if (src_mode == src || dst_mod == dst)

Use bitfields when relevant so that when checking capabilities we use
the bit offsets rather than the plain numbers.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Miquel Raynal
b86b7d3a41 net: l2: ieee802154: Fix address length macros
When validating a MAC command, there is sometimes a misunderstanding of
what "src" and "dst" length mean.

There are actually two fields in the MHR:
- One giving the type of address, if it is short or extended, it is the
  value provided by the macros IEEE802154_ADDR_MODE_{SHORT,EXTENDED} and
  their respective decimal values are 2 and 3.
- One giving the size of the address field, this is
  IEEE802154_{SHORT,EXT}_ADDR_LENGTH and their value is actually 2 and 8
  (bytes).

The function validate_mac_command() provides inputs to
validate_mac_command_cfi_to_mhr() which expects the former information.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2023-01-02 10:54:46 +01:00
Andrei Emeltchenko
d320100df4 net: ip: Fix dereference before NULL check
Fix warnings like "Dereference before NULL check". Also make check
readable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-12-30 11:11:06 +00:00
Krzysztof Chruscinski
63eba62876 logging: Reset buffered message counter on init
Add reset of buffered messages counter to the initialization function.
It is for testing purposes sinces in the application logging is
initialized only once.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-29 10:33:29 +01:00
Piotr Jasiński
ceb7ca7e80 modules: build segger debugmon code with config
Updated segger module CMake to build code added by
https://github.com/zephyrproject-rtos/segger/pull/14 when relevant
config is provided.

Signed-off-by: Piotr Jasiński <piotr.jasinski@nordicsemi.no>
2022-12-28 12:00:46 +01:00
Dominik Ermel
77f21ce966 storage: flash_map: shell: Show device pointer instead of ID
The commit changes flash_map list output to display flash_map
assigned pointer instead of device ID which was not propagated
anyway.
The commit also fixes formatting of the output.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-27 13:24:55 +01:00
Jamie McCrae
b64ea89ed5 mgmt: mcumgr: img_mgmt: Fix mismatched slot missing variable
Fixes an issue with a missing variable when
CONFIG_IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT is enabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-24 16:58:11 +01:00
Juha Heiskanen
4a50f9362f net: lib: LwM2M rd client fix
Fix LwM2M rd client stop call hang when Queue client is at
RX_ON_IDLE_STATE. Added miossing connection resume for
de-register functionality.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-12-22 15:50:31 +00:00
Kai Vehmanen
0368b49ea7 logging: fix error handling in link_filters_init
If k_malloc() of filters fails in log_mgmt.c:link_filters_init(),
return an error and do not rely on the __ASSERT(0).

If __ASSERT_ON==0 in the build, assert will not trigger and
code will proceed to execute

  memset(NULL, 0, sizeof(uint32_t) * total_cnt);

Avoid this by returning -ENOMEM on error.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-12-22 14:43:43 +01:00
Juha Ylinen
1827636ab6 net: lwm2m: Verify receiving buffer size in lwm2m_engine_get()
Check receiving buffer size and return error if
 * buffer size is too small for opaque or string data type
 * buffer size is not equal to data lenght when data type is
   fixed size

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2022-12-22 13:44:27 +01:00
Dominik Ermel
671625cd0c mgmt/mcumgr: Add Kconfig option naming notes
The commit adds Kconfig option naming notes to Kconfig
files of MCUmgr subsystem.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Dominik Ermel
c7378d0d84 mgmt/mcumgr: Move Kconfig options to proper Kconfig files
After Kconfig options got renamed, some of the no longer fit
to files they have been defined in.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Dominik Ermel
db34adf9c3 mgmt/mcumgr: Standardise MCUmgr Kconfig names
Standardise Kconfig options for MCUmgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Rob Barnes
61b5566e74 logging: Add an option for a custom log header
There are scenarios when it is necessary to globally redefine
a log macro. The existing logging frontend is not sufficient since
it redirects at the function level.

One example is using pigweed_tokenzier. The pigweed tokenizer depends
on intercepting log strings at the macro level to function.

Introduce an option to include a custom application provided header
named "zephyr_custom_log.h" at the end of log.h. This allows an
application to extend the LOG_* macros globally.

This change includes a simple test that redefines the core LOG macros
to include a custom prefix.

Signed-off-by: Rob Barnes <robbarnes@google.com>
2022-12-22 11:09:59 +01:00
Jamie McCrae
23ca3841db mcumgr: img_mgmt: Add SHA256 image upload hash check
Will check an uploaded image's hash against the hash that was
originally supplied before the upload began and return the result to
the client to know if the upload was successful or if there was an
error during upload. Requires CONFIG_IMG_ENABLE_IMAGE_CHECK be
enabled for functionality to be available.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:08:49 +01:00
Hubert Miś
0b5ac4023f ipc: icmsg multi endpoint with nocopy in receive path
Add nocopy feature to icmsg-me initiator and follower roles
in their receive path. This feature is optional, configured
with Kconfig.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
6d3d2309ce ipc: icmsg multi endpoint with nocopy in send path
Add nocopy feature to icmsg-me initiator and follower roles
in their send path.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
3a1c9bce6e ipc: icmsg: send nocopy feature
Add a nocopy feature for sending message through the icmsg IPC library.

Also eliminate data races if multiple threads are using the
same ipc instance and are trying to send a message simultaneously.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
5b023df67f ipc: icmsg: rx nocopy feature
This patch adds an optional nocopy feature for RX message to the icmsg
IPC library. The nocopy feature can be enabled using project
configuration.

If this feature is not used by icmsg users it is recommended to disable it
to reduce memory usage and improve run-time performance.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś
4a79754dd5 ipc: icmsg capability to clear rx buffer headers
On system startup icmsg headers space must be cleared before
cores start handshake procedure. The simplest way to enforce
it is to clear memory by the core responsible by enabling
the remote core, before the remote core is enabled and before
the handshake is started.

This patch ensures that nRF53 APP core clears both TX and RX
memory for icmsg before it starts NET core.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-12-22 11:07:44 +01:00
Kamil Gawor
d0e21fe6a6 ipc: Enable ICMSG multiendpoint role by default
This commit enables the initiator or the follower
role for the ICMSG multi-endpoint backend
depending on dts by default.
It is needed when BT_RPMSG transport for HCI is used.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-12-22 11:07:44 +01:00
Robert Lubos
d27ace4012 net: zperf: Simplify shell initialization
Instead of calling zperf shell initialization routine on the first
command execution, initialize it during system boot, along with other
zperf submodules.

Remove redundant IP address configuration on an interface. The default
configuration relies on NET_CONFIG module, so there's no need to set the
address manually in zperf.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
7a2c8d2ab8 net: zperf: Shell cleanup
Zperf shell functionality is now encapsuled within a single file,
therefore it no longer makes sense to have a separate shell_utils
file.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
dd3fb692fe net: zperf: Add shell command to stop TCP/UDP server
Add zperf shell command to stop TCP/UDP server.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
87ca1c3329 net: zperf: Make UDP/TCP servers restartable
Make the TCP/UDP server functionality restartable. Provide a public API
to stop the TCP/UDP server.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
cd4f7cbc61 net: zperf: Add public API to start TCP/UDP server
Add public API for zperf download functionality. The TCP/UDP server
modules are decoupled from shell, allowing to trigger download directly
from the application code. The shell submodule makes use of this new
public API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
722ed07287 net: zperf: Add shell option for asynchronous upload
Add shell option to the UDP/TCP upload command, which allows to execute
the upload asynchronously. This allows to unblock the shell for other
commands during the upload.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
fde9577e24 net: zperf: Implement asynchronous upload API
Add an API which allows to perform UDP/TCP upload operations
asychronously.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Robert Lubos
812a1bc152 net: zperf: Define a public upload API for the library
This commit defines a public API for zperf upload functionality. The
UDP/TCP uploader modules are decoupled from shell, allowing to perform
uploads directly from the application code. The shell submodule makes
use of this new public API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-22 11:05:11 +01:00
Jamie McCrae
b4b6346cdc mgmt: mcumgr: Make Bluetooth and UDP transport init automatic
This moves the UDP and Bluetooth initialisation for MCUmgr to be
performed automatically with the new hander registration feature.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Jamie McCrae
541fcb884d mgmt: mcumgr: Make handler registration functions static
Makes group registration functions for MCUmgr handlers static as
they are registered automatically at startup.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Jamie McCrae
d7557102c0 mgmt: mcumgr: Add iterable section to register MCUmgr handlers
This replaces the requirement for applications to manually
register MCUmgr handlers by having an iterable section which
then automatically registers the handlers at boot time.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Emil Gydesen
4e3205d238 Bluetooth: Audio: Add packing to unicast group create
Add the ISO packing field when creating a unicast group.

This refactors the structure of the unicast group create,
as it now takes both the packing as a group parameter, as well
as an array of stream-specific parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-22 10:59:16 +01:00
Emil Gydesen
ba1949759d Bluetooth: Audio: Add packing field to broadcast source
Add support for setting the ISO packing field when
creating a broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-22 10:59:16 +01:00
Emil Gydesen
2935cac9d6 Bluetooth: Audio: Fix handling properly deleting endpoints
When there is an ACL disconnect, or the unicast group is otherwise
deleted, the endpoints were not properly handled, causing
incorrect `dir` values and ASSERTs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
21fd387cab Bluetooth: Audio: Fix unicast group add/free handling of endpoints
When adding or removing a stream from the group, the
endpoint may or may not have been allocated depending
on the state of the endpoint.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
f1bedd01c1 Bluetooth: ISO: Remove wrong requirement for cc_len
The hci_le_setup_iso_data_path function required that if
the path->cc was set, the length could not be 0.

There is no reason why it should not be allowed to be 0
in that case.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
a7e7d87912 Bluetooth: Audio: Fix issue with creating the CIG as unicast client
The unicast client could not create a CIG with a unidirectional
CIS, because it would not set the correct values as per the
HCI spec for the unused CIS direction.

Instead of implementating a work around, this commit modifies
it so that for unidirectional CIS, we copy the QoS values
to the unused direction, so that we always set valid values,
but it also allows us to actually use that CIS direction later,
assuming that the QoS settings does not change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Emil Gydesen
f239df0ca7 Bluetooth: Audio: Fix audio_iso handling for unicast client
For the unicast client, the direction for the endpoint
is reversed in terms of RX/TX, i.e. a sink endpoint is
RX for the unicast server and broadcast sink, but TX
for the unicast client, and similar for the source endpoint.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-21 16:19:35 +01:00
Trent Piepho
2112844eea logging: backend_uart: Reword buffer size Kconfig text
As written, the title and description of the Kconfig option seem to
specify the logging sub-system will not flush until the buffer is full.
Someone reading this would expect that shorter log message will not be
flushed until the specified number of bytes accumulate.

This is not the case.  Each log message is flushed when finished.  The
size is only the maximum bytes of a single formatted message's contents
that will be accumated before the backend flushes.

What's more, it only applies in deferred mode.  In immediate mode there
is no buffering, not just of multiple log messages but also of the
message contents as they are formatted.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2022-12-21 12:23:23 +01:00
Ryan McClelland
34cfba73b4 usb: device: hid: correct bcdHID to v1.11 spec
bcdHID is intended for the spec version of USB HID. It was pointing to the
v1.1 bcdUSB define which happens to be the same value for the v1.10 hid
spec version. This corrects it to use the v1.11 HID spec.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2022-12-21 12:20:55 +01:00
Erwan Gouriou
66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Grixa Yrev
2a992c65c0 net: websocket: new receiving algorithm
websocket_recv_msg() is reworked with using fsm. Now the function
return 0 when payload is empty, -ENOTCONN if socket close. Receiving
empty ping and sending empty pong were added in tests.
Fixes #52327

Signed-off-by: Grixa Yrev <grixayrev@yandex.ru>
2022-12-20 17:05:12 +00:00
Pavel Vasilyev
932e57396f Bluetooth: Mesh: Add macros to initialize bt_mesh_msg_ctx struct
The macros are added to make clear which fields of `struct
bt_mesh_msg_ctx` needs to be initialized by an application.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-20 17:05:04 +00:00
Lars Knudsen
081b83531b Bluetooth: has: Make HAS registration dynamic
This changes HAS registration to be dynamic and let's the
application set Hearing Aid Type and binaural features.

Often, devices are flashed with generic firmware with some
features stored post factory production, requiring
the settings to be moved from compile time to run-time.

This change will increase the RAM usage as the GATT
service is moved from ROM to RAM.

Signed-off-by: Lars Knudsen <larsgk@gmail.com>
Co-author: Soren Engquist <soren@engquist.dk>
2022-12-20 17:04:45 +00:00
Jamie McCrae
b4c2b57f1b mgmt: mcumgr: Make returning rc responses when status is OK legacy
This change changes the previous mcumgr behaviour of return result
codes when the status is 0 (OK) to being legacy behaviour, instead
it will skip the rc field for these responses. If there is only an
rc field with status 0 to return, then mcumgr will now instead just
return an empty map.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-20 11:57:22 +01:00
Lingao Meng
f3cea46c75 Bluetooth: Host: Fix missing pull left mem in scan pdu
For num_reports field bigger 1, should pull left mem.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-12-20 10:20:10 +01:00
Emil Gydesen
1424df424c Bluetooth: Audio: Add broadcast source metadata update function
Add API to do the BAP Broadcast Source Metadata update procedure,
which updates the metadata of a broadcast source while
it is streaming.

This is also makes all checks for the "head stream" the same.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-20 09:23:08 +01:00
Emil Gydesen
302ec9fa37 Bluetooth: Audio: Remove const for bt_audio_stream_reconfig codec
The codec is assigned to the stream. However since the metadata,
which is stored in the codec, may be modified by other means,
the stored pointer cannot be const, and thus the
codec argument to bt_audio_stream_reconfig cannot be const
either.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-20 09:23:08 +01:00
Fredrik Danebjer
18a889fb8b Bluetooth: Audio: ASCS: Make ASE Allocation Dynamic
Decoupled the ASEs from the ASCS Session and made them dynamically
allocated instead. A Kconfig option was added to set the maximum
number of active ASEs at a single time. The intent here is to allow
the developer greater control over memory usage; this fix addresses
one of the largest ram usages in le audio.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-12-20 09:23:00 +01:00
Fredrik Danebjer
15644da0a4 Bluetooth: Audio: Endpoint: Decouple Client and Server
Refactored out the client and server members of the endpoint struct
and placed the relevant members in wrappers in ascs and
unicast_client.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-12-20 09:23:00 +01:00
Emil Gydesen
32c7b9f46b Bluetooth: Host: Add logging of pairing req/rsp
Add logging of the fields in the sent and received pairing
requests and responses. This makes it easier to debug
why a pairing would be e.g. rejected, or simply to get
more insight in the resulting pairing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-20 09:22:10 +01:00
Robert Lubos
a60f32549e net: l2: ieee802154: Align LL address update routine
IEEE802154 L2 may modify the LL address during interface operation (when
processing MAC command). So far the L2 workaround the LL address update
protection by clearing the NET_IF_UP flag temporarily, but due to recent
changes it no longer works. Update this workaround to verify
NET_IF_RUNNING flag instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 18:18:03 +01:00
Robert Lubos
129f34fd0b net: if: Allow to set LL address after interface was brough admin UP
Bluetooth IPSP L2 sets the LL address only after establishing Bluetooth
connection. As this can take place after the interface was brough UP by
the application, the network interface API should not block such
attempt. Instead, verify the NET_IF_RUNNING flag.

For the same reason, move the assert verifying that LL address is set
from net_if_up() (which only puts the interface in the admin UP state)
into the function that transitions the interface into operational UP
state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 18:18:03 +01:00
Robert Lubos
f38d5f440f net: l2: bluetooth: Remove invalid check
After network interfaces state handling rework, it's no longer correct
to verify the connection status on `net_if_up()`, as this only changes
the administrative state of the interface. The interface won't be put in
operational UP state until it's connected.

This check prevented the interface from being brought up during system
boot.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 18:18:03 +01:00
Emil Gydesen
a96f8ba9ba Bluetooth: ISO: Fix ISO MTU when CONFIG_BT_BREDR=y
If CONFIG_BT_BREDR=y and bt_dev.le.acl_mtu == 0, then we
would report the bt_dev.br.mtu for ISO channels.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:16:01 +01:00
Emil Gydesen
ba0bb89a70 Bluetooth: ISO: Fix conn_mtu for BT_CONN_TYPE_ISO
If the bt_dev.le.iso_mtu was 0, then we would report
bt_dev.le.acl_mtu if CONFIG_BT_CONN=y (which is often true when
CONFIG_BT_ISO=y). Thus if the ISO MTU is 0, we would often
return a non-0 value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:16:01 +01:00
Emil Gydesen
b245b023e1 Bluetooth: Audio: Always start BAP discovery at handle 0x0001
Instead of only conditionally starting the discovery at
0x0001, we now always start it at that handle. Since we are
reading by UUID, this should not really affect performance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:13:02 +01:00
Emil Gydesen
fd6e6601e0 Bluetooth: Audio: Fix logging of object ID in mcc.c
mcc.c used 0x%016x, but for some platforms we need to
be more explicit and use 0x%016llx to avoid compile
warnings.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:12:50 +01:00
Emil Gydesen
e3fcf8267a Bluetooth: Audio: Fix issue with non-bonded devices in has.c
The HAS implementation of the security_changed callback
expected all devices to have bonded, and thus always added them
to the ntf_bonded implementation.

This adds a check to whether the device is actually bonded.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-19 18:12:38 +01:00
Marcin Niestroj
c707585e75 settings: remove local settings_mount_*_backend()
Prototypes of those functions are already in header files in
subsys/settings/include/settings/ directory, so no reason to have
duplicates in C files.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-19 16:00:08 +00:00
Marcin Niestroj
ebe815650e settings: fcb: remove second settings_fcb_storage_get() prototype
Remove settings_fcb_storage_get() prototype, as there the same prototype 5
lines below.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-19 16:00:08 +00:00
Jamie McCrae
95697b5fcf mgmt: mcumgr: Replace non-zephyr cmake functions with zephyr versions
This fixes an issue whilst investigating using iterable sections,
which cannot be used when the non-zephyr prefixed functions are
used. It also resolves a possible critical bug intoduced with the
MCUmgr rework whereby functions or elements seem to have silently
dropped.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-19 13:02:32 +01:00
Robert Lubos
1448923be3 net: shell: Make it possible to abort ping command
Rewrite the "net ping" command handling, to allow the command to be
aborted during execution. This includes:

* Using shell bypass mode to capture input whilst the ping is active.
* Using system workqueue to send individual ping requestes, instead of
  sending ping requests directly from shell thread, in a blocking
  manner. This is needed because in order to receive input in the
  registered bypass handler, the shell thread must be unblocked to
  process the input.
* The bypass mode is left after receiveing `CTRL-C` character (which
  cancels the ping), after receiving all expected Ping replies or after
  the timeout occurs.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 09:46:53 +00:00
Robert Lubos
55af3dd075 shell: Clear command buffer when leaving bypass mode
If bypass mode is left outside of the registered bypass handler, the
command buffer was not cleared, basically containig leftovers from the
processing of the previous command. This resulted in undefined behaviour
on consecutive shell operations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-12-19 09:46:53 +00:00
Corey Wharton
21a7c2d7eb pm: don't suspend unready devices when entering low power states
The PM subsystem should not call the PM control callbacks on
uninitialized devices when entering low-power states.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2022-12-19 09:46:17 +00:00
Jonathan Rico
dc4d63e97b Bluetooth: host: adv: set the address in bt_le_adv_resume
The address could have changed. The issue linked (and bsim test in previous
commit) shows a scenario where that could happen:

- we start scanning, host will use NRPA
- we start advertising, host will use identity address
- a device connects (as a central)
-> advertising resume fails for some unrelated reason
- another device connects (as a peripheral)
- the central device disconnects, we resume scanning
- the peripheral disconnects, the stack resumes advertising
-> but it mistakenly advertises using the NRPA set by the scanner

Fixes #52059 .

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-19 09:37:25 +00:00
Jonathan Rico
5f98b1bea4 Bluetooth: host: adv: add adv_is_directed helper
Makes it more readable.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-19 09:37:25 +00:00
Mateusz Wielgos
217987f1b5 usb: host: add port power and port reset USB hub features
Add port power and port reset USB hub features.

Signed-off-by: Mateusz Wielgos <mateusz.wielgos@emerson.com>
2022-12-16 13:21:12 +01:00
Johann Fischer
7c1ef35027 usb: add initial USB host support
This is initial support. Necessary to test the UHC driver API,
for the USB support test implementations, and upcoming USBIP support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-16 13:21:12 +01:00
Emil Gydesen
c27db9ed90 Bluetooth: Shell: Move the name filter last
Moved the name filter last, as that it the most expensive
to use.

The address filter has almost been moved after the more
trivial checks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-16 11:05:24 +00:00
Emil Gydesen
bc1bb4f63c Bluetooth: Shell: Add pa_interval scan filter
Add filtering for the pa_interval. This can be used to
easier find devices that are advertising with periodic
advertising.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-16 11:05:04 +00:00
Troels Nilsson
c0a5b1ef7b bluetooth: controller: Reduce user ops status to uint8_t
The status field is currently a uint32_t even though there are only
3 possible values. Reducing it to a uint8_t allows status to fit in
existing padding in the struct, saving 4 bytes per ticker_user_op

Updated function signatures to match; ticker_op_func left as-is
to avoid having to update a whole bunch of files for no real benefit

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-12-16 11:02:30 +00:00
Carlo Caione
a337bfc3b3 pm: runtime: Move from mutexes to semaphores
To be able to call pm_device_runtime_put() from an IRQ context, move
from mutexes to semaphores and force the async path when the put
operation is called from an ISR.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-15 22:35:38 +01:00
Carlo Caione
d38a6b4bcd pm: runtime: Migrate from condition variables to events
For the async operation move from condition variables to events to
reduce the dependency on the mutexes that cannot be used in IRQ
context.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-15 22:35:38 +01:00
Stephanos Ioannidis
37c6d52f8c random: Fix non-random number generator warning condition
The `TEST_RANDOM_GENERATOR` symbol in itself does not imply that a
non-random number generator is selected -- that is indicated by the
`RNG_GENERATOR_CHOICE` choices, of which only `TIMER_RANDOM_GENERATOR`
is a non-random generator.

This commit updates the Random subsystem to print the "non-random
number generator usage warning" when `TIMER_RANDOM_GENERATOR` is
selected, as opposed to when `TEST_RANDOM_GENERATOR` is selected.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-12-15 22:35:31 +01:00
Stephanos Ioannidis
6f91f97939 random: Clarify the semantics of TEST_RANDOM_GENERATOR
The `TEST_RANDOM_GENERATOR` Kconfig symbol indicates that a non-random
number generator (i.e. a random number generator that is not truly
random) is _allowed_ to be used for testing purposes, and not
necessarily that a non-random number generator is _selected_ -- that is
indicated by the `RNG_GENERATOR_CHOICE` choices that depend on
`TEST_RANDOM_GENERATOR` (i.e. only `TIMER_RANDOM_GENERATOR` as of now).

This commit updates the `TEST_RANDOM_GENERATOR` Kconfig symbol
description to reflect and clarify that.

It also removes the `TEST_RANDOM_GENERATOR`'s dependency on
`ENTROPY_HAS_DRIVER` because the act of _allowing_ a non-random number
generator to be used does not depend on the availability of an entropy
driver -- when an entropy driver is available, by default, the
`ENTROPY_DEVICE_RANDOM_GENERATOR` will be selected; otherwise,
`TIMER_RANDOM_GENERATOR`, a non-random generator, will be selected.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-12-15 22:35:31 +01:00
Reto Schneider
c646a5576a net: zperf: Fix SO_RCVTIMEO dependency
Since 6c30c9ac47 (samples: net: zperf:
Rewrite upload part to use sockets), zperf uses SO_RCVTIMEO in UDP mode,
hence must depend on/enable support for it.

Without SO_RCVTIMEO support, zperf fails like this:
> nb_packets=47   delay=188964    adjust=-13
> setsockopt error (109)
> setsockopt error (109)
> -
> Upload completed!
> LAST PACKET NOT RECEIVED!!!
> Statistics:             server  (client)
> Duration:               0 us    (10.19 s)
> Num packets:            0       (50)
> Num packets out order:  0
> Num packets lost:       0
> Jitter:                 0 us
> Rate:                   0 Kbps  (9 Kbps)

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-12-15 17:14:26 +01:00
Mariusz Skamra
5fc2079963 Bluetooth: audio: ascs: Handle CIS failed to be established error
In case CIS failed to be established, leave the ASE in enabling state
waiting for peer to retry.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-12-15 14:31:11 +00:00
Tomasz Moń
21975231e2 usb: device: cdc_acm: Prevent recursive logging loop
Allow enabling CDC ACM logging only if CDC ACM is not used as logging
backend. This prevents endless recursive logging loop, especially
visible when minimal footprint logging is enabled.

Fixes: #52981

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-12-15 14:54:24 +01:00
Jonathan Rico
ca51439cd1 Bluetooth: host: copy fragment data at the last minute
Only copy the data from the 'parent' buf into the segment buf if we
successfully acquired the HCI semaphore (ie there are available controller
buffers).

This way we avoid pulling and pushing back the data in the case where there
aren't any controller buffers available.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-15 09:58:07 +00:00
Jonathan Rico
ef19c64f1b Bluetooth: host: poll on CTLR buffers instead of host TX queue
When there are no buffers, it doesn't make sense to repeatedly try to send
the host TX queue.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-15 09:58:07 +00:00
Jonathan Rico
c3e5fabbf1 Bluetooth: host: make HCI fragmentation async
Make the ACL fragmentation asynchronous, freeing the TX thread for sending
commands when the ACL buffers are full.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-12-15 09:58:07 +00:00
Emil Gydesen
cbd1e67574 Bluetooth: Audio: Remove newlines from HAS log statements
Removes two log statements in HAS that added a newline,
which it shouldn't.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 10:45:37 +01:00
Emil Gydesen
7630161376 Bluetooth: Audio: Shell: Improve printing of incoming audio
Instead of printing every audio packet (typically
arriving every 7.5 or 10ms), we now only print every 100th.

Ideally we would add support for changing the number of
"skippe" audio packets at runtime in a shell command, but
that will be postponed.

Ideally we would also have a rx_cnt per stream, but that will
also be postponed to the future, and should be fixed with e.g.
the sequence number (seq_num) as well.

Finally this commit also adds a verification if the currently
incoming data packet contains the same ts or seq_num of the
previous one, and print if it does, as this indicates that
we are receiving some invalid data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 10:44:56 +01:00
Emil Gydesen
b2a8fa1392 Bluetooth: Audio: Shell: Fix issue with restarting start_sine
The lc3_start_time and lc3_sdu_cnt were not reset properly,
causing it to fail when trying to do start_sine after calling
stop_sine.

This commit also ensures that the sending of the sine wave is
stopped once the stream is either released or stopped.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 10:44:11 +01:00
Emil Gydesen
366ddedeb6 Bluetooth: Host: Fix issue with setting 0/NULL data for PA
bt_le_per_adv_set_data would not accept the ad to be NULL or
the ad_len to be 0, making it impossible to set no data (which
effectively clears existing data).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 09:40:16 +01:00
Emil Gydesen
336d706f52 Bluetooth: Host: Add length values to malformed adv data warning
Add the advertised length, and the actual length, in the log statement
so it is more clear what the issue is.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-15 09:39:55 +01:00
Fredrik Danebjer
c5b270e7b0 Bluetooth: GATT: Fix missing endianess conversion on include end-handle
Added missing conversion to CPU endianess for the include service
end-handle.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-12-14 17:26:03 +01:00
Wojciech Slenska
4b2fffc7f9 shell: added SHELL_AUTOSTART configuration option
In some applications, there is a need to don't start the shell by
default, but run it later on some special condition.
When SHELL_AUTOSTART is set to n, the shell is not started after
boot but can be enabled later from the application code.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-12-14 15:17:02 +01:00
Ian Oliver
1675d49b4c log_core: Add Kconfig symbol for init priority
Users may want to do some configuration after the kernel is up, but
before initializing the log_core. Making the log_core's init priority
configurable makes that possible.

Signed-off-by: Ian Oliver <io@amperecomputing.com>
2022-12-14 15:16:54 +01:00
Marcin Niestroj
2d3365200c settings: file: drop CONFIG_SETTINGS_FILE_DIR
There is already CONFIG_SETTINGS_FILE_PATH, which is set to full file path,
while CONFIG_SETTINGS_FILE_DIR is required to be set to its parent
directory. This is redundant, as parent directory path can be easily found
out either during runtime or optionally during buildtime by CMake.

CONFIG_SETTINGS_FILE_DIR was actually introduced recently after Zephyr 3.2
release as a replacement of deprecated CONFIG_SETTINGS_FS_DIR. This means,
that there is no need to deprecate it for 3.3 release and dropping it
should be fine. Adjust 3.3 release notes accordingly, so that
CONFIG_SETTINGS_FILE_PATH will be used directly.

This patch stops using deprecated CONFIG_SETTINGS_FS_DIR. There is actually
no value in respecting it, as setting anything other than parent directory
of CONFIG_SETTINGS_FS_FILE makes no sense.

There is actually one use of CONFIG_SETTINGS_FILE_DIR in file backend
tests, to derive directory for files containing tested settings.
CONFIG_SETTINGS_FILE_PATH is not used there, so it makes little sense to
derive directory name from it. Instead, just use hardcoded "/settings"
subdirectory, as this was the default value of CONFIG_SETTINGS_FILE_DIR.

Deriving parent directory can be done either in runtime or in
buildtime (e.g. using some helper CMake function). Doing it in runtime
however allows to create directory recursively (which this patch actually
implements), e.g. for some more nested FS tree structure. Additionally it
will simplify migration of settings configuration from Kconfig to
device-tree (yet to be developed feature).

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-14 14:11:03 +01:00
Marcin Niestroj
f386967b06 settings: do not panic on backend initialization errors
There is little reason to panic on settings backend initialization error.
Such behavior was introduced with initial settings subsystem support, which
was adapted from MyNewt. This is not the usual way how Zephyr handles
errors, so it is time to change that.

There is already handling of some errors by simply returning / propagating
them to caller. Rework all the paths that resulted in k_panic() to also
return error codes.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-14 14:10:55 +01:00
Tomasz Moń
fed6bde788 usb: device: cdc_acm: send more than 1 byte in poll out
Schedule CDC ACM tx work to happen 1 ms after first unprocessed data
write. This gives enough leeway for the task writing to the queue to
write more than 1 byte before USB workqueue preempts and schedules IN
transfer. Sending more than 1 byte at a time increases data throughput
because transaction overhead remains the same regardless of packet size.

Prior to this change, virtually every IN transaction carried only one
character when CDC ACM was used as a console.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-12-14 12:07:33 +01:00
Marco Argiolas
f8f3629efd net: lib: lwm2m: add uCIFI LPWAN object
Add support for Low Power Wide Area Network (LPWAN) Object (ID 3412)

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2022-12-14 09:51:38 +01:00
Dominik Ermel
72db5c09c0 samples/smp_svr: Switch to ZCBOR_MAP_DECODE_KEY_DECODER
Swithc zcbor_map_decode_bulk to use ZCBOR_MAP_DECODE_KEY_DECODER
macros.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-13 11:42:02 +01:00
Dominik Ermel
550b6d518d mgmt/mcumgr: zcbor_bulk: Allow spaces in map keys
The CBOR encoding allows strings to have white spaces, and as string
may be used as key it should also be allowed to use space in key.
The commit provides ZCBOR_MAP_DECODE_KEY_DECODER macro, which is
intended to replace ZCBOR_MAP_DECODE_KEY_VAL macro, that allows
to use string keys with spaces in it.
Both macros are available for now.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-13 11:42:02 +01:00
Carlo Caione
e1e06d05fa ipc: static_vrings: Zero config struct
Initialize the config struct to zero before passing down to OpenAMP.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-13 09:44:44 +01:00
Vinayak Kariappa Chettimada
5fab7a5173 Bluetooth: Controller: Fix MIC failure transmitting LL_CIS_REQ PDU
Fix MIC failure transmitting LL_CIS_REQ PDU.
The MAXPACKETSIZE value was not set with using Long Control
PDUs.

Relates to commit e895948047 ("Bluetooth: Controller: Add
Long Control PDU support").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:44:40 +01:00
Vinayak Kariappa Chettimada
88d94a5b8b Bluetooth: Controller: Remove duplicate code in nRF5 radio HAL
Remove duplicate PPI/DPPI configuration in
radio_tmr_start_now() which reuses radio_tmr_start_us().

And other minor refactor to remove unnecessary conditional
compilation of a define.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:44:22 +01:00
Vinayak Kariappa Chettimada
dfb5988da2 Bluetooth: Controller: Fix dynamic tx power for Broadcast ISO
Fix compilation error for ISO Broadcaster with dynamix Tx
power support, and remove setting tx power for ISO
Synchronized Receiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:44:06 +01:00
Vinayak Kariappa Chettimada
0dfa37b7e1 Bluetooth: Controller: Add internal comments in BIS LLL code
Add internal comments explaining the control flow in the
BIS synchronization in LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
b5d089fb48 Bluetooth: Controller: Receive starting at selected BIS and skip others
Updated implementation to save power consumption by
scheduling BIG event starting at the first BIS selected for
synchronization. Also, skip reception of any unselected
BISes in between multiple BISes that the Broadcaster is
transmitting. Added advance calculation of next subevent
channel index.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
9a51ece3fd Bluetooth: Controller: Fix BIS subevent channel indices
From Bluetooth Core Specification v5.3 Vol 6 Part B Section
4.4.6.8 Channel indices,

The subevent number se_n shall be set to the values 1 to
NSE, in order, for the subevents on a given BIS - the same
values shall be used for all the BISes in a BIG - and to 1
for the control subevent.

Hence, fix implementation to reset back to se_n to 1 when
next BIS PDUs are transmitted in the subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
9660f52dc7 Bluetooth: Controller: Fix Broadcast ISO PDU receive connection handle
Fix broadcast ISO PDU receive connection handle. The look up
was using BIS index instead of the index of the selected
stream that is being received.

Example, when receiving BISes 2 and 4, only the connection
handle for BIS 2 was correct and connection handle lookup
was out-of-bounds for BIS 4; symptoms being that Host
dropped the received ISO PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
46ead9915d Bluetooth: Controller: One extra ISO rx buffer for empty PDU reception
Budget for one extra ISO Rx PDU buffer for empty/NULL PDU
reception that has to always remain free in order to be able
to setup radio h/w for new PDU receptions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Vinayak Kariappa Chettimada
554ea0bae3 Bluetooth: Controller: Fix missing cssn and cstf flag initialization
Fix missing cssn and cstf flag initialization in ISO
Broadcast LLL implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-12 18:43:47 +01:00
Witold Lukasik
c7acd98bf4 usb: device: update logging module registration
Update logging module registration and remove LOG_LEVEL macro
for USB device classes.

Signed-off-by: Witold Lukasik <witold.lukasik@nordicsemi.no>
2022-12-12 15:57:35 +01:00
Jani Hirsimäki
5a93a25158 net: l2: ethernet: ethernet support for AF_PACKET/SOCK_RAW/IPPROTO_RAW
Setting the protocol type for raw IP packets to be sent so that they
can be passed to Ethernet.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2022-12-12 14:56:07 +01:00
Mariusz Skamra
a68f78526d Bluetooth: audio: tbs_client: Fix misleading error log
This fixes error log that has been shown if number of calls in the list
was equal to CONFIG_BT_TBS_CLIENT_MAX_CALLS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-12-12 14:55:41 +01:00
Hang Fan
ebcfa196fc Bluetooth: audio: fix invalid ase state transition
When Receiver Stop Ready operation has completed, the Unicast Server
may request to terminate a CIS and set source ASE state to Qos
configured state immediately. But after CIS disconnected completed,
it will transition source ASE state from Qos Configured to Disabling
state. It's invalid and will cause assert.

we should add Streaming and Enabling state check when CIS disconnected.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-12-12 14:55:32 +01:00
Vinayak Kariappa Chettimada
a1b4896efe Bluetooth: Controller: Fix BT_LL_SW_LLCP_LEGACY compile error
Fix compile error building application with
BT_LL_SW_LLCP_LEGACY. Request Peer SCA command is not
supported in legacy control procedure implementation.

Relates to commit 76439d0ba4 ("Bluetooth: controller:
integrating SCA procedure and adding HCI API").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-12-11 18:29:02 +01:00
Erik Brockhoff
7c9d792211 Bluetooth: controller: refactor to remove duplicated functionality
Duplicated functionality used for tx handling is moved to local proxy
functions to avoid code overhead

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
edef6f3b46 Bluetooth: controller: refactor conn update notify function
Reusing code between local/remote procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
2fcbdaf3ba Bluetooth: controller: refactor pdu encode/decode functions
Introducing common pdu struct declarations for conn param req/rsp and
data length req/rsp to utilize identicality for optimal pdu handling

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
f5f0714c81 Bluetooth: controller: refactor to remove duplicated state function
Removing code for duplicate state handling in local  procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
7f0a801cdc Bluetooth: controller: refactor enc setup lll function
Reusing code between local/remote procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
1f97652998 Bluetooth: controller: refactor ull_rx_put/sched
Instead of calling both ull_rx_put and ull_rx_sched, combine into one
function

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Erik Brockhoff
ddeb0e9f6e Bluetooth: controller: refactor ll_rx_put/sched
Instead of calling both ll_rx_put and ll_rx_sched, combine into one
function

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-09 12:44:39 +01:00
Morten Priess
ee2a43b5dc Bluetooth: controller: Reject CIS_TERMINATE when unsupported for role
If a central or peripheral is not configured for ISO connected streams,
reject a remote LL_CIS_TERMINATE_IND procedure, responding with an
unsupported feature error (BT_HCI_ERR_UNSUPP_FEATURE).

This fixes EBQ test /LL/PAC/CEN/BV-01-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
a803588d2c Bluetooth: controller: Add handle to ll_data_path_sink_create
For making handle available in vendor sink creation, add ISO handle
to function prototype.
Expose datapath allocation via new ull_iso_datapath_alloc function.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
f1c9a02dd6 Bluetooth: controller: Minor ISO refactoring due to compiler issue
Function ll_setup_iso_path has a construction which causes proprietary
compiler to generate incorrect code. As a workaround, local data path
pointer variables are eliminated.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
a93a860231 Bluetooth: controller: Fix ISO Test Mode SDU counting for framed
For framed case, the internal RX SDU counter would increment regardless
of whether the first valid SDU was received or not. According to spec,
SDU counter synchronization is done from first valid SDU.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
fae2beba9d Bluetooth: controller: Don't consider CIS connected before established
Make sure ll_iso_stream_connected_get returns NULL until CIS is
established. Always return DISALLOWED when trying to disconnect a CIS
which is not connected.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
44030a9da7 Bluetooth: controller: Fix CIS restart state de-initialization
When a CIS is terminated, the associated link pool must be de-
initialized to be ready for next creation of the corresponding
instance in memory.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
6e2dea3e41 Bluetooth: controller: Reject CIS_REQ with invalid PHY
Send LL_REJECT_EXT_IND if a LL_CIS_REQ was recevied with invalid PHY
specification.

Fixes EBQ tests:
  /LL/CIS/PER/BI-02-C
  /LL/CIS/PER/BI-03-C
  /LL/CIS/PER/BI-05-C
  /LL/CIS/PER/BI-06-C

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
a9f855e2bf Bluetooth: controller: Fix error in ISO reset sequence
To avoid races, ull_conn_iso_reset must be performed before higher level
ull_iso_reset.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Morten Priess
613283548c Bluetooth: controller: Fix LL_CIS_TERMINATE RX node leak
Reusing NODE_RX_TYPE_TERMINATE for CIS requires special deallocation
handling to prevent memory leak.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-09 11:18:49 +01:00
Yanqin Wei
00cdb7afa2 net: zperf: fix incorrect statistics of zperf
The sequence id from iperf starts with 1. The commit changes the
initial value of "next_id" in zperf from 0 to 1. In addition, the
error output of "error" and "out of order" packets is corrected.

Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
2022-12-09 11:18:25 +01:00
Pavel Vasilyev
163c2bc316 Bluetooth: Mesh: Warn log mode incompatibility with friendship
Log modes other than the deferred may cause unintended delays during
processing of log messages. This in turns will affect scheduling of the
receive delay and receive window for both, Friend and LPN.

Adding a compilation warning instead of assert as a user may still want
to compile a code with friendship feature enabled without actually
establishing a friendship.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-09 11:18:18 +01:00
Pavel Vasilyev
37ab40f2f7 Bluetooth: Mesh: Calculate adv duration instead of using estimation
The duration value passed to `struct bt_mesh_adv_cb::start` is an
estimation.

When running mesh with BT_MESH_ADV_EXT option, the actual duration will
be shorter and the `struct bt_mesh_adv_cb::end` is called right after
the contorller finished advertising. Using the calculated duration the
lpn node can be configured for a shorter receive delay and receive
window and eventually use less power.

When running mesh with BT_MESH_ADV_LEGACY option, the time when adv will
be sent out by controller is unpredictable. But the time between start
and end `struct bt_mesh_adv_cb` callbacks is always 50ms for a single
advertisement. Therefore, the receive delay can't be less than 50ms.

With this change, adv duration is calculated between start and end
callbacks, but timers are started after end callback is called. Therefore
we need to consider time between two callbacks when setting timeouts for
timers.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-09 11:18:18 +01:00
Pavel Vasilyev
5b4b5c0d34 Bluetooth: Mesh: Call friendship callbacks at the end
If a user does some heavy operations in friendship callbacks
unintentionally, this may break friendship communication as timers will
be scheduled or messages will be queued only after code execution comes
back from these callbacks. To avoid this issue, call callbacks only after
required operations are done.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-09 11:18:18 +01:00
Jamie McCrae
5d8c79f064 mgmt: mcumgr: transport: dummy: Fix issue with large packets
Fixes an issue with large packets being received, these packets are
chunked into 127-byte frames for the serial transport but this system
is not needed for the dummy transport as it has a fixed size buffer.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-07 13:53:02 +00:00
Jamie McCrae
656a910b1e mgmt: mcumgr: lib: cmd: os: Add device information handler
The device information handler can be used to retrieve information about
the configuration of the configured device such as board name, board
revision, firmware version and build date.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-07 13:53:02 +00:00
Armin Brauns
dfc97f3f38 fs: fat: document path transformation
The FAT driver converts zephyr paths like /SD:/foo into ELM-FATFS paths
like SD:/foo. Document this behaviour by extracting it into a separate
function (and adding a sanity check).

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2022-12-07 10:31:01 +00:00
Erik Brockhoff
68ef1306fb Bluetooth: controller: proper handling of invalid pdu in CIS create
Do not assert on invalid PDU in CIS create procedure. Instead terminate
with reason BT_HCI_ERR_LMP_PDU_NOT_ALLOWED

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-07 10:30:11 +00:00
Yuval Peress
0f174e5758 zdsp: Fix missing kconfig and no source library
Adds a missing menuconfig for the DSP library as well as fix an issue
with the zephyr library being a STATIC library and having no sources
in the case of the cmsis backend.

Signed-off-by: Yuval Peress <peress@google.com>
2022-12-07 10:24:24 +00:00
Nirosharn Amarasinghe
8510ecf6e3 Bluetooth: controller: corrected time stamps for unframed RX
Corrected an omission in the ISO-AL that required an SDU interval to
be added to the reconstructed RX time stamps for each SDU after the
first.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-12-07 10:15:17 +00:00
Al Semjonovs
da23050812 ztest: Add config to control test summary
Test summary can add a lot of noise to the logs when debugging
a specific test using `-test` argument.
Add control to turn this off.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-12-06 07:35:23 -05:00
Pavel Vasilyev
5d059117fd bluetooth: mesh: Remove illegal use of NET_BUF_FRAG in friend.c
This commit removes illegal use of NET_BUF_FRAG in friend.c, which is an
internal flag.

Now `struct bt_mesh_friend_seg` keeps pointer to a first received
segment of a segmented message. The rest segments are added as fragments
using net_buf API. Friend Queue keeps only head of the fragments.
When one segment (currently head of fragments) is removed from Friend
Queue, the next segment is added to the queue. Head has always 2
references: one when allocated, another one when added as fragments
head.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-12-06 11:06:43 +02:00
Carles Cufi
3d306c181f net: buf: Simplify fragment handling
This patch reworks how fragments are handled in the net_buf
infrastructure.

In particular, it removes the union around the node and frags members in
the main net_buf structure. This is done so that both can be used at the
same time, at a cost of 4 bytes per net_buf instance.
This implies that the layout of net_buf instances changes whenever being
inserted into a queue (fifo or lifo) or a linked list (slist).

Until now, this is what happened when enqueueing a net_buf with frags in
a queue or linked list:

1.1 Before enqueueing:

 +--------+      +--------+      +--------+
 |#1  node|\     |#2  node|\     |#3  node|\
 |        | \    |        | \    |        | \
 | frags  |------| frags  |------| frags  |------NULL
 +--------+      +--------+      +--------+

net_buf #1 has 2 fragments, net_bufs #2 and #3. Both the node and frags
pointers (they are the same, since they are unioned) point to the next
fragment.

1.2 After enqueueing:

 +--------+      +--------+      +--------+      +--------+      +--------+
 |q/slist |------|#1  node|------|#2  node|------|#3  node|------|q/slist |
 |node    |      | *flag  | /    | *flag  | /    |        | /    |node    |
 |        |      | frags  |/     | frags  |/     | frags  |/     |        |
 +--------+      +--------+      +--------+      +--------+      +--------+

When enqueing a net_buf (in this case #1) that contains fragments, the
current net_buf implementation actually enqueues all the fragments (in
this case #2 and #3) as actual queue/slist items, since node and frags
are one and the same in memory. This makes the enqueuing operation
expensive and it makes it impossible to atomically dequeue. The `*flag`
notation here means that the `flags` member has been set to
`NET_BUF_FRAGS` in order to be able to reconstruct the frags pointers
when dequeuing.

After this patch, the layout changes considerably:

2.1 Before enqueueing:

 +--------+       +--------+       +--------+
 |#1  node|--NULL |#2  node|--NULL |#3  node|--NULL
 |        |       |        |       |        |
 | frags  |-------| frags  |-------| frags  |------NULL
 +--------+       +--------+       +--------+

This is very similar to 1.1, except that now node and frags are
different pointers, so node is just set to NULL.

2.2 After enqueueing:

 +--------+       +--------+       +--------+
 |q/slist |-------|#1  node|-------|q/slist |
 |node    |       |        |       |node    |
 |        |       | frags  |       |        |
 +--------+       +--------+       +--------+
                      |            +--------+       +--------+
                      |            |#2  node|--NULL |#3  node|--NULL
                      |            |        |       |        |
                      +------------| frags  |-------| frags  |------NULL
                                   +--------+       +--------+

When enqueuing net_buf #1, now we only enqueue that very item, instead
of enqueing the frags as well, since now node and frags are separate
pointers. This simplifies the operation and makes it atomic.

Resolves #52718.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-12-06 11:06:43 +02:00
Dominik Ermel
5f4664dabe fs/fat: Improve help of Kconfig options for FAT
The commit fixes usage of old identifiers, from ELM FAT module,
and adds additional information on how certain options affect
FAT operation in Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 17:55:58 +01:00
Dominik Ermel
6ae861f559 mgmt/mcumgr: Remove APP_LINK_WITH_MCUMGR Kconfig option
This option is not actually doing anything.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 17:22:51 +01:00
Morten Priess
51ba6e9dd3 Bluetooth: controller: CIS Central fixes
- New calculation of Max_PDU for framed case according to BT Core 5.4
- Fix CIS_Offset calculation for multiple CIS usecase
- Fix resume ticker setup for central

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-05 15:48:39 +01:00
Franciszek Zdobylak
2259e98d95 fs: Implement mkfs operation in FAT fs
Provide an implementation of fs_mkfs operation in FAT fs.

Signed-off-by: Franciszek Zdobylak <fzdobylak@internships.antmicro.com>
2022-12-05 15:36:00 +01:00
Franciszek Zdobylak
78f8937470 fs: Implement mkfs operation in littleFS
Provide an implementation of fs_mkfs operation in littleFS.

Signed-off-by: Franciszek Zdobylak <fzdobylak@internships.antmicro.com>
2022-12-05 15:36:00 +01:00
Franciszek Zdobylak
7a96ed2771 fs: Add fs_mkfs operation to fs api
Adds fs_mkfs function to fs api. It will allow to perform mkfs operation
in file systems added to Zephyr.

Signed-off-by: Franciszek Zdobylak <fzdobylak@internships.antmicro.com>
2022-12-05 15:36:00 +01:00
Wojciech Slenska
29400b18a6 shell: shell_log_backend: added check for msg allocation
When the message buffer cannot be allocated, dropped package
counter should be incremented.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-12-05 15:35:03 +01:00
Hubert Miś
14a03e90d5 ipc: ipc_service: kconfig cleanup
Separate ipc_service libraries Kconfig entries from ipc_service backend
entries. IPC_SERVICE_BACKEND_ICMSG_BOND_NOTIFY_REPEAT_TO_MS is renamed
to drop BACKEND part, because this entry applies to a library, not to
one backend. Icmsg related entries are grouped now in a menuconfig for
cleaner presentation in configuration editors.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-12-05 15:26:31 +01:00
Dominik Ermel
9a48fdf62f mgmt/mcumgr: Remove redundant config headers
The shell_mgmt_config.h and stat_mgmt_config.h as they have been only
providing alternative identifiers for Kconfig options.
Now the Kconfig options are directly used in code and the headers
have been removed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 15:22:27 +01:00
Krzysztof Chruscinski
1f63a07c5f shell: Fix log message queue size for all backends
188d2dfcca introduced a change where log message queue again
become configurable through Kconfig instead of being fixed in
the code. However, it updated only the configuration of an UART
backend. This commit updates other backends as well. Including
dummy backend which has fixed in the code value.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-05 15:20:01 +01:00
Dominik Ermel
043cea12e5 fs/fatfs: Add CONFIG_FS_FATFS_MIN_SS
The Kconfig option allows to set minimum expected sector size
to be supported by FAT fs driver.
When this value differs from CONFIG_FS_FATFS_MAX_SS the driver
will query device for actual sector size, expecting different
sector sizes for different device. When CONFIG_FS_FATFS_MIN_SS
and CONFIG_FS_FATFS_MAX_SS are the same, then there is slight
reduction if FAT driver size, as the query logic is removed
and CONFIG_FS_FATFS_MAX_SS is used for all devices.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-05 15:18:05 +01:00
Marcin Niestroj
976520c77e settings: file: do not create file when loading
File backend can be read-only with the use of `settings_file_src()` API. It
makes no sense to create file when `settings_load()` is called and
registered file backend won't be used for saving files (because
`settings_file_dst()` was not used).

Do not create file during `settings_load()` if it does not exist yet. This
just requires to remove FS_O_CREATE flag in `fs_open()` invocation.

Open file with read-only access, which is now possible after removal of
`FS_O_CREATE` flag.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 14:59:59 +01:00
Chris Friedt
510dca57da shell: devmem: add devmem dump subcommand
This allows the caller to dump a region of memory rather than
dumping one byte (word, etc) at a time. Additionally, it
respects alignment requirements so it works for e.g. 32-bit
register accesses.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-05 11:28:22 +01:00
Marcin Niestroj
426896ea3e settings: fcb: remove unnecessary drop of const identifier
`settings_fcb_save_priv()` already takes `const char *value`, so there is
no reason to cast to `char *` before passing.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
36b06f4af8 settings: file: remove unnecessary drop of const identifier
`settings_file_save_priv()` already takes `const char *value`, so there is
no reason to cast to `char *` before passing.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
312bddfe17 settings: line: simplify settings_line_len_calc()
This function was refactored several times due to many features (like
base64 encoding), which got deprecated over time. Simplify it a bit now.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
b1a15f50b2 settings: line: remove unused MAX_ENC_BLOCK_SIZE macro
This macro is not used anymore and is strictly a leftover, which should be
removed as part of commit 55be783c85 ("settings: Remove deprecated
SETTINGS_USE_BASE64 support").

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
c6af1c3320 settings: line: fix typos in comments
Fix some typos in comments.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Marcin Niestroj
fb9807da9a settings: put all options under if SETTINGS
Put all options under one `if SETTINGS` block, so that `depends on
SETTINGS` does not need to be repeated every time.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-12-05 11:00:57 +01:00
Yuval Peress
b38445eaa0 math: Introduce a DSP basicmath subsystem with a cmsis backend
Introduce an API mirroring the CMSIS-DSP's basicmath. If CMSIS_DSP is
enabled, then it will by default be used as a backend. Developers may
opt into a custom backend by setting CONFIG_DSP_BACKEND_CMSIS=n. If
done, the application must provide `zdsp_backend/dsp.h` and optionally
implement the functions in its own .c files.

Signed-off-by: Yuval Peress <peress@google.com>
2022-12-02 20:15:55 +01:00
Jamie McCrae
47518d47a2 logging: minimal: Change imply to select for printk
This changes the minimal logging Kconfig to select printk rather
than imply it, this is because if someone turns printk off,
minimal footprint logging does not work, therefore it needs to be
a requirement.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-02 16:17:35 +01:00
Emil Gydesen
abef3d3001 Bluetooth: Audio: Removed unused cmd_mcc_ots functions
The functions were not used, and MCC doen not use OTS, but
rather OTC.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 16:08:54 +01:00
Emil Gydesen
312b06a130 Bluetooth: Audio: Add missing static for MCC shell commands
Adds the `static` keyword to the MCC shell command functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 16:08:54 +01:00
Emil Gydesen
b12a09baa8 Bluetooth: Audio: Replace generic media "send cmd" with explicit commands
Rather than exposing shell commands that take an opcode and
an optional parameter, the shell commands are now explicit
so that it is easier for a person to use the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 16:08:54 +01:00
Madhurima Paruchuri
fa738b0f74 usb-c: Generate USB-C connector VIF policies XML file
Generates XML file containing VIF policies by reading the device tree
using EDT.pickle generated during build
This script writes a subset of general and sink-pdo VIF policies in
output file
This script gets invoked during build if enabled through kconfig
The generated XML containing USB-C VIF policies could be used by
USB PD/Type-C analysers/testers to understand USB-C properties and
perform tests accordingly

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2022-12-02 08:46:04 -06:00
Johann Fischer
fcd21f10d5 usb: device_next: add experimental CDC ACM implementation
Add experimental CDC ACM implementation for new USB device stack.
It currently implements only UART IRQ API support and is WIP.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Johann Fischer
cb8b9ad38a usb: add new experimental USB device stack
The device supprt brings support for multiple stack instances,
multiple configuration, asynchronous transfer model, ability to
change most of the properties of a device at runtime and
the composition of configuration and classes at runtime.

The stack requires new UDC driver API and is not compatible
with old driver API (usb_dc_). The classes (functions) of old
(current) USB device stack cannot be used with new ones and must
be ported.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Emil Gydesen
04092ac9a5 Bluetooth: Audio: Change shell print for default_stream == NULL checks
Change what is printed to the shell if the default_stream == NULL
check fails.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Emil Gydesen
ea448ed69a Bluetooth: Audio: add check for default_conn for audio qos shell command
Add a missing NULL check for the command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Emil Gydesen
ff7f644aff Bluetooth: Audio: Remove audio connect command
The `audio connect` shell command did not really do
anything anymore, and has thus been removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Emil Gydesen
34715022ef Bluetooth: Audio: Move some unicast shell commands to also support server
Some of the unicast audio shell commands were guarded by
CONFIG_BT_AUDIO_UNICAST_CLIENT and only usable by the client.

This moves some of the commands to a CONFIG_BT_AUDIO_UNICAST
guard instead, so that they are usable for builds with just
the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-12-02 11:32:18 +01:00
Mariusz Skamra
795573c43f Bluetooth: audio: shell: Fix VCP Volume Renderer build
This fixes VCP Volume Renderer linker error that was seen if built
with VOCS and/or AICS support disabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-12-02 11:28:34 +01:00
Chris Friedt
cdc0f30dbb Revert "shell: devmem: add devmem dump subcommand"
This seems to have caused build failures in spite
of CI passing in PR 52653.

This reverts commit 0a02a4a2af.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-02 14:09:37 +09:00
Chris Friedt
0a02a4a2af shell: devmem: add devmem dump subcommand
This allows the caller to dump a region of memory
rather than dumping one byte at a time.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-12-01 15:52:47 -05:00
Carlo Caione
cc427b4bb0 cache: Fix libraries and drivers
Fix the usage to be compliant to the new cache API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-01 13:40:56 -05:00
Christian Taedcke
12f2258305 net: Make user_data size in rx and tx buffers configurable
Introduce the Kconfig symbol `NET_PKT_BUF_USER_DATA_SIZE`. It is used to
set the user data size in the buffers used in the rx and tx network buffer
pools.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-12-01 15:50:35 +01:00
Christian Taedcke
5bd3beff14 Kconfig: net: Remove deprecated NET_BUF_USER_DATA_LEN
This Kconfig setting was deprecated since
commit 8e99db5801 ("Kconfig: net: deprecate `NET_BUF_USER_DATA_LEN`")
and zephyr release 3.0.0.

This commit removes this deprecated and unused setting.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-12-01 15:50:35 +01:00
Morten Priess
1d235189d5 Bluetooth: controller: Remove HCI_Read_Local_Supported_Codecs [v1]
An LE controller shall no longer support HCI_Read_Local_Supported_Codecs
[v1] according to BT Core 5.3.
Command bit and support code removed.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-12-01 15:49:25 +01:00
Erik Brockhoff
218da91211 Bluetooth: controller: Implementing CIS STO & establishment timeout
Adding a bit-mask to the 'extra' data structure allowing passing info
re. active CIS's to the ull_conn_iso_done handling. Per CIS storing
an expiration time counter, monitoring in done handling. Adding
establishment timeout monitor in CIS Create procedure, completing
and ntf'ing accordingly.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-01 10:32:34 +01:00
Erik Brockhoff
3c68fa45d2 Bluetooth: controller: fixing possible race re. termination vs. cis's
If a CIS is in teardown state, the data in structure should not be
trusted, so skip passing data to ISOAL

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-01 10:32:34 +01:00
Erik Brockhoff
0604a4d2f1 Bluetooth: controller: store STO value instead of pre-calculated reload
Instead of storing the calculated reload value (in conn intervals) in
the conn object, now store the timeout value, and perform calculation
when used. This allows using the timeout value across all CIS's without
having to re-calc and store on change of TO

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-12-01 10:32:34 +01:00
Armin Brauns
7e0e9d0d7e logging: allow disabling auto-start of UART backend
This allows putting the UART backend on a serial device that has to be
quiet unless logging is explicitly enabled at runtime.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2022-12-01 09:48:42 +01:00
Kamil Piszczek
916e02563c bluetooth: host: smp: unauth bond overwrite on different identity
Added a new Kconfig option for the Bluetooth Host to allow
unauthenticated pairing attempts made by the peer where an
unauthenticated bond already exists on other local identity.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-12-01 09:48:02 +01:00
Théo Battrel
e4be91b0c4 Bluetooth: Update Bluetooth legacy logging Kconfig
Update the Bluetooth specific Kconfig legacy log template to use the new
log inheriting template.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-30 14:37:58 +01:00
Théo Battrel
ff5b8f003e Logging: Add Kconfig template for log inheriting
Add a new Kconfig template that allow log modules to inherit their log
level from their parent module.
For example, the logs used in the Bluetooth audio like
`BT_AUDIO_STREAM_LOG_LEVEL` can inherit their level from
`BT_AUDIO_LOG_LEVEL`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-30 14:37:58 +01:00
Erik Brockhoff
9f5eb0f1a8 Bluetooth: controller: fixup to peripheral CIS Create check instant
In case a CIS is the first in a CIG, we should start ISO peripheral
early to allow small CIS offsets

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 13:39:44 +01:00
Erik Brockhoff
9b553c3eb2 Bluetooth: controller: fixup to peripheral CIS CREATE procedure
Missing decode of conn_event_count on CIS_IND
Peripheral Suggest update to conn_event_count in case of a delayed
CIS_IND, allowing CIS peripheral more time to setup

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 13:39:44 +01:00
Jonathan Rico
42e490917e Bluetooth: Host: l2cap: disconnect when PDU > MPS
The Bluetooth spec states that a K-frame exceeding the device's MPS
should trigger a disconnection of the channel.

Fixes two PTS tests that verify this behavior:
L2CAP/LE/CFC/BV-27-C
L2CAP/ECFC/BV-34-C

The current behavior is a silent truncation, which is not very nice for
the user, even if the spec would allow it.

Fixes #52228 and #51174.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-11-30 12:50:10 +01:00
Thomas Ebert Hansen
f192fccf3a Bluetooth: controller: Add lock around LLCP data
Add mayfly locking around the access to the local pending procedure list
as it is accessed by both thread and mayfly.

Fixes #45427

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-11-30 12:49:15 +01:00
Erik Brockhoff
83c380bfcd Bluetooth: controller: adding missing NTF wait state to SCA procedure
When generating notification for Sleep clock accuracy, check for
success on rx_node allocation was left out. This is added.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 12:48:52 +01:00
Erik Brockhoff
d99052b316 Bluetooth: controller: set bit to indicate support for Request Peer SCA
Setting bit to indicate that LE Request Peer SCA command is supported

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-30 12:31:26 +01:00
Emil Gydesen
e80c70fd05 Bluetooth: Audio: Fix MCC disconnect issue
When MCC disconnected, it would memset the entire instance.
This causes issues, because the subscription parameters
would also be memset, causing the `notify` callback to
be set to NULL. If this was done as part of a disconnect,
the GATT layer would attempt to call the notify callback
as part of cleaning up the ACL, but if the callback was
set to NULL (from the memset) this caused a fatal error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-29 13:26:57 +01:00
Jamie McCrae
b635b55ef0 logging: Increase dummy shell buffer size to 400 bytes for LOG_PRINTK
If LOG_PRINTK is used then the buffer size needs to be larger to
account for the additional header/footer output from the shell.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-29 10:46:26 +01:00
Jamie McCrae
c5a40e3a9d logging: Enable LOG_PRINTK if PRINTK is enabled
This change will enable the logging system to handle printk() calls by
default if printk support is enabled, which improves output resiliency
when logging, mcumgr and printk calls are used. Will disable keep
LOG_PRINTK disabled for tests which are not using the new API as
moving to LOG_PRINTK causes test data to be output to a different UART
in the old test system.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-29 10:46:26 +01:00
Emil Gydesen
f3b0a8f478 Bluetooth: Audio: Fix broadcast assistant recv state pointer value
When reporting a receive state to the upper layers, the broadcast
assistant should report NULL if there is not a receive state
active. The "activeness" of a receive state is determined by
the length of the characteristic - If it is 0 then there
is no receive state active.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-29 09:50:22 +01:00
Yuval Peress
49ca6f8f7d unittest: add support for coverage
Some missing features for getting coverage data for unit tests:
- Setting the unit_testing board to have coverage support and native
  application.
- Fixing the CONFIG_COVERAGE check

Signed-off-by: Yuval Peress <peress@google.com>
2022-11-28 16:26:02 -05:00
Emil Gydesen
bbc85e0b2c Bluetooth: Audio: Use bt_vcp_vol_ctlr instead of bt_vcp
Use the `bt_vcp_vol_ctlr` opaque type instead of the more
generic `bt_vcp`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
914e96e6fe Bluetooth: Audio: Vol rend use bt_vcp_vol_rend instead of bt_vcp
Use the struct bt_vcp_vol_rend instead of the more generic
`bt_vcp`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
ae11b5879b Bluetooth: Audio: Remove bt_vcp from vol rend API
Remove the struct bt_vcp pointer from the volume
renderer API, as there is only ever a single
Volume Renderer instance on a device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
c82af2885e Bluetooth: Audio: Split vol_ctlr and vol_rend callback structure
Split the `bt_vcp_cb` struct into separate structure for
the volume controller and the volume renderer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
7f69b866f0 Bluetooth: Audio: Specify bt_vcp_vol_rend API
The VCP server, known as the volume renderer, has a
more explicity bt_vcp_vol_rend API naming scheme now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
71bd487cc4 Bluetooth: Audio: Add separate API for VCP vol controller
Add a separate API for the VCP volume controller (client).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
966c9f80e7 Bluetooth: Audio: Remove the bt_vcp_vocs API
Remove the bt_vcp_vocs API as it did the same as the
bt_vocs API, and did not really any functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
bfbb704c8e Bluetooth: Audio: Remove the bt_vcp_aics API
The AICS functionality can be exercised using the
bt_aics API instead. These functions did very little
besides cluttering up the bt_vcp API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
ce2b8f9fe1 Bluetooth: Audio: Rename VCS to VCP
Renames almost all occurences of VCS to VCP, as we want to
use the profile as the namespace for volume control.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen
aaac86dada Bluetooth: Audio: Rename vcs.h to vcp.h as well as the Kconfig file
Rename vcs.h to vcp.h to better detail what the
file contains, as it is more than just VCS. This also
renames the Kconfig file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Théo Battrel
f739f0b87c Bluetooth: Add legacy warning to Kconfig.template.log_config_bt
Add documentation to tell people to not use the file for new stuff.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-28 17:14:56 +01:00
Martin Jäger
22c8a67d4a lorawan: enforce larger system work queue stack size via Kconfig
The LoRaWAN subsystem uses the system work queue internally and needs
more than the default stack size of 1024 bytes. This is considered
in the sample application, but may be forgotten by out of tree users.

Enforcing it via Kconfig prevents users from accidentally getting
hard-to-debug stack overflows.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-11-28 10:49:18 +01:00
Manuel Arguelles
d17caaacc5 net: icmpv6: fix if need calc tx checksum
Fix regression from 0a3bf289b6.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-11-28 10:47:20 +01:00
Anders Storrø
52a39c0180 Bluetooth: Mesh: Only settings load post mesh init
Prevent mesh stored settings from triggering unless bt_mesh_init
has been called.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-11-25 20:02:53 +01:00
Tomasz Moń
f8ac6b6d66 usb: device: Disable all endpoints on stack disable
Disable all enabled endpoints on stack disable to allow re-enabling USB
device stack.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-11-25 20:02:42 +01:00
Théo Battrel
e458f5aae6 Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log
The `bluetooth/common/log.h` and `bluetooth/common/log.c` files have been
removed. Files that were using them have been updated to use
`zephyr/logging/log.h` instead.

Those replacement have been done consequently:
- `/BT_DBG/LOG_DBG/`
- `/BT_ERR/LOG_ERR/`
- `/BT_WARN/LOG_WRN/`
- `/BT_INFO/LOG_INF/`
- `/BT_HEXDUMP_DBG/LOG_HEXDUMP_DBG/`
- `/BT_DBG_OBJ_ID/LOG_DBG_OBJ_ID/`

Also, some files were relying on the `common/log.h` include to include
`zephyr/bluetooth/hci.h`, in those cases the include of `hci.h` has
been added.

For files that were including `common/log.h` but not using any logs,
the include has been removed and not replaced.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-25 17:08:36 +01:00
Pavel Vasilyev
c32ee7199f Bluetooth: Mesh: Filter out unknown conns and disconns in pb-gatt srv
Ensure that another established connection with the mesh device don't
mess up pb-gatt server state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-25 10:45:07 +01:00
Pavel Vasilyev
2b0fbd86a1 Bluetooth: Mesh: Limit number of Bluetooth connections used by mesh
When a remote devices establishes a ble connection with the mesh device
with default identity and there are more available connection slots, the
mesh stack will try to restart connectable advertisements (either
pb-gatt or proxy depending on the provisioning state). This makes
difficult for an application to advertise own connectable advertisements
as the mesh stack will not let a chance the app to start advertising.

This change adds a Kconfig option that limits number of connection slots
that the mesh stack can use for own connectable advertisements.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-25 10:45:07 +01:00
Mariusz Skamra
93b2205ff5 Bluetooth: tests: shell: Fix build error
This fixes build error that happens when shell is built without CAP
Acceptor Set Member support. The cap_acceptor.c contains shell commands
for Set Member only, thus it's OK to build the code if
CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER is set for now. This can be modified
in the future when shell will be extended with other
Set Member non-specific CAP commands.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-25 10:44:51 +01:00
Emil Gydesen
43e0a63996 Bluetooth: Audio: Fix CSIP compliance check with returns after else
The compliance check did not like the otherwise valid
way of returning from read_set_sirk.

The code has been slightly refactored to avoid the check
failing in CI.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
292db21a18 Bluetooth: Audio: Use svc_inst instead of bt_csip for set_member
Use the service instance struct instead of the more generic
`bt_csip` for the CSIP set member API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
1991fcaced Bluetooth: Audio: Use svc_inst instead of bt_csip for set coordinator
Use the bt_csip_set_coordinator_svc_inst struct in the
set coordinator implementation instead of the more
generic bt_csip.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
5ecaf5af1b Bluetooth: Audio: CSIP set coordinator API not using bt_csip
Modified the CSIP set coordinator slightly to not use the
bt_csip struct at all. For the use a void pointer works
equally well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
87f86cebe2 Bluetooth: Audio: Rename bt_csip to bt_csip_set_member
Renamed remaining structs and functions that are not
for the set coordinator to use the set member CSIP
role name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen
93b3944a51 Bluetooth: Audio: Rename CSIS to CSIP
Renamed the coordinated set implementation to use the
profile (CSIP) name instead of the service (CSIS) name, as
the former is more general.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Andrei Emeltchenko
a5400407fc net: conn: Fix issues with SMP in connection code
When testing on qemu_x86_64 with e1000 Ethernet driver, there are
several crashes due to list management simultaneously executing on
different cores. Add mutexes similar to other parts on networking
stack, for example tcp_lock.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-11-24 15:23:11 +01:00
Mariusz Skamra
8c86595289 Bluetooth: audio: has: Fix HAS features dynamic presets value
If there is no support for presets, Dynamic Presets feature
flag should not be set.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-24 15:23:00 +01:00
Chamira Perera
67db7d07f2 net: ip: Fixed IGMP V2 membership report destination address.
As per RFC 2236 Section 9, the IGMP V2 membership reports should be sent
to the group multicast address being reported. Without this fix, when
IGMP snooping is enabled on a network a device is not able to receive
multicast from certain multicast addresses e.g. 239.255.x.x.

Fixes #52449

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2022-11-24 15:22:38 +01:00
Morten Priess
3915754ac3 Bluetooth: controller: Add support for Read/Write Conn. Accept Timeout
Implement HCI commands HCI_Read_Connection_Accept_Timeout and
HCI_Write_Connection_Accept_Timeout, and enable the feature in
supported commands.
Remove hardcoded use of default accept timeout in new LLCP code, and
use configurable value instead.

This makes EBQ test /HCI/CIN/BV-03-C pass.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-24 11:17:28 +01:00
Emil Gydesen
40e3930ebd Bluetooth: Audio: Broadcast source subgroup and BIS codec support
Updates the broadcast source API to create subgroups and
to set BIS specific codec configuration

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 10:21:36 +01:00
Marcin Niestroj
26ea31fc87 settings: use CONTAINER_OF() to access backend structure
Use CONTAINER_OF() macro to access outer backend-specific structure. This
removes the requirement to keep `struct settings_store` as the first item
in outer structure.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-11-24 10:18:35 +01:00
Ahmed Moheb
b86150ff0c tests: bluetooth: host: Add mocks for crypto.c
Add required mocks to be able to compile/test /bluetooth/host/crypto.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 10:06:05 +01:00
Aleksandr Khromykh
2411cf68ab Bluetooth: Mesh: fix adv counter in LPN
LPN should send Poll\Sub Add\Sub Del only once.
Sending multiple times breaks polling time parameters
(Figure 3.17: Friendship timing parameters).

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-11-24 10:03:04 +01:00
Vinayak Kariappa Chettimada
668505e778 Bluetooth: Controller: Fix periodic sync Skip value vs Sync_Timeout
Adjust skip value so that there is minimum of 6 events that can be
listened to before Sync_Timeout occurs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-24 09:37:00 +01:00
Marcin Niestroj
daee6cb4a9 settings: file: change FS (or file system) wording to File
Currently there is inconsistency in repository file names, APIs, Kconfig
options and documentation around file / file-system backend for settings
storage, as both "file" and "FS (file system)" are used. As an example,
there is `CONFIG_SETTINGS_FS` Kconfig option, but the file that implements
this settings backend is called `settings_file.c`. Another example are
names of static functions that implement settings storage API:
`settings_file_load()`, `settings_file_save()` and
`settings_fs_storage_get()`.

This backend is actually storing all settings in a single file, so it makes
sense to use "File" as the name of backend, instead of a more general
"FS" (which would make sense if several files would be used to store
settings).

Fix inconsistency in used wording in the tree and unify it to "settings
file backend". This naming is more precise to how the implementation looks.
It will also make it easier to grep through the codebase and analyze
existing code.

Deprecate settings_mount_fs_backend() function and all Kconfig options
starting with `CONFIG_SETTINGS_FS`.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-11-24 09:36:31 +01:00
Johann Fischer
b70f92e570 net: buf: keep memory alignment provided by k_heap_alloc and k_malloc
Allocation callback in net_buf_heap_cb and net_buf_var_cb
used for net_bufs with variable size payloads, defined by
NET_BUF_POOL_HEAP_DEFINE or NET_BUF_POOL_VAR_DEFINE,
allocate one more octet for internal variable ref_count,
used in function generic_data_ref(), which in turn is needed
for net_buf_clone()).
The user gets a buffer which is shifted by one octet in memory
block. This breaks alignment provided k_heap_alloc and k_malloc.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-11-24 09:35:13 +01:00
Adrian Warecki
aac03280ec dma: dts: Rename of the dma_buf_alignment to dma-buf-addr-alignment
Renamed the dma-buf-alignment field to a more explicit
and descriptive name dma-buf-addr-alignment.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2022-11-23 15:36:31 -05:00
Emil Gydesen
1b2f57270a Bluetooth: Host: Add addr to bt_le_ext_adv_get_info
Add the local advertising address to bt_le_ext_adv_get_info.

This may help with debugging, but is also needed to
properly support something like the BAP Broadcast Assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-23 16:12:52 +00:00
Anas Nashif
cffe98d9de crc: Make the build of crc function dependent on a Kconfig
Add CONFIG_CRC for building CRC related routines.
CRC routines are now being built for each application, whether used or
not and are add in the build system unconditionally.

Keep CONFIG_CRC enabled by default for now and until all users have
converted to use the new option.

Partial fix for #50654

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-23 13:30:00 +01:00
Milind Paranjpe
cf91f1873b usb: disable previously enabled endpoint before re-enabling
When switching between alternate settings of an interface, it is
currently possible to call set_endpoint() multiple times on an endpoint
without first calling reset_endpoint(). For these situations, it is
beneficial to track endpoints for which set_endpoint() has previously
been called, and then reset them to properly terminate any transfers,
and to return the HAL to the correct state

Signed-off-by: Milind Paranjpe <mparanjpe@yahoo.com>
2022-11-23 12:59:40 +01:00
Jamie McCrae
9831b320f2 mgmt: mcumgr: Fix missed variable rename
Fixes accesses a renamed variable when a specific Kconfig is
active that would cause a compile error.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-23 12:24:59 +01:00
Vinayak Kariappa Chettimada
990d9a3abe Bluetooth: Controller: Fix BIS access address generation
Fix BIS access address generation to follow the requirements
in Bluetooth Core Specification v5.3, Vol 6, PartB, Section
2.1.2 Access Address.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-23 12:18:55 +01:00
Vinayak Kariappa Chettimada
1b023e5419 Bluetooth: Controller: Ensure ext header max size reservation
Ensure maximum size of common extended header format be
reserved when CONFIG_BT_CTLR_ADV_RESERVE_MAX=n is used so
that changes to ACAD, like channel map update does not need
frequent update to periodic advertising auxiliary channel
PDU time reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-23 12:18:55 +01:00
Vinayak Kariappa Chettimada
1164c327d6 Bluetooth: Controller: Revert T_MAFS change done for broadcasting roles
When calculating the offsets between primary advertising
PDU, auxiliary PDU, Periodic Advertising PDU, and BIS PDU,
the values used as anchor points for starting the periodic
interval for auxiliary, periodic and BIG events, should be
ensured to have the minimum auxiliary frame spacing T_MAFS
between the PDUs. EVENT_OVERHEAD_START_US has to be reduced
as this value is used to offset the start of the radio
event on air.

Reverts commit b867f0e8a6 ("Bluetooth: Controller: Fix
T_MAFS between broadcasting roles").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-23 12:18:55 +01:00
Lingao Meng
7668bd3b7c Bluetooth: Mesh: Add macro control whether adv main to relay
Enable advertiser main to support relay messages, this maximizes
theutilization efficiency of advertising sets, which is helpful for the
sending of dense relays, but for Friend and LPN, it delays the sending
of local messages a little, this may cause the time slot deviation between
friend and lpn, and the power consumption of lpn will increase.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-23 11:36:57 +01:00
Lingao Meng
a5ebad1e23 Bluetooth: Mesh: Fix missing check local match for mesh message
For Mesh Message, should only process by model layer when dst
is unicast address of this nodes or model subscrip on.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-23 11:36:57 +01:00
Radoslaw Koppel
0620cb1fe1 ipc: ipc_service: icmsg: Increase reliability of bonding
This commit changes the way bonding between endpoints is processed.
There is no blind attempt to read the buffer without mbox notification.
On second side the notification is repeated multiple times until valid
bonding is detected.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2022-11-23 11:34:04 +01:00
Armin Brauns
1f41c01553 shell: kernel: right-align stack usage percentages
This improves readability by aliging digits with the same significance
vertically.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2022-11-23 11:33:47 +01:00
Andries Kruithof
7678cdaa10 Bluetooth: controller: llcp: increase memory for procedures
The default number of buffers (contexts) for locally initiated
procedures was 4. Per default the host initiates 3 procedures
when opening a connection, allowing the application to initiate
only 1 additional procedure in parallel.
This commit increases the default to 6, if auto phy-update and
dle is enabled, increasing the robustness for an application.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-11-23 11:32:49 +01:00
Johann Fischer
1c4011ff6e usb: remove usb_pid.Kconfig file
Remove Kconfig file samples/subsys/usb/usb_pid.Kconfig added in
the commit e5cbe6a9e7 ("usb: cdc: Add unique PIDs for each sample")
with the motivation to have a separate ID for each sample supposedly
to be recognizable by the host.

The new USB support does not use the options, VID/PID is set
directly in the application. As a note, it is not necessary to have
unique PID for each sample, especially for the well known USB classes.

Replace the individual Kconfig options in the documentation
by a table with the references to the samples and PIDs.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-11-22 11:09:21 +01:00
Emil Gydesen
02226d0352 Bluetooth: Audio: Fix mcc.c conn logging statements
mcc.c does not include `conn_internal.h` so it does not
know the `bt_conn` struct, causing logging issues when
trying to log a `bt_conn` pointer.

Fixed by casting the `conn` pointers to `(void *)`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-22 11:05:33 +01:00
Reto Schneider
b51218a110 net: net_pkt: Fix conditional compilation
This aligns the conditional compilation logic with the one used for the
prototype in net_pkt.h, avoids build errors due to a undefined reference
to net_pkt_print_frags.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-11-22 09:30:26 +00:00
Reto Schneider
a66935aea7 net: net_pkt: Embrace NET_PKT_DEBUG_ENABLED
This deduplicates the logic a tiny bit.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-11-22 09:30:26 +00:00
Reto Schneider
217d9ac113 net: net_pkt: Simplify conditional compilation
The #if has the same conditions as the one closed the previous #endif.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-11-22 09:30:26 +00:00
Wojciech Slenska
188d2dfcca shell: shell_log_backend: take buffer size from config
Use LOG_MESSAGE_QUEUE_SIZE config instead of hardcoded value.
LOG_MESSAGE_QUEUE_SIZE default value has been changed to 512, so
it is now matching to the hardcoded value.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-11-22 13:05:29 +09:00
Tomasz Moń
a9bfe0a423 usb: dfu: Reduce default bwPollTimeout value
The bwPollTimeout name is somewhat confusing as it refers to minimum
polling period. The bwPollTImeout is essentially a mechanism allowing
device to ratelimit DFU_GETSTATUS requests from host.

Setting bwPollTimeout to relatively high values effectively slows down
DFU download process. The slowdown is not observed if the time between
DFU_DNLOAD and DFU_GETSTATUS is enough for the device to process the
write. That is, the bwPollTimeout does not effect DFU download if the
first DFU_GETSTATUS after DFU_DNLOAD reports dfuDNLOAD-IDLE state.
Otherwise the host must wait bwPollTimeout ms before issuing next
DFU_GETSTATUS, which slows the communicaiton to not more than 1 download
block (CONFIG_USB_REQUEST_BUFFER_SIZE) every bwPollTimeout ms.

The bwPollTimeout ideally should report an estimate how much longer the
download operation will take. Zephyr does not have such estimate and
therefore defaults to using fixed value. Reduce default bwPollTimeout
from 256 to 8 ms to allow significantly faster DFU downloads on devices
where the time between DFU_DNLOAD and DFU_GETSTATUS is too short to
process download block at the expense of unnecessary bus traffic if
processing download block takes longer than 8 ms.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-11-22 13:03:11 +09:00
Keith Packard
e478a4e850 subsys/cpp: make libstdc++ select full libc to get tests working
Using a STD C++ library requires a toolchain-provided C library with
associated STD C++ library. Instead of using a dependency on !MINIMAL_LIBC,
select REQUIRES_FULL_LIBC so that the build will select a viable C library
rather than failing.

This allows all of the C++ tests to be run as a part of a standard twister
run. I expect this will uncover regressions in some of those which haven't
been run recently.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-22 12:54:00 +09:00
Jamie McCrae
0922ec7d75 mgmt: mcumgr: Move zephyr basic group defines to standard files
Moves the zephyr group ID defines to the mgmt header file as it is
with other group IDs and moves the zephyr basic group command IDs
to the the same header-location style as other groups.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:42:48 +09:00
Jamie McCrae
4cf008cb45 mgmt: mcumngr: Remove old files missed in restructure
Removes some old files that should have been deleted in the recent
cleanup of MCUmgr.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:42:09 +09:00
Jamie McCrae
cbd0d2d55a mgmt: mcumgr: Add fs_mgmt prefix to hash/checksum functions/files
This aligns the naming of files in fs_mgmt so that files and
functions relating to hash/checksum are prefixed with fs_mgmt.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:41:49 +09:00
Yuval Peress
c585df4996 unittest: add C++ support
Some of the struct in the unit test's cpu.h header were empty which
isn't allowed in C++.

Signed-off-by: Yuval Peress <peress@google.com>
2022-11-21 16:11:14 -05:00
Chun-Chieh Li
59f3316d33 usb: audio: do not discard usb_transfer result in usb_audio_send()
Pass result of usb_transfer() as return value to the user,
and allow user to react accordingly, e.g. release net_buf on error.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2022-11-21 20:11:24 +01:00
Emil Gydesen
0a570a25c9 Bluetooth: Audio: Fix null pointer access in mcc.c
One of the notification callback functions did not properly
get the `read_params` pointer, causing an invalid result of
CONTAINER_OF as it would use a NULL pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-21 20:11:13 +01:00
Joakim Andersson
51d510adc6 Bluetooth: host: Call RPA expired on disabled advertising sets
Call the RPA expired callback on advertising sets even when they are
not enabled.
The RPA expired callback will now be called on advertising sets
when the BT_ADV_RPA_VALID flag is cleared for the set.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
d63ae607cc Bluetooth: host: Fix RPA timeout expiration
Fix RPA timeout expiration when BT_EXT_ADV has been enabled.

Always invalidate the device RPA on RPA timeout.
This RPA is used by the scan roles, and the advertiser that was started
using the bt_le_adv_start API.

Call the RPA expire callback only on advertising sets that are enabled
and not being limited by a timeout and not using the identity address.
On RPA timeout always invalidate the RPA of advertising sets that are
disabled.

Fixes: #51208
Fixes: #51228
Fixes: #51247

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
0a1a32841f Revert "Bluetooth: Host: Fix resolvable address update with Ext Adv enabled"
This reverts commit 6c40427931.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
ff36bd42d0 Bluetooth: shell: Add shell support for RPA expire callback and control
Add shell support for RPA expire callback.
This prints a message when the callback is called on the specific
advertising set.
Add a command to control the return value of this callback for a
specific advertising set.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Joakim Andersson
ba657c9570 Bluetooth: shell: Use a common help text for commands args on and off
Use a common help text for commands args on and off.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-11-21 12:36:50 +01:00
Martin Fletzer
144d30eb47 net: gptp_md: Consider different resolutions regarding correction field
From https://www.ieee802.org/1/files/public/docs2007/as-garner-protocol-state-machines-frame-formats-0307.pdf:
  The correctionField is the value of the correction
  measured in nanoseconds and multiplied by 2^16.

Zephyr uses nanoseconds for follow_up_correction_field.
Therefore, the value must be shifted by 2^16.

Signed-off-by: Martin Fletzer <martin.fletzer@kftec.at>
2022-11-21 10:14:48 +01:00
Aaron Massey
2dd0b48140 test: SBS gauge gets initially supported props
Add a test that validates fetching every property from the sbs gauge driver
results in no driver error codes being returned.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-19 17:56:05 -05:00
Aaron Massey
28b8123887 fuel_gauge: Sample sbs gauge driver with tests
Add a sample sbs gauge driver with feature parity and basic tests
comparison to its sensor counter-part. Includes a simple stub test that is
extended upon.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-19 17:56:05 -05:00
Robert Lubos
387a66131e net: pkt: Introduce minimum length requirement to net_pkt_get_frag()
net_pkt_get_frag() and a few other functions did not specify the
allocated fragment length, incorrectly assuming that fixed-sized
buffers are always used.

In order to make the function work properly also with variable-sized
buffers, extend the function argument list with minimum expected
fragment length parameter. This allows to use net_buf_alloc_len()
allocator in variable buffer length configuration, as well as verify if
the fixed-sized buffer is large enough to satisfy the requirements
otherwise.

Update the existing codebase to provide the expected fragment length,
based on the context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
98608b3c30 net: shell: Fix build with CONFIG_NET_BUF_VARIABLE_DATA_SIZE
The "net mem" command handler did not take the variable buffer length
configuration, and failed to build in such case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
521341813e net: pkt: Fix build with CONFIG_NET_BUF_VARIABLE_DATA_SIZE
In case variable buffer length feature was enabled, net_pkt code did
not build due to unconditional references to CONFIG_NET_BUF_DATA_SIZE,
which is not avaialable in this configuration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
00269af3e6 net: tcp: Fix build with CONFIG_NET_BUF_VARIABLE_DATA_SIZE
In case variable buffer length feature was enabled, the TCP stack did
not build due to unconditional references to CONFIG_NET_BUF_DATA_SIZE,
which is not avaialable in this configuration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Robert Lubos
0e388e64fd net: shell: Process Echo Replies without a timestamp
In case Echo Request did not carry timestamp (i. e. requested payload
size was smaller than 4), there won't be a timestamp in the reply
either. Such replies should not be ignored. Instead, simply skip the
turnround time calculation if timestamp is missing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:34:45 -05:00
Robert Lubos
2b67e421a0 net: shell: Allow to specify ping payload size
Add -s parameter to the net ping command, allowing to specify the
payload size for the Echo Request.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:34:45 -05:00
Robert Lubos
967a91dce5 net: icmp: Allow to autogenerate Echo Request payload
Let net_icmpv4_send_echo_request() and net_icmpv6_send_echo_request()
autogenerate Echo Request payload, in case data length is specified but
no data pointer provided. The autogenerated payload includes timestamp
(if payload size permits) so that the turnround time can be calculated.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:34:45 -05:00
Morten Priess
afd14d6573 Bluetooth: controller: CIS Central fixes from EBQ run
Various fixes for issues found during EBQ run.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
745bf7297e Bluetooth: controller: Implement CIS Central in ULL
- Add CIS Create policy config choices
- Implemented CIS Central in ULL following proposed setup/commit flow
- Full support for HCI_LE_Set_CIG_Parameters_Test
- Extend ull_conn_iso_start and ull_conn_iso_ticker_cb to handle
  central role
- Partial support for HCI_LE_Set_CIG_Parameters. TODOs:
  * Drop suggested retransmissions if Max_Transmission_Latency is
    exceeded
  * Calculate ISO interval based on policy

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
07acdc9650 Bluetooth: controller: HCI fixes for ISO central role CIG/CIS creation
Fix issues with referencing invalid netbuf data and add missing
parameter. Removed returning of handle in setup functions, as handles
are  not available until commit.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
64ade9e01d Bluetooth: controller: Move CIS peripheral functionality to ull_conn_iso
Move ull_peripheral_iso_start ull_peripheral_iso_ticker_cb to
ull_conn_iso, to share code between CIS peripheral and central.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Morten Priess
38a4e58d1f Bluetooth: controller: Implement local CIS Creation procedure
Local procedure for CIS central establishment. Calls yet unimplemented
functions in ull_central. Changes are guarded by
CONFIG_BT_CTLR_CENTRAL_ISO.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-18 12:48:13 +01:00
Michał Barnaś
94458f88b9 ec_host_cmd: add eSPI peripheral for the host commands
This commit adds the support for host commands being transported
by the eSPI subsystem.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś
b91849c4bd ec_host_cmd: add missing fields and improve compatibility
Add missing fields in structure containing the arguments used by
the host commands handlers and change the order of parameters
in macro used for defining the handlers.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś
369596dc95 ec_host_cmd: increase stack size, change thread priority and alignment
This commit increases the stack size for thread handling the host
commands requests. It was required due to the stack being
corrupted using earlier default size. The thread priority is now
configurable using the Kconfig.
It also adds alignment to the tx_buffer since the npcx MCU requires it
to work correctly and removes clearing the buffer before use due to
the hard time requirements. Tests checking if buffers are cleared
are also removed.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś
959d3b87fb ec_host_cmd: move the host_cmd_periph.h to subdirectory
Move the header file to corresponding directory which refers to
submodule name instead of root of drivers directory.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Dominik Ermel
7048383362 doc: Move SMP transport documentation under doc/services
The commit moves MCUmgr SMP transport documentation from
subsys/mgmt/mcumgr/lib to doc/services/device_mgmt.
Documentation have been rewritten for that purpose.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Dominik Ermel
4328f165a8 mgmt/mcumgr: Reworking source code tree and API interface
The commit reworks mgmt/mcumgr subsystem source code to remove
lib subdirectory and make it a little bit more flat.
It also moves all API interface files, which are supposed to be
visible by applications using MCUMgr, to interface sub-directories,
and exposes them with full paths; for example to include general
MCUMgr support, group registration and so on, user would now include:
 <mgmt/mcumgr/mgmt/mgmt.h>
to additionally have control on File System group management
registration user would need:
 <mgmt/mcumgr/mgmt/grp/fs_mgmt.h>

All internal headers have been removed from interface.

CMAkeLists.txt get significant rework and various MCUMgr subsystems
have been divided into separate sub-libraries.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Dominik Ermel
7c2924f4bc mgmt/mcumgr: Move transport headers to transport subdir
The MCUmgr transport headers have been moved to
zephyr/mgmt/mcumgr/transport/

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Vinayak Kariappa Chettimada
a6beef4b26 Bluetooth: Controller: Replace Central connection spacing Kconfig
Replace the BT_CTLR_ADVANCED_SCHEDULING_CENTRAL_CONN_SPACING
Kconfig with BT_CTLR_CENTRAL_SPACING to configure the
the spacing from the beginning of a central connection event
to beginning of the next central connection when supporting
multiple simulataneous central connections.

If the BT_CTLR_CENTRAL_SPACING in microseconds is smaller
then the required time reservation for a connection event,
for given maximum data length and PHY in use, then the
calculated time reservation will be used as the spacing
between consecution central connection events.

The change fixes an issue wherein use of old Kconfig with
higher values causes new central connections to be placed
in between already connected central role if there was
free time space available to fit the new connections time
reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-17 14:44:17 +01:00
Omkar Kulkarni
7e3b509ae1 bluetooth: mesh: check id in connection callbacks
When application uses multiple identities mesh stack keeps reacting
on connection events not related to the own identity (BT_ID_DEFAULT)
causing it to trigger additional advertising and this leads to errors.
Though not harmful, this also leads to mesh stack counting connections
wrongly and consuming internal resources.

This commit fixes the issue described above by checking the
connection id before proceeding further.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2022-11-17 11:17:45 +01:00
Vinayak Kariappa Chettimada
465a96181d Bluetooth: Controller: Explicitly set all bits of used radio registers
Explicitly set all bits of used radio registers when
configuring radio events, removing the dependency on having
the power-on reset value and removing the need to ensuring
power-on reset values being set in the radio peripheral.

This will ensure the Controller has radio register value
correctly configured irrespective of changes across SoCs'
radio register power-on reset values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-17 10:56:13 +01:00
Vinayak Kariappa Chettimada
316a999d95 Bluetooth: Controller: Fix to allow multiple connectable advertisers
Fix BT_CTLR_MAX_CONNECTABLE define to allow multiple
connectable advertising sets to be enabled simultaneously.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-17 10:56:00 +01:00
Robert Lubos
1d7a077e11 net: ppp: Revert interface management changes
This reverts changes introduced in commit
dd535f611d, as they broke the gsm_ppp
driver integration with PPP L2. Apparently, a more thorough
refactoring is needed to use the new interface management scheme with
PPP.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-16 11:21:24 +01:00
Aleksandr Khromykh
7e63139499 Bluetooth: Mesh: fix memory corruption if oob string is 16 bytes
strcpy copies string including terminating null character.
strlen returns length without terminating null symbol.
If oob string is 16 bytes length then strcpy will corrupt byte
after auth array.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-11-16 11:21:14 +01:00
Aleksandr Khromykh
fcfc47bf93 Bluetooth: Mesh: fix static oob zero padding
The sample in the Provisioning protocol spec chapter
is in big endian. Static OOB value should append
zeroes on the little endian platforms.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-11-16 11:21:14 +01:00
Aaron Massey
bce9c6e2da emul_sbs_gauge: Rename reg_read/write more unique
Rename the reg_read and reg_write functions in the emul_sbs_gauge emulator
to be more unique symbols so as to support overriding this specific
function in future tests that make use of FFF. See #46817 which includes a
test for error reads as an example.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-16 11:19:21 +01:00
Aaron Massey
1d8750ddd6 emul_sbs_gauge: Don't set bad val in i2c msg buf
The SBS Gauge emulator would set the I2C buffer message with a value from
the emulator's custom read function even on a read error instead of just
returning. This behavior may be improperly relied upon by future tests.

Return early on register read before setting the i2c message buffer value
in the emulator.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-16 11:19:21 +01:00
Aaron Massey
1cff6099f7 emul: emul_sbs_gauge read/write returns ret code
To facilitate testing improper reads and writes on various registers,
enable the emul_sbs_gauge reg_read/write handlers to return custom exit
codes.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-16 11:19:21 +01:00
Emil Gydesen
ecb7591d6b Bluetooth: Audio: Rename BASS and BASS client
Rename BASS to BAP Scan Delegator and BASS Client
to BAP Broadcast Assistant. This is the first step towards
integrating the BASS with the rest of BAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-16 11:17:52 +01:00
Théo Battrel
b56823818d Bluetooth: Rename functions to satisfy CI
In file `subsys/bluetooth/mesh/net.c`:
renamed `loopback` to `net_loopback`.

In file `subsys/bluetooth/host/settings.c`:
Renamed `set` to `set_setting` and `commit` to `commit_settings`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-15 12:20:56 +00:00
Emil Gydesen
1d83e561e6 Bluetooth: Audio: Refactor use of cur_mcs_inst
Removes the global cur_mcs_inst and replace it
with lookup functionality.

This fixes an issue with bt_mcc_discover_mcs not being able
to be called more than once, as well
as streamline the implementation significantly.

This is also the first step towards not only supporting
multipe MCS instances for a single device, but also a
step towards handling multiple devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-15 12:18:50 +00:00
Emil Gydesen
0c04cf3c8e Bluetooth: Audio: Fix issue with NULL instance for MCC notifications
It was possible that on re-connect, the MCC implementation
would receive notifications when cur_mcs_inst was NULL.

This is partially caused by a bug in gatt.c, but can
and should also be handled in MCC.

This commit ensures that we do not compare handles
on notifications with a NULL instance.

This commit also ensures that subscribe_mcs_char_func
is not called outside the context of the discovery
procedure by setting the subscribe callback
to NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-15 12:18:50 +00:00
Emil Gydesen
0b4d33bcbb Bluetooth: Audio: Fix missing path_id for broadcast_sink
Adds support for using the path_id set by the capabilities
for the broadcast sink role.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-15 12:14:14 +00:00
Rodrigo Peixoto
b8ecbfaa57 zbus: Add message bus subsystem to Zephyr
Add zbus message bus as a Zephyr subsystem. No message bus
or communication abstraction other than the usual (message queues,
mailboxes, etc.) enabled developers to implement event-driven systems in
Zephyr quickly. Zbus would fill that gap by providing the community with
a lightweight and flexible message bus. The implementation tries to be
closest as possible to the existing ones. We use the claim/finish
approach, and the API for publishing and reading channels are similar
in message queues. Zbus is about channels, messages, and observers.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2022-11-14 17:25:29 -05:00
Martin Tverdal
09b514a610 Bluetooth: Fix issue with adv_stop
If adv stop was called form connected callback,
it would continue and unref the wrong conn object
if there where 2 connectable advertisers running,
but with only one 1 id configured.

Fixes #52196

Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
2022-11-14 13:07:51 +01:00
Vinayak Kariappa Chettimada
b56a6906e2 Bluetooth: Controller: Fix advertising disable on connection complete
Fix advertising set's is_enabled flag to be reset when
connection complete is dequeued for connectable advertising
started using legacy advertising enable HCI commands. And
reset the is_enabled flag when advertising set terminated
is dequeued for connectable advertising enabled using
Extended Advertising HCI commands.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-14 13:06:38 +01:00
Vinayak Kariappa Chettimada
13c29940bf Bluetooth: Controller: Fix ticker ticks diff calculation
Fix ticks difference calculation to determine delayed
prepare callback. Without the use of masking by
ticker_ticks_diff_get, the diff value can be higher than
the supported 24-bit value. i.e. ticker_ticks_now_get()
rolls over in 24-bit value, whereas ticks_at_event is
free running value of 32-bits.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-14 13:06:21 +01:00
Benjamin Lindqvist
85c6de4335 lorawan: enable run-time config of region/freq
This commit adds support for compiling in support for several different
regions/frequencies and dynamically choosing which to use in run-time.
This commit introduces no API breakages - if a prj.conf contains only a
single region Kconfig, the new function lorawan_set_region() does not
need to be called.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2022-11-14 11:16:16 +00:00
Veijo Pesonen
f467410088 net: lwm2m: shell - allow leading slash
Paths should start from root.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-11-11 08:49:25 +00:00
Vinayak Kariappa Chettimada
e895948047 Bluetooth: Controller: Add Long Control PDU support
Add long control PDU size support, also the implementation
now allocates control PDU size restricted to the supported
biggest control PDU that is enabled in the application
build. Features that are covered based on the increasing
control PDU sizes are ClearText connections, Encrypted
Connections, Connection Parameter Request support and
Create CIS control Procedure (Connected Central ISO)
support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-11 08:46:26 +00:00
Carles Cufi
b90c27238a Bluetooth: crypto: Refactor a few items
After merging #51809, a few things were spotted that needed tweaking.
Among them:

- Rename the folder from bt_crypto to crypto, since the prefix is
  unnecesary
- Remove the include folder
- Remove the path from the global include paths

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-10 17:54:14 +02:00
Dominik Ermel
dac058c058 mgmt/mcumgr: Fix documentation for hash_checksum_mgmt_list_cb
Incorrectly hash_checksum_mgmt_handler_fn has been referenced
in documentation for hash_checksum_mgmt_list_cb, causing
documentation generation error, because parameter list does
not match.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-10 15:48:39 +01:00
Jason Wright
e369a8899f testsuite: coverage: create kconfig option for gcov dump heap size
The heap size for serial dump of gcov data is currently
defined by MALLOC_MAX_HEAP_SIZE, which cannot be
adjusted by kconfig. This commit adds a new kconfig
option, CONFIG_COVERAGE_GCOV_HEAP_SIZE, which retains
the behavior or MALLOC_MAX_HEAP_SIZE by default.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-11-10 08:48:06 -05:00
Dominik Ermel
7ed6775d02 mgmt/mcumgr: Fix MCUMGR_BUF_USER_DATA_SIZE selection for BT
Rounded up struct smp_bt_user_data takes 8 bytes; this fixes
static assert failing with message:
  CONFIG_MCUMGR_BUF_USER_DATA_SIZE not large enough to fit Bluetooth
  user data

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-10 13:30:12 +01:00
Jamie McCrae
dbd2176655 mgmt: mcumgr: fs_mgmt: Update hash/checksum supported command
Updates the hash/checksum supported command to use the new command
structure.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
c2b872b901 mgmt: mcumgr: os_mgmt: Switch to new event callback system
Switches to the new event callback system for the os_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
986ea39512 mgmt: mcumgr: img_mgmt: Switch to new event callback system
Switches to the new event callback system for the img_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
4e8fde15a3 mgmt: mcumgr: fs_mgmt: Switch to new event callback system
Switches to the new event callback system for the fs_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
042ed0539b mgmt: mcumgr: Add access denied error code
Adds an access denied error code that can be used to signal to the
mcumgr client that the requested access to a specific resource or
command/functionality has been denied.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
6f75c99b8b mgmt: mcumgr: Rework event callback system
Reworks the event callback system to use a linked list to allow for
chained handlers and support passing a status back to the handler to
indicate if the request should be rejected or allowed. This also
removes the old base callback functionality.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae
77374b3857 mgmt: mcumgr: fs_mgmt: Allow querying supported hash/checksums
Adds a new mcumgr command for returning information on all supported
hash/checksum types that the firmware supports.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:10:03 +01:00
Jamie McCrae
2aca1242f7 mgmt: mcumgr: Fix Bluetooth transport issues
This fixes issues with the Bluetooth SMP transport whereby deadlocks
could arise from connection references being held in long-lasting
mcumgr command processing functions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:08:52 +01:00
Jamie McCrae
7028d01544 mgmt: mcumgr: Update struct name in documentation
Replaces mgmt_hdr with smp_hdr in documentation to match changes in
code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:08:26 +01:00
Jamie McCrae
f0669f845c mgmt: mcumgr: Replace mgmt_ctxt struct with smp_streamer
This replaces an intermediatory structure with a different one which
allows command functions to access the full contents of the streamer
structure that would be otherwise unavailable. This is a foundation
for allowing asynchronous mcumgr messages from the server.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:08:26 +01:00
Nirosharn Amarasinghe
bd74d27614 Bluetooth: controller: Time wrapping point used in ISO-AL calculations
-- Handle time calculations across the point at which the controller's
   time information from the controller's clock will wrap (in the
   microsecond range)
-- Use wrapped time in all ISO-AL time calculations

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-11-10 09:29:42 +01:00
Théo Battrel
e9c542ab5b Bluetooth: Add the cryptographic toolbox function h8
Add to the cryptographic toolbox the h8 function, defined in the Bluetooth
Core Vol. 6, part E 1.1.1.

Also add test and SMP self test for this function. The data used for those
are from the Bluetooth Core.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-10 09:28:28 +01:00
Théo Battrel
f16738b62b Bluetooth: Move crypto toolbox functions from smp.c to their own files
Move functions defined in the Cryptographic toolbox of the Bluetooth
specification inside their own files in the following folder:
`zephyr/subsys/bluetooth/bt_crypto`. The functions were previously
implemented in `zephyr/subsys/bluetooth/host/smp.c`.

The cryptographic toolbox functions can now be accessed from outside of the
host.

In addition to that, tests for each cryptographic toolbox functions have
been added.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-10 09:28:28 +01:00
Ryan Erickson
12b4187092 lwm2m: swmgmt: fix observations not working for resources
The pointers to resource values should not be used
directly to update the values.
This will break observations if the server is trying to
observe changes during a software update.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-11-10 09:27:54 +01:00
Pavel Vasilyev
1629a2f4d1 Bluetooth: Mesh: Fix net and app keys commands in shell
Fix net and app keys commands in shell

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-09 10:50:31 -06:00
Mariusz Skamra
6148d8a39d Bluetooth: audio: Fix invalid assert in bt_audio_iso_unbind_ep
This should assert if iso argument does not match the one ep holds
reference to.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-09 10:45:12 +01:00
Emil Gydesen
03a4e1ae48 Bluetooth: Audio: Add missing unbind of audio_iso for broadcast sink
When a BIS disconnected, we removed the references between
the endpoint and the stream. This made it impossible
to later unbind the audio_iso when
broadcast_sink_cleanup_streams was called.

Fixed by unbind the audio_iso when we remove the reference.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-09 10:45:06 +01:00
Markus Fuchs
ea17d5152d net: sockets_tls: Fix memory leak in socket
Fix file descriptor leak on unsupported socket protocols.

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
2022-11-09 10:44:44 +01:00
Erik Brockhoff
b1c0bc0c0a Bluetooth: controller: add central anchor point move to new LLCP
Add central functionality re. anchor point move to refactored LLCP

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 10:43:17 +01:00
Erik Brockhoff
26df2db60a Bluetooth: controller: add handling of preferred periodicity to new LLCP
Port central functionality re. preferred periodicity to refactored LLCP

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 10:43:17 +01:00
Erik Brockhoff
c180afec11 Bluetooth: controller: Adding user ext. anchor point move to ctrl/CPR
Adding support for allowing user extension code to support deferring
anchor point moves. Refactored LLCP only.
Note: This is NOT supported by LEGACY LLCP impl.
KConfig'd by BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE
Modified ll_conn_update API, to accommodate passing offsets
Modified CPR/CU context data structure
Modified CPR/CU procedure to handle anchor point move wait state
Fixed up unit tests, adding anchor point move cases to CPR/CU test

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 10:43:17 +01:00
René Beckmann
26758117d6 net: mqtt-sn: Add MQTT-SN library
This commit adds an implementation of MQTT-SN v1.2.
The specification is available on oasis-open.org:
https://www.oasis-open.org/committees/download.php/66091/MQTT-SN_spec_v1.2.pdf

The following things are missing in this implementation:
- Pre-defined topic IDs
- QoS -1 - it's most useful with predefined topics
- Gateway discovery using ADVERTISE, SEARCHGW and GWINFO messages.
- Setting the will topic and message after the initial connect
- Forwarder Encapsulation

Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
2022-11-09 10:43:00 +01:00
Hubert Miś
dc9d479dea ipc: add a multi-endpoint feature to icmsg
The icmsg backend for ipc_service has a limitation of supporting only
on endpoint. This limitation is acceptable for many IPC instances.
However, some require to use multiple endpoints sharing a single
instance. To preserve the simple and the most efficient single-instance
backend, a separated backend is introduced implementing a wrapper
around icmsg core which adds multiple endpoints support.

There are two multi-endpoint ipc_service icmsg backends: one in the
initiator role, and the other one in the follower role. In a IPC
configuration one end of communication must be in the follower role
while the other one is in the initiator. The initiator initiates
an endpoint discovery handshake to establish enpoint identifiers for
requested endpoint names. The follower responds to requests sent by
the initiator.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-11-09 10:41:43 +01:00
Hubert Miś
6f450fdf18 ipc: separate icmsg core from ipc_service backend
icmsg library was implemented as a ipc_service backend. It is a simple
library with minimal feature set. To preserve its simplicity while
adding more features it is useful to introduce separated ipc_service
backends with added features. To reuse most of the icmsg code for the
simplest backend and other including more features, the core of icmsg
is separated from the simplest ipc_service to an icmsg module which
can be used by multiple backends.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-11-09 10:41:43 +01:00
Erik Brockhoff
85354c405c Bluetooth: controller: refactoring pdu length validation
Using a macro instead of repeated identical code for validation
Use macro for pdu length field encoding

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 09:34:35 +00:00
Erik Brockhoff
2a236e52db Bluetooth: controller: rename pdu_data_llctr struct SCA member
Rename struct member to adhere to general naming pattern

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-09 09:34:35 +00:00
Christoph Schnetzler
c364721796 net: sockets: Prevent compiler error if warnings being treated as errors
If gcc compiler option -Werror is used the warning,

declared inside parameter list will not be visible outside of this
definition or declaration [-Werror]

is treated as error, for

sockets_internal.h:18:28: ‘struct net_context’
sockets_internal.h:19:32: ‘struct zsock_pollfd’
fdtable.h:108:17: ‘struct k_mutex’

Signed-off-by: Christoph Schnetzler <christoph.schnetzler@husqvarnagroup.com>
2022-11-09 09:15:32 +00:00
Emil Gydesen
64c2d86a64 Bluetooth: ISO: Replace CONFIG_BT_DEBUG_ISO_DATA guard with BT_ISO_DATA_DBG
Instead of guarding all BT ISO data log statements with
CONFIG_BT_DEBUG_ISO_DATA, a new macro, BT_ISO_DATA_DBG, is
implemented to handle the guarding.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-09 09:05:03 +00:00
Emil Gydesen
36c5dd4bca Bluetooth: ISO: Guard addition ISO debug with CONFIG_BT_DEBUG_ISO_DATA
Guard additional debug statements in ISO that deals
with TX/RX with CONFIG_BT_DEBUG_ISO_DATA to avoid spamming
the log.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-09 09:05:03 +00:00
Sean Madigan
a53446cd09 Bluetooth: Host: Check if EATT l2cap server is registered
bt_eatt_init currently registers a l2cap server, however should not
register a new one if it has already been registered - for example in
bt_enable previously.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
f88b19a833 Bluetooth: Host: init bt_workq and cancel rpa_update work
Init bt_workq in bt_enable so it can be safely disabled.

Cancel rpa_update work upon disable as it is no longer required.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
666990b6e4 Bluetooth: Host: add pub_key_hci_disrupted function
Add bt_pub_key_hci_disrupted function for when hci is disrupted during
a pub key hci command, to clear callbacks and BT_DEV_PUB_KEY_BUSY flag.

Call this from bt_disable for the case bt_disable disrupts the pub key
hci command.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
a4fcf39a69 Bluetooth: Host: clean up after connections in bt_disable
Reset disconnected handles as is no longer needed after disable.

Created a destroy function to clear all connection states and cancel any
deferred work.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
c80b6d8223 Bluetooth: Host: reset adv_pool in bt_disable
Reset the adv_pool in disable so that advertising can be started after
re-enabling without issue.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
0e010e8744 Bluetooth: Host: init fifos and slists before use
In bt_att_init, bt_conn_init and bt_l2cap_init, init the fifos and
slists before use. This means that they can be used after disable
without memory leakage.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Sean Madigan
0ef4f9740a Bluetooth: Shell: Add bt_disable to bluetooth shell app
bt_disable can now be used with the bluetooth shell.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-11-09 09:03:50 +00:00
Jamie McCrae
693e4cda81 mgmt: mcumgr: img_mgmt: Remove packed attribute from some structs
Removes the packed attribute from the img_mgmt structs that do not
need it.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-08 22:38:20 +01:00
Emil Gydesen
a34c2cd90a Bluetooth: Audio: Fix ASE_{SNK,SRC}_COUNT=0 issues
Due to the LISTIFY macro for the counts, the value
cannot be 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 10:48:54 +01:00
Mariusz Skamra
529b4b2b1d Bluetooth: audio: ascs: Fix invalid error code returned
This fixes invalid error code that was returned in case remote requested
Disable operation with invalid ASE ID.

Fixes: BAP/USR/SPE/BI-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-08 10:48:47 +01:00
Pavel Vasilyev
f2ea6f2149 Bluetooth: Mesh: Check avail conn before restarting pb-gatt srv adv
When a provisioner connects to the device, gatt_connected callback is
called in pb_gatt_srv.c, then pb-gatt advertising is stopped and adv_sent
callback is triggered in adv_ext.c. adv_sent callback reschedules
advertising and eventually calls bt_mesh_adv_gatt_send. Since the device
is not provisioned yet, it tries to start pb-gatt advertising again. If
number of available connections is reached, this results in "Advertising
failed" error in adv_ext.c.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-08 10:47:24 +01:00
Vinayak Kariappa Chettimada
0f80133571 Bluetooth: Host: Add auto conn param update retry count and timeout
Add implementation to retry the automatic peripheral
perferred connection parameter request with a configurable
retry countdown and retry back-off timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-08 10:47:07 +01:00
Vinayak Kariappa Chettimada
073b2af808 Bluetooth: Host: Fix use of tabs inside struct and enum definitions
Fix use of tabs inside struct member of bt_conn_le and
bt_conn enum definitions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-08 10:47:07 +01:00
Sam Hurst
37e6f15f34 usb-c: Fix unsupported message reporting
When operating in PD2.x mode, PD_CTRL_REJECT should be
transmitted to the port partner when an unsupported message
is received.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-11-08 10:46:40 +01:00
Mariusz Skamra
e4f0bcdd56 Bluetooth: audio: ascs: Fix audio ISO allocation in QoS->QoS transition
ASE in QoS state already have audio ISO object.
This will just skip the audio ISO allocation and binding in such case
if CIG and CIS parameters did not change.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-08 10:46:07 +01:00
Lingao Meng
93709a7359 Bluetooth: Mesh: Add specific number of keys & groups
Since Mesh Spec and Mesh model sayes, some model no need
groups and no need keys, such as Config Server, but the
current implementation, all model use same configuration,
which cause some ram ext comsume.

So that, change to specific way, but will consume more footprint size.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-08 10:45:15 +01:00
Erik Brockhoff
76439d0ba4 Bluetooth: controller: integrating SCA procedure and adding HCI API
Adding controller support for updating SCA in ACL and ISO peripherals
Adding HCI API support for le_request_peer_sca and complete event.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-08 10:44:54 +01:00
Erik Brockhoff
b3b4b9e322 Bluetooth: controller: implementing SCA update procedure PDU flow
Adding PDU flow and unittest for Sleep clock accuracy procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>

wip kconf
2022-11-08 10:44:54 +01:00
Tom Burdick
e3d877f811 rtio: Userspace support
Add support for userspace with RTIO by making rtio and rtio_iodev
k_objects. As well as adding three syscalls for copying in submissions,
copying out completions, and starting tasks with submit.

For the small devices Zephyr typically runs on one of the most important
attributes tends to be low memory usage. To maintain the low footprint of
RTIO and its current executor implementations the rings are not shared with
userspace. Sharing the rings it turns out would require copying submissions
before working with them to avoid TOCTOU issues.

The API could still support shared rings in the future so that a
kernel thread could directly poll, copy, verify, and start the submitted
work. This would require a third executor implementation that maintains its
own copy of submissions similiar to how io_uring in Linux works.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-08 10:44:03 +01:00
Emil Gydesen
8dffa45e0c Bluetooth: Audio: Add support for multiple subgroups for BAP broadcast sink
The broadcast sink supports multiple subgroups, but was
not possible due to the Kconfig option.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:43:11 +00:00
Erik Brockhoff
6b324122e7 Bluetooth: controller: fix CIS REQ event generation and rejection
Check LE event mask state as well as host controlled feature mask state
and reject CIS request accordingly.
Release pre-allocated ISO resources on rejection of request

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-11-08 09:38:21 +00:00
Emil Gydesen
87eab711df Bluetooth: Audio: Add additional printing in CSIS client shell
The CSIS client shell did not print the pointers of the instances
discovered, which are needed for future commands.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:37:17 +00:00
Emil Gydesen
6d46472cfe Bluetooth: VCS: More explicit log for abs vol set opcode
When the set absolute volume opcode was received, we
logged the current volume, but without any explaining
text.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:36:04 +00:00
Emil Gydesen
7fb8f77103 Bluetooth: Audio: Shell: Fix metadata argument
The metadata in the presets are just defined
using the BT_AUDIO_LC3_PRESET which ultimately
uses BT_CODEC_LC3_CONFIG_META which correctly
sets the data pointer, but the `value` array is unused.

So we cannot just update the `value`, as that is actually
not used in those cases, and the `data` pointer is `const`.

The solution is to a copy of the metadata data, and use
the copy when calling the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-08 09:35:25 +00:00
Kumar Gala
6401682dd3 ztest: Fix building when CONFIG_MP_NUM_CPUS=1
We get compiler warnings on testcases that set CONFIG_MP_NUM_CPUS=1
and platforms that have CONFIG_SMP=y.  Qualify the code so its only
built if CONFIG_SMP && (CONFIG_MP_NUM_CPUS > 1).

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-11-07 21:12:54 -05:00
Andrzej Puzdrowski
2c52733f8d dfu/boot/mcuboot: treat pristine image as confirmed
In case of initial/pre-programed image.
Such image can neither be reverted nor physically confirmed.

Image like this should be recognized as confirmed by the
boot_is_img_confirmed() for consistency.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-11-07 09:50:35 +01:00
Mariusz Skamra
9054435a4a Bluetooth: ascs: Handle CIS disconnection in non-releasing state
Unbind ISO when goint to idle state if there's still reference kept.
It may happen that we get CIS disconnection being in non-releasing
state, so we have to handle that case. This fixes regression that was
introduced in 3fa456905d.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-07 09:50:18 +01:00
Lingao Meng
9cb1ff7fce Settings: NVS: Add cache for nvs name lookup
Add cache for name id lookup.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-05 19:58:34 +01:00
Jamie McCrae
b6cd83bf7a net: ipv4: Add fragmented packet support
Adds support for incoming and outgoing IPv4 fragmented packet support,
allowing a single packet that is too large to be sent to be split up
and sent successfully.

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2022-11-05 19:58:26 +01:00
Pavel Vasilyev
d286bc4699 Bluetooth: Mesh: Fix args parsing in cmd_net_key_add function
cmd_net_key_add has only 2 arguments.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-11-05 19:56:50 +01:00
Mariusz Skamra
7a6581219d Bluetooth: gatt: Fix notification cleanup on disconnection
This fixes GATT notification buffer missing cleanup on ACL
disconnection. Fixes potential NULL pointer dereference trying to use
invalid conn object in `notify_mult_process` work queue task handler
and/or missing free of pending notification buffer.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-05 19:56:42 +01:00
Stephanos Ioannidis
fa5fd41b61 kernel: Add C++ main() support
The C++ standard requires the main() function to have the return type
of 'int' and does not allow the main() to be defined with the 'void'
return type. Moreover, GCC goes as far as to emit a hard error when the
'::main()' has the return type of `void`.

This commit introduces an option to instruct the Zephyr kernel to call
the 'int main(void)' instead of the 'void main(void)' in case a Zephyr
application defines main() in a C++ source file.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-11-05 16:41:45 +09:00
Mariusz Skamra
fbeee206f2 Bluetooth: audio: pacs: Hotfix invalid PACS length
This fixes adding 2 redundant bytes... to the PAC records.
As a result we end up with broken PAC record.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 10:00:00 +01:00
Mariusz Skamra
7405f81db6 Bluetooth: audio: pacs: Remove unused structure member
The 'pacs' member was never referenced.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 10:00:00 +01:00
Mariusz Skamra
8f6fc38ca3 Bluetooth: audio: unicast_client: Remove redundant code
The unicast_client_ep_set_codec function that is called below
sets the codec id, cid, vid.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 10:00:00 +01:00
Juha Heiskanen
efa75b5a76 net: lwm2m: Send operation registry lock update
Secured Message allocation, init and rebuild process for secure
timeseries ring buffer.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-11-04 09:59:51 +01:00
Juha Heiskanen
05a92f9258 net: lwm2m: Timeseries data cache read update
Added support for handle case when all data is not possible to
add in 1 message for Send and Observed Notification.

Notification continuous pending timeseries data is triggred
by iMIN attribute.

Send Operation generate continuous message in multiple lwm2m
message.

Normal Read by server only report back latest stored data.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-11-04 09:59:51 +01:00
Tommi Kangas
75b5eaac0f net: lwm2m: fix hanging deregistration
Fixed a deadlock in deregistration by moving mutex unlocking.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2022-11-04 08:56:05 +00:00
Mariusz Skamra
50b57056bd Bluetooth: iso: Fix calling wrong function to terminate BIG
The bt_iso_chan contains vaild pointers for Tx and Rx QoS parameters.
This unifies the implementation between different roles.
This fixes checking ISO type that is done based on ISO type that
is kept inside of conn.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
0fa978508c Bluetooth: audio: unicast_client: Inform all related EP's about ISO state
This fixes application callbacks not being called on ISO connection
state change.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
3fa456905d Bluetooth: audio: Factor out bt_audio_iso pool
This adds common bt_audio_iso pool that will be used across all the
roles/profiles. The pool range is dependent on the CONFIG_BT_ISO_MAX_CHAN
which is the maximum number of ISO connections the host can maintain.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
1aaf1e522f Bluetooth: audio: unicast_client: Remove unused functions
This removes unused functions from unicast_client.c

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Mariusz Skamra
6fde7ae96d Bluetooth: audio: ascs: Move control point work to EP
Move the control point work to the EP. The aim is to cleanup the code so
that it there's no EP for ASE that means ASE is in idle state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Jamie McCrae
461b2147d6 mgmt: mcumgr: Fix using wrong value for response packet size
Fixes an issue introduced with a recent change that wrongly uses the
source packet header size for the output instead of the supplied
size.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-03 15:39:17 +01:00
Dominik Ermel
95202ae3da mgmt/mcumgr: Unify function definition style
Move static and return type in line with definition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
98831be2c4 mgmt/mcumgr: Rename mgmt_hdr to smp_hdr
mgmt_hdr has always been part of SMP protocol and the name is
a little bit misleading.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
73d1bf984a mgmt/mcumgr: Make mgmt_hdr definition internal
It is only needed to be known by SMP protocol processing
and in some cases by transport, for example reassembly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
bf8ec99860 mgmt/mcumgr: Remove mgmt_ntoh_hdr and mgmt_hton_hdr
These two-liners have been only used by SMP protocol processing,
and there is no reason to have them available as public functions.
Code from these functions have been moved directly where they
have been used and they have been removed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:45 +01:00
Dominik Ermel
5f025cf49c mgmt/mcumgr: Move and rename zephyr_ prefixed functions in OS group
zephyr_ prefix is now redundant as there are no other OSes supported.
The commit also moves functions, after renaming them, and makes
them static, as they no longer have to be shared between compilation
units.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:29 +01:00
Dominik Ermel
80958bbff9 mgmt/mcumgr/lib: Merge Zephyr specific code to fs_mgmt.c
It is no longer needed to have "system specific" API for FS management.
The commit removes fs_mgmt_impl.h and moves Zephyr specific
functions that implement the fs_mgmt_impl.h declared functions
into fs_mgmt.c

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-03 13:04:29 +01:00
Jamie McCrae
4c48b4f21a mgmt: mcumgr: img_mgmt: Fix bug with old image state being present
This fixes an issue whereby the image state of an upload is present
even after an image erase command, which would instruct a client to
continue uploading at an offset that has no preceeding data.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-03 13:03:53 +01:00
Vinayak Kariappa Chettimada
f35b9eb5cc Bluetooth: Shell: Select BT_TICKER_NEXT_SLOT_GET when BT_LL_SW_SPLIT
Select BT_TICKER_NEXT_SLOT_GET when BT_LL_SW_SPLIT enabled
and building applications with shell support (BT_SHELL).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-03 10:24:49 +01:00
Emil Gydesen
cdc3b332ba Bluetooth: Audio: Fix unicast client ep reset
The endpoint was only partially memset on disconnect,
which left the handles untouched. This meant that the
reset endpoint would still get returned by
unicast_client_ep_find.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-03 10:24:03 +01:00
Morten Priess
447c7390f5 Bluetooth: controller: Add window widening for CIS/CIG
Program CIG ticker with window widening drift. Introduce vendor specific
conversion macros allowing sub-microsecond resolution in the
accumulation of window widening drift per interval.

Calculation of window_widening_max_us is done for NSE<3, and must be
adjusted in the LLL before use, if the first CIS in the CIG has a
NSE>=3. In that case window_widening_max_us shall be limited to one sub
interval.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-03 08:56:58 +00:00
Théo Battrel
7d2b4e1917 Bluetooth: Remove unneeded macros
Remove the `bt_hex`, `bt_addr_str`, `bt_addr_le_str` and `bt_uuid_str`
macros from `bt_str.h` as they were just aliases for the `*_real` functions
in the same file.

The functions has been renamed without the `_real` suffix.

Some files were using the functions and not the macros, they have been
updated to use the new name of the functions.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-02 13:28:57 +01:00
Théo Battrel
effb76c61e Bluetooth: Move re-implementation of snprintk
Move the function in the `subsys/testsuite/ztest/src/ztest_mock.c` files.

This is motivated by the fact that there is others re-implementation of
`*printk` functions using libc counterparts in the `ztest_mock.c` file.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-02 13:28:57 +01:00
Théo Battrel
c9d68a5a4f Bluetooth: Move out string related function of common/log.h
Functions related to string manipulation that were defined in
`common/log.h` has been moved to the `common/bt_str.h` file and their
implementation in `common/bt_str.c`.

Files that were using those functions has been updated consequently.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-02 13:28:57 +01:00
Vinayak Kariappa Chettimada
5cf47b1e7f Bluetooth: Controller: Fix ticker slot reserved check
Fix ticker slot reserved check to handle deferred execution
of ticker worker where ticks_elapsed is greater than
ticks_slot_previous. In which case, each ticker expiring be
checked for overlap with previous slot reservation.

This fixes:
ASSERTION FAIL [0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/
controller/ll_sw/nordic/lll/lll.c:476
lll_preempt_calc: Actual EVENT_OVERHEAD_START_US = 3906

Flash erase operation exposed the assertion, CPU being
halted deferred the ticker_worker collision resolution and
ticker expiry was not individually checked for overlap with
previous expired ticker reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:33:22 +01:00
Vinayak Kariappa Chettimada
fbfa2b4631 Bluetooth: Controller: Fix missing first connection event
Fix missing first connection event due to first connection
event ticks_slot of central and peripheral overlapping with
the initiator window ticks_slot and advertising ticks_slot,
respectively.

Use ticker_stop_abs interface so that when the ticker is
stopped the ticks_slot_previous is truncated to the actual
ticks used as requested by the supplied absolute ticks.

Relates to commit 8a294a62d4 ("Bluetooth: controller:
legacy: Fix missing first conn event").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:33:22 +01:00
Tomasz Moń
04059ec8a7 usb: device: msc: synchronize cache after writes
Flush disk cache when write command finishes.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-11-02 10:31:58 +01:00
Vinayak Kariappa Chettimada
af9dd5cb26 Bluetooth: Controller: Fix ticks_current initialization
Fix ticker instance ticks_current initialization to be
acquired from the RTC counter value. The RTC counter may
have run in previous use of ticker before bt_disable hence
keep the instance ticks_current equal to RTC counter value
when ticker_init() is called again.

Relates to commit 4349a475a8 ("Bluetooth: Controller: Add
deinit() infrastructure").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:31:33 +01:00
Vinayak Kariappa Chettimada
943deca7c4 Bluetooth: Shell: Add back erroneously removed ll-addr command
Add back erroneously removed ll-addr command, when removing
legacy Controller, which is provided when using Zephyr
Bluetooth Low Energy Controller to read the random and
public address set by the Host, and used by the Controller.

Relates to commit b67a31e411 ("Bluetooth: controller:
Remove legacy LL").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-11-02 10:30:52 +01:00
Ingar Kulbrandstad
7367980bea Bluetooth: Mesh: Extended advertiser as default
Setting the extended advertiser as default advertiser
to improve both preformence and reliability.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2022-11-01 08:52:56 +00:00
Piotr Pryga
f24b5b4b43 Bluetooth: host: df: fix wrong connectionless CTE enable cmd length
There were a bug in a prepare_cl_cte_rx_enable_cmd_params function.
The size of command buffer was wrong when CTE enabled in AoD mode.
The command buffer was extended by param->num_ant_ids, that was
zero in case of AoD. Then a dummy antenna switch pattern was copied
into the command buffer.

That lead to: memory overwrite, and wrong command buffer length.
The command was rejected by Controller.

To fix, use cp->switch_pattern_len that was already assigned with
correct antenna pattern length.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-31 11:23:44 +01:00
Mariusz Skamra
3ea297960d Bluetooth: audio: Remove capablilities leftovers
Remove dead code that remained after
https://github.com/zephyrproject-rtos/zephyr/pull/51425 was merged.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-31 16:39:05 +09:00
Christoph Schnetzler
0dd14404e1 net: lwm2m: Prevent wundef warnings
If -Werror is used compilation fails due to wundef warning.

Signed-off-by: Christoph Schnetzler <christoph.schnetzler@husqvarnagroup.com>
2022-10-28 22:06:09 +09:00
Carles Cufi
8e4d499fa0 treewide: Use CONFIG_*_ENDIAN instead of __BYTE_ORDER__
In order to avoid using multiple sources of truth for the platfom's
endianness, convert the in-tree code to use the (BIG|LITTLE)_ENDIAN
Kconfig variables exclusively, instead of the compiler's
__BYTE_ORDER__.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-28 19:23:46 +09:00
Jordan Yates
c3eeae80ec debug: thread_info: store arch mode_exc_return offset
Store the offset of mode_exc_return in the arch struct. This is required
to restore the link register to the original value, as `swap_helper.S`
saves the LSB to this field when `CONFIG_ARM_STORE_EXC_RETURN=y`.

Failing to account for this results in broken debugging when
`FPU_SHARING` or `ARM_NONSECURE_PREEMPTIBLE_SECURE_CALLS`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-10-28 11:51:15 +02:00
Emil Gydesen
affd8da9a0 Bluetooth: Host: Fix wrong addr for PA term when using adv list
If using the advertiser list when syncing to a PA, then the
address address needs to be updated for the PA sync object.
This is a small optimization to avoid doing a copy when
the address and SID is already set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-28 07:56:41 +00:00
Emil Gydesen
cba4b1828d Bluetooth: Host: Fix missing term callback for PA syncs
When deleting a PA sync with bt_le_per_adv_sync_delete
Zephyr should call the `term` callback for the PA sync
as per the documentation for the callback.

This was not done in the case that the PA sync was
terminated by local request.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-28 07:56:41 +00:00
Martin Tverdal
0cf6cac77e Bluetooth: extended adv reports with legacy content discardable
To avoid legacy extended adv repots blocking important
events or work, mark them as discaradble.

Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
2022-10-28 07:55:44 +00:00
Kumar Gala
8eb0cdfcfb ztest: Convert CONFIG_MP_NUM_CPUS handling
For test_1cpu_start/test_1cpu_stop make the code only build if
CONFIG_SMP and move to using arch_num_cpus() for runtime loops
and CONFIG_MP_MAX_NUM_CPUS for array decleration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-27 14:02:05 -04:00
Kumar Gala
dd03af653d pm: Rework usage of CONFIG_MP_NUM_CPUS to CONFIG_MP_MAX_NUM_CPUS
Replace usage of CONFIG_MP_NUM_CPUS with CONFIG_MP_MAX_NUM_CPUS for
init and declaration as we phase out CONFIG_MP_NUM_CPUS usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-27 13:51:55 -04:00
Jonathan Rico
4b1585c23f Bluetooth: shell: fix compiler warning
Compiler thinks `err` is not initialized when
`CONFIG_DEBUG_OPTIMIZATIONS=y`.

Fixes #51521 .

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-27 17:23:36 +02:00
Andries Kruithof
5e360b81c2 Bluetooth: controller: llcp: update rx parameters upon receipt of PDU
According to specification, when executing a remote procedure the
rx parameters used need to be updated when the REQ from the peer
is received. Currently this is done only when an ACK is
received on the RSP PDU send out.
This commit updates the RX parameters upon receipt of the REQ PDU

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-10-27 16:57:27 +02:00
Krishna T
1852e33213 net: lib: zperf: Disable prints during ongoing traffic
Prints when traffic is ongoing cost a few Mbps due to writing to UART as
observed by the profiler, so, disable them by default.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-27 15:37:41 +02:00
Aleksander Wasaznik
fd5fe6ca8e Bluetooth: Host: Add CONFIG_BT_ID_UNPAIR_MATCHING_BONDS
This commit prevents the assertion error added in the previous commit,
by introducing the following behavior.

When the Host detects that a pairing procedue would result in more than
one local identity having a bond with the same remote address, it will
try to abort the pairing. If the pairing procedure cannot be properly
aborted, it will remove the pairing locally and disconnect.

This commit also introduces a new kconfig `BT_ID_UNPAIR_MATCHING_BONDS`.
This config changes the above-described behavior to instead un-pair the
old bond and continue with the pairing (if the new bond has the same or
better security.)

The new kconfig is not enabled by default. See the help text of the new
kconfig option for more details.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-27 13:16:59 +02:00
Aleksander Wasaznik
6e926dcd83 Bluetooth: Prevent bonding to the same device more than once
This change prevents two local identities from having bonds to the same
device.

The Core specification is not well suited for Zephyr's multiple-local-
identities feature. The HCI specification seems written with intent that
a controller is used for only one GAP device. A GAP device has at most
one public address, and at most one random static address.

The Zephyr Bluetooth API, on the other hand, has a concept of local
identities. This feature allows the Zephyr Bluetooth stack to
simulatainously assume multiple local addresses. This does not mesh well
with the above intent in the specification.

In particular, the HCI specification for the resolve list does not allow
more than one entry for a remote address. The controller will deny any
attempts at doing this.

The current implementation of the Zephyr host will try the above and be
denied. But there is no handling for this situation and the host ends up
in a confused state. Some parts of the system are ok with the two bonds,
but other parts assume this situation never occurs behave badly.

The result is that the host confuses the multiple bonds to the same
device. Symtoms include:

- Directed advertisements have a different source address than what the
  host intended, in which case the two sides are confused about the
  address of the Zephyr advertiser, and as a result LTKs will not match.

- Errors in the log.

This commit simply asserts. This is not a solution, just a placeholder
for a fix. The next commit will implement a strategy for handling this
situation instead of failing this assert.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-27 13:16:59 +02:00
Aleksander Wasaznik
dfe03c1268 Bluetooth: Host: Define bt_irk_eq
This gives a well-defined method for determining if two IRKs are equal.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-27 13:16:59 +02:00
Veijo Pesonen
8c68e01e55 doc: lwm2m: LwM2M Shell
Describes a possible scenario where to use the LwM2M shell
and how to enable it.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-10-27 11:05:05 +02:00
Juha Heiskanen
a66970a6b8 net: lwm2m: Fix connection resume without DTLS
LwM2M connection resume was missing socket connection when
DTLS is disabled.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-27 11:00:46 +02:00
Sam Hurst
c2677cef57 usb-c: Correct spelling error in comment
Correct spelling error in comment

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-27 11:00:14 +02:00
Sam Hurst
cc393f24af usb-c: Fix policy callback function assertion
Fix the assertion check that's performed on a non-existing
callback.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-27 11:00:14 +02:00
Dominik Ermel
9331591ab1 mgmt/mcumgr: Remove buf.c
buf.c have been providing net_buf pool allocator and dealocator
for SMP packets: mcumgr_buf_alloc and mcumgr_buf_free.
The functions have been moved to smp.c and renamed
smp_packet_alloc and smp_packet_free, respectively.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Dominik Ermel
12b1528df9 mgmt/mcumgr: Remove mgmt/mcumgr/buf.h
SMP buffer allocation functions have been moved to smp/smp.h,
and buf.h has been removed.
Definitions of cbor_nb_reader and cbor_nb_writer have also been moved.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Dominik Ermel
6fdf95fbce mgmt/mcumgr: Move and internalize cbor_nb_*_init functions
The commit moves functions used for initialization of CBOR encoding
and decoding to the only unit that is supposed to use them.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Emil Gydesen
326b2fdf15 Bluetooth: Audio: Fix issue with supporting bidir CIS in ASCS
If 2 ASEs shared the same CIS and the first ASE had the CIS
connected before the second ASE was QoS configured, then
the CIS was missing either the TX or RX pointer, causing
it to be considered unidirectional by the ISO layer.

This commit fixes this issue by configuring the (static)
pointers at an earlier time, so that the RX and TX QoS
pointers are always valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-26 12:01:52 +02:00
Marc Lasch
df68307121 net: lwm2m: Rename timer object instance create function
Rename timer object instance create funciton `timer_create` to fix a
name collision regression with a POSIX function in `timer.h`. The issue
was introduced with commit 73a637eda0 when
first including`timer.h` into `lwm2ms.h`.

Signed-off-by: Marc Lasch <mlasch@mailbox.org>
2022-10-26 12:01:27 +02:00
Tommi Kangas
c3ad5efa19 net: lwm2m: use zsock_ functions
Use Zephyr internal zsock_ calls to remove dependency
to NET_SOCKETS_POSIX_NAMES.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2022-10-26 12:01:14 +02:00
Hang Fan
756421b85e Bluetooth: Audio: Fix codec configuration parameter
Fix wrong Codec_Configuration and Codec_Configuration_Length
when setup ISO data path.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-10-26 12:00:38 +02:00
Wojciech Slenska
861f4f81c3 logging: log_backend_fs: added LOG_BACKEND_FS_AUTOSTART configuration
This configuration option gives the possibility to not enable
the fs backend on startup.
Backend can be enabled in runtime using log_backend_init and
log_backend_enable functions.
Implementation is based on log_backend_net.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-10-26 12:00:29 +02:00
Robert Lubos
3bf503085f net: ip: Increase the number of IPv4/IPv6 interfaces with loopback
In case loopback interface is enabled, it's most likely there will be
more than a one network interface if running on real hardware. Therefore
increase the default IPv4/IPv6 interface count to avoid the need to
increase it manually in every test suite.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Krishna T
9b02f91f80 net: wifi: Fix MFP when security type is not given
When security type is not given but instead MFP is given, MFP setting
will be considered as security type, this is because both are optional
and no way to distinguish them easily.

Make security type mandatory for MFP selection, this way we either
assume defaults for both security type and MFP or explicitly ask user
for both. Reword the help text to reflect this.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-26 12:00:11 +02:00
Keith Packard
ced5053e6c subsys/tracing: Use z_current_get in switch_{in,out}
The thread switching tracing hooks are called in the middle of swapping,
before z_thread_entry has a chance to set the z_tls_current value, so they
cannot use k_current_get. Switch them to z_current_get instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-26 12:00:04 +02:00
Mariusz Skamra
2627063ab2 Bluetooth: audio: pacs: Replace capabilities API with pacs
This changes the API to use proper naming convention, as the code has
been moved out of capabilities.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
e635d3aab6 Bluetooth: audio: pacs: Refactor capabilities related code
This simplifies and removes redundant code.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
ce973edbd2 Bluetooth: audio: pacs: Refactor location related code
This simplifies and removes redundant code.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
49f9119c99 Bluetooth: audio: pacs: Refactor context related code
This implifies and removes redundant code.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
2a1cb0acd8 Bluetooth: audio: Fix building and reading PAC Records
This fixes missing checks, and invalid struct bt_pac definition that was
missing one mandatory metadata byte.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
43ffe3cad9 Bluetooth: audio: pacs: Refactor PAC read handler
This makes use of bt_audio_foreach_capability fuction to
simplify building the PAC attribute value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
7c1f6d93dc Bluetooth: audio: pacs: Move capabilities to PACS
There is no point of having dedicated source file that is PACS
dependent. This moves all of the code from capabilities.c to pacs.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Mariusz Skamra
8500eb1335 Bluetooth: audio: pacs: Fix PACS notification
This fixes sending PACS notification with buffer containing invalid,
uninitialized data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Jamie McCrae
7bab5c1b75 mgmt: mcumgr: transport: smp_bt: Fix deadlock on disconnect with data
This fixes an issue with the bluetooth transport whereby if a device
drops the connection prior to receiving all the output data it could
cause a deadlock.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-25 17:37:17 +02:00
Henrik Brix Andersen
f8a88cdb27 drivers: can: use flags fields for can_frame and can_filter structs
The can_frame and can_filter structs support a number of different flags
(standard/extended CAN ID type, Remote Transmission Request, CAN-FD format,
Bit Rate Switch, ...). Each of these flags is represented as a discrete bit
in the given structure.

This design pattern requires every user of these structs to initialize all
of these flags to either 0 or 1, which does not scale well for future flag
additions.

Some of these flags have associated enumerations to be used for assignment,
some do not. CAN drivers and protocols tend to rely on the logical value of
the flag instead of using the enumeration, leading to a very fragile
API. The enumerations are used inconsistently between the can_frame and
can_filter structures, which further complicates the API.

Instead, convert these flags to bitfields with separate flag definitions
for the can_frame and can_filter structures. This API allows for future
extensions without having to revisit existing users of the two
structures. Furthermore, this allows driver to easily check for unsupported
flags in the respective API calls.

As this change leads to the "id_mask" field of the can_filter to be the
only mask present in that structure, rename it to "mask" for simplicity.

Fixes: #50776

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Henrik Brix Andersen
a9c7c58345 canbus: isotp: avoid reusing CAN controller driver API definitions
Avoid reusing the CAN_EXTENDED_IDENTIFIER and CAN_STANDARD_IDENTIFIER
definitions from the CAN controller driver API for ISO-TP structure members
as this is a fragile design.

The ISO-TP layer must be responsible for its own definitions where
needed. Replace the "id_type" ISO-TP struct member with a well-known
abbreviated "ide" bit (Identifier Extension Bit) struct member.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Dominik Ermel
8e0464ef68 mgmt/mcumgr/lib: Remove zephyr_ and _impl_ from function names
The commit removes zephyr_ and _impl_ from function names in image
management group, and renames img_mgmt_impl.* source files to
img_mgmt_priv and merges img_mgmt_priv.h headers.
The zephyr_ and _impl_ have been removed because they no longer make
sense, as the mcugr is internal part of Zephyr, and removal makes
function names shorter.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-25 16:24:18 +02:00
Dominik Ermel
552217cd68 mgmt/mcumgr/lib: Remove stubbed logging calls from img group
The commit removes some leftover code from feature that has been
supposed to log image upload events with use of SMP, but has never
been actually implemented.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-25 16:24:18 +02:00
Sjors Hettinga
14cb6cb419 net: ip: Speed up the IP/UDP/TCP checksum calculation
Instead of doing a 1-complement addition for every 16-bit word, process
32-bit words and handle the 1-complement addition at the end.

This work is a colaboration with Diego Pino García. The algorithm is
inspired by:
https://blogs.igalia.com/dpino/2018/06/14/fast-checksum-computation/

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-10-25 12:46:11 +02:00
Théo Battrel
2d1d309936 Bluetooth: Move out BT_ASSERT of common/log.h
Macro that was defined in the `common/log.h` has been moved to the newly
created `common/assert.h` file.

Files that were using those macro has been updated consequently. Also, the
include of `common/log.h` has been removed of files that were actually not
using any logging methods.

Some `#include "common/log.h"` have been removed. Those were required
before when including `hal/debug.h`. With this change, `hal/debug.h` no
longer has this requirement, because the replacement, `common/assert.h`
includes what it uses.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-10-25 10:48:17 +02:00
Théo Battrel
fdd0a26348 Bluetooth: Remove BT_HEXDUMP_DBG
Replace unnecessary `BT_HEXDUMP_DBG` with `LOG_HEXDUMP_DBG`.

`BT_HEXDUMP_DBG` did an extra cast to `const uint8_t *` on its first
argument. This was probably the reason it was introduced. But the
current definition of `LOG_HEXDUMP_DBG` does this cast for us.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-10-25 10:48:17 +02:00
Ahmed Moheb
b8a957a0eb bluetooth: host: id: Fix copy BT_HCI_OP_VS_READ_STATIC_ADDRS response
Fix copying addresses returned in response to command
BT_HCI_OP_VS_READ_STATIC_ADDRS for reading controller static addresses.
The loop was iterating only over the destination locations while
keeping the source address pointing to the first location of
the command response.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-25 10:03:27 +03:00
Mariusz Skamra
0b825d0ee4 Bluetooth: audio: csis: Fix bt_conn_foreach function parameter
Exclude non-LE connections when sending notifications.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-25 09:53:23 +03:00
Peter Mitsis
6c1e8efa09 ztest: Make cpu hold time configurable
3000 milliseconds may not always be enough time for all 1cpu type
tests to finish on all platforms. Making the CPU hold time
configurable allows for additional flexibility.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-10-24 11:15:00 -04:00
Robert Lubos
caab8cb1b3 net: lwm2m: Don't assume time_t data type size
sizeof(time_t) can vary depending on architecture/libc being in use,
therefore LwM2M should not assume time_t data type size. Instead of
using magic numbers, use a proper sizeof.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-24 16:13:40 +03:00
Emil Gydesen
d5499e6b87 Bluetooth: Audio: Add CAP stream
Add a new stream object, bt_cap_stream, which is an extension
of the BAP bt_audio_stream. The purpose of this stream
is that we can extend the data stored in the BAP stream for
CAP usage, as well as making it more explicit what type
of stream should be used for CAP.

The callbacks will be extended for CAP in specific use cases,
e.g. when starting one or more unicast audio streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
7a1e827a8b Bluetooth: Audio: Make CAP acceptor more explicit
Remove the generic CONFIG_BT_CAP and CONFIG_BT_DEBUG_CAP
and only use Kconfigs specific to the individual roles.

This also includes renaming cap.c to cap_acceptor.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
ce05cb5c2c Bluetooth: Audio: CAP initiator discover CSIS
The CAP initiator will now discover, or return a
known, CSIS instance included by CAS (if any).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
ed11295cf6 Bluetooth: Audio: CSIS client register multiple callbacks
Change the CSIS client callback to a slist so that
multiple applications can register it. An example of
such a case is that both the application and CAP initiator
want to get the callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
2e42105df0 Bluetooth: Audio: CSIS: Refactor CSIS client discover API
The API will now take a simple bt_conn instead of a
set member struct. This is due to the set member struct
being moved to the stack. The reasoning for this is that
having the struct in the stack, rather than in the
application, the stack itself can initiate the CSIS
discovery which is useful if the remote device
has a service that includes a CSIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
ee70dffc6d Bluetooth: Audio: CAP shell implementations
Implements the CAP shell functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
7a49de12af Bluetooth: Audio: Implement CAP initiator discover
This is the primary discovery of the CAS on the remote device,
but does not include discovering the (optional) CSIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen
760177b1be Bluetooth: Audio: Add CAP initiator skeleton
Add skeleton for the expected APIs and
implementation. May be subject to change as
implementation progresses.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Juha Heiskanen
4bcc880670 net: lwm2m: LwM2M engine time API update
Updated lwm2m_enigen_set/get_time API for support time_t.

Updated LwM2M engine set/get resource time to time resource support
time_t and uint32_t input.

LwM2M engine put and get time API update to use time_t.

Time series data cache entry have own type for time resource.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-24 10:39:03 +02:00
Juha Heiskanen
e1e2228e9c net: lwm2m: LwM2M object time resource update
Updated Timestamp resource default buffer type to time_t.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-24 10:39:03 +02:00
Emil Gydesen
31bf99cbd2 Bluetooth: ISO: Change ISO seq_num to 16-bit
The sequence number is by the core spec defined as 16-bit.
We had implemented a workaround for the wrapping of the
sequence number, which required the type to be larger
than 16-bit (32-bit).

However, since the definition of the sequence number,
and the use of, is poorly defined by the core spec, we
are reverting this workaround and reducing the sequence
number to 16-bit again. This way it is more in line
with the core spec, as well as more intuitive given the
other uses for the sequence number.

This change moves the responsibility of using the
right value to the upper layers, as the stack can
and will no longer provide any guarantees.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:38:49 +02:00
Sam Hurst
e90f1b66d8 usb-c: Add USB-C Subsystem with Sink PD Support
This USB-C Subsystem enables an application to include
USB-C Power Delivery Sink functionality.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Chris Friedt
d832b04e96 net: sockets: socketpair: do not allow blocking IO in ISR context
Using a socketpair for communication in an ISR is not a great
solution, but the implementation should be robust in that case
as well.

It is not acceptible to block in ISR context, so robustness here
means to return -1 to indicate an error, setting errno to `EAGAIN`
(which is synonymous with `EWOULDBLOCK`).

Fixes #25417

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-10-22 02:30:04 -07:00
Henrik Brix Andersen
c5352e99a1 canbus: isotp: fix size_t format specifier
Fix the format specifier for logging size_t values.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-10-22 14:36:02 +09:00
Ahmed Moheb
92c93ef3c4 bluetooth: host: crypto: Check input arguments with CHECKIF()
Check input arguments passed to APIs with CHECKIF().

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-21 20:30:47 +02:00
Kumar Gala
a1195ae39b smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS
Change for loops of the form:

for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
   ...

to

unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
   ...

We do the call outside of the for loop so that it only happens once,
rather than on every iteration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-21 13:14:58 +02:00
Emil Gydesen
37028ea0d0 Bluetooth: Shell: Add support for advertising appearance
Add support for advertising the appearance value in the
advertising data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-20 17:00:26 +03:00
Emil Gydesen
135bcd339b Bluetooth: Shell: Remove ad_mode_parse
The function did not provide anything that could
not just as easily have been done in the existing
loops.

This just required moving the call to ad_init to
after the param parsing loop.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-20 17:00:26 +03:00
Mariusz Skamra
39dcde2b7e Bluetooth: audio: ascs: Do not store Bluetooth address
The struct bt_ascs holds the conn reference already,
thus it's not needed to store the device address.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-20 15:41:47 +02:00
Krishna T
9d1974ea08 net: ip: mgmt: Log the event ID for dropped events
This helps debug and fix the maximum event size allocation.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-20 15:40:02 +02:00
Krishna T
0ac7c6a32a net: ip: mgmt: Fix the maximum event size calculation
Use a union to capture all big NET event structures with a default size
of 32bytes, this makes maintenance easier.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-20 15:40:02 +02:00
Kumar Gala
fc95ec98dd smp: Convert #if to use CONFIG_MP_MAX_NUM_CPUS
Convert CONFIG_MP_NUM_CPUS to CONFIG_MP_MAX_NUM_CPUS as we work on
phasing out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-20 22:04:10 +09:00
Robert Lubos
6851a33a64 net: dhcpv4: Fix NAK processing in RENEWING state
NAK message should be processed in the RENEWING state just like in
REBINDING, not ignored.

Additinonally, NAK processing should include the rejected IP address
removal from the nework interface, otherwise the IP address will remain
on the interface indefinitely (i. e. until removed manually), which
might disturb further operation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:01:13 +02:00
Robert Lubos
80f71ff2d2 net: dhcpv4: Fix requested IP address overwrite
It could happen, that the requested IP address, stored in the dhcpv4
config structure in the network interface, could get overwritten with an
unexpected message, for example NAK from the DHCP server. In result, the
DHCPv4 module was no longer able to remove the requested address from
the network interface, as it simply no longer remembered what the
address was.

Fix this, by setting the requested address only when it's actually
provided by the DHCP server, i. e. when handling the OFFER message from
the server. Accordingly, the requested address will be cleared when the
SELECTING stage is entered, where all of the cleanups should've already
be done.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:01:13 +02:00
Ahmed Moheb
07e22abb12 bluetooth: host: id: Fix flags updated by bt_id_del()
bt_id_del() was setting the bit 'BT_KEYS_ID_PENDING_ADD' instead
of setting the bit 'BT_KEYS_ID_PENDING_DEL'

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-20 10:00:48 +02:00
Ahmed Moheb
dcfd0220b4 bluetooth: host: id: Increment IDs count only on success
Increment the number of identities after a successful execution
of id_create() by checking if the return value is 0.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-20 10:00:48 +02:00
Ahmed Moheb
0a2388c5be bluetooth: host: id: Check input arguments with CHECKIF()
Check input arguments passed to APIs with CHECKIF().

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-20 10:00:48 +02:00
Robert Lubos
43b057a7b2 net: if: Remove net_if_carrier_down function
The function is no longer used, as its functionality has been replaced
with net_if_carrier_off().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
0ac6fe913e net: virtual: Align virtual L2 with iface status upgrade
Align virtual L2 with interface state handling update. Introduce
net_virtual_enable() function, which gets called whenever a network
interface is brought up (operational). This, combined with already
existing net_virtual_disable() function, can be used to update the
carrier state on the virtual interface, based on the underlying
interface status.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
dd535f611d net: ppp: Align PPP driver/L2 with iface state upgrade
Align PPP drivers/L2 with interface state handling update. Use the
carrier on/off notification instead of bringing the interface up/down to
update the interface state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
942800784c net: netusb: Align netusb driver with iface state upgrade
Align netusb driver with interface state handling update. Instead of
bringing the interface up/down from the driver level, use carrier on/off
notification to update the inteface state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
65db65a6be net: openthread: Align OpenThread L2 with iface state upgrade
Align OpenThread L2 with interface state handling update. Use the
dormant flag to indicate whether an interface joined a Thread network.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
ec243e2553 net: bluetooth: Align Bluetooth L2 with iface state upgrade
Align Bluetooth L2 with interface state handling update. Use the dormant
flag to indicate whether interface has a Bluetooth connection or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
b279bfd2dd net: ethernet: Align Ethernet drivers/L2 with iface state upgrade
Align Ethernet/Wi-Fi drivers/L2 with interface state handling update.

For drivers, that did not support carrier detection, no changes are
needed.

Driver that did support carrier detection, are updated to set the
carrier state to OFF by default, instead of setting the
NET_IF_NO_AUTO_START flag. This allows to postopne the actual
NET_EVENT_IF_UP notification until driver detects that carrier is ready.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
89b32a0f5d net: if: Verify actual interface state instead of admin state on TX
When packet is passed to transmit at the net_if level, verify the
carrier state (NET_IF_LOWER_UP) instead of administrative state
(NET_IF_UP).

The administrative state is checked anyway at higher level (net_context)
so no need to verify it again. This will allow to still transmit control
packets for example when interface is in a dormant state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
efd03a86d7 net: if: Introduce carrier and dormant management on a network iface
Introduce a new interface state management scheme, according to
RFC 2863. This includes the following changes:

* Introduce a new interface flag: NET_IF_LOWER_UP, along with
  corresponding helper functions. The flag should be set/cleared on an
  interface by a network driver/L2 to signalize physical readiness of an
  interface to transmit data (for example cable plugged in).

* Introduce a new interface flag: NET_IF_DORMANT, along with
  corresponding helper functions. The flag should be set on an
  iterface when the interface is not ready to transmit application data,
  for example still not joined a Wi-Fi network.

* Introduce a new interface flag: NET_IF_RUNNING, indicating that
  interface is ready to transmit application data.

* Update the meaning of the NET_IF_UP flag - it now singnalizes whether
  an interface has been brought up/down by the application (admin
  up/down).

* Introduce operational state of an interface, derived from above. It
  reflects the internal interface state.

The meaning of net_if_is_up() function and NET_EVENT_IF_UP/DOWN events
remains unchanged to retain backward compability - they reflect the
interface readiness to transmit application data.

To verify the administrative up/down state, a new function
net_if_is_admin_up() has been introduced, along with
NET_EVENT_IF_ADMIN_UP/DOWN events.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos
04fce39e03 net: if: Fix if down handling for all offloaded interfaces
Socket offloading was not taken into consideration when network
interface was put down. Fix this by introducing a helper function, to
verify whether an interface is offloaded or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Aleksander Wasaznik
046f531a6e Bluetooth: Host: Document bt_irk.rpa
Document `bt_irk.rpa` as "Cache for `bt_keys_find_irk`. Not reliable as
"current RPA"!".

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-20 10:17:04 +03:00
Robert Lubos
c27a6af712 net: zperf: Add QoS support
Improve the zperf upload/upload2 commands, by allowing to specify
DSCP/ECP fields for outgoing packets. The introduced -S option is
compatible with Linux iperf3 utility.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
d437f950db net: shell: Allow for ping arguments to be specified in hex
Improve the parse_arg() helper function used with shell ping command,
by allowing to parse arguments provided in hex.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
9e38a3ec48 net: shell: Add support for ping -Q parameter (Quality of Service)
Add new option to the net shell ping command, which allows to specify
the DSCP/ECN values for an outgoing ping request. The option is
compatible with Linux ping command.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
45ce047605 net: icmpv6: Allow to specify DSCP and ECN values in ping
Add support for setting DSCP/ECN values for an outgoing ping request.
Additionally, copy DSCP/ECN values from an incoming ping request into
the ping response, like Linux does.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
38aff54961 net: icmpv4: Allow to specify DSCP and ECN values in ping
Add support for setting DSCP/ECN values for an outgoing ping request.
Additionally, copy DSCP/ECN values from an incoming ping request into
the ping response, like Linux does.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
618fa8d665 net: sockets: Add options to control DSCP/ECN value
Add new socket options IP_TOS and IPV6_TCLASS which allows to set
DSCP/ECN values on a socket for an outgoing packet IPv4/IPv6 headers.

The options are compatible with Linux behaviour, where both DSCP and ECN
are set with a single socket option.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
d28a72ed9e net: sockets: Add missing break statement in setsockopt
SOL_SOCKET and IPPROTO_TCP levels were missing the break statement at
the end of their processing logic, which could cause unexpected
fallthrough on unhandled optname value.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
c868018c3c net: context: Add DSCP/ECN support
Add a new net_context option, which allows to set DSCP/ECN values on a
net context. Those values are then encoded into outgoing packet
IPv4/IPv6 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
c7af28b9af net: ipv6: Add support for setting/reading DSCP/ECN fields (TC)
Encode/decode recently added DSCP/ECN fields into/from IPv6 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
5c10f6f9d6 net: ipv4: Add support for setting/reading DSCP/ECN fields (ToS)
Encode/decode recently added DSCP/ECN values into/from IPv4 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos
c5096f4ca1 net: pkt: Add IP DSCP/ECN information to a packet structure
Add new fields to the net_pkt structure, representing IP-specific
Differentiated services code point (DSCP) and Explicit Congestion
Notification (ECN) values. Those values are encoded in legacy
Type of Service (IPv4) and Trafic Class (IPv6) header fields.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Emil Gydesen
4f78655915 Bluetooth: Audio: Add check when registering media_proxy_pl_calls
Add NULL checks when registering the media_proxy_pl_calls.
Currently the media player expects all of them to be set.

In the future, ideally the callbacks would mostly be
optional and reflect which of the optional
characteristics that there is in the MCS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-19 16:05:46 +02:00
Emil Gydesen
e45eff3e10 Bluetooth: Audio: Add missing commands supported callback for MCS
When registering the media player, we were missing a callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-19 16:05:46 +02:00
Pavel Vasilyev
cf701acb94 Bluetooth: Mesh: Convert model_ackd_send and model_send to a common API
Convert model_ackd_send and model_send from health_cli.c to a common API
to get rid of code duplication in other client models that implement
synchronous messages' sending.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-19 16:05:16 +02:00
Øyvind Rønningstad
1e88e7cc9b lwm2m_senml_cbor.patch: Update patch file to match current changes
File created by commiting changes and running

  git diff HEAD~1.. > lwm2m_senml_cbor.patch

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad
8b295bc58c lwm2m_senml: Regenerate cbor code using zcbor
Also do clang-format and apply patch.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad
7b05569d49 lwm2m_senml_cbor_regenerate.sh: Fix argument order in zcbor call
zcbor 0.6.0 has changed the argument order to put code/convert/validate
first.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad
f8d0c8a43f lwm2m_senml_cbor_regenerate.sh: Use git am instead of git apply
Since it's better at resolving conflicts.
Commit regenerated files before applying patch.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Mariusz Skamra
54d1e15b71 Bluetooth: audio: ascs: Make ascs_ep_set_metadata static
This changes ascs_ep_set_metadata to be static as it's not used outside
of ascs.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-19 16:00:33 +02:00
Mariusz Skamra
fc398ac33f Bluetooth: audio: pacs: Fix redundant CCCD attribute without location
This removes the CCCD that was added even if location attribute was not
there.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-19 16:00:21 +02:00
Aleksander Wasaznik
17fc4b811c Bluetooth: Replace 'bt_addr_le_cmp(x) != 0' with 'bt_addr_le_eq(x)'
These should be equivalent. The '_eq'-form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Aleksander Wasaznik
ea558187b5 Bluetooth: Replace bt_addr_le_cmp in bool context with !bt_addr_le_eq
These should be equivalent. The new form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Aleksander Wasaznik
21e5dcb42a Bluetooth: Replace 'bt_addr_le_cmp(x) == 0' with 'bt_addr_le_eq(x)'
These should be equivalent. The '_eq'-form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Aleksander Wasaznik
9db3fa82d1 Bluetooth: Replace all '!bt_addr_le_cmp' with 'bt_addr_le_eq'
There should be functional equivalence between these two forms. And the
'_eq'-form is more readable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Mariusz Skamra
9973d2f1f7 Bluetooth: audio: Factor out PACS related API to internal header
This moves the PACS API to internal header, as it duplicates the
bt_capabilities API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-18 14:14:19 +02:00
Tom Burdick
872e3553f9 kernel: Option to assert on spin lock time
Spin locks held for any lengthy duration prevent interrupts and
in a real time system where interrupts drive tasks this can be
problematic. Add an option to assert if a spin lock is held for
a duration longer than the configurable number of microseconds.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-18 14:14:12 +02:00
Emil Gydesen
4321fef3b7 Bluetooth: Audio: Ensure that stream is in streaming state for ISO recv
Adds check to verify that the audio stream is actually
in the streaming state before handling the
audio data. As per the BAP spec, a stream that
is not in the streaming state shall not send
any data, and this check is to handle any
remote devices that are not working correctly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-18 14:13:51 +02:00
Dominik Ermel
7089f94be9 mgmt/mcumgr: Deprecate zephyr_ prefixed API
The zephyr_ prefixed functions have been marked __deprecated.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel
79f105d778 mgmt/mcumgr: Drop zst_ prefix from smp_transport members
With dropping the zephyr_ prefix, the member prefix zst_ makes
no sense.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel
71e498dbd2 mgmt/mcumgr: Rename zst pointers to smp_transport to smpt
Cosmetic change: the zst was short for zephyr_smp_transport,
now it is just smp_transport so smpt makes more sense.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel
a7e40b35f0 mgmt/mcumgr: Drop zephyr_ prefix from functions
The MCUMgr library is now part of Zephyr, so there is no point
to prefix SMP functions with Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Veijo Pesonen
33453e1135 lwm2m: fails if incorrect registration reply
No need to proceed if registration reply parsing fails.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-10-17 20:06:32 +02:00
Florian Grandel
b674ed6b8b net: pkt: decouple from ieee802154 internals
This change implements part two of the program laid out in the TSCH RFC,
see #50336#issuecomment-1250250154 :

> Consolidate IEEE 802.15.4 options in net_pkt

This change improves decoupling of generic net core code from
IEEE 802.15.4 internals. It also simplifies IEEE 802.15.4
attribute cloning and thereby makes it easier to maintain and less
error prone (and probably even faster as individual bits are no longer
copied over separately).

This enables us to extend and design IEEE 802.15.4 L2 attributes inside
the package in isolation from the net core code which will no longer
have to be changed when introducing changes or additions to the flags.

This flexibility will be built upon in later change sets to model the
IEEE 802.15.4 attributes closer to the spec.

The solution is inspired by Linux's sk_buff->cb attribute which addresses
the same concern as the attribute introduced in this change set:
https://elixir.bootlin.com/linux/v6.0.1/source/include/linux/skbuff.h#L871

As the inline comment says: The cb attribute can be made a union or even a
uint8[something] in the future, if further L2s need a control block, too.
Right now such full indirection would make the code overly abstract, so
I chose to compromise with maintainability in mind.

Care has been taken to ensure that this changes does not introduce
additional padding into the net package. To maintain zero-padding, future
changes to the net packet struct will have to ensure that the
IEEE 802.15.4 struct is 4-byte aligned (iff the IEEE 802.15.4 struct
continues with max uint32_t scalar members) which is no deviation from
the previous implementation.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel
0b94947d33 net: l2: ieee802154: set ll protocol in pkt
The IEEE 802.15.4 L2 now sets the ll protocol in the packet to a
specific value. This corresponds to the respective solution in Linux and
is required to validate access to IEEE 802.15.4 specific attributes of
the packet.

Later change sets will rely on this value to ensure that IEEE 802.15.4
specific package content can only be accessed on IEEE 802.15.4 packages.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel
389bd57753 net: ip: fix and consolidate cloning of ll addr
The net packet structure contains pointers to link-layer source and
destination addresses. Usually, these structures do not point to
separately allocated memory but directly into the packet's data buffer.

In case of a deep package clone (which includes copying the buffer) the
copy of the ll addresses continued to point into the old package
(contrary to a rather misleading inline comment). This was proven by an
additional failing unit test assertion.

As the original package may be unreferenced while the cloned package is
still being accessed, the ll address pointers of the cloned package may
become invalid.

The fix consists of two parts:
 * First it is determined whether a given ll address actually points into
   the buffer and if so at which logical cursor offset it is located.
 * If the address points into the package buffer then the cursor API is
   used to determine the corresponding physical memory location in the
   cloned package. The ll address of the cloned package is then patched
   to point to the cloned buffer.

Additional assertions were introduced to the existing unit test to ensure
that the newly generated address points to the correct content of the
cloned package.

The solution is implemented in a generic way so that the previously
redundant implementations were consolidated into a single one. The code
includes a check that ensures that the ll address check and manipulation
will be skipped in case of shallow package copies.

The change also addresses problems related to the "overwrite" flag of the
package:
 * Package cloning assumes the overwrite flag to be set. Otherwise it
   will not work correctly. This was not ensured inside the clone method.
 * Package cloning manipulates the overwrite flag of the cloned package
   but does not reset it to represent the same state as the original
   package.

The change introduces a fix and unit test assertions for both problems.

Fixes: #51265

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel
f1e9dd2930 drivers: ieee802154: properly announce promisc mode
Most IEEE 802.15.4 drivers do not support promiscuous mode, some do.
There is a dedicated L2 flag to signal this capability to clients.

Unfortunately the IEEE 802.15.4 L2 stack does not announce this flag
even for drivers that correctly expose it in their HW capabilities.
Some clients (notably the OpenThread L2) even uses promiscuous mode
without checking whether the driver actually supports it.

This change lets the vanilla IEEE 802.15.4 L2 check the driver's
HW capabilities to announce promiscuous mode on its 'get_flags()'
interface if supported.

The OpenThread L2 uses a constant (potentially incorrect) response
to 'get_flags()'. Fixing the OpenThread L2 is out of scope of this
change. This change just introduces TODO messages to the OpenThread code
so that the OpenThread team may fix the issue (or delete the TODO if they
deem it irrelevant).

Fixes: #51263

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Gerard Marull-Paretas
178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Emil Obalski
45f0fb1970 ipc: Add deregister API support for icmsg backend
Add support for deregister_endpoint IPC service API
in icmsg backend.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2022-10-17 14:49:42 +02:00
Pavel Vasilyev
93e6f73d62 Bluetooth: Mesh: Change linkage for ctx_shell and default_key in shell
Change linkage for ctx_shell and default_key in shell.c to external to
share their usage in other places.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
73c5568b5c Bluetooth: Mesh: Remove _cli postfix from models shell files
This commits renames `health_cli.c` and `cfg_cli.c` under `mesh/shell`
folder to `health.c` and `cfg.c` accordingly. This is to create a
generic pattern for the future, when not only clients, but server models
will also expose some API through shell commands. This means that server
models' shell commands should be located in the same file as client
commands to avoid cluttering `mesh models` subcommand.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
f93ab2769c Bluetooth: Mesh: Add macro for instance set/get-all mesh shell cmds
This code is a boulerplate that will be needed for many models in mesh
shell module. This commit adds a special macro designed to improve
readability of the code and helps to avoid potential bugs when
copy-pasting identical code.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
8e5ff49118 Bluetooth: Mesh: Make mesh features pluggable in shell
Not all shell commands may be needed for an end application even if a
certain feature is enabled. In that case they will just occupy flash
space without being used. This commit adds a separate Kconfig for each
feature to make possible to selectively disable some mesh shell commands.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
559e526708 Bluetooth: Mesh: Add options to disable health and cfg clients shell
Add Kconfig options to be able to disable Health and Config Client
models shell commands.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Pavel Vasilyev
f9c4872ce4 Bluetooth: Mesh: Move mesh shell Kconfig options to a separate file
Move mesh shell related options to a new file to avoid cluttering of
the main Bluetooth Mesh Kconfig file when extending it with new options.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-17 14:39:58 +02:00
Francois Ramu
f37ebf48ec include: add missing kernel.h for lorawan subsys
Header lora.h and lorawan.c files make use of types defined
in kernel.h without including it.
The types.h is no more relevant with inclusion of kernel.h
Explicitely including <stdint.h>, even if the kernel.h includes
the stdint.h, this is an implementation detail. "If Kernel
decides one day to drop usage of stdint.h (unlikely),
lora.h users be in trouble."

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-10-17 18:10:10 +09:00
Krzysztof Chruscinski
af573dbffb logging: Add ipc_service log link
Added link that sends messages over ipc_service. It uses
log_link_remote and will talk to log_backend_ipc_service based
on log_link_backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
b01867812e logging: Add ipc_service log backend
Added backend that sends messages over ipc_service. It uses
log_backend_remote and will talk to log_link_ipc_service based
on log_link_remote.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
6c785b5677 logging: Add remote link and backend
Added implementation of link and backend that are intended to
complement each other. Both requires transport function hooks
to be provided.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
050378ab39 logging: log_output: Adapt to multidomain support
Add support to multidomain case where source field contains
ID and not address of the source structure.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
e322447109 logging: Initial multidomain support
Adding multidomain support by introducing log_link module which
acts as a receiver of log messages created by another domain.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
1b3a12ce8e logging: Add log_cache module for caching remote names
log_cache is capable of storing fixed length byte arrays
identified by a generic ID. If entry identified by given ID
is not found in cache, the least recently used entry is evicted
from cache.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Sean Madigan
5b1dd71f3e Bluetooth: kconfig: Add config options for PAST
Add config options specific for periodic advertising sync transfer.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2022-10-17 10:14:10 +02:00
Andy Ross
45ea83af89 subsys/cmsis_v*: Fix racy mutex testing, decouple from k_mutex
The cmsis implementations of osMutex was trying to inspect internal
k_mutex state (the owner and lock count) in the process of trying to
acquire the lock.  This is unfixably racy, by definition other
contexts will be trying to do the same on the unsynchronized data.

As far as I can tell, the only purpose was to be able to synthesize
osMutex's specified error behavior, which we can do with the existing
return codes from k_mutex_lock().  Add similar logic to osSemaphore,
which didn't have the race but was likewise abusing access to kernel
internals.

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Andy Ross
13f78fb005 bluetooth: Don't use k_sem internals
The "limit" field of struct k_sem was in use in two places in the BTLE
host code, in one it was being used as a duplicate placeholder for the
"iso_max_num" field received in read_buffer_size_v2_complete[1].  In
another, it was just being tested for zero[2].

Those are pretty clear abuses of internal data, provide minimal value
beyond a few bytes of memory in struct bt_dev_le, and in any case
won't work with zync, where that field doesn't have the same name and
may not even exist depending on app configuration.

Copy the limit value into the struct where it belongs, and use it from
there.

[1] I strongly suspect there is a bug lurking there if the semaphore
maximum is being used to implement the kind of "packet buffer" this
code looks like.  Calling k_sem_give() on a "full" semaphore WILL NOT
BLOCK.  It will just drop the increment on the floor and return
synchronously.  Semaphores aren't msgqs or ringbuffers!  But disabling
the max value feature in zync does not result in test failures, so
maybe this usage is safe.

[2] Again, this seems suspicious; a valid k_sem should never have a
zero in that field.  Presumably this is really a test for "is
initialized", and so implies there's a mixed up initialization path
somewhere?

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Andy Ross
bd063d1a9e net/ethernet/bridge: Fix k_mutex initialization
The bridge subsystem was written with a ETH_BRIDGE_INITIALIZER that
assumed it could initialize a k_mutex with a zero-filled initializer.
That never worked.  Unlike semaphores, mutexes have always required a
runtime call to k_mutex_init().  What happened instead is that
k_mutex_un/lock() returned error codes, which were ignored by the code
here.  So no locking was happening.

This was discovered while migrating to zync, where an attempt to
unlock an unlocked mutex is a panic condition (and where zero-filled
initializers are legal, but represent an unfair semaphore and not a
mutex, so deadlock correctly).

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Andy Ross
95101e6890 net/route: Add missing lock in net_route_mcast_add()
This is a public API for the subsystem, can be called from app
context, unlocks the local k_mutex on one of its three exit paths, and
it's quite clear that nothing ever locks that mutex!

The code used to work because k_mutex simply returned an error if you
tried to unlock an unlocked object.  Now zync will panic (when
CONFIG_ZYNC_VALIDATE=y) if you try that.

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Piotr Pryga
6a79c3deae Bluetooh: Host: conn: Resume adv after disconn for periph role only
Zephyrs Host has by default enabled automatic resume of advertising
in case of disconnection when peripheral role is enabled.

The feature becomes a bit problematic in case of multirole usage.
For example assume a use case where a device is working as peripheral
and central, where it may establish single connection for each role.

In case there are two connections established and connection in
central role is dropped by peer, Host will automatically resume
advertising. After that an application can resume scanning, e.g.
in disconnected callback. That should not happen.

If one of connections was used for central role, it should not
be stolen by Host to run peripheral role. Host should verify
if a disconnected connection role was peripheral and then resume
advertising.

This approach will not break backward compatibility and change
correct resume behavior. What more, Host will follow an application
decisions about use of connection objects.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-17 10:06:45 +02:00
Kumar Gala
c778eb2a56 smp: Move arrays to use CONFIG_MP_MAX_NUM_CPUS
Move to use CONFIG_MP_MAX_NUM_CPUS for array size declarations instead
of CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-17 14:40:12 +09:00
Emil Gydesen
0af4aad4bf Bluetooth: Audio: Remove call to bt_enable in audio init
The `audio init` should only initialize the audio (BAP)
stack. Furthermore, given that the `bt init` may do more
than just calling `bt_enable` it is generally for the best,
and more future proof, to let that command be the exclusive
way of calling `bt_enable` in the shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 14:24:20 +02:00
Emil Gydesen
e4b640ff2b Bluetooth: Audio: Fix segmentation issue in BT Audio shell
It was possible to enter a state where setting the QoS
for a source stream after having released a sink stream
as the unicast client would cause a segmentation error.
This issue is related to how the unicast shell is using
the unicast group.

A fix has been added for it, and a check for
whether or not `audio init` (to register the needed
callback) has been added. This check has also been added
for the broadcast sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 14:24:20 +02:00
Jukka Rissanen
cf24ebcc1f net: dns: Always init the resolver
If user has not specified any DNS servers in
CONFIG_DNS_SERVER_IP_ADDRESSES, then the DNS resolver will not be
initialized properly. So fix this by always calling dns_resolve_init()
so that DNS mutex get properly initialized.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2022-10-14 09:57:09 +02:00
Troels Nilsson
06aa981611 Bluetooth: controller: Support split advertising PDU pools
Adds proper support for having more than one PDU pool for the advertising
PDUs (to save memory)

- Introduces lll_adv_aux_data_init, lll_adv_aux_scan_rsp_alloc and
  lll_adv_sync_data_init to indicate if the PDU is a primary/legacy PDU
  or secondary/auxillary PDU
- Scan response PDUs are initialized later, since the correct pool to draw
  from depends on whether the advertising is extended or legacy

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-10-14 09:56:00 +02:00
Gerard Marull-Paretas
eda9689789 shell: device_service: add missing EARLY init level
The device_service shell was missing the capability to list devices
registered in the EARLY init level.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-14 09:55:48 +02:00
Kim Sekkelund
a83b4f9d06 Bluetooth: Audio: Fix endian conversion in PACS
Not all C compilers understands how to use the address of a return
value as an argument to a function call. At least not our compiler.
Fix the issue by adding a variable to hold the converted value
before passing it to the function call.

Signed-off-by: Kim Sekkelund <ksek@oticon.com>
2022-10-14 09:55:26 +02:00
Gaël PORTAY
6dedea7c16 wifi: shell: Move closing bracket after type enumeration
This fixes the output below by moving the closing bracket to "<Security
type (optional: valid only for secure SSIDs)>" after the enumeration of
security types "0:None, 1:PSK, 2:PSK-256, 3:SAE".

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP
	               "<SSID>"
	               <channel number (optional), 0 means all>
	               <PSK (optional: valid only for secure SSIDs)>
	               <Security type (optional: valid only for secure SSIDs)>
	                                              v----------------------^
	               0:None, 1:PSK, 2:PSK-256, 3:SAE
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
f7dfae5730 wifi: shell: Indent second parameter to new line
Return to line after the first parameter to:
- have the second parameter in a single line (not splitted) and
- start every parameters from a brand new line (easier to read)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
ff077aafe9 wifi: shell: Add missing bracket
This fixes the output below by adding the missing closing bracket to
"<MFP (optional): 0:Disable, 1:Optional, 2:Required":

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP
	               "<SSID>"
	               <channel number (optional), 0 means all>
	               <PSK (optional: valid only for secure SSIDs)>
	               <Security type (optional: valid only for secure SSIDs)>
	               0:None, 1:PSK, 2:PSK-256, 3:SAE
	               <MFP (optional): 0:Disable, 1:Optional, 2:Required
	               ^-------------------------------------------------^
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
b177911a4d wifi: shell: Add missing end of line
This fixes the output below by returning to line after "Connect to a
Wi-Fi AP":

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP"<SSID>"
	                                    ^------^
	               <channel number (optional), 0 means all>
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Emil Gydesen
23562448dc Bluetooth: Audio: Fix reset PAC records on bt_audio_discover
When calling bt_audio_discover, the discovered PAC records
were just added to the pac_cache. If called multiple times,
the PAC records would just be duplicated.

This change reset the pac records for the direction when
called.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:57 +02:00
Emil Gydesen
f307c08331 Bluetooth: Audio: Add additional check and log for stream->conn
bt_audio_stream_config should not be called with a stream
that is already configured to another connection.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:43 +02:00
Emil Gydesen
bd773158e1 Bluetooth: PACS: Add PAC records to the debug log
Logs the PAC records with BT_DBG for easier debugging
of the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:36 +02:00
Emil Gydesen
59a9dd6054 Bluetooth: Audio: Add misisng stream_count reset for broadcast sink
This caused the sink to attempt to sync to more stream
for each call to bt_audio_broadcast_sink_sync as the
stream count was stored in the struct bt_audio_broadcast_sink
but never reset.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:23 +02:00
Emil Gydesen
65f130b73e Bluetooth: Audio: add missing CONFIG_BT_AUDIO_DEBUG_STREAM_DATA guards
Some places did not properly guard debug messages for sending
ISO data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:53:11 +02:00
Emil Gydesen
0f30fbec96 Bluetooth: Audio: Increase unicast client Kconfig ranges
There is no reason for the previous limitation.

The limit of 255 for the ASEs is based on the ASE IDs
which is a uint8_t, so there is a maximum of 255 of
each ASE type.

The limit of 73 * 2 = 146 is based on the maximum size of an
GATT attribute (512), and the minimum size of a PAC record (7)
makes it a total of 73 PAC records for each direction.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:52:56 +02:00
Andries Kruithof
eb78f9f808 Bluetooth: controller: llcp: fix access to context after release
There is access to the procedure context after a potential release
of the context, which (in theory) can lead to incorrect behaviour

There is no good way of testing this with a unittest without adding
specal debug code to the ull_llcp_local module
After code-inspection no other location has been found with
potential access after context release

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-10-14 09:52:41 +02:00
Emil Gydesen
7ab1cafbc2 Bluetooth: Audio: Add Broadcast source application AD
This refactors how the BAP broadcast source handles the
extended and periodic advertising.

First it removes the start and stop of the extended
advertising, and instead expects the application
(or upper layers) to do this.

Second it exposes API functions to get the
necessary advertising data from BAP (service data and
the BASE), which the upper layers will then also
be responsible for setting and updating.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:51:39 +02:00
Emil Gydesen
cb4541ae51 Bluetooth: Audio: Fix missing metadata_updated calls
The metadataa_updated callback has existed for a long
time, but was never actually used. The metadata is set
or updated in the enabling and streaming state.

Added checks to see if the state actually changes when going
into these states, and if not, then it means that the
metadata was updated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:51:23 +02:00
Andreas Müller
b0e76dbf35 net: shell: fix memory leak in udp_rcvd()
Without pkt_unref(), the shell command "net udp bind" will fail to
receive after a few packets ("net allocs" shows that memory is still
allocated).

Signed-off-by: Andreas Müller <andreas.mueller@husqvarnagroup.com>
2022-10-13 17:10:28 +02:00
Mariusz Skamra
d44e112045 Bluetooth: audio: ascs: Remove unused bt_ascs member
Remove unused struct member.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-13 16:03:34 +02:00
Andrei Emeltchenko
ab2594e313 shell: devmem: Update help string for devmem
Update help string to make it more clear.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-10-13 08:00:52 -04:00
Andrei Emeltchenko
1ff34e234c shell: devmem: Fix help for devmem module
Fixes devmem help string shown below:

uart:~$ devmem -h
devmem - Read/write physical memory"devmem address [width [value]]

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-10-13 08:00:52 -04:00
Yuval Peress
4f75848e71 ztest: fix grammar for errors in bad test phases
Addresses the comments in #48846 regarding the error messages

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-13 06:40:31 -04:00
Yuval Peress
a40a2f5c50 ztest: make failed assumptions fail test binary
Adding the new Kconfig (enabled by default) to make a failed assumption
mark the final result as failed. This change has the following benefits
which have been asked for by the Zephyr community:
1. A failed assumption does not go silent. In this example, the failed
   assumption will still mark the test as skipped, but the final result
   will be to mark the full test run as failed. This would allow
   blocking the CI when an assume fails.
2. Normal test skipping via the ztest_test_skip() is unaffected by this
   change. Those tests will be marked as skipped, but the binary will
   still pass.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-13 06:40:31 -04:00
Emil Gydesen
0dc9f57fa5 Bluetooth: Audio: Fix bad error check for bt_unicast_client_start
If bt_audio_stream_connect didn't fail, we would just return
without sending the receive start ready command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-13 09:57:24 +02:00
Lingao Meng
4a2033a661 Bluetooth: Mesh: net cache uses reverse order traversal
Since the net cache is accumulated in positive order, the net
cache uses reverse order traversal, which can filter duplicate
messages more effectively.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-13 09:56:50 +02:00
Lingao Meng
5867492582 Bluetooth: Mesh: Fix missing clear dup cache
When lpn reject message, should clear dup cache to
avoid dup check next mesh message.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-13 09:56:50 +02:00
Lingao Meng
4f1e326f2a Bluetooth: Mesh: Remove msg_cache_next in rx ctx
Since in bt_mesh_net_recv will call msg_cache_add
and if lpn reject this message, should remove this cache.

But this function sequentially and will not be interrupt
by any thread so, we no need a copy var to save this value.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-13 09:56:50 +02:00
Peter Tönz
46a59124dc net: lwm2m: Fix seg-faults if a socket was closed in the meantime
Our application (posix-naive/debug) ran into segmentaion faults,
because the socket was closed between the "wait for sockets" and the
second if in the first loop. Added the check also to line 690
and 720.
The other uses of sock_ctx[i] are already checked against NULL

Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
2022-10-12 18:42:41 +02:00
Piotr Pryga
c2ea0328fa Bluetooth: Controller: df: Fix spelling errors
Fix spelling errors in coments in ull_df.c source file.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-12 18:41:54 +02:00
Piotr Pryga
3987259888 Bluetooth: Controller: df: Relax cl CTE RX enable param check
According to Core 5.3 Vol 4, Part E, section 7.8.82 slot_durations,
switch_pattern_len and ant_ids are used only for AoA and do not affect
reception of AoD CTE.

To improve interoperability checking of correctness of these parameters
is not required. It will not affect lower link layer in case the AoA
CTE reception feature is not enabled in Kconfig.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-12 18:41:54 +02:00
Mariusz Skamra
9c3f190721 Bluetooth: audio: capabilities: Hide bt_audio_capability_get function
This function exposes list pointer, so that it allows the user to modify
the internal list. This adds bt_audio_foreach_capability iterator finction
that can be used instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-12 18:41:22 +02:00
Florian Grandel
580d789cd0 net: l2: ieee802154: fix frame type field check
The LLDN frame has been obsoleted in IEEE 802.15.4-2015f. This change
removes it from the code, introduces frame types from current spec
levels and updates the frame validation rules in accordance with the
spec.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
14c608e9c4 net: l2: ieee802154: improved context thread safety
Several attributes in the ieee802154_context struct may potentially be
accessed from different threads and/or ISR context. Only some of these
attributes were properly guarded against race conditions.

This may not have been to problematic in the past but as other changes
in this PR introduce additional attributes and mutate several attributes
in a single atomic transaction, leaving such changes unprotected seems
dangerous.

This change therefore introduces systematic locking of the
ieee802154_context structure.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
6a6b89516d net: l2: ieee802154: improve short address support
IEEE 802.15.4 short address support is incomplete in several places.
This change improves short address support without claiming to fix
it everywhere. Future iterations will have to continue where this change
leaves off.

The purpose of this change was to:
 * use the short address returned by association responses,
 * automatically bind IEEE 802.15.4 datagram sockets to the short
   address if available,
 * use the short address in outgoing packages where applicable,
 * improve validation of association/disassociation frames,
 * model association more closely to the spec by tying it to the
   existence of a short address in the MAC PIB thereby removing
   redundancy in the PIB (which makes race conditions less probable),
 * keep both, the short and extended addresses, of the coordinator.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
bff6a5cce5 net: l2: ieee802154: fix short/ext address endianness
This changes fixes several bugs and inconsistencies in the IEEE 802.15.4
L2 implementation. These bugs were revealed while documenting intended
endianness of driver, IP, socket and L2 attributes (see previous
changes).

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
b951f062f5 net: l2: ieee802154: add short address to ll address
This is a preparatory change that fixes one aspect of short address
handling before fixing endianness so that the endianness fix can be
applied consistently in this method.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
34999a8b3e net: l2: ieee802154: document endianness
The IEEE 802.15.4 L2 code stores representation of attributes like
PAN id, short address and extended address in different encodings:

* big endian for extended address and CPU byte order for everything
  else whenever such attributes enter user space (except for IP/socket
  link layer addresses which are always big endian - even in case of
  short addresses - to maintain POSIX compatibility).

* little endian for everything that is close to the radio driver as
  IEEE 802.15.4 frames are little endian encoded.

Endianness was almost nowhere documented which led to several bugs and
inconsistencies where assignments of different byte order were not
converted (or sometimes converted, sometimes not).

This change documents endianness wherever possible within the realm of
the IEEE 802.15.4 L2 code. Conversion bugs and inconsistencies that were
revealed by the improved documentation will be fixed in a separate
commit.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel
7ea6cc99ce net: ip: fix minor formatting glitch
This changes just fixes an erroneous indentation from a previous patch.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Christopher Friedt
dbe2c0d59e include: net: http: rename http_x.h http/x.h
Some minor housekeeping prior to adding an http server
implementation. There are already a number of http headers
and that number will likely increase with subsequent work.
Moving them into a common directory cleans up the
`include/net` directory a bit.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2022-10-12 09:02:21 -04:00
Gerard Marull-Paretas
e5eade32e2 shell: device_service: fix MISRA 5.7 violation
Changes in device_service have triggered MISRA 5.7 violation CI error
(Tag name should be unique). Renamed shell to sh, same as some other
modules.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas
495245a971 init: remove _SYS_INIT_LEVEL* definitions
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Dominik Ermel
3d367ae8b4 mgmt/mcumgr: Remove MGMT_MAX_MTU from mgmt.h
Not used anywhere, MTU depends on transport.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-12 18:48:25 +09:00
Andrzej Głąbek
6ae66cc13d net: pkt: Allow compilation with custom IEEE 802.15.4 based L2
This is a follow up to commit bb86f8b967.

Also custom IEEE 802.15.4 based L2 implementations may need to use
packet handling without the IP layer. Add support for such cases.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-10-12 18:46:09 +09:00
Peter Tönz
a868da8568 net: lwm2m: Fix buffer overflow by using CONFIG_LWM2M_VERSION_1_0
By using CONFIG_LWM2M_VERSION_1_0, the function
lwm2m_engine_get_binding() returns the binding
and the queue mode bytes. Therefore the buffer
must be tree bytes long.
The issue is caused by the two inconsistent defines:

lwm2m_registry.c:
    #define BINDING_OPT_MAX_LEN 3 /* "UQ" */
lwm2m_rd_client.c:
    #define CLIENT_BINDING_LEN sizeof("U")

Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
2022-10-12 18:45:50 +09:00
Henrik Brix Andersen
b219b5cba7 stats: shell: enable the stats shell if both stats and shell are enabled
Enable the statistics subsystem shell by default if both statistics and
shell are enabled.

Have the statistics shell imply enabling named statistics as this takes out
a lot of guesswork regarding which statistics counter is which.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-12 06:46:34 +02:00
Gerard Marull-Paretas
b959ab25a9 include: add missing sys/slist.h include
Some headers makes use of slists w/o including sys/slist.h

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
3976ccd5f7 include: add missing sys/printk.h include
Some files were using the printk API without including sys/printk.h

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
e63b0bb3fe include: add missing errno.h include
With the incoming removal of kernel.h/types.h from init.h, lots of files
start to show compile errors because they relied on indirect
definitions, including errno.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas
34a6848887 include: add missing arch/cpu.h include
The sys* ops like sys_clear_bit are indirectly included via arch CPU
header. Other stuff like find_msb_set end up included via this header as
well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Anas Nashif
46af0620b3 console: move winstream console to drivers/
This was all done as part of the soc and called from the soc. Define
this type of console under drivers/console and use it in the SoCs
supporting that via SYS_INIT instead of calling the console code
directly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 08:28:25 -04:00
Jamie McCrae
cfd657fcec mgmt: mcumgr: Add fs_mgmt log output workaround on file write
If a file write was attempted with a file that does not exist, over
the shell/UART when logging was enabled, it would output a fs_unlink
error, this works around the issue by checking if the file exists and
needs truncating before performing that action. It also imrproves
flash endurance slightly by performing a truncate operation instead
of a delete, but will fall back to a delete if the truncation
operation fails. This issue can be also be mitigated by altering
logging settings or adjusting the SMP thread priority.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-11 11:15:02 +02:00
Seppo Takalo
d454cc946e net: lwm2m: Add helper macro for filling lwm2m_obj_path structs
Allows filling up struct lwm2m_obj_path by a macro.
For example:
  struct lwm2m_obj_path p1 = LWM2M_OBJ(MY_OBJ);
  struct lwm2m_obj_path p2 = LWM2M_OBJ(MY_OBJ, 0, RESOURCE);

Similarly, some function calls accept the structure, so it can
be initialized from stack and given by a pointer
  lwm2m_notify_observer_path(&LWM2M_OBJ(obj_id, 0, RESOURCE_ID));

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:14:31 +02:00
Dominik Ermel
c759eb0a93 mgmt/mcumgr: Remove net_buf_pool_get call from zephyr_smp_alloc_rsp
It was pointless and nothing has been done with a result.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-11 11:14:22 +02:00
Seppo Takalo
65c084f9e5 net: lwm2m: Don't close the socket context on callbacks
I need to register a service for the pull-context so I can
safely close the socket context. Otherwise the socket loop
would crash, because context would be closed while going through
the list where it was located.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
d49219aede net: lwm2m: Block on semaphose waiting
Minor change, the semaphore is freed by a caller so it was always
free, but just for being correct, it should be a blocking call,
so any errors would clearly block.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
b72fde1f54 net: lwm2m: Remove second layer or rettrying from pull handler
CoAP layer handles retrying so having a second layer of retry
in the pull-context does not make sense. If we need more retrying
it should be done in CoAP layer.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
4ec698004c net: lwm2m: Set FOTA state correctly on URI write
When URI is written, we must first set the state to DOWNLOADING
so when any error happens on the initialization phase, the
result written on a callbacks are correctly reflected and the state
changes correctly IDLE -> DOWNLOADING -> IDLE (result written).

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo
99ebcefc71 net: lib: lwm2m: Add shell commands for lock and unlock
Allowing locking the registry from commandline allows
us to test composite observation and observation of
object instances, etc. where multiple values are changed
before the notify message triggers.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:12:20 +02:00
Daniel Leung
90456c94f7 logging: workaround hard fault on Cortex-M0 with sys-t/catalog.
For some reason, running sys-t with catalog message on
Cortex-M0 would result in hard fault in mipi_catalog_formatter()
if log_output_syst.c is complied before the backends (and weird
enough, only with SIZE optimization). This new ordering was
introduced in commit f5587552bb
as it was to group all backend source files under a single
directory.

Workaround the issue by compiling file later after backends
as this issue is causing CI failures. Actual root-cause is TBD.

Relates #50941

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-10-10 18:02:08 +02:00
Troels Nilsson
28a9a79b98 Bluetooth: Controller: JIT fixes for ext. adv. duration handling
- Account for the added random delay when updating remaining duration
- Re-worked JIT re-scheduling update a bit to keep the random delay
  information and remaining duration correct

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-10-10 13:55:37 +02:00
Troels Nilsson
b6f5c75581 Bluetooth: Controller: Ext. adv. duration handling fix
- Remaining duration is now in us instead of ticks to avoid
  overflow when ticks have higher resolution
- First advertising event should not reduce remain duration

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-10-10 13:55:37 +02:00
Troels Nilsson
2a9cd8ffb1 Bluetooth: Controller: Add EVENT_OVERHEAD_START_US when enabling states
Add EVENT_OVERHEAD_START_US to ticks_anchor when enabling
advertising, so the first advertising event is not late due
to calculations for aux packets etc.

Signed-off-by: Troels Nilsson <trnn@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
236d0351e7 Bluetooth: Controller: EVENT_OVERHEAD_START_US for typical usecases
Tune the EVENT_OVERHEAD_START_US for typical usecases on
nRF52833 SoC using the central_gatt_write and
peripheral_gatt_write samples.

Manually run the samples for over 30 mins without any
assertions and use the actual profiled value that would
otherwise be printed on assertion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
a3b0ade9c6 Bluetooth: Controller: Explicit ticker worker trigger on expire in past
When ticks_to_expire is in the past, i.e. ticks_to_expire is
0, perform an explicit trigger of ticker worker instead of
setting up the compare which delays the trigger by the
minimum ticks offset margin. The changes reduce latencies
of the O(n) ticker_resolve_collision by upto the minimum
ticks offset margin (3 for nRF SoCs) for each resolution.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
ebf7236267 Bluetooth: Controller: Add verbose assertion on delayed prepare
When an event's prepare is delayed due to ULL scheduling or
ISR latencies, check and have a verbose assertion that logs
the actual EVENT_OVERHEAD_START_US required.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Vinayak Kariappa Chettimada
7715fb40e2 Bluetooth: Controller: Add LL_ASSERT_MSG definition
Add LL_ASSERT_MSG definition to log a verbose message as
part of assertion check.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-10 13:55:37 +02:00
Krzysztof Chruscinski
02664dbc91 logging: Use cbprintf flags for log_printk
Use cbprintf flags also when creating log message for printk entry.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-08 18:32:57 +02:00
Krzysztof Chruscinski
dc9c5fca4f logging: Add option LOG_MSG_APPEND_RO_STRING_LOC
Bring back Kconfig option which was previously removed by
9cd5086407 (previously named LOG_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS).
Renamed to shorten and be more descriptive. It can be useful for
external backends or frontends.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-08 18:32:57 +02:00
Juha Ylinen
c8a409d7d3 net: lwm2m: Use const data pointers in lwm2m_engine_set functions
lwm2m_engine_set functions use void data pointers. Change those to
to const void

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2022-10-07 16:43:51 +00:00
Robert Lubos
b76c35d809 modules: mbedtls: Replace select statement with depends on for EC
Instead of using "select" on certain EC configurations, which is
considered unsafe for various reasons, use a "depends on" and rely on
the user to set a proper configuration in the config file.

Update the respective project configurations to comply with the new
configuration scheme.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-07 15:12:42 +02:00
Vinayak Kariappa Chettimada
367004fd57 Bluetooth: Controller: Conditional compile optional ticker interfaces
Conditional compile ticker interfaces like ticker_update
which are not required when individual state or role samples
are build.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-07 14:46:38 +02:00
Vinayak Kariappa Chettimada
e48ea7e87b Bluetooth: Controller: Fix BIG event counter calc from payload count
Fix the BIG event counter calculation from stored payload
counter. Event latency should not be multiplied by burst
count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-07 14:42:27 +02:00
Vinayak Kariappa Chettimada
36db43716a Bluetooth: Controller: Fix missing includes to build full feature set
Fix missing includes and rearrange header includes to be able
to build a full feature set Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-07 14:34:14 +02:00
Andrzej Głąbek
916e04e0ef net: lib: sockets_tls: Include zephyr_mbedtls_priv.h conditionally
This is a follow-up to commit a418ad4bb4.

Since the path to zephyr_mbedtls_priv.h is added to include directories
only when CONFIG_MBEDTLS_BUILTIN is enabled, the inclusion of the file
needs to be done under the same condition. Otherwise, an error occurs
when socket_tls.c is compiled without CONFIG_MBEDTLS_BUILTIN.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-10-07 13:23:18 +02:00
Emil Gydesen
02d6661d71 Bluetooth: Shell: Add support for sending sine tone with the audio shell
added `audio start_sine` and `audio stop_sine` to start/stop
sending an LC3 encoded sine tone.

This code is heavily inspired from the sine tone implementation
from the unicast_client sample implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-07 13:22:53 +02:00
Emil Gydesen
83d3a36f78 Bluetooth: Audio: Shell: Add broadcaster address in broadcast scan callback
Add printing of the broadcast source advertising address in the
scan callback. Also rename the scan callback to make
it more clear that it is for broadcast scanning.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-07 13:22:45 +02:00
Emil Gydesen
208f44722f Bluetooth: Audio: Clear received_base in audio shell on PA sync lost
When the PA sync is lost, we clear the received_base so
that once we resync to the PA, we get the BASE again.

This is to make it easier to decode and use the BASE again
if the sync was lost, as the previous BASE may have
been printed a long time before.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-07 13:22:39 +02:00
Emil Gydesen
1302e95647 Bluetooth: Audio: Modify log of non-found stream for config state callback
In the unicast client, it is possible for the unicast server
to send a notification for ASE when it is in the codec
configured state after a reconnect. In that case, the
unicast client does not have a coupling between the ASE
and the audio stream.

This caused a BT_ERR to trigger, but it is not really an
error, but rather a state that the current unicast client
cannot handle, so the BT_ERR has been replaced with
a BT_WARN.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-07 13:22:30 +02:00
Emil Gydesen
fa13e02320 Bluetooth: Audio: Use stream->conn instead of iso->acl for ISO disconnect
Use the stream->conn instead of the iso->acl, as the iso->acl
may already have been free'd by the ISO layer when the
disconnected callback is called.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-07 13:22:23 +02:00
Szymon Czapracki
ab45e31c7e Bluetooth: Audio: Fix ASE race condition
This patch fixes invalid ASE state transition,
ASE now waits for Receiver Start Ready before
going into Streaming state.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-10-07 10:10:32 +00:00
Emil Gydesen
384f3461ad Bluetooth: Audio: Fix bug where sink ep did not go to streaming state
If the CIS was connected before the sink endpoint was
in the enabling state, it never autonousmly went into
the streaming state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-07 10:09:58 +00:00
Lucas Denefle
2efc9cc847 logging: enable setting custom logging output func
To enable custom formatting of the log output while still using existing
backend, this commit adds the `log_output_custom` feature.
To use, register a commit with `log_custom_output_msg_set` then set the
log backend format set using `log_backend_format_set` with
`LOG_OUTPUT_CUSTOM`

Signed-off-by: Lucas Denefle <lucas.denefle@converge.io>
2022-10-06 19:15:35 -04:00
Mariusz Skamra
4eb7077978 Bluetooth: audio: ascs: Move control point pointer out of bt_ascs
bt_ascs is per connection, so the control point attribute pointer
should not be part of this structure.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-06 22:42:24 +00:00
Mariusz Skamra
28ce0a96b1 Bluetooth: audio: capabilities: Remove redundant direction parameter
The direction is used to identify the list to append the registered
capabilities. There is no need to keep it in the bt_audio_capabilities,
it can be provided as a function parameter instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-06 22:41:27 +00:00
Emil Gydesen
8673fab276 Bluetooth: Audio: Fix bad warning when creating MPL OTS objects
The return check for adding MPL objects in OTS with
bt_ots_obj_add was incorrect, as only negative values
indicate an error, and a positive value returns the ID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-06 22:40:32 +00:00
Dominik Ermel
49ac66ae99 mgmt/mcumgr: Drop smp_streamer.tx_rsp_cb
No longer needed, since smp_streamer has smpt pointer to
zephyr_smp_transport, it can directly call smpt->zst_output.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-06 16:37:23 +02:00
Dominik Ermel
b64f61115e mgmt/mcumgr: Remove mgmt_streamer structure
There are no more functions directly using the type, so it
has been removed and its contents have been moved to
smp_streamer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-06 16:37:23 +02:00
Dominik Ermel
7f67b6759c mgmt/mcumgr: Remove declaration of mgmt_streamer_trim_front
The commit removes declaration of functions
mgmt_streamer_trim_front and mgmt_streamer_init_reader
as they no longer have definitions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-06 16:37:23 +02:00
Dominik Ermel
84345a4ec0 mgmt/mcumgr: Drop empty parameter from img_mgmt_flash_check_empty
The commit drops empty parameter from img_mgmt_flash_check_empty
and img_mgmt_flash_check_empty_inner and uses the return code
instead.
Both functions now use negative errno codes instead of MGMT_ERR_
type codes.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-06 16:36:37 +02:00
Jamie McCrae
b58d4356a1 mgmt: mcumgr: img_mgmt: Prevent re-upload of duplicate image data
This adds a hash check when the CONFIG_IMG_ENABLE_IMAGE_CHECK Kconfig
option is enabled that will check the underlying image hash to see if
it is the same as the one provided by the mcumgr client, and if so,
will prevent erasure/uploading the same image data.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-06 16:35:31 +02:00
Jamie McCrae
486b4db2cd mgmt: mcumgr: Remove Kconfig values that were deprecated in zephyr 3.1
Removes deprecated Kconfig values that have been replaced.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-06 16:34:58 +02:00
Jamie McCrae
ff3fd335b2 mgmt: mcumgr: Add dummy shell buffer size Kconfig to shell_mgmt
This adds the dummy shell buffer size to the shell_mgmt
configuration to allow ease of changing it.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-06 16:33:41 +02:00
Benjamin Gwin
4fa2f6fdb2 ztress: Fix comparison of signed/unsigned types
This fixes the compiler warning "comparison of integer expressions of
different signedness: 'int' and 'unsigned int' [-Werror=sign-compare]"

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-10-06 11:23:21 +02:00
Tomasz Moń
c27d48c89a usb: dfu: Support DFU with WinUSB on Windows
DFU on Windows with WinUSB driver failed with "Lost device after RESET?"
error because WinUSB does not support host initiated resets. USB Device
Firmware Upgrade Specification Revision 1.1 attribute bitWillDetach can
be used to overcome WinUSB reset limitation. When bitWillDetach is set,
it is the device responsibility to detach and reattach itself to the bus
after receiving DFU_DETACH request.

Add and enable by default USB_DFU_WILL_DETACH configuration option,
because it is the only way to support WinUSB driver. WinUSB driver is
preferable because it can be automatically installed on Windows 8 and
later if USB device implements WCID descriptors.

Fixes: #49821

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-10-06 09:12:34 +00:00
Andries Kruithof
ce1580765d Bluetooth: controller: set Ctrl Tx buffers to non-zero
Set the correct number of Ctrl Tx buffers used for the new
implementation, so that the ACK-fifo gets the correct size

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-10-06 09:01:19 +02:00
Vinayak Kariappa Chettimada
6a9e7a2960 Bluetooth: Controller: Conditionally compile legacy Ctrl Tx buffers
Conditionally compile the legacy control procedure defined
control Tx buffers that is not required in the new control
procedure implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-06 09:01:19 +02:00
Kamil Kasperczyk
1475d20aff net: ipv6: Allowed to add route to router's link local address
Zephyr doesn't seem to allow on adding route to the device from
which it received Router Advertisement without SLLAO field set
(in particular device that doesn't include Link Layer address).

Changes done:
* Added creating new NBR without Link Layer address set on RA
reception (LL is added only if SLLAO option is set, otherwise
NBR doesn't have LL address, but exists in the table and has
valid IPv6 link local address).
* Removed two asserts preventing from adding route to the NBR
that doesn't have Link Layer address set.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2022-10-05 16:22:40 +00:00
Juha Heiskanen
8e1ade2663 net: lwm2m: Fixed cached readtime
Added missing typecast for time read.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen
17b60d0fce net: lwm2m: LwM2M engine send operation update.
Added mutex lock for message build operation.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen
87dc170fed net: lwm2m: SenML-JSON support for Historical data
Extend SenML-JSON content format for handle cached data
timestamp API for basetime and timestamp label's.

Added support for write historical data for static resource
size's: Float (v) and Boolean (vb).

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen
60d9948b67 net: lwm2m: SenML-CBOR Encoder and CDDL update
Added support for historical data encode by adding base time (bt)
and time (t) label. New labels are needed for Encoder so Decoder
is not regenerated.

Added support for SenML-CBOR to write time series data.
Use "bt" base time and "t" timestamp labels for data cache.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen
73a637eda0 net: lwm2m: Historical data cache API update
New API for enable Historical data storage for LwM2M resource.
Data cache is only supported at resource which resource size is
static and well known.

Extend output writer for write cached data timestamp.

Enable cache support for Resource set and Read operation.

Added possibility for for drop latest or oldest data from cache.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Emil Gydesen
7b0ba0f517 Bluetooth: Audio: Fix missing path_id for unicast server
The codec->path_id supplied to the capabilities
were not being used for the endpoint codec.

Important note: This only works if there is a single
capability per codec ID per direction. This limitation
is also an existing limitation in the current
implementation of capabilities.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-05 12:45:14 +02:00
Emil Gydesen
9e256681a4 Bluetooth: Audio: Fix syncing to multiple BIS for broadcast sink shell
Fixed an issue with syncing to multiple BIS as the broadcast
sink in the shell. Also changed a check in the broadcast
sink implementation from an assert to a `if` to provide
a better way of handling bad input.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-05 12:42:09 +02:00
Troels Nilsson
de8c19da5e Bluetooth: controller: Handle fragmented AD without chaining PDUs
Adds support for handling fragmented advertising data over HCI when
CONFIG_BT_CTLR_ADV_AUX_PDU_LINK is not enabled

- Added support for appending advertising data to ull_adv_aux_hdr_set_clear
  and ull_adv_aux_pdu_set_clear via ULL_ADV_PDU_HDR_FIELD_AD_DATA_APPEND
- Updated ll_adv_aux_ad_data_set and ll_adv_aux_sr_data_set to
  handle fragmentation ops without CONFIG_BT_CTLR_ADV_AUX_PDU_LINK

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-10-05 09:18:15 +00:00
Jakob Krantz
8cac1f5b2c Bluetooth: Host: Add function to retreive per_adv_sync obj from index.
Gives the application a two way mapping between array index
and a per_adv_sync object instead of current only per_adv_sync
obj -> index using bt_le_per_adv_sync_get_index.

Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
2022-10-04 19:17:27 +00:00
Yuval Peress
a7979f8896 mocking: Update fff.h
Update fff.h to the pending PR upstream which allows for using a custom
function signature. This enables the use of C++ std::function as the
mock.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-04 14:24:09 -04:00
Tom Burdick
8b6ede6047 rtio: Release sqe before submitting cqe
When an application is waiting on a completion it may be expecting,
rightfully so, that a new submissions slot is available.

Frees the submission queue event prior to enqueuing
the completion queue event in the simple executor.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-04 09:31:13 -05:00
Jonathan Rico
a7537f527c Bluetooth: log: show function names by default
Show function names for all BT_xx logging levels when BT_DEBUG_LOG is
enabled. This makes it easier to find the problematic lines.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-04 14:09:04 +00:00
Jonathan Rico
afef6e2722 Bluetooth: att: precise warning messages
- Downgrade the warning emitted when we run out of channels.
- Only log a warning when failing to establish channels and the error is
  not -ENOMEM.
- Add a debug log message in that case to hint what might've happened.

This should make it less confusing to the average user not aware of the
stack internals.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-04 14:09:04 +00:00
Jonathan Rico
477c0fcb6e Bluetooth: l2cap: reword unknown pdu warning
This is a scary-looking warning for users, and should only really matter to
stack developers. It will eventually show up in the wild for embedded
devices that don't get updated to the latest and greatest.

Reword it to make it clear we are rejecting it, and it doesn't impact the
stack in any way.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-04 14:09:04 +00:00
Jonathan Rico
5d96b9e555 Bluetooth: smp: reword pairing failed error
This makes it more user-friendly, in case no failed cb has been
registered so this error is printed out of context.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-04 14:09:04 +00:00
Jonathan Rico
5cc0e8cdaa Bluetooth: hci_core: reword warning
Reword the scary-looking `bt_hci_core; Malformed data` warning to show
where it is originating from.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-04 14:09:04 +00:00
Mariusz Skamra
ae1ed41116 Bluetooth: audio: tbs_client: Fix GTBS index returned in API callbacks
This fixes GTBS index used in API. The index that is exposed to the
application is 255 in case of GTBS.
The code has been reworked to remove redundant booleans and index that
was kept inside instance.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-04 14:08:26 +00:00
Mariusz Skamra
1b310b26f3 Bluetooth: audio: tbs_client: Remove redundant checks
The CONTAINER_OF does not return NULL, thus the `inst == NULL` checks
are not needed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-04 14:08:26 +00:00
Lingao Meng
61d6532014 Bluetooth: Mesh: Add missing adv_main for relay message
By design, adv main set can use to send relay mesh messages
but here adv main set is invoked.

Add in the ended, so, adv main set only can be used when all
relay adv sets busy.

and this way does not cause too much delay for adv main set,
due to local message will process firstly.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-04 10:21:18 +00:00
Anders Storrø
b9f776d2fb Bluetooth: Mesh: Shell: Clear CDB on local reset
Adds feature that clears the CDB entry on local reset.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-10-04 10:20:38 +00:00
Anders Storrø
c7621d7ea1 Bluetooth: Mesh: Shell: Del CDB node on node reset
Adds feature that deletes the shell CDB node after perfoming a config
client reset of another node.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-10-04 10:20:38 +00:00
Vinayak Kariappa Chettimada
630eb033ba Bluetooth: Controller: Remove redundant assertion check
Remove redundant assertion check, and minor indentation fix
to correct the alignment of function call.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-04 10:36:32 +02:00
Vinayak Kariappa Chettimada
d96aa6dd70 Bluetooth: Controller: Minor indentation fix
Minor indentation fix to keep within 80 columns when it is
possible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-04 10:36:32 +02:00
Anders Storrø
bea54c5691 Bluetooth: Mesh: Shell: Make prov features dynamic
Alters several provisioning related features to allow commands to be
functional with application defined Provisioning properties &
capabilities.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-10-04 10:33:30 +02:00
Emil Gydesen
15ed8569ed Bluetooth: Audio: Update ASE EP state checks
Update the existing ASE EP state checks to be more correct
and aligned with the ASCS specification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-04 10:33:13 +02:00
Vinayak Kariappa Chettimada
578cc10043 Bluetooth: Controller: Ticker window extension for broadcaster only
Enable ticker ticks slow window extensions implementation
when broadcaster role is enabled. This feature moves the
primary channel advertising event within the specified
window when overlapping with other roles.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-10-03 16:28:09 +02:00
Daniel DeGrasse
11e3344909 sd: enable 4 bit bus width for high speed cards
Enable 4 bit bus width for high speed cards, so that host and card
combinations that cannot use UHS mode will still benefit from the
speed increase of using 4 data lines.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-03 14:22:33 +02:00
Nirosharn Amarasinghe
8b0d695be5 Bluetooth: controller: Implemented PDU release timeout
Implemented:
-- Combining segments from multiple SDUs in a single PDU for TX
-- Release of PDU based on remaining capacity below threshold
-- Release of any PDUs in production on receiving a timeout for the
   upcoming event
-- Release of PDUs in production if source if destroyed
-- Synchronization flag to exclude multiple contexts in ISO-AL
-- New Kconfig BT_CTLR_ISO_TX_SEG_PLAYLOAD_MIN to allow definition of
   minimum TX segment size

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-10-03 13:22:13 +02:00
Nirosharn Amarasinghe
789628a4e3 Bluetooth: Controller: Implemented buffering of SDU fragments in ISO-AL
Implements:
-- SDU fragments can be buffered in the ISO-AL so that the correct size
   of the SDU can be computed such that it can be released for inclusion
   in the first fragment's header
-- Changed SDU emit interface to allow the same structure to be used to
   buffer as well as release fragments
-- New configuration BT_CTLR_ISO_RX_SDU_BUFFERS to specify the number of
   SDU buffers for each sink
   (Buffering disabled when BT_CTLR_ISO_RX_SDU_BUFFERS=0)

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-10-03 13:22:13 +02:00
Nirosharn Amarasinghe
6c855b43be Bluetooth: Controller: implemented HCI_LE_Read_ISO_TX_Sync in ISO-AL
Implemented:
-- Storing information required to service HCI_LE_Read_ISO_TX_Sync
   request
-- Implemented interface to retrieve information
-- Cleared ISO-AL source and sink state on deallocation
-- Renamed cig_ref_point to grp_ref_point as it serves a common purpose
   in both CIS and BIS

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-10-03 13:22:13 +02:00
Nirosharn Amarasinghe
68b7b36adf Bluetooth: controller: Included guard for lost data in framed PDUs
Improvement for IAL/CIS/FRA/PER/BI-01-C & IAL/CIS/FRA/PER/BI-02-C
-- Test appears to fail as the transmitted PDU is packed with less data
   than is indicated in the segment headers.
-- Guards were included to verify that sufficient data exists in the PDU
   before extracting the segment.

General
-- Updated timestamps in error SDUs to better approximate the expected
   timestamps if time information is missing.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-10-03 13:22:13 +02:00
Juha Heiskanen
8c2f5d3296 net: lwm2m: RD Client bootstrap trigger update
Accept now from bootstrap trigger from any state expect ongoing
bootstrap process.
Free also possible on going RD client message. There was a chance
that update message response change state and bootstrap proces
not started.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-03 10:20:13 +02:00
Juha Heiskanen
7cee4cf80c net: lwm2m: LwM2M RD client message allocate update
Updated message handler that it free possible old allocated
message. Added message free also to RD stop and idle state.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-03 10:20:13 +02:00
Juha Heiskanen
8279489aee net: lwm2m: RD Client update registration timeout
Renamed LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT.

Changed reported event type for registration timeout to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT from
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE.
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE should be only
reported case when server reject by response registration.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-03 10:20:13 +02:00
Erik Brockhoff
bd3bc98847 Bluetooth: controller: correct parameters in conn update complete event
In case a connection update complete event reports an error, the
parameters reported should be the ones active on the connection and not
the ones requested

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-10-03 10:20:04 +02:00
Lingao Meng
83d129bc15 Bluetooth: Mesh: Add prefix bt_mesh_ for global variable
Some variables shadow global, which is difficult to handle when
porting to other platforms with shadow warnings turned on.

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

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-10-03 10:19:57 +02:00
Sjors Gielen
c0bcff120e net: sntp: use zsock_ functions.
Now the library does not need to depend on NET_SOCKETS_POSIX_NAMES.

Signed-off-by: Sjors Gielen <sjors@sjorsgielen.nl>
2022-10-03 10:19:47 +02:00
Mariusz Skamra
9dae352007 Bluetooth: audio: ascs: Increase the number of supported ASEs
This increases the number of supported audio stream endpoints.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-03 10:19:39 +02:00
Mariusz Skamra
1432d05c29 Bluetooth: audio: pacs: Remove redundant code
Avoid unnecessary memcmp of UUID's.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-03 10:17:30 +02:00
Mariusz Skamra
9ecbee2587 Bluetooth: audio: capabilities: Remove callbacks
This removes the callbacks from capabilities. The callbacks are used for
unicast server role only, while the capabilities are used for the
broadcast sink role as well. Thus the callbacks can be removed as there
is another bt_audio_unicast_server_cb API that is specific for unicast
server role.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-03 10:17:21 +02:00
Mariusz Skamra
43f270ad11 Bluetooth: audio: tbs_client: Fix primary service discovery function
Fixes the discovery function that handles GTBS only discovery. The
discovery stops when there is no space left for another instance. The
function has been split to improve the code readability and avoid
unnecessary UUID comparison.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-03 10:15:03 +02:00
Mariusz Skamra
124d66e885 Bluetooth: audio: tbs_client: Make GTBS client only build option
Refactor Kconfig to add a way to enable GTBS only client.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-03 10:15:03 +02:00
Piotr Pryga
9f56e3d8a5 cpp: Add C++20 [[nodiscard]] attribute to operator new
C++20 standard added [[nodiscard]] attribute to operator new
definitions. In case value returned by operator new is ignored,
compiler emits a warning.

The commit adds the attribute to operator new definitions.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-03 10:13:25 +02:00
Piotr Pryga
7205f3e35b cpp: Add spec of new operator with alignment request
C++17 delivered another specialization of a new operator,
that allows to allocate a memory with requested alignment.

The commit adds these specialziations to C++ subsystem.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-03 10:13:25 +02:00
Piotr Pryga
a0dc682bd9 cpp: new: Add no-throwing implementation of new operator
C++ subsystem defines exception throwing operator new.
Though the implementation never throws an exception.

If used by an application it should verify if requested
memory was allocated. This is against C++ standard.
If an application does not support exceptions or does not
want to call throwing new operator, it should use a
specialization of a new operator that makes sure it
never throws bad_alloc exception. The cpp subsystem
does not provide this specialization.

The commit adds missing operator new specializations.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-10-03 10:13:25 +02:00
Anders Storrø
901767a47a Bluetooth: Mesh: Shell: Add cfg opt for health srv
Adds Kconfig option for the Mesh Shell Health server.

The shell implementation of Health Server test commands is
dependent on the user adding and initializing the shell Health
Server instance in their application to make the commands functional.
To prevent any confussion about how these commands work, a Kconfig
option has been added to allow conditional compilation of these
commands. In this way the user must actively enable this feature, making
the conditional requirements more clear.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-10-03 10:12:25 +02:00
Krzysztof Chruscinski
e6bbc6941a logging: Use STRUCT_SECTION macros for log backend
Clean up logging code to utilize macros for handling sections.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-03 10:11:03 +02:00
Mariusz Skamra
7cc5be0dcf bluetooth: audio: pacs: Remove duplicated code
Remove code duplicates

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-03 10:10:46 +02:00
Jackson Cooper-Driver
23c9f7b215 ipc_service: Add ipc_service_close_instance function
This function allows the application to close an ipc_service instance.
It is intended for use when the remote agent it is communicating with
has gone down and allows for cleanup.
It first checks that the endpoints have been separately deregistered
with the instance using the deregister_endpoint function before
calling into previously added functions in ipc_static_vrings.c
and ipc_rpmsg.c to close those instances.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Jackson Cooper-Driver
e69d131bc5 ipc_service: Adding ipc_static_vrings_deinit function
This function deinitialises the static vrings used by the ipc_service
instance. It acheieves this by tearing down the initialised
virtqueues before closing the various aspects of libmetal which
are in use.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Jackson Cooper-Driver
f16a19c33f ipc_service: Add ipc_rpmsg_deinit function
This function does the opposite of the ipc_rpmsg_init function and
allows the rpmsg instance to be torndown in the case that the application
wishes to do so. It is intended to be used by the ipc_service subsystem.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Szymon Janc
6673cb1f60 Bluetooth: Controller: Fix DLE HCI params parsing
LE Write Suggested Default Data Length and LE Set Data Length commands
are suggestions from host and should be validated only as per HCI
specification regarding internal setting of LLCP.

LLCP is allowed to use other values if needed.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-10-03 10:08:34 +02:00
Ming Shao
94f2d2437f twister: refine the twister test plan generation
Due to the diverse coding styles and lack of preprocessing when
scanning for test cases, there were many unintended combinations
of yaml test scenarios and C test functions with the regex-based
test case discovery, which caused an inaccurate test plan and test
result stats.

As the new ztest fx is used, the test cases of a test instance can
be accurately determined via zephyr.symbols file.

Because the zephyr.symbols file is not available until after build,
test cases determination is placed right after the build stage of
the pipeline and before the runtime test collection.

For those test instances that don't go through the build stage,
such as those with "Skip filtered" (statically filtered) reason
before entering the pipeline, they are not affected.

This patch also adjust the stats logic because the zephyr.symbols
file is generated after build. So ExecutionCounter update is split
and some must be postponed until test execution pipeline is completed.

Some concepts:

A test instance = a yaml scenario + a platform
"Test instance" and "test config" are synonyms in twister, unfortunately
excessive IMHO...

A test instance can be filtered or skipped in 3 ways.
Let's define "runtime" as "after entering the execution pipeline".

1) statically filtered (before runtime)
   Such test instance is filtered by analyzing the yaml and never
   enters the execution pipeline.
2) cmake filtered (runtime)
   Such test instance enters pipeline and is filtered at cmake stage.
3) build skipped (also runtime)
   Such test instance enters pipeline and is skipped at build stage.

All the test instances that enter the execution pipeline will go
through the report stage, where ExecutionCounter is further updated.

The meaning of the fields of ExecutionCounter are:

 .skipped_configs = static filtered + cmake filtered + build skipped
 .skipped_runtime = cmake filtered + build skipped
 .skipped_filter = static filtered
 .done = instances that enter the execution pipeline
 .passed = instances that actually executed and passed

Definition of the overall stats:
total_complete = .done + .skipped_filter
total = yaml test scenario * applicable platforms
complete percentage = total_complete / total
pass rate = passed / (total - skipped_configs)

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-10-01 06:42:54 -04:00
Christopher Friedt
f5587552bb logging: move backends to subdirectory
This is mainly to reduce clutter in `subsys/logging`, but also to make
backend management slightly easier.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-10-01 03:34:48 -07:00
Andries Kruithof
5530ea0bd0 Bluetooth: controller: ensure memory access is aligned
The memory used for Tx buffers and procedure context must
be aligned on a word boundary, otherwise it is possible
to get unaligned memory access

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-09-30 11:12:19 +02:00
Aleksander Wasaznik
c90b4a4e52 Bluetooth: Shell: Fix GATT exchange mtu assertion fail
This change fixes a bug where the second use of shell command `gatt
exchange-mtu` would trigger an assertion failure in the stack. The BT
API `bt_gatt_exchange_mtu` asserts `params->func != NULL`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-09-29 17:34:33 +02:00
Vinayak Kariappa Chettimada
48c21fab93 Bluetooth: Controller: Fix radio_tmr_start_us to be soft realtime
Fix radio_tmr_start_us to be soft realtime, if the requested
start in microseconds is in the past, setup the next
earliest expiry. This is to prevent radio not being started
and not let the LLL hanging. When setup to receive auxiliary
PDU in LLL scheduling, is_aux_sched is set and if radio does
not start and the window is requested to be pre-empted, then
it is blocked from being preempted due to the is_aux_sched
flag remaining to be set. This stalls the scanning
infinitely until explicit scan disable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-29 16:42:36 +02:00
Vinayak Kariappa Chettimada
8b586ee5a4 Bluetooth: Controller: Fix missing is_aux_sched flag being reset
Fix missing is_aux_sched flag being reset before resuming to
scan for new advertising PDU in the same scan window after
having received an earlier primary channel PDU and auxiliary
channel PDU using LLL scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-29 16:42:36 +02:00
Vinayak Kariappa Chettimada
0eec434472 Bluetooth: Controller: Fix receiving spurious PDU in active scanning
Fix receiving spurious overlapping ADV_IND and SCAN_IND PDU
when LLL state expects to receive SCAN_RSP PDU. Explicitly
check that these PDUs are not processed when in active
scanning and waiting for SCAN_RSP PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-29 16:42:36 +02:00
Vinayak Kariappa Chettimada
1de70b575a Bluetooth: Controller: Fix node rx leak on extended scanning stop
If scan is being disabled, rx could already be enqueued
before coming to ull_scan_aux_rx_flush. Check if node rx is
not the last in the list of received PDUs then add it to the
list, else do not add it to the list to avoid duplicate
report generation, release and probable infinite loop
processing of the list. It is possible that node rx has not
be already added in case of last PDU in the chain, under
this case when scan is being stopped add it to the list
before auxiliary context is flushed.

Add the node rx to aux context list of node rx if not
already added when coming to ull_scan_aux_rx_flush. This is
handling a race condition wherein the last PDU in chain is
received and at the same time scan is being disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-29 16:42:36 +02:00
Vinayak Kariappa Chettimada
ba6cbc57e1 Bluetooth: Controller: Fix scan aux leak on periodic sync terminate
Fix scan aux context leak on Periodic Sync Terminate. On
Periodic Sync Terminate the `is_stop` flag is set to prevent
the ULL from assigning an aux context to the sync context,
but the acquired aux context was neither assigned to sync
context nor was being released back to the aux context pool.
Fixed by releasing the aux context if not assigned to the
sync context when `is_stop` flag is set.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-29 16:42:36 +02:00
Jonathan Rico
5f8e657a22 Bluetooth: att: limit EATT MTU to max buffer size
If a device sends an MTU that is bigger than our maximum tx buffer size,
that could cause assertion failures down the line.

This PR limits it to the maximum we support (CONFIG_BT_L2CAP_TX_MTU).

The issue has been observed with a gatt discovery procedure, but is likely
present in other places in att.c.

To reproduce it, we need two zephyr shell devices, with one having a larger
MTU than the other:
- connect
- do data length update to the bigger MTU
- set security to 2, EATT channels get connected
- launch a gatt discovery from the device with the larger MTU
- observe kernel panic on the other device when it attempts to add too much
memory to a net buf.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-29 10:16:57 +00:00
Joakim Andersson
cc74b3b977 Bluetooth: host: Log SC LTK in pairing procedure without bonding
Log the LE Secure Connection (SC) LTK in a pairing procedure without
bonding when CONFIG_BT_LOG_SNIFFER_INFO is enabled.

Fixes: #50691

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-09-29 10:15:08 +00:00
Emil Gydesen
715478fe8e Bluetooth: Shell: Add log of error code from bt_audio_stream_qos
Print the error code from calling bt_audio_stream_qos if it fails.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-28 14:06:06 +00:00
Dominik Ermel
16cdb40df7 mgmt/mcumgr: Remove mcumgr_util.h header
The header provides declarations for no longer used/existing
functions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-27 16:39:22 +02:00
Erik Brockhoff
183370277b Bluetooth: controller: fixing slot reservation for connection setup
With introduction of refactored LLCP was also introduced an error
re. calculation of initial slot reservation in connection setups.

Due to this error a bigger slot was reserved, leading to failure due to
connection overlaps in multiple.sh test.
Also the removal of this 'overhead' in slot reservations calls for
bigger time-allowance for l2pcap_stress test.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-09-27 10:02:07 +00:00
Emil Gydesen
186181687b Bluetooth: Audio: Remove unicast client set state
The unicast client should never need to set the state of the
endpoints directly, without an notification from the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-27 09:16:21 +00:00
Emil Gydesen
a59bc35235 Bluetooth: Audio: Ensure that ASEs don't get idled when CIS is connected
Ensure that the CIS for an ASE, if any, is disconnected before we
go into the idle state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-27 09:16:21 +00:00
Emil Gydesen
874c45241e Bluetooth: Audio: Remove caching ASE on release
Remove the support for caching ASEs on release.

This is mainly due to the 2-stage design in Zephyr: We
have the bt_audio_stream and the bt_audio_ep, where the
the latter represents an ASE in most cases.

However, once the endpoint goes into the codec configured
state, then a stream must be bound to it. This would be fine
(although a stream is technically not established at this point),
except that a stream is also, for unicast, specified for a
specific ACL. Once the ACL disconnects, the stream technically
becomes invalid, and if the stream is invalid, so is the endpoint.

Based on that, there's no reason (or even option) to keep the
endpoint in a codec configured state, as it would not
have a valid stream associated with it.

If we want to support an ASE going into the codec
configured state on ASE release (or ACL disconnect),
the relationsship between ASEs and streams needs to
be redefined.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-27 09:16:21 +00:00
Krishna T
d2b196978f net: l2: wifi: Fix channel length check
To allow 5GHz (and 6GHz) channels, use 3 digits check.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-26 18:41:40 +02:00
Juha Heiskanen
b559bd818c net: lwm2m: Fix LwM2M pause and resume
Fixed unstable thread state read for detetect engine thread
state.
Fixed engine missing socket conrext add.
lwm2m resume now do update also from network error state

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-09-26 15:17:37 +00:00
Jonathan Rico
1051607c7c Bluetooth: l2cap: prevent deadlock on chan timeout
When getting a channel timeout, l2cap_chan_destroy is called from the
rtx_work work item.

In that function we attempted to cancel the current work item, and sync on
it being cancelled. The kernel API says that this will block until the work
item completes execution, hence a deadlock.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 15:13:13 +00:00
Vinayak Kariappa Chettimada
744e5f4da4 Bluetooth: Controller: Fix ticks_slot_id_previous reset on ticker yield
Fix implementation to not reset the ticks_slot_id_previous
when ticker yields its reserved slot, only reset if ticker
was stopped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-26 13:20:28 +02:00
Vinayak Kariappa Chettimada
245b1e0330 Bluetooth: Controller: Fix ticker worker check ticks_slot_previous
Fix ticker worker from checking the ticks_slot_id_previous,
only ticks_slot_previous be checked as previous slot id
would be assigned to TICKER_NULL if the ticker was stopped.
The ticks_slot_previous value should be used to check that
a slot is reserved even if the ticker has been stopped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-26 13:20:28 +02:00
Ahmed Moheb
fab9c5a140 tests: bluetooth: host: Add UT for bt_keys_get_addr()
Unit test project for bt_keys_get_addr().
This part of subsys/bluetooth/host/buf.c unit testing

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-26 13:05:47 +02:00
Ahmed Moheb
fd888df41d tests: bluetooth: host: Add mocks for keys.c
Add required mocks to be able to compile and test /bluetooth/host/keys.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-26 13:05:47 +02:00
Juha Heiskanen
8364715998 net: lwm2m: Fix LwM2M resume from Update registration state
If LwM2M engine was paused at ENGINE_UPDATE_SENT it was not
able to resume lwm2m engine properly. There was also missing
RD client Pending message free which could also affect a issue.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-09-26 10:55:03 +00:00
Juha Heiskanen
c9c8c467b5 net: lwm2m: LwM2M rd client Update registration Timeout fix
RD client was not closing socket socket when Update registration
timeout. It fail new connection open. There is added a flag for
detect a case when Registration state need to be re-open a socket
for new connection.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-09-26 10:55:03 +00:00
Anas Nashif
268fff57a8 ztest: add a delay between tests through CONFIG_ZTEST_TEST_DELAY_MS
Some testsuites dump lots of output very fast where some systems are not
able to capture the complete output from the tests. Add a slight delay
between each test in the suite.

New kconfig CONFIG_ZTEST_TEST_DELAY_MS is added to ztest.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-26 10:53:43 +00:00
Vinayak Kariappa Chettimada
e348fe494a Bluetooth: Controller: Warn LLCP Legacy implementation as DEPRECATED
Add in Kconfig, select DEPRECATED, to warn at build time
that the LLCP legacy implementation is deprecated and the
refactored LLCP enabled by BT_LL_SW_LLCP Kconfig option be
used instead (which is the default now).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-26 11:07:17 +02:00
Jonathan Rico
109c47639e Bluetooth: l2cap: remove ambiguous naming
`l2cap_tx_meta_data` is also a function-like macro.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
77e1a9dcad Bluetooth: host: l2cap: add alloc_seg callback
This callback allows use-cases where the SDU is much larger than the l2cap
MPS. The stack will then try to allocate using this callback if specified,
and fall-back on using the buffer's pool (previous behavior).

This way one can define two buffer pools, one with a very large buffer
size, and one with a buffer size >= MPS, and the stack will allocate from
that instead.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
8e207fefad Bluetooth: host: l2cap: workaround SDU deadlock
See the code comments.

SDUs might enter a state where they will be blocked forever, as a
workaround, we nudge them when another SDU has been sent.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
3c1ca93fe8 Bluetooth: host: l2cap: don't send too much credits
There was an edge-case where we were sending back too much credits, add a
check so we can't do that anymore.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
1c8fe67a52 Bluetooth: host: l2cap: release segment in all cases
See code comment

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Vinayak Kariappa Chettimada
88705be89b Bluetooth: Controller: Fix BIS max PDU size used in calc of sub_interval
Fix BIS max PDU size used in calc of sub_interval, use the
minimum of supported maximum BIS PDU size and the requested
SDU size. This will avoid wasted air time between subevents
when SDU size is less than maximum supported PDU size, where
only 150 us tIFS is mandatory between subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 12:47:17 +00:00
Anders Storrø
3cbb8315fc Bluetooth: Mesh: Shell: Fix cfgCli appkey arg conv
Rectifies incorrect conversion of appkey string in config client
appkey add command.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-23 13:13:59 +02:00
Vinayak Kariappa Chettimada
b867f0e8a6 Bluetooth: Controller: Fix T_MAFS between broadcasting roles
When calculating the offsets between primary advertising
PDU, auxiliary PDU, Periodic Advertising PDU, and BIS PDU,
the values used as anchor points for starting the periodic
interval for auxiliary, periodic and BIG events, should be
ensured to have the minimum auxiliary frame spacing T_MAFS
between the PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 11:51:52 +02:00
Vinayak Kariappa Chettimada
1bbe209a30 Bluetooth: Controller: Fix auxiliary scan stop assertion check
Use a local variable to assert check on auxiliary context's
release.
Add missing volatile qualifier to the parent field of the
auxiliary scan context.
Under race condition a released aux context can be allocated
for reception of chain PDU of a periodic sync role, hence
fix the assertion check to consider that the released
context can be allocated to other roles.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 08:11:39 +00:00
Vinayak Kariappa Chettimada
16e0e6607c Bluetooth: Controller: Increase BIS PDU access address receive timeout
Increase the BIS PDU access address receive timeout, use the
+/- 2 us jitter for each subevent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 09:57:06 +02:00
Vinayak Kariappa Chettimada
24efea7ba1 Bluetooth: Controller: Fix infinite loop receiving ISO Data
Fix inifinite loop in ll_rx_get() when both ISO Broadcast
and ISO Receive features are enabled in a build. Missing
conditional compile prevented the ack_last index that
maintains a relation between number of packets complete and
the received data packets was unassigned.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-22 18:05:36 +02:00
Piotr Pryga
047b756e64 Bluetooth: df: Add ntf of insufficient resources for IQ samples
According to Bluetooth 5.3 Vol 4, Part E section 7.7.65.21 the
Controller should send an IQ report with Packet_Status set to 0xFF
and Sample_Count to 0x0, to inform Host that it is not able to
store IQ samples for all received Constant Tone Extensions and has
failed to sample at least once.

This commit adds handling of such situation for direction finding
in connectionless mode in lower link layer. It includes:
- lack of node_rx_iq_report to store IQ samples,
- lack of free node_rx to report received advertising data (generates
  an advertising data report with indication "incomplete, no more to
  come" and cancels reception of chained PDUs,
- cancellation of chained PDUs reception due to other scheduling
  reasons.
In all of these situations CTE reception must be enabled and number of
received CTEs is smaller than requested by Host.

If there is not sufficient number of node_rx_iq_report nodes and
report was generated, the CTE will not be samples in a given
periodic advertising synchronization event. The CTE will be
sampled again in next event if there are node_rx_iq_report available.

End user applications may check periodic advertising sync event
counter when use of the reports to be sure about sync event
the received report is connected with.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-09-22 18:04:00 +02:00
Dominik Ermel
e4d0bf0e64 mgmt/mcumgr: Fix image erase returning improper error code on error
The img_mgmt_erase could return MGMT_ERR_EOK even when
img_mgmt_impl_erase_slot failed.

Fixes #50522

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-22 15:32:04 +00:00
Enjia Mai
77986382df tests: framework: fix code coverage report on zephyr-sdk-0.15
The GCC/GCOV version over 12 has slight format change of the gcno
and gcda. Make some adaption in the gcov dump function to fix the
code coverage report.

Mainly two places change:
1. Added the checksum in the struct gcov_info. This fix the crash
in qemu_x86, and mps2_an385 when run with --coverage.

2. Adjust the GCOV_TAG_FUNCTION_LENGTH accroding to gcov-io.h. It's
length unit is caculated by bytes now.

Fixes #50255.
Fixes #50257.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-22 14:14:39 +00:00
Vinayak Kariappa Chettimada
30823c6f56 Bluetooth: Controller: Fix stream index use in Broadcast ISO Tx
Fix incorrect use of stream handle instead of connection
handle to enqueue Tx ISO Data, and use stream index to get
stream instance.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-22 15:53:35 +02:00
Pavel Vasilyev
e4921cc84d Bluetooth: Mesh: Trigger GATT update when subnet is added
When the node is part of only one subnet, it starts Network ID
advertisements with infinite timeout. It is not an issue when using
legacy advertising and extended advertising with shared set for local
messages and GATT because any message will stop advertisements. However,
when a separate adv set is used for GATT advertisements,
`struct bt_le_ext_adv_cb.start` callback won't be called, but the
implementation relies on that callback to switch to a next subnet.
Calling `bt_mesh_adv_gatt_update()` stop GATT advertisement so that the
implementation can switch to the next subnet.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-22 10:03:39 +02:00
Pavel Vasilyev
20a3a83c9f Bluetooth: Mesh: Fix node identity interleave multiple subnets
Reduce advertising duration to `max_timeout` when advertising node
identity for multiple subnets. This will let the node to interleave
subnets for NODE_ID_TIMEOUT.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-22 10:03:39 +02:00
Pavel Vasilyev
326786efd6 Bluetooth: Mesh: Avoid indefinite timeout when duration less than zero
`struct bt_le_ext_adv_start_param.timeout` resolution is in 10ms. When
duration is less than 10ms, division will be evaluated to zero, which
will result in indefinite timeout. Set timeout to 10ms to avoid
indefinite timeout. The advertisement will end earlier anyway after the
event is finished.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-22 10:03:39 +02:00
Jamie McCrae
1489104ddb mgmt: mcumgr: img_mgmt: Fix slot3 if check
Fixes an issue with img_mgmt whereby the if check for a slot3
partition is using the wrong case for the partition name.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-21 18:18:18 +02:00
Vinayak Kariappa Chettimada
d53d9fb6bf Bluetooth: Controller: Add error log for Advertising enable/disable
Add error message logging for Advertising enable/disable at
RPA timeout when the resolvable address is updated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 13:04:00 +00:00
Vinayak Kariappa Chettimada
6c40427931 Bluetooth: Host: Fix resolvable address update with Ext Adv enabled
Fix resolvable address update after RPA timeout with
Extended Advertising support enabled. As Extended
Advertising HCI Commands are being used to start legacy
advertising, incorrectly the local random address was being
used instead of using the random address populated in the
Extended Advertising set. BT_DEV_RPA_VALID is not cleared
when Extended Advertising HCI commands are used, hence the
local random address is not updated and the incorrect use
of it did not make any change to the advertising when
disabled and enabled at RPA timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 13:04:00 +00:00
Vinayak Kariappa Chettimada
87b39c5975 Bluetooth: Controller: Fix repeated skip in ticker resolve collision
Enforce next_is_older only when current has equal force as
with the next ticker.

Added Kconfig to disable priority feature in ticker that is
currently not used by Zephyr Bluetooth Low Energy
Controller.

The priority feature if enabled then a custom ULL is needed
by vendors to avoid repeated skipping of overlapping events
as next_has_priority check uses lazy value that would be
always lazy_next > lazy_current as currently skipped event
becomes the next event with lazy value incremented by 1.

Regression in commit 3a9173afe1 ("bluetooth: controller:
Revised ticker for improved conflict resolution") due to
Zephyr Controller does not implement any vendor specific
priority logic.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 12:28:44 +02:00
Mariusz Skamra
933a987d75 Bluetooth: audio: Fix possible memory violation
This fixes possible memory violation by using the index outside of an
instance array by tbs_client_common_call_control.
This basically fixes the get_inst_by_index function to return NULL if
the index is invalid. The function calls have been guarded to catch the
returned NULL.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-09-21 12:25:44 +02:00
Krishna T
97ee180c72 wifi: shell: Fix network switching issue
When switching from a secure network to open network, the previous
parameters are not reset which causes the open connection to fail.

Remove the unnecessary "static" storage and reset to zero for params.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-21 08:58:37 +00:00
Henrico Brom
bde8c6d24f net: lwm2m: Fixed missing _CONFIG prefix
Fixed missing '_CONFIG' prefix when enabling
LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT_MULTIPLE and
CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_INSTANCE_COUNT through prj.conf

Signed-off-by: Henrico Brom <henrico.brom@vention.nl>
2022-09-21 08:56:58 +00:00
Jamie McCrae
521c787e6f net: shell: Fix stray tab in "net mem" output
Fixes a stray tab in the net mem shell output which makes the TX DATA
line indented.

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2022-09-21 08:54:25 +00:00
Vinayak Kariappa Chettimada
fca96cfe33 Bluetooth: Controller: Reduce cntr_cnt_get() calls in ticker
Reduce the number of times cntr_cnt_get() is called in
ticker implementation as call to this function halts the
CPU inorder to access the RTC count in the 32KHz clock
domain.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 08:53:03 +00:00
Jamie McCrae
771668cf91 net: arp: Replace pending packet pointer with fifo
This fixes a bug with ARP and multiple outgoing packets with an IP
that needs to be resolved, causing the first packet to go out and
all others to be dropped after the timeout by having a FIFO of
pending packets instead of a single packet.

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2022-09-21 08:49:32 +00:00
Jamie McCrae
50738819f4 mgmt: mcumgr: Move wrongly placed header file
Moves a .h file added outside of the zephyr include folder to be
within the zephyr include folder.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-20 15:01:47 +02:00
Vinayak Kariappa Chettimada
69fb2dced0 Bluetooth: Controller: Fix TICKER_LOW_LAT Ext. Scan assert check
Fix Extended Scanning assertion check when using Ticker
Low Latency Implementation where the failure to schedule
a ticker timeout is returned inline compared to deferred
failure in the operation callback.

Auxiliary PDU is received using a single-shot ticker
timeout with ticks_slot reservation. This single-shot
ticker is allowed to fail if it is overlapping another
event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-20 09:10:40 +00:00
Andrew Hedin
4507608d71 shell: Improve kernel stacks alignment
Use Kconfig value to determine name field width.
Pad stack size to 4 characters.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2022-09-20 09:05:00 +00:00
Pavel Vasilyev
ef7f5226cf Bluetooth: Mesh: Fix description in BT_MESH_ADV_BUF_COUNT option
Fix description in BT_MESH_ADV_BUF_COUNT option.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-20 08:43:32 +00:00
Aleksander Wasaznik
7e11b98125 Bluetooth: Host: Add "assert non-null" to bt_conn_ref
Clearly `conn` must be non-null since it's dereferenced without checks.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-09-20 08:22:28 +00:00
Aleksander Wasaznik
a8f12ab690 Bluetooth: Host: Name enum bt_keys_type
Name annonymous enum with `BT_KEYS_` as `bt_keys_type`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-09-20 08:22:06 +00:00
Mariusz Skamra
bc2414e094 Bluetooth: audio: ascs: Fix crash on source QoS config
This fixes crash that happened during source ASE QoS by setting
the tx path that was left uninitialized.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-09-20 09:40:17 +02:00
Andrzej Puzdrowski
8d4d827a94 mgmt/mcumgr: include bootutil_public.h in im_mgmt
This header provides original BOOT_MAX_ALIGN definition.
This definition is used indirectly by the code this
patch modifies.
Let's use it instead of copy from mcuboot.h

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-09-19 18:36:37 +02:00
Andrzej Puzdrowski
1e7b120606 dfu: include MCUboot's bootutil_public.h
This header provides original BOOT_MAX_ALIGN definition.
This definition is used directly on indirectly by the code this
patch modifies.
Let's use it instead of copy from mcuboot.h

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-09-19 18:36:37 +02:00
Wolfgang Puffitsch
06e7751303 Bluetooth: controller: Fix error codes for accept/reject CIS request
The LE Accept/Reject CIS Request commands shall return Unknown
Connection Identifier if the handle is not a CIS handle or does not
exist. If the CIS already has been established, the commands shall
return Command Disallowed.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2022-09-19 18:34:41 +02:00
Emil Gydesen
927df43092 Bluetooth: Audio: Fix bad BASE config check for broadcast sink
The broadcast sink did not allow codec config data to exist
in both the subgroup and in the individual BISes, which
not only doesn't make sense to not allow, but would
also cause interoperability issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-19 18:34:25 +02:00
Dominik Ermel
4b01c733bb mgmt/mcumgr: Make img_mgmt_erase construct only good response
Constructing error response makes no sense as smp_build_err_rsp
will rewrite it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-19 18:30:57 +02:00
Dominik Ermel
c19aac161e mgmt/mcumgr: Remove mgmt_write_rsp_status function
It is no longer used.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-19 18:30:16 +02:00
Dominik Ermel
1cd03dee96 mgmt/mcumgr: Fix CONFIG_MGMT_VERBOSE_ERR_RESPONSE
The options should enable verbose responses in error responses
to SMP command processing, but has been broen when the code
has been ported to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-19 18:30:16 +02:00
Vinayak Kariappa Chettimada
d7b183d1da Bluetooth: Controller: Fix incorrect data type use
Fix incorrect data type int32_t local variable used for lazy
value which is uint16_t type.

Other minor code refactor done.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:27:38 +02:00
Vinayak Kariappa Chettimada
e8d1ed5d0d Bluetooth: Controller: Fix missing TICKER_SLOT_AGNOSTIC cond. compile
Fix missing conditional compile of structure members not
required with BT_TICKER_SLOT_AGNOSTIC is enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:18:12 +02:00
Vinayak Kariappa Chettimada
336013fe34 Bluetooth: Controller: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned
variable.
MISRA-C rule 7.2

Relates to commit b97db52de7 ("misra-c: Add 'U' to
unsigned variable assignments in subsys/").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
da2b1b615c Bluetooth: Controller: Fix incorrect use of stream instead of bis
Fix incorrect use of stream index (application selected list
of BIS stream) instead of BIS index when checking for
whether the received PDU is to be stored and to be
dispatched as ISO data to ULL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
be7a9ade7d Bluetooth: Controller: Fix missing terminate reason initialization
Fix missing Broadcast ISO Synchronized Receiver terminate
reason initialization that caused Sync Lost immediately on
a new Sync Establishment due to previous Sync terminate
reason not being reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
dfa3d959e0 Bluetooth: Controller: Initialize invalid ISO data packet
Initialize the invalid ISO data packet generated by LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
75346a47f9 Bluetooth: Controller: Fix Rx chan idx when skipping BIS subevents
Fix missing implementation to correctly to use data channel
index for subevents when previous subevent of previous BIS
stream where skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
3c92b25234 Bluetooth: Controller: Fix ISO broadcast to flush and ack for all BIS
Fix ISO broadcast implementation to flush stale ISO data for
all BIS streams and like wise generate acknowledgements for
all BIS streams that had its ISO data transmitted at its
reference anchor points.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
c8f5fbcf8d Bluetooth: Controller: Restrict maximum Pre-Transmissions to 1
Restrict the calculated possible Pre-Transmission subevents
count to a maximum of 1 so that the full ISO interval is
not fully occupied by the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
eff946a9ad Bluetooth: Controller: Fix leak in Num Completed Packets
Fix a leak in generation of Number of Completed Packets when
more than one handle has acknowledgements to be processed.

The loop exited for the current handle by dequeueing the
node tx element of the next handle leading to lost Number of
Completed Packets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
f11fe69450 Bluetooth: Controller: Fix missing supervision/sync lost
When radio event prepare is cancelled due to preemption by
overlapping radio events, the extra done event processing
was missing and hence the use of accumulated prepares'
skip/latency count.
This caused the check for supervision timeout and sync
lost not be aware of the elapsed events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:02:28 +02:00
Vinayak Kariappa Chettimada
38905eb0ab Bluetooth: Controller: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned
variable.
MISRA-C rule 7.2

Relates to commit b97db52de7 ("misra-c: Add 'U' to
unsigned variable assignments in subsys/").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:02:28 +02:00
Vinayak Kariappa Chettimada
0feb34363f Bluetooth: Controller: Add missing margin to BIG ticks_anchor
Add the missing ticker resolution margin when calculating
the ticks_anchor to be used to get non-overlapping BIG
events.

Relates to commit fab4511164 ("Bluetooth: Controller: Fix
overlapping advertising events").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 17:55:56 +02:00
Krzysztof Chruscinski
4ece3406f5 logging: Add log_output dependency to mipi syst
Add missing dependency since log_output_syst.c is calling functions
from log_output module.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-19 14:15:17 +00:00
Yong Cong Sin
15b3150ac2 mgmt/hawkbit: Print hrefs only if there's an update
If the is no update from the server, the _links will be NULL.
Check if it is NULL before trying to LOG these strings.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-09-19 15:43:04 +02:00
Jamie McCrae
52e2493842 mgmt: mcumgr: fs_mgmt: hash/checksum: Fix size errors
There are warnings when building fs_mgmt with hash/checksum
functionality enabled due to array access and a wrong variable type
being used.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-19 10:50:42 +00:00
Jarno Lämsä
05b17356e2 net: lib: lwm2m: Fix lwm2m exec
The lwm2m exec erroneously checked the previous return value
instead of checking if the resource existed. This caused exec
to try to get and execute the execute callback from NULL and caused
a reboot.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2022-09-19 10:33:04 +00:00
Krzysztof Chruscinski
b097f5c5f8 logging: Use new cbprintf check for pointers
Cbprintf has new feature where it can distinguish between
character pointers used for %p and %s. It is enabled by
flag CBPRINTF_PACKAGE_CONVERT_PTR_CHECK.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-19 10:14:23 +00:00
Pirun Lee
8e0f003112 Bluetooth: OTS - Object Write check parameter properly
Check sum of len and offset with properties.
Check offset with obj cur size.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2022-09-19 10:57:10 +02:00
Jonas Woerner
6432e100aa Bluetooth: Host: Make adv error reporting more consistent
this changes adv_new_legacy to adv_get_legacy.
without this fix the function would return NULL if BT_EXT_ADV is enabled.

Signed-off-by: Jonas Woerner <jonas.woerner@online.de>
2022-09-16 10:53:31 +01:00
Pavel Vasilyev
24af6031e2 Bluetooth: Mesh: Use separate pool for relayed messages
Sharing the same pool for both, local and relayed messages has some
disadwantages. In a high-traffic environment the relayed messages may
occupy the whole pool without letting the node to send own messages,
neither to process segmented messages. The vice versa situation is
possible when local messages takes the whole pool so that the node is
not able to relay other messages. Another thing is that it doesn't let
to controll amount of local and relayed messages that the node can send
at once. Controlling the number of messages that the node can relay may
help to reduce the message latency.

This change adds separate net_buf_pool for the relayed messages that
helps to avoid problems described above.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-16 08:39:04 +00:00
Reto Schneider
b11ba9ddc8 net: net_pkt: Simplify net_pkt_compact() API
Since db11fcd174 [net/net_pkt: Fully
separate struct net_pkt from struct net_buf], net_pkt_compact() can not
fail anymore.

This commit acknowledges this and simplifies the API accordingly.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-09-15 16:35:11 +00:00
Krishna T
79f864028d net: l2: wifi: Log band from the scan result
Along with channel, also log the Wi-Fi band from the scan result.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-15 16:34:30 +00:00
Reto Schneider
9e1b130156 net: zperf: Configurable packet size limit
Allow user to adjust (artificial) size limitation of 1024 bytes.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-09-15 16:34:13 +00:00
Pawel Dunaj
3676aeff78 ipc_service: icmsg: Trigger data read after magic
After magic is read during bound procedure, trigger an
initial data read. This is to ensure data is not missed
when piggybacked on magic's exchange interrupt.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2022-09-15 16:31:48 +00:00
Aleksander Wasaznik
a89d5edb92 Bluetooth: Shell: Remove a debug-print
I don't think it was intentional to leave this line.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-09-15 17:27:42 +01:00
Al Semjonovs
b27c5d73ef ztest: Fix unused variable compile error in shuffle function
When CONFIG_ZTEST_SHUFFLE is enabled and ASSERTS are disabled
`start_pos` becomes an unused variable leading to a compile error.
Cleaned-up shuffling algorithm to not need a `start_pos` check.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-09-14 20:13:46 -04:00
Reto Schneider
6de54e0d03 net: context: Fix memory leak
Allocated, but undersized packets must not just be logged, but also
unreferenced before returning an error.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-09-14 14:38:34 +01:00
Pavel Vasilyev
85e7818ff2 Bluetooth: Mesh: Don't process unprovisioned beacon without callback
If `struct bt_mesh_prov::unprovisioned_beacon` callback is not set,
don't process the beacon.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-14 14:37:54 +01:00
Dominik Ermel
f46f8511ce mgmt: mcumgr: Remove zcbor_size_ definitions
zcbor supports native zcbor_size_ functions for some time now,
so there is no need to have local zcbor_size_ definitions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-14 09:40:30 +00:00
Herman Berget
372b7869df Bluetooth: Shell: Fix L2CAP ecred commands
The channel arrays must be null-terminated if it is less than 5 elements
long.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-09-14 09:38:39 +00:00
Erik Brockhoff
5951cd4c9b Bluetooth: controller: fixing missing reset of proc context greedy flag
For the encryption procedure exists a flag used to indicate that the
procedure expects all PDUs to be delivered to the procedure STM.
This flag was not cleared during creation of new procedure. This could
lead to unexpected PDUs being passed to local procedure STM

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-09-14 09:36:56 +00:00
Vinayak Kariappa Chettimada
8636766e57 Bluetooth: Controller: Fix compile error BT_CTLR_JIT_SCHEDULING enabled
Fix compile error when BT_CTLR_JIT_SCHEDULING is enabled but
BT_CTLR_ADV_EXT is disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-14 09:36:28 +00:00
Pavel Vasilyev
cf953de484 Bluetooth: Mesh: Check pending_buf in bt_mesh_send_cb in friend.c
When friend entry is cleared by `friend_clear` after an adv buffer has
been sent to that friend in `friend_timeout`, another friend request
coming after this may reuse the same entry. It is possible that
`friend_timeout` will be scheduled twice: once by the friend request
and once by `buf_send_end` of the previously sent buffer.
In that case, the code will assert on line friend.c:1234. It is not
possible to cancel an adv buffer for the friendship that is to be
cleared, therefore, we need to ensure in correctness of the pending_buf
value in start and end callbacks.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-13 16:26:39 +00:00
Lingao Meng
fcbe88d598 Bluetooth: Mesh: Fix iv recovery unable clear replay list
When local node enter iv recovery procedure, should clear
replay list at first due to avoid possible wrong replay attack.

At present, `bt_mesh_rpl_clear` schedule a timer to clear rpl,
this would cause local node unable precess mesh message(IV Updated).

Also, in `bt_mesh_rpl_pending_store` also not clear rpl, which check
`BT_MESH_VALID` flag, always valid for iv recovery.

So, Add `rpl_clear_pending` work handler process rpl clear.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-09-13 16:24:46 +00:00
Szymon Czapracki
85639f78bd Bluetooth: audio: Fix error message in PACS
Change error code in PACS source/sink
write operation to Write Request Rejected.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-09-13 08:55:39 +00:00
Dennis Sitelew
42f9b69f50 logging: Fix signed integer cast for isprint
Casting the value byte to char may result in it being a negative
number. On some platforms this could lead to either UB, or a crash.

Signed-off-by: Dennis Sitelew <dennis.sitelew@grandcentrix.net>
2022-09-13 08:51:22 +00:00
Sjors Hettinga
452592fc9a net: websockets: Fix websocket_send_msg return code
When the websocket_prepare_and_send is called from websocket_send_msg,
the header length is subtracted to retrieve the transmitted payload length.
Make an exclutsion to prevent the return code of
websocket_prepare_and_send being modified in case of 0 or a negative
return code.
This avoid confusion with modificated error codes

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-13 08:49:24 +00:00
Anders Storrø
97ed0061cb Bluetooth: Mesh: Remove experimental tag from CDB
The CDB module is a mandatory part of provisioning features in BTM, and
can not be regarded as experimental anymore.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-12 14:14:27 +00:00
Sagar Shah
dfd897096d net: lib: coap: method_from_code() API change to return errors.
method_from_code() signature has changed to return error and
the method. In case of an invalid code it returns -EINVAL and
causes coap_handle_request() to return -ENOTSUP.

Fixes: #49498

Signed-off-by: Sagar Shah <sagar.shah@legrand.us>
2022-09-12 10:53:34 +00:00
Pavel Vasilyev
1357be36b0 Bluetooth: Mesh: Fix print of newly allocated node in CDB
Using the passed address is incorrect since the passed address can be
zero to find the lowest available address.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-12 10:52:50 +00:00
Pavel Vasilyev
33b9f3e361 Bluetooth: Mesh: Prevent CDB reusing address of deleted nodes
According to MshPRFv1.0.1, section 3.10.7, the Provisioner shall only
use reuse addresses of the deleted nodes after IV Index is updated.

This change prevents CDB reusing addresses of the deleted nodes until IV
Index is updated. Due to a high range of the unicast addresses, CDB only
stores the highest deleted address once a node is deleted. This creates
a limitation where allocating a node with the high primary unicast
address and then deleting it will make CDB skip big range of address
until next IV Index update.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-12 10:52:50 +00:00
Ola Tangen Kulseng
1df3de4e98 net: lwm2m: API for multiple resource writing
Used the registry lock in the functions lwm2m_registry_lock() and
lwm2m_registry_unlock() to make the registry lockable through a public
API. If writing to multiple resources that are composite-observed,
locking will halt the main thread until every resource is written to,
ensuring that only one notify message will be sent. Updated
the documentation in lwm2m to include this addition.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-09-12 10:52:18 +00:00
Florian Grandel
0956647aaf pm: device_runtime.c: compile error
Enabling device power management together with tracing caused a compile
error.

Fixes: #50107

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-10 17:04:20 -04:00
Vinayak Kariappa Chettimada
0954185e81 Bluetooth: Controller: Fix periodic advertising re-enable assertion
When periodic advertising with chaining is re-enabled after
changing interval or just re-enabled then the chain PDUs
where not duplicated causing the LLL to assert detecting the
presence of aux pointer but no linked chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-09 16:29:28 -04:00
Kai Vehmanen
6c71ddc2c6 logging: allow to select FORMAT_TIMESTAMP for ADSP_MTRACE backend
The CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP cannot be selected unless one of
the enumerated backends is selected. Add the ADSP_MTRACE backend to the
list, so timestamp formatting can be selected when only this backend is
enabled in the build.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-09-09 16:25:47 -04:00
Jamie McCrae
c56b45c3e8 mgmt: mcumgr: Fix output packet to frame issue on serial transport
Fixes an issue with outgoing mcumgr frames that are larger than the
transport MTU size whereby they would wrongly be split up into multiple
frames with multiple start frame headers, which affected SMP over
console transports.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-09 19:47:12 +00:00
Dominik Ermel
798d6c7ffc mgmt/mcumgr: Drop zst from zephyr_smp_transport_out_fn
Never used and not needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-09 18:25:44 +00:00
Krzysztof Chruscinski
b17823d063 logging: Allow use of log_output without subsystem
Allow using log_output without the logging subsystem. It can be
used in the situation where external messages are processed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-09 16:41:50 +00:00
Dominik Ermel
7cc729558f mgmt/mcumgr: Move SMP transport to own sub-dir
The lib/transport directory has been moved up, directly under the
subsys/mgmt/mcumgr, and all transport files have been moved to
that directory.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-09 16:37:48 +00:00
Huifeng Zhang
3d81d7f23f arch: arm64: fix the wrong way to send ipi interrupt
On GICv3, when we send an IPI interrupt, aff3, aff2 and aff1 should
be assigned a value corespond to a PE for which interrupt will be
generated. target_list only corresponds to aff0.

On real hardware, aff3, aff2, aff1 and aff0 should be treated as a
whole to determine a PE.

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2022-09-09 16:36:37 +00:00
Christian Taedcke
6a1c2304c4 net: context: Remove redunant check of automatically selected port
In the function find_available_port() a port is randomly selected. Because
the random value is always >= 0x8000, it is redundant to check if it is
<= 1023 afterwards.

This commit removes the redundant check.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-09-09 14:12:57 +00:00
Michał Barnaś
dae8efa692 ztest: remove the obsolete NULL appended to zassert macros
This commit removes the usage of NULL parameter as message in
zassert_* macros after making it optional

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Michał Barnaś
36f74e9837 ztest: remove msg parameter from zassert_* and zassume_* macros
This commit removes the requirement for msg parameter in zassert_*
and zassume_* macros. It will allow to use them without sending NULL
as the last parameter.

The default messages look like:

void* beauty_ptr = NULL;
zassert_not_null(beauty_ptr);
=>
Assertion failed at main.c:20: suite_test: beauty_ptr is NULL

void* ugly_ptr = (void*)0xbaadf00d;
zassume_is_null(ugly_ptr);
=>
Assumption failed at main.c:23: suite_test: ugly_ptr is not NULL

int apple = 3;
int tomato = 9;
zassume_equal(apple, tomato);
=>
Assumption failed at main.c:27: suite_test: apple not equal to tomato

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Michał Barnaś
305ee1816a ztest: prepare zassert and zassume macro to be used without message
This commit adds intermediate macros that will allow to use the
zassert and zassume macros without setting the msg parameter as NULL
if it isn't used.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Michał Barnaś
ce5985b9a1 ztest: improve comments for ztest assert macros
Move params in comment about zassert and zassume macros.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Szymon Czapracki
66e6572a0f Bluetooth: audio: shell: Add command to change contexts
Allow to change available audio contexts from shell

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-09-09 10:50:06 +00:00
Jamie McCrae
ce7e0f4425 mgmt: mcumgr: Fix wrongly using pointer of pointer in free function
Fixes an issue introduced when the mcumgr code was simplified whereby
the newer compressed free function call wrongly passes a pointer to a
pointer instead of the pointer itself.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-09 09:53:43 +00:00
Jamie McCrae
59cbe81ec3 mgmt: mcumgr: smp_bt: Fix missing notification connection unref
Fixes an issue with the connection reference not being decremented
at the end of the outgoing notification function resulting in an
ever-increasing connection count.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-09 09:53:43 +00:00
Emil Gydesen
34d4501e8a Bluetooth: Shell: Add connect-name command
Add a new command, connect-name, which takes a string
as the single input and uses that to setup a scan filter
and connect to the first device that matches the name.

This command is thus basically shorthand for
bt scan-filter-set <name>
bt scan on
bt scan off
bt connect
bt scan-filter-clear-name

The idea of this command is to not only make it easier
find and connect to devices in a crowded environment,
but also to more easily connect to devices that changes
their advertised address.

The implementation is minimal as it uses existing
shell commands.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-09 10:10:52 +02:00
Hang Fan
fd4d18852d Bluetooth: Audio: Set transparent coding format for default ISO path
As per BAP_v1.0, Section 5.6.3.1:

If HCI is used when setting up their respective audio data paths,
and if the codec in use resides in the Bluetooth Host of the device
using the LE Setup ISO Data Path command, the Unicast Client and/or
Unicast Server shall:
* Write the LE Setup ISO Data Path command Codec_Configuration_Length
parameter with the value 0x00.
* Write octet 0 (Coding_Format) of the LE Setup ISO Data Path command
Codec_ID parameter with the value 0x03 (Transparent).

We can assume the codec in use resides in the Bluetooth Host default.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-09-09 10:08:34 +02:00
Szymon Czapracki
35c0d5ef67 Bluetooth: audio: shell: Add command to set location
Allow to set audio locations from shell

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-09-09 10:07:49 +02:00
Ahmed Moheb
cb5ba5bea8 tests: bluetooth: host: Add mocks for buf.c
Add required mocks to be able to compile and test /bluetooth/host/buf.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-09 10:06:19 +02:00
Szymon Czapracki
ac6c35728a Bluetooth: Add IAS shell
This commit adds IAS functionality to the shell.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>

shell fixes
2022-09-09 10:05:46 +02:00
Szymon Czapracki
f4d23b6cd7 Bluetooth: Immediate Alert Client
Implement Immediate Alert Client
Move IAS into separate subdirectory

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>

general fixes
2022-09-09 10:05:46 +02:00
Ryan Erickson
820fca76cc logging: fs backend: only delete old files if necessary
During initialization of the FS backed, the oldest
file is always deleted.
Fix this to prevent throwing away useful historic logs.
If there is space left in the newest file, append to it instead
of creating a new file and removing the oldest.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-09-09 10:04:24 +02:00
Pieter De Gendt
34ee707d4a mgmt: mcumgr: Fix unused function warning
The static function img_mgmt_flash_check_empty is only used if
CONFIG_IMG_ERASE_PROGRESSIVELY isn't set.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-09-08 15:31:36 +00:00
Jamie McCrae
1da4adfe20 mgmt: mcumgr: Replace #if with #ifdef for CONFIG_ checks
Replaces #if with #ifdef when checking Kconfig defines

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-08 15:29:21 +00:00
Jamie McCrae
edd1a5ff6f mgmt: mcumgr: os_mgmt: Make reboot conditional on CONFIG_REBOOT
This prevents the os_mgmt reboot command being available if
CONFIG_REBOOT is not selected.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-08 15:29:21 +00:00
Jamie McCrae
7992256df5 mgmt: mcumgr: Add dummy SMP backend
This adds a dummy SMP backend which can be used for unit testing or
virtual interface purposes.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-09-08 15:29:21 +00:00
Vinayak Kariappa Chettimada
8191423950 Bluetooth: Controller: legacy: terminate condition to check role first
Refactor to revert back the terminate check condition to
check the connection role first.

Reverts legacy code changed in
commit 8b1d50b981 ("Bluetooth: controller: llcp: fix issue
 re. missing ack of terminate ind").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 15:12:22 +02:00
Vinayak Kariappa Chettimada
4da89756b3 Bluetooth: Controller: Dont prioritize ticker slot window that yield
Do not use lazy value to prioritize ticker with ticks slot
window that yield to other tickers. Primary channel PDUs
use ticks slow window to nudge themself after an
overlapping ticker within the ticks slot window, but such
ticker may be skipped to next interval. At the next
interval if they again overlap with other tickers then
lazy value shall not be used to prioritize but rather
continue to yield again. This is required to avoid BIG
events from being skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 14:31:23 +02:00
Emil Gydesen
717b4fee56 Bluetooth: ISO: Remove TS size from SDU len check
The timestamp is not part of the SDU, and should
thus not be used to get the maximum SDU size.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-08 11:32:53 +00:00
Troels Nilsson
ba810303c5 Bluetooth: controller: Big-endian fix for aux_ptr offs and phy
pdu_adv_aux_ptr no longer uses a bitfield for offs and phy, so
we can properly adjust for BE

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-09-08 10:08:51 +00:00
Krzysztof Chruscinski
2735a3a2fa testsuite: ztress: Use XOSHIRO generator when ztress is used
Use XOSHIRO random number generator if target has entropy generator.
Some entropy generators may have limitations (e.g. only thread context)
which would conflict with ztress usage.

Added Kconfig.defconfig for testsuite.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-08 05:43:17 -04:00
Krzysztof Chruscinski
77617b0d98 testsuite: ztress: First sys_rand_get32 from thread
Added a workaround to call random generator once during the
initialization. It is done to handle XOSHIRO generator limitation
which performs initialization in the first sys_rand32_get call.
And for some entropy generators it cannot be done from an interrupt
context and it happens if k_timer context is used which expires first.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-08 05:43:17 -04:00
Vinayak Kariappa Chettimada
b8a959ee47 Bluetooth: Controller: Fix BIG Create silently fail on RTN/SDU_interval
Fix BIG Create implementation from silently failing on
values of RTN and SDU_interval that lead to BIG events that
cannot be acheived when using sequential or interleaved
subevents by the Controller Implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 10:14:09 +02:00
Vinayak Kariappa Chettimada
b304eaa29b Bluetooth: Controller: Add Kconfig for experimental AD Data Chaining
Add a Kconfig for Advertising Data Chaining in Extended and
Periodic Advertising, permitting AD data lengths of upto
1650 bytes. The implementation is experimental and needs
further testing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 10:12:56 +02:00
Vinayak Kariappa Chettimada
34154e3efe Bluetooth: Controller: Fix BT_CTLR_ADV_DATA_LEN_MAX Kconfig dependency
Fix BT_CTLR_ADV_DATA_LEN_MAX and other Kconfig dependencies,
and clean up the use of PDU_AC_LL_SIZE_MAX which is used to
allocate scratch packet to be atleast able to accommodate
the minimum 31 bytes AD data such that it is sufficient to
transmit and/or receive scan response PDUs when either
broadcaster or observer alone is supported.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 10:12:56 +02:00
Tom Burdick
54474510b3 logging: adsp hda backend refinements and additional test
Additional testing showed that when using printk the logger would start
sticking and spitting out nulls which is wrong. This made it appear as if
the firmware had locked up. The issue seems to have been caused by the
initial ipc message to read all the dma buffers on the host.

Removing that, the issue seems to have been solved.

This also improves the test case to ensure printk with LOG_PRINTK=y
works as expected. It also adds a last log message between some
timeouts of the flush timer length to ensure the padding and timer
flush are working properly.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-09-07 20:27:44 -04:00
Anders Storrø
bfb4e1bac4 Bluetooth: Mesh: Shell: Split out mdl shell feat
This commit splits out the model related commands from mesh shell to
separate shell modules. The purpose of this alteration is to make model
commands more flexible by letting the application itself define the
model instances.

- Move Health Client commands to separate shell module.
- Move Config Client commands to separate shell module.
- Remove Health Client instance from shell.c.
- Add Health Client instance to mesh_shell test application.
- Add util library for Mesh shell.
- Some refactoring of shell menu layout.
- Update Mesh shell documentation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-07 15:02:58 +02:00
Anders Storrø
548f850192 Bluetooth: Mesh: Move shell.c to subfolder
Moves shell.c to shell subfolder. Done as a separate step to preserve
diff between previous and new revision of shell.c.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-07 15:02:58 +02:00
Timothy Keys
194cb8abab Bluetooth: Controller: Request any TX Power
Allow requesting any TX power in SDC via kconfig. This enables easily
setting higher TX values when using a FEM.

Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
2022-09-07 10:30:55 +02:00
Yong Cong Sin
148317f075 shell/mqtt: Handle negative return value of wait
`wait()` returns the retval of `zsock_poll()` which can be
negative but is currently unhandled.

This patch make sure that the error will be handled.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-09-07 10:30:16 +02:00
Yong Cong Sin
834fb411e3 shell/mqtt: minor MISRA-related fixes
Minor MISRA-related fixes so that the conditionals are boolean
and precedence of statements are explicit.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-09-07 10:30:16 +02:00
Vinayak Kariappa Chettimada
61a44f1af2 Bluetooth: Controller: Use macros in num complt implementation
Use macros to encode the counting of number of completed
packets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Morten Priess
eb025d0497 Bluetooth: Controller: Fix ISO TX pool corruption and missing release
- Fix ISO TX data pool corruption due to multiple calls to
  tx_cmplt_get, without removing the nodes
- Added missing release of TX node link in case of ISOAL error

Signed-off-by: Morten Priess <mtpr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Vinayak Kariappa Chettimada
4a74f97a9a Bluetooth: Controller: Fix ISO Tx PDU memory pool corruption
Fix ISO Tx PDU memory pool corruption due to duplicate ISO
Tx PDU buffers repeatedly released into the memory pool.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Vinayak Kariappa Chettimada
8eee8430d4 Bluetooth: Controller: Add implementation to flush Tx on BIG terminate
Add implementation to flush pending ISO Tx PDUs when BIG
events are terminated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Vinayak Kariappa Chettimada
73e0b415ce Bluetooth: Controller: Fix removal of BIG association with Periodic Adv
Move the removal of BIG context association with the
Periodic Advertising context to when the BIG streams are
release and BIG terminate message is generated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Kai Vehmanen
eac6176961 logging: adsp_mtrace: fix handling of buffer full condition
If the mtrace buffer gets full, the entries are dropped. This
is however not reflected in the "bytes_written" argument passed
to the hook function used to notify of new data in the buffer.

This behaviour becomes problematic in the case there is no
active consumer of the mtrace logs. To allow the client that has
registered the hook function, to act correctly in this case,
the bytes_written should reflect the actual bytes that have been
added to buffer.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-09-06 17:43:08 +02:00
Jamie McCrae
e394899256 mgmt: mcumgr: Add runtime taskstat tick usage
Adds the runtime tick count of threads to mcumgr's taskstat response,
if CONFIG_SCHED_THREAD_USAGE is enabled, which reports the number of
execution cycles that each thread has been running for.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-06 16:19:37 +02:00
Jamie McCrae
92074e00a8 mgmt: mcumgr: Fix Bluetooth notification issue
Fixes an issue with Bluetooth notification sending whereby it does
not wait for buffers to become available and can error out if
unable to get a buffer once.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-06 16:19:15 +02:00
Jamie McCrae
698c4b0243 mgmt: mcumgr: Use dedicated work queue for SMP
Fixes an issues where the system work queue can become a source of
contention and cause a deadlock by moving MCUMGR SMP processing to its
own dedicated work queue.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-06 16:19:15 +02:00
Jamie McCrae
4bd39c21c7 mgmt: mcumgr: Move zephyr_grp to lib/cmd folder
Moves the zephyr_grp commands to the same directory as the other
mgmt command handlers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-06 16:18:50 +02:00
Dominik Ermel
4a702ea21e mgmt/mcumgr: Move mgmt Kconfig file under mgmt sub-dir
The Kconfig for MCUMgr management source code (service registration,
group registration, and so on) has been moved to the sub-dir with
the code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 12:49:27 +02:00
Jamie McCrae
3a79fddfc2 mgmt: mcumgr: Make signed thread priorities enabled by default
By default, thread priorities in mcumgr task stat responses are
unsigned, whilst in zephyr, thread priorities are signed. This means
that clients get obscenely large numbers for priorities that make no
sense. The fork of mcumgr has been in zephyr long enough now that
this should be changed to use signed thread priorities by default
instead of sticking with the old mcumgr default.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-06 12:48:25 +02:00
Dominik Ermel
6b760b3702 mgmt/mcumgr: Remove internal functions form Zephyr header
The commit removes declarations of:
 zephyr_smp_rx_req, zephyr_smp_alloc_rsp, zephyr_smp_free_buf
from include/zephyr/mgmt/mcumgr/smp.h, as these are MCUMgr internal
functions used in SMP processing and should be not exposed
from header file that provides interface for SMP transports.
The declarations have been moved to smp_internal.h, which is
visible within MCUMgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 12:36:08 +02:00
Jakub Rzeszutko
66d4471d48 shell: add function checking shell readiness.
Tests with shell commands will fail if they are started
before the shell backend is initialized or started.
Adding API function: shell_ready indicating shell readiness.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2022-09-06 12:36:01 +02:00
Jakub Rzeszutko
2b05f467f0 shell: add missing asserts to api functions
Add missing macro: __ASSERT_NO_MSG to API functions.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2022-09-06 12:36:01 +02:00
Anders Storrø
36e34fce41 Bluetooth: Mesh: Add CDB depend on to prov Kconfig
The current implementation of provisioning features is dependent on CDB
to compile, which is reflected poorly in the Kconfig options for mesh.

This commit alters the Kconfig options for provisioning to be dependent
on the CDB option to compile.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-06 12:35:48 +02:00
Marc Lasch
42858bebb7 mgmt/mcumgr: Fix format specifier
Use c99 format specifier macros to remove build warnings when building
for `native_posix[_64]`.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2022-09-06 10:00:25 +02:00
Dominik Ermel
b07c8656ff settings: Switch from FIXED_AREA_ to FIXED_PARTITION_ macros
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Dominik Ermel
56663b4821 debug: coredump: flash backend: Switch FIXED_PARTITION_ macros
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Dominik Ermel
0d956d2d31 subsys/mgmt/hawkbit: Switch from FLASH_AREA_ to FIXED_PARTITION_
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Dominik Ermel
f762fc7a2c usb: dfu: Switch from FLASH_AREA_ to FIXED_PARTITION_
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Dominik Ermel
b8533a7bee mgmt: updatehub: Switch from FLASH_AREA_ to FIXED_PARTITION_
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Dominik Ermel
c058a457b2 fs: Switch from FLASH_AREA_ to FIXED_PARTITION_ macros
The commit switches LittleFS code from using FLASH_AREA_
macros to FIXED_PARTITION_ macros.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Dominik Ermel
51d676d601 dfu: Switch from FLASH_AREA_ to FIXED_PARTITION_ macros
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Dominik Ermel
572e527bd1 mgmt/mcumgr/lib: Switch to FIXED_PARTITION_* macros
The commit switches mcumgr from FLASH_AREA_* macros to
FIXED_PARTITION_* macros.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Krishna T
25d0f87b3c net: dhcp: Add support for restarting DHCP
If a L2 link has been established, then the DHCP is taking too long as
it has to go through its capped exponential backoff timers to trigger
discover (The DHCP starts immediately during init, this is itself wrong,
it should start on a link UP notification) that delays the DHCP for
few seconds to a minute.

And if we do stop and start DHCP then also it goes through the initial
delays (though configurable), which is also not ideal.

Add support for restarting DHCP without any delay, i.e., release and
send discover immediately.

This is also useful in case L2 switches to a different subnet, in this
case Zephyr doesn't restart DHCP automatically, this API can be used by
L2 apps/drivers to restart DHCP to get new subnet IP.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-06 09:56:22 +02:00
Vinayak Kariappa Chettimada
d5f94e632f Bluetooth: Controller: Support for multiple BIS sync selection
Added implementation to use the BIS array parameter and
selectively synchronize to subset of multiple Broadcast
Isochronous Streams in a Broadcast Isochronous Group.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:47 +02:00
Vinayak Kariappa Chettimada
4f02f05378 Bluetooth: Controller: BIG event timing reservations
Added implementation to calculate BIG event timing
reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:47 +02:00
Vinayak Kariappa Chettimada
1d4a5dd0ef Bluetooth: Controller: Fix calculation of BIS subevents
Fix calculation of BIS subevents that was missing num_bis
when calculating the PDU latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:47 +02:00
Vinayak Kariappa Chettimada
f738f494eb Bluetooth: Controller: Fix incorrect cond compile scheduling BIG
Fix incorrect conditional compile to disable Controller
advanced scheduling feature which is required for Broadcast
ISO implementation.

Regression in commit 6fe1299c33 ("Bluetooth: controller:
llcp: fix CI tests for new LLCP").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:12 +02:00
Vinayak Kariappa Chettimada
052136841e Bluetooth: Controller: Restrict max ISO Tx PDU size to ISO Tx MTU
In a Host plus Controller combined build for ISO feature
restrict the maximum ISO Tx PDU size to minimum of 251 bytes
and Host ISO Tx MTU. This will allow controller to use
reduced Tx time (subevent interval).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:01 +02:00
Dominik Ermel
8af9d3b960 mgmt/mcumgr: Move FS conditional block to FS CMakeLists.txt
The conditional block linking mbedTLS for checksum calculation
in FS commands have been moved to CMakeLists.txt responsible
for compiling these commands.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-05 14:44:05 +00:00
Florian Grandel
51af614f88 net: ip: core: clean up check_ip_addr()
* only define function when IP stack is built
* use switch statement rather then if/else if

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-05 14:35:17 +00:00
Florian Grandel
c57650c403 net: context: clean up net_context_get()
* reduced cyclomatic complexity
* group validation by family to make the validation easier to understand
and extend
* change preprocessor markup where possible to allow for complete code
elimination when features (esp. IP) are disabled
* renamed net_context_get/set_ip_proto() to net_context_get_proto()

While the latter is formally part of the public API and might therefore
have to be deprecated rather than renamed, it is considered internal API
by the net developers, see
https://github.com/zephyrproject-rtos/zephyr/pull/48751#discussion_r942402612

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-05 14:35:17 +00:00
Florian Grandel
9695a022f4 net: core: clean up inbound packet handling
The net_core:process_data() and connection:net_conn_input() methods are
the central network packet reception pipeline which:

1) guide network packets through all network layers,
2) decode, validate and filter packages along the way and
3) distribute packages to connections/sockets on all layers.

This code seems to have grown complex and rather cluttered over time as
all protocols, layers and socket implementations meet there in one single
place.

The code also reveals its origin as a pure IP stack which makes it hard
to introduce non-IP protocols and their supporting socket infrastructure
in a modularized way.

For an outside contributor it seems almost impossible to add another
protocol, protocol layer, filter rule or socket implementation without
breaking things.

This change doesn't try to solve all issues at once. It focuses
exclusively on aspects that maintain backwards compatibility:

* Improve modularization and encapsulation on implementation level by
disentangling code that mixes up layers, protocols and socket
implementations.

* Make IP just one protocol among others by removing assymmetry in
protocol handling logic and introduce preprocessor markup so that
IP-specific code can be eliminated by the preprocessor if not needed.

* Use preprocessor markup to delineate hook points for future
modularization or expansion without introducing structural changes (as
this would almost certainly break the API).

* Reduce cyclomatic complexity, use positive rather than negative logic,
improve variable naming, replace if/elseif/else blocks with switches,
reduce variable span, introduce inline comments where code does not
speak for itself, etc. as much as possible to make the code overall
more human-friendly.

Background: These are preparative steps for the introduction of IEEE
802.15.RAW sockets, DGRAM sockets and sockets bound to PAN IDs and device
addresses similar to what the Linux kernel does.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-05 14:35:17 +00:00
Florian Grandel
228526e0db net: lib: sockets: improve scalability through a hidden var
Introducing additional socket implementations is rather involved right
now due to some more or less convoluted code that had grown over time.

This change introduces an additional configuration variable in preparation
for additional socket API drivers. The idea is to reduce redundant code
and make existing code more readable by better exposing its actual intent.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-05 14:35:17 +00:00
Florian Grandel
e9a433cd8f net: introduce NET_IP config to efficiently mark conditional code
The code contained several repeated composite IPv4/v6 and UDP/TCP
preprocessor statements that can be simplified by introducing a hidden
NET_IP preprocessor constant that captures what probably is actually
"meant" by this code.

While we were on it we also used the new constant to further isolate
IP-specific code from non-IP specific generics.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-05 14:35:17 +00:00
Florian Grandel
e608e92112 net: context: properly namespace can-related methods
The net_context_set/get_filter_id() methods are CAN specific and should
say so.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-05 14:35:17 +00:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Krzysztof Chruscinski
64ab22bf43 shell: Add option to format logging timestamp
Add option to control formatting of the logging timestamp. By default
formatting is enabled which maintains backward compatibility.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-05 14:27:00 +02:00
Michal Narajowski
5c27067dcd Bluetooth: Mesh: Align Config Client API with Health Client API
This PR adds a `*_cli_*` infix to the Config Client API to match
the changes in Health Client. The old API is marked as deprecated.

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
2022-09-05 13:56:25 +03:00
Krzysztof Chruscinski
dbda37ddf0 logging: Add LOG_RAW macro
Add macro for logging raw formatted string. It is similar to
LOG_PRINTK macro but contrary to LOG_PRINTK it should not append
carriage return character to any new line character found in the
string. LOG_PRINTK processed by log_output module has that to
mimic printk behavior.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-05 06:26:54 -04:00
Ahmed Moheb
c7d37d956e bluetooth: host: keys: Rename bt_keys_foreach() to bt_keys_foreach_type()
Use the name bt_keys_foreach_type() to be more descriptive.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-05 12:22:13 +02:00
Ahmed Moheb
f1884e5083 bluetooth: host: keys: Remove CONFIG_BT_MAX_CONN from key in use check
Eliminate key in use check dependency on (CONFIG_BT_MAX_CONN > 1).

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-05 12:22:13 +02:00
Ahmed Moheb
eea982e91e bluetooth: host: keys: Check if returned key matches keys pool item
bt_keys_find_addr() is used to find key by both ID and address.
Following checks must continue to compare ID and address as well.
Or, we can compare key references which is faster.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-05 12:22:13 +02:00
Ahmed Moheb
21882c5779 bluetooth: host: keys: Add assertions to check arguments
Check arguments passed to APIs with assertions.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-05 12:22:13 +02:00
Ahmed Moheb
ad5b154250 bluetooth: host: keys: Add APIs docs
Add API documentation to describe behavior, args and return value.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-05 12:22:13 +02:00
Krzysztof Chruscinski
89de6d19af logging: log_output: Use \r\n instead of \n\r for printk
Replace order to be compatible with printk and other logging outputs.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-05 06:18:17 -04:00
Fabio Utzig
5a3c459c00 mgmt: mcumgr: fix includes to avoid redefinition
Fix include order to avoid redefinition of `ARRAY_SIZE`, because
`sys/util.h` and `zcbor_common.h` both define it, but `sys/util.h` does
not protect against redefinition.

Signed-off-by: Fabio Utzig <utzig@tumenibits.com>
2022-09-02 15:13:10 +00:00
Andrey Borisovich
2e04bfdfe0 soc: intel_adsp: Refactored IPC/IDC
Changes to code:
1. Renamed CAVS_IPC API from common/include/cavs_ipc.h to
common/include/intel_adsp_ipc.h. Renamed all API functions and structs -
added "intel_adsp_" prefix.
2. Moved definitions from intel-ipc-regs.h and ace-ipc-regs.g to SOC
specific headers include/<soc_name>/adsp_ipc_regs.h.
3. Added new common intel_adsp_ipc_devtree.h header with new
macros to retrieve IPC and IDC nodes and register addresses.
Put those new macros in code replacing hardcoded values outside of
devicetree.
4. Changed documentation of IDC and renamed IDC register struct
to have common name between all intel adsp socs.
5. Removed excessive docs description on cAVS IPC protocol.

Changes to Devicetree:
1. Renamed in all CAVS boards .dtsi files content in IPC nodes:
   - "cavs_host_ipc" node labels to "adsp_ipc" labels.
   - compatible "intel,cavs-host-ipc" renamed to
     "intel,adsp-host-ipc".
2. Added (previously missing) yaml file for "intel,adsp-host-ipc"
   compatible.
3. Renamed in all CAVS boards .dtsi files content in IDC nodes:
   - "idc" node labels to "adsp_idc" labels.
   - compatible "intel,cavs-idc" renamed to "intel-adsp-idc"
4. Renamed intel,cavs_idc.yaml file to intel,adsp_idc.yaml
   so it is suitable for both CAVS and ACE SoC family.
   Moved it from ipm bindings to ipc bindings where it belongs.

Changes to Kconfig:
1. Renamed existing Kconfig option CONFIG_CAVS_IPC to
   INTEL_ADSP_IPC.
2. For renamed INTEL_ADSP_IPC addded default value based on
   status of the "adsp-ipc" and "adsp-ipc" node.

Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
2022-09-02 08:18:32 -04:00
Emil Gydesen
68e17426ac Bluetooth: Audio: Support setting non-HCI data path for audio streams
Add support for setting a vendor specific data path using
the BAP API, instead of only support the HCI data path.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-02 14:16:49 +02:00
Emil Gydesen
1099030210 Bluetooth: ISO: Modify cc in bt_iso_chan_path
The CC/Codec Configuration in bt_iso_chan_path was
defined as an array of size 0. This meant that the
CC always had to be allocated right after the
bt_iso_chan_path struct.

This does not give a very flexible API, and also makes
it impossible for two bt_iso_chan_path to share the same
CC.

The API is modified so that the CC is simply a pointer
to a an array now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-02 14:16:49 +02:00
Krishna T
34db41d934 net: l2: wifi: Improve help
* Fix newlines
* Improve text

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-02 11:07:07 +00:00
Krishna T
d6448aeb49 net: l2: wifi: Use proper Wi-Fi terminology for MAC
MAC address is generic, in context of scan it should be called BSSID.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-02 11:07:07 +00:00
Krishna T
870fcb3aa4 net: l2: wifi: Fix the width for security
The longest security string is 15 (WPA2-PSK-SHA256), so, use that width
for alignment.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-02 11:07:07 +00:00
Sagar Shah
7973483649 net: lib: coap: coap_packet_parse() returns different error values
coap_packet_parse() returns different values depending on error.
It now returns
-EINVAL for invalid input arguments,
-EBADMSG for malformed coap header,
-EILSEQ for malformed options error.

Fixes: #48960

Signed-off-by: Sagar Shah <sagar.shah@legrand.us>
2022-09-02 11:02:38 +00:00
Kumar Gala
26574e239a modbus: Update Kconfig
Utilize DT_HAS_<COMPAT>_ENABLED for devicetree based driver

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-09-02 11:00:08 +00:00
Kumar Gala
a96eaf25f9 usb: device: cdc: Update Kconfig
Utilize DT_HAS_<COMPAT>_ENABLED for devicetree based driver

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-09-02 10:59:32 +00:00
Emil Gydesen
e2055e158c Bluetooth: Audio: Fix error check for bt_gatt_subscribe error log
We shouldn't log an error if we are already subscribed to the device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-02 10:59:23 +00:00
Jamie McCrae
0cbd888831 mgmt: mcumgr: Add optional slot number to erase command
Allows selecting which slot will be erased, will default back to
slot 1 as it would do in previous versions if the optional parameter
is not provided

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-02 10:56:58 +00:00
Jamie McCrae
767d32f54c mgmt: mcumgr: Fix ARRAY_SIZE build warning
Fixes a build warning due to include file ordering

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-02 19:11:02 +09:00
Parthiban Nallathambi
75479f5338 modbus: add user data for adu callback
add user data for adu callback, which helps in passing
socket and relevant application parameters.

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2022-09-02 10:51:57 +02:00
Christopher Friedt
13a2294f9d sys_clock: define NSEC_PER_MSEC
NSEC_PER_MSEC should be defined along with the rest of the
per-sec macros in sys_clock.h. Currently, it's defined
multiply in a few separate locations.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-09-01 16:29:25 -04:00
Krzysztof Chruscinski
6890a9a434 shell: Fix dependency to log_output
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.

Original commit (b0072e1cea) was
reverted, reappling.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-01 20:54:13 +02:00
Krzysztof Chruscinski
539c509d2c logging: cleanup in CMakeLists.txt
log_output.c was added in two places: unconditionally when logging
is enabled and when CONFIG_LOG_OUTPUT is set. Cleaning up to add
source file only when module is enabled.

Original commit was reverted. Now it is reapplied.
Original commit:af31cad8366c82a35e8749e6488252e394ce158d

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-01 20:54:13 +02:00
Herman Berget
e65fdd4c5e Bluetooth: Host: Clean up buffer user data in case of error
`bt_l2cap_chan_send_cb()` overwrote the buffer user data for internal
use. In the case where sending fails, this would be visible for the
caller. If the caller relied on the buffer user data to be unchanged,
this could cause unexpected behavior.

L2CAP tx metadata was also not freed in the error case.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-09-01 14:58:08 +00:00
Christopher Friedt
c59178b695 net: ip: tcp: use zu format specifier for size_t
The `%i` format specifier is for `int` and is equivalent to
`%d` for printf formatting.

However, for `size_t`, the correct format specifier is `%zu`.

Fixes #49825

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-09-01 10:24:39 -04:00
Jamie McCrae
41ecd5998f mcumgr: shell: Change command exit code from rc to ret
This prevents the shell command response code conflicting with the
mcumgr response code, which are 2 distinct variable types

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-01 14:05:14 +02:00
Jamie McCrae
4ef4944673 mgmt: mcumgr: Fix race condition with task status
Fixes a race condition when listing task status using mcumgr whereby
if a thread status changes, it could cause unpredictable output for
the command.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-01 13:20:44 +02:00
Jamie McCrae
c72eb5f02c mgmt: mcumgr: Reduce unnecessary pointers and objects
Reduces the level of indirection for functions by calling the zephyr
functions directly as support for multiple operating systems is no
longer required with mcumgr being forked and placed into the zephyr
tree. Saves 60 bytes flash when compiling smp_svr on an ARM Cortex
M4 board.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-01 13:20:11 +02:00
Jamie McCrae
3839398964 mgmt: mcumgr: Move to slist for group management
Switches to using Zephyr's single linked list implementation for
group management objects instead of duplicating functionality for
mcumgr only.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-01 13:19:41 +02:00
Jamie McCrae
03730e71fd mgmt: mcumgr: Make img_mgmt structures packed
Resolves an issue with processors that do not support unaligned memory
access when using img_mgmt functions, e.g. ARM Cortex M0, by marking
structures as packed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-09-01 13:19:21 +02:00
Vinayak Kariappa Chettimada
b294b6e648 Bluetooth: Controller: Fix prepare pipeline preempt timeout stop
Fix prepare pipeline preempt timeout stop from stopping a
a prevously started timeout for the next in pipeline event.

The preempt timeout started prior for the current event that
has its prepare that is invoked is to be not explicitly
stopped. If there is a next prepare event in pipeline, then
the prior preempt timeout if started will be stopped before
starting the new preempt timeout. Refer to implementation in
preempt_ticker_start().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-01 13:18:11 +02:00
Vinayak Kariappa Chettimada
ddf04997a5 Bluetooth: Controller: Add abort fairness in overlapping Periodic Sync
Add implementation in Periodic Sync LLL abort to use near
fair scheduling to ensure overlapping multiple Periodic
Sync set each get to use the radio and not lead to Sync
Loss.

The implementation is used when overlap in radio event
happens in unreserved time space of the event. An abort
count is maintain in each Periodic Sync instance and is
used to decide whether the current event or the next
event is to be aborted when they overlap.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-01 13:18:11 +02:00
Vinayak Kariappa Chettimada
1a1f347ad3 Bluetooth: Controller: Add Kconfig for minimal time reservation
Add Kconfig to use minimal time reservation for auxiliary
and sync PDU reception. A peer device could be scheduling
multiple advertising sets in a short duration with small
PDUs hence using the minimal time reservation would avoid
skipping closely scheduled reception of multiple auxiliary
PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-01 13:18:11 +02:00
Sjors Hettinga
74772abfd2 net: tcp: Add build in auto check for reordering
The reorder process in rather complicated. Add a runtime check to always
check afterwards if the reordering queue is still consistent. When this
test fails, discard the contents of the complete reorder buffer.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Sjors Hettinga
39328e8836 net: tcp: Discard duplicate data in reodering correctly
When all the data of the new packet is already present in the
queue_recv_data, make sure the packet is discarded.
This commit adds a test line that reproduces the issue and implements a
fix.

Also in appending the packet, call the official net_buf_frag_add function
instead of updating the last net_buf pointer, since the net_pkt_remove_tail
called in between, might have removed the last net_buf.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Sjors Hettinga
89860fd74e net: tcp: Correctly deal with fully duplicated buffered out of order data
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.

The reordering logic should be able to deal with this situation and
throw away the overlapping data. This fix clears the out of order queue
when the queued data is not relevant.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Sjors Hettinga
515fc73b79 net: tcp: Correctly handle partial duplicate buffered out of order data
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.

The reordering logic should be able to deal with this situation and
throw away the overlapping data. Now also for data that needs to be added
to the existing queue

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Sjors Hettinga
e255f1a9c7 net: tcp: Correctly handle partial duplicate out of order data
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.

The reordering logic should be able to deal with this situation and
throw away the overlapping data.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Sjors Hettinga
f2d94a7f5c net: tcp: Implement a fast retransmit algorithm
Instead of waiting for the retransmit timeout, retransmit as soon as
missing data is deduced based on a triple-duplicate ACK.

Increase the number of buffers in the testcase, to allow for at least 4
packets in flight to trigger the triple-duplicate ACK.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Sjors Hettinga
9d772efbbc net: tcp: Send a duplicate ACK for out of order data
When out of order data is received, send out a duplicate ACK to notify
the sender that there is data received out of sequence, so it can
retransmit the missing section.

Also avoid sending acknowlegdement to acknowlegdement messages that are
having an out of order sequence number.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Adam Augustyn
6986185c81 Bluetooth: Host: Clear random address field in bt_dev in bt_disable()
This commit clears cached random address in bt_dev when calling
bt_disable(). This change makes future calls of set_random_address()
function possible with previously used address value, after BLE stack
re-initialization. Without this change no HCI command was sent, see this
condition in set_random_address():

/* Do nothing if we already have the right address */
if (!bt_addr_cmp(addr, &bt_dev.random_addr.a)) {
	return 0;
}

Signed-off-by: Adam Augustyn <adam.augustyn@hidglobal.com>
2022-09-01 10:36:40 +02:00
Jonathan Rico
f10db5e5cb Bluetooth: smp: Fix SC with fixed passkey
passkey confirm should not be called when secure connections are enforced.

Fixes #49599

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-01 10:27:34 +02:00
Pavel Vasilyev
52b423e18c Bluetooth: Mesh: Replace segack tx delay with Kconfig options
Additional uncontrolled delay for transmitting segack affects throughput
of the segmented messages. Though the best throughput can be achieved
with the smallest allowed values, move them to Kconfig option so that
the segack delay can be controlled by a user.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-01 10:27:27 +02:00
Ming Shao
5b84b0ac87 ztress: Coherence fix for tests/lib/spsc_pbuf
When CONFIG_KERNEL_COHERENCE=y, it's illegal to place shared
data(like ztress_context_data in this test case) on the stack,
because that memory is incoherent with respect to other CPUs
in the system.

In this specific case, it will cause PC register to load invalid
handler function pointer and crash the Xtensa processor.

Make it static.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-09-01 10:27:08 +02:00
Kumar Gala
482ed5b4e3 ipc: ipc_service: Update Kconfig
Utilize DT_HAS_<COMPAT>_ENABLED for devicetree based drivers

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-09-01 10:26:13 +02:00
Florian Grandel
856c985239 net: l2: ieee802154: security: fix several bugs
The IEEE 802.15.4 security implementation had several severe bugs:
* A regression introduced by 6ea225e34a
  (net/ieee802154: Finally removing usage of ll_reserve in L2)
  introduced a buffer leak (reading/ writing beyond the end of the frame
  buffer) and led the security implementation to malfunction in all but
  the simplest cases (i.e. encryption/authentication: none).
* Encryption vs. authentication modes were not properly implemented i.e.
  encryption was always active even if not required by the chosen
  encryption level.
* Nonce endianness was not correctly handled on decryption of packets
  which led to authentication failures.
* The frame counter was not checked for overflows.
* The encryption output buffer limit (out_buf_max) was not correctly set.
* Setting an invalid key mode led to a NULL pointer deref.
* We use CCM rather than CCM* as crypto.h does not provide access to
  CCM*. CCM does not support encryption-only operation, though. This
  condition was not checked by the code.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-31 21:52:37 +00:00
Florian Grandel
ed0060f5a0 net: l2: ieee802154: AF_PACKET support for IEEE 802.15.4
This change makes the packet socket and ieee802154 l2 drivers aware of
AF_PACKET sockets, see https://github.com/linux-wpan/wpan-tools/tree/master/examples
for examples which inspired this change.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-31 21:52:37 +00:00
Florian Grandel
43a7695dfe net: l2: ieee802154: publish re-usable constants
Some IEEE 802.15.4 specification constants must be made available in
userspace as they will be needed to use IEEE 802.15.4 RAW/DGRAM sockets
which will be introduced in this changeset.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-31 21:52:37 +00:00
Florian Grandel
705a8b6ea1 net: ieee802154: introduce consistent MTU definition
Zephyr IEEE 802.15.4 drivers and L2 stack use the same constant names
for different MTU definitions. The intent of this change is to introduce
a consistent MTU definition which can be used everywhere in zephyr to
avoid confusion, bugs and name conflict.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-31 21:52:37 +00:00
Morten Priess
da402c0830 Bluetooth: controller: Implements ISO Test Mode HCI commands
Implements the flollowing HCI commands:
- HCI_LE_ISO_Transmit_Test
- HCI_LE_ISO_Receive_Test
- HCI_LE_ISO_Read_Test_Counters
- HCI_LE_ISO_Test_End

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-08-31 21:50:13 +00:00
Krishna T
2a9b06b7c6 wifi_mgmt: Fix checkpatch warnings
Checkpatch says "else after return is not useful".

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
e2db4e690e wifi_shell: Fix the duplicate tag CI warning
Newly introduced Coverity scan throws a warning about duplicate tag as
per MISRA coding standards, so, use a unique tag name in the existing
code for "shell".

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
bcf7585429 wifi_shell: Rename Wifi to Wi-Fi
This is the standard.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
0f126a7adb wifi_mgmt: Add new API for Wi-Fi statistics
Networking statistics framework is used to define handler and the data
structure, Wi-Fi management layer implements the handler and also adds a
new offload API to get statistics from the Wi-Fi driver.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
1ecca68886 wifi_shell: Add new security methods
Add PSK_256, SAE and MFP settings.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
b5b11bbff0 wifi_mgmt: Add new API for Wi-Fi status
A new net_mgmt command and event are added for interface status,
depending on the implementation the status can be returned when polled
or an unsolicited event can be send by driver whenever there is a change
in status.

This is planned to be implemented only by upcoming wpa_supplicant,
offload implementation is left for driver developers.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
0e5c900400 wifi_mgmt: Implement checks for new security types
Extend checks for PSK-256 and SAE.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Anas Nashif
838f581300 tracing: ctf: change timer values to us instead of ms
Be consistent with timeout values and use micro seconds.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-31 16:04:01 -04:00
Anas Nashif
6a9540a773 tracing: ctf: add timer support
Add k_timer tracing to CTF and other formats.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-31 16:04:01 -04:00
Anas Nashif
f402e807dd tracing: ctf: remove unused metadata
Remove unused events.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-31 16:04:01 -04:00
Gerard Marull-Paretas
0cd311c4a1 include: fix files using legacy include paths
Some files were still using the already deprecated include path, fix
this.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-31 06:49:00 -04:00
Adam Wojasinski
47db797236 Bluetooth: controller: Replace deprecated nrfx API
This commit replaces API that became deprecated with the release
of nrfx2.9 - see CHANGELOG in zephyrproject-rtos:hal_nordic repository

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2022-08-31 10:43:14 +02:00
Ola Tangen Kulseng
00aa80bb8c net: lwm2m: thread safety in the rd client
Used the mutex in the client to protect the state transitions of
client.state.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-08-31 10:42:02 +02:00
Ola Tangen Kulseng
0a87c2d0d0 net: lwm2m: Thread safe lwm2m registry
Created the mutex registry_lock to:
- protect read and write operations
- protect the registry.
Only partially finished as the functions like lwm2m_engine_get_obj
warrants a larger refactoring to completely thread safe the registry.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-08-31 10:42:02 +02:00
Juha Heiskanen
534c7f2246 net: lwm2m: Fixed LwM2M message wrong error response
LwM2M was not reported properly case when message "Accept"
coap option was not not supported. In that case LwM2M transport
specification define 4.06 "Not Accepted"

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-31 10:41:49 +02:00
Pirun Lee
c4bd693d9a Bluetooth: OTS - Client APIs add Object Write sub-procedure
OTS client: Add object write function.
Also add write object callback.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2022-08-31 10:39:33 +02:00
Carles Cufi
7dde7f626f Revert "shell: Fix dependency to log_output"
This reverts commit b0072e1cea.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-30 17:28:05 -04:00
Carles Cufi
d03d17a7fa Revert "logging: cleanup in CMakeLists.txt"
This reverts commit af31cad836.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-30 17:28:05 -04:00
Gerard Marull-Paretas
2e0899e8ca pm: state: use DT_FOREACH_CHILD_SEP
Avoid usage of auxiliary macros by using DT_FOREACH_CHILD_SEP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-30 16:19:57 +02:00
Ola Tangen Kulseng
24a84ae743 net: lwm2m: Documentation of the lwm2m engine
I've provided documentation for the API's
- lwm2m_registry.h
- lwm2m_engine.h

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-08-30 14:19:05 +00:00
Vinayak Kariappa Chettimada
94710e0f6d Bluetooth: Controller: Kconfig to permit periodic sync event skip
When AUX_ADV_IND or AUX_CHAIN_IND auxiliary channel PDU scan
radio event overlaps Periodic Sync radio event in unreserved
time space, let the Periodic Sync radio event be aborted so
that the auxiliary channel PDU can be received to generate
Extended Advertising Reports. Added a new Kconfig to enable
this.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-30 10:30:16 +02:00
Emil Gydesen
32b2a3e218 Bluetooth: Audio: Update audio shell with location in cmd_init
Set the location in the init command. Also updates the
available context to the CONTEXT macro value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-30 10:27:00 +02:00
Hang Fan
5b8b3a74d6 Bluetooth: audio: mcc: add NULL check for mcs instance
Add NULL check for mcs instance to avoid access violation crash.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-08-30 10:25:36 +02:00
Veijo Pesonen
862cabc48c net: lwm2m: Fixes FOTA update result code
The update result is supposed to indicate success only after a firmware
update has been applied. The bug here was that the success was reported
already when the update image download was done.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-08-29 11:38:53 +02:00
Kai Vehmanen
8195ea7ea0 logging: Intel ADSP mtrace logging backend
Implements a logging backend implementing the mtrace protocol
to relay log messages over SRAM. This protocol is implemented
by the SOF Linux driver ("mtrace" debugfs interface).

This implementation follows example of the ADSP HDA logger implemented
in commit 6913da9ddd ("logging: cAVS HDA based logger").

Cc: Tom Burdick <thomas.burdick@intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-08-29 10:43:42 +02:00
Ming Shao
be392fc23b ztress: fix the progress stats
Current ztress design supports both timer context and thread
context. The timer context always uses the first element of
several global array variables like exec_cnt[] and backoff[].
But progress_timeout() is using the last element of exec_cnt[]
to calculate the progress of timer context. It is not right.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-29 10:32:10 +02:00
Anders Storrø
32ebeb0a5c Shell: Increase ARGC_MAX default val
Increase deafult value of SHELL_ARGC_MAX configuration.
This allows users to utilize deeper nested shell menus without
risking maxing out the number of allowed arguments.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-08-29 10:31:38 +02:00
Yuval Peress
61fb681036 ztest: Match cleanup ordering between unittest and normal tests
Tests with KERNEL enabled perform their cleanup logic after the suite's
after and test rules are executed. Unittests should do the same.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Yuval Peress
5ceba48473 ztest: Safely handle fail/skip/pass outside tests
Updates the implementation when KERNEL is available to safely bail on
the test when the test calls fail, skip, or pass during invalid test
phases. Print a detailed message, and skip all other tests. The test
run will be marked as failed.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Yuval Peress
20475bff0e ztest: move get_friendly_phase_name to common code
Move the function used for printing the phase name up so its available
for both unittest and KERNEL mode of tests.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Yuval Peress
5b6b304e3c ztest: unittest: Fix fail/skip/pass outside of tests
When not running in setup, before, or in the test. Calling fail, skip,
or pass is invalid and should be considered an error. Properly handle
these cases by printing a more detailed error message and bailing the
process.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Yuval Peress
2a110cc473 ztest: unittest: Add before/after phase
Add missing setters for the before/after phase when running without
KERNEL.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Yuval Peress
08db645d81 ztest: move end_report implementation
Move the implementation of end_report so it can be used by both code
paths (with and without KERNEL).

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Yuval Peress
cdb961eac6 ztest: remove init_testing
When KERNEL was not defined (unittest), the call to init_testing was
used to set a longjump target using 'stack_fail'. When triggered,
this was actually causing a segfault, because longjmp is only valid
if going directly up the stack. Since init_testing returned, it was
no longer on the stack. Instead, that logic MUST be inlined.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Jamie McCrae
fc64b77ab1 mgmt: mcumgr: Split up transport Kconfig into separate files
Makes each mcumgr transport have a separate Kconfig file for ease of
maintenance

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-08-26 21:34:38 -04:00
Tom Burdick
3a4864bdd2 logging: adsp hda backend improvements
* Adds a default hook and init function for cavstool.
* Adds an optional padding on flush feature to ensure all data is written.
* Fixes an error in cavstool.py for correctly wrapping the ring buffer.
* The test case now ensures wraps and flushes occur numerous times.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-08-26 21:33:10 -04:00
Herman Berget
096fc3b826 Bluetooth: Increase RX thread stack size
Normal usage for Bluetooth applications are getting close to or
already overflowing the default BT RX stack size of 1024.

For example:
 - Discovery using the fixed ATT channel used 984 bytes.
 - Discovery using an enhanced ATT channel used 1048 bytes,
   which would lead to stack overflow using the default BT RX thread
   stack size.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-26 12:52:22 +02:00
Krzysztof Chruscinski
bb74b4f028 lib: os: cbprintf: Renamed flags used for conversion function
At some point, package copy function was extended and renamed
to cbprintf_package_convert. However, flags used by this
function were not renamed and used contained COPY idiom.
Deprecating flags with COPY and replacing them with flags
with CONVERT idiom to match function which is utilizing them.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-26 12:52:08 +02:00
Jakob Krantz
605d8c85d8 Bluetooth: Host: Fix invalid sync term callback params
When using periodic advertising list and receiving
hci_le_per_adv_sync_established event from controller with
an error code the bt_le_per_adv_sync_term_info would be
incorrectly populated with le_addr and sid. This is because
the current pending advertising sync object is not populated
with any le_addr and sid from bt_le_per_adv_sync_create as
those are not used when option
BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST is set.

Instead the bt_le_per_adv_sync_term_info shall be populated
with the le_addr and sid coming in the event from controller.

Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
2022-08-26 12:51:05 +02:00
Erik Brockhoff
7719bc6785 Bluetooth: controller: llcp: fix unhandled rsp in periph phy upd proc
Re. peripheral phy update procedure: UNKNOWN_RSP from central was not
handled, leading to stall of procedure and subsequent procedure timeout

Proper handle and unit test for case added.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-08-26 11:56:33 +02:00
Emil Gydesen
70dfbb6747 Bluetooth: Audio: Add missing NULL checks when looking up audio_iso streams
Multiple places we assumed that we could simply just do
sink_stream->iso == chan without checking if sink_stream
was NULL.

This commit fixes that by adding proper NULL checks for that,
as well as additional checks before defaulting to the
source_stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-26 11:56:15 +02:00
Krzysztof Chruscinski
af31cad836 logging: cleanup in CMakeLists.txt
log_output.c was added in two places: unconditionally when logging
is enabled and when CONFIG_LOG_OUTPUT is set. Cleaning up to add
source file only when module is enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-25 12:18:26 +02:00
Krzysztof Chruscinski
b0072e1cea shell: Fix dependency to log_output
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-25 12:18:26 +02:00
Stephanos Ioannidis
074b7f4ecd Bluetooth: Define global Bluetooth address constants
The Bluetooth address constants (BT_ADDR[_LE]_ANY, BT_ADDR[_LE]_NONE)
are currently defined as the address of the local anonymous structs
that are initialised to the corresponding address values, and assigning
them to a variable whose scope is greater than that of a function may
end up creating dangling pointers (for instance, as done in the
`bt_conn_get_info` function).

This commit defines the Bluetooth address constants as global constant
variables that are placed in the read-only data section, and modifies
the Bluetooth address constant macros to use the address of these
variables instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-25 12:18:09 +02:00
Stephanos Ioannidis
13885bd6d5 Bluetooth: Host: Monitor: Make addr param const in bt_monitor_new_index
This commit adds the `const` qualifier to the `addr` parameter of the
`bt_monitor_new_index` function because this parameter is and should
never be modified within this function.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-25 12:18:09 +02:00
Stephanos Ioannidis
97f9a16ed1 Bluetooth: Host: GATT: Make addr param const in find_sc_cfg
This commit adds the `const` qualifier to the `addr` parameter of the
`find_sc_cfg` function because this parameter is and should never be
modified within this function.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-25 12:18:09 +02:00
Jakub Rzeszutko
5e33b2daea shell: add backends command
Add command that lists all active shell backends.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2022-08-25 12:13:37 +02:00
Vinayak Kariappa Chettimada
689bf9b015 Bluetooth: Controller: Fix uninitialized adv mode in scan rsp PDU
Fix uninitialized adv mode value in the scan response PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-24 12:41:21 +02:00
Gerson Fernando Budke
b0564dfd97 zephyr/ztest_assert.h: Fix implicit to bool conversion
The current zassert macro uses implicit conversion to boolean which
has implication on analysis tools like clang-tidy-14. This add an
aditional step to create a boolean value for the evaluation instead
use the string direct which allows run analysis tool without this
warning/error.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2022-08-24 10:06:53 +02:00
Vinayak Kariappa Chettimada
4938d2a0d4 Bluetooth: Controller: Fix regression in overlapping 1M and Coded Scan
Fix regression in overlapping 1M and Coded PHY scan window
by considering rounding margins when checking for same
interval and same window durations.

Relates to commit c14bde45b6 ("Bluetooth: Controller: Fix
overlapping 1M and Coded PHY scannning").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-24 10:04:20 +02:00
Daniel DeGrasse
1a9d470fab sd: fix spelling in sdmmc_decode_csd
Fix spelling in sdmmc_decode_csd to use count instead of cout. Shortening
the variable name here was needlessly confusing.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-08-23 11:12:37 -05:00
Emil Gydesen
d62223e930 Bluetooth: Audio: Fix unicast_client avail ctx dir check
The unicast_client_pacs_avail_ctx_notify_cb had a direction
check that was a leftover copy from the location notification.

However the context notification is always for both sink and
source, and thus does not need any direction checks (in fact
the dir variable was unused).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-23 16:24:24 +02:00
Mariusz Skamra
a120af8f33 Bluetooth: audio: ascs: Fix missing metadata reset before update
The old metadata shall be reset (simply set the couynt to zero) before
reuse or update.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-23 16:22:11 +02:00
Mariusz Skamra
c57ba529dc Bluetooth: audio: ascs: Remove invalid check
This fixes invalid check, which is redundant in fact as the length
is already checked in ascs_parse_metadata function.
The check be test 'greater than' only, as 'equal' condition is valid.
Moreover this fixes return value from ascs_verify_metadata function.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-23 16:22:11 +02:00
Anders Storrø
5f8168d5dd Bluetooth: Mesh: Health_cli: Fix fault test rsp
Swaps response scheme for Fault_test command so that it
aligns with description of the documentation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-08-23 16:21:54 +02:00
Vinayak Kariappa Chettimada
ce0f65e768 Bluetooth: Controller: Enable back-to-back PDU chaining
When AD data length of greater than 191 bytes support is
enabled then default to using the back-to-back PDU chaining
feature in the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-23 16:21:00 +02:00
Vinayak Kariappa Chettimada
f736498b2a Bluetooth: Controller: Fix parent PDU's aux offset in aux ptr field
Fix Extended Advertising and Periodic Advertising's parent
PDU's aux ptr field to contain correct aux offset value to
its chain PDU.

Uninitialized pointer reference to aux ptr in the parent PDU
was used before the pointer reference was returned by the
function adding the aux ptr fields in the parent PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-23 16:21:00 +02:00
Vinayak Kariappa Chettimada
a08e8ef88d Bluetooth: Controller: Use local variable for current PDU's flags
Use local variable to update current PDU's Common Extended
Header Format flags instead of updating it directly in the
PDU buffer. This is required to be able to non-destructively
be able to manipulate the PDU's header flags and contents
many time before a final commit of the updated PDU.

In order to calculate overflowed AD data length, PDU is
manipulated couple of times to determine the overflow length
and next to be able to add aux ptr field when chain PDU is
appended.

The changes are now consistent with how Periodic Advertising
PDU's Common Extended Header Format is manipulated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-23 16:21:00 +02:00
Vinayak Kariappa Chettimada
5ed463008b Bluetooth: Controller: Fix regression in adding ADI in scan rsp PDU
Fix regression in adding ADI in scan response PDU introduced
in implementation adding support for AD data fragment
operation.

Setting scan response data with ADI failed with too long
data error. This was caused by a bug in calculating the
offset to the overflow length returned back by the call
to set_clear function.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-23 14:50:17 +02:00
Anders Storrø
3dccd319b6 Bluetooth: Mesh: Cfg_cli: Fix appkey get rsp
Adds missing feature so that the config client is able to receive
odd number of app index entries.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-08-23 10:20:34 +00:00
Pieter De Gendt
155f42a9fa task_wdt: Fix build warning on 64-bit platforms
When building for 64-bit platform (tested on native_posix_64), there
was a cast warning for different sizes.

A void * is used to store a simple ID, fixed by using uintptr_t instead.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-08-23 10:16:04 +02:00
Pavel Vasilyev
1659ac4392 Bluetooth: Mesh: Use mesh settings API only if settings are enabled
Don't call bt_mesh_settings_store_pending if CONFIG_BT_SETTINGS is not
enabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-08-22 16:38:02 +00:00
Eric Johnson
7f74797b8f shell: Fix handling mandatory args with optional raw arg
Previous code provided incorrect argc value to handlers when a command
used SHELL_OPT_ARG_RAW option.

Fixes #48380

Signed-off-by: Eric Johnson <eric.johnson2@walgreens.com>
2022-08-22 16:29:59 +00:00
Gerard Marull-Paretas
a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Piotr Pryga
2b57c0716b Bluetooth: Remove default n from common Kconfig
The commit is a minor refactor of the common Host and Controller
Kconfig. There were used "default n" that should be avoided.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-08-19 16:26:10 +02:00
Piotr Pryga
939578e79d Bluetooth: hci: df: Fix unnecessary IQ sample storage
In case Controller reports to Host insufficient resources to store IQ
samples, according to BT 5.3 Core spec. Vol 4, Part E, sections
7.7.65.21 and 7.7.65.22:
1) packet_status shall be set to BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES
2) sample_count shall be set to zero.
That means there should be no IQ samples stored in IQ report.

HCI implementation stored single IQ sample with value BT_HCI_LE_CTE-
_REPORT_NO_VALID_SAMPLE.

The commit fixes that. No additional memory is added to event buffer
and no IQ sample is stored if sample_count is zero.

Also there is added code that handles situation where ULL provides
IQ report with packet_status indicating valid IQ samples report
but sample_count is zero. In such case Host event stores single IQ
sample with value BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE.
In case of vendor specific counter part of the event the value is
BT_HCI_VS_LE_CTE_REPORT_NO_VALID_SAMPLE.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-08-19 16:26:10 +02:00
Piotr Pryga
56262f8207 Bluetooth: Host: Add common handling of VS IQ report
Bluetooth Controller has a vendor specific extensions that allows it
to send IQ report events with IQ samples that are 8 bits or 16 bits
signed integer. To use that functionality, there is added common
handler of vendor specific events.

Vendor specific events handling is prioritized to be done by user
provided event handler. If that is not available, then Host generic
implementation enters.

Added vendor specific events that are handled by common Host code
are BT_HCI_EVT_VS_LE_CONNECTIONLESS_IQ_REPORT and BT_HCI_EVT_VS_LE-
_CONNECTION_IQ_REPORT.

The only difference between regular IQ report events is size of
IQ samples, hence implementation of IQ report events is changed to
use the same user callback. To avoid differentiation of user callbacks
new member sample_type was added to bt_df_per_adv_sync_iq_samples-
_report. Also sample member is changed to be a union, to allow easy
access to IQ samples without type casting.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-08-19 16:26:10 +02:00
Piotr Pryga
d8d8ef74ce Bluetooth: hci: Add VS IQ samples report using 16 bit sign integer sampl
Add vendor specific IQ samples report that holds IQ data in 16 bits
signed integer format. Thanks to that we preserve complete accuracy of
IQ samples provided by Nordic Direction Finding Extension in Radio
peripheral. That helps to maintain better accuracy of evaluated
angles with use of reported IQ samples.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-08-19 16:26:10 +02:00
Jonathan Rico
43e1ae1452 Bluetooth: host: gatt: Properly check subscription status
We had two bugs:

- we didn't check the subscription, only the fact that the passed chrc can
be subscribed to.

- that check only worked if we passed the chrc descriptor handle, not its
value handle.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-19 14:09:43 +02:00
Jonathan Rico
fae5dd3643 Bluetooth: gatt: allow disabling subscription enforcement
This introduces a new option that allows the user to disable the
subscription checking when notifying or indicating.

Some users might have use-cases where they would like to send notifications
or indications without the peer having to go through the subscription
process, as that is allowed by the Bluetooth specification.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-19 12:14:21 +02:00
Mariusz Skamra
9c7ef8ea06 Bluetooth: audio: tbs: Fix List_Item_Length value in CCL
This fixes setting invalid List_Item_Length in Current Calls List.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-19 12:09:46 +02:00
Mariusz Skamra
3253ad2ab8 Bluetooth: audio: tbs: Make bt_tbs_client_call to contain URI pointer
To avoid compilation issues when including tbs.h header file when
CONFIG_BT_TBS_MAX_URI_LENGTH is not set, just pass the URI pointer
instead of an array in bt_tbs_client_call structure.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-19 12:09:46 +02:00
Mariusz Skamra
1b7aafc424 Bluetooth: audio: tbs: Factor out bearer_list_current_calls function
To avoid code duplicates, this factors out common code to separate
function.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-19 12:09:46 +02:00
Aleksandr Khromykh
5a0aa47383 Bluetooth: Mesh: fix adding in sublist the same addresses
If LPN loses Subscription List Add Confirmation it repeats
Subscription List Add frame. Friend doesn't check both
transaction number and presence addresses in the list.
That causes situation when Friend fills the same address
full list.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-08-19 12:08:27 +02:00
Aleksandr Khromykh
3f88dcaaff Bluetooth: Mesh: add more latency for scanner in lpn
With extended advertiser a precision of transmission becomes high.
The first frame is emitted quite quickly. The scanner latency
config option to enable scanner a bit in advance is not sufficient.
Sometimes replays on Friend Poll are lost.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-08-19 12:08:27 +02:00
Mariusz Skamra
ea5f59f896 Bluetooth: shell: Add LE Audio related advertisement data
This adds LE Audio related data to the shell advertisement data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-19 12:07:31 +02:00
Mariusz Skamra
6219c12035 Bluetooth: csis: Expose bt_csis_generate_rsi function
The function will be used to update the RSI value. The returned value
can be later used in advertisement data for set identification. This
removes the need of specific bt_csis_advertise function so that the user
can call the API to generate new RSI once needed (e.g. on RPA change).
This allows the user to manage the advertisement data to fit it's needs.

< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
        Extended advertising: Disabled (0x00)
        Number of sets: 1 (0x01)
        Entry 0
          Handle: 0x00
          Duration: 0 ms (0x00)
          Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 33
        Handle: 0x00
        Operation: Complete extended advertising data (0x03)
        Fragment preference: Minimize fragmentation (0x01)
        Data length: 0x1d
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Unknown EIR field 0x2e: 16e61d64dc45
        Name (complete): audio test shell
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Data (0x08|0x0037) ncmd 1
	Status: Success (0x00)
< HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7
        Advertising handle: 0x00
        Advertising random address: 4E:21:29:F8:94:93 (Resolvable)
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Advertising Set Random Address (0x08|0x0035) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
        Extended advertising: Enabled (0x01)
        Number of sets: 1 (0x01)
        Entry 0
          Handle: 0x00
          Duration: 0 ms (0x00)
          Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
        Status: Success (0x00)

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-19 12:07:31 +02:00
Herman Berget
62ff17df21 Bluetooth: Host: Get first packet matching channel
When sending an ATT packet, do not just try to send the first packet in
the queue, but find the first one that can be sent using the channel.
This makes sure that eg. packets that shall be sent on an unenhanced ATT
channel are not blocked by packets that shall be sent on enhanced ATT
channels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Herman Berget
62218910a0 Bluetooth: Host: Move all sending from tx_queue to process_queue
Similar functionality was implemented in two places.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Herman Berget
cc81529d58 Bluetooth: Host: Fix bt_eatt_connect returning -EINVAL if conn is NULL
bt_eatt_connect was documented to return -EINVAL if conn is NULL, but
this was not the case. Instead it lead to undefined behavior.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Herman Berget
ccaa7b291e Bluetooth: Host: Check if channel option is valid
Disallow trying to send requests or notifications on only EATT channels
if no EATT channels are connected or the link is not encrypted. In these
cases the operation will always fail, so it should not be queued.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Herman Berget
7f740cbd46 Bluetooth: Shell: Use chan_opt BT_ATT_CHAN_ANY
The chan_opt field of GATT parameter structs must be set.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Herman Berget
741fe73f74 Bluetooth: Host: Add option to use GATT over EATT
A channel option field has been added to the bt_gatt_*_params structs.
This allows the application to choose wether Unenhanced ATT, Enhanced
ATT, or Any ATT channel shall be used for the
request/command/indication/notification.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-08-19 11:59:52 +02:00
Gerard Marull-Paretas
e0125d04af devices: constify statically initialized device pointers
It is frequent to find variable definitions like this:

```c
static const struct device *dev = DEVICE_DT_GET(...)
```

That is, module level variables that are statically initialized with a
device reference. Such value is, in most cases, never changed meaning
the variable can also be declared as const (immutable). This patch
constifies all such cases.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Gerard Marull-Paretas
42b53e46aa logging: initialize devices at compile time
Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Gerard Marull-Paretas
50fb146985 tracing: initialize devices at compile time
Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Gerard Marull-Paretas
745db7afd4 ipc: rpmsg_service: initialize devices at compile time
Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Gerard Marull-Paretas
b402ac7b82 fb: initialize devices at compile time
Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Gerard Marull-Paretas
0f2003eee6 bluetooth: host: initialize devices as compile time
Initialize monitor UART device at compile time so that device pointer
can be constified.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Gerard Marull-Paretas
51932c2cec random: initialize devices at compile time
Initialize devices at compile time so that device pointer can be
constified.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Andy Ross
02b23f3733 arch/posix: Add MemorySanitizer support
Wire this up the same way ASAN works.  Right now it's support only by
recent clang versions (not gcc), and only in 64 bit mode.  But it's
capable of detecting uninitialized data reads, which ASAN is not.

This support is wired into the sys_heap (and thus k_heap/k_malloc)
layers, allowing detection of heap misuse like use-after-free.  Note
that there is one false negative lurking: due to complexity, in the
case where a sys_heap_realloc() call is able to shrink memory in
place, the now-unused suffix is not marked uninitialized immediately,
making it impossible to detect use-after-free of those particular
bytes.  But the system will recover cleanly the next time the memory
gets allocated.

Also no attempt was made to integrate this handling into the newlib or
picolibc allocators, though that should hopefully be possible via
similar means.

Signed-off-by: Andy Ross <andyross@google.com>
2022-08-19 08:30:01 +02:00
Andy Ross
74cc534758 cmake: Update CONFIG_ASAN support
This had bitrotten a bit, and didn't build as shipped.  Current
libasan implementations want -fsanitize=address passed as a linker
argument too.  We have grown a "lld" linker variant that needs the
same cmake treatment as the "ld" binutils one, but never got it.  But
the various flags had been cut/pasted around to different places, with
slightly different forms.  That's really sort of a mess, as sanitizer
support was only ever support with host toolchains for native_posix
(and AFAICT no one anywhere has made this work on cross compilers in
an embedded environment).  And the separate "gcc" vs. "llvm" layers
were silly, as there has only ever been one API for this feature (from
LLVM, then picked up compatibly by gcc).

Pull this stuff out and just do it in one place in the posix arch for
simplicity.

Also recent sanitizers are trying to add instrumentation padding
around data that we use linker trickery to pack tightly
(c.f. SYS_INIT, STRUCT_SECTION_ITERABLE) and we need a way
("__noasan") to turn that off.  Actually for gcc, it was enough to
just make the records const (already true for most of them, except a
native_posix init struct), but clang apparently isn't smart enough.

Finally, add an ASAN_RECOVER kconfig that enables the use of
"halt_on_error=0" in $ASAN_OPTIONS, which continues execution past the
first error.

Signed-off-by: Andy Ross <andyross@google.com>
2022-08-19 08:30:01 +02:00
Szymon Czapracki
aa7533380c Bluetooth: audio: Add missing 'or' in service declaration
Fix missing or symbol in service declaration

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-08-18 21:40:23 +00:00
Steven Slupsky
fe716dbb09 pm: stats: fix typo
There is a typo in argument for the STATS_NAME_INIT_PARMS macro.
This causes an error during build.
The correct reference should be "pm_stats".

Signed-off-by: Steven Slupsky <sslupsky@gmail.com>
2022-08-18 15:13:47 -05:00
Daniel Leung
c9955cf861 testsuite: coverage: pin gcov sections for demand paging
This adds the bits to pin the GCOV sections to the pinned
sections so they can be accessed during boot when demand
paging is enabled. Or else accessing them would result in
page faults.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-18 17:23:18 +02:00
Daniel Leung
ade3394f11 testsuite: coverage: align rodata section
This adds an ALIGN statement to the rodata linker snippet
for coverage. Without this, sometimes the section is not
aligned, but __init_array_start indicates an aligned
address, resulting in incorrect function pointers.
So align it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-18 17:23:18 +02:00
Torsten Rasmussen
7a65bdbd64 cmake: kconfig: introduce dedicated unit testing board
This commit introduces a dedicated unit testing board.

Today, a dedicated Zephyr unit testing scheme exists but is different
from how a Zephyr build generally works.

For example Kconfig is not possible, resulting on various different
hacks to pass Kconfig settings from test cases / testcase.yaml through
CMake to the code.
Some directly as compile definitions, some as header files with forced
inclusion on sources, some with wrapper flags which again results in
different define being enabled. There is even cases where a second
forced header inclusion undefines previous defines.

Unit test often does a manual check for the right boards, like this:
> if (NOT BOARD STREQUAL unit_testing)
>    message(FATAL_ERROR "This project can only be used with...")
> endif()

Introducing a dedicated unit_testing board under `tests/root` allows
us to use Kconfig in unit test samples, and thus proper `prj.conf` and
extra Kconfig fragments.
Generation of autoconf.h so the overall architecture follows regular
Zephyr builds.

Proper and uniform error messages when invalid board is selected.

The unit_testing board and arch is located under: `subsys/testsuite` so
that it is only available when find_package(Zephyr COMPONENTS unittest)
is used, and not available for regular Zephyr builds.

Kconfig generates autoconf.h which is applied as compile flag to
test binary which means that kconfig defines placed in ztest.h can now
be removed.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Yong Cong Sin
dd9d6bbb44 subsys/mgmt/hawkbit: Set ai_socktype if IPV4/IPV6
Follows the implementation of updatehub and set the
`ai_socktype` only if IPV4/IPV6

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-08-18 11:33:38 +00:00
Yong Cong Sin
2ed88e998a subsys/mgmt/hawkbit: Init the hints struct to a known value
Initialize the `hints` struct to a known value so that it won't
cause undetermined behavior when used in `getaddrinfo()`.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-08-18 11:33:38 +00:00
Aleksander Wasaznik
cdfe085cfb Bluetooth: Host: Add CONFIG_BT_PRIVACY_RANDOMIZE_IR
This new option prevents the Host from using Controller-provided
identity roots. This potentially increases privacy.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-08-18 13:04:35 +02:00
Aleksander Wasaznik
058dc7c0bc Bluetooth: Host: Refactor bt_setup_public_id_addr
Move the flagging of `BT_DEV_STORE_ID` to a separate if-statement.

This clarifies the meaning of the code, and paves way for wrapping the
if-statement with the call to `bt_smp_irk_get` in another conditional.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-08-18 13:04:35 +02:00
Dominik Ermel
323422e8c2 dfu: Fix write block size check on, probably, incorrect device
The write block size has been gathered from device pointed by
chosen 'zephyr,flash', while it should be taken from a device
a target image flash area resides on.
The write block size has been used to check if write buffer
is properly aligned.
The check is only possible on devices that have write-block-size
property in DTS, so in case of SPI connected devices this property
may not be available - when device does not have the property,
the check is not performed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-08-18 12:51:20 +02:00
Emil Gydesen
3dbc13c4ae Bluetooth: Audio: Fix issue with registering VOCS callbacks
When registering VOCS callbacks via bt_vcs_client_cb_register
it could fail if the application did not reset the
vocs_cb.discover as that is set internally.

This commit adds a simple check to also allow the
vocs_cb.discover to be the callback VCS expect/want it to be.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-18 12:50:19 +02:00
Emil Gydesen
2b0f98b4fc Bluetooth: Audio: Fix issue with registering AICS callbacks
When registering AICS callbacks via bt_vcs_client_cb_register
or bt_micp_mic_ctlr_cb_register it could fail if the application
did not reset the aics_cb.discover as that is set internally.

This commit adds a simple check to also allow the
aics_cb.discover to be the callback they expect/want it to be.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-18 12:50:19 +02:00
Daniel DeGrasse
ba9220c5bd sd: sdmmc: wait before sending second OCR
introduce a small wait between probing and initialization OCR. This
delay fixes a failure to initialize seen on some SD cards

Fixes #47238

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-08-18 12:49:03 +02:00
Emil Gydesen
2647bc0cf5 Bluetooth: Audio: Fix NULL pointer ref in bt_csis_lock
bt_csis_lock would call write_set_lock with `attr` set to
NULL, which was dereferenced to get the bt_csis instance.

This commit modified the functions such that we instead have
common function to handle changes to the lock value, called
from either the GATT write callback function, or the
bt_csis_lock, so that we have a clearer separation of what
the individual functions do.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-18 12:48:51 +02:00
Mariusz Skamra
541d946d10 Bluetooth: audio: Add HAS client support for preset switching
This adds client support for switching the active preset along with bsim
tests implementation.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-18 12:46:27 +02:00
Emil Gydesen
b8cdf9d0a6 Bluetooth: Audio: Fix issue with reset QoS on state change
The unicast client would simply reset all existing ISO QoS
when there was a state change to the QoS state (and only
update the stream QoS).

This caused issue with some ISO check later, as well
as wrongly resetting the data path too.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-18 12:33:44 +02:00
Emil Gydesen
9e9ea2146c Bluetooth: ISO: Add check for maximum ISO SDU size
Verify that the HCI ISO data packet is smaller than
the maximum SDU size we support, based on the group
settings.

Since we do not yet support fragmentation we also
verify that the data length is smaller than the
HCI ISO buffer size.

For the ISO peripheral is it not possible to know
the SDU, and we are forced to not send any value larger
than the PDU size.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-18 12:33:44 +02:00
Neil Armstrong
fe7ffcf2e8 tls_credentials: add Trusted Credential storage backend
This adds a Trusted Credential storage backend using the PSA
Protected Storage API, permitting storage of the credentials
offering a trusted long-term storage with integrity checks.

This implementation tries to fit the actual tls_credentials
implementation, with some slight differences:
- the buffer pointer returned by credetial_get & credential_next_get
  is dynamically allocated and differs from the one given to
  tls_credential_add since it's extracted from the storage at runtime.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2022-08-18 12:33:07 +02:00
Jackson Cooper-Driver
09cb88edcf ipc_service: Add ipc_service_deregister_endpoint function
In the case that an endpoint goes down, it needs to be deregistered
from the ipc_service for cleanup. This function deregisters the endpoint
from the ipc_rpmsg instance and sets the endpoint to zero.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-08-18 12:32:21 +02:00
Nicolas VINCENT
80c97c37de fcb_settings: Use weak function to get storage flash area
On MCU with bank swap capabilities, the offset of the storage area is
not the same before and after a bank swap. This commit introduce a weak
function which returns the default flash area of the storage partition.
On MCU with the bank swap capability the user can define its own
function to get the proper flash area depending on which bank the fw is
run from.
This commit is a workaround for #47732

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2022-08-18 12:31:43 +02:00
Emil Gydesen
0277682a33 Bluetooth: ISO: Add check for pending ISO connections
Per the HCI spec it is not possible to send the
HCI_LE_Create_CIS command while an outstanding request
is pending. To avoid failing the command we can
check and verify if any ISO connections are in the
pending state.

Since multiple ISO channels can be connected
in a single request, the solution implemented was
to iterate over all ISO connections and see if there was
any unicast ISO channels in the connecting state.

It also checks for the encryption pending state, as
we should not start the encryption procedure if we know
that the connect ISO command cannot be completed afterwards.

This adds a new return value to bt_iso_chan_connect,
and decided to properly document the return values the
function can return.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-18 12:30:58 +02:00
Théophile Ranquet
f044a356dd shell: typos
This addresses a few typos in the filesystem shell.

Signed-off-by: Théophile Ranquet <theophile.ranquet@gmail.com>
2022-08-18 12:25:39 +02:00
Steven Slupsky
fd1423620e storage: flash_map: fix incomplete type
A pointer is not properly declared properly which causes the
build to fail.

flash_map_shell.c and flash_map.h do not include device.h so
the device struct has an incomplete type hence the build error.
Including device.h resolves the problem.

Also fixes a Wformat warning when referencing fa_off which is a pointer.
Cast the pointer to an uint32_t.

Fixes #48722

Signed-off-by: Steven Slupsky <sslupsky@gmail.com>
2022-08-18 11:20:26 +02:00
Henrik Brix Andersen
27eb12ed48 net: socketcan: decouple SocketCAN and CAN controller headers
Decouple the zephyr/net/socketcan.h and zephyr/drivers/can.h header files
by moving the SocketCAN utilities to their own header.

This is preparation for including the SocketCAN types defined in
socketcan.h in a native posix (Linux) SocketCAN driver context without name
clashes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen
d1d48e8304 net: socketcan: rename SocketCAN header from socket_can.h to socketcan.h
Rename the SocketCAN header from socket_can.h to socketcan.h to better
match the naming of the functionality.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen
b40a8cb9fd net: socket: can: rename utility functions
Rename the SocketCAN utility functions to reflect the new naming of the CAN
controller API and SocketCAN API data types.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen
13c75417ba drivers: can: remove z prefix from public CAN API types
Remove the "z" prefix from the public CAN controller API types as this
makes them appear as internal APIs.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen
d159947443 net: socket: can: prepend SocketCAN data types with socketcan
Rename the SocketCAN data types to "socketcan_*" in preparation of renaming
the low-level CAN controller API data types.

This breaks the naming compatibility with the similar SocketCAN data types
from the Linux kernel, but Zephyr and Linux SocketCAN are not 100%
compatible anyways (only the structure fields are compatible, extended
functionality such filtering, error reporting etc. are not).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Juha Heiskanen
b0c794305c net: lwm2m: Fix to Queue update process triggering
Fix that broken Queue client for stop looping
"ENGINE_REGISTRATION_DONE_RX_OFF" state.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-18 10:19:11 +02:00
Ahmed Moheb
807c715cec bluetooth: host: buf: Remove redundant 'evt_discardable_count' check
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT is defined by default and the
value ranges from 1 to 255.
So, checking if this parameter is defined seems to be redundant

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-08-17 22:36:45 +03:00
Kumar Gala
e950c2184e emul: emul_sbs_gauge: Fix compile
EMUL_DEFINE was removed and replaced.  Update code to use new
EMUL_DT_INST_DEFINE.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-17 12:47:16 -05:00
Peter Mitsis
f86027ffb7 kernel: pipes: rewrite pipes implementation
This new implementation of pipes has a number of advantages over the
previous.
  1. The schedule locking is eliminated both making it safer for SMP
     and allowing for pipes to be used from ISR context.
  2. The code used to be structured to have separate code for copying
     to/from a wating thread's buffer and the pipe buffer. This had
     unnecessary duplication that has been replaced with a simpler
     scatter-gather copy model.
  3. The manner in which the "working list" is generated has also been
     simplified. It no longer tries to use the thread's queuing node.
     Instead, the k_pipe_desc structure (whose instances are on the
     part of the k_thread structure) has been extended to contain
     additional fields including a node for use with a linked list. As
     this impacts the k_thread structure, pipes are now configurable
     in the kernel via CONFIG_PIPES.

Fixes #47061

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-08-17 19:31:25 +02:00
Aaron Massey
2bc23e0543 ztest: Add docstring for zassume macro
Add a detailed docstring to the zassume() macro that describes what it does
and how its usage is different from zassert.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-08-17 18:02:26 +02:00
Anders Storrø
348d977124 Bluetooth: Mesh: Health_cli: Fix async cmd rsp
Swaps response scheme for Fault_get & Fault_clear command so that it
aligns with description of the documentation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-08-17 15:52:01 +00:00
Abe Levkoy
c7b0b13fb2 emul: Update EMUL_DEFINE usages in emulators
Use EMUL_DT_INST_DEFINE instead.

Part of #45976.

Signed-off-by: Abe Levkoy <alevkoy@google.com>
2022-08-17 15:47:52 +00:00
Hang Fan
9d06245fe7 Bluetooth: audio: check MCS characteristic properties before subscribe
MCC need to check characteristic properties before subscribe as not all
MCS characteristics support notify.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-08-17 17:05:23 +02:00
Mariusz Skamra
0175e23695 Bluetooth: shell: Fix Unicast Client Source endpoint pool size
Fix using proper Kconfig value for defining endpoint pool size.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-17 12:10:51 +02:00
Mariusz Skamra
bacc4953e9 Bluetooth: audio: Reject QoS if CIS is already is use in this direction
As per ASCS_v1.0
If a client requests a Config QoS operation for an ASE that would
result in more than one (Sink/Source) ASE having identical CIG_ID
and CIS_ID parameter values for that client, the server shall not
accept the Config QoS operation for that ASE.
The server shall send a notification of the ASE Control Point
characteristic to the client, the server shall set the Response_Code
value for that ASE to 0x09 (Invalid Parameter Value), and the server
shall set the Reason value for that ASE to 0x0A
(Invalid_ASE_CIS_Mapping).

Fixes: ASCS/SR/SPE/BI-{15,16}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-17 12:10:51 +02:00
Mariusz Skamra
8b06f7a5e1 Bluetooth: shell: Add multi-cis support
Add support for multiple CIS.

Relates: ASCS/SR/SPE/BI-{15,16}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-17 12:10:51 +02:00
Daniel DeGrasse
575a8e116c usb: Increase mass storage stack size when SD stack is enabled
SD stack requires a larger stack size than the default value for the
mass storage stack thread. Increase the default stack size to 768 when
the SD stack is enabled.

Fixes #49057

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-08-17 12:09:17 +02:00
Aastha Grover
70c51768de kconfig: logging: Add LOG_MIPI_SYST_ARGS_BUFFER_SIZE option.
Add user configurable LOG_MIPI_SYST_ARGS_BUFFER_SIZE Kconfig
option to use it for macro MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE.
Moving macro definition of MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE
from mipi-sys-t library to platform.h which defaulted to 1kb
and resulted in stack overflow in some applications.
LOG_MIPI_SYST_ARGS_BUFFER_SIZE gives flexibilty to users when
maximum log length is known.

Fixes zephyrproject-rtos/mipi-sys-t#10

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2022-08-17 12:07:08 +02:00
Marcin Niestroj
6653fd945f modules: mbedtls: set mbedTLS debug threshold during module initialization
mbedTLS library threshold initialization was done in native TLS socket
implementation (which tends to use mbedTLS now) and inside mbedTLS
benchmark test. Move that to mbedTLS module initialization, as this is a
global setting.

Update description of CONFIG_MBEDTLS_DEBUG_LEVEL to clarify when
mbedtls_debug_set_threshold() is called.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-08-17 12:03:52 +02:00
Marcin Niestroj
a418ad4bb4 modules: mbedtls: move debug log hook implementation to modules/mbedtls/
So far there was a debug log hook installed in TLS socket implementation.
However, mbedTLS (with debug enabled) might be used outside from TLS socket
and even outside from networking context.

Add new module, which implements debug log hook and makes it available
whenever CONFIG_MBEDTLS_DEBUG is enabled.

Note that debug hook needs to be installed for each mbedTLS context
separately, which means that this requires action from mbedTLS users, such
as TLS sockets implementation.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-08-17 12:03:52 +02:00
Ivan Herrera Olivares
71b4dcf269 Bluetooth: L2CAP: Add check to see if device is not disconnected
Currently, if a bluetooth peripheral sends a connection parameter update
request to a Zephyr central while the central is in the process of
disconnecting and has sent a connection terminate command in the same
connection interval, the central will try to reply, resulting in an
error being printed in the console.

This commit adds a check in le_conn_param_update_req that catches this
state before the central considers this request, preventing the unneeded
error being printed.

Fixes #48813

Signed-off-by: Ivan Herrera Olivares <ivan.herreraolivares@uantwerpen.be>
2022-08-17 08:06:19 +00:00
Aaron Massey
c01b4d8106 emul: Add sbs_gauge emulator
Add an initial bare-bones functionality sbs_gauge emulator that only
supports register reads tested by the current sbs_gauge driver tests and
what the sbs_driver currently supports.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-08-17 08:04:17 +00:00
Carles Cufi
26f5897819 Bluetooth: Mark Extended Adv as stable
Extended Advertising is no longer experimental, it has been now
extensively tested and is fully qualifiable and usable in production.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-16 18:10:59 +02:00
Kumar Gala
8d0b1650a9 ipc: rpmsg_service: Convert to devicetree APIs
* Convert device_get_binding to DEVICE_DT_GET
* Convert Kconfig RPMSG_SERVICE_SHM_BASE_ADDRESS and
  RPMSG_SERVICE_SHM_SIZE to DT_REG_ADDR/DT_REG_SIZE

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-16 15:50:03 +02:00
Mariusz Skamra
e0d36beb72 Bluetooth: audio: Add security requirements check
The LE Audio related profiles define specific security requirements that
client have to met to gain access to related characteristics. This
introduces internal wrapper API for GATT characteristics and CCC
descriptors to ensure the security.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 12:19:43 +02:00
Mariusz Skamra
2241efedfb Bluetooth: audio: Keep ASE pointer in bt_audio_ep
This makes the server endpoint to store the ASE pointer instead of
handle. This way, there will be no need to "mock" attribute when
notification is sent.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 12:19:43 +02:00
Mariusz Skamra
cc86b9213c Bluetooth: conn: Extend bt_conn_info with security information
This extends the bt_conn_info with security information. This is needed
by LE Audio profiles to check if security requirements are met.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 12:19:43 +02:00
Mariusz Skamra
cc37266742 Bluetooth: conn: Add const modifier to conn
The bt_conn_get_security and bt_conn_enc_key_size do not
modify the conn thus the parameter can be guarded with const modifier.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 12:19:43 +02:00
Mariusz Skamra
12010fafe6 Bluetooth: keys: Extend keys flags with OOB flag
Adds flag indicating the pairing that was completed using OOB method.
The flag is needed for checking 128bit entropy pairing required by LE
Audio services.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 12:19:43 +02:00
Mariusz Skamra
ffea5b6b54 Bluetooth: audio: ascs: Fix missing negative sign parameter
This fixes missing negative sign passed to ascs_cp_rsp_add_errno
that takes negative error argument.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 10:07:54 +00:00
Mariusz Skamra
778ed28ee2 Bluetooth: audio: ascs: Reject peer Release operation in Idle state
This fixes crash that happened when client initiated Release operation
on ASE in Idle state. In such case the operation shall be rejected with
Invalid ASE State Machine Response_Code.

Fixes: ASCS/SR/SPE/BI-10-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-16 10:07:54 +00:00
Robert Lubos
405e3d757f net: tcp: Add exponential backoff for ZWP probing
Persist timer should implement exponential backoff, as per RFC 1122:

    The transmitting host SHOULD send the first zero-window
    probe when a zero window has existed for the retransmission
    timeout period (see Section 4.2.2.15), and SHOULD increase
    exponentially the interval between successive probes.

Implement this, by following Linux behaviour, and simply double the
timeout or each probe transmission.

Additionally, prevent reseting the persist timer in case an
acknowledgment is received with zero window size, and the timer is
already running.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-15 08:21:29 +00:00
Andries Kruithof
6fe1299c33 Bluetooth: controller: llcp: fix CI tests for new LLCP
Setting the new LLCP as default exposed errors in CI tests, which
are fixed here
Note that advanced scheduling needs to be disabled. Work is in
progress for implementing this for the new LLCP

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-08-14 21:59:09 +02:00
Andries Kruithof
e1c2c36f56 Bluetooth: controller: llcp: set refactored as default
Set the new refactored LLCP the default

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-08-14 21:59:09 +02:00
Jonathan Rico
5b0ff0b35b Bluetooth: gatt: support having the CCCD in any location
Per spec, the CCCD doesn't necessarily have to be located immediately after
the characteristic value. This commit fixes that assumption when checking
for subscriptions.

Fixes #48880.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-14 17:14:41 +02:00
Matthias Hauser
c5155b2dbf Bluetooth: writing appearance to settings
avoid saving appearance in flash if it did not change

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2022-08-12 14:17:44 +01:00
Robert Lubos
9a090d434c net: tcp: Use default MSS value if no MSS option is present
In case peer does not send the MSS option, the TCP stack should assume
default peer MSS value of 536, as per RFC 1122:

    If an MSS option is not received at connection setup, TCP
    MUST assume a default send MSS of 536.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-12 11:33:35 +02:00
Matthias Hauser
c0e39711ac Bluetooth: bugfix in applying appearance from settings
The len parameter is the settings name length 'appearance'

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2022-08-12 11:31:42 +02:00
Johann Fischer
46a0e5347d modbus: remove the use of DT_INST_LABEL and DT_PROP(inst, label)
Although it is possible to simply use the interface number,
it has proven convenient to use the names for the interfaces
in the samples.

Migrate to DEVICE_DT_NAME().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-08-11 09:39:24 -07:00
Reto Schneider
e8510f0577 emul: Remove empty files
Those files do not contain anything of relevance since
fa90b5c243 [emul: spi: bmi160: Move to
top-level directory].

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-08-11 11:17:04 -05:00
Marek Pieta
f5560279f5 bluetooth: host: Increase long workqueue stack size
Change increases long workqueue stack size to prevent stack
overflows while processing GATT database hash.
CONFIG_BT_HCI_ECC_STACK_SIZE is removed, because the configured
stack was removed.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2022-08-11 17:01:08 +02:00
Ming Shao
9a4b5e1d90 ztest: Add test duration to summary for new ztest
Add duration stats at both suite level and unit test
level into test summary. The duration is at second
level. Since the new ztest fx can execute a test suite
for multiple times, the worst/longest test duration is
collected.

Note that even a skipped test can have a duration greater
than 0 because the skip operation itself is not free.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-11 09:01:12 -04:00
Ming Shao
cce1ec6f42 ztest: Refine when to collect unit test duration
Previously, unit test duration is collected within the
TC_START and Z_TC_END_RESULT macros. With existing tests,
the TC_START macro can be invoked by both the ztest fx
and the tests themselves. And the TC_START macro definition
went lengths to avoid the interference when it is invoked
within a unit test. This commit decouple the time collection
and the TC_STRAT/Z_TC_END_RESULT macros to fix this issue.
Now only the (old) ztest framework is responsible for the
test duration measure. The test duration stats of new ztest
fx is different from this btw.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-11 09:01:12 -04:00
Ming Shao
77e1e39cff ztest: add test summary after all suites finish running
Add test summary after all test suites finish running.
The summary can be one-line or verbose, which is configured
with CONFIG_ZTEST_VERBOSE_SUMMARY. The one-line summary covers
overall suite stats. The verbose summary covers each test
function within the suite besides the one-line summary.

The new ztest output ultimately go through the printk. If
printk go through the logging subsystem, there may be log
messages dropped. And if log_panic is invoked, log messages
can be flushed in a mess. So several explicit log flush
are used when printing summary to ensure no content is lost
and content is in good shape.

Some macros are shared between old and new ztests. Such as
TC_START_PRINT and TC_END_PRINT. The are defined accordingly.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-11 09:01:12 -04:00
Ming Shao
bb63d87b4b ztest: Add config switch for modes of test output
Support verbose or one-line summary at test suite level.
Support verbose or no output at test function level.

Totally 4 combinations configurable:
- function verbose + suite verbose
- function verbose + suite oneline
- no function output + suite verbose
- no function output + suite oneline

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-11 09:01:12 -04:00
Marek Pieta
3a1d9735fc bluetooth: gatt: Fix value returned by db_hash_commit
Change fixes value returned by db_hash_commit. Returning positive
value leads to settings load failure.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2022-08-11 12:19:52 +02:00
Juha Heiskanen
cec0ea0dce net: lwm2m: Fix Update registration issue
Client Registration update process may be reject by server
and this commit fix a case that it will jump to new state
which send registration message. Earlier RD client try
allocate message before only possible one was released.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-11 12:16:56 +02:00
Juha Heiskanen
6bfebe5fc3 net: lwm2m: Fix Queued data buffer send at wakeup from idle
Queue mode without TLS cache was loosing buffered messages at
wake-up process from idle state. Now client context linked list
are initialized at rd client start process only 1 time.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-11 12:16:56 +02:00
Nahal Farhi
557fdaf2e3 fs: fat_fs: Changing mkfs options to create FAT32 on larger storage
Changing mkfs options from FM_FAT to FM_ANY so that on larger storage
FAT32 instead of FAT16 is automatically created.

Signed-off-by: Nahal Farhi <nahal@whisper.ai>
2022-08-10 18:37:33 +02:00
Stephanos Ioannidis
230ddd9a7f lib: os: assert: Add unreachable path hint for assertion failure
This commit adds the `CODE_UNREACHABLE` hint at the end of the
assertion failure branch so that the compiler takes note of the assert
function not returning when an assertion fails.

This prevents the compiler from generating misguided warnings assuming
the asserted execution paths.

It also introduces the `ASSERT_TEST` Kconfig symbol, which indicates
that the "assert test mode" is enabled. This symbol may be selected by
the tests that require the assert post action function to return
without aborting so that the test can proceed.

Note that the `CODE_UNREACHABLE` hint is specified only when the assert
test mode is disabled in order to prevent the tests from crashing when
the assert post action function returns.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-10 14:32:36 +02:00
Marek Pieta
d5a453efaf bluetooth: smp: Add authentication callbacks per connection
Change introduces authentication callbacks used only for specified
BLE connection. The feature can be used by devices that require
reporting specific bonding capabilities only when pairing using
vendor-specific procedures.

If per-connection authentication callbacks are defined for given
connection, they are used instead of global authentication
callbacks. SMP latches authentication callbacks during the first
access to prevent updating the callbacks while pairing.

Fixes: #38336

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2022-08-10 12:49:30 +02:00
Eduardo Montoya
ee2a8d9a64 net: openthread: allow to configure OPENTHREAD_MESSAGE_BUFFER_SIZE
Add `OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE` to Kconfig.

Also set the number of children to minumum possible for MTD builds
in order to save some resources (~512B of RAM).

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-08-10 12:01:18 +02:00
Gerard Marull-Paretas
b74a22924e net: lib: config: remove NET_CONFIG_IEEE802154_DEV_NAME
Remove NET_CONFIG_IEEE802154_DEV_NAME in favor of DT based choice using
zephyr,ieee802154.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-10 11:57:34 +02:00
Gerard Marull-Paretas
e2bea3b008 net: lib: config: ieee802154: use zephyr,ieee802154
Use DT choice zephyr,ieee802154 as CONFIG_NET_CONFIG_IEEE802154_DEV_NAME
is being phased out.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-10 11:57:34 +02:00
Robert Lubos
d18cdad2fc net: zperf: Use zsock_* API instead of POSIX socket API
In order to make the zperf to work regardless of the POSIX configuration
in the system, convert the socket API usage into Zephyr's native
zsock_* API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-10 11:15:21 +02:00
Robert Lubos
2091b34820 net: zperf: Extract zperf into library
Make a library out of the zperf shell sample. This makes to enable the
module in any application, not only the dedicated sample.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-10 11:15:21 +02:00
Robert Lubos
2670fc9b67 net: ppp: Fix NULL pointer dereference in FSM module
ppp_send_pkt() function can be called with NULL fsm parameter (when
PPP_PROTOCOL_REJ packet was sent), howerver this was not taken into
consideration when ppp_context was retrieved. In result, this could lead
to NULL pointer dereference an crash.

Fix this, by moving the ppp_context extraction directly where it's
actually used (PPP_CODE_REJ packet type handling). In such case, fsm
point should not be NULL.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-10 11:06:24 +02:00
Yuval Peress
84dfb8edf8 ztest: allow asserts anywhere
Updates the ztest_test_fail() function to allow failures in setup.
When executed, a failed assert will fail every test in the suite owning
the setup function. This was verified by adding a suite which asserts
in the setup function and has a test that should pass. During
exeuction, ztest marks the test as failing.

In order to verify exection I also added 2 new APIs:
- ZTEST_EXPECT_FAIL(suite_name, test_name)
- ZTEST_EXPECT_SKIP(suite_name, test_name)

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-09 13:30:15 -04:00
Al Semjonovs
95cae9b870 zephyr: Fix verify run all check
In scenarios where test_main is overridden ztest_run_all
may be invoked multiple times leading to the verify check to
fail inadvertently.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-08-09 08:49:28 -04:00
Stephanos Ioannidis
8fe855f166 net: dns: Check query index in dns_read
This commit adds a check, in the `dns_read` function, before
dereferencing the query index returned by the `dns_validate_msg`
function.

This fixes the warnings generated by the GCC 12 such as:

  error: array subscript -1 is below array bounds of
  'struct dns_pending_query[5]' [-Werror=array-bounds]

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-09 14:20:28 +02:00
Mariusz Skamra
f836dabb46 Bluetooth: audio: Handle Receiver Stop Ready on non-connected stream
This fixes state transition to QoS Configured state triggered by
client-initiated Receiver Stop Ready operation on ASE that has no ISO
attached.

Fixes: ASCS/SR/ACP/BV-12-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-09 12:30:10 +02:00
Gerard Marull-Paretas
a7c3e7e84a doxygen: remove redundant usages of def
The def command Indicates that a comment block contains documentation
for a #define macro. This is useful if the comment block documents a
macro not adjacent to it, e.g.

```c
/**
 * @def MAX(x,y)
 * @brief Computes the maximum of @a x and @a y.
 */
 #ifdef XXX
 #define MAX(x,y) ...
 #endif
```

However, it is not necessary if the comment is adjacent to the
definition, e.g.

```c
/**
 * @brief Computes the maximum of @a x and @a y.
 */
 #define MAX(x,y) ...
```

This patch removes all unnecessary def entries in-tree.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-09 12:29:28 +02:00
Daniel DeGrasse
0a3bf289b6 net: icmp: skip checksum calculation when possible
Skip IP header checksum calculation when the network interface reports
support for this feature.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-08-09 12:29:18 +02:00
Joakim Andersson
fcb9813128 tests: arm: Increase main stack size with no optimizations
If the test is run with the config NO_OPTIMIZATIONS enabled then the
stack size usage increases by around 80% for ARM platforms.
Increase the stack size used in test cases that enables building with no
optimizations for ARM.

Update description on TEST_ARM_CORTEX_M since it was outdated and said
it was only used for a single purpose.

Fixes: #47930
Fixes: #47929
Fixes: #47855

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-08-08 11:17:01 -04:00
Mariusz Skamra
a618143b46 Bluetooth: audio: Add unavailable audio context warning
This logs warning if the stream is rejected due to unavailable
audio context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-08 15:03:55 +02:00
Mariusz Skamra
17d7bd8219 Bluetooth: audio: Fix missing audio direction check
This fixes missing `dir` parameter check when setting the available
contexts value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-08 15:03:55 +02:00
Mariusz Skamra
8ae28b796e Bluetooth: shell: Fix available contexts value
This fixes the available audio contexts that shall be a subset of
supported audio contexts.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-08 15:03:55 +02:00
Dominik Ermel
dd79b9c11a subsys/mgmt/hawkbit: Clean up flash map usage
The commit cleans up how flash map labels and definitions are
used.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-08-08 15:03:34 +02:00
Krishna T
b754e63d1b net: ethernet: Add EAPoL ether type support
Wi-Fi protocol uses EAPoL ether type frames for authentication, so, add
support for that ether type so that they are not dropped.

Though we have NET_ETHERNET_FORWARD_UNRECOGNISED_ETHERTYPE to allow
unknown frames to be passed up the stack, but this might cause
performance penalty.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-08 14:03:54 +02:00
Seppo Takalo
eafc4f875b net: lwm2m: Allow string and opaque data types to be empty
When string and opaque types are uninitialized, we should
allow their data length to be zero. However, most content
formatters seem to calculate the string length separately
so replace the pointer of empty data into a static string
that is guaranteed to be empty.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-08-08 11:27:16 +02:00
Aleksandr Khromykh
56d67dfac8 Bluetooth: Mesh: don't send Friend Clear if Friend is lost
If LPN lost Friend node (all Poll attempts didn't succeed)
no reason to send Friend Clear to the Friend node.
This makes LPN powersupply  inefficient usage.
During Friend Clear sending LPN rejects any frame from
primary subnetwork.
Specificastion doesn't mandate that LPN would send Friend Clear
if polling didn't succeed.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-08-08 10:52:23 +02:00
Andreas Chmielewski
7532a23dc9 net: lwm2m: Try to reuse registration in case of a network error
For most of the times it is not necessary to do a full registration
once a connection is established after a network error. This is in
particular not needed if lifetime is not yet expired and the server
does not refuse a registration update.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-08-08 06:55:49 +01:00
Andreas Chmielewski
74a56b05a9 net: lwm2m: separate closing context from closing socket
Separate closing lwm2m context from closing socket. This patch is required
for the rd client to take more control over lwm2m context and the socket.
The goal is to close the socket and to keep the lwm2m context if this is
needed.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-08-08 06:55:49 +01:00
Andreas Chmielewski
3cdff65eb0 net: lwm2m: Update registration only in good path
Registration should only be updated if update of the registration was
succesful.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-08-08 06:55:49 +01:00
Al Semjonovs
ccc0315e14 ztest: Handle assert failures without signal handler
The signal handler needs to return gracefully. When multiple
tests assert, the first assert will raise SIGABRT and the signal
handler will run and the test will stop running.
The second assert will raise SIGABRT but the signal handler
will not be called, therefore the test PASS/FAIL status is not
updated correctly.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-08-05 12:51:44 -04:00
Al Semjonovs
4a0040f346 ztest: Fix logic for SUITE_SKIP
When ZTEST setup fails z_assume, we should mark all tests within
suite as skipped.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-08-05 11:54:11 -04:00
Robert Lubos
de55dbcbb1 net: tcp: Fix SYN handling after connection is established
According to RFC 793, ch 3.9 Event Processing, receving SYN flag after
the connection has been established is an error codition:

    If the SYN is in the window it is an error, send a reset, any
    outstanding RECEIVEs and SEND should receive "reset" responses,
    all segment queues should be flushed, the user should also
    receive an unsolicited general "connection reset" signal, enter
    the CLOSED state, delete the TCB, and return."

Currently TCP stack ignored such event, causing interoperability test
failures. Fix this, by verifying if the SYN flag is set in a packet in
any state other than TCP_LISTEN and TCP_SYN_SENT.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-05 15:17:09 +02:00
Jordan Yates
1d844bff26 dfu: fixup conditional CMake include
The dfu subsys is theoretically agnostic to the particular bootloader,
even if MCUboot is the only bootloader currently supported. Include the
dfu folder based on the parent symbol `IMG_MANAGER` instead of the
specific `MCUBOOT_IMG_MANAGER`.

The MCUboot specific files are already gated by the Kconfig in the
`boot` and `img_util` folders.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-08-05 15:14:40 +02:00
Joakim Andersson
83d5402fe8 Bluetooth: host: Fix SMP local keys check when starting encryption
Fix SMP check of existing local keys when attempting to start security
with required security mode 1 level 4. The logic for checking the
conditions was wrong, leading to a situation where encryption would be
attempted to be started by the central instead of initiating a new
pairing procedure. This would fail when the connection was encrypted and
the connection would be disconnected.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-08-05 15:05:56 +02:00
Mariusz Skamra
42e372fc3e Bluetooth: audio: ascs: Fix sending invalid ATT_ERROR_RSP error code
This fixes sending invalid ATT Request Not Supported error code as a
response to Control Point write request.
ATT Request Not Supported error code is used to inform that
"ATT Server does not support the request received from the client",
so it should not be sent in this case.
If the requested opcode is unsupported, ASCS mandates to send ATT
Notification from Control Point with Unsupported opcode Response_Code
only. If the request received from the client is properly formatted,
ATT Write Response can be sent to complete the ATT transaction.

Fixes: ASCS/SR/SPE/BI-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-05 15:05:17 +02:00
Mariusz Skamra
a0ea971e9f Bluetooth: audio: ascs: Use BT_WARN to log peer invalid behavior
BT_ERR() should really be reserved for local errors only,
thus BT_WARN() is the right choice whenever a remote peer
sends something invalid that we cleanly handle.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-05 15:05:07 +02:00
Mariusz Skamra
c88b5dab61 Bluetooth: audio: ascs: Fix handling zero Number_of_ASEs parameter
As per ASCS_v1.0
"A client-initiated ASE Control operation shall be defined as an
invalid length operation if the Number_of_ASEs parameter value is
less than 1".

Fixes: ASCS/SR/SPE/BI-{02,03,04,05,06}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-05 15:05:07 +02:00
Florian Grandel
bb86f8b967 net: ip: build IEEE 802.15.4 L2 without IP support
While a previous change had already decoupled the IEEE 802.15.4 L2 from
IP upper layers, this only worked when at least one other interface of
the device supported IP.

This change removes this requirement and thereby fixes a build error
that occurred when disabling IP support while maintaining IEEE 802.15.4
L2 support.

Fixes: #48718

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-05 15:04:37 +02:00
Johan Hedberg
7ebaf1b10b Bluetooth: host: Fix scan info dangling pointer
Clear pointer to the le_adv_recv() stack frame before returning to the
calling function. This fixes a potential compiler warning newer gcc
versions.

zephyr/subsys/bluetooth/host/scan.c: In function ‘le_adv_recv’:
zephyr/subsys/bluetooth/host/scan.c:463:20: error: storing the address
of local variable ‘id_addr’ in ‘*info.addr’ [-Werror=dangling-pointer=]
  463 |         info->addr = &id_addr;
      |         ~~~~~~~~~~~^~~~~~~~~~
zephyr/subsys/bluetooth/host/scan.c:439:22: note: ‘id_addr’ declared here
  439 |         bt_addr_le_t id_addr;
      |                      ^~~~~~~

Fixes #48459

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2022-08-05 13:03:32 +02:00
Troels Nilsson
1c27b4353c bluetooth: controller: Expose prpa cache for LLL use
The prpa cache is now exposed through the ull_filter_lll_prpa_cache_get()
function (as the resolve list already is). This is needed to be
able to reply to AUX_CONNECT_REQ within the required time when
using SW-based RPA resolving

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-08-04 15:05:41 +02:00
Florian Grandel
a1a2107b42 net: ip: only start IP configuration on IP interfaces
net_if_up() unconditionally calls iface_ipv6_start() and
net_ipv4_autoconf_start(). This is not correct for interfaces that do
not support IPv4/v6.

This patch therefore introduces a check on the interface's flags before
proceeding.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Florian Grandel
6b09d0e791 net: l2: ieee802154: apply clang format
This change makes the files which are part of this changeset comply to
the project's coding style rules as defined in .clang-format.

This required addition of some forward declarations and additional
dependencies into header files as some of them depended on the order of
header inclusion which was changed due to alphabetical ordering of
includes.

Background: .clang-format states "SortIncludes:true" which will force
re-ording of include-statements which in turn might break the build if
header file inclusion is not order-independent.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Florian Grandel
dcb2ead52c net: l2: ieee802154: rename *fragment to *6lo_fragment
6LoWPAN fragmentation is not related to IEEE 802.15.4 proper but is just
part of its IPv6-specific L3-adaptation layer. To make this more obvious
we rename all resources related to 6LoWPAN fragmentation.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Florian Grandel
2e5e761074 net: l2: ieee802154: decouple L2/L3 concerns
This change decouples the IEEE 802.15.4 (L2) layer from all IPv6 (L3)
concerns.

Applications may now choose to set CONFIG_NET_6LO=n and
CONFIG_NET_L2_IEEE802154=y at the same time.

Setting CONFIG_NET_6LO=n will build a vanilla IEEE 802.15.4-2006 specs
compliant L2 layer without any reference to 6LoWPAN or IPv6. This allows
application developers to design custom non-IP protocols on top of
IEEE 802.15.4-2006 and thereby makes the L2 layer much more re-usable.

Fixes #48585.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Florian Grandel
59be7bfb26 net: l2: ieee802154: improve inline comments
This change contains some merely editorial changes to inline comments
plus updates references from the IEEE 802.15.4-2003 spec to
IEEE 802.15.4-2006 which corresponds to the implementation level of
the module.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Florian Grandel
4dbaa170cf net: l2: ieee802154: Improve TODO marker consistency
Most existing TODO markers (as well as VSCode default settings) favor
TODO over ToDo - so let's make this a little bit more consistent in the
IEEE 802.15.4 module.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-04 13:44:06 +02:00
Juha Heiskanen
ca20462bcc net: lwm2m: Shell helper for pause and resume
Helper commit for test pause and resume.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-04 13:42:55 +02:00
Juha Heiskanen
ed5f3cdf06 net: lwm2m: LwM2M Pause and resume support
New API for suspend and resume LwM2M engine.
New event LWM2M_RD_CLIENT_EVENT_ENGINE_SUSPENDED for indicate
application that engine is suspended.

Simplify stack suspend and resume state same time for queue mode.

New CONFIG_LWM2M_RD_CLIENT_SUSPEND_SOCKET_AT_IDLE for enable skip socket
close at RX_OFF_IDDLE state that socket is only suspended and close is
called only when connection is resumed.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-04 13:42:55 +02:00
Al Semjonovs
1463e1c26a ztest: Fix logic for listing tests once
A test case may invoke run_all multiple times, causing
logic for listing tests to run tests on second call.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-08-03 14:32:54 -04:00
Jonathan Rico
1d0692b2f7 shell: kernel: fix sleep command
Was trying to parse the second argument instead of the first one.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-03 18:47:03 +02:00
Jonathan Rico
975fd4787b shell: Bluetooth: Fix auto-connect
The logic was still trying to parse the address even though one was already
stored.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-03 18:47:03 +02:00
Aleksandr Khromykh
678b003a50 Bluetooth: Mesh: Scanner is enabled during Friendship termination
Scanner was disabled after Friend Clear command. LNP didn't have
chance to receive Friend Clear Confirmation command back.
If option BT_MESH_LPN_ESTABLISHMENT is off then scanner is left
disabled and next Friend Offer after Friend Request
cannot be received.
PR fixes this.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-08-03 18:43:29 +02:00
Piotr Pryga
e9ea1b0e68 Bluetooth: df: fix ref antenna repeat after switch pattern exhausted
Direction finding functionality does antenna switching during CTE
reception in AoA mode and CTE transmission in AoD mode. Antennas are
switched according to user provided antenna switch pattern. If a CTE
length is enough to exhaust all antenna ids in a switch pattern then
Radio should loopback to reference antenna and continue from switching
from it.

Current implementation loops back to wrong antenna due to wrong index
used in GUARD_REF_ANTENNA_PATTERN_IDX. It was set to one instead of
zero. Zero is the index of reference antenna in Host provided antenna
switching pattern array.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-08-03 12:37:59 +02:00
Vinayak Kariappa Chettimada
6a41330650 Bluetooth: Controller: AD data fragment operation review rework
Added define PDU_AC_EXT_AD_DATA_LEN_MAX, maximum AD data
length possible in AUX_ADV_IND when all Common Extended
Header Format fields are populuted.

Updated function description to explain the added ADI and
Aux Ptr fields support in updating the auxiliary PDUs.

Remove the redundant CTE info population code unnecessary
for new chain PDU as a result of AD data overflow.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
76396496b6 Bluetooth: Controller: Minimal time reservation for aux and sync
Use minimal time reservation for auxiliary and sync PDU
reception. A peer device could be scheduling multiple
advertising sets in a short duration with small PDUs hence
using the minimal time reservation would avoid skipping
closely scheduled reception of multiple auxiliary PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
e6c8aaf629 Bluetooth: Controller: Refactor DF impl to add aux offset in ULL context
Refactor DF implementation to add aux offset in the aux
pointer field of the parent PDU when chain PDU is added
and/or is duplicated when PDU contents are updated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
d34cfb2929 Bluetooth: Controller: Add Extended Scan Resp Data fragment operation
Add implementation to support Extended Scan Response Data
fragment operation of first, intermediate, last, unchanged
and complete data operation using the HCI LE Set Extended
Scan Response Data Command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
1ed0ae3c81 Bluetooth: Controller: Minor scan response implementation refactor
Minor refactor of scan response implementation to rename sr_pdu
to sr_pdu_prev, and aux_pdu to sec_pdu_prev etc.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
97bb30ea59 Bluetooth: Controller: Add Extended Advertising Data fragment operation
Add implementation to support Extended Advertising AD Data
fragment operation of first, intermediate, last, unchanged
and complete AD data operation using the HCI LE Set Extended
Advertising Data Command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
aa5c0c0a90 Bluetooth: Controller: Rename Kconfig to BT_CTLR_ADV_AUX_PDU_BACK2BACK
Rename Kconfig BT_CTLR_ADV_PDU_BACK2BACK to
BT_CTLR_ADV_AUX_PDU_BACK2BACK to represent use of
back-to-back for Extended Advertising PDU chaining support
similar to BT_CTLR_ADV_SYNC_PDU_BACK2BACK that is used to
represent the use of back-to-back for Periodic Advertising
PDU chaining support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
efe1b1dda4 Bluetooth: Controller: Fix missing AD Data Set fragment operation
Fix missing AD data set fragment operation implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
349d27ebc7 Bluetooth: Controller: Fix sync set_clear to return aux_ptr reference
Update ull_adv_sync_pdu_set_clear() to return aux_ptr
reference so that aux_ptr field for chain PDUs can be
pupulated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
ccab45f9ad Bluetooth: Controller: Add defines for ext adv header field offsets
Add defines for Extended Advertising Common Extended Payload
Format field offsets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
4c94227b1d Bluetooth: Controller: Minor refactor to move ULL after LL functions
Minor refactor to reorder and move ULL functions after the
LL functions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
84450d8981 Bluetooth: Controller: Duplicate and add aux offset to chain PDU in ULL
Refactor PDU chaining implementation to add aux offset in
the aux pointer field in the parent PDU when duplicating
chain PDUs.

By adding the aux offsets in the ULL execution context the
LLL prepare execution in Extended and Periodic Advertising
does not need to have a O(n) while loop in LLL execution
context.

This will reduce CPU use in the highest priority ISR
compared to current implementation where chain PDUs where
duplicated in ULL execution context and aux offset populated
in LLL execution context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
b689f18079 Bluetooth: Controller: Cleanup periodic adv chaining aux ptr population
Cleanup Periodic Advertising Chain PDUs auxiliary pointer
population, populate the back to back auxiliary pointer
field in thread context. Also, removed an unused code for
filling data.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
3edf487f6a Bluetooth: Controller: Set/Clear function to enqueue aux PDU in caller
Refactor the ull_adv_aux_hdr_set_clear function so that the
caller of the function will enqueue the auxiliary PDU when
enqueuing the primary PDU.

This change is required to support chaining of AD Data where
parent auxiliary PDU will be added with aux ptr fields when
chain PDUs are appended.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
49abc04d41 Bluetooth: Controller: Fix Periodic Adv Sync from preemption
Fix Periodic Advertising Synchronization from being
preempted by an overlapping Auxiliary PDU scan event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
a40a403a0d Bluetooth: Controller: Fix skipped Periodic Sync radio events
Fix skipped Periodic Advertising Sync radio events due to
increased CPU use during pre-emption in LLL from a Scan
radio event to Periodic Advertising Sync radio event by
increasing EVENT_OVERHEAD_START_US value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
5071ba4157 Bluetooth: Controller: Fix continuous scan initiator from being aborted
Fix to prevent a transmitted CONNECT_REQ PDU from being
aborted mid-air when initiator is using continuous scan
window that do not use time reservation. A different state
or role that overlaps the connection initiation requesting
for an abort should be denied when CONNECT_REQ PDU has been
enqueued for tranmission by the radio.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
3eb0c448be Bluetooth: Controller: Fix directed adv connection setup stall
When directed advertising and continuous scanning are
simultaneously active, and a connection request is received
by the directed advertising state then the connection was
not established due to the done event not being generated.

Done event from the directed advertising state was not
generated because the prepare pipeline only had resume
event which does not get scheduled when there is prepare
event of the continuous scan state.

The fix is to explicitly abort all pending prepare and
resume event in the pipeline for the directed advertising
state when connection request is received.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Vinayak Kariappa Chettimada
6b98d33ea6 Bluetooth: Controller: Minor refactor to move initialization
Minor refactor to move initialization close to locality of
reference.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-03 12:02:47 +02:00
Anas Nashif
d60e3123cb tests: TEST_EXTRA_STACK_SIZE depend on test
Make the option TEST_EXTRA_STACK_SIZE depend on Tests, otherwise it will
appear in each generated .config file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-03 11:22:20 +02:00
Anas Nashif
51cb40e5b3 tests: ztest: move TEST_LOGGING_FLUSH_AFTER_TEST under ztest
This config option is only used with ztest, so move it under ztest.
Otherwise it appears in .config when you build ANY application.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-03 11:22:20 +02:00
Veijo Pesonen
0b57ba8dcb net: lwm2m: remove EXPERIMENTAL-label from v1.1
Version 1.1 support is not experimental anymore.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-08-03 11:20:50 +02:00
Gerard Marull-Paretas
a650c6c554 pm: policy: allow multiple subscribers to latency changes
Current API allowed to get notified when the maximum system latency
changes, however, a single callback was allowed. The design was intended
for SoC specific actions when latency changes. However, in some cases
drivers may also want to know the current maximum latency to perform
local actions if other parts of the system modify it.

This patch updates the API with a pair of subscribe/unsubscribe calls to
achieve such goal. Tests have been updated to show how the API can be
used.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-03 11:19:17 +02:00
Gerard Marull-Paretas
41a00438cb pm: policy: keep microseconds resolution
When new latency requirements are introduced/updated, the microseconds
value gets converted down to ticks. Ticks usually have a coarse
resolution compared to the microseconds scale. This is fine for making
PM state change decisions, however, when getting notified about latency
changes, we may want to know the real value in microseconds, even if the
system rounds to ticks internally. This patch stores the value in both
us and ticks (in ticks to cache the conversion, really), so that the
user will get notified with precise latency values.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-03 11:19:17 +02:00
Robert Lubos
5b34d25b69 net: context: Unregister connection for packet socket
Network connection was not unregistered properly for packet socket,
which resulted in dangling connection when net_context was dereferenced
(i. e. when packet socket was closed). This could lead to a crash on a
consecutive incoming packet.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-03 11:11:55 +02:00
Troels Nilsson
e1e2c98abd bluetooth: Fix duration endianness issues
Added missing endianness conversion in controller and fixed double
conversion in host

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-08-03 05:04:53 +01:00
Piotr Pryga
dffbcb8146 Bluetooth: Controller: df: Add selectable IQ samples to 8 bit conversion
Nordic Radio Direction Finding Extension provides 12 bits wide IQ
samples. The Bluetooth Core Specification 5.3 Vol 4, Part E sections
7.7.65.21 and 7.7.65.22 limits IQ samples to be 8 bits wide.

There are other way to convert 12 bits IQ samples into Bluetooth Core
specification compliant 8 bits IQ samples than ordinary 4 bits right
shift. If one is sure that samples will never go over 10 bits or 8
bits then, it is allowed to use 2 bits right shift or even 8 least
significant bits of 12 bits IQ samples.

The commit introduces a possibility to choose which approach is used
for IQ samples conversion in HCI layer while Host IQ report events
are created.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-08-03 05:04:25 +01:00
Martin Jäger
2590a7aa98 lorawan: upgrade to LoRaMAC-node v4.6.0
This release contains some bug fixes and improvements.

See below link for details:
https://github.com/Lora-net/LoRaMac-node/releases/tag/v4.6.0

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-08-03 05:02:57 +01:00
Fabio Baltieri
24d09d363c include: fix the remaining legacy #include paths
Add the "zephyr/" prefix to various #include statements that are
preventing the CI form running with LEGACY_INCLUDE_PATH=n.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Fabio Baltieri
def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Andrzej Puzdrowski
ccf8c547d0 settings: API for get storage instance used
Added API function +int settings_storage_get(void **storage)
which allows to get storage instance used by the
settings backed to store its records.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-08-02 15:15:10 +02:00
Gerard Marull-Paretas
63aff01427 bluetooth: common: remove Enable from BT_HCI_VS_FATAL_ERROR prompt
Boolean options are not allowed to start with "Enable...".
BT_HCI_VS_FATAL_ERROR started with "Enable..." making some PRs fail due
to compliance checks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-02 14:35:57 +02:00
Piotr Pryga
a0a8a12642 Bluetooth: hci: Use extended VS fatal error in hci and hci_rpmsg sample
Provide common helper functions to create extended extended Zephyr
Fatal Error functionality in HCI common code.

Use the implementation in hci_rpmsg sample.

The sample didn't provide an information about Controllers assert
or system fatal error to an application code while run with nRF5340
SoC. The goal for hci_rpmsg sample change is to enhance user experience
for conformance testing of the Bluetooth Controller while executed with
nRF5340.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-08-02 13:53:32 +02:00
Vinayak Kariappa Chettimada
f6a3da9c21 Bluetooth: Controller: Review rework of jitter in aux offset
Review rework of the fix to remove the jitter in aux offset
and sync offset values.

Force select BT_TICKER_REMAINDER_GET and BT_TICKER_LAZY_GET
features when Extended Advertising and Periodic Advertising
is supported.

Rename ticks and microsecond offset value struct members
for primary PDU event offset (to auxiliary PDU event).

Converted HAL_TICKER_REMOVE_JITTER and HAL_TICKER_ADD_JITTER
macro to functions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-02 12:54:31 +02:00
Vinayak Kariappa Chettimada
b6cf8bb580 Bluetooth: Controller: Use remainder in Ext and Periodic PDU offset
Use remainder value in scheduling the periodic auxiliary
PDUs and use the ticker next slot get interface with
remainder value to fill the auxiliary offsets with
microsecond precision in the primary channel PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-02 12:54:31 +02:00
Vinayak Kariappa Chettimada
aa73661b09 Bluetooth: Controller: Use macro to adjust ticks based on remainder
Use macro to adjust ticks for jitter stored in remainder
value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-02 12:54:31 +02:00
Vinayak Kariappa Chettimada
be7173a490 Bluetooth: Controller: Ticker next slot get to return remainder value
Updated ticker implementation to return remainder value for
a ticker when enumerating active tickers with time
reservations.

This is required to find offsets and to use the remainder
value to correctly calculate auxiliary offsets to the
microsecond resolution.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-02 12:54:31 +02:00
Vinayak Kariappa Chettimada
c14bde45b6 Bluetooth: Controller: Fix overlapping 1M and Coded PHY scannning
Fix overlapping 1M and Coded PHY scanning that caused idle
radio time when both PHY use same scan interval and sum of
their scan window duration equals the interval.
Implementation now will use continuous scanning and offset
the start of Coded PHY by the window duration of the 1M
scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-08-02 12:54:23 +02:00
Andries Kruithof
6d7a04a0ba Bluetooth: controller: llcp: initialise DLE parameters
The initialisation of DLE parameters for the peripheral
was done before the intialisation of the PHY settings.
Since the DLE parameters depend on PHY settings this
can result in incorrect parameters for tx/rx time and
octets
One scenario is where a previous connection set the PHY to
2M or CODED, then when a new connection is established
it uses the same memory-locations for connection settings as the
previous connection, and the (uninitialised) PHY settings will be
set to 2M or CODED, and thus the DLE parameters will be wrong
This PR moves the initialisation of DLE parameters after
that of PHY settings

EBQ tests effected include LL/CON/PER/BV-77-C.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-08-02 12:53:46 +02:00
Jonathan Rico
b0231e040d Bluetooth: host: invalidate tx context after destroying it
Now that we properly destroy the tx context in `bt_conn_process_tx`, we
need to make sure the context is really valid.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-01 18:13:35 +01:00
Jonathan Rico
00709e5fbb Bluetooth: host: add missing meta data destroy callback
Symptoms were that a disconnect happening when a buffer was enqueued but
not sent resulted in a meta-data memory leak.

This is problematic because it seemed (as per the OP) that it resulted in
the whole host getting locked up when a device sending long L2CAP packets
was prone to disconnect-reconnect cycles (e.g. in a bad RF environment).

Fixes #47649

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-08-01 18:13:35 +01:00
Seppo Takalo
c3302d5f41 net: lwm2m: Allow observing of object instances and objects
Code was limiting observations to resources and
resource instances without any reason.
Also if resource is written, and the whole object is observer
it should trigger. Path does not have to be matching on the
same level, if parent is observed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-08-01 18:12:33 +01:00
Aleksander Wasaznik
5a09325ba9 Bluetooth: Simplify predicate for host-based RPA resolution
The expression for the condition for using host-based RPA resolution now
simplifies to "Use host-based when we need to resolve more identities
than the controller can handle.".

Proof:
X=((bt_dev.le.rl_entries > 0) && (!bt_dev.le.rl_size ||
        bt_dev.le.rl_entries > bt_dev.le.rl_size))
X=(a > 0) && (!b || a > b)
a>=0, b>=0, because they are cardinal / size_t.
If a=0:
	// X evaluates to false. (0 > b)=(a > b) also always evaluates to false.
	X=false=(0 > b)=(a > b)
If a>0:
        X=(!b || a > b)
        If b=0: X=true=(a > 0)=(a > b)
        If b>0: X=(false || (a > b))=(a > b)
The expression is equivalent with (a > b) for all values of (a,b).
QED.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-08-01 18:11:57 +01:00
Michal Narajowski
fab8e29ee2 Bluetooth: Mesh: Add model publish support to Health Client
Mesh Profile Specification errata 11310
Section 4.4.4.1
"This model shall support model publication, as defined in Section
4.2.2 of the Mesh Profile specification and model subscription,
as defined in section 4.2.3 of the Mesh Profile specification."

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
2022-08-01 18:04:42 +01:00
Benjamin Björnsson
e172b1dbda debug: gdbstub: Move to DTS for uart device
Move from using Kconfig GDBSTUB_SERIAL_BACKEND_NAME to a devicetree
chosen property ("zephyr,gdbstub-uart"). This is similar to a number
of other functions like "zephyr,shell-uart" or "zephyr,bt-uart".

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-08-01 09:09:45 -07:00
Robert Lubos
bead038ba2 net: sockets: Fill the address structure provided in recvfrom()
The packet socket implementation did not fill the address structure
provided by the application. This commit fixes this.

Note, that the implementation needs to cover two cases: SOCK_RAW and
SOCK_DGRAM. In the first case, the information is extracted directly
from the L2 header (curently only Ethernet supported). In latter case,
the header is already removed from the packet as the L2 has already
processed the packet, so the information is obtained from the net_pkt
structure.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-01 18:02:20 +02:00
Robert Lubos
b5b5c29f2d net: pkt: Add ll_proto_type field
The L2 protocol type information is not carried to the upper layers.
This is problematic for packet sockets, as the address structure in
recvfrom() is supposed to provide this information.

Fix this by adding ll_proto_type field in the net_pkt structure.
Set the protocol type in the Ethernet L2 when packet is processed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-01 18:02:20 +02:00
Robert Lubos
0023ba45ee net: pkt: Add missing l2_processed flag cloning
l2_processed flag was not copied when a packet was cloned.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-01 18:02:20 +02:00
Andries Kruithof
bd0a34c4d0 Bluetooth: controller: llcp: fix failing LL/CON/CEN/BV-55-C
The mandatory minimum PDU length conformance test was failing
because the LLCP did update the effective rx/tx times (and
corresponding notification to host).
This was due to a missing test condition.

This PR adds the missing conditions.

Note that with this change the refactored controller code is
similar to the legacy code; relevant code is in ull_conn.c,
in the function event_phy_upd_ind_prep

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-08-01 18:00:50 +02:00
Tomislav Milkovic
12dd0290fb net: l2: ieee802154: Fix removing short src address filter
Driver function was called with wrong parameter, which resulted
in filter being added instead of removed

Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
2022-08-01 18:00:29 +02:00
Stephanos Ioannidis
532d2671be net: coap: Remove resource pointer NULL check
This commit removes the resource pointer NULL check inside the resource
enumeration loop of the `coap_well_known_core_get` function because the
expression `(resource + 1)` will never evaluate to NULL (aka. 0).

This fixes the "comparison will always evaluate as ‘true’ for the
pointer operand" warning generated by the GCC 12.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-01 10:47:23 +02:00
Sjors Hettinga
fafcbf59b9 net: tcp: Implement randomized retransmission timeouts
It can happen that two similar stacks enter a retransmission cycle
due to a packet collision. If the transmission timeout is the same
both stacks will retry at the same moment resulting in another
collision.

By introducing a randomized retry timeout, the chance of
a second collision is reduced and it reduces furter the more
retransmissions occur.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Sjors Hettinga
ea4f10fc58 net: tcp: Basic exponential backoff implementation
Apply an exponentially increasing wait time between tcp retries. This
is a good balance between reacting fast to single lost packets and reduce
the network load when an outage takes a little longer. It also allows the
connection to survive a longer interruption with less retransmissions.

Update the test to accommodate for the increased socket closure timeout

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Martin Tverdal
251a295d1a Bluetooth: Host: Don't read from buf after it is destroyed
Moving reading of index out of buf, to before buf is destroyed.

Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
2022-08-01 10:31:23 +02:00
Szymon Janc
f96f768532 Bluetooth: SMP: Fix min key size for LE Secure Connections Only mode
Secure Connection Only mode requires use of LE Security mode 1 level 4
which mandates 128 encryption key size.

Defaults in Kconfig are set from top-to-bottom and this resulted in
7 bytes key being forced. What is worse, user cannot override this
from prj.conf file since BT_SMP_MIN_ENC_KEY_SIZE is hidden config
if BT_SMP_SC_ONLY is enabled.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-08-01 10:30:16 +02:00
Mariusz Skamra
a0007f775f Bluetooth: audio: Fix server ASE Release in Codec Configured state
This fixes issue where the ASE state stuck in Releasing state instead of
going to Idle/Codec Configured as test requires.
Looks like there was a race condition possible where the ASE
notification work was run before the stream was detached, so there was
no transition to idle state triggered.

Fixes: ASCS/SR/ACP/BV-24-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-01 10:29:34 +02:00
Mariusz Skamra
55a70b97e6 Bluetooth: audio: Disallow Release operation on ASE in Releasing state
The server should not perform Release operation on ASE in Releasing
state. This fixes crash that might happen in ASCS when ACL gets
disconnected while ASE is in Releasing state so that server tries to
dereference NULL stream.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-08-01 10:29:29 +02:00
Aaron Massey
1cebee4a43 emul: Fix emul_espi_host.c type coercion
The data_host variable in the emul_espi_host_send_cw function should be
assigned the espi host emulator data and not the espi_emul data.

Assign the variable to correct reference.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-07-29 20:05:38 -05:00
Stephanos Ioannidis
e7263b19e1 Revert "ztest: Add config switch for modes of test output"
This reverts commit 5a850a5d06, which
broke multiple tests in the CI.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-29 15:44:32 -04:00
Stephanos Ioannidis
caed3931a4 Revert "ztest: add test summary after all suites finish running"
This reverts commit 0456ddc27d, which
broke multiple tests in the CI.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-29 15:44:32 -04:00
Hristo Mitrev
fc7287166c net: net_if.c: Fix build warning
Fix compilation warning in GCC 12 when it's not obvious that we want to
compare the adresses of the first elements of two arrays

Signed-off-by: Hristo Mitrev <hr.mitrev@gmail.com>
2022-07-30 01:43:22 +09:00
Stephanos Ioannidis
a2e2569684 testsuite: ztress: Remove idle thread NULL check
This commit removes the NULL check on the idle thread array
(`idle_tid`) because it is statically declared and will never be NULL.

This fixes the "comparison will always evaluate as ‘false’" warning
generated by the GCC 12.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-29 08:45:02 -04:00
YanBiao Hao
e1e366c912 Bluetooth: Mesh: fix le addr string overflow
le addr string arry overflow

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2022-07-29 14:11:11 +02:00
Ming Shao
0456ddc27d ztest: add test summary after all suites finish running
Add test summary after all test suites finish running.
The summary can be one-line or verbose, which is configured
with CONFIG_ZTEST_VERBOSE_SUMMARY. The one-line summary covers
overall suite stats. The verbose summary covers each test
function within the suite besides the one-line summary.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-07-28 18:07:01 -04:00
Ming Shao
5a850a5d06 ztest: Add config switch for modes of test output
Support verbose or one-line summary at test suite level.
Support verbose or no output at test function level.

Totally 4 combinations configurable:
- function verbose + suite verbose
- function verbose + suite oneline
- no function output + suite verbose
- no function output + suite oneline

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-07-28 18:07:01 -04:00
Vinayak Kariappa Chettimada
93728bf0ca Bluetooth: Add Periodic Advertising ADI support
Add support in Bluetooth Host to enable Periodic Advertising
ADI support feature when supported in the Controller to
include ADI in Periodic Advertising AUX_SYNC_IND PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-28 20:53:14 +02:00
Lingao Meng
e80161c86d Bluetooth: Mesh: Fix unable iv recovery 0 0 -> 1 0
According Mesh Spec 1.0.1:

Upon receiving and successfully authenticating to
Secure Network beacon for a primary subnet whose
IV Index is 1 or more higher than the current known IV
Index, the node shall set its current IV Index and its
current IV Update procedure state from the values in
this Secure Network beacon.

Look like test_iv_index.c:81
``` C

(bt_mesh_net_iv_update(TEST_IV_IDX + 1, BCN_IV_IN_IDLE));

```

This test case already exists, but the wrong testcase
to test wrong code.

Move `is_iv_recovery` into `bt_mesh_net_iv_update`.
First check whether it is IV recovery, and then carry out
the subsequent IV normal update procedure.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-07-28 19:47:36 +01:00
Emil Gydesen
d4b132a059 Bluetooth: Audio: Unicast client read available contexts
Read the available contexts during discovery and subscribe
for notifications.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-28 08:29:29 +02:00
Vinayak Kariappa Chettimada
a623ffb746 Bluetooth: Controller: Fix redundant node rx reservation
Fix redundant node rx reservation when receiving Periodic
Advertising Sync chain PDUs. Only the reception of first
pdu in chain, AUX_SYNC_IND PDU, needs extra node rx
reservation to be allocated for generation of incomplete
data status in case of incomplete reception of chain PDUs.

Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-27 18:46:51 +02:00
Vinayak Kariappa Chettimada
08a9c295fa Bluetooth: Controller: Fix hang on chain PDU allocation
Fix hang on chain PDU allocation by replacing K_FOREVER use
by a timeout. Hang occurs when configured number of
advertising data buffers is low.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-27 18:46:01 +02:00
Bartosz Golaszewski
7cddc5a6a3 net: ipv6: use static inlines where it makes sense for stubs
If we're disabling certain features and instead providing function stubs,
it doesn't make sense to use macros for those routines that return values
that the user may check unless we want to provide them with vague errors
like:

src/coap-server.c:101:55: error: expected expression before ';' token
  101 |  ret = net_ipv6_mld_join(iface, &mcast_addr.sin6_addr);

When a function we're mocking up returns a value, use a static inline
stub.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-07-27 18:44:07 +02:00
Seppo Takalo
b10f2c13ed net: lwm2m: Remove two useless macros
These two macros just change the name of function call
* NOTIFY_OBSERVER
* NOTIFY_OBSERVER_PATH

I don't see any benefit of those, so I dropped them.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-07-26 23:23:34 +00:00
Andrew Jackson
e7e827a0d2 kernel: Use mask rather than boolean to update events
Although there is nothing wrong with the existing code,
it doesn't permit individual bits to be set (or cleared).
This makes further changes slightly awkward.

Use a mask to restrict the bits set in an event.

Signed-off-by: Andrew Jackson <andrew.jackson@amd.com>
2022-07-25 15:24:32 -04:00
Piotr Pryga
a1963fccaf Bluetooth: llcp: Fix PHY UPD ntf send before instant on air
PHY update control procedure has to send a notification towards
Host when the PHY is actually changed, when the instant happens.
Control procedures are handled in a prepare phase of a connection
event, hence notifications are send towards host to early.

The fix for that is to postpone send of a notification.
New state has been introduced to remote requested PHY update
control procedure: RP_PU_STATE_WAIT_INSTANT_ON_AIR.
Also new event has been introduced: RP_PU_EVT_NTF, that is used
to inform the PHY update state machine that notification may
be send.

There are two places where the notification events may be generated
ull_conn_rx, just before first received PDU is send towards Host
or ull_conn_done, in case there were no PDU received.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-25 15:17:22 +02:00
Andriy Gelman
a3cdb2102c net: route: Fix pkt leak if net_send_data() fails
If the call to net_send_data() fails, for example if the forwading
interface is down, then the pkt will leak. The reference taken by
net_pkt_shallow_clone() will never be released. Fix the problem
by dropping the rerefence count in the error path.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-07-25 15:14:58 +02:00
Mariusz Skamra
6d85bd5a84 Bluetooth: gatt: Fix potential NULL pointer dereference
If the device was not paired, the conn->le.keys is NULL, so
conn->le.keys will cause NULL pointer dereference.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-25 09:39:39 +02:00
Kumar Gala
f2bcc794cd mgmt: osdp: Move to DTS for uart device
Move from using Kconfig OSDP_UART_DEV_NAME to a devicetree
chosen property ("zephyr,osdp-uart").  This is similar to a number
of other functions like "zephyr,shell-uart" or "zephyr,bt-uart".

Changed the integration platform for the osdp samples to
stm32_min_dev_black as it already has zephyr,osdp-uart set.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-23 09:25:23 -05:00
Hang Fan
8d06fd8d15 Bluetooth: Audio: Fix typo
Fix typo for CONFIG_BT_PAC_SRC_LOC_WRITEABLE

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-07-22 23:48:25 +02:00
Kumar Gala
44fb3febe6 settings: just use struct device
Replace going from 'struct device', to name, and back with just using
the 'struct device' directly.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-22 23:48:07 +02:00
Martin Tverdal
89780d715d Bluetooth: Host: Don't start scanner bt_conn_le_create
Starting the pasive scanner so host can resolve addresses
shouldn't be nessesary when the resolving list is empty.

Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
2022-07-22 14:05:21 +00:00
Mariusz Skamra
aa1771fb15 Bluetooth: shell: Remove redundant name parameter from adv-data cmd
The `name` parameter is redundant, as the `name` and `name-ad` options are
available already as `adv-create` and `adv-param` command parameters.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-22 10:33:45 +02:00
Krzysztof Chruscinski
15fdee04e3 logging: log_output: Add function for processing input arguments
Add function which formats a logging string from input parameters
and not from logging message. This function is more flexible since
it does not require data to be placed in the log message.

Converted a function for message processing to used this new function
internally.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-21 09:04:37 -04:00
Justin Huang
cb5264162d logging: added log process thread priority support
Added Zephyr config items to support setting the priority of the log
process thread at build time.

Signed-off-by: Justin Huang <justinyhuang@fb.com>
2022-07-21 08:59:38 -04:00
Reto Schneider
75ea632ba1 fs: fcb: Define length padding bytes
Before this, on flashes with a write alignment greater than one, the
padding bytes had no defined value.

The effect of this non-deterministic code made it hard(er) to verify
data written by FCB.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-07-20 11:09:29 +02:00
Aleksander Wasaznik
58c5e32e08 Bluetooth: Host: Disable host-based RPA resolution when !BT_PRIVACY
Change doc of CONFIG_BT_PRIVACY to explicitly say it's needed for both
generating and resolving RPAs.

Disable host-based RPA resolution in `bt_conn_le_create` when
!CONFIG_BT_PRIVACY.

Update doc of `bt_conn_le_create` to document that CONFIG_BT_PRIVACY is
a requirement for resolving RPAs. Also explictly say that this function
will resolve private identities. Also explain the expected effect of
Network Privacy on this function.

Reduce coupling to `bt_le_create_conn_ext` and
`bt_le_create_conn_legacy` in `bt_conn_le_create` by just use
`resp_addr` when it's set, instead of "knowing" when it had been set.
The alternative would be to also update `bt_le_create_conn_ext` and
`bt_le_create_conn_legacy` to have `(IS_ENABLED(CONFIG_BT_PRIVACY) &&
(!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size))`

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-07-20 10:48:09 +02:00
Aleksander Wasaznik
2b68a7d391 Bluetooth: Host: Make function static
`bt_le_create_conn_legacy` is not used outside its file.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-07-20 10:48:09 +02:00
Kumar Gala
dcfcd05ed3 tracing: Move to DTS for uart device
Move from using Kconfig TRACING_BACKEND_UART_NAME to a devicetree
chosen property ("zephyr,tracing-uart").  This is similar to a number
of other functions like "zephyr,shell-uart" or "zephyr,bt-uart".

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 16:00:47 -07:00
Kumar Gala
8fb2210cfb emul: remove name param from bus register APIs
Rework the <BUS>_emul_register calls to not pass the name param.  The
name param is only used for logging and we can get it from the
struct <BUS>_emul instead.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 15:52:36 -05:00
Kumar Gala
b8c276a363 emul: emul_bmi160: Remove unused bus_label
The bus_label is not used and is using DT_INST_BUS_LABEL which is
now deprecated and thus causes an error when running CI.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 13:21:03 -05:00
Aaron Massey
fc98549952 emul: Use DEVICE_DT_GET instead of DT_LABEL
DT nodes aren't guaranteed to define a label property. But emulated bus
controllers currently make use of this property to dispatch to the
associated emulator.

Have emulated bus controllers use DEVICE_DT_GET(node_id) to dispatch to
right target peripheral emulator. This also change makes emul_get_binding
and device_get_binding synonymous in behavior with respect to their
parameters.

This also strictly enforces a 1:1 correspondence between invocations of
DEVICE_DT_DEFINE and EMUL_DEFINE.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-07-19 11:43:30 -05:00
Aaron Massey
5e2678135d emul: Make emulator parameters consistently named
Some paramaters in prior emulators have historically referred to instances
of struct emul as "emulator" or "emul". The proper parameter name for this
type is "target" as it designates the struct emul instance is the emul
bus (e.g. emul_i2c) controller's target peripheral for dispatch.

Do a small refactor renaming some of these parameters to "target".

TEST=twister on accel, espi, and eeprom drivers tests

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-07-19 11:43:30 -05:00
Aaron Massey
76ae0ba270 emul: Remove or declare unused args
In several locations of the emulator code there are unused function
arguments that were never caught.

Declare these as unused or remove the unused function parameters entirely.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-07-19 11:43:30 -05:00
Aaron Massey
9d7b9dc807 emul: Simplify emulator bus initialization and API
Allow emulator creators to write an init function that can be used
across multiple busses so as to reduce the boilerplate and cognitive
load in creating an emulator.

Part of this change includes allowing access to the emul struct from a
field in a {bus}_struct api (e.g. i2c_struct), which removes the need for
sporadic usages of CONTAINER_OF to access the emul struct.

Overall, this change simplifies and reduces the amount of boilerplate
code to get a device emulator up and running, thus reducing excise work
to writing tests.

TEST=twister on accel,espi, and eeprom drivers tests

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-07-19 11:43:30 -05:00
Aaron Massey
1028459afd emul: Run clang-format
Run clang-format on all files touched by improved emulator API pull-request
that allowed access to the target device emulator from its bus api without
CONTAINER_OF usage.

drivers/i2c/i2c_emul.c
drivers/spi/spi_emul.c
include/zephyr/drivers/emul.h
include/zephyr/drivers/espi_emul.h
include/zephyr/drivers/i2c_emul.h
include/zephyr/drivers/spi_emul.h
subsys/emul/emul.c
subsys/emul/emul_bmi160.c
subsys/emul/espi/emul_espi_host.c
subsys/emul/i2c/emul_atmel_at24.c

TEST=twister on accel,espi, and eeprom drivers tests

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-07-19 11:43:30 -05:00
Emil Gydesen
df75bfd8f6 Bluetooth: Audio: Add PACS location read for unicast client
The unicast client will now read the PACS location value
during the discovery procedure, as well as subscribing to
it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-19 12:27:00 +00:00
Emil Gydesen
5aa1ab9c1a Bluetooth: Audio: Remove redundant unicast client guard
The code in unicast_client.c was guarded by
CONFIG_BT_AUDIO_UNICAST_CLIENT but the file is only
compiled if CONFIG_BT_AUDIO_UNICAST_CLIENT is enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-19 12:27:00 +00:00
Emil Gydesen
dab588a23a Bluetooth: Audio: Rename unicast client PAC cache
Rename the cache from "cache" to "pac_cache" to avoid
name clashes with local cache variables.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-19 12:27:00 +00:00
Fredrik Danebjer
c0ab35a997 Bluetooth: GATT: Add LE Secure Connections Permission Check
Added possibility to enforce that a LE Secure Connection is required
for reading and writing characteristics, i.e. providing a more fine
grained check that allows services that requires secure connection
to co-exists with those that doesn't.

Signed-off-by: Lars Knudsen <larsgk@gmail.com>
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-07-19 10:32:56 +02:00
Mariusz Skamra
31d3479c85 Bluetooth: shell: audio: Extend vcs init with opt params
Extend the `vcs init` command with optional parameters to set the
initial VCS state including volume level, mute state and step size.
This is needed to pass qualification test cases listed below:
VCS/SR/CP/BV-01-C,
VCS/SR/CP/BV-02-C,
VCS/SR/CP/BV-02-C,
VCS/SR/CP/BV-04-C

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-18 18:42:34 +02:00
Andreas Rudolf
422f98182c Bluetooth: shell: fix bt init sync command
Shell command "bt init sync" now correctly enables Bluetooth
synchronously, and "bt init" enables Bluetooth asynchronously.

Fixes #47860.

Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
2022-07-18 18:42:02 +02:00
Emil Gydesen
577caf774e Bluetooth: Audio: User _ prefix for sys_snode_t nodes
The sys_snode_t nodes are used internally, and we use the
convention of the "_" prefix to indicate that this is
an internally used value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 18:30:43 +02:00
Emil Gydesen
549a98acce Bluetooth: Audio: Modify broadcast sink to use list of streams
Modify the broadcast sink to use a list of streams instead
of an array. This removes the requirement that the array
of stream pointers shall be static, and makes the
broadcast sink API and implementation more similar
to the unicast group and broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 18:30:43 +02:00
Emil Gydesen
468bd4d852 Bluetooth: Audio: Modify broadcast source to use a list of streams
Modify from array to list. The list approach is easily
implemented as it is used for the unicast groups, and
using the list approach instead of an array does not
require the array to be static.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 18:30:43 +02:00
Tomislav Milkovic
0fe2c1fe90 everywhere: Fix legacy include paths
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths

Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
2022-07-18 16:16:47 +00:00
Robert Lubos
78c871ab86 net: sockets: Fix potential deadlock during TCP send
There is a potential, corner case scenario, where a deadlock can occur
between TCP and socket layers, when both ends of the connection transmit
data.

The scenario is as follows:
 * Both ends of the connection transmit data,
 * Zephyr side send() call gets blocked due to filing the TX window
 * The next incoming packet is data packet, not updating the RX window
   on the peer side or acknowledging new data. The TCP layer will
   attepmt to notify the new data to the socket layer, by calling the
   registered callback. This will block the RX thread processing the TCP
   layer, as the socket mutex is already acquired by the blocked send()
   call.
 * No further packets are processed until the socket mutex is freed,
   which does not happen as the only way to unblock send() is process
   a new ACK, either updating window size or a acknowledging data.
   The connection stalls until send() times out.

The deadlock is not permament, as both threads get unlocked once send()
times out. It effectively breaks the active connection though.

Fix this, by unlocking the socket mutex for the time the send() call is
idle. Once the TCP layer notifies that the window is available again,
the mutex is acquired back.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-07-18 08:36:09 -07:00
Emil Gydesen
eab6d202ca Bluetooth: Audio: Add unicast server stream reconfigure
Add support for the reconfigure procedure for the unicast
server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 13:18:35 +00:00
Emil Gydesen
b74aa44df5 Bluetooth: Audio: Add unicast server stream start
Add support for the unicast server to start a stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 13:18:35 +00:00
Emil Gydesen
49c0074b81 Bluetooth: Audio: Add unicast server stream metadata
Add support for setting metadata as the unicast server role.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 13:18:35 +00:00
Emil Gydesen
a79318f627 Bluetooth: Audio: Add unicast server stream disable
Add support for disabling streams as the unicast
server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 13:18:35 +00:00
Emil Gydesen
a22bbee33a Bluetooth: Audio: Add unicast server stream release
Update bt_audio_stream_release to also support the unicast
server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-18 13:18:35 +00:00
Yuval Peress
b513e621b0 docs: ztest: Update documentation for new API
Documentation now includes:
- How to create a test suite
- How to use predicates
- How to use setup/before/after/teardown
- How to use test rules
- Direct people to use FFF instead of ztest mock

Fixes #47420

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-15 22:25:41 +00:00
Mariusz Skamra
df5a535a5f Bluetooth: audio: Fix bt_pacs_context_available
This fixes bt_pacs_context_available so that it gets available
contexts from capabilities that hold the value.
This removes redundant available_context that were held
(and not updated) in pacs.c.

Fixes: HAP/HA/STR/BV-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-15 15:33:35 +02:00
Jonathan Rico
ffefce7745 Bluetooth: host: Rewrite bt_gatt_notify_multiple
This API now becomes a low-level API, in the sense that it should only be
used if the app developer knows what he is doing and wants to ensure a
ATT_MULTIPLE_HANDLE_VALUE_NTF PDU goes on-air.

For the other 99% of use cases, `bt_gatt_notify` should instead be used, as
it will automatically upgrade to ATT_MULTIPLE_HANDLE_VALUE_NTF when
possible.

One can disable the batching of notifications when using `bt_gatt_notify`
by setting CONFIG_BT_GATT_NOTIFY_MULTIPLE_FLUSH_MS=0 .

This API doesn't support lookup by UUID any more.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-15 12:17:29 +02:00
Jonathan Rico
7e9f652ee6 Bluetooth: host: Invoke GATT notify callback for each handle
In the case a call to `bt_gatt_notify_cb` gets its attribute data
batched with others to form an ATT_MULTIPLE_HANDLE_VALUE_NTF PDU, the
application developer would still expect one callback per API call.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-15 12:17:29 +02:00
Jonathan Rico
e6dfbe82fd Bluetooth: host: Don't send ATT_MULTIPLE_HANDLE_VALUE_NTF with one attr
Sending ATT_MULTIPLE_HANDLE_VALUE_NTF containing only one handle doesn't
seem forbidden by the spec, but peers might find it unexpected.

This change morphs a ATT_MULTIPLE_HANDLE_VALUE_NTF into a
ATT_HANDLE_VALUE_NTF right before sending it, if it detects this
condition.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-15 12:17:29 +02:00
Jonathan Rico
0218e9db18 Bluetooth: host: Fix gatt_notify_mult by using a delayed work item
The intended behavior is that calling `gatt_notify_mult` in a loop will
result in a `BT_ATT_OP_NOTIFY_MULT` containing all the handles and their
data.

What was happening instead is that the caller thread was a lower priority
than the system workqueue, and thus multiple `BT_ATT_OP_NOTIFY_MULT` PDUs
were being sent over the air instead of one.

Submitting the work item with a delay side-steps this particular issue.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-15 12:17:29 +02:00
Ola Tangen Kulseng
1563d4a0c3 net: lwm2m: Default ssid
Created the variable CONFIG_LWM2M_SERVER_DEFAULT_SSID to be
the default ssid when not using bootstrap. Needed for access control.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-07-15 10:10:16 +02:00
Ola Tangen Kulseng
e05bcefedb net: lwm2m: Access control object
Implementation of the access control object. Core object (obj_id 2).
If used without bootstrap, the default value in
CONFIG_LWM2M_SERVER_DEFAULT_SSID will be used as access control owner.
Enable/disable ac control with CONFIG_LWM2M_ACCESS_CONTROL_ENABLE.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-07-15 10:10:16 +02:00
Jonathan Rico
7411b451da Bluetooth; GATT: don't immediately cancel CCC write request
`bt_gatt_unsubscribe` was pending a write to the CCC and then immediately
canceling it.

Fixes #47682 .

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-15 10:01:15 +02:00
Johann Fischer
f7c9f328a4 different subsystems: use unsigned int for irq_lock()
irq_lock() returns an unsigned integer key.
Generated by spatch using semantic patch
scripts/coccinelle/irq_lock.cocci

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-07-14 14:37:13 -05:00
Tom Burdick
c225cf3b8a dma: HDA rename prefix from cAVS to ADSP
HDA is a common IP used across the entire ADSP line and deserves
a name respecting that alongside similiar IP drivers such as the
ADSP GPDMA driver.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-07-14 17:53:46 +00:00
Omkar Kulkarni
43f3c8fb7e Bluetooth: Mesh: IV Index timer is not started
This fixes an issue where IV index stage counting timer is not
started after the node is provisioned. This would have prevented node
from performing IV index updates.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2022-07-14 17:51:31 +00:00
Fredrik Danebjer
04a080bf70 Bluetooth: Audio: TBS Client optional procedures actually optional
This change makes the optional procedures in the TBS Client optional
and configurable through Kconfig.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-07-14 15:48:28 +00:00
Eduardo Montoya
e38c518540 net: openthread: fix mbedtls config when SRP is enabled
SRP feature requires `MBEDTLS_ECP_DP_SECP256R1_ENABLED` and
`MBEDTLS_HMAC_DRBG_ENABLED`.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-07-14 10:31:56 +02:00
Jackson Cooper-Driver
f06c06de07 ipc_service: Add endpoint registered check
Currently, it is possible to call various ipc_service functions
which take in an endpoint pointer (such as send, get_tx_buffer)
with an endpoint which has not been registered with the instance.
This leads to dereferencing a NULL pointer when the function tries
to access the api field of ept->instance.
This patch adds in multiple checks to ensure that the endpoint is
registered before continuing, one in the frontend, when ensures
that the ept->instance pointer is not NULL and one in the backend
which checks the value of the token pointer. If either of these fail,
we return -ENOENT.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-07-14 10:29:42 +02:00
Kumar Gala
989e17a493 dma: HDA: Convert to DEVICE_DT_GET
Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-13 13:11:17 -05:00
Piotr Pryga
e84cabf0d4 Bluetooth: Controller: fix mayfly unwanted re-init every bt_enable call
Mayfly by design uses a memq for storage of its jobs. The memq
requires head and tail to track the content. It is considered
empty is head equals tail.

When memq instance is initialized then there is a new link
instance stored in head and tail, nevertheless the memq is
still empty.

When new job is enqueued to a memq, the inilial link is used
to store the job. New link, provided by enqueue call, is stored
in the tail for future enqueue.

When enqueued job was served and is dequeued, the link it was
assigned to is returned and stored in the job object.
That link will be used in future for call to enqueue.

Now lets consider a situation when we are just after initalization.
Some default initial link is in empty memq. We enqueue and dequeue
a job. After dequeue, the job object stores the initial link object.
The one that was put into the memq during initialization.
Next Bluetooth stack is disabled and enabled again.

The job is enqueued again, but it still stores the initial link
address. After enqueue the memq head points to initial link object,
that stores new job. Tail points to link deliveded by enqueue call,
that is also the initial link object. The memq is considered to be
empty, nevertheless there was a successful enqueue operation.

The issue is casued by lack of re-initialization of a job object
on init. In most cases these objects are static members of some
functions, hence there is no re-initialization after bt_disable
and bt_enable calls.

The problem is fixed by re-initialization of mayfly only once
on bt_enable() call. Then it doesn't matter what links are stored
in dequeued objects and there is no need to re-initialized mayfly
job objects.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-13 16:13:57 +02:00
Piotr Pryga
9cd94277bf Bluetooth: Host: conn_change signal object not correclty initialied
The problem is visible after call to bt_disable when there was
a connection. On a next bt_enable call when hc_tx_thread starts
it is possible that the conn_change object internals are not
re-initialized entirely and the function fails during k_poll call.

The commit changes explicit assignment conn_change object to
a k_poll_signal_init that does proper initialization.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-13 16:13:57 +02:00
Piotr Pryga
2125a6494c Bluetooth: Host: add missing de-init of periodic sync pool
While execution of bt_disable there is missing de-initialization
of per_adv_sync_pool. If there was a sync in progress, (flags set
to BT_PER_ADV_SYNC_SYNCING) before bt_disable, then when the stack
is re-enabled by bt_enable new sync create fails.

The commit fixes the issue by new function that clears flags for
all per_adv_sync_pool entries. The function is executed by bt_disable.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-07-13 16:13:57 +02:00
Johann Fischer
700323dd3d modbus: use DT_INST_PARENT instead of DT_INST_BUS
Node is not a bus controller,
use DT_INST_PARENT instead of DT_INST_BUS.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-07-13 11:36:59 +02:00
Johann Fischer
6130417212 usb: device: add dummy configure API
We cannot implement configure API because there is
no notification of configuration changes provided
for the Abstract Control Model and the UART controller
is only emulated.
However, it allows us to use CDC ACM UART together with
subsystems like Modbus which require configure API for
real controllers.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-07-13 11:36:59 +02:00
Henrik Brix Andersen
d22a9909a1 drivers: net: canbus: move CAN bus network driver to drivers/net
Move the CAN bus network driver from drivers/can to drivers/net as it
implements a network driver, not a CAN controller driver.

Use a separate Kconfig for enabling the CAN bus network driver instead of
piggybacking on the SocketCAN Kconfig. This allows for other
(e.g. out-of-tree) SocketCAN transports.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-13 10:34:51 +02:00
Pavel Vasilyev
e492894a5e Bluetooth: Mesh: Call bt_mesh_reset in cfg srv from workqueue
Struct bt_mesh_send_cb.end is called from the mesh advertiser thread.
bt_mesh_reset now requires more stack size, thus can't be called from
the advertiser thread. k_work instance requires less memory than needed
for bt_mesh_reset.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-07-13 10:19:44 +02:00
Pavel Vasilyev
f4d1529947 Bluetooth: Mesh: Flush pending settings in bt_mesh_reset/_cdb_clear
Upon bt_mesh_reset call, all mesh modules has to clear the privisioning
and configuration data. None of the modules store or erase in settings
subsystem immediately, but put this on the mesh settings work. After the
settings work is scheduled, all stored data will be removed and the
device will eventually be unprovisioned. Until then, the device is not
completely unprovisioned, thus calling bt_mesh_prov_enable,
bt_mesh_provision (and bt_mesh_cdb_create) should not be allowed.

Struct bt_mesh_prov has a reset callback stating that after this
callback is called, the device has been reset and can be re-provisioned
again. Also, bt_mesh_reset API description states that after calling
bt_mesh_reset API, the device needs to reenable the provisioning layer
to be provisioned again. But this is not correct since the settings has
to be cleared before the device can be reprovisionined.

This commit makes bt_mesh_reset flush pending settings so that the
device can be reprovisioned immediately and the API will behave as
written in the description.

The same applies to bt_mesh_cdb_clear.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-07-13 10:19:44 +02:00
romain pelletant
3908b9dc74 net: lwm2m: Add Event Log object
Event Log object (ID:20) from OMA LwM2M support added

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2022-07-13 10:19:26 +02:00
Emil Gydesen
c699ae5850 Bluetooth: Audio: Expose broadcast sink adv data to application
In the broadcast sink `scan_recv` which is called when we
scan for broadcast source, we now also provide the entire
AD struct to the application.

The reason for this is that the advertising data may
contain other information that is useful for the application
like the broadcaster device name or any other
vendor/application specific data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-12 14:17:02 +02:00
Emil Gydesen
9b15426455 Bluetooth: Audio: Refactor ISO allocation endpoints
Modify how the ISO channels are allocated for the audio streams,
as well as how the CIG is allocated for the unicast group.

This fixes an issue where the unicast group could not be
fully allocated before _after_ the bt_audio_streams had been
configured by bt_audio_stream_config, thus making it impossible
to create a unicast group before the connections have been established.

This leaves us with 3 basic data types:
1) Streams allocated by the application
2) Endpoints that represent ASEs
3) Audio_iso which is used to couple streams and ISO channels.

The Unicast Group for the unicast client will now have the same
lifetime as the ISO CIG for the central.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-12 14:12:08 +02:00
Jonathan Rico
76f74344a8 Shell: kernel: Add runtime log filtering command
Use `kernel log-level modulename severity`
Also enable it for the Bluetooth Shell.

Then one can compile-in a lot of BT modules like so:

CONFIG_BT_DEBUG_HCI_CORE=y
CONFIG_BT_DEBUG_L2CAP=y
CONFIG_BT_DEBUG_ATT=y
CONFIG_BT_DEBUG_GATT=y

And at runtime select only, e.g. GATT

kernel log-level bt_hci_core 0
kernel log-level bt_l2cap 0
kernel log-level bt_att 0

And then re-enable L2CAP if needed later

kernel log-level bt_l2cap 4

And so on..

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Herman Berget
a0ce235d9b Bluetooth: Shell: Add bt security command to list current security level
The command could previously only set the security level.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico
e797c69554 Bluetooth: shell: add l2cap ECRED commands
Add commands to connect to an l2cap channel using Enhanced Credit-based
Flow Control, and to reconfigure it.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico
71bcab6335 Bluetooth: shell: add hexdump on GATT read
In order to actually see the data instead of just getting the length.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico
7f88638e11 Bluetooth: shell: stop l2cap TX when channel is disconnected
Without this, the shell locks up when disconnected in the middle of a send
routine.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico
92bd415750 Bluetooth: shell: add param-less connect command
When invoked without parameters, `bt connect` will now attempt to connect
to the last scanned device. Used in conjunction with the RSSI filter, this
makes the connection process somewhat scriptable.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico
55179da0fc Bluetooth: shell: add RSSI filtering
This adds an RSSI cutoff, so any scanned devices that are below the given
value (in dB) will not get printed out. Very useful in noisy environments.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico
ad4cf99eb3 Shell: add kernel sleep command
Basic sleep command for scripting purposes.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 12:24:43 +02:00
Jonathan Rico
e0f0f4ab45 Bluetooth: Host: add missing bt_conn_unref
conn is being referenced in `bt_conn_lookup_addr_le()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 11:14:29 +02:00
Jonathan Rico
38cd73d47d Bluetooth: gatt: check subscription before notifying
Check that the client has subscribed before sending a notification.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-07-12 11:14:29 +02:00
Asbjørn Sæbø
dbe8a3ff96 Bluetooth: Audio: Additional MEDIA_PROXY defines
Add two MEDIA_PROXY group type defines corresponding to the MCS ones.
Update the mpl.c to use the newly added names.

The purpose of the exercise is to get a complete set of MEDIA_PROXY
defines, so that the media player can be made fully independent
(define-wise) of the MCS.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-07-12 10:15:32 +02:00
Asbjørn Sæbø
704d5ee0bf Bluetooth: Auidio: Use MEDIA_PROXY_* defines in media player
Update the media player to use the MEDIA_PROXY_* defines rather than the
BT_MCS defines.  The media player should not know about the MCS (media
control service).

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-07-12 10:15:32 +02:00
Kumar Gala
5c50591070 emul: emul_bmi160: Remove unused struct element
The bus_label field of the struct was not used, so remove it.  This
lets us remove one of the last users of DT_INST_BUS_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-12 10:14:23 +02:00
Jordan Yates
962eca65af pm: device_runtime: detect power up failures
Check that the device we are trying to use has successfully powered up
when it is on a power domain. If it has not, release the request for the
power domain to be powered to ensure we do not have dangling requests.

As a result of this, `PM_DEVICE_ACTION_RESUME` will not be run on a
device if `PM_DEVICE_ACTION_TURN_ON` has already failed.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-12 10:07:18 +02:00
Jordan Yates
317679031d pm: device: store power up failures
Store errors powering up devices in a flag in the PM struct. This is
required as the `pm->state` variable always transitions to
`PM_DEVICE_STATE_SUSPENDED`, even when `PM_DEVICE_ACTION_TURN_ON`
returns an error. Marking the transition as failed will allow the
transition logic in `pm_device_runtime_get` to detect the problem.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-12 10:07:18 +02:00
Anas Nashif
01582f80b7 scripts: move gen_cfb_font_header.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Krzysztof Chruscinski
5f60164a0f logging: Prevent redundant thread wake up
Fix a bug introduced by 658123bb21 where if all backends were
ready prior to logging thread loop, thread was periodically
waken up for no reason. Fix is setting timeout to K_FOREVER
if all backends are ready after the initialization.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-11 18:05:35 +00:00
Krzysztof Chruscinski
60ca7899c7 logging: Initialize backends with autostart flag set
Added check which ensures that only backends with autostart
flag set are enabled automatically by the logging.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-11 18:05:35 +00:00
Pieter De Gendt
a727b8aaac debug: coredump: flash backend: add query/command to get raw data
Add a new coredump query and command type to retrieve the raw data
stored to the flash backend

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-07-11 18:04:05 +00:00
Mariusz Skamra
a3904bd991 Bluetooth: audio: Fix PACS location chrc properties
If the characteristic is non-writtable, the BT_GATT_CHRC_WRITE property
flag shall be unset. Moreover, threre is no point to set
BT_GATT_PERM_WRITE_ENCRYPT permission flag as well if the attribute has
no `write` callback set anyway.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-11 16:04:42 +00:00
Carlo Caione
1e74f1bff5 arch: Introduce S2RAM interface
Add a new API used by arch to implement suspend-to-RAM (S2RAM).

The API is composed by a single function to save the CPU context on
suspend.

A CPU context is the arch-specific set of registers that must be
preserved on power-off (in retained RAM) to be able to resume the
execution from the point it was suspended without going through the
whole kernel startup stage.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-11 15:26:26 +02:00
Vinayak Kariappa Chettimada
b397a950c5 Bluetooth: Controller: Fix missing reset of coded PHY scanning
When switching from Extended Scanning by Extended
Advertising HCI commands back to Legacy Scanning after a
HCI reset it is required that the coded PHY scanning
context is reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-11 14:15:13 +02:00
Vinayak Kariappa Chettimada
265731b971 Bluetooth: Controller: Fix Extended Scan Address Resolution
Fix Extended Scanning Address Resolution that incorrectly
checked for Bit Count Comparison which is not to be checked
when explicit resolution is performed in the Rx ISR.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-11 13:53:19 +02:00
Vinayak Kariappa Chettimada
918585263e Bluetooth: Controller: Use maximum Adv PDU size time reservation
Use the maximum advertising PDU size time reservation
consider the Advertising Data could be updated from zero to
maximum support size. If maximum time reservation is
disabled then time reservation corresponding to the
Advertising Data present at the time of the start/enable
of Advertising is used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-11 13:34:29 +02:00
Vinayak Kariappa Chettimada
fab4511164 Bluetooth: Controller: Fix overlapping advertising events
When multiple advertising sets are support then use advanced
scheduling implementation to place multiple auxiliary PDUs
and periodic advertising PDUs in a non-overlapping schedule.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-11 13:34:29 +02:00
Anas Nashif
32c22cc63a ztest: generate symbols for tests
This will help with parsing testcases in test binaries.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-11 11:56:39 +02:00
Jordan Yates
8a2eed6cbd pm: device_runtime: use atomic_test_bit
Use `atomic_test_bit` when checking pm flags instead of manually using
bitwise operations.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-11 11:33:26 +02:00
Jordan Yates
ab0bf48660 pm: device: store power state in all scenarios
Update the internal power state tracking for `PM_DEVICE_ACTION_TURN_ON`
and `PM_DEVICE_ACTION_TURN_OFF` even when the transition function fails.
Just because the driver couldn't perform some action does not mean the
device is still powered/unpowered.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-11 11:33:26 +02:00
Jordan Yates
caca393aad pm: device: more complete state checking
Add state checking to every transition to ensure that the device is in
the state we think it is before running the action.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-11 11:33:26 +02:00
Kiril Petrov
a4557a46b8 net: lwm2m: Pass client_ctx to observe callback
In case LWM2M cient wants to change attrs of observed obj,
it needs pointer to client_ctx.

For example:
On observer add, wants to change pmin for some obj path to 1s:

static void observe_cb(enum lwm2m_observe_event event,
		struct lwm2m_obj_path *path, void *user_data)
{
	struct lwm2m_ctx *ctx = (struct lwm2m_ctx *) user_data;

	switch (event) {
	case LWM2M_OBSERVE_EVENT_OBSERVER_ADDED:
		lwm2m_engine_update_observer_min_period(ctx, "3347", 1);
	...
}

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2022-07-11 09:32:18 +00:00
Vinayak Kariappa Chettimada
e027f0671a Bluetooth: Controller: Fix missing recv fifo reset
Fix missing recv fifo reset on HCI reset. This fix handles a
scenario where in Rx Prio thread has enqueued a node rx, Tx
thread handles HCI Reset Command, and Rx thread wakes up
from call to k_fifo_get to handle invalid node rx. The
changes here ensure Rx thread does not get any invalid node
rx post HCI Reset Command handled in Tx thread.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-11 11:28:07 +02:00
Kamil Piszczek
1eb9d36d46 bluetooth: add api for changing rpa timeout in runtime
Added a new Bluetooth API and Kconfig option for overriding the RPA
timeout in runtime.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-07-11 09:27:07 +00:00
Kamil Piszczek
8bdf363c0c bluetooth: adv: add rpa timeout callback to extended advertising api
Added a new callback to the Bluetooth Extended Advertising callback
structure. It notifies the application that the RPA validity of the
advertising set has timed out. The user can use this callback to
synchronize the advertising payload update with the RPA rotation.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-07-11 09:27:07 +00:00
Kamil Piszczek
4e924b6b1f bluetooth: id: sync advertising set start after rpa rotation
Synced the start of the advertising sets after each RPA rotation
in the Bluetooth identity module.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-07-11 09:27:07 +00:00
Daniel Leung
d0d6e1181c logging: backend: notify when process thread finishes one cycle
This adds the bits to allow the process thread to notify
backends when it has finished processing pending log messages.

This allows, for example, flash-based backends to group writing
log messages to storage to limit wear, since log_output_flush()
is called per message. Also the backend does not have to resort
to using timer to periodically flush its buffer to storage,
avoiding waking up the device when there are no messages.
Another use of this is for backends requiring DMA transfers.
Grouping all pending log messages into one DMA transfer is
sometimes preferrable.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-07-11 11:09:31 +02:00
Simen S. Røstad
92eb309918 net: lib: lwm2m: Give Kconfig choices symbol names
Give Kconfig choices symbols names so that they can be redefined in
applications that wants to alter the choice's default value without
setting it in the project configuration.

Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
2022-07-11 11:03:41 +02:00
Robert Lubos
815ebc316e net: openthread: Move glue code into module directory
Move OpenThread's glue code along with the Kconfig files that configure
OpenThread stack itself into module directory.

Update the maintainers file to reflect this change.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-07-11 11:00:12 +02:00
Pawel Osypiuk
7fcfd54423 usb: device: cdc_acm: suspend transfers when RX path runs out of buffer
Suspend CDC ACM class OUT transfers when RX path runs out
of ring buffer.

Signed-off-by: Pawel Osypiuk <pawelosyp@gmail.com>
2022-07-11 10:31:12 +02:00
Yudong Zhang
47ea15edcd shell: mqtt: fix call to bin2hex
Fixes: f2affbd973 ("os: lib: bin2hex: fix memory overwrite")
Signed-off-by: Yudong Zhang <mtwget@gmail.com>
2022-07-11 10:30:05 +02:00
Yudong Zhang
73c4d70614 mgmt: hawkbit: fix call to bin2hex
Fixes: f2affbd973 ("os: lib: bin2hex: fix memory overwrite")
Signed-off-by: Yudong Zhang <mtwget@gmail.com>
2022-07-11 10:30:05 +02:00
Yudong Zhang
0c4d614824 mgmt: updatehub: fix call to bin2hex
We noticed that in the master branch, updatehub fails to start.
That is because of the behaviour change in bin2hex caused by
commit f2affbd ("os: lib: bin2hex: fix memory overwrite").

Fixes: f2affbd973 ("os: lib: bin2hex: fix memory overwrite")
Signed-off-by: Yudong Zhang <mtwget@gmail.com>
2022-07-11 10:30:05 +02:00
Emil Gydesen
4b953eabf8 Bluetooth: Audio: Moved ASCS metadata verification to higher layer
Instead of rejecting metadata at the BAP layer, we now
expect the higher layer to provide the verification.

The reason for this is that the higher layer may be better
equiped at determining which metadata it supports.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
Emil Gydesen
e1114bf3dd Bluetooth: Audio: Add CAP acceptor set member support
The CAP acceptor can now be a set member. This allows
the CAP acceptor to register a CSIS instance and include
it in the CAS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
Emil Gydesen
9298c0f96f Bluetooth: Audio: Add CAP acceptor CCID check for TBS
Add bt_cap_acceptor_ccid_exist that verifies that CCIDs
from the CAP initiator are valid on the initiator based
on what we have previously discovered.

Verification from MCS is still a TODO.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
Emil Gydesen
e712a2462b Bluetooth: Audio: Add get_by_ccid for TBS
This is needed for the CAP acceptor to properly
verify the CCID_List in the metadata.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
Emil Gydesen
539ffe296e Bluetooth: Audio: Add stream context validation for CAP acceptor
When the CAP acceptor role is enable, ASCS will verify
that the stream context type supplied by the client
matches the PACS available context.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
Emil Gydesen
6eb67b9b6a Bluetooth: Audio: ASCS verify metadata type
Add a check to verify metadata type in the
update metadata procedure handler.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
Emil Gydesen
aab98d6b1c Bluetooth: Audio: Add ASCS Metadata verification before copy
Verify the metadata before copying it. This will allow the
unicast server to verify the data and potentially
reject it without modifying existing metadata.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
Emil Gydesen
2c6358c9c9 Bluetooth: Audio: Add CAP acceptor
Adding the CAP Acceptor role, which is a quite simple
role. The role instantiates the Common Audio Service (CAS)

The role will later be expanded to properly support
the use the Coordinated Set Member role via CSIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:08:45 +00:00
YanBiao Hao
06b246c04c Bluetooth: Mesh: cfg cli async status callback
Relay Status, Netkey Status, Appkey Status,
Mod App Status, Node Identity Status, LPN
PollTimeout Status,

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2022-07-08 20:01:02 +00:00
YanBiao Hao
b197f089b3 Bluetooth: Mesh: fix mod sub status async mod id
fix mod sub status async mod id

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2022-07-08 20:01:02 +00:00
Emil Gydesen
1b9c2e22b2 Bluetooth: Audio: Add CONFIG_BT_AUDIO_DEBUG_STREAM_DATA
Add the CONFIG_BT_AUDIO_DEBUG_STREAM_DATA Kconfig option
to better debug bt_audio_stream without drowning the log
in the data being sent.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:00:33 +00:00
Emil Gydesen
1add19c834 Bluetooth: ISO: Add BT_DEBUG_ISO_DATA Kconfig
Add the BT_DEBUG_ISO_DATA so that ISO can easier be debugged
without the logs being drowned in the ISO data being sent
and received (which is typically at a low interval like 10ms).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-08 20:00:33 +00:00
Tom Burdick
572ccd531d intel_adsp: Use device tree to enable/disable each HDA driver
Uses the dt_compat_enabled Kconfig preprocessor to set defaults
for each HDA driver.

Each direction is uniquely selectable which can be useful when building
with SOF where only some directions may wish to be enabled at any given
time.

By default, given the device tree (intel_cavs.dtsi) only the host
directions are enabled but an overlay may adjust that as needed.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-07-08 14:33:06 -04:00
Kumar Gala
c3d65b7f6b emul: espi: Remove unused struct element
espi_label struct element wasn't used anywhere so remove it.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-08 10:53:02 +02:00
Asbjørn Sæbø
15e025fd20 Bluetooth: Audio: Use common function for discovery complete
Use the same function at discovery complete, whether discovery failed
or succeeded.
Rename the discovery_failure() to discovery_complete(), and use that
also when discovery completes successfully.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-07-08 09:36:18 +02:00
Asbjørn Sæbø
0142bf9484 Bluetooth: Audio: MCC - serialized subscription after discovery
The media control client used to subscribe to GMCS characteristics as
the characteristics were discovered, in effect queuing ATT requests.

Since then, the ATT MTU exchange has become automatic, leading to
larger ATT MTUs and more discovered characteristics per ATT response,
which again lead to the client enqueuing more subscriptions and
running out of buffers, with discovery failing as a result.

This commit moves the subscription to GMCS characteristics to a
separate sequence, so that it happens serially after discovery, rather
than in parallel with the discovery.

- Remove separate discovery parameters for the characteristics - they
  are no longer needed.
- Add a subscription callback and a couple of subscription functions

The subscription for characteristics for the included OTS has not been
modified.  Only two of these are subscribed to, and doing that is
currently not a problem.  And I need to better understand the
interaction with OTS and how these subscriptipons are used.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>

Refactor subscription to get chaining into callback
2022-07-08 09:36:18 +02:00
Asbjørn Sæbø
d4b612c615 Bluetooth: Audio: MCC - warn on subscription failure
Add warning if subscription to characteristics fails.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-07-08 09:36:18 +02:00
Asbjørn Sæbø
6c2b8e6e65 Bluetooth: Audio: MCC - refactor subscription
Move subscription to characteristics to separate function.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-07-08 09:36:18 +02:00
Asbjørn Sæbø
542e99b859 Bluetooth: Audio: Media - refactor include discovery start
Move the start of discovery of included services to a separate
function, in preparation for rewriting discovery.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-07-08 09:36:18 +02:00
Erik Brockhoff
daf327de40 bluetooth: controller: Fixing feature API re. non standard bool typedef
When bool is typedef'ed to for instance char the cast from 64 bits
is not so good. Now using an explicit 'cast' to true/false

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-07-08 09:36:00 +02:00
Erik Brockhoff
3fbfb6537e bluetooth: controller: Implements Peripheral CIS Create Procedure
Implements PDU flow and unittest of CIS Create on Peripheral
Hooks CIS Create into the controller and fixes a few minor
things in ull to allow for running with NEW LLCP
Also handles CONFIG based comilation of CIS Create

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-07-08 09:36:00 +02:00
Erik Brockhoff
6cf357bd9d bluetooth: controller: Integrate CIS Terminate with controller
Hooks the CIS terminate into the controller and fixes a few minor
things in ull_conn(_iso).c
Also handles CONFIG based comilation of CIS_TERMINATE
also fixes a minor issue in helpers_pdu

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-07-08 09:36:00 +02:00
Erik Brockhoff
22ddc01f36 bluetooth: controller: CIS Terminate Procedure PDU flow and unittest
Implementing PDU flow and unittest for PDU flow of CIS Terminate.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-07-08 09:36:00 +02:00
Andrei Emeltchenko
5b633db288 ztest: Add Z_TEST_SKIP_IFNDEF macro
Add macro Z_TEST_SKIP_IFNDEF which is used when you want to skip test
if configuration option is not enabled.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-07-07 15:07:02 -04:00
Adrian Bonislawski
b3beafcbac logging: cavs_hda: Allow format timestamp
LOG_BACKEND_CAVS_HDA supports LOG_BACKEND_FORMAT_TIMESTAMP

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-07-07 17:58:56 +00:00
Yuval Peress
10feb693f5 unittest: support ztest_new_api
Add support for the new Ztest API when using unittest.

Fixes #47420

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-07 18:22:14 +02:00
YanBiao Hao
93df0e6d86 Bluetooth: Mesh: Removing the duplicated entry
Removing the duplicated entry net_transmit_status

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2022-07-07 15:50:02 +00:00
YanBiao Hao
076843fae5 Bluetooth: Mesh: async cfg client api
support node reset status, TTL status, friend status,
network transmit status, GATT proxy status, beacon status

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2022-07-07 15:50:02 +00:00
Pavel Vasilyev
4808f6f82a Bluetooth: Mesh: Don't open prov link after being provisioned
It is possible to open provisioning link again after being provisioned.
Though this has no immediate consequences, the node shall not open
provisioning after being provisioned.

Reset link.cb so that any following provisioning advs are dropped.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-07-07 15:47:59 +00:00
Pavel Vasilyev
0f27ecd29b Bluetooth: Mesh: Fix mesh shell compilation without provisionee support
cmd_pb_adv and cmd_pb_gatt are only used when provisionee role is
supported. They should not be compiled if provisionee role is disabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-07-07 10:01:09 +02:00
Thomas Ebert Hansen
154d67d90b Bluetooth: controller: llcp: Fix data pause/resume
llcp_tx_pause_data() calls ull_tx_q_pause_data() for each pause_mask,
while llcp_tx_resume_data() only calls ull_tx_q_resume_data() when
conn->llcp.tx_q_pause_data_mask == 0 leading to an unbalanced number of
calls to ull_tx_q_pause_data()/ull_tx_q_resume_data() which can leave
the data path of the TX Q paused.

Fix such that only the first call to llcp_tx_pause_data() will pause the
data path of the TX Q.

Add unit test to verify correct pause/resume behavior.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-07-07 10:00:44 +02:00
Pieter De Gendt
aba4c4ea3e uart_pipe: move driver from console to serial
The uart_pipe driver is not dependent on any console driver,
however a serial driver is required.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-07-07 09:59:49 +02:00
Emil Gydesen
5a79445feb Bluetooth: ISO: Add connecting->disconnecting state transition
Add the state transition from connecting to disconnecting
as a valid transition for ISO. This can occur if a ISO channel
is disconnected before it is fully connected, of if a BIG
or a BIG sync is terminated before established.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-07 09:59:17 +02:00
Emil Gydesen
05ace181d7 Bluetooth: Audio: Add enabling state to broadcast source
There is a brief period between the bt_iso_big_create
and when the ISO channels are established. In this state
it should be possible to call bt_audio_broadcast_source_stop
to stop the BIG from being created.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-07 09:59:17 +02:00
Emil Gydesen
590ab0567c Bluetooth: Audio: Fix state check in bass
Fix bad state check in biginfo_recv in bass.c which
would cause null-pointer access.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-07 09:59:17 +02:00
Aaron Massey
83253023cf ztest: Track skipping test versus entire suite
The addition of the assumption API introduced a bug where a skipped test
would subsequently skip later tests within the same suite. A skipped test
was being treated as an entire skipped test suite.

Keep track of tests being skipped due to skipping in the suite setup versus
being skipped within their test function.

TEST=west build -p -b native_posix tests/kernel/condvar/condvar_api/ -t run
TEST=twister -T tests/ztest -p native_posix

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-07-06 18:50:35 -04:00
Damian Krolik
fc9f59ce0f shell: fix synchronization in log immediate mode
When LOG_MODE_IMMEDIATE is used, logs processed by the shell
log backend may be intertwined with messages printed by
shell commands running on the shell thread.

It is because the shell uses a mutex while the shell log
backend uses the IRQ lock for synchronization. Switch the
latter to use the mutex as well whenever it's possible.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-07-06 17:59:32 +00:00
Anas Nashif
718750f962 fs/testsuite: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Anas Nashif
077c979f6c debug: coredump: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Anas Nashif
2d4759ec17 Bluetooth: controller: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Anas Nashif
0aefa654da net: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Erik Brockhoff
1ff458ec87 Bluetooth: controller: llcp: fixing tx buffer queue handling
Misc. fixups to get the tx buffer alloc mechanism to work as intended

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-07-06 13:08:09 +02:00
Juha Heiskanen
d4bf2ad6cc net: lwm2m: Fix socket offload and native TLS conflict
Removed auto select from LWM2M_DTLS_SUPPORT
* TLS_CREDENTIALS
* NET_SOCKETS_SOCKOPT_TLS
* NET_SOCKETS_ENABLE_DTLS

LwM2M stack shouldn't enforce these options as they
are not needed with socket offloading.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-07-06 11:28:19 +02:00
Kumar Gala
a204d16bfb ec_host_cmd: Convert to DEVICE_DT_GET
We are working on phasing out use of the devicetree 'label'
property.  We can use DEVICE_DT_GET and drop use of DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-06 11:12:32 +02:00
Emil Gydesen
504feb77c4 Bluetooth: Audio: Updated samples and shell to use seq_num
Update the samples and the shell to use the sequence number
and timestamp when sending.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 11:03:27 +02:00
Emil Gydesen
aabe7f4835 Bluetooth: Audio: Add seq_num and ts to bt_audio_stream_send
Added sequence number and timestamp to the bt_audio_stream_send
function. This allows an application to better
control the audio transmission, as it can schedule
one or more audio streams to send a buffer in a specific
SDU interval (ensuring that e.g. left and right is sent in
the same SDU interval).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 11:03:27 +02:00
Aleksandar Radovanovic
69690e3505 ipc_service: static_vrings: Fix TX virtqueue alignment
This patch fixes an issues where the TX virtqueue is misaligned by
2 bytes due to the way the virtqueue start address is calculated.
It is currently set to immediatelly follow the RX virtqueue:

    vr->tx_addr = vr->rx_addr + vring_size(num_desc, VRING_ALIGNMENT);

but the RX virtqueue does not end on an aligned boundary (last field,
avail_event is uint16_t). The resulting misaligned virtqueue causes
alignment faults on architectures that do not support unaligned
accesses (and is suboptimal otherwise)

The fix is to realign tx_addr to requested VRING_ALIGNMENT.

Signed-off-by: Aleksandar Radovanovic <aleksandar.radovanovic@amd.com>
2022-07-06 11:03:04 +02:00
Emil Gydesen
2fd3fcedcd Bluetooth: Audio: Remove CSIS minimum set size requirement
The requirement was removed by
https://www.bluetooth.org/errata/errata_view.cfm?errata_id=17007
and the implementation has been updated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:58:08 +02:00
Fredrik Danebjer
2283aad798 Bluetooth: Audio: Removed Streaming Context from LC3 PAC Record
This fix removes the Streaming_Audio_Context LTV from the LC3 Codec
helper macro, and subsequently a faulty exposure of this LTV in the
PAC records used.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-07-06 10:46:22 +02:00
Emil Gydesen
8e08d79676 Bluetooth: Audio: Rename MICP mic_dev disable to mute disable
Made it more clear that the disable functionality is to
disable the mute functionality, but and not disabling
the microphone device itself.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
28f6e37ba8 Bluetooth: Audio: Rename struct bt_micp and cleanup
Rename struct bt_micp to bt_mic_ctlr as it is only
used ofr microphone controller now.

This also allow cleanup of the bt_micp struct, thus
removing the common internal micp_internal.h header file
and reducing the size of the implementation by not
using a union of the structs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
c8a6a51566 Bluetooth: Audio: Remove bt_micp argument for MICP mic_dev API
Since there is a split API now, the mic_dev does not need
to take a bt_micp pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
e95b640df6 Bluetooth: Audio: Specify MICP Mic Dev API
Modify the existing bt_micp API for the
MICP Microphone Device to be more specific
by adding mic_dev as an infix. This follows
the naming scheme used for the MICP microphone
controller (mic_ctlr).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
3cf59fae72 Bluetooth: Audio: Add separate API for MICP mic ctlr
Add a bt_micp_mic_ctlr API that is used only
for the MICP Microphone Controller (Client).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
ff509027c1 Bluetooth: Audio: Rename bt_micp_aics functions
The AICS functionality is also possible via the bt_aics
API, and this was just a way to ensure that the AICS
instance was part of a MICS.

Removing makes MICP much simpler, and we can expect user
to know the context of a AICS.

This also fixes a few bad/missing guards.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
1245da298e Bluetooth: Audio: Rename remaning MICS files to MICP roles
Rename mics => micp_mic_dev (MICP Microphone Device)
Rename mics_client -> micp_mic_ctlr (MICP Microphone Controller)

This does not change any lines in the code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
9eb5d0795f Bluetooth: Audio: Rename MICS to MICP
Use the profile abbreviation, MICP, instead of the
service abbreviation, MICS, for the MICP implementation.

The server implementation will use MICP and the client
implementation will use MICP_CLIENT for now, as that will
be updated in a future commit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Emil Gydesen
67e570ea7e Bluetooth: Audio: Rename mics.h the Kconfig to micp
Rename the files to match the name of the profile (MICP)
instead of the service (MICS).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-06 10:41:52 +02:00
Gerard Marull-Paretas
32b9934b0f pm: remove PM_DEVICE_ACTION_FORCE_SUSPEND
PM_DEVICE_ACTION_FORCE_SUSPEND has been equivalent to
PM_DEVICE_ACTION_SUSPEND for a while. Release notes for Zephyr 2.7
mentioned its removal (see 76702e8ff3) but
for some reason it was kept.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-07-06 10:30:14 +02:00
Andreas Chmielewski
363e2f3014 net: coap: make coap vars configurable
COAP_DEFAULT_MAX_RETRANSMIT and COAP_DEFAULT_ACK_RANDOM_FACTOR
should be configurable to determine the max transmission
timeout of a CoAP packet.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-07-05 21:56:34 +00:00
Enjia Mai
5a57e0264e samples: subsys: tracing: No tracing during switch in/out using EFI console
Due to the limitation of the current x86 EFI cosnole implementation,
we skip hte printk which is called by tracing API:
sys_trace_thread_switched_in_user/out_user.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-05 16:52:32 -04:00
Enjia Mai
d1f2aa5516 logging: add a logging backend of EFI console
Add a EFI console logging backend to support logging sub-system.
To fix those testcases have no log output due to no logging backend.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-05 16:52:32 -04:00
Fredrik Danebjer
961bc352f3 Bluetooth: Audio: Fix bad buffer pointer in get_pac_records
This change fixes a buffer use from pointer-by-value to correctly
intended pointer.

Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
2022-07-05 19:59:40 +02:00
Aurelien Jarno
77ef1b715a usb: cdc_acm: implement uart_config_get() API
Implement the uart_config_get() API by converting the existing
line coding structure to the struct uart_config format.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2022-07-05 18:00:24 +02:00
Eduardo Montoya
848fd44518 net: openthread: enable default software tx security in 1.3
Make sure MAC software transmission security is enabled by default
for Thread 1.3 builds as well.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-07-05 15:40:14 +00:00
Emil Gydesen
6cd35242df Bluetooth: Audio: Stop calling broadcast sink syncable when synced
The syncable callback was called whenever we received the BIGInfo
The BIGInfo is, however, received even while synced (as per the
HCI spec). Add a check to stop calling syncable when synced,
and keep the sink->big value updated based on the ISO states.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-05 15:34:24 +00:00
Juha Heiskanen
ad5492721a net: lwm2m: Fixed crash at LwM2M registration timeout
LwM2M context close moved to thread safe place when RD client
run state machine.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-07-05 14:19:24 +02:00
Ola Tangen Kulseng
9be4fd0bbb net: lwm2m: Refactor of engine, message handling
Created the file lwm2m_message_handling.c, to include all
code pertaining to CoAP and allocation and deletion of messages
in general.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-07-05 13:50:26 +02:00
Ola Tangen Kulseng
365efa0f6a net: lwm2m: Refactoring of engine, observation
Created the file lwm2m_observation.c, to include
all code maintaining observations and parameter handling.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-07-05 13:50:26 +02:00
Ola Tangen Kulseng
02fed0b22e net: lwm2m: Refactoring of lwm2m_engine.c
Created the file lwm2m_registry.c to include the
getters and setters of values and the creation
and deletion of all lwm2m objects, resources
and instances. Refactored the registry part
of lwm2m_engine.h into lwm2m_registry.h.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-07-05 13:50:26 +02:00
Mariusz Skamra
8c72fe1586 Revert "Bluetooth: Host: Check encryption level for EATT channels"
This reverts commit f3444ce00b.
The check is not needed anymore, as the EATT channels are available on
encrypted link only.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-05 12:19:07 +02:00
Mariusz Skamra
a36d64b8d8 Bluetooth: att: Fix EATT channel security requirements
Core Vol 3, Part G, Section 5.3.2 Channel Requirements states that
"The channel shall be encrypted". It does not mention any additional
security requirements that can be specified bt higher layer profiles.
This enables link encryption requirement for EATT channel.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-05 12:19:07 +02:00
Yuval Peress
e9e030f56b ztest: Add zassume* API
Add an assume API which works like JUnit's. Assumptions can be made
at any point before your test returns (setup, before, and during the
test). If an assumption fails, the test will be marked as skipped.

This helps avoid a cascading affect of failed tests when a base
feature breaks. The feature is expected to have tests and the tests
which depend on it should be skipped (not failed) if that feature
is broken.

Issue #42472

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-04 14:16:34 -04:00
Yuval Peress
16b9fdf6a0 ztest: run clang-format for easier diffs
Run clang-format on ztest-new.c to make diffs a bit easier

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-04 14:16:34 -04:00
Yuval Peress
54adba4633 ztest: use an enum for the test result
Update `test_result` to use an enum for better code clarity

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-04 14:16:34 -04:00
Yuval Peress
e26ea1b936 ztest: run clang-format on ztest_assert.h
Simple pass to make the diff easier to read for additional changes.

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-04 14:16:34 -04:00
Emil Gydesen
98ba5ae7d4 Bluetooth: Audio: Fix CSIS SIRK read permissions
The CSIS SIRK should only require encryption,
as mandated by the CSIS spec, and authentication.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 16:44:01 +02:00
Emil Gydesen
4afa484fc3 Bluetooth: Audio: Fix PACS UUID issue
We attempted to simply store the UUID in a local variable
before sending it to bt_gatt_notify_uuid, but evidently
the `bt_uuid` struct does not work that way, and it
ended up giving errors.

Fixed by providing the BT_UUID_PACS_X UUIDs directly as
arguments, instead of storing in a local variable first.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 16:43:47 +02:00
Emil Gydesen
be85f77293 Bluetooth: Audio: Fix PACS warning if not connected
If we change PACS while not connected, notifying the
change, we would warn about notification not being sent
out, however if not connected that is to be expected.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 16:43:47 +02:00
Krzysztof Chruscinski
e4bd0fceef logging: Allow for compilation without log_output
Add option to Kconfig to enable log_output module. It is used
by most of the backends but it is an optional formatter helper
thus it is possible to run logging without it. One example might
be dictionary based logging which does not format log message
to a readable string.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-04 16:43:32 +02:00
Pavel Vasilyev
867b88635d Bluetooth: Mesh: Don't do bulk tx of seg msgs
In the current implementation of segmented messages transmission, the
transport layer will put as many segments as it can into the advertiser
buffer. If a long segmented message is transmitted, there is a chance
that an ack will be received before the transport layer finishes sending
the first batch of segments. This will trigger retransmissions of those
segments that are marked as missing in the ack, that are also the
segments that are scheduled (or about to be scheduled), but not sent
out by the advertiser yet. Thus, the receiver may receive already
received segments.

This commit changes 2 things:
- it prevents rescheduling transmission of missing segments upon
reception of ack. Thus, ack doesn't cause segments duplication in the
advertiser buffer;
- it doesn't put all segments to the advertiser buffer. Thus, ack that
acknowledges all segments can immediately stop rescheduling segments as
they are already received;

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-07-04 14:31:44 +00:00
Aleksander Wasaznik
462f3e2c11 Bluetooth: Host: Refactor tx_notify, simplify locking
The control flow around the irq-lockout used for fetching from
`tx_complete` has been simplified so that there is exactly one
line with irq_unlock that is unconditionally called.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-07-04 16:27:08 +02:00
Aleksander Wasaznik
9339f249dc Bluetooth: Host: Refactor tx_notify, use CONTAINER_OF
The cast from `sys_snode_t` to `struct bt_conn_tx` assumes `node` is the
first field in `struct bt_conn_tx`. It's better to future-proof this by
using `CONTAINER_OF` to locate `node`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-07-04 16:27:08 +02:00
Daniel DeGrasse
fdefd873fc sd: add proper handling for DISK_IOCTL_CTRL_SYNC
Add handling for DISK_IOCTL_CTRL_SYNC to SD subsystem. Note that
SD caching is not enabled by the SD stack, so the only required
operation to sync the disk is to wait for any active data programming
to complete.

Fixes #46689

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-07-04 14:25:33 +00:00
Berend Ozceri
394d5f7656 mgmt: smp: Allow building with POSIX API in UDP transport
If the POSIX API is selected via the POSIX_API option, don't also select
the conflicting NET_SOCKETS_POSIX_NAMES and use the POSIX headers instead.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-07-04 14:22:13 +00:00
Veijo Pesonen
94b81664e4 net: lwm2m: default stack size with SenML CBOR
SenML CBOR data is stored statically in RAM and does not use process
stack.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-07-04 16:20:03 +02:00
Grant Ramsay
e27f48b38a Bluetooth: Host: Fix crash if HCI send fails
bt_dev.sent_cmd is unreferenced and assigned NULL within hci_cmd_done().
Calling net_buf_unref() again causes a null pointer dereference

Signed-off-by: Grant Ramsay <grant.ramsay@hotmail.com>
2022-07-04 16:09:17 +02:00
Emil Gydesen
4c471914b9 Bluetooth: Audio: Remove codec from bt_audio_broadcast_sink_sync
The codec (or rather codec configuration) is now taken from the
previously received BASE. This also means that the BASE (with
the codec configurations) is now also stored statically.

When the application attempts to synk to the broadcaster
the stack will lookup the codec configuration based on the
bis index, as a BASE may have multiple subgroups
with multiple codec configurations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 16:08:52 +02:00
Emil Gydesen
6c74c51c9c Bluetooth: Audio: Change context type for BAP shell
The shell module will now use BT_AUDIO_CONTEXT_TYPE_ANY
instead of BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED as that provides
a more flexible solution.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 15:59:09 +02:00
Emil Gydesen
68593a105b Bluetooth: PACS: Fix support context if SRC/SNK disabled
If CONFIG_BT_PAC_SNK or CONFIG_BT_PAC_SRC was not enabled, the
function would not build due to missing Kconfig
(CONFIG_BT_PACS_SNK_CONTEXT or CONFIG_BT_PACS_SRC_CONTEXT).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 15:59:09 +02:00
Emil Gydesen
3436cc12d6 Bluetooth: Audio: Add guards for calling bt_audio_capabilities
Add guards for calling bt_audio_capabilities when
CONFIG_BT_AUDIO_CAPABILITY=n

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 15:59:09 +02:00
Emil Gydesen
2071c66249 Bluetooth: Audio: Disable HAS when unicast_server is disabled
The HAS depends on the unicast server, and should be
disabled in the `no_unicast_server` as well as depend
on the CONFIG_BT_AUDIO_UNICAST_SERVER config.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 15:59:09 +02:00
Emil Gydesen
3580147263 Bluetooth: Audio: Fix some bad guards in audio shell
Some functions are only used for the unicast server
but was guarded by CONFIG_BT_AUDIO_UNICAST instead of
CONFIG_BT_AUDIO_UNICAST_SERVER.

Some parts of the unicast-server-only code also had
client specific code that would never be called.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 15:59:09 +02:00
Emil Gydesen
bb6c0866d8 Bluetooth: Audio: Add PACS for broadcast sink
Add support for using PACS and/or capabilities for
the broadcast sink role. PACS and capabilities were
originally only supported for the unicast server
role, so the PACS callbacks were moved their own
struct, as if a device supports both the unicast
server role and the broadcast sink role, it will
only have a single PACS instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 15:59:09 +02:00
Emil Gydesen
3d8c3dfaa3 Bluetooth: Audio: Add parent service requirement if CSIS cnt > 1
If the number of CSIS instances on a device is
above 1, then each shall be included by another
service.

This creates a bit of a chicken and egg issue,
as we can't really register the "parant" service
before the CSIS instance has been registered,
and we thus can't verify if the parent service
pointer is actually another primary service on this
device. The best we can do is add the proper
type and a NULL check.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 15:52:58 +02:00
Krzysztof Chruscinski
2153c91877 testsuite: ztress: Add test skipping if system clock is too high
When system clock is set globally for the test which is executed
on various qemu platforms it may happen that clock is set too
high compared to CPU clock frequency. In that case test may stuck.
Added check and test skipping in that case.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-04 15:50:53 +02:00
Krzysztof Chruscinski
e4bfec8100 logging: Use spin lock
Updated log_core to use spin lock instead of irq_lock.
Refactored z_log_msg_post_finalize function.

Update thresholds in the log_stack test.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-04 15:50:53 +02:00
Dominik Ermel
6238bf4185 fs: Use fs_mount_t.node to check if system is mounted
The commit changes fs_mount and fs_unmount to use node fs_mount_t
member to decide whether file system described by given fs_mount_t
object has already been mounted.
Previously there was no such check in case of fs_mount, which
would allow to remount the same object as long as mount path
has been changed.
The fs_unmount has been checking whether API pointer (fs) has been
filled now it checks whether fs_mount_t is linked anywhere,
which is sign that the object is used.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-07-04 15:47:56 +02:00
Kumar Gala
c880dc908f usb: device: Update to use gpio_dt_spec
Move to use gpio_dt_spec for GPIO access.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-04 15:34:13 +02:00
Øyvind Rønningstad
c1a9866c86 west.yml: Update zcbor to v. 0.5.1
lwm2m: Regenerate lwm2m_senml code from the CDDL description.
Reapply manual changes.
Create a sh script to perform the regeneration.

tests: zcbor_bulk: Adapt to zcbor 0.5.1
zcbor_new_decode_state() now has no return value.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-07-04 15:13:42 +02:00
Emil Gydesen
2ab42db41f Bluetooth: Audio: Fix broadcast sink LTV decode length issue
The broadcast sink did not properly decode the LTV data
from the BASE.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-07-04 12:42:39 +02:00
Jordan Yates
a593a733e8 storage: flash_map: handle disabled flash nodes
Don't fail to compile when `fixed-partition`'s exist on a flash device
that is disabled. This does not fix the case where a `fixed-partition`
is on a flash device with `status = "okay"` but with no driver compiled
in.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-04 10:28:41 +02:00
Jordan Yates
75680f7ae0 treewide: update flash_area name retrieval
Update usage of `flash_area->fa_dev_name` to `flash_area->fa_dev->name`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-02 16:04:16 +02:00
Jordan Yates
4543f82c12 storage: flash_map: remove device_get_binding
Remove all usage of `device_get_binding` in the subsys by directly
storing the `const struct device*` in the `struct flash_area`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-02 16:04:16 +02:00
Jordan Yates
f12d36a51e lorawan: move REQUIRES_FULL_LIBC dependency
Move the `REQUIRES_FULL_LIBC` dependency from `config LORA` to
`config LORAWAN`. The commit that added the `select` (f590d4fa) mentions
that this is required by `loramac-node`, which is only used by LoRaWAN,
not the base LoRa code.

This results in small FLASH savings when compiling the samples, but can
result in larger savings in more complex applications:
```
// With REQUIRES_FULL_LIBC
west build -b 96b_wistrio zephyr/samples/drivers/lora/send/
[162/162] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       37708 B       128 KB     28.77%
            SRAM:        8832 B        32 KB     26.95%
        IDT_LIST:          0 GB         2 KB      0.00%

// Without REQUIRES_FULL_LIBC
[181/181] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       37444 B       128 KB     28.57%
            SRAM:        8832 B        32 KB     26.95%
        IDT_LIST:          0 GB         2 KB      0.00%
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-02 14:16:18 +02:00
Krzysztof Chruscinski
3bcd14f420 logging: Reduce code size for frontend only case
Add early returns from functions which are not used when
there is only one frontend in the system (no backends). This
allows to significantly reduce logging code size in that
configuration.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-02 14:13:54 +02:00
Kumar Gala
560ccb1f5c bluetooth: controller: openisa/RV32M1: Convert to DEVICE_DT_GET
Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-02 14:08:04 +02:00
Kumar Gala
ded6f43b0d Bluetooth: controller: nRF5: Convert to DEVICE_DT_GET
Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-02 14:07:54 +02:00
Andrei Emeltchenko
5fa0a979ca logging: Remove dead code
Remove unused variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-07-01 21:36:01 +02:00
Kumar Gala
62430ab1ce emul: i2c: atmel_at24: Remove unused variable
i2c_label is not used anywhere so we can remove it.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-01 16:38:23 +00:00
Corey Wharton
4a87ae07bf netusb: allocate packets from RX pool for incoming frames
Allocate packets and buffers from the RX slab/pool when handling
incoming frames.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2022-07-01 16:26:13 +00:00
Ryan Erickson
fb34a9749f logging: add log_source_id_get
Add API to get the logging module source ID from the
module name;

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-07-01 16:30:30 +02:00
Vinayak Kariappa Chettimada
9f3d29157d Bluetooth: Controller: Fix radio_tmr_start_now for incorrect start time
Fix radio_tmr_start_now from returning delayed start time
under race conditions where the capture time has elapsed but
the compare has triggered at the same time.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-07-01 16:05:30 +02:00
Flavio Ceolin
9e0629176d logging: adsp: Allow format timestamp
LOG_BACKEND_ADSP supports LOG_BACKEND_FORMAT_TIMESTAMP.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-07-01 11:37:32 +02:00
Mariusz Skamra
cd3c6d0258 Bluetooth: has: Handle reconnection to previously bonded device
This adds sending Active Index notification and Preset Changed
notifications on connection to previously bonded client.

Fixes: HAS/SR/CP/BV-03-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-01 11:37:02 +02:00
Mariusz Skamra
95255db964 Bluetooth: has: Fix missing supported feature flag
The implementtaion supports dynamic presets i.e. changing it's name,
registration and unregistration of the presets, thus Dynamic Presets
feature flag shall be set.

Fixes: HAS/SR/FEAT/BV-05-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-01 11:37:02 +02:00
Mariusz Skamra
cf30ac2bfc Bluetooth: has: Add support for Write Preset Name operation
This handles Write Preset Name operation that is used to change the
preset name. This covers as well changing the preset name by server.

Fixes: HAS/SR/CP/BV-04-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-01 11:37:02 +02:00
Mariusz Skamra
8537e28f66 Bluetooth: has: Fix missing preset lookup call
Fixes null-pointer dereference.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-01 11:37:02 +02:00
Mariusz Skamra
2d88e3934f Bluetooth: has: Fix sending invalid opcode error
If preset synchronization is not supported, Preset Sync
Not Supported (0x82) shall be sent in error response.

Fixes: HAS/SR/SPE/BI-04-C, HAS/SR/SPE/BI-05-C, HAS/SR/SPE/BI-06-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-07-01 11:37:02 +02:00
Andrei Emeltchenko
8dda6b8c37 net: coap: Remove unneeded statement
Assignment is not needed.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-30 10:34:40 +02:00
Keith Packard
34473f6821 subsys/testsuite: Don't add empty z_malloc_partition to mem domain
The malloc partition may actually be empty, if so, don't try to add it to
the domain as that will generate an error.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-30 10:33:24 +02:00
Kumar Gala
e1e8179690 modbus: serial: Convert to DEVICE_DT_GET
Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-30 10:32:42 +02:00
Jonathan Rico
3c5bf5089a Bluetooth: host: add dedicated WQ for long-running tasks
Send long-running tasks to a dedicated low-priority workqueue.

This shouldn't increase memory usage since by doing this, we get rid of the
ECC processing thread.

This should fix issues like #43811, since the system workqueue runs at a
cooperative priority, and the new dedicated one runs at a pre-emptible
priority.

Fixes #43811

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-06-30 10:31:13 +02:00
Adrian Bonislawski
65a242552b logging: use std_get_flags in cAVS HDA backend
This will use std_get_flags in cAVS HDA backend
and remove unnecessary duplication

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-06-29 14:42:23 +00:00
Adrian Bonislawski
83100c72cf logging: support dictionary based logging in cAVS HDA backend
This adds a dictionary based logging support in cAVS HDA backend

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-06-29 14:42:23 +00:00
Yuval Peress
a7ceba3710 testing: add zephyr/ prefix to testing include path
Continuation of issue #41543 to add prefix scope for Zephyr's include
files.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-29 06:04:32 -04:00
Andrzej Głąbek
d06d1397c3 bluetooth: ll_sw: nrf5: Apply workaround for anomalies only when needed
Workaround for nRF52 anomalies 102, 106, and 107 was applied also for
SoCs that were not affected with those, namely nRF52811 and nRF52840.
Since the side effect of this workaround is reduction of sensitivity,
this was highly undesirable.
This commit uses dedicated functions provided by MDK for checking if
a given anomaly applies to the used SoC (and its actual revision) so
that the workaround is applied only when it is really needed.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-06-29 11:57:45 +02:00
Pavel Vasilyev
df31962793 Bluetooth: Mesh: Increase BT RX thread stack size for mesh
New logging system (v2) requires more stack size in deferred mode.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-06-29 10:30:45 +02:00
Veijo Pesonen
9bf570eaba net: lwm2m: Fixes SenML CBOR composite read
Path list was replaced accidentally with free list during refactoring.
This change does fix the issue.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-29 10:29:27 +02:00
Keith Packard
866f1cb9b0 lib/cbprintf: Disable tagged arguments with picolibc
Picolibc doesn't have the non-standard printf support required for tagged
arguments in cbprintf. Disable this and use the format string parsing code
instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-29 10:29:13 +02:00
Sjors Hettinga
3bcd8d1ee1 net: socket: Use exponential backoff in case of polling errors
Some errors can occur in the sending process that have to be handled
in a polling fasion instead of blocking using semaphores. In this case
apply an exponentially growing backoff time. This will allow for fast
reactions in most situations and prevents high system loads in case
resolving the situation takes a little longer.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-29 10:28:11 +02:00
YanBiao Hao
5f5c97a905 Bluetooth: Mesh: model sub status async callback
model sub status async callback

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2022-06-29 10:26:00 +02:00
Andries Kruithof
9eaf102e1b Bluetooth: controller: llcp: fix typo
Fixed a typo: the correct term is 'link layer', not
'linked layer'

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-06-29 10:25:37 +02:00
Andries Kruithof
1d1a2f8b57 Bluetooth: controller: llcp: avoid regression errors
The change in this commit is required to avoid regression errors
on EBQ test for the PHY update procedure
When in the peripheral role transmission of data must be resumed
while waiting for the PHY IND response from peer.
In other words: in the LP_PU_STATE_WAIT_TX_ACK_PHY_REQ state
data transmission must resume when acting as peripheral,
but not when in the central role

Following tests are effected
LL/CON/PER/BV-49-C
LL/CON/PER/BV-50-C
LL/CON/PER/BV-52-C
LL/CON/PER/BV-53-C
LL/CON/PER/BV-54-C
LL/CON/PER/BV-55-C
LL/CON/PER/BV-56-C
LL/CON/PER/BV-58-C

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-06-29 10:25:37 +02:00
Andries Kruithof
aa80f7da5f Bluetooth: controller: llcp: fix PHY procedure for conformance test
This PR fixes the PHY update procedures for conformance tests when
being a Central
The problem was that data was in the LLL tx queue and was still being
queued before the PHY IND was queued (with a given instant).
As a result by the time the PHY IND was transmitted over the air the
instant was in the past.
The fix is to ensure that the LLL tx queue is empty, and to stop
queueing new data  before queueing the PHY IND

Following tests are fixed:
LL/CON/CEN/BV-49-C
LL/CON/CEN/BV-50-C
LL/CON/CEN/BV-53-C
LL/CON/CEN/BV-54-C

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-06-29 10:25:37 +02:00
Emil Gydesen
c5fc32756a Bluetooth: Audio: Remove hardcoded location and context for LC3 macros
The BT_CODEC_LC3_CONFIG_* macros had a hardcoded location
and context, which makes them a lot less usable.

Updates the macro, and the macros that used them.
This also removes the BT_CODEC_LC3_CONFIG and instead
just uses the BT_CODEC_LC3_CONFIG_N macro, which has
then been renamed to BT_CODEC_LC3_CONFIG.

As an addition, the macros and their input has
also been better documented.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-29 10:24:49 +02:00
Daniel DeGrasse
fcc25dcf0c log: swo: enable pin control support for swo log backend
Enable pin control support for SWO log backend, by creating a new
ITM node for the ARM instrumentation trace macrocell. Add pin control
properties under this node, and refactor the swo-req-freq property to be
defined within this node.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-06-28 16:02:09 -05:00
Tom Burdick
121462b129 rtio: Low (Memory) Cost Concurrent scheduler
Schedules I/O chains in the same order as they arrive providing a fixed
amount of concurrency. The low memory cost comes at the cost of some
computational cost that is likely to be acceptable with small amounts
of concurrency.

The code cost is about 4x higher than the simple linear executor
which isn't entirely unexpected as the logic requirements are quite a bit
more than doing the next thing in the queue.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-06-28 13:53:13 -04:00
Tom Burdick
3d2ead38cb rtio: Real-Time Input/Output Stream
A DMA friendly Stream API for zephyr. Based on ideas from io_uring
and iio, a queue based API for I/O operations.

Provides a pair of fixed length ringbuffer backed queues for submitting
I/O requests and recieving I/O completions. The requests may be chained
together to ensure the next operation does not start until the current
one is complete.

Requests target an abstract rtio_iodev which is expected to wrap all
the hardware particulars of how to perform the operation. For example
with a SPI bus device, a description of what a read, and write mean
can be decided by the iodev wrapping a particular device
hanging off of a SPI controller.

The queue pair are submitted to an executor which may be a simple
inplace looping executor done in the callers execution context
(thread/stack) but other executors are expected. A threadpool executor
might for example allow for concurrent request chains to execute in
parallel. A DMA executor, in conjunction with DMA aware iodevs
would allow for hardware offloading of operations going so far as to
schedule with priority using hardware arbitration.

Both the iodev and executor are definable by a particular
SoC, meaning they can work in conjuction to perform IO operations
using a particular DMA controller or methodology if desired.

The application decides entirely how large the queues are, where
the buffers to read/write come from (some executors
may have particular demands!), and which executor to submit
requests to.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-06-28 13:53:13 -04:00
Eugene Cohen
2656113190 tracing: add additional user tracing thread calls
Add additional user tracing calls for thread states, names
and priorities.

add the following user tracing calls:

sys_trace_thread_create_user
sys_trace_thread_abort_user
sys_trace_thread_suspend_user
sys_trace_thread_resume_user
sys_trace_thread_name_set_user
sys_trace_thread_info_user
sys_trace_thread_priority_set_user
sys_trace_thread_sched_ready_user
sys_trace_thread_pend_user

Signed-off-by: Eugene Cohen <quic_egmc@quicinc.com>
2022-06-28 13:52:21 -04:00
Julien D'Ascenzio
fdf5dc384d usb: cdc_acm: fix bug on transmission
In the function tx_work_handler, a pointer to ring buffer data is given
to usb_transfer then the ring_buf_get_finish is called. So, the data is
mark as read (by ring_buf_get_finish) while the data are not yet
transferred to usb. If later a user send data, the pointer hold by usb
stack could be rewrite.

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
2022-06-28 16:58:51 +02:00
Anas Nashif
c56ceacc9f tracing: fix duplicate systemview id
Fix duplicate ID for systemview. Remove k_timer_user_data_set as it is
not being tracing and uses a duplicate ID like k_sem_reset.

Fixes #46541

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-28 14:51:40 +02:00
Thomas Ebert Hansen
d9774bd925 Bluetooth: controller: llcp: fix issue re. version exchange
Complete the remote initiated version exchange if a LL_VERSION_IND is
received while already having responded in an earlier version exchange
procedure.

Clarify comment regarding how to handle this invalid behaviour.

This has been seen when running the LL/CON/CEN/BI-12-C test on EBQ.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-06-28 11:07:43 +02:00
Andries Kruithof
19bf928ffb Bluetooth: controller: llcp: fix DLE related EBQ tests
Calculation of the DLE related parameters (rx/tx octets and time) depend
on the actual phy in use. For this reason the PHY settings must be
initialised before doing the DLE parameter calculations

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-06-28 11:07:36 +02:00
Erik Brockhoff
8b1d50b981 Bluetooth: controller: llcp: fix issue re. missing ack of terminate ind
On remote terminate on central the conn clean-up would happen before ack
of terminate ind was sent to peer.
Now clean-up is 'postponed' until subsequent event.
Also now data tx is paused on rx of terminate ind to ensure no data is
tx'ed after rx of terminate ind

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-06-28 11:07:04 +02:00
Erik Brockhoff
8b912f1488 Bluetooth: controller: llcp: fix issue re. missing release of tx node
On disconnect with refactored LLCP, if data tx is paused,
possibly 'waiting' tx nodes would not get released.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-06-28 11:06:41 +02:00
Erik Brockhoff
522e0b5ade Bluetooth: controller: fixing issue re. erroneous DLE changed events
Only apply change to effective DLE times if current max times are too
small to accommodate. Similar to legacy implementation
Update unit tests to new DLE ntf behavior

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-06-28 11:06:15 +02:00
Andrei Emeltchenko
def6041fb0 net: ipip: Remove unused variable
Remove masked with ARG_UNUSED() unused variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-27 08:51:18 -05:00
Ulf Lilleengen
61f4513750 net: improve error message on not supported op
When an operation on the socket is not supported by the implementation,
which is the case for some drivers, set errno to a value that reflects
this situation rather than signalling an error with the file descriptor.

Signed-off-by: Ulf Lilleengen <lulf@redhat.com>
2022-06-27 14:14:53 +02:00
Lukasz Maciejonczyk
80eca5f7b4 net: openthread: align otPlatSettingsSet with new interface contract
The new interface contract guarantees that OpenThread stack uses
otPlatSettingsSet only for aKey which has at most one value at time.
This implies the simplification for key name used by settings subsystem
and decreases the count of records written each time when the value
for specific key is updated. In result non-volatile memory can be used
more efficiently.

It relates to zephyrproject-rtos/openthread commit: ed665e9 .

We still need to make sure that old entries are being removed for the
case with DFU.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2022-06-27 12:47:36 +02:00
Tom Burdick
5e08a3c40a logging: Use dma buffer alignment property for HDA
Use the newly added dma buffer alignment device tree property and macro
helper to set the buffer alignment.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-06-27 12:46:11 +02:00
Noah Klayman
0b16e4dfff subsys/debug/gdbstub: parse input numbers as unsigned
Fixes int too large failures when addressing upper half of address space

Signed-off-by: Noah Klayman <noah.klayman@intel.com>
2022-06-27 12:45:50 +02:00
Emil Gydesen
9bc71bdfb6 Bluetooth: Shell: Fix wrong channel for getting iso broadcast len
The length was taken from `iso_chan` instead of `bis_iso_chan`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-24 20:29:28 +02:00
Aleksandr Khromykh
e552b27117 Bluetooth: Mesh: fix pb gatt fast advertising
pb gatt server starts fast advertising for the first 60 seconds.
After that, server goes into slow mode.
When pb gatt and pb adv work in parallel pd gatt changes fast to
slow modes after the first tx frame in pd adv (about 110ms)
since they both are handled in the same thread.
Actually, pb gatt never worked in fast mode
if pb adv was enabled (in most configuration cases).

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-06-24 20:26:48 +02:00
Lukasz Maciejonczyk
cc9caf4b22 net: openthread: add option for setting Thread v1.3
Make Thread v1.3 configurable.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2022-06-23 15:52:34 -05:00
Andrei Emeltchenko
6bc6b5c405 shell: mqtt: Remove unneeded variable
Remove unneeded variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-23 15:43:59 -05:00
Andrei Emeltchenko
ce76beecc3 net: lwm2m: Remove unused variable
Remove unused variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-23 15:43:59 -05:00
Krzysztof Chruscinski
9833ca61c9 logging: Removing v2 suffix from logging names
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 15:46:37 -04:00
Lauren Murphy
318e6db239 debug: coredump: add xtensa intel adsp, support toolchains
Adds compatibility with Intel ADSP GDB from Zephyr SDK and
from Cadence toolchain to coredump_gdbserver.py.

Adds CAVS 15-25 (APL) register definitions. Implements
handle_register_single_read_packet to serve ADSP GDB
p packets.

Prevents BSA from changing between stack dump printout
and coredump by taking lock. Observed to be necessary for
accurate results on slower simulated platforms.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2022-06-23 15:44:45 -04:00
Rubin Gerritsen
77b8252da6 usb: bt_h4: Set stack sizes using Kconfig
The previously used stack sizes where in many cases too small.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-06-23 14:40:01 +02:00
Emil Gydesen
f6eb15d2d5 Bluetooth: Shell: Fix unused iso_rx_qos variable
The iso_rx_qos is only used for unicast audio, as
we do not set the RX QOS for the broadcast sink, nor
can a broadcast source set RX QOS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 15:30:23 +03:00
Krzysztof Chruscinski
041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Andrei Emeltchenko
87d5a6b1d7 net: gptp_mi: Remove unused variables
Remove unused variables and assignments.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-23 07:18:25 -04:00
Andrei Emeltchenko
f82fb0cb55 net: gptp: Remove unneeded variables
Remove unused variable and assignments.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-23 07:18:25 -04:00
Robert Lubos
ef6770f22b net: tcp: Avoid unnecessary packet cloning on the RX path
So far, TCP cloned a packet with data on an RX path for the application,
leaving the original packet intact. This isn't really needed, as the
original packet is unconditionally freed later anyway, so the TCP can as
well simply queue the original packet for the application, while
informing the network processing core, that the packet was consumed by
the TCP layer.

This allows to improve the download throughput even further, since the
CPU don't waste time on needles packet copying.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-06-23 11:10:34 +02:00
Robert Lubos
5a05ac8fc9 net: tcp: Increase default NET_TCP_TIME_WAIT_DELAY value
The current default of 250ms appears to be too low in case connection
teardown takes place in lossy networks - in case of FIN packet
retransmission, the connection on the Zephyr side could have already
been dismissed due to low TIME_WAIT state delay, resulting in ICMP
Destination Unreachable replies.

Increase the default value to 1500ms - this is still pretty low, but at
least gives the peer some time to retransmit the FIN packet.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-06-23 11:08:36 +02:00
Robert Lubos
2bd00e65ba net: tcp: Acknowledge FIN packets in TIMED_WAIT state
In case TCP stack enters TIMED_WAIT state (after receiving FIN/ACK reply
from peer), it should stil be ready to reply with ACK for any
consecutive FIN attempts. Othewise, in case the final ACK from Zephyr
side is lost, the connection is not properly closed on the other end,
and peer keeps retransmitting the final FIN packet.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-06-23 11:08:36 +02:00
Robert Lubos
28fb1a5f39 net: tcp: Prevent Silly Window Syndrome
Implement a mechanism, according to RFC 813, which allows to prevent so
called "Silly Window Syndrome" - a scenario where the TCP receiver keeps
reporting small window sizes in the acknowledgments, effectively
limiting the connection throughput. This allows to improve performance
in low-buffer configurations, where the maximum window size is small,
and the issue was hitting quite often.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-06-23 11:08:18 +02:00
Robert Lubos
e03e4d5ad1 net: openthread: Fix build with NET_MGMT_EVENT_INFO disabled
In case NET_MGMT_EVENT module was enabled but w/o NET_MGMT_EVENT_INFO,
the OpenThread integration layer failed to build as the "info" field in
the net mgmt callback structure is not available then.

Fix this by conditionally enabling code processing the event only if
NET_MGMT_EVENT_INFO is enabled. Otherwise, print a warning, as the event
is not really useful if no address information is provided.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-06-23 11:07:46 +02:00
Benjamin Gwin
6dcdbe6447 cpp: Include additional contents in <cstddef>
Similar to <cstdint>, this file should provide the contents of stddef.h
for C++ users.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-06-23 09:12:33 +02:00
Robert Lubos
41bbb51412 net: sockets: Fix uninitialized variable use in accept userspace check
Prevent local "addrlen_copy" variable from being used uninitialized in
accept() userspace verification function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-06-23 09:11:29 +02:00
Krzysztof Chruscinski
7f1b4f88e3 logging: Rename files and test from log_msg2 to log_msg
Renaming log_msg2 files to log_msg.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 09:10:33 +02:00
Emil Gydesen
e211bd8931 Bluetooth: Audio: Fix ASCS stream->conn cleanup
The stream->conn was never unref'ed on disconnect with
unbonded devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:09:45 +02:00
Emil Gydesen
17ca15067a Bluetooth: Audio: Fix issue with sending on bidirectional streams
This commit fixes some issues with setting up and
using bidirectional audio streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:09:45 +02:00
Emil Gydesen
884b296a6c Bluetooth: Audio: Fix bad CONTAINER_OF for BAP unicast and broadcast sent
In the sent callbacks we used CONTAINER_OF to get the bt_audio_ep,
but that no longer has the ISO channel, causing these
CONTAINER_OF to return a wrong pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:09:45 +02:00
Chen Peng1
5a23383ad6 tests: interrupt: remove unused macro TRIGGER_IRQ_INT.
On X86 platforms, the interrupt trigger method has been
changed to use APIC IPI, we don't use INT command to trigger
interrupt, so remove this unused macro.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-23 09:08:43 +02:00
Chen Peng1
40fb6fca05 tests: interrupt: add some nop operations in trigger_irq function.
On X86 platforms, the interrupt trigger method has been changed
from using INT command to using APIC IPI, we need to make sure
the IPI interrupt is handled before do our check, so add some
nop operations.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-23 09:08:43 +02:00
Emil Gydesen
b2cbd9f58c Bluetooth: CSIS: Client use const for conn lookup funcs
`bt_conn_index` has been changed to take a `const bt_conn`
which allows our functions that use this to also take a
`const` parameter.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen
7148146348 Bluetooth: CSIS: Implement ordered access procedure for CSIS client
the CSIS client now has a ordered access procedure function.
The function implements the procedure as per the CSIP spec,
where it will verify that 1 or more members are unlocked,
and the execture a procedure on each member in ascending
order of rank.

The procedure can be anything (even a non-BT procedure),
and it will be up to the applicaiton to implement
what to do in that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen
0558b3af95 Bluetooth: CSIS: Stored actives members by rank
Instead of getting doing look ups for each member
for the CSIS client procedures, we store the active
members ordered by rank.

This is slightly less efficient in cases of error,
but for some procedures as the upcoming Ordered
access procedure where we need to access each
member twice, ordering them once is more
efficient.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen
d995901a76 Bluetooth: CSIS: Remove const for members in API
Having the members array being const causes a lot of
limitations in the implementatation, and was
occasionally even disregarded. Removed to make the
implementation more flexible.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Benjamin Gwin
ee22ae79a4 testsuite: Make ztest_error_hook compatible with C++
This lets ztest error hooks be used from C++ based tests.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-06-22 19:30:06 -04:00
Lingao Meng
e6d27c77ef Bluetooth: Host: Fix ATT security vulnerabilities
When the client receives att error rsp, but the error code
is an illegal value, such as 0, an exception will be triggered.

gatt_read_type --> gatt_read_type_rsp --> parse_characteristic

`switch (rsp->len) {` null address access.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-22 12:29:26 +02:00
Andrei Emeltchenko
b970c4daef net: capture: Remove unneeded variable
Remove unused remote_addr_len variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko
3d42168c74 net: ipv4: Remove double assignment
Remove double assignment of cfg variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko
e0e1a12eba net: ipv6: Remove double assignment
Value of nexthdr is already assigned several lines above.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko
c27b72b331 net: ethernet: Remove double assignment
Variable type would be assigned at the block end.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko
77c694178f net: ppp: Fix stored value never read warning
Move declarations to the debug block where they are actually used.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Emil Gydesen
b2c8fa9c53 Bluetooth: Shell: Fix unused variable in iso.c
The `iso_qos` was only used for connected ISO, but
was placed outside of the CONFIG_BT_ISO_UNICAST
guard, such that for broadcast ISO-only it was unused.

Move the declaration and renamed to cis_iso_qos.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-22 12:28:21 +02:00
Vinayak Kariappa Chettimada
048619639d boards: nrf5340dk_nrf5340_cpunet: Disable BT_ECC support
Disable BT_ECC support in network core to reduce RAM usage.
ECC implementation can instead be supported in the Host
running in the application core.

This is also to keep hci_uart (nRF52 Series) and hci_rpmsg
(nRF53 Series) have the same support features. ECC is not
enabled in hci_uart sample.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-22 12:28:05 +02:00
Sjors Hettinga
4243e8e99c net: tcp: Do not capture tx_sem during retransmission
As the stack can safely keep allocating data during retransmission mode
there is no need to take the tx_sem during retransmission any more.

Data stored in the send_data buffer will be transmitted upon the ack of
the data for which an ack is pending. This the application being fully
stalled when the TCP connection enters retransmission mode.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-22 12:25:40 +02:00
Sjors Hettinga
17f94d3f96 net: tcp: Revert: Do not accept new data in retransmission mode
After the window_full function has been fixed by looking at the
send_data_total instead of the unacked_len. There is no risk
in sending data in transmission mode.

This reverts commit 0088aaefa0.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-22 12:25:40 +02:00
Troels Nilsson
eabdf16087 Bluetooth: host: Fix resume failing with extended advertising
Fix advertising failing to resume with BT_ADV_PERSIST set in
bt_hci_le_adv_set_terminated due to BT_ADV_ENABLED not getting
cleared before bt_le_adv_resume gets called

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-06-22 12:25:10 +02:00
Troels Nilsson
0f892ff8c8 Bluetooth: host: Fix missing endianness conversions
Fix missing endianness conversion for props in le_ext_adv_param_set
and bt_le_per_adv_set_param

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-06-22 12:25:10 +02:00
Carlo Caione
1608c8adba pm: Introduce CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE
Sometimes we want to entirely decouple the system PM from the device PM,
leaving the devices to manage its own power states using the runtime PM.

This is currently not possible because the suspend / resume code path is
triggering the device PM hooks even when the runtime PM is enabled.

Introduce a new PM_DEVICE_RUNTIME_EXCLUSIVE symbol to allow the platform
to skip the device PM triggers on suspend / resume.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-22 12:24:43 +02:00
Vinayak Kariappa Chettimada
e994ec1557 Bluetooth: Controller: Fix Tx Buffer allocation for Encryption Request
Encryption request is enqueued in thread context from the Tx
buffer pool, so that it is serialized alongwith the already
enqueued data buffers ensuring they are transmitted out to
peer before encryption is setup. Allocate additional Tx
buffers to accommodate simultaneous encryption setup across
active connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-22 12:22:29 +02:00
Morten Priess
ca8457d882 Bluetooth: controller: Fixes for ISO from IAL testing
- Prevent NULL-pointer dereferencing if datapath is created late
- Support SDU fragment complete-counting for framed case

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Nirosharn Amarasinghe
fc107a0775 Bluetooth: controller: Unified ISO-AL TX SDU fragment count
Implemented incrementing TX SDU fragment count such that it indicates
the number of completed SDU fragments in the PDU being emitted for both
unframed and framed transmission.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-06-22 12:21:16 +02:00
Nirosharn Amarasinghe
af37b444d4 Bluetooth: controller: fix for some problems in ISO-AL RX and HCI
HCI:
-- Discarded data from HCI ISO Data packets from controller to host if
   data has been lost

ISO-AL:
-- Corrected iso_interval in latency calculations
-- Updated handling and release of SDUs for error conditions / padding
   at the last PDU for the SDU
-- Updated prioritisation of error status in released PDUs
-- Included error spooling exit on based on payload number to SDU
   mapping for unframed reassembly
-- Updated sequence number handling for framed recombination

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-06-22 12:21:16 +02:00
Morten Priess
ef28184af2 Bluetooth: controller: Asynch stop of ISO resume ticker in disable
Do not use ull_ticker_stop_with_mark for ISO one-shot resume ticker, but
stop without checking result. If active this will stop it, otherwise it
is ignored. Also, this prevents calling lll_disable twice.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Morten Priess
3d4215d6a3 Bluetooth: controller: LLCP and ISOAL Fixes for EBQ LL tests
- Prioritize CIS_REQ handling in (old) LLCP
- Reject if CIS_REQ uses exisiting CIS ID

These fixes prevent assertions in /LL/CIS/PER/BV-38-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Ola Tangen Kulseng
38628f409e net: lwm2m: Add LwM2M shell commands for start&stop
Added start, stop and update to the shell.
Refactored the event_cb of the rd_client_info struct into the ctx,
as it was needed in the shell script.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-06-22 12:17:52 +02:00
Ola Tangen Kulseng
3e50624e39 net: lwm2m: Added commands to the lwm2m_client shell
Added read, write and execute commands to the shell.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-06-22 12:17:52 +02:00
Dominik Ermel
f9d69c34c9 mgmt/mcumgr/lib: Remove dead code from img_mgmt_upload
The img_mgmt_impl_erase_if_needed was only called when
CONFIG_IMG_ERASE_PROGRESSIVELY is y, and it does nothing anyway;
because the function always returns 0, and does nothing,
neither the function no result processing, from a call to the
function, is needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 13:42:24 +02:00
Dominik Ermel
0a5525358c mgmt/mcumgr/lib: Add BUSY error code
The commit reserves adds MGMT_ERR_EBUSY (10) error code and adds
documentaiton for it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:55:19 +02:00
Dominik Ermel
185630e387 mgmt/mcumgr/lib: Correct comment alignment
Some of comments have not been aligned to tabs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:55:19 +02:00
Dominik Ermel
d261c3b891 mgmt/mcumgr/lib: Remove flash_area_open_ex
The function is no longer needed with fix provided by commit
aa5d20aaef (storage/flash_map: Return -ENODEV from flash_area_open).

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:48:23 +02:00
Dominik Ermel
4aea359f27 mgmt/mcumgr/lib: Remove unused state variables from image management
Image management state, struct img_mgmt_state, has been defining
sector_id and sector_end variables, supposed to be used by
progressive erase feature, that have no use in code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:48:04 +02:00
Dominik Ermel
8b7b81d0f2 mgmt/mcumgr/lib: Fix overriding returned error code
The img_mgmt_upload has been overriding return codes of several
utility function calls with MGMT_ERR_EUNKNOWN, even though
these utility functions would be returning MGMT_ERR_* type codes
already, overshadowing real reason of failure.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:47:43 +02:00
Dominik Ermel
1243bf6d15 mgmt/mcumgr/lib: Change image, size and offset types
The commit changes types of image, size and offset elements of
img_mgmt_upload_req structure from unsigned long long to size_t.

This commit also fixes comments and conditional statements, where
these identifiers have been compared against -1, although they have
been clearly defined as unsigned.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:47:10 +02:00
Aleksandr Khromykh
c0749bef83 Bluetooth: Mesh: fix not initialized uuid in model publication
uuid wasn't initialized in the publication setting command.
It caused wrong the configuration clietn behavior.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-06-21 10:49:01 +02:00
Morten Priess
4e3aeeddde Bluetooth: host: Fix endianness error in L2CAP
Recent code change asserts on ECRED psm being consistent in
l2cap_ecred_conn_req. However, the values are compared between
endianness converted value and non-converted value, which fails on BE
archs.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-21 10:47:48 +02:00
Audun Korneliussen
db78d04a96 Bluetooth: ISO: Add function for reading TX sync
This function retrieves TX sync information
(timestamp, offset, and sequence number)
from controller using HCI command HCI_LE_Read_ISO_TX_Sync.

Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
2022-06-21 10:46:56 +02:00
Martin Jäger
65eede8194 lorawan: add LoRaWAN Class C support
The functions for Class C mode are already provided by LoRaMAC layer.

A device in this mode is listening for incoming downlink messages almost
continuously, which results in higher energy consumption.

Class C mode is required for FUOTA.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-06-20 09:17:33 -04:00
Juha Heiskanen
6d42ded565 net: lwm2m: LwM2M message allocation update
Allocated own message buffer for RD client interface.
This helps to cover if all messages are queued and need to do
registration or update.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 8dca91109d73a4a697e074c58ee9430d56c01a51)
2022-06-20 09:13:41 -04:00
Juha Heiskanen
ad1960625a net: lwm2m: Fix Possible Notification send blocker
If Notification build fail there was possible that Notification
are blocked after failure.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 6dfa242c7d891b3458ab88df46b69b3a9621ee82)
2022-06-20 09:13:41 -04:00
Juha Heiskanen
e4ce689de2 net: lwm2m: Coap Pending clear update
Fixed couple possible place for leak Coap pending entry.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 3c175951383be56fa9c1451845a15b66df41ff64)
2022-06-20 09:13:41 -04:00
Erik Brockhoff
96817164ea Bluetooth: controller: llcp: phy update proc, validate phys and instant
Implementing proper validation of PHY selection for PHY UPDATE procedure
Implement connection termination on PHY UPDATE with instant in the past

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-06-20 14:01:23 +02:00
Vinayak Kariappa Chettimada
7ff8581916 Bluetooth: Controller: Replace k_sem_take loop with k_sem_reset
Replace k_sem_take loop used for consuming the remaining
sem give counts with k_sem_reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-20 10:27:08 +02:00
Vinayak Kariappa Chettimada
ae8e7f4c22 Bluetooth: Controller: Fix pdu_free_sem_give assertion under ZLI use
Fix assertion due to multiple mayfly_enqueue calls used
under ZLI when pdu_free_sem_give is invoked from the LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-20 10:27:08 +02:00
Stephanos Ioannidis
33f87408c4 global: Correct extern K_KERNEL_STACK_ARRAY_DEFINE usage
This commit corrects all `extern K_KERNEL_STACK_ARRAY_DEFINE` macro
usages to use the `K_KERNEL_STACK_ARRAY_DECLARE` macro instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Seppo Takalo
4a8efbb1bc net: lwm2m: Allow longer lifetimes than uint16_t
Lifetimes are really 32 bit values, so the limitation
did not make sense, and it did not allow 24 hour lifetime.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-06-20 10:25:41 +02:00
Rubin Gerritsen
860592698b bluetooth: kconfig: Hide host options if not available
When performing a combined host and controller build, there is no point
in presenting the option to enable a given host feature if the
controller does not support it. This reduces the list of presented
features to enable/disable.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-06-17 10:49:51 -05:00
Azizah Ibrahim
2a175b6abd bluetooth: host: Revert "Avoid sending duplicate device to resolving list."
This reverts commit e11ff7df48.
This patch causes some PTS failure.
Another patch to address duplicate device will follow.

Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
2022-06-17 13:18:25 +02:00
Flavio Ceolin
f232db4630 pm: Avoid unnecessary check in SMP
_current_cpu is a macro that expands to an assert that checks if the
current context can be migrated to a another cpu. Since this
pm_system_suspend() is called from the idle thread (each cpu has its
own) and  with locked this check is redundant. Just use
arch_curr_cpu() to avoid it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-06-16 19:53:20 -04:00
Flavio Ceolin
2cd49ca0fe pm: Fix possible assertion when resuming
pm_system_resume() can be called from the idle thread with
interruptions unmasked. In this situation, _current_cpu will call
z_smp_cpu_mobile() that will return true and cause an assert.

In this function we don't need to check if the current context can be
preempted, we just need the information about which cpu is executing
it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-06-16 19:53:20 -04:00
Yuval Peress
d813e9b39f ztest: Fix incorrect use of this as fixture
Update `this` to `fixture` to avoid C++ keyword error.

Fixes #46459

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-16 16:13:18 -04:00
Yuval Peress
3634456e6b ztest: re-format header
Run clang-format on ztest_test_new.h to clean up some style issues

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-16 12:31:27 -04:00
Yuval Peress
beecf051d9 ztest: cleanup old linker script
A reminant of the old linker script was left in a previous PR.
Remove it.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-16 12:31:27 -04:00
Krzysztof Chruscinski
c5f2cdef09 logging: Remove logging v1 from the logging
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-16 10:51:15 -04:00
Wolfgang Puffitsch
9a4c3f1afa Bluetooth: controller: Tie Configure Data Path to Read Supported Codecs
The Configure Data Path command must be included when the read Local
Supported Codecs [v2] command is supported. The Configure Data Path
command is needed when vendor-specific ISO data paths are supported,
but not otherwise tied to ISO. The respective weak function is
therefore moved to ull.c.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2022-06-16 11:26:03 +02:00
Anders Storrø
b28e024fdb Bluetooth: Mesh: Configurable RPL module
Introduce configuration options for chosen RPL implementations.

This will allow introducing alternate persistent storage schemes
for the replay protection list.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-06-16 10:29:38 +02:00
Szymon Janc
253070b76b Bluetooth: host: Fix L2CAP reconfigure response with invalid CID
When an L2CAP_CREDIT_BASED_RECONFIGURE_REQ packet is received with
invalid parameters, the recipient shall send an
L2CAP_CREDIT_BASED_RECONFIGURE_RSP PDU with a non-zero Result field
and not change any MTU and MPS values.

This fix incorrectly reconfiguring valid channels while responding with
0x003 (Reconfiguration failed - one or more Destination CIDs invalid)
result code.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-06-16 10:28:44 +02:00
Szymon Janc
266394dea4 Bluetooth: host: Fix L2CAP reconfigure response with invalid MTU
TSE18813 clarified IUT behavior and rejecting reconfiguration which
would result in MTU decrease is enough. There is no need to disconnect
L2CAP channel(s).

This was affecting L2CAP/ECFC/BI-03-C qualification test case
(TCRL 2022-2).

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-06-16 10:28:44 +02:00
Al Semjonovs
0411aa666c ztest: Add CLI arguments to filter test/suites ran
Added test command line arguments to filter
which tests are executed. Filtered tests should follow
suiteA::test1,suiteB::test2 format.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-06-15 18:06:54 -04:00
Krzysztof Chruscinski
907cd8a54f bluetooth: Remove support for logging v1
Remove support for logging v1 from bluetooth monitor log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
747d6ffdb0 shell: Remove support for logging v1
Remove support for logging v1 from shell log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
3faee83748 logging: log_backend_xtensa: Remove LOG1 support
Remove support for LOG1 from Xtensa backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
34a725e89d logging: log_backend_uart: Remove LOG1 support
Remove support for LOG1 from UART backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
7c48063a1f logging: log_backend_swo: Remove LOG1 support
Remove support for LOG1 from SWO backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
28e9f4a559 logging: log_backend_spinel: Remove LOG1 support
Remove support for LOG1 from spinel backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
ca24cb8948 logging: log_backend_rtt: Remove LOG1 support
Remove support for LOG1 from RTT backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
2bb3e64f89 logging: log_backend_net: Remove LOG1 support
Remove support for LOG1 from net backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
e550a5ccda logging: log_backend_native_posix: Remove LOG1 support
Remove support for LOG1 from native_posix backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
eb3756c2be logging: log_backend_fs: Remove LOG1 support
Remove support for LOG1 from filesystem backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
31971a5593 logging: log_backend_adsp: Remove LOG1 support
Remove support for LOG1 from ADSP backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Vinayak Kariappa Chettimada
ec286d0227 Bluetooth: Controller: Fix missing PDU next pointer initialization
When supporting chain PDUs, after HCI reset the first PDU
allocated did not initialize its next pointer causing use
of unallocated PDUs for chaining while a duplicate of such
PDU buffer being allocated for other states/roles. This
causes in certain cases both Extended and Periodic PDUs
having same data, the Extended Advertising PDU being
transmitted at the instant of the Periodic Advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-15 09:13:22 +02:00
Gerard Marull-Paretas
8cb33df108 pm: remove redundant <zephyr/zephyr.h> includes
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:13:11 +02:00
Gerard Marull-Paretas
e207b39404 mgmt: osdp: remove redundant <zephyr/zephyr.h> includes
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:13:11 +02:00
Krzysztof Chruscinski
ad12e4be32 logging: Add guards for v1 frontend API
Prevent of linking of v1 frontend API when it is not being used.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 09:12:04 +02:00
Martin Jäger
ad55227903 lorawan: make function and variable names consistent
Use Zephyr coding style for variable names and functions where possible.

The function BoardGetUniqueId has to be kept as is to match LoRaMAC
library declarations.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-06-15 09:11:34 +02:00
Vinayak Kariappa Chettimada
1578dc699b Bluetooth: Controller: Fix RX_ENQUEUE_HOLD for LOW_LAT_ULL
Fix BT_CTLR_RX_ENQUEUE_HOLD implementation that stalled
generating the CONN_UPDATE and PHY_UPDATE when there were
no Rx data or Tx acknowledgements to be processed when
the controller was built with BT_CTLR_LOW_LAT_ULL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-14 10:21:24 +02:00
Veijo Pesonen
fbef82c9c0 net: lwm2m: SenML JSON bootstrap exceptions
In bootstrap mode write to a non-exisisting optinal resource must not
cause an error.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen
a5eae6f898 net: lwm2m: adds preferred content...
...format to bootstrap registration message with LwM2M v1.1.

SenML CBOR takes precedence, followed by SenML JSON and OMA TLV.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen
db602fd81d net: lwm2m: Missing optional resource does not ...
...trigger write to the error log

Uses debug-level instead.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen
7f54aea934 net: lwm2m: SenML CBOR opaque write fixed
Write to an opaque resource failed and it has been fixed. Support for
blockwise transfer is still missing.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen
4177aa21ec net: lwm2m: SenML CBOR bootstrap exceptions
In bootstrap mode write to a non-exisisting optinal resource must not
cause an error.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Jedrzej Ciupis
adca70c0fa net: lib: openthread: use ieee802154_txpwr property
This commit aligns openthread radio platform to use `ieee802154_txpwr`
of the packet to transmit instead of setting power through a separate
API call, if possible.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2022-06-14 09:30:43 +02:00
Jedrzej Ciupis
644da741f4 net: pkt: add IEEE 802.15.4 TX power field
This commit extends the `struct net_pkt` structure with
`ieee802154_txpwr` field that contains signed value of the desired
transmission power of a IEEE 802.15.4 frame in dBm.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2022-06-14 09:30:43 +02:00
Keith Packard
abac6ccfaf subsys/usb: Fix use of 'abs' in computing when to report on_idle
idle_rate is uint8_t, sof_cnt is uint32_t. The result is uint32_t, which
is the wrong type for 'abs'. Explicitly cast idle_rate to uint32_t,
subtract sof_cnt and then explicitly cast to int32_t and then use abs,
storing the result in another int32_t which matches the return type for
abs.

This quiets clang warnings about passing unsigned values to abs.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-14 01:50:36 +09:00
Lingao Meng
bfec3b2ab4 Bluetooth: host: ASCS: Correction code comments
Audio Stream Control Service Revision: v1.0

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-13 12:12:50 +02:00
Lingao Meng
5af553d0d0 bluetooth: audio: pacs: Fix missing CONFIG_
`BT_PAC_SRC_LOC_WRITEABLE` should be `CONFIG_BT_PAC_SRC_LOC_WRITEABLE`

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-13 12:12:50 +02:00
Mariusz Skamra
790b73773e Bluetooth: audio: Allow user to set supported context as available only
This adds checks to avoid setting context that is not indicated as
supported to be available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Mariusz Skamra
e5cfb1ca4a Bluetooth: audio: Add getter for available audio context
Extend API with available audio contexts getter method.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Andrei Emeltchenko
a4fe0edfdc net: dns: Return error code
Return ret error code instead of always returning zero causing
warnings:

...
subsys/net/lib/dns/resolve.c:975:6: warning: variable 'ret' set but
not used [-Wunused-but-set-variable]
        int ret = 0;
            ^
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-13 12:11:54 +02:00
Andrei Emeltchenko
4874910465 net: dns: Remove unused variable
Fix compilation warnings:
...
subsys/net/lib/dns/dns_pack.c:548:6: warning: variable
'remaining_size' set but not used [-Wunused-but-set-variable]
        int remaining_size;
            ^
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-13 12:11:54 +02:00
Andrei Emeltchenko
be2340ab96 net: net_context: Remove double assignment
Remove double assignment, the value is stored in initialization.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-13 12:11:54 +02:00
Dominik Ermel
f52085dc54 mgmt/mcumgr/lib: Fix loop when image write fails
The img_mgmt_upload was getting into loop with requesting
offset 0 from mcumgr, when requested to re-try upload after
write fails.
Because it is not really possible to recover from write fail,
at least currently, the commit changes code to reset upload
state in a case of write error and return an error code.
Now, when write fails, an error will be returned and upload
process will be stopped and reset; upload re-try will behave
as a new upload has been requested.

Fixes #44219

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-10 09:48:31 +02:00
Dominik Ermel
3d8960ffe3 mgmt/mcumgr/lib: Remove redundant offset check
The offset is checked, for correctness, before the function
img_mgmt_impl_write_image_data is called, so it is redundant to
do the same check within it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-10 09:48:31 +02:00
Lars Knudsen
c27532eec4 Bluetooth: csis: add RSI advertising callback
Makes it possible for an application to
handle CSIS RSI advertising by registering a
callback, which will disable the internal
CSIS advertising.

Also fixes registering callbacks in CSIS.

Signed-off-by: Lars Knudsen <larsgk@gmail.com>
2022-06-10 09:47:40 +02:00
Andrei Emeltchenko
766358461c net: lwm2m: Fix NULL pointer dereference
It does make sense to goto to cleanup part.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-10 09:47:05 +02:00
David Palchak
b4a7f0f2ca linker: ensure global constructors only run once
Rename the symbols used to denote the locations of the global
constructor lists and modify the Zephyr start-up code accordingly.
On POSIX systems this ensures that the native libc init code won't
find any constructors to run before Zephyr loads.

Fixes #39347, #36858

Signed-off-by: David Palchak <palchak@google.com>
2022-06-09 11:33:36 +02:00
Sjors Hettinga
e097d95c66 net: tcp: Implement Nagle's algorithm
To improve the performance with small chunks send, implement Nagle's
algorithm. Provide the option TCP_NODELAY to disable the algorithm.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-09 11:32:50 +02:00
Mariusz Skamra
c44ef044b8 Bluetooth: monitor: Avoid sending corrupted packets over RTT
This fixes sending corrupted (incomplete) packets over RTT. Additional
helper buffer has been added to ensure the complete packet before it
can be sent over RTT. Once the complete packet is collected it is sent
to the RTT control block in non-blocking manner. From now there will
be no situation that only part of the packet (e.g. header) is sent
which lead btmon to fail to parse the corrupted data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-09 11:32:39 +02:00
Mariusz Skamra
e7b66d1b73 Bluetooth: monitor: Fix sending logs over RTT
This fixes Bluetooth logs that were not sent over RTT.
Minor cleanup has been made to limit the number of ifdefs.

> ACL Data RX: Handle 0 flags 0x02 dlen 11      #1049 83.117000
      ATT: Handle Value Indication (0x1d) len 6
        Handle: 0x0003
          Data: 0100ffff
= bt: bt_att: Unhandled ATT code 0x1d                 83.117100
> HCI Event: Disconnect Complete (0x05) plen 4  #1050 84.247700
        Status: Success (0x00)
        Handle: 0
        Reason: Remote User Terminated Connection (0x13)

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-09 11:32:39 +02:00
Vinayak Kariappa Chettimada
1a56f766bc Bluetooth: Controller: Config ticker with slot window to yield
Add Kconfig option to conditionally enable tickers with slot
window to yield to normal tickers and be placed at the end
of their slot window if possible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-09 11:32:33 +02:00
Markus Rekdal
3d8f938929 net: lwm2m: Fix range of integers in SenML CBOR
This fixes a minor bug that caused an error if one attempted to encode
or decode INT64_MIN in SenML CBOR

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-09 11:32:01 +02:00
Markus Rekdal
0006f2c93e net: lwm2m: Fix decoding of objlnk in SenML CBOR
This fixes a bug in the decoding of objlinks. Without this the object
instance id is not retrieved correctly as it tries to read the second id
starting from the colon.

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-09 11:32:01 +02:00
Seppo Takalo
e0296ca0b9 net: lwm2m: Allow initializing opaque and string data to zero length
By default, any string or opaque data that LwM2M engine initializes
sets data lenght to same value as given buffer length for that
resource.

However, on run time, engine keeps track how much data is written
to each resource, so when reading from any resource, should only
return data that has been written there. But uninitialized resources
return the content of the whole buffer.

Fixed the problem by introducing macros INIT_OBJ_RES_LEN(),
INIT_OBJ_RES_MULTI_DATA_LEN() and INIT_OBJ_RES_DATA_LEN() that
allows you to give the amount of data existing in buffer when
the resource is initialized. This sets the data_len and max_data_len
variables correctly.

Also introduced new functions lwm2m_engine_get_res_buf() and
lwm2m_engine_set_res_buf() that distinct between data size and
buffer size. Deprecated the previous functions
lwm2m_engine_get_res_data() and lwm2m_engine_set_res_data()

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-06-09 11:30:37 +02:00
Krzysztof Chruscinski
d660492914 logging: Add option for prolonged backend initialization
Extended logging backend API with log_backend_is_ready call which
returns 0 is backend is ready. Logging core will make sure that
all autostarted backends are ready before they are enabled.

This option allows to handle backends which are not yet ready
after init function is called (e.g. usb backend that is not plugged
in). If this is the only backend in the system, logging processing
will not start util first backend is ready.

Function for checking readiness is optional and when backend has
no such function it is assumed that backend is ready after
initialization function returns which makes this feature backward
compatible.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-09 09:40:01 +02:00
Mariusz Skamra
868b180d64 Bluetooth: Make use of BT_CODEC_LC3_CHAN_COUNT_SUPPORT macro
Use the BT_CODEC_LC3_CHAN_COUNT_SUPPORT macro to define the supported
channel counts.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:34 +02:00
Mariusz Skamra
132ad4ac89 csis: Remove check causing assertion
This removes the check that was causing missalignment in
csis->srv.conn_cnt conunting. The csis->srv.conn_cnt was increased for
each connected device while decreased for bonded only. This caused
assertion in csis_connected when reconnected.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:07 +02:00
Mariusz Skamra
2dff20fe4b csis: Simplify the current connections counting
This makes the code cleaner.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:07 +02:00
Jordan Yates
319ffaed0a pm: device: helper to query power state
Adds a helper function to query whether a device is currently powered.
This can be used to determine if the chip can be initialised now, or if
it needs to be deferred.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-08 12:43:00 +02:00
Krzysztof Chruscinski
0829610bbc lib: os: spsc_pbuf: Add option to use cache
Add flags option to init call and a flag to use cache.
Add Kconfig choice to pick how to approach cache. Cache can be
enforced in all spsc_pbuf instances, disable in all, or runtime selected
based on configuration flag. Option is added to allow memory footprint
savings.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Krzysztof Chruscinski
2f189e39a5 lib: os: Rename icmsg_buf to spsc_pbuf
Move icmsg_buf to lib/os and rename to spsc_pbuf (Single Producer
Single Consumer Packet Buffer). It is a generic module and initially
was created as internal module for ipc service.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Sjors Hettinga
e3b8fad9fa net: tcp: Fix accidental removal of data from send_data
In the function net_tcp_queue_data. When an -ENOBUFS by
tcp_send_queued_data is returned, it throws away the whole block of size
len from the send_data. If the len is > MSS, it could happen that the
first section is transmitted, but at the second an -ENOBUFS occurs.
In that case the data is transmitted, but later on removed from the
send_data.

To circumvent this problem, check if the len + unacked_len is smaller
then the send_data_total. If so, the data can safely be removed from
send_data. Otherwise, just pretend the transmission went OK. The
acknowledgment and retransmit path will eventually take care of it.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga
ebf8b6d3da net: tcp: Fix the polling implementation with corrected window filling
The window full computation was corrected to use the send_total instead
of the unacked_len. This conflicted with the new polling implementation
due to the moment when these values are changed.

Move taking the tx_sem outside of tcp_send_queued_data to handle the
-ENOBUF situation properly in case called from net_tcp_queue_data.
net_tcp_queue_data removes data from the send_data in case the
transmission failed with -ENOBUF. This cause the buffer to be not full
any more.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga
d49d06735a net: tcp: Explicitly notify buffer allocation failures in retransmission
Log an error to explicitly log a failed buffer allocation in TCP
retransmission. This avoids silently failing retransmissions due to
repeating buffer allocation failures.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga
0a9b2ed391 net: tcp: Avoid new packets from causing killing the pending send_timer
When there was no room to transmit the a next packet to be transmitted,
the -ENOBUFS could cause the retransmission to fail.

Secondly the conn->unacked_len can be set to 0 in the retransmission
process, causing the subscribtion to the transmit timer to fail. Use the
variable send_data_total instead.

Make sure that is the send_data buffer becomes empty the send_timer is
cancelled, but make sure any pending data still keeps on being transmitted.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga
d74bd3d7d1 net: tcp: Avoid deadlock in updating the TCP receive window
The function tcp_data_get tries to update the TCP receive window using
net_context_update_recv_wnd. This function graps the context lock while
the tcp_data_get is called from a situation where it already has tcp lock
is already. Transmission actions do first grab the the context lock and
try to grab the tcp lock afterwards. The combination of both can cause a
deadlock.

By taking the shortcut to directly update the tcp receive window without
going through the net context, the context lock is not required avoiding a
possible deadlock situation.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga
f5679ab73e net: tcp: Use our MTU to determine the mss for transmission
In the existing the value received from the other side by the TCP options
is used as MSS for transmission. Since the MSS options are an
announcement rather then a negotionation, it is likely the receiver will
have a different and possibly bigger MSS than allowed by our side.
This allow potentially for different a MSS in the receive and transmit
path.

Directly using the received MSS could cause problems when our MSS is only
allowed to be small. At transmission, for that reason take the minimum of
the received MSS and our desired MSS to find a value compatible to both
sides of the link.

Rename the function to net_tcp_get_recv_mss to net_tcp_get_supported_mss
to better reflect its function in the new situation.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Mariusz Skamra
cf59606883 Bluetooth: has: Allocate context for client once link is encrypted
The HAS sends notifications to paired devices. Thus the client context
has to be initialized once the link has required security.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:36 +02:00
Mariusz Skamra
a4d9c82fca Bluetooth: pacs: Make location characteristics non-writable by default
The Sink Audio Locations and Source Audio Locations characteristics are
optionally writtable as defined in PACS_v1.0.
If the property is not mandatory in the specification it should be
disabled in implementation by default. It is more likely that the
location value will not change over time, as the end-product would
be designed to be used in specific way (in specific location).
If the user wants to make use of the writtable location feature, then
one has to enable it explicitly.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:23 +02:00
Mariusz Skamra
146124e7f9 tests: has: Extend tests with preset selection commands
The commands are used to change the active preset.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Mariusz Skamra
4e15cbe456 Bluetooth: has: Handle active preset selection
This adds handling of active preset selection in HAS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Dominik Ermel
0c290864d7 mgmt/mcumgr/lib: Remove no longer needed mgmt_streamer_trim_front
Special function for supporting various types of buffers,
via provided callbacks, is no longer needed when net_buf is the
only type of transport buffer used by mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-07 18:54:11 +02:00
Dominik Ermel
3528c1ee30 mgmt/mcumgr: Replace zephyr_smp_trim_front with net_buf_pull
The additional logic of zephyr_smp_trim_front is no longer needed
and net_buf_pul can be directly used to trim front of net_buf
response when fragmenting.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-07 18:54:11 +02:00
Emil Gydesen
c513fd87e1 Bluetooth: ISO: Rename sn to seq_num
Rename the `sn` field(s) to `seq_num` to be more readable
and clear what the value covers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen
65b5db6e3a Bluetooth: ISO: Rename ISO_INTERVAL_MIN/MAX
Rename the BT_ISO_INTERVAL_MIN/MAX to
BT_ISO_SDU_INTERVAL_MIN/MAX to avoid confusing this
the the ISO interval which is different from the SDU
interval.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen
6786bbdb32 Bluetooth: ISO: Add sn and ts to bt_iso_chan_send
Add two new parameters to bt_iso_chan_send:
sn: The packet sequence number which shall be incremeted
per SDU interval.
ts: An optional timestamp value used to synchronize SDUs.

The sequence number in the API uses a 32-bit value even though
the sequence number for the HCI command is 16-bit. This is to
properly handle wrapping of sequence numbers, which is much
easier to do with additional bits allocated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Daniel Leung
125b33c185 logging: remove CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS
CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS was added as
a stop-gap measure to support Sys-T catalog messages. Since
the Sys-T backend has envolved to use tagged argument, this
kconfig and its effect are no longer needed. So remove it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Daniel Leung
134d26bade logging: syst: extend catalog messages support for other archs
This extends Sys-T catalog messages support for other architectures,
by utilizing tagged arguments to prepare the catalog messages. So
this is no longer limited to architectures where the printf
argument list has the exact format as the catalog message argument
list.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Daniel Leung
fe0aa4c167 logging: support tagged argument in log message packaging
This adds support for packaging with tagged arguments for log
messages so that backends can make use of this information
when they process messages.

Note that currently tagged arguments must be used with
CONFIG_LOG2_ALWAYS_RUNTIME where log messages are created via
z_log_msg2_runtime_{v,}create(). For some reason, using C++ on
Cortex-M (mps2_an385) results in an additional empty string
argument being added to the list. This does not happen if only
doing C on mps2_an385, or on other architectures.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Andrei Emeltchenko
bdafd89c12 net: 6lo: Remove dead statement
Value stored to compressed_hdr_size is never read.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-07 11:54:20 +02:00
Andrei Emeltchenko
38b40f2ed1 net: utils: Remove dead statement
Value stored to needcolon is overwritten later before loop ends.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-07 11:54:20 +02:00
Benjamin Gwin
0cc9ad4f50 testsuite: Make ztress header C++ compatible
This allows ztress to be linked correctly from C++ based tests.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-06-07 11:53:41 +02:00
Pavel Vasilyev
953f8ee0d6 Bluetooth: Mesh: Fix RPL fragmentation
`bt_mesh_rpl_check` stops iterating `replay_list` if either it found an
entry with the requested source address or unassigned address. When IV
index updated, `bt_mesh_rpl_reset` is called. It will set `old_iv` to 1
for all entries with fresh IV index and remove entries with old IV index.
If the entries with old IV index are mixed with other entries, this will
cause fragmentation of `replay_list`. The next time `bt_mesh_rpl_check`
is called, it may stop iterating `replay_list` earlier than it should
because it will meet an empty entry before it iterates over all entries
in the list.

This commit does defragmentatino of `replay_list` on every
`bt_mesh_rpl_reset` by shiting existing entries to the vacated places.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-06-07 11:53:31 +02:00
Carlo Caione
4ef13f7ecd ipc_service: static_vrings: Set WQ priority back to PRIO_PREEMPT
This reverts commit 7f51907fda.

The problem with setting the priority at the highest priority possible
is that when the IPC is under high traffic, the WQ could starve the
scheduler.

Move back to a more sane preemptive priority as default value.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-07 11:53:22 +02:00
Yong Cong Sin
ae587f8e50 subsys/mgmt/hawkbit: format for readability
Formatted the code so that it is easier to read.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-07 11:52:10 +02:00
Andrei Emeltchenko
a9b3c936e2 shell: uart: Fix compilation warning
Use ARG_UNUSED() to fix compilation warning unused-but-set-variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-06 22:47:11 +02:00
Juha Heiskanen
7ffc95c430 net: lwm2m: Composite Observation refactor
Json library parser modify data so thats why we can't parse same
data again. Now Composite observation handler parse SenML Json or
CBOR resource path which is given to new API composite Read API
which not need any new data parser.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Juha Heiskanen
2da8df8b7e net: lwm2m: Integrate JSON lib to LwM2M 1.0 JSON
Integrated updated JSON library to LwM2M 1.0 JSON.
Removed Old Json format default choice.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Juha Heiskanen
a9035ebe5e net: lwm2m: Integrate JSON lib to SenML-JSON
Integrated updated JSON library to SenML-JSON.
This integrate affect that Coap Block wise transfer is not
supported.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Dominik Ermel
37dd4fb775 mgmt/mcumgr/lib: Fix parasitic use of heap by image management
The commit fixes issue where image management would switch to using
heap, whether developer wanted or not, when CONFIG_HEAP_MEM_POOL
gets value greater than zero.
Now when heap is enabled the user can select whether image management
will keep on using static variable, taking static RAM, or will use
heap to allocate the flash image context only when needed.
For this purpose CONFIG_IMG_MGMT_USE_HEAP_FOR_FLASH_IMG_CONTEXT
has been added, which is available when CONFIG_HEAP_MEM_POOL is enabled.

Fixes #44214

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-06 12:05:29 +02:00
Carles Cufi
b41d7f0f0c Bluetooth: Controller: Implement bt_hci_driver::close
The open source controller did not expose support for shutting it down
via the close() API in the HCI driver. Add support for it, which
completes the support for disabling and enabling the Bluetooth stack in
Zephyr.

Closes #3192.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-06-06 12:04:30 +02:00
Carles Cufi
4349a475a8 Bluetooth: Controller: Add deinit() infrastructure
Allow the controller to be deinitialized, adding the whole chain of
calls:

- ll_deinit()
- lll_deinit()
- lll_clock_deinit()

in order to be able to turn everything off, including the controller's
refcount of the LF clock.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-06-06 12:04:30 +02:00
Carles Cufi
11da95bb4d Bluetooth: Host: Properly handle disable()/enable() cycles
When bt_disable() was introduced, some of the global variables that
handle key aspects of Bluetooth were not converted to be also
re-initialized every time that the stack was disabled and the enabled
again. This meant that the FIFO and semaphore in the device structure
were not reset whenever the corresponding threads using them were shut
down and then restarted.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-06-06 12:04:30 +02:00
Carlo Caione
2bf678af1b ipc: static_vrings: Fix timeout management
The ipc_service_get_tx_buffer() has a timeout parameter that can be used
to wait a certain amount of time for a TX buffer to be available.

Unfortunately, for the static vrings backend, an asymmetry
between remote and host exists that makes the usage of this parameter
confusing when the user requests a buffer when no buffers are available
at that time.

When the remote endpoints requests a TX buffer specifying a certain
size and there are no TX buffers available, the function ignores the
parameter and ipc_service_get_tx_buffer() immediately returns -ENOMEM.

The same case on the host endpoint works correctly only when the
specified timeout is <= 15 seconds. All timeouts > 15 seconds simply
returns -EIO after 15 seconds.

This patch is reworking the timeout management trying to behave
correctly in all the cases.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-05 14:49:26 +02:00
Yong Cong Sin
57b1f6622d fs/nvs: Fix comment typo
Minor fix to a comment typo.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-05 14:49:20 +02:00
Yong Cong Sin
267b4ae6b8 fs/nvs: removed extra empty lines
Minor edit to the code style.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-05 14:49:20 +02:00
Yong Cong Sin
85f54380f6 fs/nvs: Remove unused variable
ate_size doesn't seem to be used in the function, removed.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-05 14:49:20 +02:00
Berend Ozceri
a9376174cd net: websocket: Allow building with POSIX API
If the POSIX API is selected via the POSIX_API option, use the POSIX
headers instead.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-06-05 14:48:52 +02:00
Kamil Gawor
0843ef1cfa bluetooth: host: Fix reading current PHY when using extended advertising
The current PHY is read only when automatic PHY
update procedure is enabled, 2M PHY is supported and
extended advertising is enabled and this is done after
application is notified about connection. This leads
to invalid connection info PHY data which always returns
1M PHY because when using extended advertising the connection
can be established on different PHY and host does not read
this value from the controller in most cases. In order to
have a current PHY value updated we need to read it in
connection complete event before the user application
is notified about connection.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-06-05 14:48:14 +02:00
Dominik Ermel
e15523d198 mgmt/mcumgr/lib: Use flash_img_bytes_written to check context
The commit replaces direct access to flash_img_context, for the
purpose of checking how much data has been written, with call
to the flash_img_bytes_written.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-05 14:47:35 +02:00
Carlo Caione
01305942f6 ipc: static_vrings: Support DT-defined buffer size
Recently OpenAMP introduced the possibility to set the sizes for TX and
RX buffers per created instance. Expose this also to Zephyr users by
using a DT property "zephyr,buffer-size".

For the sake of simplicity use the same DT property to set the buffer
size for both TX and RX buffers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-05 14:46:18 +02:00
Herman Berget
c3c7b54ccf Bluetooth: Host: Option for disabling of ATT auto retry
The automatic elevation of security and retry of ATT requests interferes
with some tests that expect authentication failures.

Affecting GATT/CL/GAR/BI-42-C

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-05 14:45:32 +02:00
Yuriy Vynnychek
cca221e928 drivers: bluetooth: hci: introduce new Telink B91 HCI driver
Telink B91 Bluetooth HCI driver basic support.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2022-06-05 14:45:10 +02:00
Herman Berget
5febfac02c Bluetooth: Allow support for Multiple Variable Length Read without EATT
EATT is not a requirement for the Multiple Variable Length Read
procedure, but previously one had to enable CONFIG_BT_EATT to enable
support for it.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-05 14:44:58 +02:00
Mariusz Skamra
33991f2dde Bluetooth: audio: Expose API methods to change the available contexts
This exposes API methods to change the available context types.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Mariusz Skamra
893f49ea88 Bluetooth: audio: Build PACS only if Sink or Source enabled
This fixes Kconfig that allowed to build PACS without support for sink
or source PACS. Few conditionals that no longer apply were removed.
Enabling ASCS support in specific direction enables related PACS
support.
Since PACS does `depends on` anything, it's safe to make use of `select`
statement.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Mariusz Skamra
eddfc89ebf Bluetooth: uuid: Rename PACS Available Contexts UUID define
This renames the UUID to follow the same naming scheme as for
BT_UUID_PACS_SUPPORTED_CONTEXT.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Damian Krolik
74e4ac0883 nvs: implement NVS cache
The NVS data lookup time grows linearly with the number of
allocation table entries to walk through, meaning that if
some data pair in the NVS changes frequently, access to
other data pairs that change rarely can take a lot of time.

It is particularly visible when the NVS is used as the
settings backend since the backend needs to perform multiple
NVS reads to find a requested key.

Implement a simple cache that stores an address of the most
recent ATE for all NVS IDs that fall into the given cache
position. CRC8/16 is used as a hash function used to
distribute NVS IDs across the cache entries.

The cache entries are only invalidated when an NVS sector
is erased as part of the garbage collector task.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-06-05 14:43:59 +02:00
Eduardo Montoya
e6f3b8a296 net: openthread: fix wrong configuration
Fix wrong OpenThread config.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-06-05 14:42:33 +02:00
Gerhard Jörges
d99827f0a5 shell: suppress newlines on boot when promt is an empty string
If the user sets the default_prompt to an empty string no newlines will
be printed during boot.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-06-05 14:42:26 +02:00
Emil Gydesen
0eb5b3ac03 Bluetooth: Shell: Add gatt notify-mult command
Add GATT command to test the bt_gatt_notify_multiple
function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:29:33 +02:00
Andriy Gelman
f12f9d5e95 net: pkt: Fix leak when using shallow clone
Currently a shallow clone of a packet will bump the reference count on
all the fragments. The net_pkt_unref() function, however, only drops the
reference count on the head fragment. Fix this by only bumping the ref
count on the head buf during shallow clone.

Only bumping the ref count of head is more in line with the idea that
head buf is not responsible for the fragments of its child.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-06-05 14:29:19 +02:00
Dominik Ermel
aa5d20aaef storage/flash_map: Return -ENODEV from flash_area_open
The commit adds check, to flash_area_open, whether there is any
device driver attached and returns -ENODEV if there isn't any.
This works around a problem where flash_area_open succeeds but
consecutive read/write causes crash.
It is enough to check the condition, and return error, here as
the flash_area_open has to precede, and be checked for success,
any read/write operations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-05 14:28:58 +02:00
Mark Holden
44c388fb33 coredump: drivers: Add coredump device
Add a pseudo device diver with device tree bindings for coredump.
The device tree bindings exposes memory address/size values to be
included in any dump. And the driver exposes an API to add/remove
dump memory regions at runtime.

Signed-off-by: Mark Holden <mholden@fb.com>
2022-06-05 14:28:34 +02:00
Markus Rekdal
cf43c49b5f net: lwm2m: Fix decoding of objlnk
This fixes a bug in the decoding of objlinks. Without  this the object
instance id is not retrieved correctly as it tries to read the second id
starting from the colon.

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-05 14:27:39 +02:00
Emil Gydesen
edb30d53d9 Bluetooth: Audio: Fix issues with unicast audio group lifetime
The unicast audio group can not have streams removed after the
CIG has been created as part of the QoS set procedure.

The bt_audio_unicast_group_remove_streams function may
leave the unicast group without streams, and thus the
check for "free" group was not correct, and has been replaced
with a simple boolean value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen
2baa0ba710 Bluetooth: Audio: Use bidirectional CIS for unicast audio
The unicast client and server will attempt to use a
bidirectional CIS instead of two unidirectional CIS
whenever possible.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen
cc94fa763b Bluetooth: Audio: Make bt_audio_codec_qos_to_iso_qos return void
Change the return type of bt_audio_codec_qos_to_iso_qos to
void as it cannot fail, and this will make it easier to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen
f77355aaa5 Bluetooth: Audio: Add sink/source ep ref to bt_audio_iso
Add supporting for referercing either a sink endpoint,
a source endpoint or both in the bt_audio_iso struct.

This way a single bt_audio_iso can have references to up
to 2 endpoints.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen
e8e1920577 Bluetooth: Audio: Move ISO struct from audio_endpoint
Moves the bt_iso_chan and bt_iso_chan_qos structs
out from the bt_audio_ep struct, and instead use a
reference.

This is due to the fact that an endpoint can ever
only be unidirectional, and a CIS can be bidrectional.

The support for using a single bididrectional CIS
for two audio streams/endpoints is not implemented
in this commit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen
73e8fd6684 Bluetooth: ISO: Move iso_server NULL check for inc. reqs
Move the NULL-check for the iso_server to an earlier point.
There's no need to do anything on the device if no iso_server
has been registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen
e2e56da061 Bluetooth: Shell: Add security level option to "iso connect"
The "iso connect" now also takes a security level option like
"iso listen", so that the central can easily encrypt
and connect a CIS in a single command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen
57e1056bef Bluetooth: ISO: Guard sec_level with CONFIG_BT_SMP
The ISO security implementation works by verifying
against the acl (bt_conn) sec_level field. The
bt_conn sec_level field is only available
if CONFIG_BT_SMP is enabled, so this commit
adds guards for all ISO security checks as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen
b3cddc6d27 Bluetooth: ISO: Central security request
If the required_sec_level is lower than the
conn->sec_level, the central will now initialize the
security procecure to ensure that the CIS is encrypted
properly.

The algorithm implemented is as follows:
1) Check security levels for each (acl, iso) pair
2) For those with insufficient security,
   call bt_conn_set_security
3) For those with sufficient security, connect the CIS
4) Once the ISO from 2) has been encrypted, connect the
   CIS for the specific ACL

The idea behind this was to implement similar support
for autonomous encryption as we have for L2CAP.
It is more complex for ISO as we are dealing with
an array of (acl, iso) pairs, meaning more can go
wrong.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen
2ace9cb256 Bluetooth: ISO: Add server security check
Add check for connection and server security
levels, and reject the CIS if the ACL security
level is too low.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Vinayak Kariappa Chettimada
f31b974243 Bluetooth: Host: Fix incorrect ACL buffer count
Fix incorrect ACL buffer count use when Controller used
supports separate ISO buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-03 15:11:33 +02:00
Herman Berget
ed0dfb9dd2 Bluetooth: Host: Fix ATT PDU alloc being non-blocking.
The API is documented as being blocking. Making it nonblocking was an
unintentional API change.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 14:41:09 +02:00
Herman Berget
e494d9c072 Bluetooth: Host: Handle err in l2cap_chan_sdu_sent and l2cap_chan_seg_sent
The error will be propagated to the higher levels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget
eff10664bd Bluetooth: Host: Do not require the ops->sent callback
The L2CAP channel ops->sent callback was required to call the
l2cap_chan_sdu_sent callback.

Previously, the only difference between the l2cap_chan_sdu_sent and
l2cap_chan_seg_sent callbacks was that l2cap_chan_sdu_sent called
ops->sent. This is no longer true and l2cap_chan_sdu_sent should always
be called when an SDU is sent.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget
bbe5143b95 Bluetooth: Host: Call bt_conn_tx callback with error in error cases
This allows the higher layers to to any required cleanup.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget
5e93b3f192 Bluetooth: Host: Free ATT metadata before calling user callback
In case the user callback tries to allocate metadata for a new ATT PDU.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget
695e5915f8 Bluetooth: Host: Add err parameter to bt_conn_tx_cb_t
This gives more information back to the supplier of the callback.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget
03f941ccb0 Bluetooth: Host: Use correct type for func in ATT metadata
The type should be the user-facing gatt callback, not the internal conn
callback.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Marcin Niestroj
c00fdcb518 net: context: prevent truncating outgoing datagrams
Datagrams should either be fully sent or not sent at all if networking
buffers or network interface MTU does not allow that. So far the behavior
was to truncate outgoing packets, even for datagram sockets.

When there is not enough available payload buffer to fit all requested
data, fail if that happens for datagram socket.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-01 11:17:07 +02:00
Mariusz Skamra
0492ef5bbf Bluetooth: audio: Fix call control client build
error: 'CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH' undeclared (first use
			in this function); did you mean
			'CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH'?
  292 |            CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH
etc.

This fixes build errors that were seen while building call control
client without server side (`CONFIG_BT_TBS`) enabled.
The options like BT_TBS_CLIENT_MAX_URI_LENGTH and
BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH have been removed because those
were not used in the code. In fact the client implementation used the
common options for BT_TBS_MAX_URI_LENGTH and
BT_TBS_MAX_PROVIDER_NAME_LENGTH that were moved in this patch to the
common Kconfig section.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-27 17:47:58 -07:00
Olof Winge
dea9343d61 net: ipv4: Accept unspecified src address if dst is broadcast
To be able to accept DHCP discover/request incoming packets the ip stack
neeeds to accept unspecified src addr if the destination is broadcast
address.

Signed-off-by: Olof Winge <olof@skyshaper.net>
2022-05-27 15:46:44 -07:00
Ryan Erickson
67598965fb lwm2m: software management: Fix URI value not being written
Create the URI resource when creating the object if
PULL support is enabled.

URI write callback should be post-write instead to ensure
the URI value is updated for the resource.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-05-27 15:45:14 -07:00
Robert Lubos
0516d75d84 net: ethernet: Add Kconfig option to forward unrecognized EtherType frames
Add Kconfig option to the Ethernet L2 which allows to forward frames
with unknown EtherType further into the stack. This can be useful for
packet sockets, where further frame processing is application dependent.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Robert Lubos
eddb6c8111 net: sockets: packet: Remove obsolete TODO
It turns out that all of the items listed under TODO section for packet
socket implmeentation has been adressed over time, threfore remove the
obsolete TODO.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Robert Lubos
96cc85146d net: conn: Add proper processing of DGRAM packet sockets
Datagram AF_PACKET sockets were not processed properly by the net stack.
Instead of receving a packet already processed L2, and thus with L2
header trimmed, it was receiving a raw, unprocessed packet.

Fix this by calling net_packet_socket_input() for the second time, after
L2 has processed the packet. An updated connection handler module will
forward the packet correctly based on the corresponding socket type and
packet L2 processing status.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Robert Lubos
5ab0d54f79 net: context: Improve packet socket interface selection on sendto()
Currently, the packet socket implementation in net_context required that
netowrk interface to transmit the packet to was set on every sendto()
call. This spoils the whole idea of binding a socket. Fix this, by
checking first if the net_conext is already bound to a particular
interface, and if so, do not throw an error in case sll_ifindex field is
not a valid interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Keith Packard
b7313f85fe subsys/img_mgmt: Add zephyr/toolchain.h for STRINGIFY [v2]
Somehow two files in subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src ended up
using STRINGIFY but nothing in their include path ended up pulling in
zephyr/toolchain/common.h. Include that via zephyr/toolchain.h.

v2:
	Use non-internal zephyr/toolchain.h header

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Emil Gydesen
0813966545 Bluetooth: GATT: Remove use of BT_GATT_ATTRIBUTE macro for discover results
The macro was remove for the GATT discover callbacks,
as only 2 out of 5 parameters for
BT_GATT_ATTRIBUTE were used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-27 15:29:36 -07:00
Dominik Ermel
38e554846a mgmt/mcumgr/lib: Improve CONFIG_IMG_MGMT_VERBOSE_ERR description
The description suggested logging information while it never
was the case: it was about adding additional "rsn":value pair
to an SMP response.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-27 15:21:24 -07:00
Fabio Baltieri
e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Vinayak Kariappa Chettimada
192e2a8f94 Bluetooth: Controller: Fix Data Length Request Cmd parameter checking
Fix Data Length Request CMD parameter checking to not
restrict invalid maximum Tx time values. This addresses
conformance test cases that provide maximum Tx time values
of 2128 us when not supporting Coded PHY in the Controller
implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-27 15:19:06 -07:00
Jonathan Rico
d3138c937f Bluetooth: host: don't timeout when reconfiguring an l2cap channel
The request timer started on the first l2cap channel when doing an MTU
reconfiguration has to be stopped when the response is received. Else the
channel will get into a bad state.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-05-27 16:03:33 +02:00
Dominik Ermel
19259ab7db mgmt/mcumgr/lib: Fix image list command crashing when no device
It is possible, in case of two application images, to have no access
to one of devices of the secondary image.
When asserts are enabled, such situation causes crash even though the
image list command can handle it with no problem.
The commit removes the assert and adds additional swap type:
IMG_MGMT_SWAP_TYPE_UNKNOWN to indicate situations where it was
not possible to obtain swap type from boot_util.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-26 13:08:35 -07:00
Piotr Pryga
131c089aaf Bluetooth: Controller: llcp: Fix wrong eff time calc if PHY changed
If there is a PHY change on a connection it may happen that effective
RX and TX time changes also. That change is applied after an instant.

Implemented handling of effective time calculation is based on the
maximum PDU length, new PHY and local (default) maximum TX or RX time.

The maximum TX value is set to default one that corresponds to PHY 1M
during the Controller initialization. It can be updated by host to other
value. By default Zephyr Host updates it to max possible TX time for all
supported PHYs. If PHY CODED is enabled, it is the longest possible TX
duration 17040 us.

The maximum RX value is set to default during connection creation.
In case of use of legacy advertising, the value is also related with
PHY 1M. It can be updated by data length extension procedure.

If the maximum RX value is set to some value and there is a change
of a PHY to one that requires more time to send a PDU with the same
length, then the maximum RX value is wrongly calculated.

Function pu_calc_eff_time returns a value that is the default_time
argument. The problem is that the default_time should be adjusted
to new maximum RX time required for a new PHY.

To solve that there should be an evaluation of a new maximum RX and
TX time based on new PHY.

The commit adds missing evaluation.

The problem occurred in DF tests that check collision mitigation
between PHY update control procedure and CTE request control procedure.

There was missing CONFIG_BT_CTLR_PHY_CODED option in CTE request
unit tests. The code was working because the ULL implementation of
PHY change control procedure does not verify if PHY CODED is supported.

When missing support was enabled, tests showed wrong evaluation of
maximum RX time. It also unveiled error in CTE request unit tests
implementation. The default_tx_time was set to wrong value 2120 us
as if PHY CODED was not supported. To fix it, the value was changed
to PDU_DC_PAYLOAD_TIME_MAX_CODED.

There was also added a mock for a feature exchange procedure done
during unit tests setup step. That allows to correctly calculate
maximum TX time by ull_dle_max_time_get function.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-26 16:29:10 +02:00
Vinayak Kariappa Chettimada
e79c48f7c6 Bluetooth: Controller: Fix missing DUP_FILTER_ADV_SET_MAX dependency
Fix missing BT_CTLR_DUP_FILTER_ADV_SET_MAX dependency on
BT_CTLR_ADV_EXT.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada
59eef60665 Bluetooth: Controller: Fix filter accept list and privacy default
Fix filter accept list and privacy feature Kconfig default
based on whether host has them enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada
1791a154dc Bluetooth: Controller: nRF5: Fix missing BT_CTLR_PRIVACY cond compile
Fix missing BT_CTLR_PRIVACY conditional compilations that
included redundant HAL code when Controller privacy is
disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada
5f670fa9c3 Bluetooth: Controller: openisa/RV32M1: Fix BT_CTLR_PRIVACY cond compile
Fix missing BT_CTLR_PRIVACY conditional compilations that
causes compile errors when Controller Privacy is disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada
620a5524a5 Bluetooth: Controller: Fix PHY update for unsupported PHY
Fix PHY update procedure to handle unsupported PHY requested
by peer central device. PHY update complete will not be
generated to Host, connection is maintained on the old
PHY and the Controller will not respond to PDUs received on
the unsupported PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:24:54 +02:00
Dominik Ermel
1bd5665b89 mgmt/mcumgr/lib: Fix usage of MGMT_ERR_ENOMEM
The commit replaces MGMT_ERR_ENOMEM with MGMT_ERR_EMSGSIZE where it
was used to indicate that SMP response does not fit in response
buffer.

Fixes #44535

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-25 13:56:03 -07:00
Erik Brockhoff
25e6279493 Bluetooth: controller: llcp: fix for failing LL qualification tests
Fixes issue re. sending packets after sending TERMINATE_IND.
Fixes issue re. erroneous error code on 'timed out' termination (ie
when peer does not ack terminate_ind)

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-25 16:29:24 +02:00
Erik Brockhoff
7daba33f2d Bluetooth: controller: llcp: update max dle times on feature exchange
On a completion of feature exchange the max DLE times needs to be
updated if Coded PHY has become supported.
For this now also keep a separate store of the default_tx_octets/time
for the sake of re-calculation of local versions of DLE values

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-25 16:29:18 +02:00
Dominik Ermel
550f1b096d mgmt/mcumgr/lib: Fix OS taskstat passing incorrect value
The commit fixes incorrect value being passed as used stack
information and also prevents compilation error when
CONFIG_INIT_STACKS is n.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-25 16:09:12 +02:00
Achatzi Julian
90236b0650 fs: fcb: Make FCB work with sectors larger than 16K
Enhance FCB to also work with sectors larger than 16K and
to handle larger flash alignment constraints correctly.

use fcb_len_in_flash when setting the offset of the data
and use buffers sizes of at least the alignment value.

The test in fcb_test_append_to_big has been altered, as it
would otherwise not come to a data length which fits the
fcb on sectors larger than 16K.

Closes: https://github.com/zephyrproject-rtos/zephyr/issues/45345

Signed-off-by: Achatzi Julian <jachatzi@baumer.com>
2022-05-25 14:57:45 +02:00
Casper Bonde
e2dad8fa11 Bluetooth: Broadcast: Fix codec and meta data encoding
Length filed was 1 off.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2022-05-25 14:57:33 +02:00
Vinayak Kariappa Chettimada
742173c314 Bluetooth: Controller: Fix prepare pipeline stall
Fix prepare pipeline from not resuming non-resume events
in pipeline when more than one resume events are present
before a non-resume event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-25 14:38:18 +02:00
Azizah Ibrahim
e11ff7df48 bluetooth: host: Avoid sending duplicate device to resolving list.
Core v5.3, Vol 4, Part E, 7.8.38
Controller has the option to accept or reject when the same device
is added to RL.
If a remote device has been added to RL before, then local device
change it's advertsing address, and the remote device tries to pair
with the new address, we could end up trying to add the same data to RL.
If a remote device's public/static address is known, this patch deletes
the old entry from RL before adding it.

Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
2022-05-25 14:25:14 +02:00
Damian Krolik
7e02e8c9f4 mcumgr: fix invalid condition for calling img_mgmt_dfu_stopped
In other places, img_mgmt_dfu_stopped() is called when
a failure occurs and the DFU cannot be continued. In this
place, however, the function is called on success which
does not seem to be correct.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-05-25 14:21:19 +02:00
Szymon Janc
b3de861d15 Bluetooth: Controller: Fix not clearing Static Random Address on reset
When host issue HCI Reset controller should clear LE Static Random
address. Otherwise controller may incorrectly use one from before
HCI reset insread of rejecting HCI commands.

This was affecting following qualification test cases:
HCI/CCO/BI-51-C
HCI/CCO/BI-53-C
HCI/CCO/BI-54-C
HCI/CCO/BI-56-C
HCI/DDI/BI-06-C
HCI/DDI/BI-07-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-25 14:20:21 +02:00
Marcin Niestroj
900137ef32 net: sockets: tls: prevent sending fragmented datagrams with sendmsg()
Fragmented data passed to sendmsg() should be sent as a single datagram in
case of datagram sockets (i.e. DTLS connection). Right now that is not
happening now, as each fragment is sent separately, which works fine only
for stream sockets.

There is no mbedTLS API for 'gather' write at this moment. This means that
implementing sendmsg() would require allocating contiguous memory area at
Zephyr TLS socket level and copying all data fragments before passing to
mbedTLS library. While this might be a good option for future, let's just
check if data passed to sendmsg() API consists of a single memory region
and can be sent using single send request. Return EMSGSIZE error if there
are more then one data fragments.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-05-25 14:20:09 +02:00
Szymon Janc
42d461d3a2 Bluetooth: Controller: Fix HCI supported commands bitmask
This was affecting HCI/GEV/BV-01-C qualification test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-25 14:19:59 +02:00
Szymon Janc
f0b6774191 Bluetooth: Controller: Fix validating PHY bitmask in HCI
At least one supported PHY bit shall be set and none of
non-supported or RFU bits should be set.

This was affecting HCI/DDI/BI-05-C qualification test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-25 14:19:41 +02:00
Piotr Pryga
f3d460ff5a Bluetooth: Controller: df: Remove experimental for direction finding
Removes label experimental for direction finding feature in
Bluetooth Controller.

The feature stays disabled by default because it requires additional
dedicated hardware to be used. Besides that it significantly enlarges
amount of memory used by the Controller.

End user has to enable the feature explicitly by use of configuration
options.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:48:43 +02:00
Vinayak Kariappa Chettimada
0d7bd277a9 Bluetooth: Controller: Fix preempt timeout not skip first in pipeline
Fix preempt timeout scheduling to not skip first prepare in
pipeline when there are no previous preempt timeout
scheduled already.

Fix related to commit 27b8beaa22 ("Bluetooth: Controller:
Fix to handle relative short preempt timeout").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-25 11:14:58 +02:00
Piotr Pryga
729e4f5b1e Bluetooth: Controller: df: Fix check for max CTE num to sample or adv
Maximum number of CTE to be send in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.80 and is 16.
Maximum number of samples CTE in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.82 and is also 16.
Both values are limited by amount of memory reserved in Controller
by Kcofigs, respectfully: CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX and
CONFIG_BT_CTLR_DF_PER_SCAN_CTE_NUM_MAX.

Functions ll_df_set_cl_cte_tx_params and ll_df_set_cl_iq_sampling_enable
check limits against Bluetooth specification provided values.
That can end with memory overwrite if number of requested CTEs is
greater that number provided in configuration.

The commit changes mentioned functions to validate HCI commands
parameters against configuration values.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:48 +02:00
Piotr Pryga
1d89b271fb Bluetooth: Controller: llcp: Fix assert if reject while loc and rem pend
In case there are pending two control procedures: local and remote,
and remote device sends LL_REJECT_IND PDU then assertion happened.
ull_cp_rx function triggers assertion because LL_REJECT_IND is
considered as expected packet for all local and remote control
procedures.

That is not correct. It does not allow local procedure to handle
a response and stops a device on assert.

A remote device should not send LL_REJECT_IND PDU for locally initiated
control procedures, hence local device should not expect to receive
LL_REJECT_IND PDU to be expected one for pending remote control
procedure.

Remote device is allowed to send LL_REJECT_EXT_IND PDU for a locally
initiated control procedures. The LL_REJECT_EXT_IND PDU has a Reject-
Opcode that identifies rejected control procedure, hence is may be
expected by local device.

The commit provides changes that prevent the Controller assertion
in described case.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:38 +02:00
Piotr Pryga
f3deccda91 Bluetooth: Controller: CCM read data to early when DF enabled on PHY 1M
CCM during on-the-fly decryption of a received packet starts decryption
when Radio triggers EVETNS_ADDRESS. In case there is possibility a
packet may include Constant Tone Extension, on-the-fly parsing of a
received packet for CTEInfo is enabled.

If there is a PHY 1M enabled the Radio stores received bits with a
delay, that is equal to time required to receive 3 bits. CCM TASKS_CRYPT
related with packet decryption should be delayed by the time the Radio
needs to store received data.

The commit provides changes required to delay start of the CCM
TASKS_CRYPT. It uses NRF_RADIO Bit counter feature. The Bit counter is
configured to trigger NRF_RADIO->EVENTS_BCMATCH on reception of 3rd bit.
The event is connected through PPI with CCM TASKS_CRYPT.

The PPI used is shared with Radio Rate override. That is possible because
direction finding feature is not allowed on PHY Coded and CCM needs a delay
only when used PHY 1M.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:15 +02:00
Piotr Pryga
6f7e58e347 Bluetooth: Controller: lll: Move packet setup after call to sw switch
lll_conn_rx_pkt_set function is called before one of radio_switch-
_complete_XXX functions calls in lll_peripheral.c. That prevents
lll_conn_rx_pkt to call any Radio setup related function that touches
NRF_RADIO->SHORTS. NRF_RADIO->SHORTS are assigned in radio_switch_-
complete_XXX functions, hence any change operation on the register done
before is overwritten.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:15 +02:00
Yuval Peress
138f399e6c ztest: run clang-format on ztest_new.c
Clang-format was updated to allow 100 column lines.

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Yuval Peress
86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Vinayak Kariappa Chettimada
4cc5c56d8c Bluetooth: Controller: Fix setting fragment when Periodic Adv is active
Fix implementation to reject setting fragment when periodic
advertising is enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:45:57 +02:00
Vinayak Kariappa Chettimada
fe18625f77 Bluetooth: Controller: Initial Periodic Adv Data fragment op support
Add initial support for Periodic Advertising Data fragment
operation support.

This commit is limited to detection of partial data if used
before Periodic Advertising is enabled, which will lead to
HCI error reason of command disallowed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:45:57 +02:00
Vinayak Kariappa Chettimada
8888681aa8 Bluetooth: Remove deprecated BT_WHITELIST KConfig option
Remove the deprecated BT_WHITELIST Kconfig option. Also,
remove a mention of the deleted bt_conn_create_auto_le API.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:45:44 +02:00
Vinayak Kariappa Chettimada
8b5c84e2aa Bluetooth: Controller: Collision resolution to use ticks_slot_window
When resolving collision if ticks_slot_window is set for
either of the ticker then skip and such ticker be
rescheduled outside the collision within the
ticks_slot_window.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:18:29 +02:00
Marc Lasch
fa84da588d net: lib: lwm2m: Cancel firmware DOWNLOADED state with NULL byte
Allow to cancel a firmware update in DOWNLOADED state by writing a
NULL byte as described in the Firmware Update object version 1.1
(urn:oma:lwm2m:oma:5:1.1). Keep object version 1.0 mechanism with
an `empty string`.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2022-05-23 10:17:52 +02:00
Szymon Janc
ab6d3d36a3 Bluetooth: Controller: lll: Fix warning when building for Nordic
[140/235] Building C object zephyr/subsys/bluetooth/controller/
    CMakeFiles/subsys__bluetooth__controller.dir/ll_sw/ull_sched.c.obj
In file included from zephyr/subsys/bluetooth/controller/ll_sw/
    ull_sched.c:28:
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:
     In function 'lll_adv_pdu_linked_next_get':
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:8:32:
     warning: implicit declaration of function 'MROUND'
     [-Wimplicit-function-declaration]
    8 | #define PDU_ADV_MEM_SIZE       MROUND(PDU_AC_LL_HEADER_SIZE + \
      |                                ^~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:12:11:
     note: in expansion of macro 'PDU_ADV_MEM_SIZE'
   12 |           PDU_ADV_MEM_SIZE - \
      |           ^~~~~~~~~~~~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:197:9:
     note: in expansion of macro 'PDU_ADV_NEXT_PTR'
  197 |  return PDU_ADV_NEXT_PTR(pdu);

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-23 10:05:39 +02:00
Sjors Hettinga
c668199b5d net: tcp: Correctly determine when the TCP transmit window is full
In the stack both unacked_len and send_data_total track the amount
of data for retransmission. send_data_total actually accounts the
total bytes in the buffer, where unacked_len is used to control the
retransmission progress.

Using unacked_len is sometimes reset to 0, this can lead to more data
being allowd in the send_data buffer. In worse case this can cause
depletion of the net buffers, causing a stall and crash of the connection.

The value send_data_total actually accounts the total amount of data in
the send_data buffer, so it is the proper value to used in the
tcp_window_full function.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-20 19:24:26 -07:00
Vinayak Kariappa Chettimada
ca2701d6d8 Bluetooth: Controller: Rework instant based procedure complete event
Rework instant based procedure complete event generation to be
held until after the on-air instant has elapsed, to have
conditional compilation around the code where the event
generation be held or immediately dispatched so that it
improves readability.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-20 19:22:59 -07:00
Vinayak Kariappa Chettimada
4c674aa1f2 Bluetooth: Controller: Fix instant based procedure complete event
Fix instant based procedure complete event generation to be
held until after the on-air instant has elapsed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-20 19:22:59 -07:00
Marek Pieta
903672c394 bluetooth: att: Fix L2CAP channel section order
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.

Fixes #45820

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2022-05-20 12:43:16 +02:00
Szymon Janc
6a9243c13e Bluetooth: Controller: LLCP: Fix handling of invalid DLE parameters
If peer sents invalid value in DLE request or response just ignore
those and keep using old values when calculating effective DLE.

This was affecting following qualification test cases:
LL/CON/PER/BI-10-C
LL/CON/PER/BI-11-C
LL/CON/PER/BI-12-C
LL/CON/CEN/BI-07-C
LL/CON/CEN/BI-08-C
LL/CON/CEN/BI-09-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-20 12:38:30 +02:00
Sjors Hettinga
2d824f4811 net: tcp: Removed copy of conn->unacked_len
In the function tcp_send_data, the variable conn->unacked_len in copied
into a local variable pos. This value is only used in one location and
used mixed with the original conn->unacked_len.

This fix removes pos and switches to use conn->unacked_len everywhere
to reduce the chance of confusion. This does not functionally change the
code.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-20 12:38:24 +02:00
Thomas Ebert Hansen
5d80dbd388 Bluetooth: controller: llcp: Fix terminate timer
Add the missing terminate timer for the ACL Termination procedure.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-05-20 12:37:49 +02:00
Flavio Ceolin
ac2e13b9a1 net: tcp: Fix possible buffer underflow
Fix possible underflow in tcp flags parse.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-05-20 12:36:42 +02:00
Erik Brockhoff
843a24924f Bluetooth: controller: llcp: terminate conn on conn update past instant
Terminate connection when Connection Update with instant in the past
Fix type re. win_offset calc in conn update ind pdu decoder
Remove feature bit on unsupported in peer

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-20 12:33:59 +02:00
Andries Kruithof
c2e07a304b Bluetooth: controller: llcp: send correct collision code
Upon collision either the error code for different procedure
collision or same procedure collision must be transmitted,
which is fixed in this PR. Previously always the error code
for same procedure collision was sent

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-20 10:29:46 +02:00
Vinayak Kariappa Chettimada
d84c5496a6 Bluetooth: Controller: Add Extended Advertising Type Validations
Add Extended Advertising Type validation when associated
Periodic Advertising is enable, and Extended Advertising
set is re-configured to other advertising types.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-19 16:05:35 +02:00
Piotr Pryga
364a8c2786 Bluetooth: Controller: df: CTE req not disabled if run in single shot
There is an error. CTE request control procedure can be run in single
shot or periodic mode. In case of run in single show, it is not
disabled after completion.

The code responsible for the disable was deleted by commit:
ac7d0506f88508e7440288c1ec4319a9f7d0ad44.

The cte_req.is_enabled should be set to zero if the CTE request
completes and cte_req.req_interval is zero.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:22:11 +02:00
Piotr Pryga
9e6f566858 Bluetooth: Controller: llcp: Add handling of unexpe CTRL PDU by CTE req
There was missing code responsible for handling of unexpected response
for CTE request. The commit adds code that will terminate connection
in case a peer device reposnes with unexpected control PDU that is not
a remote procedure reques.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga
2890f42545 Bluetooth: Controller: df: Fix CTE reqest proc enable if feat supported
The CTE request procedure should be enabled only if a peer supports
CTE response feature. That information can be obtained by feature
exchange procedure. If there were no feature exchange then CTE
request feature may be disabled if a peer responses with LL_UNKNOWN_RSP
for a CTE request.

The implementation of ll_df_set_conn_cte_req_enable was checking if
CTE response feature is supported only when there was feature exchange.
There was missing possibility to stop CTE request if a peer responded
with LL_UNKNOWN_RSP for an earlier CTE request.

The commit changes the implementation of ll_df_set_conn_cte_req_enable.
The CTE response feature check is moved to ull_cp_cte_req function,
because it belongs more to control procedure than to function that
handles Host request to start the procedure.
Second change is related with use of conn->llcp.fex.features_used.
It stores information about features supported by peer. It does
not depend on execution of the feature exchange control procedure.

By the way, there were removed else statement in ll_df_set_conn_cte_-
req_enable because it was not needed.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga
40cdd65901 Bluetooth: Controller: llcp: add missing handling LL_UNKNOWN in CTE llcp
There was missing handling of LL_UNKNOWN_RSP in CTE request control
procedure.In case there is a pending CTE request and peer responses
with LL_UNKNOWN_RSP then Host should be notified with HCI_LE_CTE_-
Request_Failed event. The pending CTE request procedure should be
completed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Vinayak Kariappa Chettimada
4b7146bf18 Bluetooth: Controller: Add missing void in memcpy calls
Minor convention changes to have void in memcpy function
calls.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-18 13:56:53 +02:00
Vinayak Kariappa Chettimada
6976b03fe4 Bluetooth: Controller: Fix handling of AD Data unchanged operation
Fix handling of AD Data set with operation type of
unchanged data with respect to invalid parameter and
state of Periodic Advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-18 13:56:53 +02:00
Vinayak Kariappa Chettimada
a57e284201 Bluetooth: Controller: Fix nRF51x advertising channel PDU regression
Fix nRF51x series advertising channel PDU S1 byte
configuration regression, that causes corrupted advertising
PDUs being reported to Host, by adding the missing bits_s1
local variable initialization.

Regression introduced in commit 1dcbe73cc8 ("Bluetooth:
controller: radio: add setting of S1 byte in radio packet").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-18 13:56:36 +02:00
Robert Lubos
8ba5990766 net: sockets: Implement POLLOUT for stream sockets
Implement POLLOUT for stream sockets, based on newly introduced tx_sem
functionality of the TCP stack.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00
Robert Lubos
86105fb795 net: sockets: Monitor TCP transmit state with semaphore
Utilize the TCP semaphore monitoring transmit status at the socket
layer. This allows to resume transfer as soon as possible instead of
waiting blindly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00
Robert Lubos
d35d9a6158 net: tcp: Implement persistent timer for sending ZWP
Instead of sending ZWP from send context, when it is detected that
window is full due to zero-window, implement a proper persistent timer,
that is scheduled once zero-window is detected. The timer is responsible
for sending ZWP to the peer and is canceled once non-zero-window is
notified by the peer.

Additionally, in case peer reported zero-window, do not trigger
retransmission from net_tcp_queue_data(), as it won't be transmitted
anyway by the stack.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00
Robert Lubos
7eaacdaca6 net: tcp: Add semaphore indicating if transfer is possible
The semaphore is reset when TCP layer would normally reject transfer
request (either due to TX window being full or entering retransmission
mode). Once data is acnowledged, or the reatransmission is done, the
semaphore is set again.

Upper layers can monitor the semaphore with `k_poll()` instead of
waiting blindly before attempting to transmit again.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00
Herman Berget
e3ed783359 Bluetooth: Host: Fix missing callback in bt_gatt_write_without_response
The meta data was not set on the buffer.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-17 11:39:26 +02:00
Piotr Pryga
bb7a67d5be Bluetooth: Controller: Fix per sync cancel and sync establ synchronize
Current implementation of ll_sync_create_cancel does not allow to stop
synchronization after ull_sync_setup is called. When that is done,
sync->timeout_reload is not zero and the ll_sync_create_cancel will
return BT_HCI_ERR_CMD_DISALLOWED. That means the Controller is able to
cancel periodic advertising synchronization only in period between
call to ll_sync_create and reception of AUX_ADV_IND that has SyncInfo
field.

The Controller should be able to cancell synchronization until first
AUX_SYNC_IND PDU is received and host notified about synchronization
established.

Complete information about synchronization status is provdied by two
ll_sync_set members: node_rx_sync_established and timeout_reload.
These two members of the structure were used in ll_sync_create_cancel
function to do a proper cancel and cleanup.
The node_rx_sync_established member was not cleared when sync was
established or expired. That was required to get a proper information
about synchronization state.

Besides that, to avoid race condition between ll_sync_create_cancel
and ull_sync_established_report, the latter function was extended
to check if cancel operation or sync lost has happened.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-17 11:39:09 +02:00
Vinayak Kariappa Chettimada
79dbfc108a Bluetooth: Controller: Remove experimental from Ext and Periodic Adv
Remove experimental label from Advertising Extensions and
Periodic Advertising features in the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-16 18:25:14 +02:00
Andries Kruithof
0c8f73da18 Bluetooth: controller: set refactored LLCP as default for DF
This PR sets the refactored LLCP as the default instead of legacy
so that more people will use this, giving us more feedback

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-16 18:02:20 +02:00
Carlo Caione
11f0bb9d1a ipc: static_vrings: Add -ENOMEM case
Sometimes it is important to know when the backend fails to send out
data because no memory / buffers are available. Return -ENOMEM in that
case.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-16 16:56:33 +02:00
Matthias Wauer
ba14fc4745 mgmt: img_mgmt: fix typo in variable name
The correct variable name is 'action'

Signed-off-by: Matthias Wauer <matthiaswauer@gmail.com>
2022-05-16 16:56:18 +02:00
Mariusz Skamra
fd87b39d80 Bluetooth: ascs: Fix compilation warning
This fixes uninitialized `ret` variable compilation warning.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-16 16:56:11 +02:00
Mariusz Skamra
d5147803f0 tests: btshell: Fix the HAS server shell dependency
Enable HAS shell only if preset support is enabled. Otherwise there are
no functions yet that can be exposed if the preset support is disabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-16 16:56:11 +02:00
Mariusz Skamra
8f1c4f36ba Bluetooth: has: Fix compliation warning
Fix unused `ccc_cfg_changed` function warning that shows up when
preset support is disabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-16 16:56:11 +02:00
Mariusz Skamra
e5aad57fc5 Bluetooth: has: Introduce BT_HAS_PRESET_SUPPORT helper symbol
Introduce invisible helper symbol that could simplify and make more
readable condiitional code checks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-16 16:56:11 +02:00
Asbjørn Sæbø
af607bb886 Bluetooth: Gatt: Update users of write callback in subscription params
Update the users of the "write" callback in the
bt_gatt_subscribe_params to use the new "subscribe" callback instead.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-05-16 16:54:27 +02:00
Asbjørn Sæbø
bf361aff21 Bluetooth: Gatt: Replace callback in gatt subscription callback.
Add a "subscribe" callback in the bt_gatt_subscribe params, and
deprecate the "write" callback.

The purpose of this is to be able to return the subscription
parameters in the callback.  The write callback
- (in principle) returns write parameters
- in fact returns nothing - the pointer is set to NULL

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-05-16 16:54:27 +02:00
Piotr Pryga
0a497fcd55 Bluetooth: Controller: df: Fix wrong ant after switch pattern exhausted
Direction finding functionality does antenna switching during CTE
reception in AoA mode and CTE transmission in AoD mode. Antennas are
switched according to user provided antenna switch pattern. If a CTE
length is enough to exhaust all antenna ids in a switch pattern then
radio should loopback to reference antenna and continue from switching
from that. Current implementation loops back to antenna that is just
after reference antenna in the switch pattern.

The commit fixes that by insertion of the reference antenna
at the end of switch pattern. Radio will operate as it was before,
it will restart switching from the same index in a switch pattern.
At the same time reference antenna will be inserted into the loop
if switching pattern is exhausted. That also means, the maximum
number of antenna ids in a switch pattern has to be decreased by
one.

The commit also fixes lower bound in the BT_CTLR_DF_MAX_ANT_SW_PATTERN-
_LEN that should be equal two. It was set to three, because in the
past the antenna at index zero was used for reception of a PDU.
Now this antenna ID is provided by device tree configuration.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-16 10:08:48 +02:00
Piotr Pryga
5a6ed86d46 Bluetooth: df: Split CTE filtering SYNC_STAT_READY_OR_CONT_SCAN
The SYNC_STAT_READY_OR_CONT_SCAN state into two: SYNC_STAT_READY
and SYNC_STAT_CONT_SCAN. The connected state was used for two
cases:
- synchronization with periodic advertising is already established,
- CTE type is wrong but periodic advertising list is used to filter
synchronized devices.
In the past states were connected because there was only one difference
between them. In case of sync already established, Controller generated
sync report notification to host.The sync was not terminated when
Controller was about to continue search for other periodic advertiser.

The state was split because now Controller terminates sync ticker and
continues search for other periodic advertised. The split improves
readability and makes code easier to understand.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-16 10:08:06 +02:00
Piotr Pryga
3715241bde Bluetooth: Controller: fix per sync hang if wrong cte and list filter
In case of use of filtering based on: periodic advertising list and
CTE type, the synchronization can hang. That is possible if a periodic
advertiser uses wrong CTE type. In such situation the sync is not
released in ull_sync_done call. What more the sync->timeout_reload
is not cleared and Host is not able to cancel the synchronization.
The periodic advertising is in a semi-sync-established state.
There are no reports send to Host. Host can't use the sync set to
synchronize with other device. It is only able to terminate the
sync (call to ll_sync_terminate).

To fix the issue following changes should be applied:
- isr_rx_adv_sync_estab should call isr_rx_done_cleanup
with sync_term parameter in case the sync_ok isn't SYNC_STAT_ALLOWED.
In any case the CTE type is wrong, no matter is the periodic
advertising list filtering is enabled or not.
- ull_sync_established_report should set sync->is_term to true
in case the CTE type is not allowed. That change is required for devices
that do not support Direction Finding Extension. For those devices CTE
type based filtering is done in ULL by ull_sync_established_report
function. The sync->is_term should be set unconditionally, hence is
moved up in the function.

With these two changes done, ull_sync_done function will execute
sync_ticker_release in case the CTE has wrong type. ULL, depending on
notifications prepared by ull_sync_established_report, will follow up
on sync termination if required.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-16 10:08:06 +02:00
Erik Brockhoff
876772f82e Bluetooth: controller: llcp: terminate conn. on past instant for chmu
In case a channel map is requested for an instant in the past
connection is terminated.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-16 09:41:23 +02:00
Erik Brockhoff
9498310c53 Bluetooth: controller: Implement cross connection CPR mutual exclusion
Porting mechanism as used in legacy LLCP to refactored CPR.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-16 09:40:36 +02:00
Erik Brockhoff
4ae3dc8cb2 Bluetooth: controller: Impl. check for active remote initiated CPR
Checking if a remote initiated CPR is currently active on given conn

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-16 09:40:36 +02:00
Erik Brockhoff
3e5b004d62 Bluetooth: controller: moving CPR cross connection serialization
Moving to allow using the mechanism with refactored LLCP

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-16 09:40:36 +02:00
Jordan Yates
e83e9b08b5 pm: device_runtime: return -ENOTSUP if PM not supported
Return `-ENOTSUP` on calls to device_runtime functions if the underlying
device does not support power management.

Fixes #45648.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-15 21:34:46 +02:00
Dominik Ermel
578cb132ff mgmt/mcumgr/lib: Make version string work with CONFIG_NEWLIB_LIBC
By default the newlib does not compile with %hhu processing,
to avoid turning on additional options for newlib compilation
this commit changes formatting string to use %hu instead.
The commit fixes problem with malformed version string being
returned, by smp_svr, when CONFIG_NEWLIB_LIBC=y is set together
with CONFIG_NEWLIB_LIBC_NANO=y.

Fixes #45261

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-15 21:33:05 +02:00
Dominik Ermel
0c051d0dd6 mgmt/mcumgr/lib: Fix astray dot in image version
Removed the dot.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-15 21:33:05 +02:00
Emil Gydesen
bcfb4df390 Bluetooth: ISO: Modify and add more debug for setup iso data path
Modify the function slightly to take a different
argument, and add more debugging to the function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Emil Gydesen
f67e12ae8e Bluetooth: ISO: Add check for can_send in bt_iso_chan_send
Ensure that we don't attempt to send any data to the
controller if `can_send` is not set, and return an
error code to the application instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Emil Gydesen
24e38e90db Bluetooth: ISO: Use can_send, can_recv when setting up data paths
Besides checking for the rx/tx pointer, we now also validate
the can_send and can_recv values to ensure that we do
not setup a useless data path.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Emil Gydesen
2660c17c31 Bluetooth: ISO: Set can_send/can_recv for broadcast channels
Set the can_send to true and can_recv to false for broadcaster.
Set the can_send to false and can_recv to true for the sync
receiver.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Emil Gydesen
b88b25adac Bluetooth: ISO: Extract and store information about RX and TX
Instead of relying only on the `tx` and `rx` qos pointers,
we extract further information from the
bt_hci_evt_le_cis_established event to properly determine if we
can actually send or receive data.

This is useful to help determine which data paths to setup,
and whether to reject requests to send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Alexej Rempel
476d199752 logging: shell: fix shell stats null pointer dereference
If CONFIG_SHELL_STATS is disabled, shell->stats is NULL and
must not be dereferenced. Guard against it.

Fixes #44089

Signed-off-by: Alexej Rempel <Alexej.Rempel@de.eckerle-gruppe.com>
2022-05-15 21:32:10 +02:00
Emil Gydesen
0380f1180d Bluetooth: Audio: Remove unicast client iso listen
Remove call to bt_audio_stream_iso_listen which
calls bt_iso_server_register for the unicast client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-13 12:44:47 -07:00
Emil Gydesen
fb8ee77efb Bluetooth: ISO: Update ISO shell for split config support
The bluetooth ISO shell module now supports the newly
added central and peripheral ISO configs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-13 12:44:47 -07:00
Emil Gydesen
75bc421664 Bluetooth: ISO: Change some functions to static
There were a few local functions that were not
defined as static even though they could.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-13 12:44:47 -07:00
Emil Gydesen
4e557d71cc Bluetooth: ISO: Move functions around to reduce number of guards
Move a few unicast functions around so that we reduce the number
of #if defined guards. No code has changed, but a single
prototype has been added.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-13 12:44:47 -07:00
Emil Gydesen
3a68de4fba Bluetooth: ISO: Update ISO Kconfig for EXPERIMENTAL
Ensure that any Kconfig with [EXPERIMENTAL] in the
description, also selects EXPERIMENTAL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-13 12:44:47 -07:00
Emil Gydesen
3f247b212b Bluetooth: ISO: Add Kconfig for ISO central/peripheral
Add two new Kconfigs: BT_ISO_CENTRAL and BT_ISO_PERIPHERAL
that is used to do central or peripheral only builds,
similar to the BT_CENTRAL or BT_PERIPHERAL Kconfigs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-13 12:44:47 -07:00
Anas Nashif
dacca51266 ztest: use TESTSUITE instead of test suite in output
output of ztest is not easy to ready with many testsuites running in
sequence, make it a bit more readable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Flavio Ceolin
bbb8c91afa pm: Fix possible race condition in multicore
There is a race condition in a multicore system that happens when the
idle thread in a CPU checks if the state was forced, if not it will
call the policy manager. If a secondary core forces a state after that
this point the value returned by the policy will be rewritten.

Another case is, if a state is forced while a CPU is sleeping,
when this CPU resumes, the forced bit is cleared and the forced state
is never be used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-05-13 08:48:29 -07:00
Flavio Ceolin
2b02843ca3 pm: Remove unnecessary goto
In pm_system_suspend there is a goto label that is supposed to be used
to do cleanup before exit the function but it is not doing anything
right now. Just remove it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-05-13 08:48:29 -07:00
Mariusz Skamra
2747665a2e Bluetooth: has: Fix missing dependency
This fixes missing UTF8 dependency. HAS makes use of utf8_lcpy.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Mariusz Skamra
bc42cbd174 tests: shell: Add Read Presets Request to HAS client shell
This extends shell with Read Presets Request command.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Mariusz Skamra
2d87443a4a Bluetooth: has: Add support for Read Presets Request operation
This extends client implementation with Read Presets Request operation
support.
The implementation can maintain up to BT_L2CAP_TX_BUF_COUNT control
point requests so that user could perform/queue another Control Point
Operation if one is ongoing. E.g. preset can be selected from Read Preset
Response notification context or perform multiple operations if EATT
enabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Mariusz Skamra
305d5bc119 tests: shell: Add shell for HAS client
This adds shell module for HAS client with it's initial functionality.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Piotr Pryga
e81414d28f Bluetooth: Controller: Fix CTE_REQ disable lock if there is no CTE_RSP
The periodic CTE_REQ disable command, requested by Host, may be locked
until connection is dropped due to missing CTE_RSP from peer device.
That is caused by implementation of CTE_REQ disable and CTE_REQ
control procedure handling.

The procedure is marked as active when CTE request was send to peer
device. It is marked as inactive after completion of the procedure.
That caused locking of CTE disable on a semaphore.

The BT 5.3 Core Spec, Vol 4, Part E, section 7.8.85 says the HCI_LE_-
Connection_CTE_Request_Enable should be considered active on a conne-
ction from when Host successfully issues the command with Enable=0x1
until a command is issued with Enable=0x0 or single LLCP CTE request
has finished (CTE_Request_Interval=0x0). Also there is a clarification
from BT SIG that the command with Enable=0x0 does not affect any
initiated LLCP CTE request. That means Controller is allowed to finish
already started procedure and it is not allowed to start new LLCP CTE
request procedure after completion of the command with Enable=0x0.

Taking that into account, there is no need to synchronize ULL and LLL
in regard of disable the LLCP CTE request while the procedure is
pending. Controller is free to complete the procedure or terminate it.

The change removes all code related with cte_req.is_active, disable
callback and waiting of ULL for LLL to finish the LLCP CTE request.

The ULL will complete the HCI_LE_Connection_Request_Enable with
Enable=0x0 immediately. In case the procedure is disabled in before
the response arrives, then further processing of the response is
dropped and the procedure context released.

The context is not released by the code responsible for disable
handling, to have single place where it is done.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-13 10:25:39 -05:00
Piotr Pryga
1004c30507 Bluetooth: Controller: Fix CTE req periodically after req is disabled
There is an error in the condition that checks if new CTE_REQ should
be started after end of connection event. The condition verifies if
counter req_expire is set to zero. Then new CTE_REQ is started
irrespectively to CTE_REQ being disabled.

req_interval is used to store information if the CTE_REQ is:
- periodic, then value doesn't equal zero,
- single shot or disabled, then value equals zero.

The condition should verify if the req_interval is not zero and
req_expire is not zero. The second part of the if condition is
required to avoid starting next CTE_REQ until last one has been
completed.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-13 10:25:39 -05:00
Piotr Pryga
c167122ce8 Bluetooth: Controller: llcp: Set remote LLCP rx_opcode to type unused
Some of control procedures has set ctx->rx_opcode in rp_comm_tx
function to values that state there is an expected PDU.
This is not always true. In case of procedures that do not expect
any response from remote device, the ctx->rx_opcode should be set
to PDU_DATA_LLCTRL_TYPE_UNUSED.

In the worst cases scenario, when the same control procedure
is executed locally and remotely, correct response PDU may
cause an assertion in  ull_cp_rx. It could happen because
of wrong ctx->rx_opcode value. A packet with opcode that is
set in remote and local control procedure context rx_opcode
will be treated as expected value for both. That is a situation
that cannot happen.

The commit changes the assignments of rx_opcode to fix the problem.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-13 10:23:34 -05:00
Gerhard Jörges
6be558af5b shell: check echo flag in z_shell_cursor_in_empty_line()
If the echo flag is disabled the cmd_buff isn't printed and the
characters in it must not be counted in this function.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-05-13 10:22:17 -05:00
Veijo Pesonen
b18f93dbc4 net: lwm2m: Fix SenML CBOR input basename length
Server might send the whole path in the basename when doing composite
write.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-05-13 10:15:27 -05:00
Veijo Pesonen
082fe9733c net: lwm2m: Adds missing SenML CBOR range check
Adds a check that number of records to be encoded does not exceed the
maximum limit configured through Kconfig.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-05-13 10:15:27 -05:00
Damian Krolik
0856b9790a settings: add shell commands to write and delete settings
Existing settings shell allows for listing and reading
settings only. Add the following two commands:

settings delete <key>
settings write <key> <value-encoded-in-hex>

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-05-13 10:11:40 -05:00
Andries Kruithof
a883e77241 Tests: bluetooth: fix build errors for bluetooth testcases
This commit fixes the build errors for the testcases in
the tests/bluetooth/init folder

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-13 08:56:12 -05:00
Andries Kruithof
d201055e70 Tests: bluetooth: fix ctrl_user_ext test
The tests/bluetooth/ctrl_user_ext test fails due to
compilation errors, which are fixed with this PR

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-13 08:56:12 -05:00
Robert Lubos
78e8e0da42 net: sockets: Make use of the status field reported by TCP
Make use of the status field, reported by TCP, in the socket receive
callback. This allows to differentiate a graceful connection shutdown
from actual errors at TCP level (transmission timeout or RST received).
In case of error reported from TCP layer, set a new SOCK_ERROR flag on
the socket, and store the error code in the net_context user_data.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-13 15:42:01 +02:00
Robert Lubos
0b27f4b2f9 net: tcp: Report TCP errors through recv_cb()
Make use of the status argument in the recv_cb() callback function -
instead of blindly reporting ECONNRESET whenever TCP context is
dereferenced, indicate whether an actual error condition happened (by
setting respective errno value) or a graceful shutdown took place (by
setting status to 0).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-13 15:42:01 +02:00
Pavel Vasilyev
1efce43a00 Bluetooth: Mesh: Fix segmentation when sending proxy message
Previous check in the if-statement would never allow to send last
segment if msg->len + 2 == MTU * x.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-05-13 15:45:22 +03:00
Jordan Yates
f2b8a9918f ztest: Add zassert_between_inclusive macro
Added macro to test that a value falls within a defined range, including
the provided end points.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-13 14:17:08 +02:00
Eduardo Montoya
78a2d237d0 net: openthread: add support for PSA MAC keys
Get actual keys from references when PSA crypto is enabled.
A more secure method should be implemented once 802.15.4 platforms
support other than clear text keys.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-05-13 13:27:04 +02:00
Eduardo Montoya
ef30cf58c1 net: openthread: implement otPlatRadioGetCslUncertainty
Implement the OpenThread API to retrieve the platforms CSL
Uncertainty.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-05-13 13:22:48 +02:00
Andrey Dodonov
bc0cf10757 net: tcp: Remove unused config NET_TCP_BACKLOG_SIZE
Remove NET_TCP_BACKLOG_SIZE from KConfig and from test,
because it's not present anymore in current version of TCP stack.

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2022-05-13 13:04:59 +02:00
Jamie McCrae
9e6b5cdca8 mgmt: mcumgr: lib: img: Add image header to callback
This allows an application to inspect a mcumgr img upload command to
provide additional information for acceptance or rejection of it, and
makes the previous private version compare function public so that
application code can call it.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-05-11 20:32:52 +02:00
Al Semjonovs
47850a301c ztest: Add config to shuffle test order
Enable ZTEST_DO_THE_SHUFFLE to shuffle the order tests are ran.
Additional configs ZTEST_DO_THE_SHUFFLE_SUITE_REPEAT_COUNT
ZTEST_DO_THE_SHUFFLE_TEST_REPEAT_COUNT specify the number of times
the test or suite is executed.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-05-11 12:14:31 -04:00
Jamie McCrae
6a85b1b0d3 mgmt: mcumgr: lib: fs: Add file read/write access callback
This allows an application to inspect a mcumgr file access command and
either allow it or deny it with a result code.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-05-11 17:10:55 +02:00
Robert Lubos
5af3c6ca90 net: tcp: Fix possible deadlock in tcp_in()
After introducing SO_SNDBUF socket option, a possible deadlock situation
slipped into the TCP implementation. The scenario for the deadlock:

  * application thread tries to send some data, it enters
    net_context_send() which locks the context mutex,
  * internal context_sendto() blocks on a TX packet allocation, if the
    TX pool is empty rescheduling takes place,
  * now, if at the same time some incoming packet has arrived (ACK for
    example), TCP stack enters tcp_in() function from a different
    thread. The function locks the TCP connection mutex, and tries to
    obtain the SNDBUF option value. net_context_get_option() tries to
    lock the context mutex, but it is already held by the transmitting
    thread, so the receiver thread blocks
  * when TX packet is available again, the transmitting thread unblocks
    and tries to pass the packet down to TCP stack. net_tcp_queue_data()
    is called which attempts to lock the TCP connection mutex, but it is
    already held by the receiving thread. Both threads are in a deadlock
    now with no chance to recover.

Fix this, by obtaining the SNDBUF option value in tcp_in() before
locking the TCP connection mutex.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-11 11:04:22 +02:00
Robert Lubos
b8b5738809 net: openthread: Skip solicited-node mcast addresses creation
Thread network makes no use of Solicited-node multicast addresses,
thereby do no create them on the interface to save multicast address
entries for important ones.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-11 11:03:26 +02:00
Robert Lubos
7acafda858 net: openthread: Fix possible deadlock in net_mgmt handlers
There is a risk of deadlock in case net_if APIs are used from within
net_mgmt handlers as both module APIs are protected with their own
mutexes.

The scenario observed with OpenThread happend when
NET_EVENT_IPV6_ADDR_ADD/NET_EVENT_IPV6_MADDR_ADD events were processed.
The net_mgmt mutex is locked when both, an event handler is being
processed (from a separate net_mgmt thread) and when an event is raised
(for example when a new address is added on an interface). In case a
net_mgmt handler tried to use some mutex-protected net_if API, we could
end up in a deadlock situation - the net_mgmt would wait for the net_if
mutex to release, while some other thread (in this case main during
initialization) could wait within some net_if function, pending on
net_mgmt mutex to be released to notify the event.

Fix this, by preventing net_if APIs from being used from within OT
net_mgmt handlers.

Additionally, simplify the net_mgmt handlers logic, by making use of
additional info provided with an event. Instead of blindy assuming that
recently added address was the last on the list (which might not always
be the case, if addresses are added/removed dynamically), read the
actual address being added from the net_mgmt_event_callback structure.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-11 11:03:26 +02:00
Emil Gydesen
83c7baf34a Bluetooth: Audio: Add recv_info to audio recv callback
The audio stream receive callback now contains a
recv_info struct, which contain crucial information
such as timestamps and packet validity.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:28 +02:00
Emil Gydesen
6191a76f55 Bluetooth: Audio: Add _DIR_ infix to BT_AUDIO_SINK/SOURCE
The values represent an enum, and it makes sense for the
enum values to follow the enum type name, so an
_DIR_ infix was added to the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
0a4e62addd Bluetooth: Audio: Remove PAC_TYPE_UNUSED
The PAC_TYPE_UNUSED would be breaking
enum rules, as it is setting and comparing
a value outside the enum range.

Instead we check if the `dir` field has been
set to SINK or SOURCE.

The reason why this still works, is that
we memset the struct unicast_client_pac
causing `dir` to become 0. This still
does not really follow the rules of enums, but
it is the best we can do without adding another
value to determine if a struct unicast_client_pac
is unused or not, without adding another value to
public enum struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
19d7420f07 Bluetooth: Audio: Standadize the use of enum bt_audio_dir
Many functions and struct fields had the directory/type
value, but named in different ways and stored in different ways.

This change updates all uses of it to use the same name
and type.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
6b41e9991d Bluetooth: Audio: Rename enum bt_audio_pac_type
The enum bt_audio_pac_type does not fully
represent the what the value is used for.

The typical use of it is not for just published
audio capabilities (PAC), but rather describes the
type, or direction, of audio endpoints.

For the unicast client, the type/direction is
relative to the unicast server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
306d766329 Bluetooth: Audio: Unicast client remove id from ep_init
The unicast_client_ep_init took a ID value that was
always 0. Moved the initialization to the value to
the function, instead of an argument. The value
is only used for the unicast server, so it can
probably be removed from the endpoint
struct for unicast clients only. To be optimized later.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
7d134e4e1d Bluetooth: Audio: Remove unused endpoint types
The endpoint.type field was unused as it was
always LOCAL for the unicast server and always
REMOTE for the unicast client, and the few places
where we actually checked it, we already had a
check for acl->role which gave the same value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Morten Priess
e74804c125 Bluetooth: controller: Removed compiler warnings in ull_iso.c
Conditionally declared auto-variables to avoid 'unused' warnings in BSIM
ISO test compilation.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-05-10 18:55:35 +02:00
Herman Berget
874ef53b17 Bluetooth: Host: Assert that all channels in request have the same PSM
The PSM of the first channel in the connection request is used, but the
PSM value is used for all of them on the receiving side.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-10 18:40:36 +02:00
Herman Berget
1069d5fe56 Bluetooth: Host: Fix L2CAP collision mitigation
There were some errors in the detection of ECRED connection collisions,
so the retry was triggered incorrectly.

The number of channels requested in the retry was wrong in some cases,
using the number of channels from the received request instead of the
sent request.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-10 18:40:36 +02:00
Daniel Leung
6ec1fcc214 logging: syst: embed log message source IDs in Sys-T messages
This embeds the log message source IDs inside the origin unit
as module IDs in Sys-T messages. This allows Sys-T message
parsers to see where the log messages are coming from.

This is enabled by default if using Sys-T catalog messages as
the collateral XML file contains the information to interpret
the module ID.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-05-09 12:54:53 -05:00
Daniel DeGrasse
e36c31a001 usb: dfu: Enable progressive erase for MCUX FlexSPI flash
Devices using the MCUX FlexSPI flash driver erase their flash too
slowly, causing the usb stack to freeze, and USB DFU utilities to
report a timeout. Enable IMG_ERASE_PROGRESSIVELY for SOCs using the
MCUX FlexSPI driver to prevent this error.

Fixes #45359

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-05-09 08:54:30 -05:00
Daniel DeGrasse
7840b07121 sd: increase SDMMC busy wait timeout
SDMMC busy wait timeout was incorrectly waiting for
CONFIG_SD_DATA_TIMEOUT microseconds, but should be waiting for
CONFIG_SD_DATA_TIMEOUT milliseconds. Multiply wait value by 1000.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-05-09 08:46:29 -05:00
Gerard Marull-Paretas
5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Vinayak Kariappa Chettimada
3702f7220a Bluetooth: Controller: Fix cte_info may be used uninitialized error
Fix cte_info may be used uninitialized compile error.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-09 09:28:34 +02:00
Vinayak Kariappa Chettimada
3af3c1237c Bluetooth: Controller: Restrict AD Data to BT_CTLR_ADV_DATA_LEN_MAX
Strictly restrict AD Data length to BT_CTLR_ADV_DATA_LEN_MAX
when there can be free bytes in Advertising PDU with common
extended header format of less that the maximum 64 bytes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-09 09:28:34 +02:00
Emil Gydesen
9defebbfd3 Bluetooth: Audio: broadcast_sink_sync array of stream pointers
Change bt_audio_broadcast_sink_sync to use an array of pointers
to bt_audio_streams, instead of an array of streams. This makes
the API more flexible, as well consistent with the broadcast
source and unicast APIs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Emil Gydesen
5628b29b01 Bluetooth: Audio: broadcast_source_create array of stream pointers
The bt_audio_broadcast_source_create function will now
take an array of stream pointers, instead of an array
of streams. This is to make the API more flexible as
well as more consistent with the unicast API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Emil Gydesen
6e60451e09 Bluetooth: Audio: Change array of unicast streams to array of pointers
In bt_audio_unicast_group_create, bt_audio_unicast_group_add_streams
and bt_audio_unicast_group_remove_streams to use an array
of pointers, instead of an array of streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Mariusz Skamra
4730f72fb6 Bluetooth: test: Extend HAS shell with preset availability funcs
This extends shell with commands that can modify the preset
availability.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-09 09:27:09 +02:00
Mariusz Skamra
2314aa2977 Bluetooth: has: Add Preset Changed operation support
This extends implementation with sending Preset Changed
notification/indication when preset changes its availability or is
added or deleted.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-09 09:27:09 +02:00
Gerard Marull-Paretas
a4eac53b9e ztest: add support for new and legacy include paths
The ztest unittest module relies on some headers that fake the real
ones, e.g. <zephyr/arch/cpu.h>. When new header location was introduced,
their path was not updates. This patch fixes this problem and provides
ztest with both, legacy and new include paths so that it can keep
working on both scenarios.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:03:00 +02:00
Piotr Pryga
c18477ad25 Bluetooth: Controller: llcp: fix wrong cond in prepare instant
In a function pu_prepare_instant there is a condition that
checks if there is actual change of a PHY. That condition
was based on ctx->data.pu.tx and ctx->data.pu.rx.
These members store PHY that is or will be used, hence
the condition is wrong. Even there is no actual change in
the PHY, values could be not equal to zero. In such case
the instant value would be set to wrong value.
What more the condition be an 'or' not an 'and' because
one of the values must be different than zero to have the
PHY change and instant different than zero.

After update of the condition, the function call places
must be changed. The ctx->data.pu.c_to_p_phy and
ctx->data.pu.p_to_c_phy are set in pu_prepare_update_ind
function, hence pu_prepare_instant should be called after
that.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-06 11:50:59 +02:00
Vinayak Kariappa Chettimada
4c31f24de7 Bluetooth: Controller: Fix Broadcast and Connected ISO cond. compiles
Fix some of the Broadcast and Connected ISO related
conditional compilations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:32:30 +02:00
Morten Priess
e3342fe01e Bluetooth: controller: ISO TX data path including ISOAL
- ISO TX data path for HCI and support for vendor path
- ISO-AL segmentation of framed PDUs
- Insertion of segment headers
- Reconstruction and storing of CIG reference point in ULL
- Calculation and insertion of of Time-Offset
- Exit error spooling in ISO-AL on detecting start
- ISO-AL TX unframed fragmentation

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-05-06 11:32:30 +02:00
Morten Priess
9d4368251e Bluetooth: host: Set ISO type for CIS at request
Set BT_ISO_CHAN_TYPE_CONNECTED as type for connected ISO at CIS_REQ.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-05-06 11:32:30 +02:00
Vinayak Kariappa Chettimada
9ff0c5c93d Bluetooth: Controller: Enqueue missing ISO PDUs with invalid status
Add implementation to generate node rx for missing ISO PDUs
and set the status as invalid. This is required for ISOAL to
correctly track the sequence numbers for every SDU interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:32:11 +02:00
Vinayak Kariappa Chettimada
d04f5917bf Bluetooth: Controller: Add Ext Adv Parameter Validations
Add Extended Advertising interval parameter validation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:31:44 +02:00
Vinayak Kariappa Chettimada
371d078654 Bluetooth: Controller: Add Kconfig to limit advertising interval max
Add Kconfig to limit the Primary Advertising Interval and
Periodic Advertising Interval maximum supported values in
the Controller implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:31:44 +02:00
Emil Gydesen
177bdff61b Bluetooth: Audio: Fix order of checks in bt_audio_stream_qos
The bt_audio_stream_qos function checked if stream->ep was
NULL before checking if the stream were even valid for this
QoS procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-06 11:30:37 +02:00
Emil Gydesen
316cc7141c Bluetooth: Audio: Add NULL check when creating the CIG
When create the CIG for a unicast group, we did not
verify whether stream->iso was NULL before attempting
to use that to create the CIG.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-06 11:30:29 +02:00
Robert Lubos
5cefcf80e9 net: sockets: Move offloading out of experimental
Socket offloading has been in the tree for a while and improved a lot
over time (from a simple define-based API override to a complex
vtable-based solution, supporting mutliple offloaded interfaces). As the
feature is heavily used by certain vendors (Nordic and its nRF Connect
SDK), I propose to move it out of experimental phase.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-06 11:30:22 +02:00
Herman Berget
5b0deb058b Bluetooth: Host: Remove unused nfy_mult_data
After adding the more general ATT meta data, it is no longer used.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-05 14:42:38 -05:00
Rubin Gerritsen
b51353628a Bluetooth: Controller: DF configs should not depend on BT_LL_SW_SPLIT
None of the common DF configs should depend on using BT_LL_SW_SPLIT.
Added dependencies to it where this was the case.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Rubin Gerritsen
aec5307ac9 Bluetooth: Controller: Make some DF configs specific to BT_LL_SPLIT
These configurations are tighlty coupled to the implementation,
so these should be hidden when not using BT_LL_SW_SPLIT.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Rubin Gerritsen
b25a2fab79 Bluetooth: Controller: Make it possible to support only TX or RX DF
Some controllers may support only TXing or RXing CTE.
As all DF features are guarded by BT_CTLR_DF, we need to ensure
that it is possible to select those when only TX or RX is available.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Rubin Gerritsen
e51999e661 Bluetooth: Controller: Document the purpose of BT_CTLR_DF_SUPPORT
I believe it will now be easier to understand how to use it.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Mariusz Skamra
e6b73b08e6 Bluetooth: gatt: Update bt_gatt_is_subscribed documentation
This updates the documentation of bt_gatt_is_subscribed function that
can take a bitfield of BT_GATT_CCC_NOTIFY and BT_GATT_CCC_INDICATE.
This might be useful if one wants to test if peer is subscribed, but
does not matter which method was used.

The gatt.c implementation handles API usage already, because it performs
bitwise AND:
if (bt_conn_is_peer_addr_le(conn, cfg->id, &cfg->peer) &&
    (ccc_value & ccc->cfg[i].value)) {
	return true;
}

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-04 18:56:36 -04:00
Tom Burdick
6913da9ddd logging: cAVS HDA based logger
Adds a log backend that maintains a ringbuffer in coordination
with cAVS HDA.

The DMA channel is expected to be given some time after the logger
starts so a seperate step to initialize the dma channel is required.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-05-04 18:56:13 -04:00
Juha Heiskanen
9b7a36099f net: lwm2m: LwM2M timeout recovery
LwM2M engine is blocking new notification send.
Notification or Send timeout trig Reconnect and registration state.
Send/Notification  message is blocked if client is not connected.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-05-04 09:50:28 -05:00
Piotr Pryga
c98e64921b Bluetooth: Controller: lll: Add missing CTEInfo copy if conn encrypted
In case a connection is encrypted received PDU is decrypted by CCM.
CCM does not encrypt/decrypt S1 byte that stores CTEInfo.
In case of reception of a PDU by encrypted connection there is missing
CTEInfo in a memory where CCM stores decrypted PDU.
The CTEInfo data must be copied from scratch packet.

The commit adds code responsible for copying of the CTEInfo into
target PDU memory.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-04 09:48:14 -05:00
Jarno Lamsa
ffa222725d net: lib: lwm2m: Don't create server object in bootstrap
When bootstrap is used, the server object shouldn't be autocreated.
Automatically creating object may cause problems after bootstrap
has been done and bootstrap server deletes and creates instances
for server object. In the next boot the auto-created server object
may have clashing server_id with the server object that the
bootstrap-server has created.
Also lifetime wasn't properly added to the registration message from
the server object.

Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
2022-05-04 09:46:10 -05:00
Juha Heiskanen
3bf30ef292 net: lwm2m: LwM2M RD client start and stop update
Added return code for for lwm2m_rd_client_start() & lwm2m_rd_client_stop().

lwm2m_rd_client_start() return -EINPROGRESS when start is in progress and
0 for success.

lwm2m_rd_client_stop() return -EPERM when context is unknown and
0 for success.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-05-04 09:44:29 -05:00
Herman Berget
d8357a2216 Bluetooth: Host: Add testing function bt_eatt_reconfigure
The function sends L2CAP reconfigure requests to reconfigure all
connected EATT channels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-04 10:35:31 +03:00
Herman Berget
addc4a90f0 Bluetooth: Host: Call att_mtu_updated callback on channel reconfigured
Previously, the att_mtu_updated callback was only called on initial
connection of the channel or during the MTU Exchange procedure. There
was no way for the application to know that the MTU increased in the
case where the peer initiated the reconfiguration.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-04 10:35:31 +03:00
Asbjørn Sæbø
0644d51d2d Bluetooth: Audio: Use existing ATT macros for handle range
Use the existing macros for first and last handle instead of defining
own macros.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-05-04 10:30:27 +03:00
Aleksandr Khromykh
0aa0913ca5 Bluetooth: Host: fix aes ccm authentication
Bluetooth Host calculated authentication value correctly only
for data smaller than 255 bytes. If data is larger then
authentication transformation used wrong flags.
Since the issue was symmetric two Zephyr
based devices were able to understand each other. Hence,
other devices like Android or IOS smartphones weren't able
to authenticate large frames and broke communication.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-05-03 09:37:17 +02:00
Carlo Caione
55dc21ffb9 openamp: Bump to v2022.04.0
Bump OpenAMP to v2022.04.0 and fix Zephyr terminology linked to OpenAMP.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-02 08:44:17 -05:00
Ole Morten Haaland
fc6f40964c net: if: Add method to set default interface
This complements the Kconfig possibility, and allows setting an
interface as default on runtime. Changing the default interface also
works around limitations when trying to use an offloaded interface
together with a native one.

Signed-off-by: Ole Morten Haaland <omh@icsys.no>
2022-05-02 10:57:05 +02:00
Giuliano Franchetto
6630f7fc07 lorawan: adding settings NVM for LoRaWAN
Adding a reference implementation of the Non-Volatile Memory module
needed to join any LoRaWAN network.

This NVM is based on the SETTINGS subsys to store all the required
key to join and communicate on a LoRaWAN network.

Without proper NVM, one may experience errors when using OTAA
to join the network, as the device may violate anti-replay
protection (depending on the version of LoRaWAN).

Signed-off-by: Giuliano Franchetto <giuliano.franchetto@intellinium.com>
2022-05-02 10:56:02 +02:00
Daniel DeGrasse
64c5b93d5c sd: Add sdmmc protocol stack
Add SDMMC driver to subsystem. SDMMC driver will handle initialization,
as well as SDMMC I/O. SD mode support is currently supported, SPI mode
support is not.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00
Daniel DeGrasse
3e8bbee9ed sd: Add common SD initialization code
All SD cards require SD CMD0 (reset) and CMD8 (send IF cond) at boot.
Add this portion of the initialization flow to SD subsystem, as well as
query command to check if card is SDIO.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00
Yuriy Vynnychek
e71448a00d shell: fix missing "update" for the last RXRDY signal
Fixed the issue when sometimes "update" is not called for the
last RXRDY signal. First, need to reset the signal and only
after that need to call the "update" function.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2022-04-29 16:11:43 +02:00
Veijo Pesonen
d8b7449b52 net: lwm2m: SenML CBOR key ordering
Keys' order - bn, n - might differ from the default due to
Length-First Map Key Ordering rules.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Veijo Pesonen
975d170792 net: lwm2m: use stack for SenML CBOR data
Formatter data are is shared between different threads.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Veijo Pesonen
a1bd90646e net: lwm2m: adds README
Includes instructions for generating the SenML CBOR encoder and
decoder.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Veijo Pesonen
98b22a1850 net: lwm2m: SenML CBOR optimisations
Regenerates the encoder and decoder. Treats integers and floating-point
values as separate entities instead of saying that those are numerical
values. Brings some memory savings.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Veijo Pesonen
b78dd2498a net: lwm2m: Sets ct to registration msg
Tells the server which content format is preferred in a registration
message.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Veijo Pesonen
4f76b194a4 net: lwm2m: empty CBOR array support
Makes possible to write an empty CBOR array if there are no SenML CBOR
records that needs to be written. This came up when trying to delete a
portfolio object instance.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Veijo Pesonen
60eaafe293 net: lwm2m: SenML CBOR gencode adaption
Generated code needs some modifications for it to work correctly.

Adds license information.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Veijo Pesonen
0562de9fbe net: lwm2m: SenML CBOR RW support
* LwM2M v1.1 SenML CBOR content format support.
* Composite operations
* SEND functionality

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-29 16:10:43 +02:00
Lingao Meng
2ef96e2f66 Bluetooth: Host: Fix unable cleanup conn
The peripheral is configured to update the connection
parameters for 5 seconds by default.

There is an abnormal situation with a very low probability.

The central actively disconnects or abnormally disconnects the
Bluetooth connection at the same time.

At this time, the connection disconnection event will be
handled by BT RX.

At this time, sysworkq has sent a parameter update request and
will receive a reply with status = 0x02, because the handle is
invalid at this time.

We can not just cancel work, because work->flag may be
in K_WORK_RUNNING, so work->flag is set to K_WORK_CANCELING
and subsequent conn_cleanup will unable call k_work_rescheduler
successfully.

According submit_to_queue_locked will return ret = -EBUSY.

	if (flag_test(&work->flags, K_WORK_CANCELING_BIT)) {
		/* Disallowed */
		ret = -EBUSY;
As a result, the connection cannot be cleanup correctly.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-29 15:35:10 +02:00
Krzysztof Chruscinski
3ee5c57934 shell: Add new way of adding subcommands
Added macro SHELL_SUBCMD_SET_CREATE which creates a set of subcommands.
SHELL_SUBCMD_ADD and SHELL_SUBCMD_COND_ADD can be used from any file to
add command to the set. This approach allows to have subcommands added
from multiple files.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-29 14:54:08 +02:00
Juha Heiskanen
1b10f8345e net: lwm2m: LwM2M RD client registration update failure fix
Client jump to full registration state if registration update fail.
Update keep already opened DTLS session.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-29 08:57:30 +02:00
Juha Heiskanen
f20eeebbd1 net: lwm2m: DTLS session cache enable and queue mode update
Enabled DTLS session cache for support session resume.
Fixed LwM2M queue mode for close connection and reconnect automatically.
Re-connect will do Registration update before it send queued data.
Session resume is helping a case when NAT change address and cause less
network traffic.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-29 08:57:30 +02:00
Juha Heiskanen
5249e43e54 net: coap: Coap pending allocation fix
When sending 2 or more confirmable message before first one is
writed to socket all messages use same coap pending structure.
Now coap_pending_init() set data pointer which lock allocation
by each call.

Using data pointer for detecting free is more stable than timeout.
Timeout is initialized only before first socket send. Queued packet
may be triggered later than other and may cause that same block is
allocated multiple time.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-29 08:57:30 +02:00
Carlo Caione
69b28bfd07 pm: policy: Consider substates for state lock functions
Extend the current pm_policy_state_lock_*() functions to support
substates.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-28 16:32:23 +02:00
Emil Gydesen
55de0fd353 Bluetooth: ASCS: Fixed wrong state for detaching stream
The audio stream should be detached from the endpoint
when the endpoint goes into the releasing state, instead
of the idle state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-28 14:18:11 +02:00
Emil Gydesen
cf89447442 Bluetooth: ASCS: Remove redundant if statement
ase_process had a check for the IDLE state, but the
check did not do anything, so was removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-28 14:18:11 +02:00
Emil Gydesen
a61cbb8182 Bluetooth: ASCS: Add no-op case for setting releasing state
The releasing state does not trigger any stream ops,
but will be a no-op case to avoid the error log
message.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-28 14:18:11 +02:00
Thomas Ebert Hansen
20cb60ecd2 Bluetooth: controller: Fix central enc termination
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.

Add a greedy option to pdu_is_expected() to make sure the procedure
processes all unexpected control PDU in all cases.

Add unit test inspired by Bluetooth Qualification test
LL/SEC/CEN/BV-14-C,
Central Receiving unexpected PDU during encryption start

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
70e38b1cbb Bluetooth: controller: Fix central enc reject
Add support for both LL_REJECT_IND and LL_REJECT_EXT_IND when waiting
for the the response to the LL_ENC_REQ and LL_START_ENC_REQ.

Add unit test to test both LL_REJECT_IND and LL_REJECT_EXT_IND as
responses to LL_ENC_REQ.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
268d00623b Bluetooth: controller: Fix periph enc reject
Chose correct rejection PDU based on features supported on remote peer
when rejecting due to missing LTK.

Update unit test setup with faking that a feature exchange procedure
has run.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
06feb0202c Bluetooth: controller: Fix periph enc termination
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.

Add unit test inspired by Bluetooth Qualification test
LL/SEC/PER/BI-05-C,
Peripheral Receiving unexpected PDU during encryption start

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
934279a48f Bluetooth: controller: Fix enc APPTO
The logic condition for when to enable APPTO needs to look at both
enc_rx and enc_tx.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Szymon Janc
57a94bff10 Bluetooth: controller: Add validation of received LLCP PDUs
This adds suport for validation of received PDUs before they are
pass further to LLCP state machines. If PDU size is invalid it is
rejected with LL_UNKNOWN_RSP.

This was affecting following qualification test cases:
LL/PAC/PER/BI-01-C
LL/PAC/CEN/BI-01-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-04-28 12:52:57 +02:00
Robert Lubos
7ad2e604bb net: sockets: tls: Add options to control session caching on a socket
Introduce TLS socket options, which allow to configure session caching
on a socket.

The cache can be enabled on a socket with TLS_SESSION_CACHE option.
Once cache is enabled on a socket, the session will be stored for re-use
after a sucessfull handshake. If a socket is attempting to connect to a
host for which session is stored, the session will be resumed and mbed
TLS will attempt to use a simplified handshake procedure.
The server-side management of sessions is fully controlled by mbed TLS
after session caching is enabled on a socket.

The other TLS_SESSION_CACHE_PURGE option allows to clear all of the
cache entries, releasing the memory allocated for sessions.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-28 11:31:07 +02:00
Carlo Caione
7f51907fda ipc_service: static_vrings: Set WQ default type to PRIO_COOP
In 92d8329d5b a new DT property was introduced to set the WQ priority
of the instance. The fallback value when the property was not present
was arbitrarily set to <0 PRIO_PREEMPT>.

The problem is that this value is actually changing the behaviour for
the code that is not explicitly setting the DT property, breaking in
some cases the existing code.

Move the default value to <0 PRIO_COOP> to give the old code a
consistent behaviour before and after the 92d8329d5b commit.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-28 10:27:10 +02:00
Reto Schneider
9c286e50f6 Bluetooth: shell: Fix unused function warning
Prevent warnings by conditional compilation of static functions.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-04-28 10:26:25 +02:00
Pavel Vasilyev
a63c515679 Bluetooth: Mesh: Check SegN when receiving Transaction Start PDU
When receiving Transaction Start PDU, assure that number of segments
needed to send a Provisioning PDU with TotalLength size is equal to SegN
value provided in the Transaction Start PDU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-04-28 08:56:01 +03:00
Keith Packard
2c310d431f subsys/logging: Increase logging stack size for assert or spin_validate
These two options significantly increase the amount of stack space used
by the logging thread as these generate both additional logging and
generate deep stacks themselves. This fixes running the
tests/subsys/logging/log_core_additional/logging.add.log1 test on
riscv32 with THREAD_LOCAL_STORAGE enabled.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Keith Packard
7ec1fb632b subsys/tracing: Use z_current_get for thread tracing
The thread switching hooks are invoked in the middle of thread
switching, after the out-going thread registers are saved, but before
the in-coming thread registers are restored, and also before
z_thread_entry is called if the thread is just starting.

When the core is first starting, the TLS base register won't be set at
all, so accessing variables will fault. When switching threads, the
in-coming thread TLS base register will not have been restored, so the
z_tls_current value will end up getting the out-going thread instead.

To fix this, switch from k_current_get() to z_current_get().

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Emil Gydesen
1e02dd0dc1 Bluetooth: Audio: Add conn check for the VOCS client notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
964df6d4da Bluetooth: Audio: Add conn check for MICS client notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
1f60adf1df Bluetooth: Audio: Add conn check for the OTC notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
b734487eaa Bluetooth: Audio: Add conn check for MCC notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
5dfea31e83 Bluetooth: Audio: Add conn check for CSIS client notify handlers
Add a NULL check for the conn pointer in the CSIS client
notify handlers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
50ccf861b8 Bluetooth: Audio: Add conn check for AICS client nofity handler
Add a NULL check for the conn pointer in the AICS client
instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Erik Brockhoff
dd5119fdb3 Bluetooth: controller: check for instant on reception of CONN_UPD_IND
Instead of waiting one connection interval, as a result of the state
change, perform the check for instant already on reception of
CONNECTION_UPDATE_IND

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
26f6941048 Bluetooth: controller: using REJECT_IND when EXT_IND was not negotiated
Unless a feature exchange determines support for REJECT_EXT_IND use
REJECT_IND for collision rejection

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
0d94ad69f6 Bluetooth: controller: removing unused functionality
Removing llcp_tx_flush() as it turns out it is not needed.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
025b9745d3 Bluetooth: controller: implementing state check for ENC reply API
Now checking that encryption procedure is in correct state to accept
a reply from host.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
06078ee54e Bluetooth: controller: DO TODO, compile out members of struct re. CPR
Compile out misc. members not used when Connection Parameter Request
is not supported.
Implement missing tests re. unsupported features in CU/CPR procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Sjors Hettinga
9392b12d4b net: tcp: Set the FIN_TIMEOUT to allow all FIN retries
Instead of using a fixed fin timeout, compute it based on the number
of retries. Fixes issue found by PR 44545.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-04-27 10:08:07 +02:00
Aleksandr Khromykh
768e0d7a01 Bluetooth: Mesh: encapsulate tinycrypt dependency
Bluetooth Mesh uses tinycrypt library for security related
algorithms. This PR encapsulates tinycrypt dependency within
one file to make the current implementation more portable.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-04-27 10:07:47 +02:00
Anas Nashif
462b13e16e Revert "ztest: Fix userspace ztests in new API"
This reverts commit 900b6723e7.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 18:55:32 -04:00
Pete Skeggs
fb2a966128 net: sockets: tls: use cipherlist set by user
The function setsockopt() option TLS_CIPHERSUITE_LIST
allows the user to set a specific list of ciphersuites
when using the Zephyr native + Mbed TLS stack.  However, the
list provided was not actually being used later for
handshaking.

This adds the missing calls to mbedtls_ssl_conf_ciphersuites()
to use the list provided.  If none was provided, fall back
to the default list as determined by Mbed TLS from Kconfig
values.

Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
2022-04-26 15:54:32 -04:00
Yuval Peress
900b6723e7 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-26 14:29:18 -04:00
Erik Brockhoff
d8f0c1adf6 Bluetooth: controller: implement connection termination on invalid pdus
When a running procedure receives a REJECT or UNKNOWN_RSP PDU that is
not an expected part of the procedure flow this leads to termination
of the connection

This affects procedures:
CU/CPR, CTE, PHY, PING, DLE, FEX, VEX, CHMU

Unit tests are updated to cover the updated behaviour.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-26 14:06:16 +02:00
Emil Gydesen
c972ffddac Bluetooth: ISO: Add additional information for ISO streams
Add all information from the ISO established events
and provide the information in the get_info function.

The use cases of each field heavily depends on what
the ISO streams are used for.

Most, if not all, of the field can be used by the
higher layers to improve quality and/or reliability
of e.g. audio streams that use ISO.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-26 11:35:45 +02:00
Aleksandr Khromykh
6896075b62 Bluetooth: Mesh: add check for rx buffer overflow in pb adv
There is potential buffer overflow in pb adv.
If Transaction Continuation PDU comes before
Transaction Start PDU the last segment number is set to 0xff.
The current implementation has a strictly limited buffer size.
It is possible to receive malformed frame with wrong segment
number. All segments with number 2 and above will be stored
in the memory behind Rx buffer.

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-04-26 11:35:33 +02:00
Aleksander Wasaznik
77ad017672 Bluetooth: Shell: Fix off-by-one in address length validation
Fixes Coverity defect id 248346.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-04-26 11:35:19 +02:00
Emil Gydesen
a796927961 Bluetooth: Audio: Make PACS location optional
Make the PACS location characteristic optional, and
also optionally writable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-26 09:00:48 +02:00
Vinayak Kariappa Chettimada
31f49936e2 Bluetooth: Controller: Fix missing cond. compile for ext. scan filter
Fix missing conditional compile when Advertising Extensions
is enabled without Extended Scan Filter Policy support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-25 11:44:22 -07:00
Thomas Ebert Hansen
d1c9efa83d Bluetooth: controller: LLCP PRT rewrite
Rewrite the entire Procedure Response Timeout mechanism.

Use two separate timers for local and remote initiated procedures.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-25 15:36:16 +02:00
Andries Kruithof
ecae7a9c7f Bluetooth: controller: llcp: terminate connection on collission
As per bluetooth spec Vol. 6 part B section 5.3 we need to terminate
the connection under given situation

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-04-25 15:35:45 +02:00
Piotr Pryga
0ead951649 Bluetooth: Controller: llcp: Fix PHY update instant val if no PHY change
BT Core spec 5.3 Vol 6, Part B section 2.4.23 LL_PHY_UPDATE_IND says:
"If both the PHY_C_TO_P and PHY_P_TO_C fields are zero then there is no
Instant and the Instant field is reserved for future use."
Fields that are reserved for future shall be filled with zeros.

New LLCPs implementation didn't handle this case and set the instant
as if there were a PHY change. That caused qualification tests to fail.

The commit fixes the issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-25 13:10:42 +02:00
Vinayak Kariappa Chettimada
4efd9b80c8 Bluetooth: Controller: Fix typo in BT_CTLR_ISOAL_SOURCES prompt
Fix typo in BT_CTLR_ISOAL_SOURCES Kconfig prompt message.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-24 19:47:46 +02:00
Herman Berget
c8b2279f89 Bluetooth: Host: Make tx complete callback work for EATT channels
Previously, if a callback was set for notifications, they would always be
sent over unenhanced ATT.

The nfy_mult_data was bigger than the buffer user_data and we were this
overflowing the buffer when setting the tx callback user_data. Now the
data is stored separately and only a pointer to it is added to the
buffer user_data.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-24 19:46:41 +02:00
Herman Berget
cf3832f0bf Bluetooth: Host: Add support for tx complete callback for ECRED channels
Previously callbacks were only supported on unenhanced channels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-24 19:46:41 +02:00
Anas Nashif
399a0b4b31 debug: generate call graph profile data using gprof
This will generate profile data that can be analyzed using gprof. When
you build the application (currently for native_posix only), after
running the application you will get a file "gmon.out" with the call
graph which can be processed with gprof:

  gprof build/zephyr/zephyr.exe gmon.out > analysis.txt

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-22 16:04:08 -04:00
Aleksander Wasaznik
8e5c177233 Bluetooth: Host: Validate IRK ID in range
Validate `id` so that `bt_dev.irk[id]` cannot result in an out-of-bounds
access.

This fixes coverity report 239569.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-04-22 10:24:43 -05:00
Kamil Gawor
3defc3dfc2 Bluetooth: Controller: Fix timings for Tx test
The Tx interval is now calculated at the beginning
of the Tx test and the next transmission is
triggerd by the switch timer instead of event
timer. This fixes a corner case issue when
timer rollover.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-04-22 13:46:34 +02:00
Piotr Pryga
77ae58ee72 Bluetooth: Controller: fix wrong use of LE Features in CTE REQ llcp
When Host calls HCI_LE_Connection_CTE_Request_Enable with cte type
set to AoD with 1us slots or AoD with  2 us slots, the Controller
verifies if peer device supports Antenna Switching During CTE
Transmission (AoD) feature.

That is wrong because the feature is marked as optional when send
to peer, so it shall be igonerd by remote device.

There are no means to check if peer device supports particular
CTE type, hence the check has to be removed.

The check causes enable CTE REQ procedure to fail after feature
exchange has happened.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-22 09:45:27 +02:00
Piotr Pryga
45bba8e5f8 Bluetooth: Controller: df: Fix missing disable CTE req LLCP after compl
The CTE request procedure can be run in periodic and non-periodic mode.
In periodic mode it stays enabled until Host call HCI_LE_Connection_CTE-
_Request_Enable(Enable=0x0).
In non-periodic mode the command is disabled after completion,
LL_CTE_RSP is successfully received.

There is missing disable of the procedure in the current code,
so Host is not able to run the command HCI_LE_Connection_CTE_Request_-
Enable(Enable=0x1) again without explicit call to HCI_LE_Connection_-
CTE_Request_Enable(Enable=0x0).

The commit adds missing code responsible for disable of the procedure.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-22 09:45:14 +02:00
Veijo Pesonen
cfcc891d3d net: lwm2m: makes CBOR as one of the default...
...content formats

In case that SenML CBOR or SenML JSON are both disabled there is need to
use plain CBOR as backup.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-22 09:44:36 +02:00
Veijo Pesonen
11b8b4e7ba net: lwm2m: enables CBOR content format
With LwM2M v1.1 the content format is enabled by default.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-22 09:44:36 +02:00
Veijo Pesonen
8fd283a788 net: lwm2m: Single instance read&write with CBOR
Raw CBOR content format support.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-22 09:44:36 +02:00
Aleksandr Khromykh
a7bb928420 Bluetooth: Mesh: subscription on fixed group addresses
There is errata clarification (Errata ID:18700)
about subscriptions on fixed group addresses.
It is possible to subscribe models on non primary elements
on any fixed group address except all nodes address.
Devices should be able to receive messages on fixed addresses
even if they do not support the feature
to which the fixed group address belongs.

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-04-22 09:44:00 +02:00
Emil Gydesen
102a6210bb Bluetooth: Kconfig: Increase TX stack size for BT_CTLR && BT_LL_SW_SPLIT
Increase the default TX stack size for BT_CTLR && BT_LL_SW_SPLIT,
as we have seen applications/samples nearing and even reaching
the stack size, causing stack overflows. This is especially
true if CONFIG_FPU=y which takes 96 bytes of the TX stack.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-22 09:43:12 +02:00
Vinayak Kariappa Chettimada
13fe3bb6c3 Bluetooth: Controller: Fix assert on LL BIG terminate
Fix assert on LL BIG terminate call before BIG sync is
established. Assert was caused due to duplicate calls to
release stream contexts, once in LL BIG terminate function
then when releasing the HCI BIG sync failed to be
established node rx was being released.

Use iso_broadcast and iso_receive samples, power cycle the
iso_broadcast device when iso_receive sample is waiting for
BIG sync to be established, iso_receive sample will perform
a BIG sync terminate that leads to the assert.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-22 09:41:50 +02:00
Vinayak Kariappa Chettimada
335315fc71 Bluetooth: Controller: Fix spurious transmit after mic failure
Fix spurious transmit of corrupt PDU after reception of PDU
with MIC failure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-22 09:41:32 +02:00
Peter Mitsis
a30cf39975 kernel: update k_thread_state_str() API
When threads are in more than one state at a time, k_thread_state_str()
returns a string that lists each of its states delimited by a '+'.
This in turn necessitates a change to the API that includes both a
pointer to the buffer to use for the string and the size of the buffer.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-04-20 20:20:13 -04:00
Al Semjonovs
fef6e46f01 ztest: Add Z_TEST_SKIP_IFDEF macro
Defined Z_TEST_SKIP_IFDEF macro to skip tests when specified
config is enabled.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-04-20 15:28:14 -04:00
Omkar Kulkarni
12553800f1 Bluetooth: Mesh: Update defaults - proxy filter, msg cache
This updates the default proxy filter size to 16. Previous value of 3
is too less for the most practical uses and demos. The default proxy
filter type is accept list type and in this mode proxy server rejects
incoming messages from source addresses not in the accept list. The
addresses are added to the accept list when proxy client sends
messages to unicast addresses or manually adds certain addresses to
the accept list. Once this list is full more addresses cannot be added.

This also updates the default network message cache size to 32. The
network message cache helps in preventing duplicate messages getting
repeatedly relayed and helps in reducing unnecessary network traffic.
Previous value of 10 is quite less for most usecases and makes the
node appear to generate much more traffic in mixed network. The
updated value should suffice for most use cases.

Additional explannation is added in Kconfig to help users understand
the significance of this setting.

These two changes result in 176 bytes of additional RAM usage in mesh
samples.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2022-04-20 16:36:42 +02:00
Peter Mitsis
79b57e2cbb logging: Enable Sys-T on ADSP backend
Enables the Sys-T formatting on the ADSP backend when the
SYST logging format is selected.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-04-20 10:25:16 -04:00
Herman Berget
0916eba4ad Bluetooth: Host: Send the "Out of Sync" error only once on each channel
The "Database Out Of Sync" error response shall only be sent once on
each channel after a client becomes change-unaware.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-20 16:10:46 +02:00
Herman Berget
1732ec061b Bluetooth: Host: Add CF_DB_HASH_READ flag
This fixes the case where the client reads the DB hash without reading
another attribute first after becoming change-unaware.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-20 16:10:46 +02:00
Asbjørn Sæbø
79d96b8112 Bluetooth: Audio: Add void() cast to memcpy
Cast memcpy to void().

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø
b0d5db147b Bluetooth: Audio: Media control - pass structs by reference
Changes the media_proxy API to pass structs by reference instead of by
value.

Also pass structs by reference in internal functions in media player
and in media controller test.

Add pointer checks to the public API implementation where
user/application code provides structs by reference.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø
ebaad4501c Bluetooth: Audio: Media - search to not modify parameter
Update the search parser to not modify the supplied parameter.
This will allow the parameter to be made 'const'.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø
1d66729a0a Bluetooth: Audio: Remove zero-ing of variable
Commit dc812539b8 ("Bluetooth: MPL: Fix use of uninitialized
command.param value") fixed the use of a potentially un-initialized
variable, by
- splitting a log statement, so that the variable is only
  logged (=used) if in use (and therefore hopefully also initialized)
- setting the variable to zero if not in use

The second part is not required, as all other code in the module
checks whether the variable is in use before using it.  And this
second part also prevents the parent struct from being made 'const'.

This commits removes the zeroing of the variable, so that the struct
can be made 'const'.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø
fa5b8a1e38 Bluetooth: Audio: MCC - pass structs by reference
Changes the media control client API to pass structs by reference
instead of by value.

Also change internals of test to pass struct by reference.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Jordan Yates
855f4b9c96 Bluetooth: hci: correct ext adv cmd definition
Update the definition of the set extended advertising data command to be
a variable array instead of hardcoded to the maximum length. This
conforms to the definition from the Bluetooth specification and allows
the corresponding code to be slightly cleaner.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-04-20 15:49:54 +02:00
Robert Lubos
e2fe8e7307 net: socket: Add option to create native TLS sock with offloaded TCP
In some cases (for examples when offloaded socket implementation does
not implement TLS functionality) it could be desired to create a native
TLS socket with an underlying offloaded socket.

This cannot be achieved with SO_BINDTODEVICE option only, as TLS socket
type is not really associated with a particular interface - it either
has to be offloaded, or a fully native socket is created (native TLS on
a native interface).

In order to address the problem, introduce TLS_NATIVE socket option.
This option instructs the socket dispatcher layer to create a native TLS
socket. As with the socket dispatcher the underlying socket
implementation is not decided during TLS socket creation, therefore it's
possible to use SO_BINDTODEVICE to choose either native or offloaded
interface for the underlying socket.

Additionally remove NET_SOCKETS_OFFLOAD_TLS Kconfig option, as it's no
longer needed with an runtime option to select whether to offload TLS or
not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-20 11:27:05 +02:00
Robert Lubos
641b2a0d93 net: sockets: Add socket dispatcher
Add an intermediate socket implementation called socket dispatcher. This
layer can be used along with the socket offloading, to postpone the
actual socket creation until a first operation on a socket is executed.

This approach leaves an opening to bind a socket to a particular
offloaded network interface, and thus offloaded socket implementation,
using SO_BINDTODEVICE socket option. Thanks to this, it is now possible
to use multiple offloaded sockets implementations along with native
sockets, and easily select which socket should use with network
interface (even if it's an offloaded interface).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-20 11:27:05 +02:00
Juha Heiskanen
53fbf40227 net: lwm2m: SenML Json fix RW Time
Added missing get_time and put_time for fixing crash.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-20 11:10:12 +02:00
Omkar Kulkarni
dbc7689404 Bluetooth: Mesh: Foundation model Client timeout setting
Adds a Kconfig option for setting the Config Client and Health Client
timeout. Updates updates the default for Config Client to allow
reception of full sized message from a similar peer device at zero hops.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2022-04-20 10:44:23 +02:00
Nicolas Pitre
1a21ac8122 shell: fix history optimization
Commit f7c4fe6778 ("shell: optimize history storage a bit") forgot
to distinguish between the newly allocated history item and the previous
one, causing havoc on ring buffer wraparounds with excess padding.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-20 09:50:03 +02:00
Ryan McClelland
1216f19a89 logging: fix LOG_TAG_MAX_LEN min warning
if CONFIG_LOG_TAG_MAX_LEN is 0, then a warning would be generated
on the MIN macro always being false, but as
CONFIG_LOG_TAG_MAX_LEN is a constant, then it is better to just
compile out the function if it's 0.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2022-04-19 11:49:34 +02:00
Bartosz Bilas
306f92e646 tracing: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Bartosz Bilas
e89f441146 testsuite: ztest: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Bartosz Bilas
1ace84a896 shell: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Bartosz Bilas
f9d8f34eba net: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Bartosz Bilas
6367075dfe logging: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Bartosz Bilas
9e3d9784ff canbus: isotp: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Bartosz Bilas
95f3b4bc70 bluetooth: audio: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Dominik Ermel
ef199e92df mgmt/mcumgr/lib: doc: Minor fixes to zcbor_bulk documentation
Little polishing here and there.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:35:16 +02:00
Dominik Ermel
fb4afe2112 mgmt/mcumgr/lib: Remove mcumgr_util
With replacement of (u)ll_to_s with snprintf the util is no longer
needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
3445c29979 mgmt/mcumgr/lib: Use snprintf instead of ll_to_s in OS group
The commit replaces usage of ll_to_s with snprintf.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
4a12570ef8 mgmt/mcumgr/lib: Allow image management list broken version str
The commit adds change to image management list where "<???>"
will be returned as version string in case when version to string
conversion fails.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
692a4a7e63 mgmt/mcumgr/lib: Replace ull_to_s with snprintf in img_mgmt_ver_str
The ull_to_s, which is used to covert ints to string, has been
replaced with snprintf.
Above also fixes a bug where ull_to_s has been given INT_MAX as allowed
output string, while it should be given maiximum allowed buffer size.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
ca60b75613 mgmt/mcumgr/lib: Remove mgmt_streamer_reset_buf
Commit removes mgmt_streamer_reset_buf from mcumgr lib,
and supporting Zephyr function zephyr_smp_reset_buf.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:32:56 +02:00
Flavio Ceolin
0b13b44a66 pm: device: Dynamically add a device to a power domain
Add API to add devices to a power domain in runtime. The number of
devices that can be added is defined in build time.

The script gen_handles.py will check the number defined in
`CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC` to resize the handles vector,
adding empty slots in the supported sector to be used later.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Rihards Skuja
d5b83a8c90 logging: disable Linux-style timestamp formatting by default
Fix a typo in #43934.

Signed-off-by: Rihards Skuja <rhssk@posteo.eu>
2022-04-15 10:33:15 -07:00
Szymon Czapracki
827890c075 Bluetooth: audio: Add initial Hearing Access Service shell
This adds initial shell support for HAS.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-04-15 10:32:54 -07:00
Mariusz Skamra
4ac9eba3d5 Bluetooth: has: Add initial support for presets
This adds initial support for presets that includes API functions
to register/unregister presets and Read Preset Request control point
handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-04-15 10:32:54 -07:00
Piotr Golyzniak
00a4a94076 logging: remove obj character
Remove OBJECT REPLACEMENT CHARACTER U+FFFC from warning log messages.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-04-15 09:24:32 -04:00
Tom Burdick
02503c37c3 logging: backend_adsp: lock the output
Adds a lock around the output to prevent corruption, and sets the buffer
size of the output to size of the output buffer. This fixes the
corrupted log output as process() may be called from multiple contexts
from different CPUs. A background log processing thread may race against
the panic ISR log context also calling process() on an SMP system.

Additionally sets the buffer size to 80 such that the cavs trace_out.c
functionality and lock are useful for more than one character at a time
greatly reducing the chances of garbled output in a printk and log race
but does not entirely prevent it. CONFIG_LOG_PRINTK=y should be used
to avoid all races.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-04-13 17:41:27 -04:00
Jamie McCrae
d67a364ace mgmt: mcumgr: lib: os: Add reset callback
This allows an application to inspect a mcumgr os reset command and
either allow it or deny it with a result code.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-13 14:05:57 -07:00
Marin Jurjević
0ab6bc6626 net: lwm2m: update client tx timestamp before sending message
Update client tx timestamp right after message is added to list
of outgoing messages. Delay between when message is generated and
sent is negligible. This will prevents bugs that appear when using
queue mode, where internal engine logic depends on timestamp being
updated when message is generated.

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-04-13 13:59:58 -07:00
Krzysztof Chruscinski
33923014b9 logging: Kconfig cleanup of frontened related options
Cleanup in kconfig options in preparation for adding a
frontend that will use dictionary mode.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-13 13:45:36 -07:00
Krzysztof Chruscinski
8f919e41fa logging: Add UART dictionary frontend
Add frontend which dumps log messages in binary dictionary
mode.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-13 13:45:36 -07:00
Krzysztof Chruscinski
8b0d429bfd logging: Add timestamp getter function part of internal API
Expose timestamp getter so it can be used, e.g. in the frontend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-13 13:45:36 -07:00
Piotr Pryga
b53657a058 Bluetooth: Controller: hci: Wrong opcode when handling CTE req failed
HCI_LE_CTE_Request_Failed may be generated in case received LL_CTE_RSP
PDU didn't contain CTE or if peer rejected the request. HCI function
encode_data_ctrl responsible for dispatching received control PDUs
should not expect a PDU with PDU_DATA_LLCTRL_TYPE_CTE_REQ opcode.
It should never happen. The correct opcode here is PDU_DATA_LLCTRL_TYPE-
_CTE_RSP.

Result of this issue is an assert when LL_CTE_RSP PDU is received
but it does not include CTE.

The commit fixes the problem.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-13 13:40:59 -07:00
Herman Berget
97d64cf104 Bluetooth: Host: Fix assert in L2CAP ECRED connection response
In the case that the peer responds with fewer dcid values than the
number of scid values in the connection request, we would assert or read
past the end of the buffer.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-13 13:40:00 -07:00
Szymon Janc
31b148ab64 Bluetooth: host: Fix crash in bt_l2cap_chan_recv_complete
It is possible that LE CoC channel is in disconnecting state (eg due
to peer sending too many packets) but application is not yet aware
of this (ie disconnected callback was not called) and thus may call
bt_l2cap_chan_recv_complete() to return credits. In this case it
leads to assert in l2cap_chan_send_credits.

It looks like PTS 8.2.1 is able to trigger this scenario when
executing L2CAP/ECFC/BI-02-C test.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-04-13 13:29:12 -07:00
Veijo Pesonen
1105017ce0 net: lwm2m: Makes OMA TLV content fmt conditional
With LwM2M v1.1 usage of the OMA TLV content format is discouraged.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-13 13:28:34 -07:00
Dominik Ermel
4e03e34138 mgmt/mcumgr/lib: Add missing inclusion of toolchain.h
The zcbor_bulk_priv.h uses STRINGIFY for some of definitions
and, due to lack of inclusion of the toolchain.h, that was causing
compilation errors when NEWLIB would be selected.

Fixes #44811.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-13 13:28:16 -07:00
Anas Nashif
1537ee7a0b ztest: if runid is set, propagate it
define test run id and make it available to ztest. This will be used to
verify we are evaluating the same test we have just built and flashed
and that we are not looking at some old output.

Existing code in ztest will use this, and twister will define the run
id.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-12 08:54:41 -07:00
Anas Nashif
68670d71b8 tracing: kconfig: move RAM_TRACING_BUFFER_SIZE out of choice
This kconfig is not a choice, it is an option needed by one of the
choices, so move it out.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-12 11:39:11 -04:00
Anas Nashif
af2d83e66f tracing: add missing macros needed for k_thread_foreach
Add those dummy tracing functions to get the test to build when using
k_thread_foreach.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-12 11:39:11 -04:00
Szymon Janc
1f27849457 Bluetooth: controller: Fix build with new LLCP enabled
PR44014 introduced new pause logic for procedures but PR44297
was merged without being update to use it.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-04-12 12:57:44 +02:00
Jamie McCrae
756a8f7a9b mgmt: mcumgr: fs: Add hash/checksum (with CRC32/SHA256) handler
This adds a hash/checksum mcumgr handler to the file management commands
which can be used to get a hask or checksum of a file, and includes
handler implementations for IEEE CRC32 and SHA256.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-12 12:05:30 +02:00
Jamie McCrae
105f8b65e9 mgmt: mcumgr: fs: Add file status handler
This adds a command handler to the file management mcumgr system to get
the status of a file without needing to return file data (currently
reporting the file size).

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-12 12:05:30 +02:00
Dominik Ermel
1b92fba8e7 mgmt/mcumgr/lib: endian.h is no longer needed.
Removed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-12 11:42:28 +02:00
Dominik Ermel
e7205683bd mgmt/mcumgr/lib: Replace htons/ntohs with Zephyr functions
The commit replaces htons and ntohs calls, with sys_be16_to_cpu
and sys_to_cpu_be16.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-12 11:42:28 +02:00
Szymon Czapracki
af2e781f5a Bluetooth: Immediate Alert Service
This commits adds IAS for zephyr bluetooth.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-04-12 09:59:34 +02:00
Erik Brockhoff
f056eb516d Bluetooth: controller: Implementing LL param checks for refactored CPR
Now refactored Connection Parameter Request procedure supports
parameter checking, and implements reject_ext_ind on invalid parameters

Updates to TODO description for remaining work

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-12 09:57:43 +02:00
Veijo Pesonen
d1751cafd3 net: lwm2m: adds LwM2M specific shell command
First available subcommand is for doing a send operation. Send operation
is supported by the LwM2M version 1.1.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-12 09:57:20 +02:00
Piotr Pryga
ab17f6d9f7 Bluetooth: Controller: Fix missing event counter sub by one
The event counter value for connection and periodic advertising
events is updated to next value during event preparation (in one
of prepare_cb functions in LLL).
IQ report is prepared after event preparation, so value of event
counter is ahead of the current event value by one, hence it has
to be subtracted.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-12 09:54:07 +02:00
Piotr Pryga
7dd3d8ff87 Bluetooth: Controller: df: Fix wrong value of event counter in iq report
HCI_LE_Connectionless_IQ_Report and HCI_LE_Connection_IQ_Report
events has fields that store event counter values: Periodic_Event_-
Counter and Event_Counter, respectively.
Values assigned to this HCI events are taken directly from
lower link layer objects. In case of too slow processing of
HCI events values provided by LLL contexts could be changed before
HCI sends events to Host. That can happen e.g. in case of short
periodic advertising interval and slow UART baudrate.
In such situation event counter values will be corrupted.

To prevent that situation, event counter values connected with
IQ sample reports, has to be stored in node_rx_iq_report when
a report instance is filled in LLL.

This commit introduces required changes.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-12 09:54:07 +02:00
Carles Cufi
070c93f0d7 Bluetooth: host: Invert the logic to re-trigger the RX work queue
In order for the code to be more understandable, invert the logic to
decide when to re-trigger the RX work queue and document the approach.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-04-12 09:53:33 +02:00
Carles Cufi
ca54a4201c Bluetooth: host: Use a linked list instead of a FIFO as the RX queue
There is no need to use a k_fifo object to queue the items that are
passed to bt_recv() now that we are using a work queue instead of a
thread, since there is no need for blocking on the actual queue, instead
relying on the fact that work is triggered to know that an item is ready
for processing.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-04-12 09:53:33 +02:00
Dominik Ermel
8aa7791c53 mgmt/mcumgr/lib: Improve smp_process_request_packet documentation
The commit clarifies smp_process_request_packet behaviour.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:13:33 +02:00
Dominik Ermel
069fed9ca9 fs: Kconifg: use rsource instead of source for local Kconfigs
Change from absolute path to relative path for sourcing sub-Kconfigs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:12:20 +02:00
Dominik Ermel
aff57a0a42 mgmt/mcumgr/lib: Cleanup of img_mgmt_priv.h
Fixed define and removed unneded definitions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:12:03 +02:00
Dominik Ermel
bc276b1a68 mgmt/mcumgr/lib: Correct zephyr_grp log module name
The zephyr_grp log module name was incorrectly named
MGMT_SETTINGS and module registration has been using module name
mgmt_zephyr_basic, which is also incorrect.
Both have been changed to mcumgr_zephyr_grp.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:11:27 +02:00
Dominik Ermel
f79698a37c mgmt/mcumgr/lib: Separate Kconfig for zephyr specific commands
Kconfig options for Zephyr specific group have been moved
to zpehyr_grp/Kconfig.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:11:27 +02:00
Dominik Ermel
a1449521aa mgmt/mcumgr: Kconfig: Gather transport options under own menus
The commit adds transport dedicated menu and gathers all transport
options under that menu; each transport gets its own menu, witch
gathers options specific for that transport

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:10:39 +02:00
Dominik Ermel
b6db591a17 mgmt/mcumgr/lib: Add MCUMGR Parameters command to OS group
Adds new command that allows to retrieve MCUMGR parameters.
Currently the command returns MCUMGR buffer size and count.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:10:20 +02:00
Lingao Meng
37e561f42e Bluetooth: Host: Add choice select whether BT RX
Change CONFIG_BT_RECV_IS_RX_THREAD into a
choice:CONFIG_BT_RECV_CONTEXT with the following options
(names can be discussed further of course):

    CONFIG_BT_RECV_BLOCKING
    CONFIG_BT_RECV_WORKQ_BT
    CONFIG_BT_RECV_WORKQ_SYS

This way users would be able to choose what to run most of
the BLE stack on, they wouldn't be forced to a single model.

We would default to CONFIG_BT_RECV_BLOCKING so that we wouldn't
need to change the system workqueue stack size by default, instead
asking users to do so if they select the CONFIG_BT_RECV_WORKQ_SYS option

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-11 10:58:09 +02:00
Mohan Kumar Kumar
f105ea6ef5 net: add sndbuf socket option
Introduce set/get SO_SNDBUF option using the setsockopt
function. In addition, for TCP, check the sndbuf value
before queuing data.

Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
2022-04-11 10:23:31 +02:00
Mariusz Skamra
e9b40ebc69 Bluetooth: has: Satisfy profile security requirement
This enables Secure Connections pairing (actually disables legacy)
to satisfy security requirements of the Hearing Access Profile.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-04-11 10:23:13 +02:00
Pavel Vasilyev
0f3e473f06 Bluetooth: Mesh: Remove argc check in mesh shell commands
The shell submodule already checks number of arguments.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-04-11 10:16:28 +02:00
Pavel Vasilyev
ae2841877b Bluetooth: Mesh: Use shell_print_ctx macro to print from callbacks
Use shell_print_ctx macro when printing to shall from callbacks.
ctx_shell may not be initialized when callback is called.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-04-11 10:16:28 +02:00
Marcin Niestroj
5d07c53118 net: sockets: do not unconstify 'optval' in setsockopt()
'optval' in setsockopt(..., SO_BINDTODEVICE, ...) was casted explicitly
from 'const void *' to 'struct ifreq *'. Rely on C implicit casting from
'const void *' to 'const struct ifreq *' and simply update variable
type. This prevents unwanted modification of ifreq value in the future.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-04-08 15:51:38 -07:00
Eduardo Montoya
7ab43a7cc9 net: openthread: update otPlatSettingsInit
API has been modified.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-04-08 15:50:53 -07:00
Marcin Niestroj
cf75f01a71 net: sockets: introduce NET_SOCKETS_OFFLOAD_PRIORITY option
This option will be used as default socket priority by offloaded socket
drivers.

Describe how to prioritize native TLS over offloaded TLS (and vice
versa) using sockets priorities.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2022-04-08 15:50:11 -07:00
Yuval Peress
648bb9ebdf ztest: fix before function ordering
Make sure that the test rules' `before` function runs before the
suite's. This allows the suite to override any defaults set by the
rule.

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 15:49:57 -07:00
Yuval Peress
53ef68d459 include: Prefix includes to use a scope
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00
Dominik Ermel
33c0995e03 mgmt/mcumgr/lib: Fix zcbor_map_decode bulk
Fixed problem with uninitialized conditional variable.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 17:43:50 +02:00
Jamie McCrae
0ea3600e5c mgmt: mcumgr: lib: Fix non-visible struct build warnings
Fixes build warnings relating to visibility of 2 structs in mcumgr

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-08 15:49:36 +02:00
Dominik Ermel
f36b6d8552 mgmt/mcumgr/lib: Deprecate CONFIG_IMG_MGMT_UL_CHUNK_SIZE
The IMG_MGMT_UL_CHUNK_SIZE is no longer used to control size of
intermediate buffer used for application image chunk processing,
instead directly request trasport buffer is used.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
756c34659b mgmt/mcumgr/lib: Deprecate CONFIG_OS_MGMT_ECHO_LENGTH
The echo sentence is now directly copied from request transport
buffer to response buffer, without use of intermediate buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
057f7a2ffd mgmt/mcumgr/lib: Deprecate FS_MGMT_UL_CHUNK_SIZE
Now the chunk of uploaded file is directly read from the transport
buffer, net_buf, and is no longer copied into intermediate buffer
so the real size of chunk is actually how much the sender could
fit into MCUMGR_BUF_SIZE, less the other fields.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
7d27f8dd58 mgmt/mcumgr: Remove dependency on TinyCBOR
Mcumgr now wholy uses zcbor for decoding/encoding SMP
requests/responses.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
05b4142637 mgmt/mcumgr/lib: Remove cborattr from mcumgr
No longer used by mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
265382931f mgmt/mcumgr/lib: Remove mgmt_err_from_cbor function
No longer needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
a3793cbfa7 mgmt/mcumgr: Move Zephyr specific group to zcbor
Replacing TinyCBOR with zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
18f0db5bd0 mgmt/mcumgr/lib: Move FS command group request processing to zcbor
The commit moves processing of SMP requests from TinyCBOR to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
9f1a8cbbb4 mgmt/mcumgr/lib: Move IMG mgmt group request processing to zcbor
The TinyCBOR, in processing SMP requests, have been replaced
with zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
40462946a9 mgmt/mcumgr/lib: Add utility zcbor_map_decode_bulk
The commit adds private, for internal mcumgr use only, utility
function for bulk processing of CBOR map entries.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
ebc62e9bf9 mgmt/mcumgr/lib: Move SHELL mgmt request processing to zcbor
The commit replaces TinyCBOR for request processing within
SHELL command group.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
784d929761 mgmt/mcumgr/lib: Move STAT group request processing to zcbor
The STAT command group request processing has been moved from
TinyCBOR to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
df028e7ee6 mgmt/mcumgr/lib: Switch OS group request processing to zcbor
The commit switches OS group commands to use zcbor instead
of TinyCBOR for processing SMP requests.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
4f9f694398 mgmt/mcumgr/lib: Remove TinyCBOR state objects from mgmt_ctxt
Removes no longer needed elements of struct mgmt_ctxt.
Removes mgmt_ctxt_init, mgmt_streamer_init_reader and init_reader
from struct mgmt_streamer_cfg as they are no longer needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
9675d94119 mgmt/mcumgr/lib: Switch smp_process_request_packet to net_buf
Drops usage of mgmt_streamer.reader in favour of direct access
to net_buf.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
6bddb0305a mgmt/mcumgr: Switch cbor_nb_reader to zcbor
The commit removes cbor_decoder_reader from cbo_nb_reader and
adds zcbor state variable to the structure.
All the code that has been supporting the cbor_decder_reader
has been removed and/or replaced with zcbor/net_buf specific.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
d0445aa4a9 mgmt/mcumgr/lib: Replace cbor_decoder_reader with cbor_nb_reader
Replaces TinyCBOR cbor_decoder_reader with cbor_nb_reader in
SMP processing code.
The SMP source code has been relying on internal elements of the
cbor_decoder_reader and had to be rewritten to use net_buf
structures, that are part of cbor_nb_reader, instead.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
1c9395f3b9 mgmt/mcumgr/lib: Replace calls to mgmt_streamer_init_writer
The calls have been replaced with direct invocations of
cbor_nb_writer_init.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
bff015feff mgmt/mcumgr/lib: Remove cbor_encoder_writer from usage
With transition to zcbor, the cbor_encoder_writer structure of
TinyCBOR is no longer used.
This commit replaces the structure with cbor_nb_writer, which
gathers zcbor processing structure with netbuf into one object.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
7cac9ef413 mgmt/mcumgr/lib: Use zcbor in OS command group responses
The commit switches processing of OS command group responses
to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
f9a7ba38b1 mgmt/mcumgr/lib: Encode IMAGE command group responses with zcbor
The commit moves encoding of IMAGE command group responses to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
2c66849401 mgmt/mcumgr/lib: Encode FS command group responses with zcbor
The commit moves encoding of FS command group responses to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
8cb52b26c1 mgmt/mcumgr/lib: Encode SHELL command group responses with zcbor
The commit moves SHELL command group responses encoding to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
e9b2c6ade2 mgmt/mcumgr/lib: Encode STAT command group responses with zcbor
The commit moves STAT command group responses encoding to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
a8e0b249fe mgmt/mcumgr/lib: Move common code for responses to zcbor
Common SMP response processing code gets switched to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
c883c45752 mgmt/mcumgr: Add zcbor support for sending responses
The commit modifies cbor_nb_writer to handle zcbor.
Proper initialization code has been added to cbor_nb_writer_init.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Eduardo Montoya
fd8d1f5fb3 net: openthread: name Kconfig version choice
Name OpenThread version selection option to `OPENTHREAD_STACK_VERSION`
to be able to superseed it somewhere else.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-04-08 12:29:45 +02:00
Pieterjan Camerlynck
53327e30f2 Bluetooth: Controller: Fix null pointer dereference
Fix null pointer dereference in Controller when receiving an extended
advertisement and CONFIG_BT_LOG_LEVEL_DBG is enabled.

Signed-off-by: Pieterjan Camerlynck <pieterjan.camerlynck@gmail.com>
2022-04-08 10:22:22 +02:00
Abe Kohandel
f1e75dea50 bluetooth: ots: notify application prior to object name change
This change augments the application object name change notification to
occur prior to the actual name change done by the OTS layer.

Notifying prior to the actual name change makes it possible to inform the
application of the current name of the object as well as the new name.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2022-04-08 09:31:31 +02:00
Vinayak Kariappa Chettimada
eef7d67926 Bluetooth: Controller: Add +3dBm Tx power support in nRF53 Series
Add implementation in Controller to set radio high voltage
to enable support for +3dBm Tx Power in nRF53 Series SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-08 09:30:52 +02:00
Vinayak Kariappa Chettimada
11d81f8e0a Bluetooth: controller: Add radio_stop interface
Add radio_stop interface that will be called on radio event
done. This interface can be in turn used to perform H/w
dependent cleanup for every Radio event done.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-08 09:30:52 +02:00
Alexandru Carbuneanu
f3444ce00b Bluetooth: Host: Check encryption level for EATT channels
Check the encription level before sending on EATT.

Signed-off-by: Alexandru Carbuneanu <alexandru.carbuneanu@nordicsemi.no>
2022-04-08 09:30:45 +02:00
Jordan Yates
c910e4d931 net: context: log on net_pkt alloc fail
Log an error when allocating a network packet for transmission fails.
This is a problem which can be solved by increasing
`CONFIG_NET_PKT_TX_COUNT`, but is currently hard to diagnose.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-04-08 09:30:17 +02:00
Jonathan Rico
ef2e31a686 Bluetooth: host: Prevent null pointer dereference
bt_le_lim_adv_cancel_timeout(adv) de-references adv.
Reported by https://github.com/zephyrproject-rtos/zephyr/issues/44480.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-04-07 13:18:02 +02:00
Jani Hirsimäki
2d39c9f463 net: l2: ppp: config: fix for max terminate-req transmissions
CONFIG_NET_L2_PPP_MAX_TERMINATE_REQ_RETRANSMITS
was not having any impact and
CONFIG_NET_L2_PPP_MAX_CONFIGURE_REQ_RETRANSMITS
was used incorrectly instead for terminate().

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2022-04-07 09:39:09 +02:00
Herman Berget
60d42966e8 Bluetooth: Host: Update change-aware requirements for Bluetooth 5.3
Core spec version 5.2 introduced EATT, and multiple ATT channels on one
connection is now possible. The requirements for when a client
becomes change-aware were updated to reflect this.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-07 09:38:26 +02:00
Emil Gydesen
d98cfd1f8a Bluetooth: Audio: Improve unicast client handling of CIG
The CIG was improperly handled by the unicast
client. It attempted to remove the CIG when an ACL
was disconnected, and did not properly use the
cig_reconfigure function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-07 09:38:09 +02:00
Emil Gydesen
777a5801ea Bluetooth: Audio: Add missing null check for ep idle state
The endpoint will likely be in the idle state when
we first read the ASE state. In that case we have
not yet attached a stream to the endpoint, and
thus should not request the stream to be released when it
is NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-07 09:38:00 +02:00
Mariusz Skamra
db59647c0a Bluetooth: has: Add initial Hearing Access Service client
This adds initial support for Hearing Access Service client. The client
performs GATT discovery to find and read HAS related characteristics and
subscribe for characteristic value notifications/indications.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-04-07 09:37:53 +02:00
Lingao Meng
97a0151004 Bluetooth: Host: Fix bt_recv_thread_id assignment
The above mentioned fix attempts to detect the situation when
bt_att_req_alloc() is invoked on the same thread that runs
att_handle_rsp. It attempts to do so by noting the thread that
first ran bt_recv, assuming the same thread will house all calls
to bt_att_req_free. This turns out not to be correct. It is
evident from the call stack provided below that bt_att_req_free
can be called from other threads than the one that runs bt_recv.

Fixes: #43448

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-07 09:37:45 +02:00
Lingao Meng
502ca3b788 Bluetooth: host: Move to l2cap_internal.h
BR_CHAN should be moved to l2cap_internal.h instead of redefining it.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-07 09:37:12 +02:00
Lingao Meng
20ff55e234 Bluetooth: host: Optimize L2CAP resource usage
Making sure struct bt_l2cap_chan has absolutely no members related
to dynamic channels.

That way we ensure that there is no overhead for a build where only
fixed channels are used.

It's not enough that the dynamic channel-related members are put behind
ifdefs - they should be completely moved out from the struct definition.

Furthermore, the public l2cap.h header file already has a struct
that's meant to be used for dynamic channels: struct bt_l2cap_le_chan!

However, currently dynamic channel support is a mess - it's a mix
between these two structs. The bt_l2cap_le_chan struct should really
be an extension of the bt_l2cap_chan struct, i.e. the former should
contain as a member the latter.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-07 09:37:12 +02:00
Jordan Yates
04d29c4eb4 net: mqtt: remove custom logging macros
Remove the custom MQTT logging macros and just use the NET macros
directly. The custom macros provide no additional functionality and the
non-standard naming can cause confusion.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-04-06 17:41:06 +02:00
Karol Duda
5878f55662 cfb: support for HPACKED fonts
The HPACKED fonts are already declared in header.
Extend drawing routine to allow HPACKED fonts
along with VPACKED fonts.

Signed-off-by: Karol Duda <karol.duda@grinn-global.com>
Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
2022-04-06 09:49:00 -05:00
Jakob Krantz
4f05240cec Bluetooth: controller: df: Fix check for saturated IQ samples.
When an int16_t I or Q value was input to IQ_CONVERT_12_TO_8_BIT
the compiler would not make the correct comparison with
IQ_SAMPLE_STATURATED_16_BIT causing saturated IQ samples never
being found.

Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
2022-04-06 11:24:02 +02:00
Eduardo Montoya
ed89142661 net: openthread: add Time Sync support
Implement `otPlatTimeGetXtalAccuracy` which is missing when Time
Sync is enabled.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-04-06 11:23:41 +02:00
Casper Bonde
4d6b0ee47d Bluetooth: Stream: Add functions to parse codec parameters
This is the opesite of the macros to build codec configurations.
As some information was not up-to-date with the adopted
specification this change also includes alignment of the assigned
numbers in the Generic Audio section.
The codec config macros currently in lc3.h have moved from LC3
codec config parameters in the older specification to generic
codec configuration parameters in the adbpted specification.
This is why these additions have been made in the audio.h API
file rather in lc3.h. It is the expectation that lc3.h will be
merged into audio .h at some point.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2022-04-06 11:00:20 +02:00
Emil Gydesen
04cfb06875 Bluetooth: ISO: Add ISO recv timestamp flag
Add a flag that is set when the timestamp is supplied
by the controller when receiving ISO packets.

Previously we used 0 to indicate this, but a timestamp
value of 0 is a valid value, and should not be used
to indicate that it is not present.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-06 11:00:10 +02:00
Emil Gydesen
ffedee6e39 Bluetooth: ISO: Change ISO recv flags to bitfield
Change the receive flags in the struct bt_iso_recv_info
to a bitfield instead of a single value. This will allow
us to extend the flags with more options.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-06 11:00:10 +02:00
Krzysztof Chruscinski
653cda5029 logging: Fix LOG_OVERRIDE_LEVEL option
When option is set whole logs shall be set to minimum
of CONFIG_LOG_OVERRIDE_LEVEL. However, module was not
registered when module specific level was set to NONE.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-06 10:59:57 +02:00
Yong Cong Sin
9d10127b87 subsys/mgmt/hawkbit: Kconfig: Add HAWKBIT_DDI_SECURITY to choice
Add a name for the choice of authentication modes so that it
can be default to a certain type in project's Kconfig.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-04-06 04:51:07 -04:00
Vinayak Kariappa Chettimada
de5510668a Bluetooth: Controller: Fix Extended Scan and Periodic Sync terminate
Fix Extended Scan disable and Periodic Synchronization
terminate to cover scenarios where chain PDU reception could
complete while thread context is waiting for the radio event
to be done.

Changes here ensure auxiliary context is not released twice
which is caught as an assertion in flush() when checking for
validity of aux->parent pointer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-05 14:50:18 +02:00
Vinayak Kariappa Chettimada
2ed87e13cd Bluetooth: Controller: Fix missing check already stopped periodic aux
Fix missing return value check when Periodic Synchronization
Auxiliary PDU reception has already been stopped, this can
be due to PDU reception in LLL completing while stop has
been requested.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-05 14:50:18 +02:00
Vinayak Kariappa Chettimada
6321b9666e Bluetooth: Controller: Add additional assert check for aux release
Add additional assertion check in the control path leading
to auxiliary context release to catch regressions that may
lead to duplicate auxiliary context release.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-05 14:50:18 +02:00
Vinayak Kariappa Chettimada
5cf39c4755 Bluetooth: Controller: Fix missing Tx demux for LOW LAT ULL variant
Fix missing execution of Tx demux for LOW LAT ULL variant
which caused connection events not being maintained to
transmit the latest Tx Data enqueued while being inside a
connection event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-05 14:47:23 +02:00
Timothy Keys
e34c63012e Bluetooth: Controller: Fix -40 tx power kconfig for nrf53
Fix -40 dbm kconfig tx power option dependency rules preventing use
on nrf53 boards.

Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
2022-04-05 14:47:13 +02:00
Gerard Marull-Paretas
c925b5991a include: remove unnecessary autoconf.h includes
The autoconf.h header is not required because the definitions present in
the file are exposed using the compiler `-imacros` flag.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-05 11:18:20 +02:00
Seppo Takalo
43c988d43e net: lwm2m: Clean up context on stop
When lwm2m_rd_client_stop() was called and immediately
followed by lwm2m_rd_client_start() it leaked the file
handle for existing socket.

Problem can be fixed when rd_client_stop() does not
move state machine to IDLE, but instead DEREGISTER
and then allow state machine to move forward.

I added a blocking wait for rd_client_stop() because
it needs to wait for proper clean up.

I also move couple of lwm2m_engine_context_close() to
set_sm_state() event handler or similarly in lwm2m_engine.c
there was couple of places where context was not properly
cleaned.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-04-05 11:16:58 +02:00
Anders Storrø
e4aed1cfbd Bluetooth: Mesh: Add err check to shell input
Changes parsing of input string args  to provide error checking.
This is to prevent unintentional command execution on garbage input
strings.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-04-05 09:21:52 +02:00
Anders Storrø
7963c819f2 Shell: String to numeric conversion utils
Adds string to numeric conversion utility for shell.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-04-05 09:21:52 +02:00
Juha Heiskanen
ba2354a277 net: lwm2m: Support for "Mute Server" resource
Added support for server Mute send operation.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-04 10:29:07 -05:00
Juha Heiskanen
d75b986151 net: lwm2m: SenML Json Base compare fix
Fixed wrong initialized base name objed id.
Base name was added to every object instance.
Fix will save message size.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-04 10:28:01 -05:00
Andries Kruithof
94f7bb9194 Bluetooth: controller: llcp: remove extra initialisation
There was an extra call to llcp_lr_init and llcp_rr_init, which is
removed in this commit

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-04-04 15:34:17 +02:00
Thomas Ebert Hansen
060ac37166 Bluetooth: controller: Fix RX data pause
Reset pause_rx_data to 0 during adv enable or connection creation.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-04 15:34:09 +02:00
Thomas Ebert Hansen
fefa83d5ed Bluetooth: controller: Rework procedure pause logic
llcp_lr_pause()/llcp_rr_pause() only pauses currently pending procedures
in their respective request machines, any future initiations are not
paused, thus they are allowed to run, when the opposite was expected.

Change the procedure pause logic into a global pause on the request
machines them self, this is essence what the per-procedure pause
flag was trying to achieve.

Add new query function llcp_?r_ispaused() to not expose the logic behind
the pause functionality.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-04 15:34:09 +02:00
Thomas Ebert Hansen
79092c3cf4 Bluetooth: controller: Rework TX data pause
Change LLCP TX data pause into using mask to allow for pausing from
multiple different sources - but only once per source
(the underlying TX queue still just has an integer counter).

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-04 15:34:09 +02:00
Andries Kruithof
b909647d0a Bluetooth: controller: llcp: serialize phy update notifications
The PHY update procedure may trigger a DLE update in certain
situations
When a limited number of rx buffers is available there may not be
enough for doing the phy update and dle update notifications
at once.

Fixes #41788

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2022-04-04 15:33:59 +02:00
Thomas Ebert Hansen
3c5243fa9c Bluetooth: controller: Rewrite LLCP PDU RX handling
Rewrite ull_cp_rx to handle the following cases:

(1)
  Local active procedure
  Unexpected local procedure PDU
  Remote active procedure
  Unexpected remote procedure PDU
  => Invalid Behaviour

(2)
  Local active procedure
  Unexpected local procedure PDU
  Remote active procedure
  Expected remote procedure PDU
  => Process PDU in remote procedure

(3)
  Local active procedure
  Expected local procedure PDU
  Remote active procedure
  Unexpected remote procedure PDU
  => Process PDU in local procedure

(4)
  Local active procedure
  Expected local procedure PDU
  Remote active procedure
  Expected remote procedure PDU
  => This cannot happen

(5)
  Local active procedure
  Unexpected local procedure PDU
  No remote active procedure
  => Process PDU as a new remote request

(6)
  Local active procedure
  Expected local procedure PDU
  No remote active procedure
  => Process PDU in local procedure

(7)
  No local active procedure
  Remote active procedure
  => Process PDU in remote procedure

(8)
  No local active procedure
  No remote active procedure
  => Process PDU as a new remote request

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-04 15:20:16 +02:00
Herman Berget
101a9a7525 Bluetooth: Host: Automatically create EATT channels on connection
If the Kconfig BT_EATT_AUTO_CONNECT is enabled (on by default), the
host will try to connect BT_EATT_MAX EATT channels when a connection
to a peer is established.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-04 14:22:22 +02:00
Herman Berget
40237f3e99 Bluetooth: Host: Make bt_eatt_count public
bt_eatt_count returns the number of EATT channels connected for a given
connection.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-04 14:22:22 +02:00
Herman Berget
a4a6e7a042 Bluetooth: Host: Make bt_eatt_connect connect up to BT_EATT_MAX channels
bt_eatt_connect may now send multiple credit based connection requests.
Previously it would only send one and thus only allow 5 EATT channels to
be connected.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-04 14:22:22 +02:00
Herman Berget
4750d9621f Bluetooth: Host: Cancel EATT connection work in att_reset
When att->conn is set to NULL in att_reset, EATT connection will fail.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-04 14:22:22 +02:00
Vinayak Kariappa Chettimada
9530fb739b Bluetooth: Controller: Fix use of uninitialized secondary PHY
Fix connectable advertising to not use uninitialized
secondary PHY value to set the max_tx_time and max_rx_time
for a non-extended connectable advertising context.

The symptoms being Data Length Update event being generated
when peer central initiated Data Length Update Procedure
does not change from default 27 byte 328 us values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 14:11:32 +02:00
Vinayak Kariappa Chettimada
08311d747d Bluetooth: Controller: Use macro to check scanning on PHY enabled
Use a macro to check where scanning on 1M and/or Coded PHY
is enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 14:11:24 +02:00
Vinayak Kariappa Chettimada
4137a5b1af Bluetooth: Controller: Offset Coded PHY scan window
Offset the Coded PHY scan window by 1M PHY scan window
duration so that when 1M PHY scan window is less than
scan interval then Coded PHY scan window can utilize the
radio thereafter for its scan window duration. For
example, with 20 ms interval and 10 ms window there can
be 10 ms 1M PHY followed by 10 ms of Coded PHY scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 14:11:24 +02:00
Vinayak Kariappa Chettimada
6316ca44af Bluetooth: Controller: Introduce a timeout to get HCI event buffer
Introduce a timeout to get HCI event buffer when preparing
Extended and Periodic Advertising reports. This will prevent
silent hanging of Controller in case of insuffient Rx buffer
configurations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 14:09:51 +02:00
Vinayak Kariappa Chettimada
36c4c64675 Bluetooth: Controller: Workaround nRF52840 Revision 3 Errata 191
Add workaround for nRF52840 Revision 3 Errata 191. Removed
workaround for fixed nRF52840 Engineering Revision A Errata
164.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 13:03:08 +02:00
Juha Heiskanen
164680d696 net: lwm2m: Senml Opaque BASE64URL support and fix padding
LwM2M specification is only mentioning BASE64 encoding but SenML-JSON
specification is talking about BASE64URL encoding.
This change is silently accepting both formats and automatically pads the
data if padding is dropped.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-04 11:16:26 +02:00
Kamil Gawor
54c9a3b8e9 Bluetooth: Controller: Fix b2b rx shorts
This fixes Radio Rx when switching back-to-back is
used and device support CTE. For the CTE reception we need to use
PHYEND->DISABLE short instead of END->DISABLE short.
Using NRF_RADIO_SHORTS_PDU_END_DISABLE short handles
both cases.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-04-04 11:14:52 +02:00
Kamil Gawor
c2a0d7f761 Bluetooth: Controller: Improve handling iq samples in DTM
This adds improvements in handling IQ samples
in the Direct Test Mode.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-04-04 11:14:44 +02:00
Vinayak Kariappa Chettimada
992d133b42 Bluetooth: Increase supported maximum simultaneous connection to 250
Increase the supported maximum simultaneous connection to
250, tested under BabbleSim simulations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 10:24:34 +02:00
Vinayak Kariappa Chettimada
cfc44101a6 Bluetooth: Controller: Update to increase simultaneous connection limit
Update Controller to use uint16_t instead of uint8_t to
allow buffer counts to exceed beyond 255. Also fix pointer
arithmetic from being restricted to uint16_t that prevented
calculating the memory index for large offsets. This will
now allow support for 250 simultaneous connections, limited
by ticker_id type being uint8_t.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 10:24:34 +02:00
Vinayak Kariappa Chettimada
8ef4cfc577 Bluetooth: Controller: Force MD feature not supported in LOW LAT ULL
Add Kconfig dependency to disable use of Force MD feature
when using LOW LAT ULL variant of the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-04 10:24:19 +02:00
Vinayak Kariappa Chettimada
018f59e46f Bluetooth: Controller: NULL structure fields before release to pool
NULL structure fields before releasing memory back to pool.
Add assertion check to prevent NULL pointer dereferencing of
node rx.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-02 15:40:09 +02:00
Erik Brockhoff
046ef86e7a bluetooth: controller: optimizing random get in encryption procedure
Utilizing packed location of SKDm/s and IVm/s to only call
csrand_get() once

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-02 15:40:02 +02:00
Erik Brockhoff
e42d453e3e bluetooth: controller: use global ull_conn_event_counter() in procedures
Replace the use of local event_counter() functions with one defined
in ull_conn.c

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-02 15:40:02 +02:00
Erik Brockhoff
045735787d bluetooth: controller: removing 'no-brainer' TODOs from refactored LLCP
Getting rid of TODOs that are fairly straight forward to resolve
* introduce role checks in ENC API
* Remove ASSERT on re-rx of LL_VERSION_IND, ignore instead
* in tests/.../ctrl_chmu: rename variable and initialize initial ch map
* in tests/.../mock_ctrl/util.c: Changing TODO into FYI
* in tests/.../helper_features.h update mask and remove TODO comment
* in ull_llcp_remote.c: re-order cases in proc_with_instant switch
* in ull_conn_upd.c: PARAM REQ only uses REJECT_EXT_IND
* in ull_llcp_common.c: in CENTRAL on rx of LL_MIN_USED_CHANNELS_IND
     chose to do nothing re. channel map. Update unit test accordingly

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-02 15:40:02 +02:00
Erik Brockhoff
628d3224f9 bluetooth: controller: removing 'empty' TODO's from refactored LLCP
Cleanup, removing TODOs that should just be removed

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-02 15:40:02 +02:00
Andrzej Głąbek
586e26e8fc soc: nrf: Use data from DTS to populate HAS_HW_NRF_* Kconfig options
Instead of selecting appropriate HAS_HW_NRF_* options for particular
nRF SoCs (and simulated nRF52 target), set their values basing on
information from devicetree.
Correct also semantics of those options so that they are set only when
a corresponding DT node is enabled. This allows using them directly in
Kconfig dependencies of Zephyr drivers for nRF peripherals. Update
appropriately these dependencies.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-02 15:14:38 +02:00
Lukasz Maciejonczyk
5dd5128345 net: openthread: align platform time with radio time
On dual-core architecture the platform time can be not aligned with
radio time. This happens e.g. for nRF53 devices. Unaligned times imply
mulfunction in CSL windows scheduling.
This PR fixes it by adding/subtracting the time offset in functions
which return the plaform time. The changes have no impact on platforms
where the times are the same.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2022-04-01 12:41:12 -05:00
Vinayak Kariappa Chettimada
7802d88309 Bluetooth: Controller: Fix missing dup filtering cond. compile
Fix missing duplicate filtering feature conditional
compilation which caused build error when duplicate
filtering feature is disabled when Periodic Advertising
feature selected.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-01 12:39:37 -05:00
Carlo Caione
9bd8bbe35b ipc_service: static_vrings: Add NOCOPY capability
Add the newly introduced NOCOPY capability to the static vrings backend.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-01 09:05:06 -05:00
Carlo Caione
7cb91be0c0 ipc_service: Extend API with nocopy functions
Add several new functions to the IPC service API:
  - ipc_service_get_tx_buffer()
  - ipc_service_drop_tx_buffer()
  - ipc_service_send_nocopy()
  - ipc_service_release_rx_buffer()
  - ipc_service_hold_rx_buffer()

This set of function is used to support backends with nocopy capability.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-01 09:05:06 -05:00
Mohan Kumar Kumar
5d37de8551 net: add rcvbuf socket option
Introduce set/get SO_RCVBUF option using the setsockopt
function. In addition, use the rcvbuf value to set the
tcp recv window.

Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
2022-04-01 13:30:09 +02:00
Daniel Leung
ba488d14d4 logging: syst: add support for catalog messages
MIPI Sys-T catalog messages are similar to dictionary logging
where an ID is emitted instead of the format string. This allows
the format strings to be removed from the final binary to save
a few bytes. This adds the necessary bits to determine to emit
catalog messages when appropriate.

Note that this implementation copies the argument list as-is
with string arguments stitched together since the format strings
are assumed to have been removed and they cannot be examined
to properly convert the argument lists into catalog message
payloads. Because of this, various build asserts are there to
avoid building for configurations where they are known not to
work.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
f7d3d0268e logging: v2: add kconfig to always add indexes to msg packages
This adds a new CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS
kconfig. If enabled, the log message packages will always have
the indexes of read-only string arguments appended to the package.
This will be selected only by those backends requiring it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
8610f9f019 logging: syst: v1/imm: remove temp buffer for sync string output
The MIPI Sys-T library can now take a format string with a variable
argument list so there is no need for the temporary buffer anymore.

This saves some stack space in v1 immediate mode.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Carles Cufi
65a2e4b760 Bluetooth: host: Clear the supported commands list when disabling
Whenever we disable Bluetooth we need to  clear the supported commands
array, because there are several functions that check whether a
controller is ready to receive a particular command by testing a bit on
that bitfield.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-04-01 11:21:51 +02:00
Carles Cufi
00636682ca Bluetooth: host: Introduce a new bt_hci_le_rand() call
In order to get rid of the duplication of the code that we had until now
in the tree, consolidate the handling of multiple calls to
bt_hci_cmd_send_sync(BT_HCI_OP_LE_RAND, ...) in a single location,
namely in hci_core.

This allows all of the users of this HCI command to use a single
implementation of the iterated sending of the HCI command to fill a
buffer with random bytes.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-04-01 11:21:51 +02:00
Dominik Ermel
f44a222275 mgmt/mcumgr: Split Kconfig into smaller Kconfigs
The commit splits the main mcumgr Kconfigs into primary Kconfig
that collect general mcumgr options for Zephyr (Zephyr specific
commands, transports, and so on), into lib/Kconfig
that collects library options and command groups' Kconfigs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-31 14:36:38 -05:00
Benjamin Bigler
28e368de59 net: lwm2m: Fix missing context_close
Added missing lwm2m_context_close if set TLS_HOSTNAME failed

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2022-03-31 14:33:04 -05:00
Benjamin Bigler
6807d75e16 net: lwm2m: Fix TLS_HOSTNAME is always set
LWM2M Client Sample with DTLS enabled fails because TLS_HOSTNAME is set
but MBEDTLS_X509_CRT_PARSE_C is disabled which leads to error
'net_lwm2m_engine: Failed to set TLS_HOSTNAME option: 109'
Add new field hostname_verify to let the application decide if hostname
should be checked.

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2022-03-31 14:33:04 -05:00
Berend Ozceri
782c7b6026 net: tcp: Fix possible race condition in connection establishment
When connect() is called on a TCP socket, tcp_in() is called with a NULL
packet to start establishing a connection. That in turn leads to a SYN
packet being produced which, depending on the Ethernet driver, may
result in a synchronous transmit of that packet. After that, the
connect() implementation, which at this point is executing
net_tcp_connect() starts waiting to take a semaphore until the
connection timeout is reached. However, if the transmit of the SYN
packet results in a RST packet being returned from the connection
destination (due to there being no listening socket) very quickly on a
local network, the device driver may deliver an interrupt which can
cause the receive path of the network stack to run, resulting in the
tcp_in() of the RST packet via the network RX thread. That can cause
tcp_conn_unref() to be called before the connecting thread has gotten
to the point of acquiring (or failing to) the semaphore, which results
in a deinitialized semaphore being accessed.

This commit fixes the possible race condition by ensuring that the
connection lock mutex is held until after the connection state moves
to "in connect."

Fixes #44186

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-03-31 14:30:23 -05:00
Maciej Zagrabski
ac71af1001 cfb: introduce invert area function
Allow user to invert part of a screen, as a part of rendering.

Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
2022-03-31 11:58:29 -05:00
Maciej Zagrabski
2ae8e96573 cfb: deprecate use of specific error return values
Replace module specific return values with standard errno values.

Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
2022-03-31 11:58:29 -05:00
Johann Fischer
6be45c2a18 usb: move USB device stack code to own directory
Until now the whole USB device stack code is located
in the top subsys/usb directory. Move it to own directory
in preparation for upcoming extension and rework of USB support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-03-31 18:30:14 +02:00
Martijn Stommels
49cb6537be usb: dfu: add permanent download and automatic reboot
This commit adds the USB_DFU_PERMANENT_DOWNLOAD and USB_DFU_REBOOT and
symbols.When the permanent download symbol is enabled, slot 1 will be
marked as confirmed. With the reboot symbol enabled, the devices
automatically reboots after the download is completed.

The functionality is split into two symbols to allow the automatic
reboot without confirming the image. This enables image confirmation via
another channel. For example via the shell’s Mcuboot commands.

This functionality allows downloading an image to the device without the
user having to interact with the device. It is useful in cases where
ease of use is more important then safety. For example  when using USB
download for daily development. This is especially applicable for
devices with a closed case.

The changes were tested on an nrf52840dk. The following line can be used
to build the USB DFU example with the symbols enabled.

west build -b nrf52840dk_nrf52840 zephyr/samples/subsys/usb/dfu \
-d build-dfu -- -DCONFIG_BOOTLOADER_MCUBOOT=y \
-DOVERLAY_CONFIG=overlay-reboot-permanent.conf \
-DCONFIG_MCUBOOT_SIGNATURE_KEY_FILE\
=\"bootloader/mcuboot/root-rsa-2048.pem\"

Fixes #41921

Signed-off-by: Martijn Stommels <martijn@martijnpc.nl>
2022-03-31 15:33:16 +02:00
Vinayak Kariappa Chettimada
aab1b579b7 Bluetooth: Controller: Workaround nRF5340 Revision 1 Errata 117
Add implementation workaround for nRF5340 Revision 1 Errata
117.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-31 13:43:57 +02:00
Benjamin Bigler
493b940248 net: lwm2m: Fix address length at connect
If NET_IPV4 and NET_SOCKETS_PACKET is enabled, NET_SOCKADDR_MAX_SIZE will
be bigger than the ipv4 address length.
This is a problem when DTLS is used as the address comparison will fail
because of the different length of the received and the stored address.
This is also a problem if NET_IPV6 and NET_IPV4 is enabled and the remote
address is a ipv4 address

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2022-03-31 10:31:01 +02:00
Andreas Pettersson
df59335541 net: lib: lwm2m: Use defines for update state and result pathstrs
Use defines instead of hardcoded strings to avoid future errors if the
values would change.

Signed-off-by: Andreas Pettersson <andreaspettersson95@gmail.com>
2022-03-31 10:30:40 +02:00
Rubin Gerritsen
b52397584a Bluetooth: Controller: Enhance experimental SW_SPLIT Kconfigs names
This makes the it more intuitive when searching.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-31 10:29:21 +02:00
Rubin Gerritsen
8649eb122e Bluetooth: Controller: Only show one prompt for experimental configs
Uses the proposed workaround in
https://github.com/ulfalizer/Kconfiglib/issues/117

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-31 10:29:21 +02:00
Yong Cong Sin
313c49ec21 subsys/mgmt/hawkbit: Check the hash of stored firmware
Previously, the hash of the firmware is checked while we are
downloading the firmware. This isn't ideal as the validity of
the firmware written into the flash is not verified and can be
corrupted. Furthermore, checking while downloading will have an
negative impact to the download speed as the CPU need to do
more work during the data transfer.

This PR removes the previous verify-hash-while-download
implementation and use the flash_img_check API instead.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-31 10:28:22 +02:00
Yong Cong Sin
77d829e31e subsys/mgmt/hawkbit: Improve hawkbit_probe readability
After the firmware is downloaded in hawkbit_probe, a series of
operations are done by using the fact that the conditions of
an if-else statement will be ran until a match.

This patches separate these condition into individual
if-condition for better readability

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-31 10:28:22 +02:00
Krzysztof Chruscinski
b98f8e39fa logging: Adapt logging to use new cbprintf feature
Adapt logging to always use static packaging. Runtime packaging
is used only when configuration requires that. Static packaging
significantly speeds up logging when there are string arguments.

Update log_stack test to new stack usage.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-30 16:16:40 -04:00
Trond Einar Snekvik
6224ecbfa6 kernel: Remove idle thread cpu index on single-core devices
The idle thread got an index suffix in #23536 to make it easier to
identify different idle threads on different cores. This looks out of
place on single-core devices when the idle thread is listed next to
other kernel threads, such as main.

Remove the idle thread index on single-core platforms, and replace all
references to this format in tests and documentation.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2022-03-30 10:08:48 -04:00
Emil Gydesen
78fe76156b Bluetooth: Host: Add const to bt_conn_index
The `bt_conn_index` simply returns the index
of a `bt_conn` struct. There is no reason why
such a function should not use `const`.

Not using `const` will make other lookup/index
functions that perhaps relies on the bt_conn index
unable to use `const` as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-30 11:32:08 +02:00
Saleh Mehdikhani
d201d4d79a Bluetooth: Controller: Fixing value of sample_offset when PHY is 1M
When PHY is set to 1M, due to missed "break" statement of switch/case
the sample_offset will be set to the corresponding values of 2M
which causes improper function of sampling CTE signals.
By adding "break" statement the problem has solved.

Fixes: #44296

Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
2022-03-30 11:30:05 +02:00
Robert Lubos
0088aaefa0 net: tcp: Do not accept new data in retransmission mode
When TCP stack enters retransmission mode, the variable tracking the
amount of unacknowledged data is cleared. This prevents the stack from
detecting when TX window is full, which could lead to queueing unlimited
amount of data, effectively consuming all of the avaiable network
buffers.

Prevent this, by returning early from net_tcp_queue_data() in case TCP
stack is in retransmission mode. The socket layer will take care of
retrying just as in case the window is full.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-30 11:08:22 +02:00
Robert Lubos
2e9866f88f net: tcp: Retrigger the send work in case of loopback
In case a loopback or own address is used in TCP connection, the TCP
stack delegates the acatual data send to a workqueue. This is fine,
however it could lead to some aritificial delays in case a lot of data
is being sent before the workqueue has a chance to execute queued work
items. In such case, we only sent a single packet, when many could've
already been queued.

Fix this, by resubmitting the queue in case a local address is used, and
there's still more packets pending for send.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-30 11:08:22 +02:00
Robert Lubos
ce93fae60b net: tcp: Simple zero window probe implementation
When peer reports a zero length receive window, the TCP stack block any
outgoing data from being queued. In case no further ACK comes from the
peer, the whole communication could stall. Fix this by sending a simple
Zero Window Probe, when we detect a Zero Length Window.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-30 11:08:22 +02:00
Robert Lubos
22f970b97f net: pkt: Add net_pkt_rx_clone() function
Add a function which allows to clone a packet, using RX packet poll to
create the clone.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-30 11:08:22 +02:00
Valerio Setti
45751e2a11 logging: fix for 64 bit timestamp + new timestamp format option
Timestamps can be 32 or 64 bit long based on the platform and
build configurations. The proper way to handle these timestamps
is to use the ad-hoc log_timestamp_t variable.
This patch fixes some timestamp's reference which were still
using uint32_t changing them to log_timestamp_t.

Moreover also a new config is added in order to print the
timestamp as the Linux's kernel format. This might be useful
in AMP platforms in which Linux's and Zephyr's logs must be
interleaved in order to get a more comprehensive log solution.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-03-29 12:34:58 -07:00
Emil Obalski
d877e1dded ipc_service: Automatically include source files for backends
The purpose of this change is to allow to enable more than one
backend at once by removing choice from ipc-service backend Kconfig
and depending backend Kconfig option on existing of correct compatible.

Overwriting IPC_SERVICE_BACKEND option in some places is removes
as no longer needed.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2022-03-29 12:30:50 -07:00
Emil Gydesen
5d18f93561 Bluetooth: Audio: Unicast client missing unref on ACL disconnected
The unicast client takes a reference to the ACL, but did
not return the reference when the ACL disconnected, but
rather just reset everything.

Modified to detach the stream, ensuring
a bt_conn_unref on ACL disconnect.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-29 12:30:07 -07:00
Krzysztof Chruscinski
6d98a1cc7e debug: Revert ASSERT options dependency
f4df23c9 added dependency on ASSERT to some options prefixed
with ASSERT_ assuming that they are no used elsewhere. Turned
out that there are subsystem specific assert macros (e.g. BT_ASSERT)
which relies on those options. Removing the dependency.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-29 12:29:55 -07:00
Lingao Meng
154f5c02a8 Bluetooth: host: crypto: Add a config to select how rand is generated
Considering that in most scenarios, bt_rand will not be called
frequently, but the current implementation of tinycrypt will
occupy more than 300 bytes of RAM space. Its existence is to
optimize the frequent call of bt_rand.

Therefore, it is considered to put it into a config
(`BT_HOST_CRYPTO_RANDOM`), when this config has been selected,
will use tinycrypt library for random. Otherwise will call bt random
hci command.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-29 12:59:33 +02:00
Dominik Ermel
30fcf494be mgmt/mcumgr: Fix possible buffer overflow in BT tranport
The commit add checks whether frame received from BT transport
will really fit into allocated net_buf form mcumgr.

Fixes: #44271

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-29 10:19:09 +02:00
Kweh Hock Leong
ea43f89285 net: gptp: Fix type mismatch calculation error in gptp_mi
NSEC_PER_SEC is an unsigned integer macro. Thus, -NSEC_PER_SEC will be
treated as unsigned integer as well which lead to calculation error on
64bits integer variables. Added the correct type casting into the formula
to fix the calculation error.

Signed-off-by: Kweh Hock Leong <hock.leong.kweh@intel.com>
2022-03-28 12:47:41 +02:00
Vinayak Kariappa Chettimada
586ba9fd13 Bluetooth: Controller: Increase BT_RX_STACK_SIZE for BT_HCI_RAW enabled
Increase BT_RX_STACK_SIZE for BT_HCI_RAW enabled, as HCI
Extended Advertising Report generation requires more program
stack.

Without the update conformance test run failed with hanging
controller with mem manage fault.

Profiled the hci_uart sample using BlueZ by performing
`find -l` in `btmgmt` utility with the sample built
using:

CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_AUTO=y
CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
CONFIG_THREAD_NAME=y

Thread analyze:
 HCI uart TX         : STACK: unused 496 usage 528 / 1024 (51 %); CPU: 0 %
      : Total CPU cycles used: 146
 BT RX               : STACK: unused 72 usage 696 / 768 (90 %); CPU: 0 %
      : Total CPU cycles used: 3549
 BT RX pri           : STACK: unused 88 usage 168 / 256 (65 %); CPU: 0 %
      : Total CPU cycles used: 1210
 thread_analyzer     : STACK: unused 528 usage 496 / 1024 (48 %); CPU: 0 %
      : Total CPU cycles used: 889
 sysworkq            : STACK: unused 344 usage 168 / 512 (32 %); CPU: 0 %
      : Total CPU cycles used: 0
 logging             : STACK: unused 240 usage 528 / 768 (68 %); CPU: 0 %
      : Total CPU cycles used: 4305
 idle 00             : STACK: unused 228 usage 92 / 320 (28 %); CPU: 99 %
      : Total CPU cycles used: 3101052
 main                : STACK: unused 672 usage 352 / 1024 (34 %); CPU: 0 %
      : Total CPU cycles used: 395
 ISR0                : STACK: unused 1248 usage 800 / 2048 (39 %)

Signed-off-by: Vinayak Kariappa Chettimada <vinayak.kariappa@gmail.com>
2022-03-28 12:47:34 +02:00
Asbjørn Sæbø
ed2ea2c7df Bluetooth: Audio: Media - truncate strings for notification
Truncate strings being notified to fit the ATT_MTU, to prevent
notifications from not being delivered due to being too long.

For now uses the minimum ATT_MTU, as the MCS does not yet track
connections.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-28 12:46:53 +02:00
Kamil Piszczek
33408fa7af ipc: backends: rpmsg: initialize shared memory to zero
Added a code for initializing shared memory to zero. This operation
normalizes the memory state so that the IPC service is no longer
prone to reading status bits from the previous reset session.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-03-28 12:46:32 +02:00
Carlo Caione
92d8329d5b ipc_service: static_vrings: Move to one WQ per instance
Instead of having one single WQ per backend, move to one WQ per
instance instead and add a new "zephyr,priority" property in the DT to
set the WQ priority of the instance. Fix the sample as well.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-28 12:46:15 +02:00
Abe Kohandel
3a03d9c50d bluetooth: ots: reduce directory listing memory usage
Allocating a buffer to hold the entire directory listing consumes a very
large sum of memory when a large number of OTS objects are supported.

This implementation minimizes the memory footprint of the directory
listing by only allocating the minimum necessary buffer size to allow
for efficient over the air transfer. The contents of the transferred
buffer are built incrementally and upon request.

The directory listing manipulation upon object creation and deletion can
be removed since the directory listing content is never constructed
until it is requested.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2022-03-28 12:45:51 +02:00
Emil Gydesen
a7ed7b7250 Bluetooth: Audio: Make bt_tbs_client_cb const
Add `const` for the bt_tbs_client_cb as it is a singleton
that should not change over time.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-28 12:45:03 +02:00
Emil Gydesen
b32491df11 Bluetooth: Audio: Add Telephone Bearer Client shell module
Add a shell module for the TBS client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-28 12:45:03 +02:00
Emil Gydesen
ab4056ad8a Bluetooth: Audio: Add Telephone Bearer Service client
Add a client for the telephone bearer service (TBS).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-28 12:45:03 +02:00
Emil Gydesen
500a1792b8 Bluetooth: Audio: Add TBS shell module
Add a shell module for the TBS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-28 12:45:03 +02:00
Emil Gydesen
2a08b9e73c Bluetooth: Audio: Add Telephone Bearer Service server
Add the telephone bearer service server implementation.
This support multiple service instances as well as the
generic telephone bearer service, but is still a work in
progress and should be treated as such.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-28 12:45:03 +02:00
Christian Taedcke
05a5db4821 fs: littlefs: Use flash map macro in automount
To identify the flash partition id, the macro DT_FIXED_PARTITION_ID()
was used previously.

Now the macro FLASH_AREA_ID() is used. This also supports the usecase
when a different flash map implementation is used that redefines the
macros in include/storage/flash_map.h, e.g. the nordic partition
manager.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-03-26 12:15:09 +01:00
Emil Gydesen
66479fd001 Bluetooth: Host: Remove duplicated bt_auth callbacks
Remove the duplicated pairing_complete, pairing_failed
and bond_deleted informational callbacks from bt_auth.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-25 15:17:18 -07:00
Emil Gydesen
9c2cf4ded5 Bluetooth: Host: Add auth_info_cb struct
Add a new callback structure for Bluetooth authentication

This struct is meant to replace the information-only
callbacks in bt_conn_auth_cb. The reason for this is that
due to the nature of bt_conn_auth_cb, it can only be registered
once. To allow mulitple users gain information about pairing
and bond deletions, this new struct is needed.

Samples, tests, etc. are updated to use the new struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-25 15:17:18 -07:00
Marek Pieta
15ebdfafe2 Bluetooth: Controller: Fix filter bdaddr list size
The lll_filter is used for rl_filter and fal_filter. Size of bdaddr
must be big enough for the worst case.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2022-03-25 16:13:06 +01:00
Emil Gydesen
fe91c1dbc4 Bluetooth: ISO: Add named enum for bt_iso_state
Add an enum for the state field, to provide more
semantics to it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-25 15:36:02 +01:00
Emil Gydesen
9e862411b3 Bluetooth: ISO: Add STATE infix for ISO state enum
Change from BT_ISO_<state> to BT_ISO_STATE_<state>
to make the value more descriptive.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-25 15:36:02 +01:00
Emil Gydesen
5d25e34d89 Bluetooth: ISO: Add ing to the bt_iso (dis)connect-ing state
Add `ing` to the `BT_ISO_CONNECT` and `BT_ISO_DISCONNECT`
states, so that the name better matches the actual state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-25 15:36:02 +01:00
Emil Gydesen
c1e95d6084 Bluetooth: Host: Add ing to the bt_conn (dis)connect-ing state
Add `ing` to the `BT_CONN_CONNECT` and `BT_CONN_DISCONNECT`
states, so that the name better matches the actual state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-25 15:36:02 +01:00
Emil Gydesen
dc4d70da26 Bluetooth: conn: Expose simplified connection state in get_info
Add a state field in struct bt_conn_info that is a simplified
version of the internal state value (bt_conn_state_t).

This should provide an application to better determine the state
of the connection whne calling bt_conn_get_info, in case the
application does not keep track of the state itself.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-25 15:36:02 +01:00
Vinayak Kariappa Chettimada
2954658d3b Bluetooth: Controller: Cond. compile ISOAL for broadcast/receive only
Conditional compile ISOAL implementation to support ISO
Broadcast only and ISO Receive only application builds.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-25 12:52:11 +01:00
Emil Obalski
63b4f3e6ce ipc_service: icmsg: Pass priv user data to callbacks
This change fixes inconsistency with ipc-service API.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2022-03-25 11:33:42 +01:00
Vinayak Kariappa Chettimada
1825f81cd3 Bluetooth: Controller: Fix compiler error due to missing include file
Fix compile error, compiling the connectionless direction
finding samples, due to missing include file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-25 10:42:14 +01:00
Vinayak Kariappa Chettimada
690fc52a03 Bluetooth: Controller: Fix Periodic Sync CTE time reservations
Fix Periodic Advertising Synchronization time reservation
updated when enabling/disabling direction finding IQ
sampling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-25 10:42:14 +01:00
Anders Storrø
c0eb461c50 Bluetooth: Mesh: shell several arg idx bug fix
Fixes errornous arg index for new identity in cmd_node_id.
Fixes errornous arg index for uuid in mod_pub_set.
Fixes errornous arg index for net_idx in hb_pub_set.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-03-25 10:42:08 +01:00
Anders Storrø
cbf97cb441 Bluetooth: Mesh: shell several arg idx bug fix
Fixes errornous arg index for new identity in cmd_node_id.
Fixes errornous arg index for uuid in mod_pub_set.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-03-25 10:42:08 +01:00
Asbjørn Sæbø
1ef1ca5dd1 Bluetooth: Audio: Media control - add const keyword
Add const keyword to variables that shall not change their value.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
fb2df17933 Bluetooth: Audio: Media - move variables to innermost scope
Move variables to innermost scope - do not define the variable (and
read the value) until it is clear that the receiving callback exists.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
98fa332527 Bluetooth: Audio: Media control - guard callback
Exclude callback from struct when not needed.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
2c12328edd Bluetooth: Audio: Media control - correct return value
Change return value from calls to player(s) to EINVAL.

These functions are guarded, so that if neither local nor remote
players are supported, the functions will not be accessible.
So no need to return EOPNOTSUPP.  If the functions reach these
returns, it will be because the pointer provided does not match any
registered player.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
b4dd2d934a Bluetooth: Audio: Media control - update guard
The calls to the players were guarded by "_LOCAL_PLAYER_CONTROL".
This was incorrect for two reasons:
- the second part of each function uses the remote player, not the
  local one
- the first part of each function is for local control (only) of the
  local player

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
59b26061cd Bluetooth: Audio: Fix spelling in comment
Correct spelling in a comment

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Mariusz Skamra
35188c41ec Bluetooth: shell: Adapt to the ATT MTU API changes
This handles -EALREADY return error.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
6eafc64855 Bluetooth: audio: Enable auto ATT MTU Exchange for BASS and unicast client
This enables automatic MTU exchange for services that require MTU size
bigger than default ATT MTU to operate.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
e9becda611 Bluetooth: gatt: Add support for automatic ATT MTU Exchange
This adds support for automatic ATT MTU Exchange that will be done right
after the connection has been established.

Fixes: #43946
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
a5d9322105 Bluetooth: gatt: Skip MTU exchange if already initiated by peer
This implements Core 5.3 recommendation to skip MTU Exchange procedure
if already performed by peer.

Core 5.3 | Vol 3, Part F 3.4.2.2:
If MTU is exchanged in one direction, that is sufficient for both
directions.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
f619ca24d4 Bluetooth: gatt: Disallow repeated attempts to exchange MTU
The MTU can be exchange once during the connection by the client.
This ensures the ATT MTU Exchange request will not be sent again.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
f6d0dc355f Bluetooth: has: Add stubs for handling control point requests
This adds server stubs for handling the preset control point requests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:11 +01:00
Asbjørn Sæbø
570bc0d4bb Bluetooth: Media proxy - move mcc callbacks into instance struct
Move the media control client callbacks into the media proxy instance
struct, as requested in earlier PR review.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:39:40 +01:00
Dominik Ermel
e20f72f7cb kconfig: Remove unneeded ${ZEPHYR_BASE} from template import
The commit removes, from various Kconfigs, ${ZEPHYR_BASE} in
sourcing of logging template.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-24 18:07:28 -04:00
Piotr Pryga
3604a7bf9a Bluetooth: Controller: df: Fix CTE req send wrong ntf in single shot run
In case the CTE request was executed as a single shot and Controller
successfully received LL_CTE_RSP PDU there was an assertion.
The assertion was caused by not completely prepared notification PDU.
The notification PDU was send towards Host by CTE request handling code
due to an error in lp_comm_complete function. If the CTE request was
single shot it went into wrong if-else statement, despite that the
LL_CTE_RSP was correctly received.

A check if-clause if the procedure is periodic should not affect the
procedure completion. It should affect whether req_expire counter has
to be restored.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-24 15:26:50 +01:00
Constantin Krischke
8ee675946c modbus: stop bits can now be set individually in client mode
Added the stop_bits_client parameter to the modbus_serial_param struct.
Being able to configure the number of stop bits for the client
independently from the parity setting, allows to support connecting to
modbus server that do not follow the MODBUS over Serial Line Specification
and Implementation Guide.

Signed-off-by: Constantin Krischke <constantin.krischke@lemonbeat.com>
Signed-off-by: Jan Geldmacher <jan.geldmacher@lemonbeat.com>
2022-03-24 08:23:17 -04:00
Alexander Mihajlovic
4b2d4eb287 settings: Add support for overriding settings partition
Change NVS and FCB backends to look for chosen `zephyr,settings-partition`
in the first place, or fall back to partition "storage" if the chosen
is not set.

Signed-off-by: Alexander Mihajlovic <a@abxy.se>
2022-03-24 08:16:46 -04:00
Emil Gydesen
f474e5075e Bluetooth: Audio: Fix bad string format for ARRAY_SIZE
ARRAY_SIZE was recently changed to a size_t instead of
a long. Update the log statement to use correct
string format.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 12:50:05 +01:00
Piotr Pryga
09cd296962 Bluetooth: Controller: radio: Fix num of antennas returned by controller
The antenna number returned by controller if antenna switching is not
enabled was zero. That is not compliant with  BT 5.3. Core Spec Vol 4.
Part E section 7.8.87. In this situation returned value should be 1.

There is always single antenna available that is responsible for PDU
reception and transmission.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-24 11:59:31 +01:00
Emil Gydesen
b0a01ac82f Bluetooth: Audio: Fix broadcast sink PA sync callbacks register
The broadcast sink would continously register the PA sync callbacks,
effectively creating an infinite loop. Fixed by correctly
setting the boolean to prevent this.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
868806c211 Bluetooth: Audio: Fix broadcast sink null pointer in cleanup
Fix potential null pointer acceess in
broadcast_sink_cleanup_streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
9e765a2004 Bluetooth: Audio: add BIS index check for broadcast sink
When the broadcast sink receives a BASE it will now
properly check if the BIS indexes are valid.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
ec3793b154 Bluetooth: Audio: Fix broadcast audio endpoint disconnect state
Once a broadcast source is stopped, the endpoints
should go into the same state before it was
started (BT_AUDIO_EP_STATE_QOS_CONFIGURED), instead
of idle.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
2df9077307 Bluetooth: Audio: Add missing break for broadcast source ep state
There was a missing break statement for the
BT_AUDIO_EP_STATE_QOS_CONFIGURED state, so the
broadcast source could never go into the streaming state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
9efa22940c Bluetooth: Audio: Add broadcast source subgroup count Kconfig
Add a (initally hidden) Kconfig option for broadcast source
used to determine the size of the advertisable BASE.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
23e45c937a Bluetooth: Audio: Add subgroup count check for broadcast sink
The broadcast sink will now not attempt to decode BASEs with
more subgroups than what the broadcast sink can
actually decode.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
a50e41b059 Bluetooth: Audio: Remove unicast guard for some stream functions
Remove the unicast guard for bt_audio_codec_qos_to_iso_qos
and bt_audio_stream_attach as they are also used for
broadcast sink and broadcast source.

Also allow broadcast source to use bt_audio_stream_send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
8e34701e19 Bluetooth: Audio: Move CONFIG_BT_CODEC out of unicast-only
Move the Kconfig options for BT_CODEC out of the
BT_AUDIO_UNICAST guard, as these are used for broadcast sink
and broadcast source as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Lingao Meng
b76d74cd64 Bluetooth: Mesh: Fix adv_send call before enabled.
Since the default syswork thread priority = `-1`.
`adv_send` will call when controller report advertising
sending completed, due to this process by BT RX task, will
maybe process this before `buf_send`, since, sysworkq will be
used by other place and defer by any place.

Note: secure beacon will be 40ms, and friend and lpn will be 20ms.

This problem is very easy to reproduce, especially in native posix.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-24 10:46:07 +01:00
Lingao Meng
58a501d6cd Bluetooth: Mesh: Fix unref null pointer
When pb-gatt advertising enabled, after extablish connect,
will call `cb->connected` and `cb->adv_send`.

In previous connected also clear `ADV_FLAG_PROXY` flag, but
in `adv_send` will attempt unref null point buffers.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-24 10:46:07 +01:00
Casper Bonde
0874ff5cfd Bluetooth: Audio: ASCS: do not fail on preferred value check
bt_audio_valid_stream_qos() is used to validate the QoS parameters
set by a client. It did a check of a preferred setting which is
ok to exceed (mandatory in some cases).
This change removes the statement that causes the check to fail,
but keeps the check for debug purposes.

Fixes #43359

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2022-03-24 10:43:38 +01:00
Dominik Ermel
e1d57d19f2 mgmt/mcumgr/lib: Add missing mcumgr_img_mgmt log Kconfig options
Due to lack of proper Kconfig options for the logging module,
default were always applied.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 18:40:53 +01:00
Dominik Ermel
7de1061f5c mgmt/mcumgr/lib: Fix LOG_MODULE_NAME for image group
Was mcumgr_flash_mgmt, replaced with mcumgr_img_mgmt.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 18:40:53 +01:00
Vinayak Kariappa Chettimada
68f63246a0 Bluetooth: Controller: Fix filter accept list with periodic adv list use
Fix implementation to be able to establish synchronization
when scan filter accept list is in use and periodic
synchronization needs to be established using specified peer
address or using periodic advertiser list.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 16:32:49 +01:00
Piotr Pryga
e6f685991f Bluetooth: Controller: llcp: fix missing remote CTE REQ was handling
The CTE request has two parts: transmission of a CTE request and
reception of a CTE request. The outcome of reception of a CTE request
is transmission of CTE response.

In the new_proc_lut table for allowed remotely requested control procedures
the CTE request was quarded by CONFIG_BT_CTLR_DF_CONN_CTE_REQ.
In case of a build where CTE request is not enabled but CTE response is
the receiver part of CTE request should be enabled also.

The entry in the new_proc_lut should be quarded by CONFIG_BT_CTLR_DF_CONN_-
CTE_RSP.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-23 14:10:47 +01:00
Emil Gydesen
ae55dae454 sys: util: Change return type of ARRAY_SIZE to size_t
The ARRAY_SIZE macro uses sizeof and thus the return
type should be an unsigned value. size_t is typically
the type used for sizeof and fits well for the
ARRAY_SIZE macro as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-23 14:09:23 +01:00
Dominik Ermel
14877fd6a6 mgmt/mcumgr/lib: Use stack allocated shell buffer
The commit moves shell command buffer to stack and changes
initialization to just just put null at the beginning, before calling
a function that will fill in the buffer, and at the end, after the call.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 14:04:31 +01:00
Dominik Ermel
7dea9134a9 mgmt/mcumgr/lib: Unify source code for SHELL mgmt group
Moves Zephyr specific code to common source file and removes
no longer needed interface headers.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 14:04:31 +01:00
David Leach
a282e93079 random: rand32_ctr_drbg: fix bug preventing initialization
Bug introduced that prevented the logic from initializing the
context structure. Without this initialization, the application
will crash on repeated request for ctr_drbg random data.

Fixes: #44092

Signed-off-by: David Leach <david.leach@nxp.com>
2022-03-23 07:42:34 -05:00
Jordan Yates
01402429cc Bluetooth: check if Bluetooth has been enabled
Adds a simple boolean check of whether the Bluetooth subsystem has been
enabled. This allows users outside of `subsys/bluetooth` to check
whether they can send HCI commands.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-23 13:38:47 +01:00
Jordan Yates
38c2f892ed random: ctr_drbg: initialize on first run
With f44b3dc4df statically initializing
the entropy_dev variable, `ctr_drbg_initialize` was not being run on
the first call to `z_impl_sys_csrand_get`. Use a dedicated static bool
to track whether the init needs to be run.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-23 13:38:47 +01:00
Jordan Yates
fd618351bf random: xoshiro128: reseed state on entropy fail
When requesting seed entropy data fails, reseed the PRNG state with
runtime data. This is a minimal effort to ensure that random data
requested before a backing entropy device is ready does not result in
repeatable data on each boot.

The random XOR integers are selected from the CRC32 algorithm.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-23 13:38:47 +01:00
Jordan Yates
9bfb7bde1d random: xoshiro128: defer state init
Defer the state initialization of the xoshiro algorithm until the first
time a random number is requested. This allows the PRNG algorithm to be
used with entropy sources which may not be available at boot, i.e
Bluetooth HCI.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-23 13:38:47 +01:00
Michał Barnaś
a1ab8da862 kconfig: fix dt_node_has_prop and add nodelabel functions
The Kconfig function "dt_node_has_prop" was using label as its
parameter, where other functions use either chosen or path.
The documentation says that the parameter is path, so this patch
makes the function as documentation says and as other functions
in the file.
The additional nodelabel functions were added as counterparts that
are using nodes labels instead of paths.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-03-23 13:25:21 +01:00
Vinayak Kariappa Chettimada
fef56b3223 Bluetooth: Controller: Fix aux context release before aux done event
Fix scan aux context release when (ULL) ticker scheduling
fails due to overlapping events (example a new scan window)
and aux context being released before scan aux done event is
processed, caused assertion when processing the done event
with corrupt ULL reference count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 13:15:12 +01:00
Vinayak Kariappa Chettimada
11db2d95f8 Bluetooth: Controller: Increase event done max count for Coded PHY
Increase the event done max count when supporting Extended
Scanning with Coded PHY support, wherein prepare queue will
hold an extra resume prepare when both 1M and Coded PHY
are enabled in continuous scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 13:15:03 +01:00
Rubin Gerritsen
414329f329 Bluetooth: Host: Fix addr type when syncing using list and privacy
We expect the address type to be set to PUBLIC or RANDOM always, even
if the controller reports that it was able to sync to a resolved
addresss.

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

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-23 13:11:12 +01:00
Vinayak Kariappa Chettimada
1f973f4330 Bluetooth: Controller: Fix Extended Scan disable livelock
Fix implementation from enqueueing duplicate node_rx which
leads to infinite loop processing the node_rx list.

Relates to commit a5fb434705 ("Bluetooth: Controller: Fix
to stop Extended Auxiliary Scan context").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:57:08 +01:00
Vinayak Kariappa Chettimada
4548bd9a25 Bluetooth: Controller: Use ticker yield to allow chain PDU receive
Use ticker yield interface to allow chain PDU reception that
overlaps with currently reserved time for received PDU.
Without the yield ULL scheduling to receive auxiliary PDU
fails to be scheduled using ticker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:53:38 +01:00
Vinayak Kariappa Chettimada
53996ba459 Bluetooth: Controller: Yield stopped ticker time reservations
Update ticker_yield_abs implementation to allow yielding
expired single shot tickers.

Relates to commit bce82ad49b ("Bluetooth: controller: Add
ticker_yield_abs interface").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:53:38 +01:00
Vinayak Kariappa Chettimada
8482c95884 Bluetooth: Controller: Use minimal time reservation for aux receive
Use minimal time reservation for aux receive.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:53:38 +01:00
Vinayak Kariappa Chettimada
5dc29b2c8c Bluetooth: controller: Fix aux offset overhead calculation and margin
Fix missing use of EVENT_TICKER_RES_MARGIN_US and receive
chain delay in the calculation of overhead value that
determines if ULL or LLL scheduling to be used to receive
auxiliary PDUs.

Also, fix missing use of EVENT_TICKER_RES_MARGIN_US when
ULL scheduling for reception of auxiliary PDU.

See also commit 544acb9804 ("Bluetooth: controller: Fix
missing EVENT_TICKER_RES_MARGIN_US").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:53:38 +01:00
Asbjørn Sæbø
75e6680086 Bluetooth: Audio - media: Make local control of local player default
Make local control of local player the default if control of local
player is configured.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
6ca4cf8ff5 Bluetooth: Audio - media - add more guarding
Add include guards for local player local control

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
9c43315d4f Bluetooth: Audio - media - guard instance members
Guard media proxy instance members.
As a consequence, change guarding for functions using remote player
member.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
347181866e Bluetooth: Audio: Media - change default kconfig values
Change the default URL length value to something that can contain the
default URL string.
Increaste the default track title length.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
476ff198bb Bluetooth: Audio - MCS kconfig - fix spacing in comments
Change double-space after period to single space.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
308390f5af Bluetooth: Audio: MCS config file cleanup
- Rename MCS configs that are only used by MCC to "MCC", add some more
  documentation.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
e494debdc8 Bluetooth: Audio: Use new media control configs in media proxy
Update the media proxy to use the new Kconfigs to include/exclude the
various parts of the implementation. This replaces existing guarding
using other Kconfig values.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
29aa654600 Bluetooth: Audio: Media control Kconfig
Add Kconfig file for the media proxy, for high-level media control
configuration.

The media proxy did not have a Kconfig file, it was relying on the
Kconfigs for GATT media control client and server.

The purpose is to unify the media control configurations, to make the
different media control functionalities available separately, and to
separate the high-level media control from the bluetooth media control
server and client.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
0092f7467f Bluetooth: Audio - remove media controller dependency
The media controller internal header file does not need to depend upon
the media proxy header.

Requires one piece of spec info here, but the media player already
needs to adhere to the media control service spec, so situation no
worse than before.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
8e509b47a9 Bluetooth: Audio: Fix initialization of not present module
Do not initialize the media control service if it is not configured.

This is a temporary fix, there is an issue to fix this properly:
https://github.com/zephyrproject-rtos/zephyr/issues/42965

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
e3a7ed4766 Bluetooth: Audio: Separate Kconfig for MPL
Separate out the Kconfig for the media player.
Also removes some unused MCS configs.

The media player has been using MCS configs, while it should be the
other way around.

Also, this will make it easier to move the media player elsewhere, as
has been discussed.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
8c01c69779 Bluetooth: Audio: Bugfix - add cast to conn pointer
Cast conn pointer to void in debug statement, to avoid compilation
error.

(Explanation given: Trying to log an opaque pointer causes error.)

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Dominik Ermel
a47fff2d02 mgmt/mcumgr/lib: Fix unneeded stats gathering when container failed
The commit makes stats collection conditional so in case when
CBOR container encoding fails the stats collecting function
will not be called.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 14:49:35 +01:00
Jamie McCrae
6d7d414204 mgmt: mcumgr: lib: smp: Fix checking variable before set
Fixes a twister test issue whereby handler_found and valid_hdr variables
are checked prior to being set.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-03-22 08:32:03 -04:00
Kamil Gawor
71a4c05120 Bluetooth: controller: Use rx back to back interface
Use the back-to-back receive of PDU with a
configurable inter frame spacing. This fixes an issue
when nRF53 was able to receive only one Rx PDU and
was not able to switch to next Rx.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-03-22 12:40:12 +01:00
Vinayak Kariappa Chettimada
fc25cc82a1 Bluetooth: controller: nRF5: Back-to-Back Radio Rx interface
Add Radio interface to perform back-to-back receive of PDU
with a configurable inter frame spacing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-22 12:40:12 +01:00
Emil Obalski
40b28ab51e ipc_service: Add new backend based on custom messaging buffer
This commit adds ipc backend, that relies on simple
inter core messaging buffer also added by this commit.

This backend is configurable with DT overlay. Each
ipc instance could be defined with ipc-icmsg commpatible.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2022-03-22 12:36:39 +01:00
Tim Sørensen
9312b79b1c edtt: Extend Zephyr EDTT test app with IXIT request/response command
This command is used to obtain 'Implementation eXtra Information for Test'
(IXIT) values that are required to proceed with BT qualification tests.

Signed-off-by: Tim Sørensen <tims@demant.com>
2022-03-22 12:35:32 +01:00
Ludvig Samuelsen Jordet
0a8ad746af Bluetooth: Mesh: Add warning about RPL persistence
With BT_SETTINGS disabled, or when using an indefinite
RPL_STORE_TIMEOUT and not storing the RPL, the device will not be able
to follow the replay protection required by the spec. This adds a
warning about this.

Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
2022-03-22 12:35:15 +01:00
Vinayak Kariappa Chettimada
d214bc5340 Bluetooth: Controller: Fix uninitialized param in sync report
Fix uninitialized param field when generating incomplete
no more data to come periodic advertising report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-22 12:33:49 +01:00
Vinayak Kariappa Chettimada
6fb38eb24f Bluetooth: Controller: Fix sync reports post terminate and rx disable
Fix generating periodic advertising reports post sync
terminate under race condition when disabling reporting or
terminating the sync or while performing HCI reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-22 12:33:49 +01:00
Vinayak Kariappa Chettimada
a602a18660 Bluetooth: Controller: Add static build assert to check mem member
Added BUILD_ASSERT definition to check for safe access to
memory pool allocated memory structure member after the
memory has been released back to mem pool.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-22 12:33:49 +01:00
Marin Jurjević
683868f3d2 net: lwm2m: fix potential invalid pointer dereference in reset message
Sometimes message is being reset from multiple locations in code.
If message has already been reset, pointer to context is invalid.

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-03-22 12:33:31 +01:00
Mariusz Skamra
e01e2235d3 Bluetooth: ascs: Fix ASE invalid state transition
This fixes issue where, the ASE went directly to QoS Configured state
when in Releasing state and the ISO link has been disconnected.

To not change the current behavior, the transition from Streaming state
has been unchanged, but rather fixed depending on the ASE direction.

Fixes: #44004
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-22 12:33:03 +01:00
Mariusz Skamra
d0111f7f44 Revert "Bluetooth: gatt: ccc changed cb after connection cb"
This reverts commit 6bb75a53d1.
This fixes GATT that was uninitalized when application received
bt_conn_cb->connected callback. As the result, the bt_gatt_is_subscribed
was not working as expected when called from bt_conn_cb->connected.

The _bt_gatt_ccc->cfg_changed callback does not carry information about
the device that subscribed for notifications but rather is says the
app when it should start/stop broadcasting notifications.

This leads to the conclusion that the bt_gatt_ccc->cfg_changed can be
called before bt_conn_cb->connected callback.

Fixes: #42829
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-22 12:32:54 +01:00
Juha Heiskanen
0c6ea8eec4 net: lwm2m: Fix Read operation for /object
Read operation must return empty payload when read /object_id
if there is no created object instances.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-22 12:32:45 +01:00
Mariusz Skamra
cb28ffbc8b Bluetooth: has: Improve grouping of settings
Use menuconfig in order to give a better grouping of HAS related
settings with separate subpage.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-22 12:32:29 +01:00
Artur Hadasz
001894a1c0 ipc: use highest coop priority for workqueue in new IPC backend
The priority of workqueue responsible for rpmsg processing was too
low. Any cooperative task could cause rpmsg processing to be
slightly delayed.

Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
2022-03-22 12:29:17 +01:00
Dominik Ermel
5a4f5abc4d mgmt/mcumgr/lib: Fix CONFIG_IMG_MGMT_VERBOSE_ERR
The IMG_MGMT_VERBOSE_ERR Kconfig option has not been really working
since the SMP response that it would setup was reset in case of
error, so in any instance that it would actually be used.

Fixes #32545

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:40:19 +01:00
Dominik Ermel
41cc3f04a0 mgmt/mcumgr/lib: Add support for "rsn" in error SMP responses
The commit adds support for passing "rsn" explanation strings,
for "rc" code, in error SMP responses.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:40:19 +01:00
Dominik Ermel
cbd48e1294 mgmt/mcumgr/lib: FS mgmt replace zephyr_fs_mgmt_truncate
The zephyr_fs_mgmt_truncate has been replaced with fs_unlink
since there is no point to specially check for file existence
before just removing it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:53 +01:00
Dominik Ermel
a0d379a646 mgmt/mcumgr/lib: Fix return paths code style
Functions fs_mgmt_impl_read and fs_mgmt_impl_write have been missing
proper returns.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:53 +01:00
Dominik Ermel
02f355c541 mgmt/mcumgr/lib: FS management reduce duplicated "rc" setting code
The fs_mgmt_file_upload_rsp has been renamed fs_mgmt_file_rsp
and is used everywhere where "rc" code and "off" is placed into
response, instead of duplicating code that does the task.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:53 +01:00
Dominik Ermel
aa0249ddd1 mgmt/mcumgr/lib: STAT mgmt: Remove stat_mgmt_get_group function
The function has been reimplemented within stat_mgmt_list directly,
reducing execution time and code size.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:32 +01:00
Dominik Ermel
6314a9c6d8 mgmt/mcumgr/lib: Unify STAT group code
The commit merges Zephyr specific code from zephyr_stat_mgmt.c
to stat_mgmt.c, removes *_impl_* prototypes of functions that are
used for system specific implementations.
zephyr_ prefixes have been removed from identifiers as they are
no longer needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:32 +01:00
Dominik Ermel
a3ec5b258c mgmt/mcumgr/lib: Start response container after request validation
The commit reorganizes smp_handle_single_payload function to only
open map container, in response, after request have been validated
to be processable.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:03 +01:00
Dominik Ermel
2a33947842 mgmt/mcumgr/lib: Remove unused arg param from mgmt_init_writer_fn
The commit removes arg parameter from mgmt_init_writer_fn
function typedef and implementation in zephyr_smp_init_writer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Dominik Ermel
10f41622d2 mgmt/mcumgr/lib: Remove unused arg para from mgmt_init_reader_fn
The commit removes arg parameter from mgmt_init_reader_fn
function typedef and implementation in zephyr_smp_init_reader.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Dominik Ermel
88e2b4c768 mgmt/mcumgr/lib: Replace smp_init_rsp_hdr with smp_make_rsp_hdr
The smp_make_rsp_hdr prepares new response header from request
header, sets proper frame length to it and converts it to
network format.
Because a respose buffer has now pre-allocated space for header
it is no longer required to call the smp_make_rsp_hdr,
formerly smp_init_rsp_hdr, to reserve such space before adding
data that should follow it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Dominik Ermel
d643a9c4ea mgmt/mcumgr: Reserve SMP header size on buffer initialization
The commit changes cbor_nb_writer_init function to reserve
SMP header size on init. The change makes call to
mgmt_streamer_reset_buf within smp_write_hdr no longer needed.
The mgmt_streamer_write_at function, that has been exclusively
used to write headers, have been replaced with mgmt_streamer_write_hdr
and zephyr_smp_write_hdr, formerly zephyr_smp_write_at, has been
reduced as it no longer needs to check and update net_buf metadata
to write header as the cbor_nb_writer_init does it now.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Nirosharn Amarasinghe
3cdaf72d9d bluetooth: controller: Add ISO-AL TX unframed fragmentation
- Implemented ISO-AL TX interface functions for fragmentation of
  unframed PDUs
- Implemented ISO-AL source construct and its creation for an input
  data path

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-03-21 19:03:56 +01:00
Gerard Marull-Paretas
c966a95718 mgmt: mcumgr: fix Kconfig option prompt
Boolean options must not start with "Enable...". Adjusted the prompt to
comply with the guidelines.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-21 18:54:08 +01:00
Dominik Ermel
92103b835b mgmt/mcumgr: Add optional packet re-assembly to BT transport
New CONFIG_MCUMGR_SMP_BT_PKASM has been added that enabled
SMP packet re-assembly, at transport level, to the BT.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Dominik Ermel
a99118d140 tests/mgmt/mcumgr/smp_reassembly: Unit tests for re-assembly
The commit adds unit tests for SMP packet re-assembly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Dominik Ermel
d0499d112a mgmt/mcumgr: Add packet re-assembly support
The commit adds packet re-asembly to SMP that can be used to
collect packet from fragments at SMP transport level.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Dominik Ermel
fa71c9c9e8 mgmt/mcumgr/lib: Prepare mcumgr smp for logging
Commit adds configuration for logging from mcumgr SMP protocol
source, and registers logging module.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Vinayak Kariappa Chettimada
70a1827fc1 Bluetooth: Controller: Use the received coding scheme for Periodic Sync
Use the received coding scheme when receiving Periodic
Advertising PDUs for correctly calculating the receive
chain delay and on-air PDU time.

Relates to commit 6911e7e1d8 ("Bluetooth: Controller: Use
the received coding scheme when scanning").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-21 16:09:38 +01:00
Vinayak Kariappa Chettimada
37026650a1 Bluetooth: Controller: Use the received coding scheme for advertising
Use the received coding scheme when receiving Extended
Advertising PDUs for correctly calculating the receive
chain delay and on-air PDU time.

Relates to commit 6911e7e1d8 ("Bluetooth: Controller: Use
the received coding scheme when scanning").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-21 16:09:38 +01:00
Vinayak Kariappa Chettimada
df666d1809 Bluetooth: Controller: Use PHY_FLAGS_S8 define
Use PHY_FLAGS_S8 define instead of hardcoded values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-21 16:09:38 +01:00
Vinayak Kariappa Chettimada
54ddd8d031 Bluetooth: Controller: nRF53: Fix compile error when debug pins enabled
Fix compile error when debug pins are enabled for nRF53
Series SoCs.

Regression introduced in commit 743b0583fc ("Bluetooth:
controller: Enable debug pins with TF-M enabled").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-21 12:50:19 +01:00
Vinayak Kariappa Chettimada
8c89a9fd42 Bluetooth: Controller: Fix missing periodic accept list SID assignment
Fix missing assignment of SID in the Periodic Advertiser
Accept List. This cause advertisers with SID 0 only to be
accepted when using list.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-21 12:49:45 +01:00
Vinayak Kariappa Chettimada
311eabeda1 Bluetooth: Controller: Fix Tx Power in Extended and Periodic Adv Report
Fix Tx Power field in Extended and Periodic Advertising
for chain PDU reception. Tx Power shall be from the
current PDU containing the AD Data, Scan Response Data and
from first PDU of Periodic Advertising Data be used to
prepare the HCI report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-21 12:49:37 +01:00
Sjors Hettinga
1165bd667f net: http: Allow a content_len of 4GB
Instead of maximally 99999 bytes allow a content_len of 4GB.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-03-21 10:16:21 +01:00
Piotr Pryga
9cb4e58a48 Bluetooth: Controller: df: make radio_df_vendor_hal.h compile in always
The header file radio_df_vendor_hal.h was conditionally copiled in.
There were a dependency on a CONFIG_BT_CTRL_DR. The dependency is
removed because radio_df_vendor_hal.h and radio_df.h hasn't got any
DF related type dependencies. What more it allows to use IS_ENABLED
for code that uses types and functions defined in radio_df.h.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-21 10:15:39 +01:00
Piotr Pryga
07f02f90ae Bluetooth: Conroller: radio: Clear EVENTS_CTEPRESENT always if DF supp
The EVENTS_CTEPRESENT is available when radio peripheral has
direction finding support. The event is set if received
PDU has CTEInfo and there were collected IQ samples during
CTE reception.

The event should be cleared always when other events are cleared.
That guarantees that the event is not set when use of radio for
following activities.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-21 10:15:39 +01:00
Piotr Pryga
15b1c3eaf8 Bluetooth: Controller: lll: df: Check CTEPRESENT before radio reset
The radio_df_cte_ready function returns state of EVENTS_CTEPRESENT.
The function may not be used in create_iq_report function, because
it is called after lll_isr_rx_status_reset. The lll_isr_rx_status-
_reset clears EVENTS_CTEPRESENT value.

The result of this calls chain is lack of IQ sample report no matter
if the PDU has CTEInfo and radio has collected IQ samples.

To fix the problem, state of EVENTS_CTEPRESENT has to be get when
e.g. rssi_ready is get.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-21 10:15:39 +01:00
Vinayak Kariappa Chettimada
7f97c04bf8 Bluetooth: Controller: Fix jitter between primary and auxiliary PDU
As Extended Advertising primary PDUs do not use ticker
remainder value for fine scheduling of radio events, do not
use the remainder value for auxiliary PDUs. This fixes the
jitter in the aux_offset value that caused the auxiliary PDU
being observed to be late compared to the aux_offset value
filled in the primary PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-21 10:14:59 +01:00
Szymon Janc
2f93808bcc Bluetooth: Host: Validate security on GATT subscription
Core Specification 5.3 clarified security requirements for GATT client
when handling incoming notifications and indications.

Vol 3: Part C: 10.3.2.2:
"...Since the configuration is persistent across a disconnection and
reconnection, the client shall check the security requirements against
the configuration upon a reconnection before processing any indications
or notifications from the server. Any notifications received before
the security requirements are met shall be ignored. Any indications
received before the security requirements are met shall be confirmed
and then discarded. ..."

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-03-21 10:14:53 +01:00
Dominik Ermel
9a0174df40 mgmt/mcumgr: Storeage erase may bus fault when no device
The commit fixes erase storage command so that it would return with
error code instead of bus faulting when no device is attached
to flash storage.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 10:14:41 +01:00
Dominik Ermel
c842bb1ac1 mgmg/mcumgr/lib: Fix image commandis bus faults when no device
It is possible for flash partition to have no device attached
which may cause image commands to bus fault device.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 10:14:41 +01:00
Carlo Caione
3fc5150f36 ipc_service: static_vrings: Use atomic helpers
Use the correct atomic helpers when accessing atomic_t variables and fix
a possible race condition.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-21 10:14:32 +01:00
Mariusz Skamra
7c99e67b94 Bluetooth: audio: Add initial Hearing Access Service implementation
This adds bare minimum implementation of Hearing Access Service.
The GATT HAS service contains one Hearing Aid Features mandatory
characteristic.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-21 10:14:15 +01:00
Henrik Brix Andersen
67ba9900f0 drivers: can: add struct device argument to callback functions
Include a pointer to the CAN controller device for the CAN
transmit, receive, and state change callback functions.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-19 14:31:22 -04:00
Martin Jäger
9cc32af99e lorawan: allow setting of DevNonce for OTAA re-join
Starting with LoRaWAN 1.0.4 the DevNonce sent with the OTAA join must be
monotonically increasing for each new join with the same EUI. The DevNonce
should be stored in non-volatile memory by the application.

This commit uses a simple extension of the lorawan_join_otaa struct to
allow specifying the DevNonce.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-03-19 14:29:01 -04:00
Nazar Kazakov
f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Kamil Gawor
a80416fede bluetooth: controller: Align the Openisa test ll API
Alignes the Openisa ll_test_tx and ll_test_rx functions
with the new test API.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-03-18 12:00:03 +01:00
Kamil Gawor
5db0302c99 bluetooth: controller: Add support for all DTM commands
This adds support for the following Direct Test mode
commands:
- HCI LE Receiver Test [v3]
- HCI LE Transmitter Test [v3]
- HCI LE Transmitter Test [v4]

Those commands set add a possibility to test an CTE
reception and transmission. The HCI LE Transmitter
Test [v4] commands allows also setting a transmit power.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-03-18 12:00:03 +01:00
Szymon Janc
a5364567ec Bluetooth: controller: Make sure effective DLE is valid
If peer sends invalid data length in response IUT should fix those
when calculating effective data length.

This was affecting following qualification test cases:
LL/CON/PER/BI-10-C
LL/CON/PER/BI-11-C
LL/CON/PER/BI-12-C
LL/CON/CEN/BI-07-C
LL/CON/CEN/BI-08-C
LL/CON/CEN/BI-09-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-03-18 11:39:27 +01:00
Robert Lubos
ffdc621f1b net: http_client: Fix http_client_req() return value
http_client_req() was supposed to return the number of bytes sent as a
HTTP request. The return value was not riht however due to some bugs in
helper functions:
* http_send_data() returned the current buffer position istead of the
  number of bytes actually sent. This could result in counting the same
  data into the total request size several times. A helper variable was
  added to track how many bytes were actually sent to the network.
* http_flush_data() forwarded the return value of sendall() helper
  function. That function however did not return number of bytes sent,
  but 0 or a negative error code.

Additionally, change the return type of sendall() function - according
to standard the ssize_t type is only capable of holding -1 negative
value, but the function could return the full range of negative errno
values. Use int instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-18 11:14:24 +01:00
Aleksander Wasaznik
4fcaba29e2 Bluetooth: Host: Fix GCC 7 error: non-constant expr in initializer
Using a const-qualified object in a static initializer is implementation
specific in C, and it does not work in GCC 7.

Before this change, `write_appearance` was a pointer object if
CONFIG_BT_DEVICE_APPEARANCE_GATT_WRITABLE was disabled. This change
removes that object in favor of a macro `GAP_APPEARANCE_WRITE_HANDLER`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-03-18 10:21:49 +01:00
Eduardo Montoya
3efc73f031 manifest: openthread upmerge up to commit 9f30e049
Regular OpenThread upmerge.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-03-17 16:37:03 -05:00
Juha Heiskanen
9777ba7354 net: lwm2m: SenML JSON dynamic Resource instance allocation
Integrated dynamic resouce instance allocation to SenML JSON.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-17 11:41:42 +01:00
Vinayak Kariappa Chettimada
4aad6d0d66 Bluetooth: Controller: Fix Extended Legacy Direct Advertising report
Fix Extended Legacy Direct Advertising report to have the
correct Target Address.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-17 11:38:40 +01:00
Vinayak Kariappa Chettimada
07ff037da3 Bluetooth: Controller: Avoid pre-empting when extended active scanning
Avoid pre-empting scan window when extended active scanning.
If a scan request has been transmitted, then avoid being
pre-empted at the end of window when in continuous scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-17 11:38:17 +01:00
Vinayak Kariappa Chettimada
7c7da5d4a4 Bluetooth: Controller: Fix power amp for transmit of chain scan resp
Fix power amp for transmitting of chain scan response
wherein capture of PDU end timestamp was missing causing
power amplifier from not being enabled for first chain PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-17 11:37:41 +01:00
Mariusz Skamra
26ff5a30d2 Bluetooth: bap: Remove EATT dependency
The EATT support is optional for BAP. The specification mandates the
minimum MTU supported to be 64 bytes.

As per BAP_v1.0
"The Unicast Server shall support a minimum ATT_MTU of 64 octets for
one Unenhanced ATT bearer, or for at least one Enhanced ATT bearer
if the Unicast Server supports Enhanced ATT bearers."

The same applies for other BAP roles.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-17 11:37:21 +01:00
Vinayak Kariappa Chettimada
d402dbb652 Bluetooth: Controller: Fix auxiliary context flush on auxiliary stop
Fix auxiliary context from being flushed when scanner or
periodic synchronization is stopped, to avoid using the
disable_cb by both. Fixes an assertion when this race
condition happens.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-17 11:36:05 +01:00
Vinayak Kariappa Chettimada
3325aac985 Bluetooth: Controller: Fix to not send release message to HCI
Do not enqueue NODE_RX_TYPE_RELEASE into Auxiliary context
when stopping scanner, as this type is not to be passed to
HCI processing, which would lead to assertion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-17 11:36:05 +01:00
Vinayak Kariappa Chettimada
8b26752199 Bluetooth: Controller: Fix auxiliary context leak on stop
Fix auxiliary context leak on stop, under race condition
where ULL High execution context does not release the
auxiliary context as stop has been requested, and done
has decremented the auxiliary context's reference count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-17 11:36:05 +01:00
Vinayak Kariappa Chettimada
c1e78c232e Bluetooth: Controller: Fix the order of Periodic Sync in HCI Reset
Fix the order of Periodic Synchronize reset during HCI
Reset Command. Perform scan reset last after Periodic
Synchronize reset to avoid resetting the auxiliary
context which may be in use by Periodic Synchronize.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-17 11:33:43 +01:00
Rubin Gerritsen
c17bc7ad2a Bluetooth: Kconfig: Move audio and mesh to be shown under host
These subsystems are part of the host.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-17 11:12:47 +01:00
Rubin Gerritsen
beaa73ff19 Bluetooth: Kconfig: Hide buffer configuration in a separate menu
Users will usually not want to browse through these. Therefore it is
better to hide them a bit.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-17 11:12:47 +01:00
Rubin Gerritsen
6a687da940 Bluetooth: Kconfig: Move BT_LIM_ADV_TIMEOUT to host config
This configuration is meant to be in the host.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-17 11:12:47 +01:00
Rubin Gerritsen
96a2f56ac6 Bluetooth: Kconfig: No use menu for observer and broadcaster configs
This will ensure that they don't turn up as sub-menus

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-17 11:12:47 +01:00
Rubin Gerritsen
d13ff191c3 Bluetooth: Kconfig: Remove Controller comment line
The controller configuration is already a submenu

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-17 11:12:47 +01:00
Rubin Gerritsen
1e0e2370ac Bluetooth: Kconfig: Move GATT Kconfig to be part of host
This prevents GATT service selection being selectable when compiling
controller only builds.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-17 11:12:47 +01:00
Rubin Gerritsen
db9ae3e09a Bluetooth: Kconfig: Move Host configuration to a separate menu
This reduces the number of visible options.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-03-17 11:12:47 +01:00
Robert Lubos
81b92fcbb3 net: tcp: Verify accept callback before use
Closing a listening socket will set the accept callback to NULL.
This could lead to a crash, in case an already received packet,
finalizing the connection handshake, was processed after the socket was
closed. Thereby, it's needed to verify if the callback is actually set
before processing it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-16 16:23:16 +01:00
Robert Lubos
08752aed0f net: sockets: Fix userspace accept() verification
The verification function for accept() did not take into account that
addr and addrlen pointers provided could be NULL.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-16 16:23:16 +01:00
Robert Lubos
546267ab3b net: sockets: Implement getpeername() function
Implement getpeername() function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-16 16:23:16 +01:00
Gerard Marull-Paretas
8f913d1977 pm: policy: allow to get notifief when maximum latency changes
Add a new API that allows to register a callback that is called when the
maximum latency value changes. This can be used by SoC code to perform
actions based on certain latency values.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
35fd6eadbf pm: policy: new API to set maximum latency requirements
Add a new API that allows to configure maximum latency requirements.
When the policy manager computes the next state, it will check if the
state brings too much latency based on requirements. This can be useful,
for example, if a certain driver or the application want a system to
respond fast, since any low power state that brings too much latency
will not be used.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
e6339eac1a pm: policy: assert on unbalanced state lock get/put
The state lock get/put calls should always be balanced: first call get
and then put. Add an assertion in case lock counter is about to go
negative, indicating a programming error.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
5a71eeb35c pm: policy: move constraints to policy API
The pm_constraint_* APIs were effectively used by the policy manager
only. This patch renames the API to the policy namespace and makes its
naming more explicit:

- pm_constraint_set -> pm_policy_state_lock_get()
- pm_constraint_release -> pm_policy_state_lock_put()
- pm_constraint_get -> pm_policy_state_lock_is_active()

The reason for these changes is that constraints can be of many types:
allow/disallow states, impose latency requirements, etc. The new naming
also makes explicit that the API calls will influence the PM policy
behavior.

All drivers and documentation have been updated accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
d158f512ac pm: constraint: cleanup include list
Most include files were not used, and `toolchain.h` was missing (needed
by `__weak`).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
ebb88fb3a2 pm: constraint: remove unused logging
The constraint code does not log, so remove include/module declaration.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
a66a4cdf6e pm: constraint: remove redundant assertions
1. state < PM_STATE_COUNT: the function argument is an enumeration that
   already indicates the valid values. It is a programming error to pass
   random integer values, the API should not be defensive "just in case
   the application has messed things up".
2. v < UINT_MAX: first, this assumes type used by `atomic_t` (opaque).
   Second, if the integer overflows it will just wrap around, so the
   check does nothing in practice.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
3c38a41991 pm: policy: remove unused logging
The policy file does not perform any logging, so just drop logging
include and declaration.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
2238387285 pm: policy: move to pm folder
Move policy code one level up for simplicity, since there is a single
source file. Source file has been renamed to "policy.c" to make things
clear.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas
22fe2142f0 pm: policy: use DEFAULT/CUSTOM naming
The residency policy, is in reality, influences by other parameters for
example constraints. It has been renamed to "DEFAULT" policy to make it
more general. The "APP" policy has been renamed to "CUSTOM" to better
represent its purpose.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Tomasz Bursztyka
521c9d13fb pm: constify all device instances
Run cocci script to constify device instances.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-03-16 12:33:12 +01:00
Robert Lubos
2f2c356ca7 net: tcp: Verify if IPv4/IPv6 is enabled before processing addr family
TCP processed IPv4/IPv6 packets w/o verifying first if IPv4/IPv6 is
enabled in the system. This could lead to problems especially for IPv6,
where in case it's disabled the sockaddr structure is not large enough
to accomodate IPv6 address, leading to possible out-of-bound access on
the sockaddr structure.

Fix this by adding appropriate checks where applicable.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-16 04:21:34 -07:00
Krzysztof Chruscinski
786647bdcf lib: os: assert: Avoid including printk.h in __assert.h
Create wrapper for printk to avoid including printk.h in __assert.h.
__assert.h is used everywhere thus should not have dependency to
printk.h.

Cleanup assert Kconfig options.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-16 10:27:20 +01:00
Juha Heiskanen
6cb662a495 net: lwm2m: Composite Observation update
Added support for Composite observation for LwM2M v1.1.
Updated current Observation node to support linked path list.
Rename typos lwm_ to lwm2m_.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-16 10:26:01 +01:00
Juha Heiskanen
6970addc12 net: lwm2m: Observation pmin and pmax refactor
Removed to store pmin and pmax at oberservation node structure and
use attribute list store for calculate time for next Notification.
Observation class use timestamp for triggering notification based on
resource update which use pmin and default pmax behaviour.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-16 10:26:01 +01:00
Yong Cong Sin
d2f7d696aa subsys/mgmt/hawkbit: update http response handling
Following the merge of #42026, the http body handling can be
simplified.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-16 10:25:38 +01:00
Mariusz Skamra
145948efa0 Bluetooth: audio: Remove BT_CODEC_META_CONTEXT_* defines
There are no more context defines specific to metadata, the ones
coming from Assigned Numbers shall be used.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-16 10:25:31 +01:00
Krzysztof Chruscinski
fe423d52a7 testsuite: ztress: Delay start of the test
Delay start of threads and timer to ensure that setup
is completed. Especially, vital on multiple CPUs.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-15 13:19:28 -04:00
Krzysztof Chruscinski
1916a833f3 testsuite: ztress: Make cpu load calculation multi-cpu ready
Use idle threads on all cores for cpu load calculation.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-15 13:19:28 -04:00
Robert Lubos
6a0df63ea0 net: sockets: Retry net_context_sendmsg if EAGAIN is reported
TCP module can report EAGAIN in case TX window is full. This should not
be forwarded to the application, as blocking socket is not supposed to
return EAGAIN.

Fix this for sendmsg by implementing the same mechanism for handling TX
errors as for regular send/sendto operations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-15 09:50:21 -07:00
Andrzej Głąbek
222d42c22a modules: hal_nordic: Improve reservation of resources for BT_CTLR
Instead of including from nrfx_glue.h a specific Zephyr Bluetooth
controller header file that defines PPI and GPIOTE resources to be
reserved for exclusive use by the controller, include a file with
only a fixed name and expect the chosen Bluetooth controller to
provide the location of this file in include paths. This way, when
a different Bluetooth controller implementation is used downstream,
a different file can be easily pointed to.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-15 14:59:35 +01:00
Martin Jäger
b6a907dd89 lorawan: make unconfirmed message type explicit
The enum did not contain an entry for unconfirmed messages. Instead, it
was only mentioned in the comment that 0 is the default for
unconfirmed messages.

This commit adds LORAWAN_MSG_UNCONFIRMED to the enum and changes the
parameter in the lorawan_send function to enum lorawan_message_type.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-03-15 10:37:36 +01:00
Marin Jurjević
2a4e47a912 net: lwm2m: fix registration update event in queue mode
When queue mode is enabled, state machine will enter state
ENGINE_REGISTRATION_DONE_RX_OFF. This state needs to be
taken into account during registration update to send
correct event.

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-03-15 10:06:22 +01:00
Yong Cong Sin
ce3e1e7e29 net: http: Calculate body_frag_len
Calculate the body_frag_length if any part of the body is found
in the http response.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-15 10:05:21 +01:00
Yong Cong Sin
49c2d8a635 net: http: Rename body_start to body_frag_start
Following #42026, the body_start pointer now points to the
start of the body fragment in the recv_buffer as long as there
is body in it, either entirely or partially.

Rename the body_start to body_frag_start to better reflect
what it represents.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-15 10:05:21 +01:00
Yong Cong Sin
74a0ae01bc shell: Add MQTT backend
Add MQTT backed for shell module.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-15 10:01:12 +01:00
Juha Heiskanen
0b38be9d3a net: lwm2m: Inteagrate LwM2M new API's
Remove local path to string and string to path functionality
and use utility library API.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-14 22:04:32 -04:00
Juha Heiskanen
c95dd9a9c5 net: lwm2m: lwm2m utility API update
New API's
- lwm2m_string_to_path
- lwm2m_path_to_string
- lwm2m_atou16

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-14 22:04:32 -04:00
Mariusz Skamra
0481b697d8 Bluetooth: iso: Fix data path configuration
This fixes data path configuration that was done for both directions
even if CIS was unidirectional. To ensure the data path shall be
configured, the QoS SDU is checked.

Fixes: #43190
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-14 22:03:43 -04:00
Jordan Yates
e65e261621 logging: backend_uart: configurable buffer size
Update the UART RAM buffer size to be user configurable from Kconfig.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-14 16:44:17 -05:00
Krzysztof Chruscinski
f7b44a36f8 soc: xtensa: sample_controller: Cleanup backend config
Removing backend config from board Kconfig.defconfig and moving
it to xtensa_sim backend configuration in logging. Without this
change define persisted even when logging was not using backends
and that impacted what is compiled in.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-14 14:08:49 -04:00
Krzysztof Chruscinski
54ca1b36d7 boards: posix: Cleanup backend config for native_posix and nrf52_bsim
Removing backend config from board Kconfig.defconfig and moving
it to native_posix backend configuration in logging. Without this
change define persisted even when logging was not using backends
and that impacted what is compiled in.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-14 14:08:49 -04:00
Krzysztof Chruscinski
7c72b78660 logging: Add frontend support to v2
Extended logging v2 to support frontend api. Contrary to v1,
it is possible to have frontend and backends in the system.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-14 14:08:49 -04:00
Thomas Ebert Hansen
7f4471c84e Bluetooth: controller: Rename local proc ctx config
Rename
BT_CTLR_LLCP_PROC_CTX_BUF_NUM
to
BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM
to match naming scheme of
BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-03-14 11:38:09 +01:00
Thomas Ebert Hansen
33cb9e3433 Bluetooth: controller: Add remote proc ctx pool
Add a separate procedure context pool for remote initiated procedures.
Make it configurable in size by BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM.
Fix all unit tests referring to the amount of free context buffers.

Fixes #41823

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-03-14 11:38:09 +01:00
Thomas Ebert Hansen
cecb12e9d9 Bluetooth: controller: Improve mem mngt of proc ctx
Move the mem_pool structure to the internal header for wider access.
Introduce a mem_pool owner in the proc_ctx, sch that multiple mem_pool
could be used for memory management of proc_ctx, also static 'foreign'
allocated proc_ctx would be supported by this.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-03-14 11:38:09 +01:00
Nicolas Pitre
f7c4fe6778 shell: optimize history storage a bit
When padding is added to "fill" the gap in order to wrap to the
beginning of the ring buffer, such padding is attributed to the
current item being added. Let's attribute it to the previous entry
instead so it'll be freed along with that entry and make the space
available one entry sooner, increasing the chances for keeping the
current entry around longer.

If ring buffer is empty then always reset it up front to get best
alignment right away i.e. beginning of buffer.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-03-14 11:33:17 +01:00
Tristan Honscheid
082ca85b7c ztest: bug: Add friendly name helper function for all phases
The `handle_signal()` function in the new ztest API (`ztest_new.c`) uses
an array of strings to lookup a friendly name for each test phase, but
the array only has three elements despite there being six test phases.
This can lead to an out-of-bounds issue. Replace the array with a helper
function and switch statement.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-03-14 11:32:38 +01:00
Piotr Pryga
008fd88d6f Bluetooth: Controller: Add sampling and switching offset configuration
Start of the antenna switching and sampling CTE is configured by use
of DFECTRL2 register in Nodric Radio peripheral. As of now the
configuration was set to defaults, so antenna switching has started
immediately after CTE procedure was started (end of CRC).

Sampling was started at the very beginning of a sampling slot.
It should be delayed for at least 125 ns from beginning of sampling
slot and not more than 125 ns to the end of sampling slot. This is a
requirement from BT 5.3 Core specification Vol 6, Part B section 2.5.4
IQ sampling.

Although it seems to me that when samples are taken depends on
implementation and used hardware. Taking that into account
there is provided a set of KConfig options to configure samples
offset for PHY 1M, PHY 2M and sapling slots 1 us and 2us separetely.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-14 11:31:24 +01:00
Piotr Pryga
b7bbe4b702 Bluetooth: Controller: Fix per adv chain broken after per adv re-enable
If there is enabled support for ADI in periodic advertising and
periodic advertising uses chained PDUs there is an assert when
periodic advertising is re-enabled.

There is missing a code that will set a chain for PDU with
updated ADI field.

The commit fixes the issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-14 11:29:59 +01:00
Juha Heiskanen
6d624e5e18 net: lwm2m: Senml Json Base name dynamical update
SenML Json support dynamical basename for composite operation.
Changes simplify base name generation and compres message better.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-14 11:29:13 +01:00
Krzysztof Chruscinski
c917e6c2ce lib: os: cbprintf: Extend API to support new packaging modes
Added new flags to packaging API:
- CBPRINTF_PACKAGE_ADD_RO_STR_IDXS - when set, read-only string
  locations are appended to the package
- CBPRINTF_PACKAGE_ADD_RW_STR_IDXS - when set, read-write string
  locations are appended to the package (instead of appending actual
  strings)
- CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(n) - indicate that n first strings
  are known to be read only. Ignored in runtime packaging.

Add function for copying packages with optional appending strings.

Changed CBPRINTF_MUST_RUNTIME_PACKAGE to use same flags as packaging.

Aligned logging and test to those changes.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-14 11:16:14 +01:00
Gerard Marull-Paretas
8ae7694e93 random: rand32_xoshiro128: obtain entropy device using DEVICE_DT_GET
The entropy device reference can be obtained at compile time. Adjust
error code to -ENODEV.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-11 15:27:05 -08:00
Gerard Marull-Paretas
f5770991b6 random: rand32_entropy_device: get entropy device using DEVICE_DT_GET
THe entropy device can be ontained at compile time. Simplify some
logs/code as a result. Also adjusted "entropy_driver" name to
"entropy_dev", since it holds a "device", not a "driver".

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-11 15:27:05 -08:00
Gerard Marull-Paretas
f44b3dc4df random: rand32_ctr_drbg: obtain entropy device using DEVICE_DT_GET
The entropy device can be obtained at compile time. Adjusted the
assertion message slightly, as it no longer uses the entropy macro
label. Also adjusted the entropy_driver variable to entropy_dev, since
it does not hold a "driver" but a "device".

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-11 15:27:05 -08:00
Gerard Marull-Paretas
7a0026a5c1 net: lib: openthread: obtain entropy device using DEVICE_DT_GET
The device can be obtained at compile time. Note that now the readiness
is checked on every call, but it's a fast operation anyway.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-11 15:27:05 -08:00
Gerard Marull-Paretas
749afa38e1 bluetooth: controller: ll_sw: obtain entropy device using DEVICE_DT_GET
The entropy device can be obtained at compile time.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-11 15:27:05 -08:00
Emil Gydesen
18466530ab Bluetooth: PACS: Refactor PAC location read/write
Refactor the PAC location read and write. Instead
of storing the location in the service, the
location is now stored in the application, and
is retrieved by the service via callbacks.

Similarly, if a client writes the location, this
request is being sent to the application.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-11 11:36:19 -08:00
Emil Gydesen
4518c1935f Bluetooth: Audio: Add sent callback for audio streams
Add a sent callback that is used to notify applications
using the audio API when a SDU has been sent over HCI.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-11 11:28:53 -08:00
Lukasz Maciejonczyk
245457649b net: openthread: fix check for unsuccessful wipe
ot_setting_delete_subtree returns the information if the subtree
had been found in the persistent storage or not before removing.
This has matter for otPlatSettingsGet. In other uses cases
the return value shoud be ignored.
The right place for the check if deletion succeded is in
settings_load_subtree_direct and its callback.
Currently "ot factoryreset" causes an assert if there is no
OpenThread dataset stored in the persistent memory.
This PR fixes it.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2022-03-11 11:26:34 -08:00
Emil Gydesen
555f15deaa Shell: shell.c Use IN_RANGE macro from util.h
Change an occurence of `in_range` to use the IN_RANGE macro.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-11 07:20:16 -06:00
Emil Gydesen
9a3a2424e1 Bluetooth: Host: Use IN_RANGE macro from util.h
Use the IN_RANGE macro from util.h instead
of the two local implementations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-11 07:20:16 -06:00
Omkar Kulkarni
539c1c9c34 Bluetooth: Mesh: Change ERR to WARN
Changes ERR to WARN message when relay buffers
run out, as this is not really an error but a
consequence of high traffic.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2022-03-11 10:59:56 +01:00
Emil Gydesen
7e2c206274 Bluetooth: ASCS: Call stream callbacks on ASE state changes
Whenever a stream is attached to an endpoint, the
stream's operation callbacks will be called for the
unicast server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-11 10:59:28 +01:00
Dominik Ermel
412ff6edce mgmt/mcumgr/lib: Fix os_mgmt_echo returning Cbor error
The os_mgmt_echo is supposed to return MGMT type error not
Cbor; there was missing translation.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-11 10:58:55 +01:00
Dominik Ermel
f184f9d341 mgmt/mcumgr/lib: Fix cbor_internal_read_object error overwrite
The cbor_value_advance at the end of attribute parsing loop could
overwrite err with 0; this could cause loop to fail to break
on error and make cbor_internal_read_object return success, even
if parsing of input buffer failed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-11 10:58:55 +01:00
Dominik Ermel
7946713bcb mgmt/mcumgr/lib: Fix formatting in cborattr
Fixes tabs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-11 10:57:34 +01:00
Robert Lubos
3d4fe03a98 net: shell: Fix packet leak in TCP receive handler
TCP receive handler did not free the net_pkt provided, causing memory
leak.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-11 09:21:51 +01:00
Robert Lubos
bb5909f7d1 net: tcp: Update receive window in other direct net_context users
As the receive window is now decreased at the TCP module level, other
direct net_context users are also responsible for acknowledging the
received data with net_context_update_recv_wnd() - otherwise, the
communication will stall.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-11 09:21:51 +01:00
Mariusz Skamra
5e6fe46d08 Bluetooth: iso: Fix ISO data path setup
This patch fixes ISO data path setup that shall be done for enabled
directions only and removes usage of Path ID = 0xFF which is RFU value.

As per Core 5.3 Vol 4, Part E, 7.8.109
"If the Host attempts to set an output data path using a connection handle
that is for an Isochronous Broadcaster, for an input data path on a
Synchronized Receiver, or for a data path for the direction on a
unidirectional CIS where BN is set to 0, the Controller shall return the
error code Command Disallowed (0x0C)."

Fixes: #43190
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-10 14:33:20 -05:00
Pavel Vasilyev
d9de3dcc90 Bluetooth: Mesh: Send Friend Poll after every segments retransmission
Send Friend Poll every time when segments are retrasmitted.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-03-10 14:32:39 -05:00
Emil Gydesen
0d719ba893 Bluetooth: Audio: Add endpoint type to capabilities config cb
The capabilities callback did not provide information about
the type of the endpoint being configured, making it
impossible for the application to determine if it is a
sink or source endpoint.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:07:17 -05:00
Emil Gydesen
f41c1cd8a9 Bluetooth: Audio: Fix setting correct QoS based on direction
The unicast client would set the QoS reversed, as the
client should configure it TX parameters for SINK
and RX parameters for source, where it did it the other
way around.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:07:17 -05:00
Emil Gydesen
23c1d6c3da Bluetooth: Audio: Use endpoint dir value
Remove functions and and macro uses that otherwise
determined the direction of an audio stream, and instead
use the direction (dir) field of the endpoint instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:07:17 -05:00
Emil Gydesen
b880637231 Bluetooth: Audio: Remove bidirectional audio streams
Audio streams as defined by the BAP spec does not
support bidirectional audio streams. This commit
updates the API and implementation to match that.

The use a bidirectional CIS with 2 audio stream will
be added in a future commit.

This removes the _IN_ and _OUT_ and _INOUT_ QOS
values, as well as the direction of the codec QOS
struct.

To keep direction for internal use, the direction
has been added to the endpoint struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:07:17 -05:00
Emil Gydesen
956518a33b Bluetooth: Audio: Add BASS client shell
Add the BASS client shell module.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:06:44 -05:00
Emil Gydesen
dcbd1a555f Bluetooth: Audio: Add BASS shell
Add support for the BASS server shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:06:44 -05:00
Emil Gydesen
b1437e1f0c Bluetooth: Audio: Add BASS client
Add the BASS client implementation

This is a standalone implementation that
needs to be (heavily) modified for the
broadcast assistant role in the future.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:06:44 -05:00
Emil Gydesen
742eac6214 Bluetooth: Audio: Add broadcast audio scan service (BASS)
Add the BASS as a standalone service. The service is
used for the scan delegator role, which has not been
fully implemented yet.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 14:06:44 -05:00
Emil Gydesen
e485305b7c Bluetooth: Audio: Fix ordering of array size after array parameter
Make it consistent for audio.h and capabilities.h that the
array size parameter appear after the array parameter.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 13:50:20 -05:00
Emil Gydesen
a01cc054c9 Bluetooth: Audio: Use size_t for audio.h array len arguments
Use size_t instead of uint8_t to describe array lengths.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 13:50:20 -05:00
Emil Gydesen
7ce1022691 Bluetooth: Audio: Fix valid checks for bt_audio_unicast_group_delete
The checks for stream->group was useless, and the check for
an active CIG was missing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 13:50:20 -05:00
Emil Gydesen
d64328ebe5 Bluetooth: Audio: Add support for add/rem streams for unicast group
Add a function to add more and remove streams
to and from a unicast group.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-10 13:50:20 -05:00
Piotr Pryga
ce0ad0e30a Bluetooth: Controller: df: Do not send IQ rep for PDU without CTE
Check if the CTE was discovered by Radio peripheral should be
done with use of CTEPRESENT event. Samples count should not
be used for that purpose. If samples count is a value different
than zero for PDUs that don't have CTE, unwanted IQ samples
report will be generated. CTEPRESENT event is set only in case the
CTEInfo filed was correctly parsed by Radio peripheral during
PDU reception.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-10 13:45:41 -05:00
Pavel Vasilyev
f1d5066032 Bluetooth: Mesh: Don't replace destination of segmented message
Don't replace destination of segmented message when acknowledgement is
received from a friend node, otherwise, when segments are retransmitted,
the destination will be used and the friend node will treat it as a new
segmented message.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-03-10 13:44:05 -05:00
Erwan Gouriou
a099c79234 subsys/bluetooth/host: hci_core: Add a bt_disable command
Add a bt_disable function. This will abort existing threads and
close the HCI transport.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-03-10 13:28:41 -05:00
Benedikt Schmidt
ccd7ae2445 net: if: add default selection of first up interface
Add the default selection of the first interface which is up.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2022-03-10 13:24:03 -05:00
Herman Berget
3fb7f24f1d Bluetooth: Host: Add missing BT_ATT_OPs to att_op_get_type()
BT_ATT_OP_READ_MULT_VL_REQ, BT_ATT_OP_READ_MULT_VL_RSP, and
BT_ATT_OP_NOTIFY_MULT were missing.

Because of this, multiple variable length reads did not time out.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-03-10 13:16:56 -05:00
Aleksandr Khromykh
8c9e8da82f Bluetooth: Mesh: add heartbeat publication callback
Heartbeat publication sent callback can be used
as a watch mechanism to determine whether
the mesh stack is still capable of sending messages or not.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-03-10 13:16:40 -05:00
Herman Berget
6a23439b20 Bluetooth: Host: Fix check for number of ATT bearers
Fixes #42306

Attach bt_att_chan objects to bt_att when creating them so that the
check in att_chan_new() works. Use the flag ATT_CONNECTED to signal that
a channel is connected instead of attaching it.

The flag ATT_DISCONNECTED was not set anywhere and is replaced by
ATT_CONNECTED.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-03-10 13:26:46 +01:00
Herman Berget
5afa815e88 Bluetooth: Host: Remove unused function att_chan_is_connected()
gcc does not warn on unused static inline functions.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-03-10 13:26:46 +01:00
Enjia Mai
2b1bccde07 tests: testsuite: add emulating send IPI in X2APIC mode
We emulate the interrupt by sending the IPI to core itself by
the local APIC for x86 platfrom.

But in X2APIC mode, this no longer works. So we emulate the
interrupt the by writing the IA32_X2APIC_SELF_IPI MSR to send
IPI to the core itself via LOAPIC also. According to SDM vol.3
chapter 10.12.11.

Fixes #42108

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-03-09 14:55:26 -05:00
Lingao Meng
5b50133467 Bluetooth: Host: Reconstruct stream interface
Add `remaining_size` in struct ad_stream.

By calculating the actual space required instead of
using the maximum space.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-09 13:59:47 -05:00
Lingao Meng
5f2170f184 Bluetooth: Host: Optimize hci buf alloc by calc actually require size
By calculating the actual space required instead of using
the maximum space, for `hci_set_adv_ext_complete`.

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

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-09 13:59:47 -05:00
Henrik Brix Andersen
e9c9caa80d net: remove unmaintained 6LoCAN implementation
Remove the unmaintained, experimental 6LoCAN (IPv6 over CAN bus)
implementation.

Fixes: #42559

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-09 18:07:31 +01:00
Gerard Marull-Paretas
dffaf5375c kconfig: tweak Kconfig prompts
Tweak some Kconfig prompts after the removal of "Enable...".

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Gerard Marull-Paretas
95fb0ded6b kconfig: remove Enable from boolean prompts
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:

sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Vinayak Kariappa Chettimada
d510663c26 Bluetooth: Controller: Fix Extended Advertising Power Amp setup
Fix Extended Advertising implementation to setup Power
Amplifier (PA) GPIO toggle for transmission instead of
incorrect Low Noise Amplifier (LNA) setup which is for
reception.

Relates to commit 4e5290948e ("Bluetooth: Controller: Fix
Periodic Advertising to setup Power Amp").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 14:22:04 +01:00
Vinayak Kariappa Chettimada
681127f6ce Bluetooth: Controller: Fix allocations for chain reception
Do not implicitly allocate Rx buffers for maximum chain PDU
reception. Instead let applications increase as required the
Kconfig CONFIG_BT_CTLR_RX_BUFFERS.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 14:20:47 +01:00
Alperen Sener
0eee702bad Bluetooth: Mesh: Add back-off to secure beacons
adding back-off mechanism to mesh secure beacon behaviour

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2022-03-09 15:10:26 +02:00
Emil Gydesen
b2cf78af4c Bluetooth: Audio: Improved cleanup on disconnect
The LE Audio clients will now do more and proper cleanup
during disconnects. Furthermore, the will also
take a proper bt_conn_ref when the conn pointer
is assigned locally.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-09 15:04:57 +02:00
Vinayak Kariappa Chettimada
39570bd1d7 Bluetooth: Controller: Fix missing configure of Device Address Match
Fix missing configure of Device Address Matching when
receiving auxiliary PDUs.

This fixes some privacy related conformance test cases.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 13:59:23 +01:00
Vinayak Kariappa Chettimada
e60ac093b4 Bluetooth: Controller: Fix missing RPA timer start for Broadcaster
Fix missing RPA timer start in Broadcaster only controller
builds.

Without the fix private resolvable addresses where not
updated at RPA timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 13:58:41 +01:00
Vinayak Kariappa Chettimada
b36a0ee071 Bluetooth: Controller: Fix private address update in auxiliary PDUs
Fix missing implementation to update private resolvable
address in auxiliary PDUs on RPA timeout.

Without the implementation the controller asserted on RPA
timeout when AdvA is not present in the primary channel PDU
of Extended Advertising set.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 13:58:41 +01:00
Vinayak Kariappa Chettimada
d54f3bd5f7 Bluetooth: Controller: Fix missing reset of sync create association
Fix missing reset of sync create association with scan
context when associated with both 1M and Coded PHY contexts,
and sync create cancel is called.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 13:58:17 +01:00
Vinayak Kariappa Chettimada
5494f475b8 Bluetooth: Controller: Fix address resolution when max entries in list
Fix address resolution when trying to match the maximum
entries in the resolving list.

Wait for address resolution AAR peripheral to complete with
checking with all the entries in the IRK list.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 13:57:57 +01:00
Andy Ross
c5cf46a670 subsys/ztest: Revert "Make 1cpu tests run on CPU 0 specifically"
This change introduced some weird failures on x86 that will take some
time to untangle, and wasn't a particularly important feature to
merge.  Revert for now.

This reverts commit adc901aa6a.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-03-09 06:54:24 -05:00
Vinayak Kariappa Chettimada
a10cb58295 Bluetooth: Controller: Fix out-of-bound memory write
Fix out-of-bound memory write during mem_init due to
regression introduced in commit c6750de9c1 ("Bluetooth:
Controller: Fix missing ISOAL sink destroy").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-09 12:44:42 +01:00
Andy Ross
adc901aa6a subsys/ztest: Make 1cpu tests run on CPU 0 specifically
Some hardware has "interesting" configuration like asymmetric default
interrupt masking (the intel_adsp devices in particular, but x86's
IO-APIC driver has tripped over this in the past too) that needs
special treatment if you want to run something on "core 1"
specifically, and 1cpu test cases pretty much by definition are going
to have been written without SMP details in mind.  Switch the logic
around a tiny bit such that these test cases always run on CPU ID zero
explicitly.

Actually in practice this was ALMOST guaranteed to be true already,
because test setup and happens serially, having been started on the
main thread, which starts on CPU 0 by definition.  Then the test
teardown aborts all the spawned threads that might have been running
on CPUs 1+, so those reach idle, and the next test case starts
syncronously on the same thread (and thus CPU) where it started.  But
nonetheless that wasn't actually enforced, and we've found at least
one simulation environment where timing conspires to break things.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-03-08 16:26:26 -05:00
Przemyslaw Bida
c9645f4d36 openthread: net: implementing of otPlatRadioSetChannelMaxTransmitPower
This commit adds implementation of otPlatRadioSetChannelMaxTransmitPower
This function is responsible for setting maximum allowed power on
IEEE 802.15.4 channels.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2022-03-08 09:21:48 -06:00
Krzysztof Chruscinski
3cbfc505b3 logging: Add prompt to LOG2_ALWAYS_RUNTIME option
Prompt was removed by 154ca8526 to ensure that it is not
disable when it is required. That removed possibility of
manually enabling that option my the user. Bringing prompt
back and adding check to code to fail compilation if
LOG2_ALWAYS_RUNTIME is not set but is required.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-08 12:36:28 +01:00
Trond Einar Snekvik
b6993b0837 Bluetooth: Mesh: Extended advertiser should build without relay
The extended advertiser would fail to build due to a missing kconfig
option dependency when relay was disabled.

Fixes #43172.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2022-03-08 12:32:46 +02:00
Lingao Meng
05f75f9f33 Bluetooth: Mesh: Fix unable iv update due to cache
When local node poweroff and power on again, will
receive iv update but within 96hours.

When 96h after, due to cache, we can't process this
beacon any more.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-08 11:09:49 +01:00
Lingao Meng
78eddf6e37 Bluetooth: Mesh: Fix unable iv recovery when in iv update state
According Mesh Profile 3.10.6 IV Index Recovery procedure

Upon receiving and successfully authenticating a Secure Network
beacon for a primary subnet whose IV Index is 1 or more higher
than the current known IV Index, the node shall set its current
IV Index and its current IV Update procedure state from the
values in this Secure Network beacon.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-08 11:09:49 +01:00
Emil Gydesen
62704bd8a0 Bluetooth: PACS: Add PAC record data to pac_notify
When pac_notify is called it will notify the
actual PAC records for the specific type (sink/source).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-08 11:08:00 +01:00
Emil Gydesen
9477e61bf8 Bluetooth: PACS: Move read of PAC records into new function
Adds function get_pac_records that will retrieve the PAC
records from the application. The pac_read callback
will then call this to get the value, before returning
it to GATT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-08 11:08:00 +01:00
Emil Gydesen
4c2a09e8c5 Bluetooth: PACS: Change indicate to notify
The PAC service (PACS) should use notify instead
of indicate as per the specification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-08 11:08:00 +01:00
Krzysztof Chruscinski
47ae656cc1 all: Deprecate UTIL_LISTIFY and replace with LISTIFY
UTIL_LISTIFY is deprecated. Replacing it with LISTIFY.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-08 11:03:30 +01:00
Daniel DeGrasse
5ba1787163 tests: ztest: add CONFIG_ZTEST_NO_YIELD to keep SOC awake after test
Some SOCs cannot be flashed reliably in low power modes. If
CONFIG_ZTEST_NO_YIELD is selected, do not yield to the idle thread after
testsuite completes, so that the SOC will not enter low power mode.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-07 13:53:14 -06:00
Georges Oates_Larsen
303c42e70a net: http_client: Add official null response behavior
Adds an official behavior in response to null response from HTTP
endpoint.

Fixes #42988

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2022-03-07 09:18:50 -06:00
Thomas Ebert Hansen
0b0a90ae84 Bluetooth: controller: Unsupported proc handling
Add handling of unsupported procedures based on opcode and role.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-03-07 16:15:54 +01:00
Thomas Ebert Hansen
995ce7a226 ztest: Add skipping for non-kernel tests
Add ztest_test_skip() support to non-kernel tests by implementing
long jump buffer and TC_SKIP result collection.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-03-07 16:15:54 +01:00
Juha Heiskanen
3d44738b19 net: lwm2m: Fix SenML Json Name parser
Bug fix for case when base name is not included at message.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-03-07 10:54:57 +01:00
Lu Ding
818d90efda net: gptp: Fix sync_receipt_time calculation in gptp_mi
Fix #42800
Both pss->rate_ratio and port_ds->neighbor_rate_ratio are double type
but sync_receipt_time is uint64_t. If pss->rate_ratio is less than 1
or sync_receipt_time * port_ds->neighbor_rate_ratio is less than 1,
sync_receipt_time becomes 0 due to double to uint64_t cast.
Assign port_ds->neighbor_prop_delay to sync_receipt_time first to fix
this issue.

Signed-off-by: Lu Ding <lucasdinglu@gmail.com>
2022-03-07 10:54:49 +01:00
Eduardo Montoya
e05c966992 net: openthread: remove CONFIG_OPENTHREAD_CSL_SAMPLE_WINDOW
Remove obsolete configuration option.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-03-07 10:54:30 +01:00
Vinayak Kariappa Chettimada
fdda91d4b4 Bluetooth: Controller: Fix k_sem_give call from Zero Latency IRQs
Fix k_sem_give() from being called from Zero Latency IRQs
when the Controller is configured with BT_CTLR_ZLI=y.

Kernel features shall not be used from Zero Latency IRQs as
these IRQs cannot be locked by the kernel to maintain
context safety of the kernel objects.

Relates to commit 92e017fd70 ("Bluetooth: controller:
split: Support Zero Latency IRQs") and
commit c842eef3ae ("Bluetooth: controller: Add semaphore
to indicate free AD data buffers").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-07 10:53:50 +01:00
Piotr Pryga
89a6a3a7c2 Bluetooth: Controller: Fix per adv scheduling issue
sw_switch implementation uses two parallel groups of
PPIs connecting radio and timer tasks and events.
The groups are used interchaneably, one is set for
following radio TX/RX event while the other is in use
(enabled).

The group should be disabled by timer compare event that
starts Radio to TX/RX a PDU. The timer is responsible for
maintenance of TIFS/TMAFS. The disabled group collects
all PPIs required to maintain the TIFS/TMASF. After
the time is reached Radio is started and the group is
disabled. It will be enabled again by software radio
swich during next call.

If the group is not disabled then it will work in parallel
to other one. That causes issues in correct maintenance of
instant when radio shoudl be started for next TX/RX  event
e.g. radio may be enabled to early.

In case the PHY CODED was enabled and periodic advertising
included chained PDUs, that are transmitted back-to-back,
there was missing group delay disable. The missing case was
sw_switch function called with dir_curr and dir_next set
to SW_SWITCH_TX.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-03-07 10:53:30 +01:00
Dominik Ermel
264877cf50 mgmt/mcumgr/lib: Fix taskstat thread name processing
The commit:
 - removes usage of strnlen to make taskstat code C99 compliant;
 - corrects thread name len, following update description of
   CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN;
 - reduces duplicated code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-07 10:53:20 +01:00
Dominik Ermel
cd97b19749 mgmg/mcumgr/lib: Remove strnlen from OS echo command
The commit removes usage of strnlen from echo command to make
code C99 compliant, and allow it to compile with newlib.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-07 10:53:20 +01:00
Dominik Ermel
8284d486c4 mgmt/mcumgr: Kconfig: Correct OS_MGMT_TASKSTAT_THREAD_NAME_LEN info
The help for the OS_MGMT_TASKSTAT_THREAD_NAME_LEN stated that
the config includes terminating zero, but this is not true:
when thread name is encoded with CBOR it is encoded with actual
string length and is not zero terminated.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-07 10:53:20 +01:00
Veijo Pesonen
0032f0bcff net: lwm2m: obj inst processing per formatter
It depends from a content formatter is there need to put constructs
with a path level deeper than object instance. In other words with
resource- or resource-instance-level.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-03-07 10:52:58 +01:00
Carlo Caione
4ea6fd4f20 ipc_service: Start the wq only once
No need to start the wq every time the mbox is initialized, it must be
done once for all the instances (it is shared by all the instances).

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-07 10:52:51 +01:00
Lingao Meng
e6212c203a Bluetooth: Mesh: Fix missing add suffix _COMMON
Since `CONFIG_BT_MESH_PB_GATT` represent to pb-gatt-srv.

We use `CONFIG_BT_MESH_PB_GATT_COMMON` to represent common.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-07 10:52:14 +01:00
Asbjørn Sæbø
68144f58e9 Bluetooth: OTS - rename client data receive callbacks
Rename the data and metadata callbacks to _read(), for consistency
with the corresponding function calls.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
13b4506bf8 Bluetooth: OTS: Use out-of-range value for unknown object ID
Use a value for "Unknown object ID" that is outside of the range of
valid object IDs.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
eecd94409c Bluetooth: OTS - Client APIs to have instance as first parameter
Move the instance as the first parameter of the client function calls
and callbacks, for consistency with the server implementation.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
4e1ca8f9d4 Bluetooth: OTS - do not include internal connection header
Remove #include of conn_internal.h - cast conn pointers to void for
logging instead.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
1f8e4c906f Bluetooth: OTS - rename two defines
Rename two defines for internal consistency in file.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
c894b63e9e Bluetooth: OTS - Rename client callbacks
Rename client callbacks to be more consistent with common code style.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
70eefae1d2 Bluetooth: OTS - Merge server and client header files
- Move content of client header file to common header file.
- Rename content from "otc" to "ots_client".
- Remove empty client header file.
- Update users.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
adfd1d16e0 Bluetooth: OTS: Merge client and server metadata types
Merge the metadata types for client and server.
This is part of merging the ots_client and ots header files.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
da89dcfbcd Bluetooth: OTC - Move metadata bitfields to common files
Move the metadata request bitfields to the common header files.
This is part of merging the ots_client and ots header files.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
68745d87d5 Bluetooth: OTS: Unify object name size for client and server
Use Kconfig value for object name size also for client.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
7fabcb3124 Bluetooth: OTS - minor client cleanups
Small clean-ups to client code: Making variables const, adding a value
to a debug print.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
b16c760c6c Bluetooth: OTS: Move defines to internal file
Move defines from public API to implementation (only used there).

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
76cf124060 Bluetooth: OTS - rename client files
Rename OTS client files from "otc" to "ots_client".

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
352dd3763e Bluetooth: OTS - join Kconfig for OTS server and client
Merge Kconfig file for OTS server and client.
Rename the client config from _OTC to _OTS_CLIENT

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
b33625fcd2 Bluetooth: OTC - mark as Experimental
Mark the OTC implementation as experimental

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
69b731d824 Bluetooth: OTC: Rename two functions
Rename functions to follow common pattern (module, action, noun).

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
1a81bceea2 Bluetooth: OTC: Use OTS defines and types instead of separate ones
Update the Object Transfer Client to use OTS defines and types instead
of the ones left over from the previous "le-audio local" object
transfer service:
DIR_LIST, object ID size, OACP and OLCP

Remove the no longer used defines and types from the OTC header file.
Exception: The OLCP sort order defines have not been removed, but
moved to the olcp internal header file, for expected later use.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
1be80a4d84 Bluetooth: OTS: Move directory listing defines to other header
Move the directory listing size defines to the OTS directory listing
internal header file.

This removes an implicit dependency upon users of
ots_dir_list_internal.h to also include ots_internal.h.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
aa80b87d4a Bluetooth: OTC: Clean up internal header file
Remove various unused defines, update comments, update inclusion guard

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
a821dacf90 Bluetooth: Audio: Media control - add missing include
The media control client shell must include the OTC header file.
(It is currently indirectly included via otc_internal.h.)

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
00b14b36aa Bluetooth: OTC: Use ots_l2cap for l2cap transfer
Update the OTC to use the existing ots_l2cap code rather than its own
implementation.
- Add an ots_l2cap struct and register it
- Add ots_l2cap callbacks, reuse most of old l2cap_recv callback in
  the ots_l2cap rx_done callback
- Remove old l2cap code

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
806aeb73cb Bluetooth: OTS/OTC: Config changes for using l2cap for OTC
Update configuration so that the OTS l2cap file can also be used for
the OTC.
(The plan is to merge the OTS and OTC config files later.)

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
3e80d4b04f Bluetooth: OTS: add connect() function to ots_l2cap
Add an l2cap connect() function to OTS.  This is a function for
clients, added to prepare for the upcoming OTC client (re)using the
ots_l2cap module.

As part of this, factor out an internal function to find a free l2cap
context.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
9e4443a8b3 Bluetooth: OTC: Remove unused macros and net_buf
Remove some unused code from the OTC.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
25540ef746 Bluetooth: OTC - do not register L2CAP server
Remove L2CAP server registration.  The object transfer client does not
need to register an L2CAP server.

OTS spec: "It is always the responsibility of the Client to open the
Object Transfer Channel, regardless of the direction of transfer, and
is never the responsibility of the Server."

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
0d6e18a052 Bluetooth: OTC: Move OTC files to OTS folder
Move the OTC files to the OTS folders for further refactoring.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
725d9b9b7e Bluetooth: OTC - remove old ots header file
Preparations for making OTC "official"

Move remaining content of old ots header fil into the otc header file,
and remove the old ots header file.

(Another ots header file already exists in the ots folder.)

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
343586dd05 Bluetooth: OTC: Remove old ots internal header file
This commit is the first in a series of commits to make the OTC
(Object Transfer Client) implementation that exists in the audio
folder "official". That is, the client implementation will be updated
and refactored to be aligned with the OTS (Object Transfer Service)
implementation that exists in subsys/bluetooth/services/ots, and moved
to that folder.

Preparations for making OTC "official":
Move remaining content of old ots_internal header fil into the
otc_internal header file, and remove the ots_internal header file.
(Another ots_internal header file already exists in the ots folder.)

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Asbjørn Sæbø
88a40e4e1b Bluetooth: OTC: Add TODO to fix macro
Object Transfer Client: Add TODO to fix the OLCP result conversion
macro

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-07 10:47:43 +01:00
Aleksander Wasaznik
5c37441256 Bluetooth: Host: Implement GAP writable appearance
This change adds the kconfig option
BT_DEVICE_APPEARANCE_GATT_WRITABLE_AUTHENTICATED. When enabled, GAP
apperance is writable by authenticated peers.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-03-07 10:45:55 +01:00
Aleksander Wasaznik
3bdf582172 Bluetooth: Shell: Add command "bt appearance [new appearance]"
Extend the command "bt appearance" to take an optional argument, which
is used to set the appearance.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-03-07 10:45:55 +01:00
Aleksander Wasaznik
a713f21f14 Bluetooth: Host: Implement dynamic apperance
Introduces new kconfig option CONFIG_BT_DEVICE_APPEARANCE_DYNAMIC.

New API `bt_set_apperance` allows dynamic setting of apperance. The
dynamic setting is saved in the settings subsys. `bt_set_apperance` is
analogous to `bt_set_name`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-03-07 10:45:55 +01:00
Aleksander Wasaznik
8ad5119f46 Bluetooth: Shell: Add command "bt appearance"
The new command "bt appearance" prints out the current Bluetooth
Appearance Value.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-03-07 10:45:55 +01:00
Aleksander Wasaznik
8c76677bfd Bluetooth: Host: New API: bt_get_appearance()
The this change is a step towards make the GAP appearance runtime
settable and ATT writable.

The new function bt_get_appearance() wraps CONFIG_BT_DEVICE_APPEARANCE
and should replace all its uses in code.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-03-07 10:45:55 +01:00
Krzysztof Chruscinski
923e491db5 logging: Fix Kconfig dependency
Fix dependencies when enabling of legacy kconfig option

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-03 12:06:10 -05:00
Przemyslaw Bida
47557d7d9d manifest: openthread: Simplification of openthread integration.
This commit moves openthread CMakeLists.txt from openthread submodule
to zephyr/modules/openthread.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2022-03-02 10:06:03 -08:00
Marcin Niestroj
ab2f616641 net: http: use shutdown(..., SHUT_RD) in receive timeout handler
So far close() was called on underlying socket when timeout has expired.
This is wrong in several ways. First of all POSIX specification of
close() does not specify what should happen on blocking recv() call and
different systems have different behaviors (e.g. Linux does not wake up
recv() caller if there was no new incoming data, while other systems
might wakeup recv() caller immediately). Another (and much more severe)
problem is that HTTP client user does not know whether underlying socket
was already closed or not after HTTP request has finished. As a result
it was not clear whether close() should be called by HTTP client user.

Use shutdown(..., SHUT_RD) in internal HTTP client implementation, so
that recv() is woken up immediately with 0 as result (which means EOF).
This will allow to gracefully handle timeouts and make it clear that it
is application responsibility to always call close() after HTTP
request (successful or not).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2022-03-02 10:05:09 -08:00
Marcin Niestroj
084ca91a73 net: sockets: tls: implement shutdown() method for TLS sockets
Add basic shutdown() implementation of TLS sockets, which basically
calls shutdown() on underlying wrapped sockets.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2022-03-02 10:05:09 -08:00
Marcin Niestroj
f54dee6531 net: sockets: implement shutdown() method for net_context sockets
Add basic shutdown() implementation for net_context sockets, which
handles only SHUT_RD as 'how' parameter and returns -ENOTSUP for SHUT_WR
and SHUT_RDWR. The main use case to cover is to allow race-free wakeup
of threads calling recv() on the same socket.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2022-03-02 10:05:09 -08:00
Marcin Niestroj
8eb2565dbf net: sockets: add shutdown() support in vtable
So far shutdown() implementation was a noop and just resulted in warning
logs. Add shutdown() method into socket vtable. Call it if provided and
fallback into returning -ENOTSUP if not.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2022-03-02 10:05:09 -08:00
Lingao Meng
8c3b244fe3 Bluetooth: Mesh: Fix unable send mesh message when proxy adv pending
When Proxy advertising or PB-GATT Advertising Enabled and use a same
advertising sets.

As `adv_start` will call multi HCI Command will cause syswork_q yield.
At same time, if another thread(BT RX) all `schedule_send` will cause
unable send mesh message, because `ADV_FLAG_ACTIVE` was be set, but
`ADV_FLAG_PROXY` not set currentlly.

Add `ADV_FLAG_SCHEDULE_PENDING` indicate mesh buf has been pendings
but not scheduled, so when proxy advertising enable, let's take again,
as we can't break or terminated `adv_start`, so we must waiting proxy
advertising enabled.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-03-02 10:02:25 -08:00
Lu Ding
24ab659cd1 net: gptp: fix endianness of correction field in sync follow up message
correction field in sync follow up message must be converted from host
endianness to network endianness.

Signed-off-by: Lu Ding <lucasdinglu@gmail.com>
2022-03-02 09:43:35 -06:00
Torsten Rasmussen
aff31cf62b modules: littlefs: move CMake glue code from littlefs repo into Zephyr
Fixes: #40559

Moving CMakeLists.txt gluecode into Zephyr repo minimizes the patching
needed in LittleFS repo.

It provides a dedicate Zephyr LFS config header which will define the
equivalent LittleFS settings based upon Kconfig settings.
This further reduces the patching needed in LittleFS.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-03-02 15:34:11 +01:00
Vinayak Kariappa Chettimada
c6750de9c1 Bluetooth: Controller: Fix missing ISOAL sink destroy
Fix missing call to ISOAL sink instance destroy interface,
without this there is leak in ISOAL sink instances when
removing ISO data path.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-02 14:52:41 +01:00
Nirosharn Amarasinghe
8b09d524a5 bluetooth: controller: fixed problems in ISO-AL RX
[*] Fixed setting of SDU production status when exiting the
    ISOAL_ERR_SPOOL state for framed PDU consumption when receiving the
    start of the next SDU
[*] Changed condition identifying a padding PDU to include padding PDUs
    with errors received after the end fragment is seen and expanded
    unit tests to cover new condition
[*] Changed definition of ISOAL_PDU_STATUS_xxx errors to match value of
    similar errors defined for the SDU status

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-03-02 11:22:33 +01:00
Gerard Marull-Paretas
260deccb6e doc: use :kconfig:option: domain role
Kconfig options now belong to the Kconfig domain, therefore, the
:kconfig:option: role needs to be used.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-02 09:28:37 +01:00
Flavio Ceolin
df3d1f83f7 drivers: crypto: Rename cipher file
This file defines the crypto driver API, cipher is supposed to be just
one type of capability (other can be hash) of these drivers, just
change the file name to be consistent with it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-03-01 16:32:43 -05:00
Flavio Ceolin
637fd58efb drivers: crypto: Change HW capabilities query namespace
This is not cipher specific, just replace it crypto to make it clear.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-03-01 16:32:43 -05:00
Vinayak Kariappa Chettimada
25169d92d8 Bluetooth: Controller: Broadcast ISO Tx ack on event close
Improvement to generate Tx ack early when the event close
compared to being done at the start of the next event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 14:54:35 +01:00
Vinayak Kariappa Chettimada
6c983adedb Bluetooth: Controller: Initial broadcast ISO Tx data path
Initial work on adding ISO Tx data path for ISO Broadcast.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 14:54:35 +01:00
Vinayak Kariappa Chettimada
ccf1ecbdee Bluetooth: Controller: Add define for Connected ISO Stream handle base
Add define for Connected ISO Stream handle base.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 14:54:35 +01:00
Vinayak Kariappa Chettimada
73d8fff54e Bluetooth: Controller: Fix Extended Advertising conditional compiles
Fix Extended Advertising conditional compiles in header files.
Do not conditional compile declarations, definitions of
functions in source files only be compiled out.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 14:54:35 +01:00
Vinayak Kariappa Chettimada
0ab8f1b102 Bluetooth: Controller: Pass link_type to data_buffer_overflow
Refactored implementation to pass link type to data buffer
overflow function.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 14:54:35 +01:00
Vinayak Kariappa Chettimada
213a14594e Bluetooth: Controller: Fix ISO Broadcast and Sync related cond. compile
Fix ISO Broadcast and ISO Synchronized Receiver related
conditional compilation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 14:54:35 +01:00
Vinayak Kariappa Chettimada
e0cd316049 Bluetooth: Controller: Fix missing ll_adv_cmds_set
Fix to include ll_adv_cmds_set when broadcast role is not
enabled in the Controller but advertising extensions is
enabled (Extended Scanning is used).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 14:54:35 +01:00
Dominik Ermel
b30fda2639 mgmt/mcumgr/lib: Allow echo buffer size configuration
Commit adds CONFIG_OS_MGMT_ECHO_LENGTH Kconfig option that allows
to configure size of echo buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-01 13:21:57 +01:00
Eduardo Montoya
166fd0dc9e net: openthread: bring back LOG_MODE_MINIMAL support
A previous commit fixed OpenThread logging when `LOG=n`, but
introduced regression when `LOG_MODE_MINIMAL=y`. This commit
fixes the latest.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-03-01 12:49:36 +01:00
Lukasz Duda
0c94817b55 openthread: platform: implement otPlatCryptoRand API
This commit utilizes psa_crypto_get function to fetch cryptographically
secure pseudorandom numbers.

Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
2022-03-01 12:49:36 +01:00
Eduardo Montoya
b588444a53 net: openthread: Align Kconfig with cmake symbols
OPENTHREAD_BORDER_ROUTING_NAT64
OPENTHREAD_DNS_DSO
OPENTHREAD_EXCLUDE_TCPLP_LIB

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-03-01 12:49:36 +01:00
Gerard Marull-Paretas
f07430349b settings: use nvs_mount
Replace deprecated nvs_init() with nvs_mount().

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-01 12:46:34 +01:00
Gerard Marull-Paretas
252053f4fe mgmt: hawkbit: nvs: use nvs_mount
Replace deprecated nvs_init() with nvs_mount().

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-01 12:46:34 +01:00
Gerard Marull-Paretas
56d5486fbf fs: nvs: introduce nvs_mount and deprecate nvs_init
Add a new API call to replace nvs_init: nvs_mount. The new API does the
same as nvs_init except that it assumes to be provided with a valid
flash device via `struct nvs_fs` `flash_device` field. Previously, it
was not possible to avoid the runtime overhead of device_get_binding()
even if the flash device was known at compile time.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-01 12:46:34 +01:00
Emil Gydesen
0e8f556b17 Bluetooth: ISO: Fix issue with ++ in calls to sys_le16_to_cpu
sys_le16_to_cpu is a macro, and not big endian the value
is referenced twice, which would incorrectly increment the
value.

Modifed to extract the value to a variable before calling
sys_le16_to_cpu.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-01 11:55:17 +01:00
Emil Gydesen
ed4551d579 Bluetooth: ISO: Add packet_sequence_number for each ISO channel
Instead of relying on a single globally increasing (but never
resetting) packet_sequence_number, it is now correctly
reset and incremented for each ISO channel.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-01 11:55:17 +01:00
Peter Johanson
8744837fa6 Bluetooth: GATT: Fix conn cb registration
Adding the same BT callback struct twice can cause
an infinite loop when iterating the callback_list,
so register the gatt callback just once early.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2022-03-01 11:53:22 +01:00
Vinayak Kariappa Chettimada
adca553f04 Bluetooth: Controller: Rename use of mstr word to cen for Central
Rename the use of mstr word in advanced scheduling
implementation to cen as a representation for Central
role.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00
Vinayak Kariappa Chettimada
4e787d0a2a Bluetooth: Controller: Use conn interval unit for Auxiliary event
Use connection interval units of 1250 us for periodic
scheduling of Extended Advertising auxiliary PDU events so
that auxiliary events can be periodically grouped alongwith
the Periodic Advertising Events. This will permit
mitigating overlaps amongst them.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00
Vinayak Kariappa Chettimada
0f407597bd Bluetooth: Controller: Use define TICKER_NULL instead of 0xFF
Use the define TICKER_NULL to represent invalid ticker id.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00
Vinayak Kariappa Chettimada
3a6b8e1bc0 Bluetooth: Controller: Schedule BIG event after Periodic Adv event
Add implementation to find free slot after Periodic
Advertising event, to place the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00
Vinayak Kariappa Chettimada
62144e4326 Bluetooth: Controller: Expose the Periodic Adv time reservation func
Make the Periodic Advertising time reservation calculation
function internal public so that advanced scheduling can
use it to scheduling the BIG event after the Periodic
Advertising radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00
Vinayak Kariappa Chettimada
74c13daa23 Bluetooth: Controller: Refactor free slot after role implementation
Refactor the implementation to get free slot after a
state/role so that it is easy for reused for scheduling
Broadcast ISO events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00