Commit graph

11768 commits

Author SHA1 Message Date
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
Vinayak Kariappa Chettimada c169347ea8 Bluetooth: Controller: Fix scheduling of Periodic Advertising events
Fix scheduling of Periodic Advertising events to be after
the group of Auxiliary set events. Do not reduce the slot
offsets as time reservations in ticker for non low latency
variant of controller does not include the slot offsets in
the reservation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00
Vinayak Kariappa Chettimada ac5d5c1100 Bluetooth: Controller: Refactor scheduling function depth
Refactor the implementation to get free slot after a
state/role so that the code depth is reduced.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-01 11:51:46 +01:00
Kamil Piszczek 8e327161bb mcumgr: bluetooth: use dedicated config of connection params during dfu
Extended the connection parameters negotiation procedure used in the
SMP BT module. From now on, it is possible to configure a preferable
set of all connection parameters to be used during the image transfer.
The default values are optimized for transfer throughput.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-02-28 11:10:03 +01:00
Emil Gydesen 9f1e46e17b Bluetooth: Audio: Guard chan recv for just unicast and broadcast sink
Guards the `recv` callback for just unicast and broadcast sink
builds, and removes the usage of it in broadcast_source.c

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-02-28 11:04:37 +01:00
Emil Gydesen 628b54a959 Bluetooth: Audio: Remove ISO disconnected and connected cbs
The callbacks were implemented to notify the application
about the state of the ISO. However, since then, callbacks
such as `started` and `stopped` have been implemented,
and as such the `connected` and `disconnected` callbacks
no longer server any purpose.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-02-28 11:04:37 +01:00
Emil Gydesen 555c6ecc6c Bluetooth: L2CAP: Add ing to the bt_l2cap (dis)connect-ing state
Add `ing` to the `BT_L2CAP_CONNECT` and `BT_L2CAP_DISCONNECT`
states, so that the name better matches the actual state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-02-28 10:53:08 +01:00
Daniel Leung dc22617478 linker: add a utility func to check if an addr is in RO section
This adds a utility function to check if an address is within
read only section. This is extracted from logging subsys so
use the new func in logging. The one is cbprintf_packaged is
also replaced.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-28 10:53:02 +01:00
Daniel Leung e54b4faabc logging: v2: force LOG2_ALWAYS_RUNTIME if XCC
XCC is based on GCC 4.2.0 which doesn't support auto type.
So force CONFIG_LOG2_ALWAYS_RUNTIME to be enabled if XCC is
being used.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-28 10:52:51 +01:00
Nicolas Pitre eee5b8e563 ring_buffer: make finish methods final
Make it possible to "finish" with fewer bytes than what was "claimed".

This was possible before on the get side, but the put side was
cummulative wrt finish. The revamp made it cummulative on both sides.
Turns out that existing users rely on the opposite behavior which is
more logical and useful. So make both sides that way.

Adjust documentation, test case and users accordingly.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-28 10:52:41 +01:00
Gerard Marull-Paretas 2903680822 pm: constraint: drop __weak
No SoCs are re-implementing the constraints API. This _feature_ was
mostly put in place to cover TI platform needs, but it is no longer
needed. Refer to previous commit for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-28 10:18:38 +01:00
Rubin Gerritsen 52a240c583 Bluetooth: Host: Remove experimental tag from periodic adv and sync
We have done sufficient testing to claim that the host is no longer
experimental.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-02-25 21:59:49 +02:00
Veijo Pesonen 2231287e27 net: lwm2m: Resource Instance level read access.
Makes possible to read a single resource instance at a time with
plaint text, JSON and TLV content formats.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-02-25 10:12:23 -08:00
YanBiao Hao 57f5125a8a Bluetooth: mesh: load iv && neykey from app
User can load iv && netkey from app for
the first time to create network.

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2022-02-25 10:06:32 -08:00
Herman Berget 5b63ead63c BLuetooth: Host: Fix ecred connection retry on encryption change
The L2CAP channels were removed from the bt_conn channels list. They
were thus not found in the ecred connection response handler.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-02-25 10:04:10 -08:00
Rubin Gerritsen 9a088f9778 Bluetooth: Host: Error if setting unsupported adv data for ext adv
We keep the behavior for legacy advertising data as the controller will
ignore such scenarios when using legacy advertising commands.

Extended non-scannable advertising sets don't support scan response
data. Extended scannable advertising sets don't support advertising
data.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-02-25 09:56:04 -08:00
Nicolas Pitre 24f5c65b5a shell: fix history memory reclaim
No ring_buf_get_finish() should be performed on ring_buf memory that
wasn't claimed beforehand. Using ring_buf_get() with a NULL destination
does both the claim and the finish part without retrieving anything.

This is especially important with the ring_buffer revanp where the above
is enforced for proper operation.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Emil Gydesen dc812539b8 Bluetooth: MPL: Fix use of uninitialized command.param value
The command.param may not always be set in send_command
depending on whether command.use_param is set.

