Commit graph

7023 commits

Author SHA1 Message Date
Joakim Andersson f85433c4a9 Bluetooth: host: Refactor setting maximum data length
Refactor setting the maximum data length parameters supported on in
auto data length procedure. This makes setting the data length of the
connection a re-usable function.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Vinayak Kariappa Chettimada aa60a51a66 Bluetooth: controller: Update Bluetooth version to 5.2
Update the Bluetooth HCI Version to 5.2.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-05-07 19:26:13 +03:00
Morten Priess 3ed658e9ed Bluetooth: controller: Added support for vendor ticker nodes
With BT_CTLR_USER_TICKER_ID_RANGE it is possible for vendors to add a
number of ticker nodes for proprietary purposes. The feature depends on
BT_CTLR_USER_EXT.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-05-07 17:34:21 +02:00
Tomasz Bursztyka 38970c07ab net/ieee802154: Validate length on received frames
Frame format was validated, but its length should be also validated
relevantly against the format.

Fixes #24970

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-07 13:20:46 +03:00
Emil Obalski 45bdb23005 usb: Special return values for custom_handler
This commit introduces dedicated return type for custom_handler.
Relevant code is updated to fulfill the API documentation.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-07 11:20:27 +02:00
Emil Obalski 8fa51bca58 usb: Allow Audio Class to handle custom_hander for all interfaces
This exception allows USB Audio Class to properly respond to the
interface requests.

This commit is temporary solution and shall not be considered as
valid solution for other classes.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-07 11:20:27 +02:00
Carles Cufi 04d1104ee5 timeouts: Fix power _sys_suspend invocation
Use K_TICKS_FOREVER instead of K_FOREVER after the timeout API rework.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Carles Cufi 8e297e87b3 console: Port to the new timeout API
Port the code so that it uses the new timeout API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Carles Cufi 0d2b74bc6f power: ti: Port to the new timeouts API
Port the TI-related code in subsys/power so it complies with the new
timeouts API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Peter Bigot e052c7991c settings: add const qualifier for unmodified data source
Code using this API to set a key to a value that is a string literal
produces errors in C++ because the passed pointer is not const
qualified, allowing the possibility that the callee modifies the
referenced string literal memory.  Add the required const qualifiers
since the set function does not change the passed to it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-07 10:51:49 +02:00
Simon Glass fc0e10d064 shell: Support output using a va_list
At present it is not possible to write a printf()-like function in
board code which outputs to the shell. Add shell_vfprintf() to permit
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-07 10:04:28 +02:00
Simon Glass 2a8463e2b8 shell: Extend dummy backend to record for testing
It is useful to run tests which generate shell output and check that it
is correct. Update the existing 'dummy' backend to support this.

It works by retaining the output in a small buffer so that it can be
read and checked by the test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-07 10:04:28 +02:00
Luiz Augusto von Dentz 1c35cc18fe Bluetooth: hci_raw: Split TX into ACL and CMD pools
This might reduce the footprint if the supported sizes are different.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-07 10:31:36 +03:00
Luiz Augusto von Dentz f9d1b7ed63 Bluetooth: hci_raw: Fix number of TX buffers
The numbers should have been the sum of HCI commands count and ACL TX
buffers but instead the buffer size was used which makes the pool holds
substatially more buffer than necessary.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-07 10:31:36 +03:00
Joakim Andersson c6edfa0971 Bluetooth: shell: Add name option control to advertise parameters.
Add control over the use name option to advertise shell parameters as
an optional argument.
The argument count for extended advertise parameters had not been
updated for the maximum directed advertise parameter count.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Joakim Andersson 4592cb64ea Bluetooth: host: Add BT_LE_ADV_OPT_USE_NAME for new advertising API
Implement the BT_LE_ADV_OPT_USE_NAME when using bt_le_ext_adv_* APIs
to start the advertiser.
When starting an extended connectable advertiser the name must be
included in the advertising data, since scan response data is
not allowed in this configuration.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Joakim Andersson e9002a4fb4 Bluetooth: host: remove duplicate flags set.
Remove setting state flags in bt_le_adv_start_ext since they are set
by le_ext_adv_param_set, except for BT_ADV_PERSIST flag.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Joakim Andersson a2a7cc9fe6 Bluetooth: host: Only persist advertising with bt_le_adv_start API
Only persist advertising when the bt_le_adv_start API is used to start
the advertiser. For multiple advertising set a connectable advertiser
can only be started if there is a connection object available for the
advertiser. Leave the decision on which advertising set should be
advertising up to the application instead of suspending advertising
when no connection object is available.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Peter A. Bigot 2b33467a61 disk: disk_access_flash: align buffer
Flash drivers may impose alignment requirements on the destination
buffers due to use of DMA transfers.  In particular Nordic QSPI flash
API requires that addresses, sizes, and buffers all be 4-byte aligned.
Align the ready/copy buffer to satisfy this requirement.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-05-06 11:31:44 +02:00
Peter A. Bigot ebd19ad10b usb: mass_storage: align page buffer
Flash drivers may impose alignment requirements on the destination
buffers due to use of DMA transfers.  In particular Nordic QSPI flash
API requires that addresses, sizes, and buffers all by 4-byte aligned.
Align the page buffer to satisfy this requirement.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-05-06 11:31:44 +02:00
Håkon Øye Amundsen 0aa21a632a dfu: use stream_flash in flash_img
Leverage strem_flash in flash_img.c to reduce code size.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-05-06 11:14:00 +02:00
Håkon Øye Amundsen a9676831cb storage: add stream flash library
This library supports stream writes to flash with
optinal progressive erase.

