Commit graph

21541 commits

Author SHA1 Message Date
Andrew Boie
ed7263bf6b bluetooth: add dep on !SMP
The BT code uses co-op thread priorities to implement some
critical sections. This won't work with SMP turned on.
Express this in our configuration ontology, so that it's
not possible for the end user to set up the system in this
way and get crashes or odd behavior.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-10-05 19:33:02 -07:00
Simon Glass
442f38d610 emul: Add an emulator for the Bosch BMI160 accelerometer
This emulator supports enable functionality to start up the device and
read a few samples. It connects itself to any BMI160 device it finds in
the device tree. The SPI emulation controller driver is used to direct
SPI messages from the BMI160 driver to the BMI160 emulator.

Add a few more definitions to the header file, as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass
4d77edd6ba emul: Add messages in emul_init_for_bus_from_list
Add a log message to indicate that a new emulator is attached. Also add
a message in the assert to make it clearer what has gone wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Robert Lubos
12e1fd653d net: lwm2m: Fix FOTA block transfer with opaque content-format
This commit fixes PUSH FOTA when opaque content-format is used.

This consists of the following fixes:
 * Moved `struct block_context` to a private header, so that it can be a
   part of `struct lwm2m_input_context`. This allows content decoders to
   make use of the block context data.
 * Removed faulty `get_length_left` function from the plain text
   decoder, and replace it with coap_packet_get_payload() to obtain the
   actual payload size.
 * Introduce `struct lwm2m_opaque_context` as a part of block context,
   which allows to keep track of opaque data download progress.
 * Simplify `lwm2m_write_handler_opaque()` function. It will now only
   make calls to `engine_get_opaque` - it's the decoder responsibility
   to update the opaque context according to it's content format (for
   instance TLV decoder should only update it with the actual opaque
   data size, not the whole TLV).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-10-05 12:16:57 +02:00
Jordan Montgomery
ec9080a036 Bluetooth: controller: Fix Null deref during adv data update
Added a check for adv->lll.aux before starting extended advertising to
fix observed NULL pointer dereference when updating AD data of legacy
advertising.

Fixes #28544.

Signed-off-by: Jordan Montgomery <montytyper@msn.com>
2020-10-05 11:47:30 +02:00
Jukka Rissanen
d4347b4015 net: dhcpv4: Generate start/bound/stop mgmt events
The L4 connected/disconnected events are usually used to detect
when the application is connected to the network. Unfortunately
if the device has also a static address, then the connected event
might be created (for the static address) even if DHCPv4 is not
ready yet and application would not be able to connect (yet) to the
network. In order to allow the application to fine tune the network
connection creation, generate start, bound and stop events for DHCPv4.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-03 17:15:15 +03:00
Håkon Øye Amundsen
780fa73b83 settings_fcb: initialize rc variable
Avoid warning about uninitialized variable.
The for loop should do at least two iterations
in a valid execution, hence initialize to an
error value.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-10-02 12:07:06 -04:00
Ievgenii Meshcheriakov
cf523e449e drivers: flash: Pass bool to flash_write_protection_set()
The second argument of this foonction is a bool, so passing 0 and 1
is incorrect.

Coccinelle script:

    @@
    expression e;
    @@
    flash_write_protection_set(e,
    (
    - 0
    + false
    |
    - 1
    + true
    )
     )

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-10-02 12:06:28 -04:00
Jakub Rzeszutko
f43985e334 shell: enhance help command
To get a list of all supported shell commands user must hit the TAB
button. It may be awkward on some terminal emulators. This change
enhances the help command in a way it will in addition print all
supported commands.

Fixes: #28785

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-10-02 12:05:49 -04:00
Jakub Rzeszutko
137b7ec5bd shell: help functions update
Functions shell_help_subcmd_print and shell_help_cmd_print
are more generic. Now they can operate on command passed as an
argument not hard coded active_cmd.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-10-02 12:05:49 -04:00
Jakub Rzeszutko
0cf6670b70 shell: improve function shell_cmd_get
The function can return existing root command even if dloc argument
is a NULL pointer.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-10-02 12:05:49 -04:00
Jukka Rissanen
db889774c2 net: tc: Remove not used field from net_traffic_class struct
The "tc" field which was holding the traffic class thread
priority is not used nor needed so remove it from the struct
to save some space.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-02 13:20:17 +03:00
Emil Gydesen
8cc051ccac Bluetooth: host: Change PA sync callbacks to global callbacks
Changes the callbacks for periodic sync callbacks such that multiple
applications can register callbacks, similar to the connection and
scan callbacks.

This change will make it easier to support the PAST feature, as
PA syncs make be created by the controller which then notifies
the host, and thus the application (if callback registered).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-02 11:49:13 +02:00
Xavier Chapron
824f423e54 misc: Replace assert include and calls by sys/__assert.h equivalent
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-10-02 11:42:40 +02:00
YanBiao Hao
dc89bfcc7f Bluetooth: Mesh: Config Client network transmit set/get API
Get/Set network transmit parameter of a node.

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2020-10-02 11:30:12 +02:00
Flavio Ceolin
b8b42c6d18 random: Warning when using test config
Generates a warning message when building with
CONFIG_TEST_RANDOM_GENERATOR. The purpose is inform that this is not
secure and should not used in production.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-10-02 11:30:03 +02:00
Aastha Grover
83b9f69755 code-guideline: Fixing code violation 10.4 Rule
Both operands of an operator in the arithmetic conversions
performed shall have the same essential type category.