If command.use_param is not set, the command.param is
not logged, and is set to 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-02-24 13:56:04 -08:00
Lingao Meng 7f928a8916 Bluetooth: Mesh: Add mesh shell command
Add mesh shell command for pb_gatt_client.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Lingao Meng 3e4cf9b693 Bluetooth: Mesh: Add _srv suffix for pb_gatt_srv
Add `_srv` suffix for pb_gatt_srv.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Lingao Meng 2ead5725b1 Bluetooth: Mesh: Add Provisioner Over PB-GATT Support
Add support provisioner over pb-gatt.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Lingao Meng 3f3ef659da Bluetooth: Mesh: Add Proxy Client Feature
Add Proxy client feature support.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Lingao Meng ad1e8d89ec Bluetooth: Mesh: Move relative function to pb_gatt.h
Move relative function to pb_gatt.h

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Lingao Meng 341e67ad83 Bluetooth: Move proxy_relay to proxy_msg.c
Move proxy_relay to proxy_msg.c

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Lingao Meng e96e312aa7 Bluetooth: Mesh: Move conn_count to proxy_msg.c
Move conn_count to proxy_msg.c

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Lingao Meng a01a3f8511 Bluetooth: Mesh: Refactoring proxy msg API
Refactoring proxy msg send & recv API.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-24 13:51:09 -08:00
Krzysztof Chruscinski b74397db13 logging: Making format_table static const
Add static const to format_table.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-24 08:51:26 -08:00
Lukasz Maciejonczyk c5afc2e1f2 net: openthread: add assert which checks settings wipe failure
If settings wipe fails we are not informed about this what can lead to
bugs which are hard to investigate.
This commit adds log and/or assert which is triggered by this failure.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2022-02-24 08:33:30 -06:00
Michał Barnaś 08c41e7e4f shell: don't print colon if there's no item help
If the item has name but no help, there's no need to fill
shell with tabulators and colon at the end of the line.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-02-24 08:29:52 -06:00
Aastha Grover c0d7e10beb logging: Add support to backends to switch log format at runtime.
Adding mechanism to all the backends to switch the logging formats
at runtime while leveraging the function pointer table based upon
the Kconfigs which also cleans up the logging backend design.
Also demonstrate the working API with the changes
to syst sample. Clean up Kconfig for backends and add a standard
template to generate the Kconfigs for logging formats to be used
by all backends.

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2022-02-23 14:12:22 -06:00
Aastha Grover 9fcbace639 logging: Add API's to switch logging formats at runtime.
Add support for new API's log_backend_format_set and
log_format_set_all_active_backends to switch the logging format
for one backend and for all the active backends respectively.
Using format_set function pointer in log_backend_api struct as a hook
to set the log format at runtime in the backends. Add function pointer
table with helper functions to be used as a way to select log format.
Add supported log format types as macros to use with the API.

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2022-02-23 14:12:22 -06:00
Aastha Grover e4e675dc37 logging: Add API to get log_backend instance by name.
Added helper API to the logging backend interface to get the
log backend instance by name.

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2022-02-23 14:12:22 -06:00
Juha Heiskanen 6904915a35 net: lwm2m: LwM2M engine default content format select
LwM2M version 1.1 will select SenML Json for default content format.
Version 1.0 will use TLV format.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-23 17:25:36 +01:00
Juha Heiskanen 312dd7f887 net: lwm2m: Composite Observe operation placeholder
Added detetction for Composite Observervation request and cancel.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-23 17:25:36 +01:00
Juha Heiskanen 98cd71eef2 net: lwm2m2: LwM2M Composite-Write operation
CoAP method iPATCH enable LwM2M Composite-Write operation.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-23 17:25:36 +01:00
Juha Heiskanen 3bec5de0fb net: lwm2m: LwM2M Composite read support
Adeed enabler for composite read to LwM2M engine.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-23 17:25:36 +01:00
Juha Heiskanen 906feebb33 net: lwm2m: Added LwM2M Send operation support
LwM2M engine Send operation support /dp.
Send operation based on Composite Read functionality
which is not enabled at engine side like composite write.
Added Kconfig configurable for composite read path list size.
Created generic Read object instance which is shared between
general read and Composite Read operation.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-23 17:25:36 +01:00
Juha Heiskanen a9c1b8d0f2 net: lwm2m: Added SenML JSON support for Read & Write
LwM2M SenML JSON contain format support for Read / Write operation.
Added Kconfig configurable for enable SenML JSON format.
LwM2m read validate read operation and report out of memory.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-23 17:25:36 +01:00
Bradley Bolen c0dd594d4d arch: arm: aarch32: Change CPU_CORTEX_R kconfig option
Change the CPU_CORTEX_R kconfig option to CPU_AARCH32_CORTEX_R to
distinguish the armv7 version from the armv8 version of Cortex-R.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-02-23 08:14:15 -06:00
Gerard Marull-Paretas 3b51f9b9e8 pm: device: remove deprecated functions
Remove deprecated functions in the previous release. Note that PM API is
not marked as stable.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-23 07:34:26 -05:00
Flavio Ceolin 78454e5e93 pm: Rename pm_power_state_exit_post_ops
Aligning with the rest of PM API, replace pm_power_state_exit_post_ops
with pm_state_exit_post_ops.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-23 07:33:46 -05:00
Flavio Ceolin f74c38e061 pm: Rename pm_power_state_next_get
Aligning with the rest of PM API, replace pm_power_state_next_get with
pm_state_next_get.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-23 07:33:46 -05:00
Flavio Ceolin 6142fcb8ba pm: Rename pm_power_state_force
Aligning with the rest of PM API, replace pm_power_state_force with
pm_state_force.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-23 07:33:46 -05:00
Flavio Ceolin 89fee61b43 pm: Rename pm_power_state_set
Aligning with the rest of PM API, replace pm_power_state_set with
pm_state_set.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-23 07:33:46 -05:00
Vinayak Kariappa Chettimada bd3ee8608c Bluetooth: Controller: Refactor rx link and node rx release
Refactor implemenation of rx link and node rx release, and
replenish of their quota.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-23 13:16:07 +01:00
Vinayak Kariappa Chettimada b29aaff415 Bluetooth: Controller: ISO Synchronized Receiver Channel Map Update
Initial implementation support for ISO Synchronized Receiver
Channel Map Update Procedure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-23 13:16:07 +01:00
Vinayak Kariappa Chettimada 28489fc900 Bluetooth: Controller: ISO Broadcast Channel Map Update
Initial implementation of ISO Broadcast Channel Map Update
Procedure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-23 13:16:07 +01:00
Vinayak Kariappa Chettimada 7437743982 Bluetooth: Controller: Fix Periodic Advertising PDU ACAD set and clear
Fix Periodic Advertising PDU ACAD set and clear interface to
support updating ACAD when previous and new PDU buffer are
same (i.e. when previous new PDU not consumed yet by LLL).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-23 13:16:07 +01:00
Vinayak Kariappa Chettimada d607d1cc6a Bluetooth: Controller: Update assertion check when traversing ACAD
Update implementation to have assertion when not finding the
Channel Map Update Indication field in ACAD.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-23 13:16:07 +01:00
Robert Lubos 9ac83be650 net: lwm2m: Add proper resource-level discovery attribute handling
In case an individual resource is being discovered, the LwM2M client
should not only fill the attributes assinged at the resource level, but
also the ones inherited from the object and object instance levels.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-22 10:12:27 -08:00
Robert Lubos ac8881f170 net: lwm2m: Allow to write attributes for resource instances
LwM2M 1.1 allows to write attributes for resource instances as well.

Resource instance level attributes need also to be taken into
consideration when adding/updating observers.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-22 10:12:27 -08:00
Robert Lubos 3e861c04e9 net: lwm2m: Add LwM2M 1.1 discovery support
LwM2M adds Resource Instance reporting in Discovery response, along with
attributes assinged at the Resource Instance level.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-22 10:12:27 -08:00
Robert Lubos 4f5a19482b net: tcp: Make receive window size configurable
Add Kconfig option to set the receive window size.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-22 10:09:45 -08:00
Robert Lubos c25cd5a894 net: tcp: Allow to acknowledge zero-length packets
Peer may send a zero-length keepalive message, probing the recv window
size - TCP stack should still reply for such packets, otherwise
connection will stall.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-22 10:09:45 -08:00
Robert Lubos 74bc876bf5 net: tcp: Implement receive window handling
Add implementation of net_tcp_update_recv_wnd() function.

Move the window deacreasing code to the tcp module - receive window
has to be decreased before sending ACK, which was not possible when
window was decreased in the receive callback function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-22 10:09:45 -08:00
Torsten Rasmussen e4ccde3774 cmake: moved unittest.cmake to Zephyr CMake modules dir
Move the unittest.cmake to the new Zephyr CMake modules dir.

This allows us to have a single Zephyr CMake package and load unittest
module as: 'find_package(Zephyr COMPONENTS unittest)'

This unifies the way Zephyr package is sourced and removes the need for
a dedicated ZephyrUnittest package.

Deprecate the use of: 'find_package(ZephyrUnittest)'

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Lukasz Maciejonczyk c9effd0ff9 net: openthread: filter ipv6 fragments
If OPENTHREAD_IP6_FRAGM is enabled the IPv6 fragments are handled in
OpenThread stack but also forwarder unconditionally to the Zephyr
uplayers. It causes additional packets processing and leads to errors
like unrecognized next header type or duplicate ping reply. What more
these errors generate additional traffic which jam channel and decrease
latency for packets required fragmentation.
This commit add filtering IPv6 fragments when data fragmentation and
reassembling is enabled in OpenThread.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2022-02-22 10:33:47 -05:00
Eduardo Montoya be742f925e net: openthread: fix received frame flags
Uninitialized memory would report wrong value for
`mAckedWithSecEnhAck` flag in the received frame, making the
OpenThread stack to update the frame counter for the neighbor
wrongly.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-02-22 10:33:23 -05:00
Krzysztof Chruscinski c5a065e3b8 debug: thread_analyzer: Use bigger stack in certain configurations
When immediate logging is used and optimization is off then bigger
stack is needed for thread analyzer. Adjusting the value.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-22 14:44:11 +01:00
Krzysztof Chruscinski a662e69cad logging: Prevent multiple arguments evaluation
Logging v2 is utilizing complex preprocessing operations to
prepare message at compile time. Multiple operations are peformed
on log message arguments. However, it is expected that argument
will be evaluated only once (e.g. it can be a call to a function
with side effects). Adding additional layer which creates copies
of user arguments on stack and passes them to further processing.

Updated test for log_msg2 which is using internal macro which
got renamed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-22 14:44:11 +01:00
Krzysztof Chruscinski 154ca8526c logging: Use runtime packaging in immediate mode
Always use runtime packaging in immediate mode. Removing attempt to
package on stack if possible. It would be done only to speed up
logging but that is not a requirement in immediate mode where
packaging time is fractional compared to backend processing. Using
runtime packaging also reduces stack usage in the context which calls
log message.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-22 14:44:11 +01:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Carles Cufi 4b8f1c04ab kconfig: Rename the ZTEST stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Dominik Ermel d7db973b04 fs/fat_fs: Allow configuration of number of root entries
The commit adds FS_FATFS_MAX_ROOT_ENTRIES Kconfig option that allows
to select number of root node entries that will be allocated while
creating FAT file system on a device.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-22 08:14:20 -05:00
Dominik Ermel a30698a148 mgmt/mcumgr: Remove redundant memcpy from buf processing
The commit removes redundant memcpy operations and switches from
using TinyCBOR provided byte order converters to sys_be, native
to Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-22 10:24:44 +01:00
Anas Nashif 49d08c25fe Revert "logging: Use spin lock"
This reverts commit dfe9561d9b.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-22 00:29:17 -05:00
Anas Nashif 421dcc8dcd Revert "testsuite: ztress: Add test skipping if system clock is too high"
This reverts commit 913868b6c4.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-22 00:29:17 -05:00
Krzysztof Chruscinski 913868b6c4 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-02-21 22:19:00 -05:00
Krzysztof Chruscinski dfe9561d9b logging: Use spin lock
Updated log_core to use spin lock instead of irq_lock.
Refactored z_log_msg_post_finalize function.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-21 22:19:00 -05:00
Seppo Takalo f1e0b5413c net: lwm2m: Allow changing the protocol version to 1.1
This is a bare minimal changes to tell the server that we are using
LwM2M 1.1 version. Queue-mode parameter has changed between 1.0 and
1.1 so it must be changed in the same time.