This module is a direct copy of the functionality found in
subsys/dfu/img_util/flash_img.c

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-05-06 11:14:00 +02:00
Alexander Wachter 464f135ce6 canbus: Convert canbus driver and subsys to new timeout API
Convert all canbus related API/samples/tests/subsys
to the new timeout API with k_timeout_t.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-05-06 10:19:13 +02:00
Marcin Niestroj 6fdb9e6ded shell: dump characters in shell_hexdump
Improve hexdump output of shell_hexdump() to match what is currently
printed by LOG_HEXDUMP*() family of functions. That way string buffers
that are sent/received using shell commands can be easily presented
using shell_hexdump() without loosing user experience (with previous
shell_hexdump() that printed only hex bytes) and code validity (printed
buffers are not always NULL terminated with only printable characters).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-05-06 09:42:02 +02:00
Lukasz Maciejonczyk ae68354428 net: l2: openthread: Add function for getting openthread default instance
The new function simplifies use of OpenThread API in Zephyr.

Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
2020-05-05 16:30:20 +03:00
Jukka Rissanen 65a1bebe85 net: Replace NET_WAIT_FOREVER by SYS_FOREVER_MS
As we now have SYS_FOREVER_MS, use that instead of network
specific NET_WAIT_FOREVER.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 16:29:23 +03:00
Jukka Rissanen 1fea82c125 net: ipv6_fragment: Remove extra net_pkt_cursor_init() call
The net_pkt_pull() will reset the cursor after its call so no
need to call it here.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 13:39:45 +03:00
Jukka Rissanen 8160385b57 net: pkt: Fix removal of empty buffers in net_pkt_pull()
If we have removed first net_buf, then we must not restore the
original cursor as that will point to wrong head net_buf.
Add also unit test to check that the packets are removed
properly.
Clarify the documentation that we are removing data from
beginning of the function, also document that the cursor
is reset after this call.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 13:39:45 +03:00
Joakim Andersson fdb3da8aff Bluetooth: host: Rename BT_LE_CONN_OPT to BT_CONN_LE_OPT
Rename connection options to be consistent with the rest of the API
names in conn.h

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-04 17:48:22 +03:00
Joakim Andersson 8b70079ebe Bluetooth: host: Remove BT_LE_CONN_OPT_2M option
Remove the BT_LE_CONN_OPT_2M option and update documentation.
This was a misunderstand about the init PHY HCI parameter.
The init PHY in the extended connection create command does not
determine which PHYs are accepted as the initial PHY of the
connection. This is instead determined by the secondary PHY of the
extended advertiser.
The init PHY parameter only specifies which conn parameters are
provided, and since we only provide one conn parameter this option
has no effect.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-04 17:48:22 +03:00
Kumar Gala 8101a0f661 flash: dts: replace DT_FLASH_{ERASE,WRITE}_BLOCK_SIZE with new macros
Replace:
	DT_FLASH_ERASE_BLOCK_SIZE ->
	DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)

	DT_FLASH_WRITE_BLOCK_SIZE ->
	DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)

As this allows us to phase out the old generator.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-04 13:26:04 +02:00
Marek Porwisz d9f8a6f8e9 subsys/testsuite: Extended mocking API to support arrays
I was missing mocking api to compare data under an address pointed
by a parameter as some functions may copy buffers before passing
further.
Created ztest_expect_data and ztest_check_expected_data.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-05-04 12:00:02 +02:00
Johan Hedberg e1dddf7bef Bluetooth: Fix NULL pointer dereference when bt_send() fails
The last parameter to hci_cmd_done() is expected to be a valid net_buf
since the function immediately tries to dereference it. Fix this by
passing the appropriate buffer reference to the function.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-05-04 10:59:39 +03:00
Luiz Augusto von Dentz ec5603da8d Bluetooth: L2CAP: Add status flag to track encrypt pending
This adds a new flag to track if the L2CAP channel is pending waiting
for encryption to be changed to resume connecting.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz e0cbdf3b87 Bluetooth: GATT: Add support for new PDUs
This adds support for ATT_MULTIPLE_HANDLE_VALUE_NTF,
ATT_READ_MULTIPLE_VARIABLE_REQ and ATT_READ_MULTIPLE_VARIABLE_RSP.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz f4192bda26 Bluetooth: ATT: Add support EATT bearer
This adds support for EATT bearer which was introduced in 5.2, they work
as extra channels to have GATT traffic, at the moment it is completely
transparent to application when they are in use since the allocation
happens automatically.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz d148f8648b Bluetooth: ATT: Add definitions from 5.2
This adds the definitions for Enhanced ATT along with new PDUs and UUIDs
introduced in 5.2.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 14d6c00b9b Bluetooth: L2CAP: Add released callback
This adds a callback to indicate when the stack has released all
references to a given channel so the owner free up any resources
associated with that.

