Commit graph

12302 commits

Author SHA1 Message Date
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