Other 1.1 features may follow on separate commits. This is still
an experimental feature that allows developing and testing of
1.1 features.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-02-21 22:18:34 -05:00
Emil Gydesen 06e07b4a54 Bluetooth: Kconfig: Increase default RX stack size for LE Audio
LE Audio builds on top of the BT Host stack, and will
thus require a higher amount of stack size. Even simple
applications using BAP will likely reach the 1024 default
size with the default BAP configurations, and when
we start adding CAP and even TMAP/HAP on top of it, it
will likely increase even further.

The default value of 2048 is unlikely to be reached,
and applications that want to optimize can likely
reduce it, depending on the configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-02-21 22:08:51 -05:00
Veijo Pesonen 37b9bb87f0 net: lwm2m: Adds semantics for handling time
This far time values have been synonymous to integer values. Content
formats like CBOR do use different representation.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-02-21 22:07:01 -05:00
Lingao Meng 2cf069df6b Bluetooth: Mesh: Opt ram of transport segment message
As use for simple message with no-segment send or receive.

This will be useful for ram-resource-constrained device.
such as bbc-microbit-v1.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-21 22:06:38 -05:00
Asbjørn Sæbø 34de2af394 Bluetooth: audio - remove BT_AUDIO_DEBUG
Remove the BT_AUDIO_DEBUG Kconfig option.

Given that all the audio modules are guarded by the BT_AUDIO config,
it seems excessive to also have a separate guard for audio module
debug. It is sufficient that this is turned on/off module by module.

Note that the BT_AUDIO_DEBUG was also located in the wrong file - the
babs Kconfig file, not the main Kconfig file.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-02-21 22:03:04 -05:00
Asbjørn Sæbø 21fc1cc670 Bluetooth: Audio - remove superfluous check for BT_AUDIO from Kconfig
Remove the check for BT_AUDIO from the Kconfig files that had it, for
consistency (some files did not have it).

This check is not required - all Kconfig.* files are sourced from the
main Kconfig file _only_ if BT_AUDIO has been configured.  As long as
this is the case, it is not required to check in the files themselves.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-02-21 22:03:04 -05:00
Juha Heiskanen 3e04783bbb net: lwm2m: LwM2M Portfolio object id support
Added support for Portfolio object support because LwM2M v1.1 conformance
test requirement that. This object is only for conformance test purposing.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-21 22:02:44 -05:00
Aleksander Wasaznik 299fac833b Bluetooth: Host: Settings: Handle extra settings_load before bt_enable
Before this change, enabling CONFIG_BT_SETTINGS and calling
settings_load(), but delaying / not calling bt_enable would trigger an
assertion error due to a timeout. The fault is that the settings load
handler for the Bluetooth host assumes bt_enable has already been called
and sends HCI commands to the controller. This times out if HCI is not
running.

The fix is to skip loading Bluetooth settings before bt_enable. The doc
is updated to guide the user on how to enable Bluetooth after settings
have been loaded before.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-02-21 22:02:34 -05:00
Aleksander Wasaznik eeb1f92a2d Bluetooth: Host: Remove no-op settings handler
STATIC_HANDLER_DEFINE accepts NULL in place of unneeded handlers.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-02-21 22:02:34 -05:00
Morten Priess 1417e8f8c7 rf: JIT scheduler fixes and improvements
- Prevent double callback with ADV re-scheduling
  For configurations using CONFIG_BT_CTLR_JIT_SCHEDULING, when last
  ADV before initiating connection is re-scheduled with a small delay,
  the disabled_cb would be called a second time. This would unexpectedly
  invoke a second conn setup with illegal parameters.
  To avoid this JIT scheduler phenomenon, clear the ADV disabled_cb
  when invoked.
- Add priority to LLL header. This allows the conn priority to be
  associated with the object. Used in vendor LLL implementation.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-02-21 22:00:57 -05:00
Morten Priess 9f7ea41780 Bluetooth: controller: Minor scoping fixes for vendor implementations
Make sure declarations are in scope for certain vendor specific
configurations.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-02-21 22:00:39 -05:00
Andreas Chmielewski b52f1cdb59 net: lwm2m: fixed "LwM2M message is invalid"
Do not retransmit a message that just has been send successfully.

This case can in particular happen quite frequently if the modem
connection/throughput is quite bad and so there is a high latency.

A message that has to be acknowledged is scheduled for retransmission.
Before retransmission a ack for this message is received that will
cause a reset of the original message. In this case you see a
"LwM2M message is invalid" error message.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-02-21 21:59:59 -05:00
Lingao Meng 0c78a2aaca Bluetooth: Mesh: Fixes Unable recovery twice even after 192h
After PR: https://github.com/zephyrproject-rtos/zephyr/pull/38296

If we receive the second recovery after 192 hours after the first
recovery, we may still not be able to perform any recovery, even
if the IV Index differs by 42, because the `ivi_was_recovered` flag
will only be cleared during the iv update.

But still May lose iv update, as we did the first iv recovery.

This patch by checking the iv duration, if 192h later, auto clear
`ivi_was_recovered` flag.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-02-21 21:57:32 -05:00
Björn Stenberg b4b87ad8a4 CMake: net: pkt_filter: Only construct the library if enabled
This fixes "No SOURCES given to Zephyr library: subsys__net__pkt_filter"

Signed-off-by: Björn Stenberg <bjorn@haxx.se>
2022-02-21 21:57:19 -05:00
Juha Heiskanen dde5c16709 net: lwm2m: JSON dynamic Resource instance allocation
Integrated dynamic resouce instance allocation to JSON.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-21 21:53:48 -05:00
Juha Heiskanen 7b3a1f31fe net: lwm2m: Plain Text dynamic Resource instance allocation
Integrated dynamic resouce instance allocation to Plain text.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-21 21:53:48 -05:00
Juha Heiskanen fcbf84b5d7 net: lwm2m: OMA TLV dynamic Resource instance allocation
Integrated dynamic resouce instance allocation to OMA TLV.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-21 21:53:48 -05:00
Juha Heiskanen 1d2f5b471e net: lwm2m: Resource instance dynamic allocation
Added support for allocate dynamically resource instance.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-21 21:53:48 -05:00
Juha Heiskanen 60088b18d4 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-02-21 21:01:23 -05:00
Juha Heiskanen 392088ea13 net: lwm2m: OMA TLV Multi Resource TLV update
Added support for handle Multi Resource TLV for Write and Create operation.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-21 21:00:36 -05:00
Carlo Caione c5894df5ec pm: Change parameters of pm_power_state_{set,exit_post_ops}
Just pass state and substate_id instead of the whole info structure
pointer.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 20:58:01 -05:00
Carlo Caione 8143f206dd pm: Rename exit_pos_ops to pm_exit_pos_ops
Because exit_pos_ops is the only function without the prefix.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 20:58:01 -05:00
Carlo Caione 11f1dd2370 pm: Reference pm_state_info only by pointer
It's unnecessary to move the pm_state_info around by value, just use a
pointer.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 20:58:01 -05:00
Krzysztof Chruscinski caa3ee686a shell: kernel_service: Use z_stack_space_get for isr stack stats
Use dedicated function for calculating stack usage of the
interrupt stack(s).

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-21 20:57:17 -05:00
Krzysztof Chruscinski 1eb5183bee debug: thread_analyzer: Add option to print ISR stack usage
Add option to include analysis of interrupt stack(s) when
threads are analyzed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-21 20:57:17 -05:00
Robert Lubos 3ebd581467 net: sockets: Allow to build CAN sockets with offloading enabled
There is no releavnce between CAN sockets and offloading that would
prevent one from working with another, therefore it's not right to
allow CAN sockets to be build only if offloading is disabled. Fix the
wrong dependency in socket CMakeLists.txt file.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-21 20:52:38 -05:00
Kamil Piszczek c7e12c9384 bluetooth: gatt: add validation for supervision timeout
Added a missing assert statement for validation of the preferred
supervision timeout parameter which can be configured by the user
via Kconfig.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-02-21 20:51:58 -05:00
Asbjørn Sæbø 8461e0b303 Bluetooth: OTS: Use existing variable instead of finding value again
Minor improvement: Use already existing variable, rather than finding
the same value again.  It is clearer, and simpler, to use the variable
everywhere this value is needed.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-02-21 20:51:14 -05:00
Henning Fleddermann 7eb25df526 net: lib: lwm2m: add lwm2m_engine_is_observed function
add helper function to check wether a specific lwm2m
path is observed

Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
2022-02-21 20:50:52 -05:00
Emil Gydesen 24bca9b27b Bluetooth: Host: Avoid address copy for PA list
Avoids copying the address and assigning the SID if the
PA list is used, as the values are ignored by the
controller, and thus there is no reason to copy
or assign the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-02-21 20:50:22 -05:00
Dominik Ermel dc8308506e mgmt/mcumgr/lib: Remove unneeded return code check
The smp_process_request_packet has been checking return code from
mgmt_streamer_init_writer where Zephyr implementation of the
callback always returns 0.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-21 20:50:06 -05:00
Eduardo Montoya a0093eeda0 net: openthread: fix handling tx done to report all kind of errors
Fix bug in radio implementation that reported any transmit error
as `OT_ERROR_NO_ACK` to OpenThread.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-02-21 20:49:20 -05:00
Boon Khai Ng e46d8a1d51 fat_fs: Add support for the "win" variable alignment in FATFS struct
This is to support Sypnosys Designware SDMMC controller read and write
operation where the buffer address is needed to be 16bytes and 512bytes
aligned. Adding macro FS_FATFS_WINDOW_ALIGNMENT to align the "win"
variable address in FATFS struct.