This is requires since EATT channels cannot rely on the destroy callback
as it does not use a fixed channel like ATT.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 0473b436b5 Bluetooth: L2CAP: Process channel with fixed PSM on RX thread
This leaves only channels on the dynamic range to be offloaded to the
system queue so ATT and EATT handling are handling in the same context.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz f7586b0b04 Bluetooth: L2CAP: Add initial implementation of ECRED mode
This adds the initial implementation of ECRED mode which can connect up
to 5 channels simultaneously and is required by EATT.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 72d4f06bf0 Bluetooth: L2CAP: Use spaces to align defines
This replaces the use of tabs with spaces to align defines.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 95e109bc8e Bluetooth: L2CAP: Add definitions introduced in 5.2
This introduces new Enhanced Credit Based Flow Control PDUs and related
definitions which were introduced in 5.2.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Kumar Gala 05f21619e3 usb: Convert vbus-gpio usage to new devicetree macros
Convert the usb_vbus_set function to utilize a chosen property
('zephyr,usb-device') to determine the device node that should have a
'vbus-gpios' property set for usb_vbus_set to be more than just a noop.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-01 07:49:31 -05:00
Jukka Rissanen 0fa86cbbf1 net: Remove CONFIG_LEGACY_TIMEOUT_API dependency
Allow networking to work without legacy timeout API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Jukka Rissanen 5284b597b1 net: stats: Convert to use k_timeout_t
Statistics was still using timeouts incorrectly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Jukka Rissanen 54864d063d net: gptp: Convert to use k_timeout_t
One k_timer_start() was missing k_timeout_t conversion.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Kumar Gala 8316818739 bluetooth: controller: openisa/RV32M1: Convert irqs to new dts macros
Convert old style defines for IRQ numbers to using DT_IRQN and
DT_NODELABEL to extract IRQ numbers.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-30 11:26:59 -05:00
Peter Bigot 52885d0576 coccinelle: run ms_timeout conversion semantic patch
Substitute integral constants where call sites passed named constants
that have timeout values as arguments to parameters that expect
millisecond durations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-30 18:26:26 +02:00
Kumar Gala a45ea3806f x86: Rework rework x86 related code to use new DTS macros
Replace DT_PHYS_RAM_ADDR and DT_RAM_SIZE with DT_REG_ADDR/DT_REG_SIZE
for the DT_CHOSEN(zephyr_sram) node.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-30 08:37:18 -05:00
Joakim Andersson eba6265ac3 Bluetooth: controller: Add BT_CTLR_CONN_RSSI_EVENT option
Split BT_CTLR_CONN_RSSI option into two, the base option enables the
Read RSSI command, while the new BT_CTLR_CONN_RSSI_EVENT enables the
connection RSSI events. There is no handling of RSSI events, only a
BT_INFO log.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:33:16 +02:00
Bilal Wasim 220b664617 net: tftp: Adding support for TFTP Client.
Adding RFC1350 compliant support for TFTP Client in Zephyr. The
current implementation is minimal and only supports the ability
to get a file from the server.

Things for the future include support for putting files to
server and adding support for RFC2347.

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
2020-04-30 14:19:46 +03:00
Joakim Andersson 91c20e313d Bluetooth: Remove LEGACY_TIMEOUT_API selection from bluetooth
The bluetooth subsystem is now fully compatible with the new timeout
API, so remove the selection of the legacy API.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson ac2ce863ef Bluetooth: shell: Convert bluetooth shell to using k_timeout struct
Convert bluetooth shell to using k_timeout struct.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson 87d9eadf50 Bluetooth: mesh: Convert bluetooth mesh to using k_timeout struct
Convert bluetooth mesh to using k_timeout struct. Many of the mesh
modules uses timeout calculations, so it is most practical to keep
the s32_t type and only initialize a k_timeout_t struct when
calling the kernel.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson d858264d9e Bluetooth: host: Convert bluetooth host to using k_timeout_t struct
Convert bluetooth host to using k_timeout_struct for the timeout values.
This is mostly replacing s32_t with k_timeout_t.
In l2cap the handling of no timeout in send channel request was removed
since the timeout is both documented as minimum of 1 second and never
given any no timeout value.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson 05e5db74cf Bluetooth: controller: Convert bluetooth controller to using k_timeout_t
Convert bluetooth controller to using the new k_timeout_t API so that
CONFIG_LEGACY_TIMEOUT_API can be turned off.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Ravi kumar Veeramally 91de50cb37 net: tcp2: Fix FIN+ACK retransmissions in ESTABLISHED
In order to avoid retransmissions from the peer's side
on full-close, handle states properly.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-30 12:52:11 +03:00
Jukka Rissanen ae87a7177d net: pkt: Add empty buffer removal to net_pkt_pull()
If net_pkt_pull() would cause an empty net_buf, then unref
those empty buffers from the list.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-30 09:27:16 +03:00
Robert Lubos 358dcc1bde net: lwm2m: Handle socket errors
So far socket errors reported by poll/recvfrom were ignored, which could
lead to an unexpected behavior when socket was left in an undefined
state.

Fix this, by requesting a re-registration in the LWM2M state machine,
which will close the faulty socket and open a new one. Note, that simply
closing and re-opening a socket in the lwm2m engine would not work,
since this would silently invalidate any open observations on the
lwm2m server side (due to port number change). Triggering a fresh
registration will notify the server to update its observations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-30 08:57:18 +03:00
Anas Nashif 051602f4f3 sanitycheck: support coverage with unit tests
Fix setting coverage for unit tests and link against gcov when coverage
is enabled.

Fixes #24674

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-04-29 09:01:06 -04:00
Paul Sokolovsky af3defd34e net: sntp: Namespace private SNTP definitions
SNTP implementation defined symbols like "MODE_MASK", which can easily
conflict with similary laxly defined symbols in other modules, and
indeed, we hit a case like that (below). So, prefix these symbols
consistently with "SNTP_", until more clear private namespacing
convention are made pervasive in Zephyr.

subsys/net/lib/sntp/sntp_pkt.h:14: error: "MODE_MASK" redefined
include/arch/arm/aarch32/cortex_a_r/cpu.h:17: note: this is the
  location of the previous definition

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-04-29 09:09:04 +03:00
Kiril Petrov ea072341d5 net: lwm2m: init pendings and replies on lwm2m_engine_start
On OT network with poor coverage, very often request/observe packets
doesn't get it's ACK and consumes from pendings/replies/message stacks.
In such cases when LWM2M engine tries to recover by resetting its state,
it fails because of lack of free messages.

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2020-04-28 20:46:35 +03:00
Kiril Petrov 7305e7b4a2 net: coap: add coap_pendings_clear and coap_replies_clear
Clears whole stack of pendins and replies.

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2020-04-28 20:46:35 +03:00
Joakim Andersson e9375a2814 Bluetooth: Remove bluetooth thread stack size analysis
Remove logging of individual threads spread out throughout the
bluetooth subsystem. The stacks can be analysed by enabling the
following options.

CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_AUTO=y
CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
Optional:
CONFIG_THREAD_NAME=y

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-28 09:11:13 -04:00
Joakim Andersson 27ef15b8f5 debug: thread_analyzer: Implement thread analyzer
Thread analyzer is simple module that helps in printing thread
information, like stacks usage statistics.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Signed-off-by: Bartosz Gentkowski <bartosz.gentkowski@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-28 09:11:13 -04:00
Robert Lubos ae4ddc77cc net: lwm2m: Lower log level for duplicate response
In networks with high latencies (like NB-IoT), it's quite common to
recieve duplicated response. It's not an error condition, a correct way
to handle it is to simply ignore the duplicate. Lower the log level for
this event, not to disturb users.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Robert Lubos afb73d1d09 net: lwm2m: Fix retransmission logic
The retaransmission logic was not correct in the lwm2m_engine, and could
lead to faulty behavior in case multiple messages were pending for
retransmission in the queue.

1. Since there is a singe delayed work item for entire retransmission
   queue, `coap_pending_next_to_expire` should be called before
   scheduling next timeout, to identify which message is going to expire
   next (and when). Currently, the engine always set next timeout, based
   on timeout from the message being currently re-transmitted.
2. In case the message was re-transmitted several times, and is removed
   from the retansmission queue due to a timeout, next retransmission
   should be scheduled, in case there are other messages on the queue.
3. Verify the timeout of the earliest message to expire in the
   retransmission handler. In case messages from the beginning of the
   queue were removed, we might need to schedule the retransmission
   again, instead of sending message rightaway.
4. `lwm2m_send_message` is not handling retransmissions anyway, so
   there's no need to check send attempts. Instead, verify
   retransmission work item is already pending, and update its timeout
   if needed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Robert Lubos df152ab59f net: coap: Add initial tx time to coap_pending structure
So far, coap_pending structure kept track only of the timeout interval
between two consecutive retransmissions. Calculations inside
`coap_pending_next_to_expire` relied only on this value. This approach
gives incorrect results though, in case multiple messages are pending
for retransmission.

For instance, assuming initial retransmission timeout is set to 2
seconds. If some message had been retransmitted already, its timeout
would be increased to 4 seconds. Any new message added to the pending
list would have a retransmission timeout set to 2 seconds, and will be
returned as a first message to expire, no matter how long the initial
message was already on the list.

To resolve this, add a `t0` field to the coap_pending structure. This
field is initialized to the initial transmission time, and is increased
on each retransmission by the retransmission timeout.
`coap_pending_next_to_expire` uses this value to calculate absolute
time, when the next retransmission should take place, and based on this
information returns correctly first pending message to expire.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Robert Lubos 40ac0a7a7d net: lwm2m: Convert to new timeout API
Align LWM2M stack implementation with the new timeout API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Kumar Gala 7a15afc1d4 drivers: flash: replace DT_FLASH_DEV_NAME with DT macro
Replace DT_FLASH_DEV_NAME with DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL.
We now set zephyr,flash-controller in the chosen node of the device
tree to the flash controller device.

NOTE: For a SoCs with on die flash, this points to the controller and
      not the 'soc-nv-flash' node.  Typically the controller is the
      parent of the 'soc-nv-flash' node).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-27 18:43:20 -05:00
Stephanos Ioannidis 0e6ede8929 kconfig: Rename CONFIG_FLOAT to CONFIG_FPU
This commit renames the Kconfig `FLOAT` symbol to `FPU`, since this
symbol only indicates that the hardware Floating Point Unit (FPU) is
used and does not imply and/or indicate the general availability of
toolchain-level floating point support (i.e. this symbol is not
selected when building for an FPU-less platform that supports floating
point operations through the toolchain-provided software floating point
library).

Moreover, given that the symbol that indicates the availability of FPU
is named `CPU_HAS_FPU`, it only makes sense to use "FPU" in the name of
the symbol that enables the FPU.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-27 19:03:44 +02:00
Joakim Andersson 3230a85590 Bluetooth: host: Include RPAs in enhanced conn complete logging
Include the RPA addresses in the enhanced connection complete debug
log. This makes it easier to debug privacy failures.
Use a new debug statement so that the debug print will work correctly
when log_strdup does not copy the string.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson 578f2a582f Bluetooth: controller: Set local RPA field only when generated legacy
Fix local RPA field for the legacy controller. This failed without
compilation errors because of blind pointer cast between two
structs of similar definition.
Set the local RPA field of the enhanced connection complete event only
when the address was generated by the controller. If the host has
set an RPA and this one was used the controller should return all
zeroes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson e9b39cd304 Bluetooth: controller: Set local RPA field only when generated
Set the local RPA field of the enhanced connection complete event only
when the address was generated by the controller. If the host has
set an RPA and this one was used the controller should return all
zeroes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson 0d9db89dde Bluetooth: host: Fix compilation issue for extended advertising beacon
Fix compilation issue for extended advertising beacon. Adv pool was
mistakenly put under BT_OBSERVER define.
Both observer and broadcaster use the bt_lookup_id_addr. SMP cannot
be enabled without connections, so for broadcaster and observer there
will not be a lookup.
Fix compilation warning for extended scanner-only build.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson 203d13c1a4 Bluetooth: host: Handle zero-set local RPA in enhanced conn complete
According to the BT Core spec. The local RPA field in the enhanced
connection complete event should be set if the own-address type was
set to 0x02/0x03 and the controller generated an RPA using a non-zero
IRK, otherwise the controller should return all zeroes.
In the case where we generate the RPA in the host instead we need to
handle set the on-air RPA address based on the random address set by
the host.
If this is not handled then pairing will fail because the on-air
addresses are used as input to the pairing procedure.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson a3161ef58e Bluetooth: host: Remove extended advertising from connection complete
Remove handling of extended advertising from connection complete
event. If extended advertising has been enabled and is supported by
the controller then enhanced connection complete must be supported.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Peter Bigot cce7165ea4 power: device: reduce space required to identify pm-capable devices
Use a smaller ordinal type than int to hold the global index
identifying devices that support power management.

