Commit graph

21541 commits

Author SHA1 Message Date
Lingao Meng
0bcd66ac36 Bluetooth: Mesh: Fix build warning with Warray-bounds
../zephyrNew/subsys/bluetooth/mesh/prov.c: In function
'bt_mesh_prov_reset_state': ../zephyrNew/subsys/bluetooth/mesh
/prov.c:61:2⚠️ '__builtin_memset' offset [52, 292] from
the object at 'bt_mesh_prov_link' is out of the bounds of referenced
subobject 'dhkey' with type 'uint8_t[32]' {aka 'unsigned char[32]'}
at offset 19 [-Warray-bounds] 61 | memset(&bt_mesh_prov_link.dhkey, 0,

Fixes: #29634

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-30 10:59:55 +02:00
Luiz Augusto von Dentz
09e95a26a4 Bluetooth: ISO: Fix crash when channel has already been disconnected
If chan->conn is already NULL do not call bt_conn_unref as that will
likely cause a crash, also this make sure that if channel has been
disconnected using bt_iso_chan_disconnect it removes the channel from
connection list before setting the chan->conn to NULL.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-10-29 20:34:55 +02:00
Joakim Andersson
92deb9ddba Bluetooth: host: Document and check for disallowed directed advertising
Document and validate advertising parameters for the disallowed
advertising mode high duty cycle directed connectable advertising
using extended advertising PDUs.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-29 16:02:57 +02:00
Vinayak Kariappa Chettimada
f8889c1d87 Bluetooth: controller: Fix unused variable compiler warning
Fix unused variable compiler warning with asserts disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-29 14:31:38 +02:00
Joakim Andersson
5e999a3081 Bluetooth: ATT: Handle encrypt change event unrelated to current req
Fix issue where the encrypt change has an error code, but the
encrypt change request was unrelated to the current ATT request.

This lead to the current ATT transaction being interpreted as finished
an the ATT client would proceed with the next ATT request, which would
fail since the ATT client is now violating the ATT single transaction
rule.

Updated similar if statement checking for the opposite to improve
readability.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-29 14:28:40 +02:00
Lingao Meng
627ee1125b Bluetooth: Mesh: Remove bt_mesh_net_start
Move `bt_mesh_net_start` functionality to `bt_mesh_start`.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-29 14:17:09 +02:00
Trond Einar Snekvik
af5bd00d1c Bluetooth: Mesh: Move labels to transport
Moves the virtual address labels to the transport layer, disconnecting
them from the configuration server.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-10-29 14:14:43 +02:00
YanBiao Hao
c9be68532c Bluetooth: Mesh: Add Config Client API
The api is used to reset a node (other than a Provisioner) and
remove it from the network

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2020-10-29 14:13:36 +02:00
Lingao Meng
1e9bd13c99 Bluetooth: Mesh: Fixes Relay to frnd_cred message
If low power node publish with unicast address other
than friend address, the friend node should relayed
this message to all network interface.

When Proxy feature enabled, message from gatt bearer should
relay to adv bearer even relay feature disabled.

Fixes: #29544

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-29 14:07:58 +02:00
Anas Nashif
8873ade781 logging: mipi-sys-t: move platform.h to main tree
Move the platform.h from the module to the zephyr tree. This file is
zephyr sepcific and belongs in the zephyr tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-10-29 07:23:40 -04:00
Erwan Gouriou
b9a4e9b3b7 subsys/disk: stm32 sdmmc: Add support for device tree pinctrl
Add required code to support pinctrl setup base don device tree.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-29 09:21:27 +01:00
Ehud Naim
c58c8b1257 net: buf: change avail_count variable to atomic type
using CONFIG_NET_BUF_POOL_USAGE monitor avail_count,
this variable should be protect.
Protecting it by using atomic variable

Signed-off-by: Ehud Naim <ehudn@marvell.com>
2020-10-28 18:45:11 +02:00
Lingao Meng
5374245dd6 Bluetooth: Mesh: split prov.c into two separate modules
Currently all provisioning procedure into common source
files call `prov.c`, that will not compile separately.

Add `BT_MESH_NODE` to control whether nodes are supported
and device provisioning is supported, this will be used in
provisioner role.

Add more provisioner OOB authentication method.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-28 12:53:09 +02:00
Simon Glass
20116f0fdf emul: spi: bmi160: Add support for I2C
At present this emulator only supports SPI. Add support for I2C as
well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass
f4ef4daa8a emul: spi: bmi160: Prepare to support I2C
At present this driver only supports SPI. Refactor it so that SPI is
just one of the options. This does not change any functionality.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass
fa90b5c243 emul: spi: bmi160: Move to top-level directory
This emulator currently only supports SPI. Before making it also
support I2C, move it up a directory to avoid I2C uses missing it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass
e43c181934 emul: spi: emul_bmi160: Move logging to access functions
Move the logging for transactions to the functions that actually access
registers and sample data. This avoids needed to repeat this code when
I2C starts calling these functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass
c953c32cbd emul: spi: emul_bmi160: Rename 'spi' to 'bus'
Update the language to refer to a bus instead of SPI. This will make it
more applicable with I2C support is added.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Viktor Sjölind
1b3abc096c net: lwm2m: Start notify sequence numbers on 0
Some LWM2M backends/servers, such as emxq, expect the sequence numbers
to begin on 0.

This change is in line with how other lwm2m clients, such as Anjay and
Wakama, starts the notification sequence.

Signed-off-by: Viktor Sjölind <viktor.sjolind@endian.se>
2020-10-27 11:25:22 +02:00
Vinayak Kariappa Chettimada
b3c9565891 Bluetooth: controller: Remove redundant condition compile
Remove a redundant condition compile.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-26 17:40:08 +01:00
Vinayak Kariappa Chettimada
c74438cdfa Bluetooth: controller: Fix arguments unused without Extended Scanning
Fix arguments unused when not enabling Extended Scanning
which was introduced in
commit 0cef1e43c9 ("Bluetooth: controller: Extended
Scanning Coded PHY duration and period").

Fixes #29442.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-26 17:40:08 +01:00
Jukka Rissanen
a1b0a98fbf net: context: Add locking to IPv6, CAN and packet socket bind
The commit 93e5181f ("net: context: Add locking for concurrent
access") added net_context locking to only IPv4 sockets.
That is not enough and we need locking also to other supported
socket address families like IPv6, SocketCAN and packet socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-26 11:03:03 -05:00
Joakim Andersson
999a91e30d Bluetooth: host: Fix application conn param update not started
Fix application conn param update submitted before the timeout of
CONFIG_BT_CONN_PARAM_UPDATE has expired being ignored when
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-26 16:16:35 +02:00
Joakim Andersson
21b8e08caa Bluetooth: host: Rename update_work to deferred_work
Rename the update_work handler to deferred_work since this handler
is being multiplexed for different kinds of deferred work, not just
updating the connection parameters.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-26 16:16:35 +02:00
Joakim Andersson
77b11d6b0c Bluetooth: host: Move auto-initiation of peripheral conn param update
Move auto-initiation of the peripheral connection parameter update,
this handling would only submit the delayed work with the timeout once
all other auto initiated procedures had completed. This behavior means
that the delay would not be set on when the connection was established
but instead relative to the previous procedures.
Based on the connection interval used, the instant(s) used, and the
number of auto procedures this delay becomes indeterminate.

Submit the work once connected, the constraint that existed in the
zephyr link layer earlier about requesting only one control procedure
at a time has been removed.

This also brings all the handling of the timeout work to the connection
state handling, which makes it easier to track this behavior in code.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-26 16:16:35 +02:00
Joakim Andersson
f4888b1ff6 Bluetooth: host: Allow conn param update delay of 0 milliseconds
Allow the application to set a conn param update delay of
0 milliseconds.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-26 16:16:35 +02:00
Joakim Andersson
f2a23ee166 Bluetooth: host: Document peripheral bt_conn_le_conn_update behavior
Document the behavior of the bt_conn_le_conn_update API when the
local device is the peripheral role.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-26 16:16:35 +02:00
Benjamin Lindqvist
660ad9791b net: lwm2m: Pack TLV integers more efficiently
Prior to this commit, the LwM2M stack would TLV-encode integers
depending on their internal storage size. An integer with value 5 stored
in an int8_t would be encoded with length 1, but an integer stored in an
int32_t would be encoded as "00 00 00 05" with length 4.

This commit checks if the value is castable to a smaller int and encodes
it as such if so. This is cascading, so even a 64 bit integer with value
5 will be encoded with length 1.

Note that this does not seem to be required by the specification, but
this is how Anjay and the other LwM2M stack seem to do it.

Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
2020-10-26 11:31:28 +02:00
Lingao Meng
27739fcc43 Bluetooth: Mesh: Add queue_size and recv_win to lpn_cb
Add Queue Size and Receive Window information to lpn
callback function to notify upper layer to determine
currently friend node information, which may be used
in future.

Add Callback structure to notification application which friendship
has been changed.

Add function `bt_mesh_friend_terminate` let's app layer determine
terminate friendship manually.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-24 10:57:45 +03:00
Joakim Andersson
948615d247 Bluetooth: shell: Fix ifdef order in command inclusion
Fix ifdef in command inclusion, in practice this meant that
CONFIG_BT_LL_SW_SPLIT and CONFIG_BT_CTLR_ADV_EXT switched meaning.
Added blank lines so that the commands in shell/ll.c are more
easily visible as group.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-23 12:56:39 +02:00
Vinayak Kariappa Chettimada
28d6028127 Bluetooth: controller: Periodic Adv Sync on Coded PHY
Added implementation to be able to establish Periodic
Advertising Sync on Coded PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-23 12:56:13 +02:00
Dominik Ermel
1241e67790 fs: Move fs_file_system_t declaration out of fs.h
The struct fs_file_system_t is only useful when defining file system
drivers and is not required for typical application development,
that is why it has been moved to separate file fs_sys.h.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-10-23 12:55:41 +02:00
Jukka Rissanen
899228bb7f net: icmpv6: Store ll addresses to pkt when sending error msg
When we are sending ICMPv6 error message, we need to store the
link local addresses of the received packet somewhere in order
to know where to send the new error message.
Easiest is to store the ll addresses is to the error message
itself, just before where the sent packet will start in memory.
We cannot use the original pkt to store the ll addresses
as that packet might get overwritten if we receive lot of packets.

Fixes #29398

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-23 09:29:27 +03:00
Joakim Andersson
d62aefe608 Bluetooth: Kconfig: Default BT_TINYCRYPT_ECC only when not supported
Introduce a support kconfig for controller ECDH command support.
Default to host ECDH emulation in combined host controller build
where the controller does not support these commands.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-22 16:12:26 +03:00
Trond Einar Snekvik
eca0141152 Bluetooth: Mesh: Isolate cryptographic material
This is a major refactoring of the handling of the cryptographic
material of both the network and transport layers. The aim is to
encapsulate the key object manipulation, and improve overall modularity.

Pulls Applications and Subnets out of the bt_mesh and into separate
modules, with static storage types on the data. This has several
side-effects:
- The Config Server no longer operates directly on the bt_mesh.subs and
  bt_mesh.apps lists, but goes through a public configuration interface,
  following the pattern set in #27908.
- All iteration through the keys is done through iteration APIs
- Key resolution on RX and TX is centralized.
- Changes to the keys triggers events the other modules can register
  handlers for.
- Friendship credentials are stored in the lpn and friend structures.

Part of #27842.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-10-22 14:36:02 +03:00
Luiz Augusto von Dentz
2811f0abf7 Bluetooth: shell: Allow passing more than one byte to gatt write
This makes it possible to pass different byte arrays to gatt write
making it usable to test attributes that take more than a single byte.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-22 13:33:57 +02:00
Luiz Augusto von Dentz
b4dceec686 Bluetooth: GATT: Don't start any work until the stack is initilized
This prevents any work to be submitted until the stack is initialized
thus avoiding pointless hash generation, etc, while initializing the
system.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-10-22 14:33:30 +03:00
Emil Gydesen
44f00358a6 Bluetooth: host: PA sync receive enable/disable
Adds support for enabling/disabling PA sync receive,
which allows applications to control when to receive data
while a sync is established.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-22 13:28:41 +02:00
Luiz Augusto von Dentz
6c67d3cb4b Bluetooth: conn: Fix not cleanup properly if ACL is disconnected
If an ACL connection is disconnected while there is an ISO connection
associated with it the ACL connection will not be cleanup properly as
the code attempt to cleanup the ISO connection and breaks without
proceeding to cleanup the ACL as well.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-10-22 14:26:55 +03:00
Emil Gydesen
c29f62e2b8 Bluetooth: host: Removed cb pointer from bt_le_per_adv_sync
The callbacks has been moved from being local to each
bt_le_per_adv_sync object, to being global. The
removal of the pointer in bt_le_per_adv_sync was
missing from that update.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-22 13:23:01 +02:00
Joakim Andersson
b2e56412a7 Bluetooth: shell: Fix shell build with out-of-tree controller
Fix shell build errors when building with combined host and controller
but the selected controller is not the in-tree zephyr controller, i.e
CONFIG_BT_CTLR=y, CONFIG_BT_LL_SW_SPLIT=n and cmd_scanx and others
are not defined.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-22 13:18:35 +02:00
Lingao Meng
4acfd5f6af Bluetooth: Mesh: Change the default value to Kconfig
Move default value of segment retransmit and timeout value
to Kconfig.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-22 14:13:49 +03:00
Lukasz Maciejonczyk
06fdea7ec8 net: config: Fix improper condition in net_config_init
Currently, there is a case for net_config_init function that for
timeout==0 and when iface is already up, the ip setup is not proceed
and the error message "Timeout while waiting network..." is logged.

This commit fixes it.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-10-22 12:33:12 +03:00
Emil Hammarstrom
ec00feef35 net: lib: sockets: added ALPN extension option to TLS
Adds the socket option TLS_ALPN_LIST for SOL_TLS sockets

Passes the configured alpn list to the mbedtls config
on mbedtls init

Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
2020-10-22 11:35:43 +03:00
Jukka Rissanen
0f9ec427bc net: tcp2: Lock conn when sending data from work queue
If we are sending data directly, we already have TCP lock so
there is no need to do any locking. But when data is re-sent,
the work queue handler is doing the sending so we need to lock
the TCP connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-21 12:57:23 -05:00
Jukka Rissanen
735fcc63bf net: tcp2: Pass data to application without any TCP locks
When receiving data that needs to be passed the data to application,
queue it for short time so that we do not have TCP connection lock
held. This way if the application wants to send data, there is no
possibility that the connection lock would prevent sending data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-21 12:57:23 -05:00
Jukka Rissanen
6003c988e1 net: context: Release lock before passing RX data to socket
Release the context lock before passing data to the application
socket as that might cause deadlock if the application is run
before the RX thread and it starts to send data and if the RX
thread is never able to run (because of priorities etc).

Fixes #29347

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-21 12:57:23 -05:00
Siddharth Chandrasekaran
4640bafca6 mgmt/osdp: Fix early check of no-data that holds PD online
When waiting for data from CP, the data timeout check must happen before
no-data check. If not, a partial packet may endlessly hold PD in
"wait-for-data" state, while the PD keeps reporting status as online
till another packet is received.

Fix this my moving no-data check below the timeout check.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
8d012aace9 mgmt/osdp: CP: Reset channel before sending a command
Flush channel of any existing partial packets before sending a new
command.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
23c0c77049 mgmt/osdp: Skip all incoming bytes till start of new packet
All OSDP packets must start with a mark byte (0xFF) followed by a Start
of Message byte (0x53). Skip all bytes received until such a sequence is
seen to to avoid waking up the refresh thread needlessly.

Also, refactor osdp_uart_isr() to reduce number of local variables.

Fixes: #28168 Coverity-ID: 214218

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00