Signed-off-by: Boon Khai Ng <boon.khai.ng@intel.com>
2022-02-21 20:48:54 -05:00
Rubin Gerritsen 5b16dd4326 Bluetooth: Host: Issue all auto-initiated commands synchronously
This solves the following issues:
- Auto-initiation of commands is aborted if one of the issued commands
  fails
- The controller return value for a PHY update or DL update is not
  made available to the application.

As a result, the host no longer prevents the application from calling
bt_conn_le_data_len_update() and bt_conn_le_phy_update() before the
auto-initiated procedure completes. Now the controller may or may not
accept the additional command issued by the application.

It also simplifies the code:
- We no longer need to keep track of if the auto-phy update
  or auto-dl update has completed. If the controller receives
  another LE Set PHY while the procedure is pending in the LL, it can
  decide if wants to accept another procedure initiation or not.
- We no longer need to auto-initiate auto-initiation of commands in
  multiple places

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-02-21 20:41:57 -05:00
Krzysztof Chruscinski 81ce6db313 logging: Add common api for getting memory usage
Logging v2 did not support getting memory usage data. Adding this
support by creating common api for getting current and maximum
usage. Tracking of maximum usage is optional and can be enabled
using CONFIG_LOG_MEM_UTILIZATION.

Updated shell command to use common API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-21 20:41:17 -05:00
Andries Kruithof 2f98f8f7cf Bluetooth: controller: llcp: inclusive naming in unittests
There were some references to slave and master left in the unittests
for the refactored LLCP.
These are changed in respectively peripheral and central

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2022-02-21 19:43:10 -05:00
Herman Berget 4c980233af Bluetooth: Host: Add L2CAP collision mitigation test
Tests that when a collision happens, the connection attempt is retried
and that it succeeds.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-02-21 19:40:42 -05:00
Herman Berget acaa7b850c Bluetooth: Host: Implement L2CAP collision mitigation
This is required by Core Spec Version 5.3 Vol. 3, Part G, Section 5.4.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-02-21 19:40:42 -05:00
Herman Berget 8b46aaaf69 Bluetooth: Add common BT_CONN_INTERVAL_TO_MS macro
The same macro was defined in multiple places.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-02-21 19:40:42 -05:00
Emil Gydesen 1d8645d2b6 Bluetooth: ISO: Add missing BT_ISO_SDU_BUF_SIZE for RX pool
The iso_rx_pool did not use the correct buffer size due to
a missing BT_ISO_SDU_BUF_SIZE, causing it to be too small.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-02-21 19:40:02 -05:00
Henrik Brix Andersen 1f57e73730 canbus: isotp: ensure consecutive frames are sent in FIFO order
Ensure that ISO-TP Consecutive Frames (CF) are sent in
FIFO/chronological order.

In order to ensure this, we can only have one CF queued in the CAN
controller TX mailboxes at a time, since transmit order for mailboxes
with the same CAN-ID (priority) is hardware specific.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-02-21 19:37:35 -05:00
Johann Fischer 3b7807cc9b usb: dfu: disable USB DFU uploading by default
Firmware uploading to the host may not always be desired,
disable it by default.

Enable it for existing USB DFU sample to keep
the usual behavior, add note about new option to README.rst.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-02-18 09:32:22 -08:00
Johann Fischer 09f48c9a4f usb: dfu: rename FLASH_AREA_ID macro
Rename confusing UPLOAD_FLASH_AREA_ID to DOWNLOAD_FLASH_AREA_ID
as it is area where firmware image is downloaded.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-02-18 09:32:22 -08:00
Johann Fischer c51cfee4bf usb: do not add ZLP if lenght to be transmitted is just zero
It is possible that the actual data stage length of
the control transfer is zero, in that case we do not
need an additional ZLP packet.

This fixes a problem with USB DFU, where after an upload
the device is no longer responsive if upload size is
multiple of control endpoint MPS.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-02-18 09:32:22 -08:00
Yuval Peress 35ec3c9579 ztest: Update verification to account for missing suite
Fix an issue where a test's suite name was misspelled and thus the
test never ran because it wasn't associated with a suite. Example:

ZTEST_SUITE(my_suite, NULL, NULL, NULL, NULL, NULL);
ZTEST(myy_suite, test)
{
}

The above will no longer pass since `myy_suite` with a double `y` will
fail the verification.

Signed-off-by: Yuval Peress <peress@google.com>
2022-02-17 09:08:21 -05:00
Szymon Janc 4fce6fb937 Bluetooth: L2CAP: Fix checking if LTK is present
This fix a typo where incorrect member of bt_keys was used for
checking if LTK is present. This was resulting in bogus results
depending on connection role and current identity used.

This was affecting L2CAP/LE/CFC/BV-25-C qualification test case.

Fixes: #42862

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-02-17 13:11:43 +01:00
Piotr Pryga 777ddc053d Bluetooth: Controller: df: Fix missing node_rx release if wrong CTE type
Periodic advertising sync may be created with CTE type filtering
enabled. When received AUX_SYNC_IND, there are HCI_LE_Periodic_-
Advertising_Sync_Established and HCI_LE_Periodic_Advertising_Report
events generated. In case received AUX_SYNC_IND has wrong CTE type,
HCI_LE_Periodic_Advertising_Sync_Established event is generated.
There may not be HCI_LE_Periodic_Advertising_Report event generated.
In this case node_rx, prepared by LLL, was not released in ULL.
It was lost in ull_sync_established_report.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-17 13:08:45 +01:00
Piotr Pryga 523f0f9bc6 Bluetooth: Controller: df: Fix build err if scan cte rx disabled
CONFIG_BT_CTLR_DF_CTE_RX is enabled by default if CONFIG_BT_CLTR_DF
is enabled and there is support for DF in given SOC.
If CONFIG_BT_CTLR_DF_SCAN_CTE_RX is disabled then the CONFIG_BT_CTLR-
_PER_SCAN_CTE_NUM_MAX is not available.
It causes build errors if that particular configuration is used by
an application. It was a case for example in split builds of direction
finding connectionless TX sample application were periodic advertising
was enabled but perddioc advertising sync was disabled.

The commit fixes the problem.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-17 13:07:12 +01:00
Rubin Gerritsen e30e2e1240 Bluetooth: Host: Fix setting long advertising data
Previously the data was set incorrectly when the data was set in
multiple operations. It did not take the previous state into account.

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

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-02-15 09:51:14 -08:00
Yuval Peress 47113211c7 ztest: document test rules
Add documentation to test rules.

Signed-off-by: Yuval Peress <peress@google.com>
2022-02-14 09:31:28 -05:00
Xabier Marquiegui e238dce6cc net: gptp: gptp port role disabled on link down
Set GPTP port role to disabled if port link is down.

Signed-off-by: Xabier Marquiegui <xmarquiegui@ainguraiiot.com>
2022-02-11 10:03:05 -06:00
Piotr Pryga a17eeb2835 Bluetooth: Host: Fix wrong length of antenna identifiers for CTE RX
There were used an uninitialized variable to set antenna identifiers
length. The value should be set with use of params argument, not
by cp pointer that is not yet initialized.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-11 13:55:32 +01:00
Marek Pieta cd89f9a75d Revert "Bluetooth: host: Remove CCC update from GATT connected callback"
This reverts commit 0a1f553dc2.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2022-02-11 13:52:29 +01:00
Vinayak Kariappa Chettimada 230f4f1c1b Bluetooth: Controller: Fix to use non-discardable buffer
Fix to use non-discardable Rx buffer for handling Extended
and Periodic Advertising Report.