Use an upper bound instead of an array of flags to identify the
devices that were successfully suspended.

Only attempt pm on devices that provide a non-default pm control
function.

Use shorter more descriptive names for state variables.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-27 15:36:48 +02:00
Peter A. Bigot e3d613e1f4 subsys/cfb: move MSB_FIRST down to font capabilities
Font capabilities currently indicate whether font data is packed
horizontally or vertically, and this is used to control frame buffer
updates.  The font bit ordering should likewise be recorded in the font
description, and any reversal to match the display applied when text is
being set in the frame buffer.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-04-27 13:27:03 +02:00
Alex Porosanu 4c4f07e0dc bluetooth: controller: openisa: Fix densely scheduled event preemption
This is a rework for OpenISA SW LL of
"b7220cef86 Bluetooth: controller: split: Fix densely scheduled event
preemption"

Fix LLL implementation handling preemption of currently
active radio event with densely scheduled events in the
pipeline.

Preempt timeout was stopped without consideration to there
being more queued events in the pipeline. Also, added
chaining of preemption timeouts one after the other expiry
so as to preempt currently active events by the densely
scheduled events in the pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Alex Porosanu 678f0296c8 bluetooth: controller: openisa: Reduce time to setup tIFS switch
This is a rework for OpenISA SW LL of
"b0826a7f65 Bluetooth: controller: split: Reduce time to setup tIFS
switch"

Refactor to reduce the setup next tIFS switch within tIFS
period of the Radio ISR.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Alex Porosanu d6710257bd bluetooth: controller: openisa: handle latency for cancelled conn events
This is a rework for OpenISA SW LL of
"4547bfb452 Bluetooth: controller: split: handle latency for cancelled
conn events" as well as subsequent fixes

Update implementation of master and slave LLL's to correctly
handle event counter values when latencies introduced due to
connection events cancelled by active events operating in
unreserved time space.

When an active radio event extends into unreserved time
space, and a connection event prepare is scheduled but at
the time of pre-emption timeout if the connection event is
cancelled then the event count and latencies needs to be
continiued to get acummulated.

In the current controller usecases the above scenarios does
not get exercised, the changes in this commit is needed for
future roles that can extend into unreserved time space and
would cancel a scheduled connection event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Alex Porosanu e08ceec584 bluetooth: controller: openisa: fix assert on invalid packet sequence
This is a rework for OpenISA SW LL of
"62c1e1a52b Bluetooth: controller: split: Fix assert on invalid packet
sequence"

Fix to remove assertion failure check on detecting invalid
packet sequence used by peer central and that no non-empty
packet was transmitted.

Fixes #22967.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Luiz Augusto von Dentz 440f647013 Bluetooth: hci_raw: Fix pushing H4 headers in bt_buf_get_rx
User of bt_buf_get_rx may attempt to push their own headers, e.g. ACL
headers, so move the H4 header logic to bt_recv after logging into the
monitor since otherwise the buffer would contain H4 headers which is
not expected by the monitor.

Fixes #24646

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-24 10:00:02 +03:00
Kumar Gala 8b6acb5e91 soc: arm: replace DT_CPU_CLOCK_FREQUENCY with new dt macros
Replace DT_CPU_CLOCK_FREQUENCY with a PATH based reference to cpu@0
(DT_PATH(cpus, cpu_0)) and than getting the clock_frequency property:

DT_CPU_CLOCK_FREQUENCY -> DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)

This lets us remove DT_CPU_CLOCK_FREQUENCY from dts_fixup.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 23:55:37 -05:00
Krzysztof Chruscinski 53b5bae41b shell: Refactor command getters
Refactor and simplified fetching commands from the tree
of commands.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-04-23 18:30:41 +02:00
Kumar Gala 9c6c1f966c drivers: ethernet: eth_mcux: Convert to using DT_INST macros
Convert driver to use instance macro's instead of dts_fixup.h based
macros.  This moves us closer to removing both dts_fixup.h and per
instance Kconfig symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 07:40:37 -05:00
Trond Einar Snekvik 86137c3a62 Bluetooth: Mesh: Add cfg cli list getters
Adds config client getters for all list commands:
- mod_app_get
- mod_sub_get
- net_key_get
- app_key_get

Closes #24505.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-23 14:03:17 +03:00
Oleg Zhurakivskyy ccb5a01fc1 net: tcp2: Refactor tcp_pkt_alloc()
In order to fix the line tracking of the TCP packet allocation
with the test protocol enabled, refactor tcp_pkt_alloc(),
so the line of the allocation can be tracked properly.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-23 12:40:33 +03:00
Lingao Meng be33f913ac Bluetooth: Mesh: Remove net_idx params when with app key
According Mesh Profile 1.0.1. A application key shall
binding single network key. And Device key shall bind all
network key, and dev key only known by cfg_cli and node self,
only used by cfg_cli & cfg_srv.

Fixes: #21088

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-04-23 11:30:41 +03:00
Trond Einar Snekvik 00ba872769 Bluetooth: Mesh: net_key_status only pull one key idx
Fixes bug where the config client's net_key_status handler would attempt
to pull two key indexes from a message which only holds one.