Changes are related to converting the integer constants to the
unsigned integer constants

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2020-10-01 17:13:29 -04:00
Emil Gydesen
0be8a91a73 Bluetooth: host: Add NULL checks for scan callbacks
The scan callbacks may be NULL, which would cause an error if
e.g. the timeout callback wasn't set and the scan terminates after
a timeout.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-01 13:57:53 -04:00
Jan Pohanka
91adf41dd4 net: sockets: tls: fix using of zsock_ functions
Use zsock_ variants of socket functions to be independent on
NET_SOCKETS_POSIX_NAMES config.

Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
2020-10-01 17:35:45 +03:00
Jan Pohanka
fff28ad8ae net: mqtt: use zsock_ functions
Using zephyr's internals zsock_ calls make mqtt library more compatible,
now it does not depend on NET_SOCKETS_POSIX_NAMES.

Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
2020-10-01 17:35:45 +03:00
Lingao Meng
f16c653be9 Bluetooth: Mesh: Move Replay Protect to seperate module
Move RPL to seperate module, and remove it in `bt_mesh`
structure.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-01 16:20:24 +03:00
Kumar Gala
9c45673d8e net: sntp: Remove deprecated API function
Remove sntp_request as its been marked deprecated since at least Zephyr
2.3 release.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-01 07:14:08 -05:00
Kumar Gala
55be783c85 settings: Remove deprecated SETTINGS_USE_BASE64 support
Remove code and associated tests and Kconfig related to
SETTINGS_USE_BASE64 that was deprecated in Zephyr 2.2

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-01 07:05:27 -05:00
Jukka Rissanen
8bb83454b4 net: tcp2: Do not assert when cancelling send timer
No real need to assert when the send timer is cancelled. Just
check if there is re-transmission going on and do nothing if
there is not.

Fixes #28758

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-01 14:19:07 +03:00
Jukka Rissanen
cace577d68 net: tcp2: Local accepted socket was not bound
The local and accepted socket was not bound which caused the
local address to be set as NULL. This then caused issues when
zsock_getsockname() was called by the application.

Fixes #28735

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-10-01 14:19:07 +03:00
Vinayak Kariappa Chettimada
8f203e46ca Bluetooth: shell: Fix PER SYNC conditional compilation
Fix conditional compilation to allow building test shell
with Periodic Advertising Sync alone.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-01 12:54:06 +02:00
Vinayak Kariappa Chettimada
416d7ee32a Bluetooth: controller: Fix latency cancel on LLCP initiation
Fix controller implementation to cancel peripheral latency
when initiating new control procedures.

Fixes #28699.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-01 12:53:53 +02:00
Vinayak Kariappa Chettimada
b6fb074d6e Bluetooth: controller: Connection termination race condition
Add checks to abort connection radio event preparation and
start, if the connection terminates with a race condition
with new radio event being prepared or being in prepare
pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-01 11:47:35 +02:00
Vinayak Kariappa Chettimada
3e2dc0d706 Bluetooth: controller: Add branch prediction hints
Add branch prediction hints in critical control paths in the
code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-01 11:47:35 +02:00
Vinayak Kariappa Chettimada
d64bbd5a06 Bluetooth: controller: Add missing debug pin toggle
Add missing debug pin toggle on abort of connection event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-01 11:47:35 +02:00
Christian Taedcke
fd6596d53b net: mgmt: Add const to info param of notify function
Since the info parameter is only read from and never written the const
in the function parameter should be present.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2020-09-30 14:40:50 +03:00
Vinayak Kariappa Chettimada
48a0c0c3a8 Bluetooth: controller: Fix undeclared identifier
Fix undeclared CONFIG_BT_CTLR_DATA_LENGTH_MAX when Force
MD bit automatic feature is enabled in nRF51 Series.

Fixes #28774.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-30 06:38:19 -05:00
Rafał Kuźnia
5b7efd3277 net: openthread: add kconfigs to change values in zephyr port
This commit adds additional Kconfigs that allow for changing
configuration values for the Zephyr port in OpenThread.

Those values are:
- number of the internal OT message buffers
- number of the state change callbacks
- number of the EID-to-RLOC cache entries
- size of the NCP buffer

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2020-09-30 14:38:04 +03:00
Jukka Rissanen
ccea4d3258 net: ethernet: Check IPv4 multicast pkt using util function
Instead of directly checking the multicast IPv4 address, use
the net_ipv4_is_addr_mcast() utility function.

Fixes #26584

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-30 14:31:13 +03:00
Marcin Niestroj
9a791dd6bb net: mqtt: Reset client state before notifying MQTT_EVT_DISCONNECT
MQTT client state is protected using mutex. That mutex however is
temporarily unlocked when calling event callbacks. This means that in
client_disconnect() transport can already be disconnected, but without
marking it as such in client->internal.state.