Regression introduced in
commit 18171bc774 ("Bluetooth: Host: Non-discardable event
buffer size is 255 for ext adv"). The default discardable Rx
buffer size was reduced causing increased fragmentation and
deadlock trying to get more free discardable Rx buffers to
generate HCI Extended and Periodic Advertising reports.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-10 20:05:11 +01:00
Daniel Nejezchleb 1f22a2bc3c net: tcp: Fix possible deadlock in tcp_conn_unref()
This reverts commit e7489d8de7.

And fixes the deadlock by allowing only 1 thread to actualy clean up
the connection when the ref_count is 0.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2022-02-10 10:59:03 +01:00
Jim Benjamin Luther bf450552b8 Bluetooth: host: Save CCC data on pairing complete
Fixes issue #39989.

Save CCC data on pairing complete by replacing private addresses
for the just bonded device with its public address in CCC attributes'
CFG arrays. This is then followed by calls to bt_gatt_store_ccc
and bt_gatt_store_cf for the just bonded device.

Signed-off-by: Jim Benjamin Luther <jilu@oticon.com>
2022-02-10 10:20:20 +01:00
Johann Fischer da47f41e42 modbus: do not loop in UART IRQ handler
On some platforms, if there are multiple MODBUS interfaces,
receiving of RTU frames may fail. Replacing while loop with
just "if" fixes this problem.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-02-09 22:11:16 -05:00
Vinayak Kariappa Chettimada d367447d64 Bluetooth: Controller: Fix scanner window close by using lll_disable
Fix race condition in setting up ISR callback and parameter
caused between ULL_HIGH and LLL context. As LLL IRQ is not
disabled the parameter and ISR callback would get out of
sync causing incorrect parameter supplied to callback and
hence leading to development assert in ull_scan_done().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada 7f24d3bc6b Bluetooth: Controller: Fix missing aux release on abort of LLL sched
Fix missing auxiliary context release message on abort of
LLL scheduling scheduling used by scan context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada c2dda0950d Bluetooth: Controller: Fix missing auxiliary context done event
Fix missing use of auxiliary context to generate done event
which caused leak in release of auxiliary context being not
release when reference count that should decrease to zero.

Regression in 'commit 665a8d2c6e ("Bluetooth: Controller:
Fix repeated per sync drift compensations").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada 4591c0173f Bluetooth: Controller: Fix auxiliary context release on scan done
Fix auxiliary context release on scan done, do not wait for
reference count to reduce when Periodic Sync events overlap.

Regression introduced in commit 624e003064 ("Bluetooth:
controller: Fix auxiliary scan context release").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada 0748474831 Bluetooth: Controller: Fix reset of is_aux_sched flag
Fix reset of is_aux_sched flag when closing the primary and
auxiliary PDU reception. Without this fix when scan window
is closed there would be duplicate auxiliary release message
generated causing memory corruption.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada 4d87a7ff15 Bluetooth: Controller: Auxiliary PDU reception continuation
Implementation to continue Auxiliary PDU reception when
overlapping with scan events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada bd4086b847 Bluetooth: Controller: Periodic Sync Chain reception continuation
Implementation to continue Periodic Sync Chain reception
when overlapping with scan events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada 481a334d2b Bluetooth: Controller: Remove minor redundant assignment
Minor change to remove redundant assignment statement.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada 0a290bd51d Bluetooth: Controller: Add assert check to detect sync aux context leak
Add assertion check to detect sync aux context leak.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada e5e0470ed3 Bluetooth: Controller: Add development assert to check aux context
Add development assert to check the validity of auxiliary
context allocation. This is to ensure that primary PDU
reception does not have an auxiliary context allocated until
ULL has processed the node rx.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada 18ca682357 Bluetooth: Controller: Add development assert to check auxiliary parent
Add development assert to check the validity of auxiliary
context's parent. This is to ensure a released auxiliary
context is not reused without allocation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Vinayak Kariappa Chettimada ebe64beb2a Bluetooth: Controller: Add assert to check IQ sample allocation
Add assert to check IQ sample allocation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 19:49:27 +01:00
Marius Scholtz 3ea5343f0d modbus: serial: Fix incomplete transmission issue
This patch is to fix an issue where the transceiver chip is
disabled before it has transmitted all data. This causes the
message to be corrupted because the last few bytes are missing.

The fix adds a check to make sure the transmission is completed
before disabling the transceiver.

Signed-off-by: Marius Scholtz <mariuss@ricelectronics.com>
2022-02-09 15:47:07 +01:00
Sjors Hettinga 4855e8ded1 net: ppp: Properly terminate LCP state at modem side when closing down
Takes the modem state machine by calling lcp_close instead of lcp_down
Using this method the LCP layer sends a TERMINATE_REQ to the modem and the
network interface is only taken down when the LCP layer has properly
finished.
Moved the ppp_mgmt_raise_carrier_off_event and net_if_carrier_down
to lcp.c to avoid breaking the interface.
Tested on a real modem.

Fixes: zephyrproject-rtos#41627

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-02-09 13:56:54 +01:00
Aleksander Wasaznik ae9380d996 Bluetooth: Host: L2CAP: Don't send credits if chan is disconnected
Fixes bug where Host sends L2CAP Flow Control Credit after receiving a
L2CAP Disconnect Response.

The when the callback in l2cap_chan_le_recv_sdu is handed a Disconnect
Reponse, the connnection becomes disconnected, as illustrated by the
asserts. The function should now trigger sending credits if the
connection is disconnected after the callback returns.

Fixes #42112

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-02-09 13:22:47 +01:00
Vinayak Kariappa Chettimada 31c6a9cf18 Bluetooth: Controller: Fix Periodic Sync lost implementation
Fix Periodic Advertising Synchronization lost implementation
to avoid processing done event twice in cases of overlapping
events or race between sync terminate being requested.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 11:02:37 +01:00
Vinayak Kariappa Chettimada fc9f976485 Bluetooth: Controller: Add sync established code comment
Add code comment related to sync context field used to
indicate the sync established event being generated towards
HCI Layer.

Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 14:50:17 +01:00
Vinayak Kariappa Chettimada bebc7a0df8 Bluetooth: Controller: Fix Sync Failed to be Established on no memory
Update implementation to generate Periodic Sync Failed to be
Established when Sync Established message could not be
generate due to lack of free node rx buffers and when there
is sync lost before sync established message could be
generated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 14:50:17 +01:00
Piotr Pryga 66312b0e34 Bluetooth: Host: df: Fix uninit per adv sync and IQ report passed to app
In case of error in hci_df_prepare_connectionless_iq_report function
e.g. due to wrong periodic advertising sync handle, uninitilized
per_adv_sync and IQ report object were passed by cte_report_cb callback
to an application.

Correct behavior in such situation is to not to cal cte_report_cb callback.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-08 14:49:43 +01:00
Vinayak Kariappa Chettimada a5fb434705 Bluetooth: Controller: Fix to stop Extended Auxiliary Scan context
Fix any stray Extended Auxiliary PDU from being scanned
when disabling Extended Scanning.

Updated Extended Scan disable implementation to find any
active auxiliary scan context and stop them.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 13:53:07 +01:00
Vinayak Kariappa Chettimada ffeee6ce1f Bluetooth: Controller: Update ull_disable with -EALREADY return
Update ull_disable implementation to return -EALREADY if
LLL event is already disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 13:53:07 +01:00
Vinayak Kariappa Chettimada 179fe06a80 Bluetooth: Controller: Fix advertising pdu latest get
Fix advertising pdu latest get to defer release of stale
PDU chain buffers. Returning NULL after some buffers where
released causes LLL to assert when chained PDUs are
switched.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 13:51:56 +01:00
Henning Fleddermann 3018279c30 net: lib: lwm2m: make pathstr parameter const correct
many functions in the lwm2m librarys api take a pathstr argument
that is never written to, so make it const

Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
2022-02-08 07:27:30 -05:00
Piotr Pryga d04456f4d9 Bluetooth: Controller: df: Fix IQ sample data saturation info drop
Nordic Semiconductor Radio peripheral provides IQ samples as
12 bits signed integer with sign extended to 16 bits.
Where out of range IQ samples (saturated) have value -32768.

Due to conversion of IQ samples to 8 bit signed integer, required by
BT 5.3 Core Vol 4, Part E sections 7.7.65.21 and 7.7.65.22 the
saturation information was lost.

The PR fixes that issue by use of value -128 to mark saturated
IQ samples. Note that BT 5.3 Core does not give any particular
value of IQ sample a special meaning.

This is a vendor specific solution and does not affect other
implementations of lower link layer.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-07 17:22:49 +01:00
Jarno Lamsa 98f99a37a2 net: lib: lwm2m: Use snprintk instead of snprintf
Use kernel print function to reduce the memory impact.

Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
2022-02-07 17:22:38 +01:00
Jarno Lamsa c2550d56c8 net: lib: lwm2m: Correct path for update result
The path was erroneously pointing to update state
resource instead of update result causing a wrong
resource value to be updated.

Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
2022-02-07 17:22:38 +01:00
Rubin Gerritsen 18171bc774 Bluetooth: Host: Non-discardable event buffer size is 255 for ext adv
After https://github.com/zephyrproject-rtos/zephyr/pull/41337, extended
advertising reports are no longer discardable. Ensure the
non-discardable events are large enough.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-02-07 17:22:13 +01:00
Aleksander Wasaznik d54ae955a2 Bluetooth: ATT: Fix conn parameter to req cb in att_reset
The conn pointer is still valid / not reused at this time and can be
used further up the stack as an identifer. This simplifies the API of
ATT, and fixes callbacks in GATT that pass on this value directly since
their API does not allow conn to be NULL.

Fixes #41794

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-02-07 17:00:51 +01:00
Daniel Nejezchleb e7489d8de7 net: tcp: Fix possible deadlock in tcp_conn_unref()
Unlock tcp_lock when calling the recv_cb. In case when
a connection is being closed from both the tcp stack
and the application, a race condition can happen resulting
in locking each other out on tcp_lock and socket lock.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2022-02-07 09:28:25 -05:00
Johann Fischer 1e3f7ca433 usb: add option to initialize USB device support at boot
Possibility to initialize USB device support is useful when
only CDC ACM class is enabled and CDC ACM UART is used as
backend for console, shell, or logging.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-02-07 13:06:35 +01:00
Andries Kruithof 43ed49c1e6 Bluetooth: tests: edtt: fix buffer overflow error
HCI/GEV/BV-01-C tries to send 255 bytes over HCI, as part of sending
an unknown/unsupported command, but the default buffer size
is 65, which results in a buffer overflow and undefined behaviour.
Instead of crashing hard we now check the buffer length.
In order for EDTT tests to pass we set the buffer size to 255

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2022-02-05 06:19:00 -05:00
Jacob Caughfield 2abc8cf3b2 usb: Handle USB_DC_RESET event notifications
This patch fixes an issue where mcux usb devices may stop
functioning after a reset event, because they do not
provide a USB_DC_DISCONNECTED event and USB_DC_RESET
events were not handled by the forward status callback.

Signed-off-by: Jacob Caughfield <mlsvrts@protonmail.com>
2022-02-04 22:58:06 +01:00
Carles Cufi d0ebeee0aa modbus: Get rid of custom CRC16 function
In previous commits the crc16_ansi() function has been made compliant
with the CRC-16-ANSI aka CRC-16-MODBUS standard. Use that standard
function instead of a custom one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-04 12:33:22 -05:00
Carles Cufi 07c78e515c mgmt: mcumgr: Replace use of crc16 with crc16_itu_t
Since this CRC uses the 0x1021 poly with no reflection, a faster
implementation is available in the crc16_itu_t() function, which is
O(n).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-04 12:33:22 -05:00
Vinayak Kariappa Chettimada 32e812c944 Bluetooth: Controller: Fix Periodic Sync Terminate race condition
Fix Periodic Sync Terminate implementation for race
conditions with ULL scheduling by using a flag to stop any
new ULL scheduling to receive chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-04 15:03:09 +01:00
Piotr Pryga 87bd890dc3 Bluetooth: Controller: llcp: Add missing PDU initialization
There was missing a PDU initialization. CP bit in data channel
PDU heder was not cleared. Also cte_info byte was not crelader.
That lead to malformed control procedures PDUs and issues
with connection maintenance.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-04 14:32:42 +01:00
Piotr Pryga 4fc0bfb0e8 Bluetooth: Controller: df: CP bit not cleared in DF conn mode RX
In direction finding connected mode there is a CP bit that is set
data PDU header. The bit was initialized only if CTE transmission
was enabled. In case of reception of a CTE the bit was available
in PDUs but not initialized.
That caused issues in connection maintenance if PDU memory buffers
were reused. PDU were malformed and connections were lost.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-04 14:32:42 +01:00
Berend Ozceri 9edb8e2afb mgmt: smp: Fix NULL pointer dereferences in UDP transport.
Guard call to k_thread_abort() to ensure it's not called with an
uninitialized thread and fix improper use of inet_pton() with
INADDR_ANY passed in place of a dotted-decimal string. Both of these
would otherwise lead to NULL pointer dereferences.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-02-04 11:23:16 +01:00
Vinayak Kariappa Chettimada 8f444e490c Bluetooth: Controller: Fix missing offset adjust field assignment
Fix missing offset adjust field assignment in the Periodic
Advertising's sync_info struct that is present in the
Extended Advertising PDU.

When the sync offset is equal or over 2.4576 seconds from
the Extended Advertising PDU, then the sync offset has to
be reduced by 2.4576 seconds and the offs_adjust flag be
set in the sync_info field.

This fixes a bug where Periodic Synchronization could not
be established for Periodic Advertisings with intervals
greater than 2.4576 seconds as the sync offset was
incorrect due to rollover in the 13-bit offset field.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-04 11:19:14 +01:00
Marin Jurjević 2f4ab97168 net: lwm2m: add missing optional resource to firmware object
Firmware Update Protocol Support resource initialization
has been left out in #41402.
Initialise the resource in object creation function.

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-02-04 11:19:07 +01:00
Herman Berget c537ac6aa3 Bluetooth: Host: Disallow sending unsupported MTU Exchange
The Exchange MTU sub-procedure shall only be supported on the
LE Fixed Channel Unenhanced ATT bearer.

This was checked when receiving, but sending was allowed.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-02-04 11:18:13 +01:00
Abe Kohandel 4ce354a382 bluetooth: ots: directory listing record length
The directory listing's record length should not reflect the size of the
directory listing object. This field is only the size of the directory
listing entry in the directory object and is intended to help a client
find the next record entry in the list.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2022-02-04 11:15:37 +01:00
Vinayak Kariappa Chettimada 7570af6c94 Bluetooth: Controller: Avoid reporting IQ samples after terminate
Avoid reporting IQ samples after terminate.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-04 11:15:07 +01:00
Daniel Leung 579829776a logging: syst: fix logging v2 with strings as arguments
The packaged string coming from logging subsys requires some
additional processing if there are string arguments.
These strings are actually embedded inside the package so
the string pointers inside the argument list must be
replaced with pointers to strings inside the package.
Without this extra step of processing, MIPI Sys-T's printf
function would process these arguments directly which may be
NULL pointers or invalid one pointing to somewhere.

This utilizes the new cbpprintf_external() for the processing
before feeding data to the MIPI library.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-04 11:14:55 +01:00
Dominik Ermel 0905e8e32f mgmt/mcumgr/lib: Fix message_size not updated
The commit fixes smp_process_request_packet failing to decrement
message_size, of read stream, by number of bytes it trims from
an input buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-04 11:14:08 +01:00
Daniel Nejezchleb 208927d640 net: tcp: Fixed forever loop in tcp_resend_data
Increments send retry every time
after the tcp_send_data when resending.
That way unhandled return values can time
out after set amount of tcp_retries.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2022-02-04 10:56:25 +01:00
Alexander Mihajlovic bd4ddec0c8 usb: Add macro for user defined string descriptors
The new macro USBD_STRING_DESCR_USER_DEFINE works like
USBD_STRING_DESCR_DEFINE with the exception of being
ordered strictly after it. The new macro is needed to
ensures that user defined string descriptors can be added
without disturbing the order of string descriptors
defined by the usb subsystem.

Signed-off-by: Alexander Mihajlovic <a@abxy.se>
2022-02-03 14:57:42 +01:00
Piotr Pryga 281ad2102e Bluetooth: Controller: Make PHY check in conn mode Kconf dependent
Constant Tone Extension may not be transmittied with PHY CODED.
There were check to avoid situation that controller tries to
transmit or receive CTE when PHY is set to CODED.
These check were not conditionally compilated, hence when
PHY Update feature is disabled code did build.

The commit fixes the issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Piotr Pryga 8f59477dc6 Bluetooth: host: df: Fix wrong HCI cmd buf size for RX params set
In case the direction finding RX is enabled but without Angle
of Arrival functionality enabled, there HCI command buffer
had wrong command length assigned. It didn't take into account
two dummy antenna IDs provided to fulfil requirement from
BT 5.3 Core Vol 4, Part E sections: 7.7.82, 7.7.85.

HCI driver when received such command buffer, didn't handle it
due to wrong command length.

The commit fixes the problem.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Piotr Pryga 48313ef4df Bluetooth: common: Kconfig: Extend EVT buf size to store IQ samples
BT_BUF_EVT_RX_SIZE size by default was set to 68 bytes.
In case of build with direction finding connected mode receiver
enabled the size of event buffer was not enough to store all
IQ samples. In such situation IQ samples reports were not delivered
to Host.

The commit changes default size of event RX buffer to 255 in
case the BT_DF_CONNECTION_CTE_RX is enabled.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Piotr Pryga 8f56d4ee19 samples: Bluetooth: df: Remove dep on CTLR Kconf in sample sources
Direction finding samples had dependency on KConfig option defined
in Controller. That caused a problem for split builds where
an application and host are not part of the same binary as
controller. The code dependend on the Kconfig option
was always disabled.

To fix that issue new Kconfig options were introduced to
Host. The dependency is removed. Unwanted features may stil be
disabled and samples binaier will be smaller.

The commit aligns all direction finding samples code.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Yong Cong Sin 731241f8d0 kernel: workq: Fix type errors in delayable work handlers
A common pattern here was to take the work item as the subfield of a
containing object. But the contained field is not a k_work, it's a
k_work_delayable.

Things were working only because the work field was first, so the
pointers had the same value. Do things right and fix things to
produce correct code if/when that field ever moves within delayable.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-02-02 18:43:12 -05:00
Julien Massot f5f61ac605 debug: Add back openocd alias
OpenOCD is still using these alias, until we fix OpenOCD
upstream we should keep them.

This partially reverts commit
1a7bc06086.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2022-02-02 14:34:41 -05:00
Vinayak Kariappa Chettimada fc348614e6 Bluetooth: Controller: Fix duplicate incomplete data status
Fix duplicate incomplete data status generated for Periodic
Advertising Report when LLL scheduling is used but auxiliary
context failed to be allocated in ULL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 16:59:08 +01:00
Vinayak Kariappa Chettimada a7d0b5e980 Bluetooth: Controller: Fix race condition in sync create cancel
Fix race condition in sync create cancel that assigned NULL
scan context's associated periodic sync context which caused
ULL to dereference NULL pointer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 16:59:02 +01:00
Vinayak Kariappa Chettimada 0cfcc56d9d Bluetooth: Controller: Fix duplicate release of auxiliary context
Fix duplicate release of auxiliary context when scanning
uses LLL scheduling for reception of auxiliary PDU but the
reception fails.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 16:58:31 +01:00
Marin Jurjević 57a66648ae net: lwm2m: fix context close race condition
Calling lwm2m_rd_client_stop causes the client context to be closed.
Doing this from arbitrary thread other than internal lwm2m engine thread
causes racing condition on lwm2m engine context pointers.

Fixes #42358

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-02-02 08:58:40 -05:00
Vinayak Kariappa Chettimada f5a2b05b0d Bluetooth: Controller: Fix same peer periodic sync check
Move the same peer periodic sync check to after check for
existing periodic sync create on both 1M  and Coded PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:21 +01:00
Vinayak Kariappa Chettimada c474e374a7 Bluetooth: Controller: Fix Periodic Sync memq link leak
Fix memq link buffer leak on Periodic Sync failed to be
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:14 +01:00
Vinayak Kariappa Chettimada 79e3be3c63 Bluetooth: Controller: Fix extended scan rx flush for continous scan
Fix missing progression of the rx_last pointer when
appending rx buffers before flushing them towards Host.
Under continuous scanning, as the disabled_cb would only
be called when reference count reaches zero, the rx_last
pointer needs to progress when appending the rx buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:08 +01:00
Vinayak Kariappa Chettimada 5f4d6e34bc Bluetooth: Controller: Fix missing Periodic ULL sched incomplete report
Fix missing Periodic Advertising Report with incomplete
data status when ULL scheduled chain reception is aborted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00
Vinayak Kariappa Chettimada 03f74c7ec2 Bluetooth: Controller: Fix missing Periodic LLL sched incomplete report
Fix missing Periodic Advertising Report with incomplete
data status when LLL scheduled chain reception is aborted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00
Vinayak Kariappa Chettimada d43435a727 Bluetooth: Controller: Fix Periodic Sync Aux context leak on -ENOMEM
Fix Controller implementation to release auxiliary context
when there is no node rx buffer available to receive
Periodic Advertising Sync AUX_CHAIN_IND PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00
Vinayak Kariappa Chettimada ee8994ee42 Bluetooth: Controller: Refactor Periodic Advertising cond. compilation
Refactor Periodic Advertising conditional compilation to use
IS_ENABLED define.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00
Vinayak Kariappa Chettimada 1b3671005f Bluetooth: Controller: Fix to defer Periodic Report after ULL schedule
Fix Periodic Advertising Report data status when ULL
scheduling to receive auxiliary PDU fails. Defer the
dispatch of Periodic Advertising Report until ULL
scheduling status is comfirmed and assign the correct
value to aux_sched flag.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00
Juha Heiskanen a03deb8ef3 net: lwm2m: Fix Server Object SSID access
Server Object SSID should only have Read access.
LightweightM2M-1.1-int-256 confirmance test validate
that write operation to SSID should return error.
Overwrite SSID affect dead block for lwm2m engine and
only reset will heal.

Fix by adding bootstrap overwrite access for Security and
Server object when bootstrap is active.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-02-02 11:18:53 +01:00
Robert Lubos 9c8d30f099 net: lwm2m: Prevent snprintk warnings on different platforms
Use explicit casting to long long within `snprintk()` and logger
functions to prevent compiler warnings with different
platforms/toolchins (as 64-bit integer can be either represented
as ld or lld depending on platform).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 486e0a8ff6 net: lwm2m: Fix lwm2m_parse_peerinfo misuse
`lwm2m_parse_peerinfo()` expects a boolean value, not a pointer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 21e5cc7a31 tests: net: lwm2m: Add link-format content writer tests
Add unit tests for LwM2M link-format content encoder/decoder.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 735fd86c0e tests: net: lwm2m: Add OMA TLV content writer tests
Add unit tests for LwM2M OMA TLV conent encoder/decoder.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos e42c1ed924 net: lwm2m: Fix OMA TLV objlnk encoding
At some point OMA TLV integer encoding was optimised to use the smallest
size possible. This broke the objlnk encoding, which internally used
`put_s32()`, but should always be 4 bytes long. In case the result
32-bit integer would fit into 16 or 8 bytes, it'd get optimized.

Fix this, by creating and writing TLV manually for objlnk instead of
relying on int32 encoder.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 3595a7cdb5 net: lwm2m: Fix lwm2m_atof for integer input
In case a string with an integer was provided to the function (no
decimal point), the function did not update the output pointer value.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos cb6c5f37ca net: lwm2m: Improve content writers error handling in engine
Verify the restult of the content writer functions and return an error
if content writer fails to read/write field in the message.

This solves an issue when for example malformed packet was sent to the
server if the payload did not fit in the message.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 1a727b8571 net: lwm2m: Improve JSON content encoder/decoder error handling
It's now possible to return an error code instead of 0 where
appropriate.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 9e2bf49103 net: lwm2m: Improve TLV content encoder/decoder error handling
It's now possible to return an error code instead of 0 where
appropriate.

Make `buf_read()` return -ENODATA instead of -ENOMEM if there's not
enough data in the packet to serve the request, which is more meaningful
for this scenario.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos f1d86a0cd2 net: lwm2m: Improve plain-text content encoder/decoder error handling
It's now possible to return an error code instead of 0 where
appropriate.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 1c3dbd5af3 net: lwm2m: Improve link-format content encoder error handling
It's now possible to return an error code instead of 0 where
appropriate.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Robert Lubos 54ddf70945 net: lwm2m: Allow to return error codes by content encoders/decoders
Rework the content encoder/decoder API to allow to return negative
values as well. This allows a proper error reporting and error handling,
as it's now possible to differentiate when there is no content to write
(retuned 0) or and error occured, and further processing should be
aborted.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-02 11:12:56 +01:00
Efrain Calderon 6b936c0315 net: coap: Update coap context using payload length
When a file is download, `ctc->current` is increaed by the block
size, which is correct for all the blocks except the last one.

 Once the download is compelted, ctx->current must match
`ctx->total_size`.

Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
2022-02-02 11:10:57 +01:00
Piotr Pryga fc208bb7eb Bluetooth: Controller: llcp: Add wait for nrf state in CTE REQ
There were no wait for free notification buffer (pdu object
used to send notifications to Host).
That may cause assertion in lp_comm_ntf function.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga dbf86b0359 Bluetooth: Controller: Add CTE REQ disable when change PHY to CODED
Accodring to BT 5.3 Core Vol 4, Part E section 7.8.85 the CTE request
procedure has to be disabled as if Host issued the HCI_LE_Connection-
CTE_Request_Enable with enable property set to 0. It means a Controller
should automaticall  disable the procedure.

There were no handling of this part of specification.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga 9603e103b9 Bluetooth: Controller: llcp: Add missing CTE pause in remote PHY change
There were missing pause of CTE request in case remote PHY change
was handled. That may end in violation of BT 5.3 Core Vol 6, Part B
section 5.1.10.1 Packet transmission restrictions.
Without the change there was a possibility to transmitt CTE when
PHY is about to change to PHY CODED.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga ff45244928 Bluetooth: Controller: df: Add clarifying comment
Add comment to clarify what is a disable_cb callback purpose
and when it is set.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga c9431ee622 Bluetooth: Controller: df: Remove not needed if statement
Removes a if statement that was always true.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga d487476f4a Bluetooth: Controller: llcp: add complete evt handling in idle state
Add handling of complete event in idle state of localy innitiated
control procedures.
The transition will be used by CTE request disable if PHY changes
to CODED while the procedure is waiting in the waiting queue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga 9684dd6c48 Bluetooth: Controller: df: Fix wrong PHY type check in CTE req enable
CTE request may not be enabled when actual PHY does not support
transmission of constant tone extension. In case a connection is
asymetric, receive PHY is required to support transmission of CTE.
Receive PHY will be used by a device to get PDU with CTE.

In ll_df_set_conn_cte_req_enable was checking TX PHY type.
It should check RX PHY type.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga f79f9d155d Bluetooth: Controller: df: refactor CTE REQ set disable
Add a function that is responsible for set CTE request disabled.
It is a refactoring, to have a single place where CTE request
is_enabled and req_interval are zeroed.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Piotr Pryga 1856c6b23e Bluetooth: Controller: df: Add missing CTE request is_enabled set
There were missing set of is_enabled member of CTE request.
That allowed host to run HCI_LE_Connection_CTE_Request_Enable
command with enable parameter set to true sequently.
That violates BT 5.3 Core specification Vol 4 Part B section
7.8.8.85.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-02 10:53:51 +01:00
Dominik Ermel 7728587f47 mgmt/mcumgr/lib: Fix no check on message
The commit fixes smp_process_request_packet not checking header
stated message length against actual message length.
This could lead to an erratic behavior of an application when it tries
to parse CBOR data beyond actual size of message or potential
Zephyr crash.
When application has asserts enabled the error leads to inevitable
Zephyr crash, caused by net_buf checks.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-01 16:20:35 -05:00
Daniel Nejezchleb d3a9e7c29a net: sockets: Fixes net_pkt leak in accept
Fix net_pkt leak by increasing net_context the reference count earlier
in the zsock_accepted_cb() with instalment of the
zsock_received_cb() callback.

And consequently flushing recv_q and decrement net_context
reference count if zsock_accept_ctx() fails.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2022-02-01 14:22:37 -06:00
Robert Lubos 0755a7f057 net: sockets: getaddrinfo: Fix possible crash when callback is delayed
In case system workqueue processing is delayed for any reason, and
resolver callback is executed after getaddrinfo() call already timed
out, the system would crash as the callback makes use of the user data
allocated on the stack within getaddrinfo() function.

Prevent that, by cancelling the DNS request explicitly from the
getaddrinfo() context, therefore preventing the resolver callback
from being executed after the getaddrinfo() call ends.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-02-01 14:18:33 -06:00
Jarno Lamsa a1c80e7374 net: lib: lwm2m: Add missing function declarations
Get-function declarations for fw update state and result were
missing from the engine header.

Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
2022-02-01 14:14:29 -06:00
Flavio Ceolin 350014d399 pm: Clear the forced flag in the error path
Now that the forced flag is cleared with the kernel locked in the
suspend path, we need to clear it out when the suspend process fails.

This is being done before jump to the end label because in the
successful path the flag is already cleared.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-01 14:41:05 -05:00
Flavio Ceolin 2e9589bd44 pm: Just check the forced flag
When suspending we don't need to set the forced flag but just check if
it is set.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-01 14:41:05 -05:00
Flavio Ceolin fdf7465851 pm: Fix multithread issue with force state
The "state forced" flag has to be cleared with the scheduler locked,
otherwise the idle thread can be scheduled out without clear it and
the next call to force a state will fail.

Fixes #41911

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-01 14:41:05 -05:00
Krzysztof Chruscinski eb9814c626 testsuite: ztest: Fix concatenation in macro
Use UTIL_CAT which resolves input arguments instead of direct
preprocessor concatenation.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-01 08:16:10 -05:00
Joakim Andersson 743b0583fc Bluetooth: controller: Enable debug pins with TF-M enabled
Enable debug pins when TF-M has been enabled for the image.
This would otherwise produce an error message as the DEBUG_SETUP would
not have been defined for the non-secure image.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-02-01 11:31:36 +01:00
Vinayak Kariappa Chettimada b5ab2f1353 Bluetooth: Controller: Fix missing ISO data packet receive
Fix missing ISO Data packet received by Synchronized
Receiver due to incorrect check on sink handle that did
not permit handle value of 0.

Fixed function to get ISO stream context to check for
valid ISO sync context, i.e. not being terminated.

Regression introduced in commit 7c89f1fe9f ("Bluetooth:
controller: Support for separate ISO RX data path").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-31 18:12:10 +01:00
Dominik Ermel 8a4c58618b mgmt/mcumgr/lib: Return error on bad SMP header
The changes smp_process_request_packet to return MGMT_ERR_ECORRUPT
in case when failed to read header.
This helps to recognize that there will not be any response sent
from mcumgr to the buffer given to smp_process_request_packet as
it has not been recognized as valid request.
It also removes redundant check on mgmt_streamer_init_reader which
always returns 0 (no failure) in Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-31 17:22:03 +01:00
Robert Lubos f4a18e471b net: sockets: tls: Fix ZSOCK_POLLHUP detection
The previous approach to detect if the underlying transport was closed
(by checking the return value of `mbedtls_ssl_read()` was not right,
since the function call does not request any data - therefore 0 as a
return value is perfectly fine.

Instead, rely on the underlying transport ZSOCK_POLLHUP event - if it
reports that the connection ended, forward the event to the application.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-31 17:20:55 +01:00
Robert Lubos f8751629c7 net: sockets: Report ZSOCK_POLLHUP when socket is in EOF state
Report ZSOCK_POLLHUP event if peer closed the connection, and thus the
socket is in EOF state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-31 17:20:55 +01:00
Dominik Ermel e83b074128 mgmg/mcumgr/lib: Image upload size no longer needs flash alignment
The mcumgr image upload uses buffed flash writes with use of stream
flash, which makes flash alignment check unneded.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-31 16:22:55 +01:00
Vinayak Kariappa Chettimada 3f37210cd6 Bluetooth: Controller: Fix parsing empty ADV_EXT_IND and ADV_SYNC_IND
Fix implementation to check for empty ADV_EXT_IND and
ADV_SYNC_IND PDUs, and not parse them incorrectly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-31 12:13:08 +01:00
Vinayak Kariappa Chettimada faa89c779c Bluetooth: Controller: Fix Periodic Adv Report to scan max data length
Fix implementation to limit Periodic Advertising data to a
configurable maximum length when generating HCI reports.

Bluetooth Test Specification defines Scan_Max_Data value
in IXIT. When HCI LE Periodic Advertising Report events are
generated by assembling the chain PDUs, the test cases
expect that if the data length is no more than
Scan_Max_Data, then at least once the IUT shall not
truncate the data in the advertising report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-28 19:13:56 -05:00
Vinayak Kariappa Chettimada 93d6d1e114 Bluetooth: Controller: Minor fix isr_done context parameter passed
Remove redundant parameter pass of lll_aux to isr_done as
the auxiliary context use is always for scan context as the
parent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-28 19:13:56 -05:00