Fixes #24601.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-23 11:26:29 +03:00
Göran Weinholt 32864ecbcc net: lwm2m: support for reading OPAQUE resources with OMA TLV
The LwM2M stack would previously ignore all OPAQUE resources when
reading them. This meant that it was impossible to read them, even if
there was a custom read callback.

Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
2020-04-23 10:16:52 +03:00
Loic Poulain f1a7a53850 net: if: Fix net_if_send_data for non-l2 iface
Some services like DHCHPv4 directly send raw packets to the iface.
This causes issue when the iface does not implement l2, e.g.
because it is a socket offload interface. fix that.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2020-04-22 21:40:38 +03:00
Jukka Rissanen 291a4b2bd1 net: tcp2: Parse TCP options only once
Make sure we only parse the received TCP options only once. Store
the options to tcp conn struct for later use.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-22 20:40:02 +03:00
Ruslan Mstoi 59c21ad3cf net: tcp2: Fix reading TCP options
This patch fixes an issue with TCP options reading. Previous approach
was accessing the options with pointers (th + 1). This does not work if
TCP options span multiple net_pkt buffer fragments. Instead net_pkt
functions must be used.

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2020-04-22 13:15:58 +03:00
Ravi kumar Veeramally 184a2d5197 net: tcp2: Handle FIN_WAIT_2 and CLOSING
Added support for FIN_WAIT_2 and CLOSING states.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-22 12:41:39 +03:00
Robert Lubos 8d984b336e net: lwm2m: Initialize socket FD to an invalid value
During registration, first thing LWM2M does is trying to close a socket
indicated by sock_fd stored in its context. In case it is not
initialized to some invalid value (-1 in this case), LWM2M may close an
ambigous socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-21 20:58:56 +02:00
Trond Einar Snekvik e5d9291d1a Bluetooth: Zero-initialize adv params
After #22013, bt_le_adv_param got additional fields which were passed to
the bluetooth API uninitialized in the BT Mesh module. This
zero-initializes the entire structure in all usages to avoid passing
uninitialized data now and in the future.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-21 18:26:37 +02:00
Oleg Zhurakivskyy 61a1dc934c net: tcp2: Acknowledge the incoming FIN+ACK in FIN_WAIT_1
In order to avoid retransmissions from the peer's side
on active connection close, acknowledge the incoming FIN+ACK
in FIN_WAIT_1 state.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-21 16:57:22 +03:00
Jukka Rissanen d70363f13e net: tcp2: Local address in net_context needs special handling
We cannot directly use the local address in net_context when
registering the connection as it is not proper type. So create
temp address variable for that purposes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-21 16:55:41 +03:00
Jukka Rissanen 76a7fdd213 net: tcp2: No dynamic allocation for TCP connection endpoint
Avoid dynamic allocations and all the issues if we run out of
memory, by placing the connection endpoint directly to TCP
connection struct.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-21 16:55:41 +03:00
Joakim Andersson d4f22a8216 Bluetooth: host: Add support for multiple advertising set
Add support for multiple advertising set. Move the advertising state
flags to be per advertising set and loop over advertising sets instead
of looking up legacy advertiser set or handle 0.

Since it is not certain that the advertising set terminated event can
arrive directly after the connection complete event there is currently
a limitation that there can only be one local identity used by
connectable advertisers at a time. This guarantees that we know
the local identity being used in the connection complete event.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-21 12:46:05 +03:00
Joakim Andersson bfd2f6e928 Bluetooth: host: Only attempt to restart scanner when role is master
Only attempt to restart the background scanner in connection complete
event when the new connection is a master role connection or the
initiator was successfully canceled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-21 12:46:05 +03:00
Joakim Andersson 36de18304b Bluetooth: host: Enable enhanced connection complete for extended adv
Enable enhanced connection complete when extended advertising has been
enabled. This event is mandatory if extended advertising is supported.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-21 12:46:05 +03:00
Arvin Farahmand 6d5f3debaa net: http_client: Fix payload issue on HTTP upload
Bug fix and improved `payload` handling in `http_client_req`.

Changes to `http_client_req` behaviour:

If the user provides `payload_len` it is used to generate the
`Content-Length` header. This is done even if `payload_cb` is used to
provide the actual data. If no `payload_len` is specified then no
`Content-Length` is generated.

If `payload_cb` is provided it is called to send the payload data.
Otherwise `payload` is used as the payload buffer and sent. If
`payload_len` is not zero, it is used as the size of `payload`.
Otherwise `payload` is assumed to be a string and `strlen` is used to
determine its size. This is to maintain current behaviour and not break
existing samples.