When mutex is unlocked in event_notify() function, then there are two
possible paths of failure:

1) First possibility is when RX and TX are called from two separate
   threads, so that the other thread gets resumed and functions like
   verify_tx_state() (e.g. in mqtt_publish()) allow to continue
   communication over disconnected medium.
2) Another possibility is that user calls mqtt_abort() or
   mqtt_disconnect() in event handler.

In both cases MQTT library tries to send or receive data, possibly
followed by second close() of underlying file descriptor.

Prevent using disconnected transport by clearing MQTT client state right
after calling mqtt_transport_disconnect(), without releasing mutex, even
for a while.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-09-30 14:30:43 +03:00
Torsten Rasmussen
5fd53dcd8a net: tcp2: added struct const to *net_context_state()
When compiling with CONFIG_NET_NATIVE=n and CONFIG_NET_OFFLOAD=n
then the following error is printed.

```
In file included from zephyr/subsys/net/ip/ net_if.c:23:0:
zephyr/subsys/net/ip/net_private.h: In function 'net_context_state':
zephyr/subsys/net/ip/net_private.h:58:27:
error: type of 'context' defaults to 'int' [-Werror=implicit-int]
 static inline const char *net_context_state(context)
```

This add `struct net_context *` as type for context.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-30 14:29:44 +03:00
Emil Obalski
5f6d526459 usb: bluetooth: Incrase data stage buffer for setup transfers.
Depending on the Bluetooth features enabled, the HCI
packets can be 264 Bytes long. For HCI over USB the HCI packet
is handled in data stage of USB transfer. Buffer for the data
stage was too short and USB driver was STALLing the data stage
making it unable to complete. Extend the data stage buffer
to 266 Bytes if HCI USB is selected and BT_RX_BUF_LEN > 127
indicating that longer HCI packets are needed.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-09-29 14:51:14 +02:00
Jakub Rzeszutko
005103739c shell: examples cleanup
Remove obsolete include of the shell_uart.h file.
It is sufficient to include the shell.h file.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-09-29 10:48:47 +02:00
Aurelien Jarno
1df2de346b net: openthread: Remove old flash code
Since commit b3a1ede830 OpenThread uses the Zepyhr settings submodule
instead of writing to the flash directly. The flash.c file is not
compiled anymore, so let's just remove it. Also remove the
OT_PLAT_FLASH_PAGES_COUNT Kconfig option which was solely used by that
file.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2020-09-28 14:17:22 -05:00
Vinayak Kariappa Chettimada
e4fe7435d7 Bluetooth: controller: Added Force MD bit automatic feature
Added automatic runtime calculation of Forced MD bit count
based on incoming Tx buffer throughput.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
3bbe2c0a07 Bluetooth: controller: Add in-system Tx throughput measurement
Added feature to in-system measure incoming Tx throughput.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
cf05f49ee2 Bluetooth: controller: Refactor Force MD bit implementation
Add Force MD bit feature wherein connection events can be
extended to match the rate at which applications provide
new Tx data. MD bit in Tx PDUs is forced on if there has
been CONFIG_BT_CTLR_TX_BUFFERS count number times Tx/Rx
happened in a connection event. The assumption here is,
if controller's tx buffers are full, it is probable that
the application would send more Tx data during the
connection event, and keeping the connection event alive
will help improve overall throughput.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
1fcb0d0b5e Bluetooth: controller: Add force MD bit feature
Add force Md bit feature wherein connection events can be
extended to match the rate at which applications provide
new Tx data.

Fixes #27981.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
62f1ad79bb Bluetooth: controller: Fix connection event close check
Fix the check that decides to close a connection event,
which was missing a check on MD bit being set for empty PDU
to be Tx-ed out.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
45593ff508 Bluetooth: controller: Optimise Tx PDU preparation
Optimize the Tx PDU preparation, empty PDU only needs MD bit
to be modified, other fields be initialised only at power up.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
6b1cfdda33 Bluetooth: controller: Fix premature connection event close
Fix premature connection event close due to the new Tx
buffers not being de-multiplexed and routed to connection's
Lower Link Layer context when they arrive while being
inside the connection's radio event.

Also, fix master prepare to demux and enqueue two Tx buffers
so that MD bit can be set correctly.

Relates to #27981.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
0096fca39d Bluetooth: controller: Refactor ull_conn_tx_ack function
Refactor ull_conn_tx_ack function as it no longer needs to
return the connection context back to caller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
35c0b77304 Bluetooth: controller: Add interface to get ULL ref count
Add a static inline interface to get ULL context reference
count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
41017478b1 Bluetooth: controller: Move tx_ull_dequeue to static functions
Move tx_ull_dequeue function to be placed alongwith other
static function definitions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00
Vinayak Kariappa Chettimada
2dc174fb10 Bluetooth: controller: Minor relocation of lll_conn_flush function
Minor relocation of lll_conn_flush function to place alongwith
non-static functions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-28 15:23:21 +02:00