Fixes #24431

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2020-04-21 00:05:04 +03:00
Kumar Gala e241de8a31 bluetooth: controller: openisa/RV32M1: Convert DT_ALIAS to NODELABEL
Use the new DT_NODELABEL macro instead of aliases to get the specific
gpios ports.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-20 15:52:30 -05:00
Luiz Augusto von Dentz 4b622afbb3 Bluetooth: hci_raw: Move buffer management to common place
This makes hci_raw to manage RX and TX buffers so its logic don't have
to be replicated on each an every driver/application, it also makes it
simpler to deal with extra headers for H:4 mode since that then can be
done at earlier at buffer allocation.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz 05f0816f93 Bluetooth: hci_raw: Add support for command extention
This adds support for registering a command extention table which is
used to match incoming commands and then pass the buffer to its
function handler.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz b3ee8be80d Bluetooth: hci_raw: Add support for using H:4 transport
This adds 2 config options which enables hci_raw to work in
H:4 mode and enable it by default automatically.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz 8a358523e7 USB: Bluetooth: Remove assert for NULL buffer
Buffer are allocated with K_FOREVER should never fail, in addition to
that asserts needs to be enabled and is not worth converting to runtime
check given the use of K_FOREVER.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz 7177f998f7 USB: Bluetooth: Remove BLUETOOTH_INT_EP_MPS
Allowing to configuring the MPS different then the buffer size might
actually generate data fragmentation/reassembly so this just use
BT_BUF_RX_SIZE which is set accourding to the controller buffer size.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz bef422f70f USB: Bluetooth: Remove BLUETOOTH_BULK_EP_MPS
Allowing to configuring the MPS different then the buffer size might
actually generate data fragmentation/reassembly so this just use
BT_BUF_ACL_SIZE which is set accourding to the controller buffer size.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz b4e71014f2 Bluetooth: hci_usb: Add implementation of Read/Set USB Transport Mode
This implements Read/Set USB Transport Mode in the Bluetooth class.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz f710b9be50 Bluetooth: HCI: Add helpers to create events
This adds bt_hci_evt_create and bt_hci_cmd_complete functions.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Luiz Augusto von Dentz 2534ab11c0 USB: Add driver and PID for Bluetooth H4
This adds USB_PID_BLE_HCI_H4_SAMPLE along with it driver which uses H4
over bulk endpoints.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-20 21:59:47 +03:00
Ahmed Shokry c2444b4e30 Bluetooth: host: Allow only one legacy advertising instance
When legacy advertising enable command is issues,
the BT_ADV_ADVERTISING has to be set, because this
flag is checked in many scenarios to see if the
advertising is ongoing or not.

Signed-off-by: Ahmed Shokry <ahmed.shokry@synopsys.com>
2020-04-20 15:49:58 +02:00
Joakim Andersson fda3bfcf1b Bluetooth: controller: Send command status for unknown commands
When receiving an unknown command send the unknown command response
as a command status event instead of a command complete event.
A command complete event has no status field, although by convention
all command parameters has a status field as the first parameter the
command status event seems like the more fitting option.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-20 15:45:18 +02:00
Flavio Ceolin e6204a982e net: coap: Fix possible overflow
Fix possible integer overflow when parsing a CoAP packet.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-04-20 09:12:33 +03:00
Lingao Meng 49e4f754b4 Bluetooth: Mesh: Fix add model group address to sub list
When low power node reset, should add group address to
friend subscription list.

Fixes: #24311

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-04-19 18:36:12 +03:00
Lingao Meng 2e4eab5ebc Bluetooth: Mesh: Add option for lpn auto sub all-nodes
Add option for low power node automatically subscribe
all-nodes-address to friend sub list.

Fixes: #24009

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-04-19 18:36:12 +03:00
Jukka Rissanen 7c23c47c0e net: tcp2: Avoid extra memory allocation in endpoint cmp
In tcp_endpoint_cmd() we allocate and then almost immediately
destroy the allocated endpoint. This is quite inefficient so
use a endpoint from stack in the compare.

Separate endpoint allocation from value setting so the caller
can decide how the endpoint union values are set.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-19 11:10:37 +03:00
Robert Lubos 16d8a8359c net: lwm2m: Fix Cell ID resource initialization
Cell ID resource was not initialized properly in the Connectivity
Monitoring object, making it unusable from the application.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-18 16:27:56 +03:00
Johann Fischer 2c9ae5f881 usb: transfer: fix too high log level
Lower log level in a debug message.

Fixes: #22502

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-04-17 13:34:40 -05:00
Joakim Andersson 69d91f0a9d Bluetooth: shell: Give NULL pointer when ad_len or sd_len is zero
Give NULL pointer when ad_len or sd_len is zero, this stops the host
from setting a zero length advertise data or scan response.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-17 15:28:03 +02:00
Joakim Andersson 8b5d91e659 Bluetooth: shell: Fix advertise command parameters
Fix the advertise command not setting the peer address parameter to
NULL, this could turn it into a directed advertiser.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-17 15:28:03 +02:00
Ravi kumar Veeramally 08e65e8684 net: tcp2: Rename SRC, DST enums
Some other part of Zephyr has similar defines (SRC)
causing build failures.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-17 14:49:18 +03:00
Ravi kumar Veeramally c655624f8a net: tcp2: Fix format specifier
len is ssize_t variable type, %zd should be there.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-17 14:49:18 +03:00
Krzysztof Chruscinski 450c6b44f9 shell: Add shell_set_root_cmd function
New function allows to set from the code the root command. It is
an equivalent of calling 'select <rootcmd>' except it sets command
for all shell instances.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-04-17 11:34:01 +02:00
Oleg Zhurakivskyy b6372ea406 net: tcp2: Fix the IPv4 endpoint assignment in net_tcp_connect()
Assigning the allocated IPv4 endpoint as struct sockaddr
leads to the memory overwrite, assign the correct structure,
i.e. struct sockaddr_in.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-17 12:30:22 +03:00
Mikkel Jakobsen 7288f51519 mgmt: smp: add UDP transport for SMP
Adds a UDP driver dedicated to transporting mcumgr SMP requests and
responses.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2020-04-17 10:16:25 +03:00
Lukasz Maciejonczyk 3ba7a3c82a net: l2: openthread: Add config option to enable OpenThread CoAP api
There was no way to use Openthread CoAP api in zephyr application so
far. These changes enable the feature. Now you can fully use CoAP
communication in an application working in Thread network.

Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
2020-04-17 09:21:41 +03:00
Robert Lubos a9eda4f622 net: openthread: Set proper FPB matching mode
Set FPB handling mode to Thread in OpenThread radio platform driver.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-17 09:17:38 +03:00
Robert Lubos 6afdd613d1 net: openthread: Set information about ACK FPB on receive
Set information about Frame Pending Bit from the ACK response in the
frame passed to OpenThread.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-17 09:17:38 +03:00
Oleg Zhurakivskyy 4fbf3c3672 net: tcp2: On active connection close go to FIN_WAIT_1
In order to implement active connection close with the
TIME_WAIT state, send FIN and enter FIN_WAIT_1 state.

We actually send FIN+ACK as most of the implementations do.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-16 11:10:36 +03:00
Oleg Zhurakivskyy 40799bc986 net: tcp2: Implement FIN_WAIT_1 state
On active close, wait for FIN+ACK and subsequently
enter TIME_WAIT state.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-16 11:10:36 +03:00
Oleg Zhurakivskyy 52fca0a8d2 net: tcp2: Add a TIME_WAIT timer and state
In order to support TIME_WAIT state during the TCP connection
termination, add a TIME_WAIT timer and the corresponding state.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-16 11:10:36 +03:00
Oleg Zhurakivskyy f95ceec35b net: tcp2: Remove extra flags reset in TCP_CLOSED
After the check for unconsumed flags was removed,
this is no longer needed.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-16 11:10:36 +03:00
Oleg Zhurakivskyy 3dc72dffb0 net: tcp2: Readability rename of TCP_FIN_WAIT states
In order to improve readability, rename TCP_FIN_WAIT
states into TCP_FIN_WAIT_1, TCP_FIN_WAIT_2.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-16 11:10:36 +03:00
Jeanina Dragusin 40ee38a945 bluetooth: controller: enable privacy for RV32M1
This patch adds the selection of the necessary CONFIG_*
options for allowing the use of privacy on VEGA platform

Signed-off-by: Jeanina Dragusin <ancajeanina.dragusin@nxp.com>
2020-04-15 13:43:00 -05:00
Jeanina Dragusin 6099e0f928 bluetooth: controller: openisa/RV32M1: add RPA support
The radio on the VEGA platform will now be able to resolve Resolvable
Private Addresses through the use of the CAUv3 hardware. With this
patch the RPA feature is now fully supported on the Controller:
RPA addresses are generated with local IRK and resolved with
previously exchanged peer IRK.

Signed-off-by: Jeanina Dragusin <ancajeanina.dragusin@nxp.com>
2020-04-15 13:43:00 -05:00
Luiz Augusto von Dentz 8863b72b05 Bluetooth: ATT: Fix passing wrong pointer when disconnecting
When disconnecting att_reset is called and all requests are notified
but instead of passing req->user_data like it should it pass the req
itself which nowdays comes from a k_mem_slab, rather than being a
contiguous memory that would contain the request and its user data,
which would likely cause invalid access.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-15 11:38:41 +03:00
Joakim Andersson 962b86564e Bluetooth: shell: Add advertising directed and scan response options
Add shell options to configure an extended advertiser for directed
advertising.
Add shell options to provide arbitrary advertising data as well as
giving scan response data.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-15 10:57:38 +03:00
Joakim Andersson 18bee9178f Bluetooth: host: Add non-connectable directed advertising support
This patch introduces two major changes to the directed advertising
feature of the bluetooth host.

Deprecating the bt_conn_create_slave_le, and removing
bt_conn_le_create_slave which has never been released. This behaviour
has now been moved by to providing the peer direct address into the
advertising parameters.

Introducing directed advertising support for nonconnectable
directed extended advertising, both scannable and non-scannable.

A bug was also fixed in the the directed-adv command in the shell
when the argument "low" was given. The advertiseng parameter pointer
declared with BT_LE_ADV_CONN_DIR_LOW_DUTY was declared in a scope that
was no longer valid when it was used to start the advertiser.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-15 10:57:38 +03:00
Trond Einar Snekvik 7c5c4da63a Bluetooth: Mesh: PB-GATT common link closed
Makes a common link_closed function for PB-GATT, getting rid of a bug
where cb_data is reset before the link closed callback. Also ensures
that the link close and reset order is the same in both scenarios.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-14 11:27:23 +03:00
Kumar Gala 43a7d26603 drivers: entropy: replace CONFIG_ENTROPY_NAME with DT macro
Replace CONFIG_ENTROPY_NAME with DT_CHOSEN_ZEPHYR_ENTROPY_LABEL.  We now
set zephyr,entropy in the chosen node of the device tree to the entropy
device.

This allows us to remove CONFIG_ENTROPY_NAME from dts_fixup.h.  Also
remove any other stale ENTROPY related defines in dts_fixup.h files.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-13 09:14:21 -05:00
Carles Cufi ba3b1e06b7 usb: Stop reversing the hardware identifier
Now that the hardware identifier obtained with the hwinfo API is stored
in the correct order based on the platform, there is no longer the need
to reverse its bytes when populating the serial number in the
corresponding USB descriptor.

Fixes #24103

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-04-10 10:59:04 +02:00
Robert Lubos 073ec8d4aa net: mqtt: Refactor because of timeout overhaul
Align MQTT with timeout API changes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-09 21:58:42 +03:00
Carles Cufi 76c3a8d964 Bluetooth: controller: Fix Peer Address Type in Conn Complete
The LE Connection Complete HCI event, unlike its Enhanced counterpart,
only uses 0x0 and 0x1 for Peer Address Type. Fix it so that it reflects
the specification correctly.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-04-09 17:18:58 +02:00
Robert Lubos 7820d99274 net: openthread: Fill mTimestamp field in OT frame
Fill the mTimestamp filed in OpenThread frame based on the net_pkt
timestamp value (only if NET_PKT_TIMESTAMP is enabled).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-09 16:56:11 +02:00