Commit graph

923 commits

Author SHA1 Message Date
Joakim Andersson 88a6234ff2 Bluetooth: host: Use bluetooth defines instead of hci defines
Use the scan types defined in bluetooth.h instead of the hci defined
ones. Although they have the same value it is best to avoid using the
hci.h header in applications.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson f2d7b77e96 Bluetooth: host: Deprecate BT_LE_ADV defines in hci.h in favour of gap.h
Deprecate BT_LE_ADV defines in hci.h that are expected to be used by the
application in the scan received callback to identify the advertising
PDU type. These defines are mixing HCI input parameters and advertising
PDU types. Internally it is acceptable to mix these, but at the API we
should to mix in them.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson be57dfbe2a Bluetooth: host: Rename and deprecate scan filter for more scan options
Rename filter_dup parameters used for scanning filter options to the
more generic name options, and make scan filter options follow same
naming patters as advertising and initiator scan options.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson 405ce842ab Bluetooth: host: Add new argument and return code to bt_create_conn_le
Deprecate bt_create_conn_le and rename it to in order to add return
code, new arguments and to follow the established naming convention.

Add API for the application to control the scan parameters of the
initiator role. This allows the application more scheduling control
of the initiator in multi-role scenarios. Also provides options to
configure the initiator for LE Coded PHY for long range support.
We deprecate the old way of creating connection to make the name more
consistent with the rest of the API.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Andrzej Głąbek 4253eae005 boards: nrf52840_pca10056: Rename board to nrf52840dk_nrf52840
The nRF52840 DK board target, so far known as nrf52840_pca10056,
is renamed to nrf52840dk_nrf52840.
Its documentation and all references to its name in the tree are
updated accordingly. Overlay and configuration files specific to
this board are also renamed, to match the new board name.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-27 09:14:08 +01:00
Martí Bolívar 6e57b42758 doc: dts: revisit documentation
This is joint work with Kumar Gala (see signed-off-by).

Document the changes to the generated node macros in macros.bnf,
moving the old file to legacy-macros.bnf and putting it in its own
section.

The actual generated macros are now a low-level detail, so rewrite the
foregoing sections as examples in terms of the new <devicetree.h> APIs.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00
Ioannis Glaropoulos f3807f19dc boards: arm: nrf51_pca10028: rename board to nrf51dk_nrf51422
We rename the nRF51 Dev Kit board target (nrf51_pca10028)
to nrf51dk_nrf51422. We update all associated references
in the supportive documentation and all nRF51-related
cofigurations and overlay files in the samples and tests
in the tree.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-24 11:45:27 +01:00
Trond Einar Snekvik 824c2ebc58 Bluetooth: Mesh: Slab based segmentation handling
Allocates segmented message buffers as slabs in a common pool for RX and
TX. This reduces memory requirements for both TX and RX, as TX messages
can be stored without the network and advertising buffer overhead, and
RX can use only the slabs it needs, instead of allocating a full size
segmented message. This approach also removes the need for decrypting
the segments for each retransmission, reducing overall processing load.

Slab based segmentation for tx also introduces queuing of segmented
messages, which allows the application layer to send multiple messages
to the same destination without violating Bluetooth Mesh specification
v1.0.1, section 3.6.4.1. This mechanism is provided through a flag that
blocks segmented messages to a destination which a message is already
being sent to until the previous message finishes.

This changes the SDU size configuration to a symmetrical
RX_SEG_MAX/TX_SEG_MAX pair of configurations, plus a new segment pool
side configuration. It also removes the binding between the TX_SEG_MAX
config and the advertising buffers, reducing the minimum advertising
buffer count from 6 to 3.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-03-19 15:54:26 +02:00
Carles Cufi bf41dd943b doc: reference: Clean up and restructure a bit
Name all subsystem reference consistently with an '_api' postfix and
clean up naming and folder structure in some cases.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-18 11:47:24 +01:00
Joakim Andersson 5726a26dd7 Bluetooth: samples: hci_uart: Remove unneeded config options
Remove data length and phy update set to 'n' on board that does not
support these features anyway. BT_CTLR_DATA_LEN_SUPPORTED and
BT_CTLR_PHY_UPDATE_SUPPORTED are both set to 'n'.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 18:12:47 +02:00
Joakim Andersson 69a7278bad Bluetooth: samples: hci_uart: Remove unsupported configuration
Remove BT_CTLR_DTM_HCI=y config which is not supported for this board.
This produced the following warning:

warning: BT_CTLR_DTM_HCI was assigned the value
'y' but got the value 'n'. Check these unsatisfied dependencies:
BT_CTLR_DTM_HCI_SUPPORT (=n).

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 18:12:47 +02:00
Joakim Andersson 49391249ee Bluetooth: samples: hci_uart: Refactor conf files
Refactor conf files to use prj.conf + board/<board>.conf configuration.
This allows us to have put common configurations into the prj.conf and
have board specific configs in each board file.
This also respects adding additional prj.conf files such as
-DCONF_FILE='nrf5.conf debug.conf' to add debug configuration.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 18:12:47 +02:00
Joakim Andersson abafd8eb22 Bluetooth: samples: hci_uart: Update main stack size nrf5 boards
Update main stack size for nrf5 boards. This is to support an
alternative hci_driver that has a higher stack size usage in hci driver
open. Measured stack usage in this case to 808/1024.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 18:12:47 +02:00
Andrzej Głąbek ff01e2a553 samples/bluetooth/hci_spi: Add configuration for nrf51_pca10028
This sample has nrf51_pca10028 on its platform_whitelist but lacks
configuration and overlay files that would make it possible to build
this sample for that board. This commit provides such files.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-12 15:08:53 -05:00
Joakim Andersson 09b89ef585 Bluetooth: samples: Unref conn object on create connection timeout
Handle connected callback with error status not releasing the default
conn object in central samples. This can happen when the initiator fails
to create the connection within 3 seconds and is canceled by the host.

Also restart the scan role in this case.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-25 14:12:04 +02:00
Joakim Andersson ce99a5b8fc Bluetooth: samples: central_hr: Move connected callback
Move the connected callback down together with the disconnected
callback.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-25 14:12:04 +02:00
Martí Bolívar 51b885019e doc: split devicetree docs into multiple pages
The one page on devicetree is too long. Split it into multiple pages
to make it easier to digest and more squintable. This is basically
just moving content around; minimal changes have been made apart from
redoing some transitions and adding a couple of introductory paragraphs.

Rename the 'device-tree' Sphinx :ref: target while we are here.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 12:15:27 +02:00
Alex Porosanu 55eb4a11cd samples: bluetooth: add missing VEGABoard overlays
The default DTS of VEGABoard does not enable the necessary nodes
for the SW LL to function; as such an overlay is needed for
each sample that is intended to be run on the VEGABoard. Some
of the samples miss this overlay so this patch adds them.

Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-02-08 10:23:49 +02:00
Andrew Boie efc5fe07a2 kernel: overhaul unused stack measurement
The existing stack_analyze APIs had some problems:

1. Not properly namespaced
2. Accepted the stack object as a parameter, yet the stack object
   does not contain the necessary information to get the associated
   buffer region, the thread object is needed for this
3. Caused a crash on certain platforms that do not allow inspection
   of unused stack space for the currently running thread
4. No user mode access
5. Separately passed in thread name

We deprecate these functions and add a new API
k_thread_stack_space_get() which addresses all of these issues.

A helper API log_stack_usage() also added which resembles
STACK_ANALYZE() in functionality.

Fixes: #17852

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-08 10:02:35 +02:00
Alex Porosanu 1a7a0dd494 samples: bluetooth: hci_uart: add VEGABoard configuration
VEGABoard BLE controller implementation supports HCI over UART;
as such enable this configuration when building the hci_uart
sample.

Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-02-07 15:49:35 -06:00
Joakim Andersson 1e80efaa1b Bluetooth: samples: peripheral_dis: Sample requires BT_SETTINGS
The DIS service requires BT_SETTINGS otherwise it will not have a
settings handler. Instead DIS will only use Kconfig to set it's
values.

Fixes: #22478

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-05 20:11:03 +02:00
Tobias Svehagen d1f15724aa Bluetooth: samples: Add mesh_provisioner sample
Add sample for how to use provisioner and Configuration Database (CDB)
APIs.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2020-02-05 18:47:41 +02:00
Marcio Montenegro c6df1b9395 Samples: Bluetooth: st_ble_demo: Update to new GPIO API
Convert to the new API pin and interrupt API.

Signed-off-by: Marcio Montenegro <mtuxpe@gmail.com>
2020-02-05 12:00:36 +01:00
Erwan Gouriou 23d3d08610 samples/bluetooth: hci_spi: convert to new GPIO API
Update bluetooth hcp_spi sample to new GPIO API.
Following changes have been done:
- Use new gpio api functions
- Introduce define for dt generated gpio flags
- Update 96b_carbon_nrf51.dts according to new bindings
- Gpio IRQ pin is configured to output inactive


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski 56fcf9845e samples: convert bluetooth mesh samples to new gpio API
This commit converts mesh and mesh_demo bluetooth samples to the new
GPIO API.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Erwan Gouriou 480bf4c73b samples: bluetooth/peripheral: Fix test variant name
Replace ..peripheral_hr.. by ..peripheral..


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-28 15:10:45 -06:00
Erwan Gouriou 4b8e05a1d8 samples: bluetooth: Add nucleo_wb55rg as test target for peripheral
Aim is to ensure build of stm32 hci_ipm driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-28 15:10:45 -06:00
Peter Bigot 5e486b98b1 treewide: use full path to ipm.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Ulf Magnusson 1b451e0bed bluetooth: kconfig: Do not assign promptless BT_DEBUG
BT_DEBUG is a promptless helper symbol, defined in
subsys/bluetooth/common/Kconfig. It is selected by BT_DEBUG_LOG, which
these configuration files also enable.

Flagged by https://github.com/zephyrproject-rtos/zephyr/pull/20742.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-14 13:41:29 +01:00
Henrik Brix Andersen db611e6781 drivers: pwm: add support for inverted PWM signals
Add support for requesting an inverted PWM pulse (active-low) when
setting up the period and pulse width of a PWM pin. This is useful
when driving external, active-low circuitry (e.g. an LED) with a PWM
signal.

All in-tree PWM drivers is updated to match the new API signature, but
no driver support for inverted PWM signals is added yet.

All in-tree PWM consumers are updated to pass a flags value of 0
(0 meaning default, which is normal PWM polarity).

Fixes #21384.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-07 18:13:18 +01:00
Joakim Andersson 0f717058a0 Bluetooth: samples: peripheral_esp: Use common 24-bit functions
Use the newly introduced byteorder 24 bit variant functions.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-02 19:05:27 +01:00
Jukka Rissanen 56101c3c9a samples: bluetooth: ipsp: Mark accepted socket correctly in accept()
The TCP code expects that we know when the socket has called accept()
in order to continue connection attempt.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-12-20 16:45:06 +02:00
Emil Obalski 2128750138 usb: api: Add user device status callback
By this commit user gets possibility to register USB
device satutus callback. This callback represents device state
and is added so user could know what happend to USB device.

Callback is registered by providing it to usb_enable()
USB api is extended by this callback handler.

Samples using using USB are by default provide no callback
and the usb_enable() is called with NULL parameter.

Status callback registered by hid class is deleted as now
USB device has global callback for all classes within device.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-19 13:08:55 +01:00
Emil Obalski d65027d8c0 usb: samples: Application calling usb_enable by itself
User app is reponsible for issuing usb_enable and
making USB hardware operative.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-19 13:08:55 +01:00
Nick Ward 537f3332f0 samples: bluetooth: peripheral_hr: Fix advertising UUID16 service list
CTS UUID was used instead of DIS UUID

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2019-12-18 21:46:51 +01:00
Andrei Stoica f72d5577f9 Bluetooth: samples: Added dynamic Tx power ctrl sample (#17731)
This commit provides a sample dummy application demonstrating
the usage of the added dynamic Tx power control over the HCI
commands and HCI interfaces.

Signed-off-by: Andrei Stoica <stoica.razvan.andrei@gmail.com>
2019-12-17 12:29:57 +01:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Kumar Gala 24ae1b1aa7 include: Fix use of <misc/FOO.h> -> <sys/FOO.h>
Fix #include <misc/FOO.h> as misc/FOO.h has been deprecated and
should be #include <sys/FOO.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Vinayak Kariappa Chettimada 0b878020f2 samples: Bluetooth: Increase ISR_STACK_SIZE value
Split Link Layer implementation uses 80 bytes more ISR stack
in comparison to Legacy Link Layer, hence increase the
required ISR_STACK_SIZE for the BBC micro:bit and other
nRF51 QFAA SoC based mesh and mesh_demo samples.

Fixes #20414.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-12-10 15:34:26 +02:00
Marcio Montenegro dd5d2e37f5 Samples: Bluetooth: Add ST BLE Demo sample
This sample demonstrates BLE peripheral for ST BLE Sensor.
You can test button notification and LED service using
ST BLE Sensor Android application

Signed-off-by: Marcio Montenegro <mtuxpe@gmail.com>
2019-12-10 12:25:06 +02:00
Trond Einar Snekvik 75adf6940e Bluetooth: Mesh: Clean up sample config
Removes redundant and invalid configurations from the bluetooth/mesh
sample. Removes some stale disabled config entries.

Fixes L2CAP related warning in config step of sample.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-12-09 17:13:41 +02:00
Joakim Andersson f49bb10ca5 Bluetooth: Samples: Switch to synchronous bt_init before main loop
Switch to using the synchronous bt_init call before starting the main
loop in the peripheral samples. This is to avoid sending notifications
before bluetooth has been properly initialized.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-12-09 16:11:19 +01:00
Rubin Gerritsen d2825134c4 samples: bluetooth: hci_uart: add config for nrf5340_dk_nrf5340_cpuapp
Sets the baud rate to 1M to align with other nrf boards.

Signed-off-by: Rubin Gerritsen <Rubin.Gerritsen@nordicsemi.no>
2019-12-09 17:01:27 +02:00
Johan Hedberg 39291fbbbe Bluetooth: Remove usage of BT_BUF_USER_DATA_MIN
This define is not of use anymore since there's a global net_buf user
data Kconfig variable and its definition already guarantees a
sufficient minimum for Bluetooth.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-11-28 13:35:11 +02:00
Kamil Piszczek 50ebde1c8b samples: bluetooth: adding hci_rpmsg sample
This commit contributes a BLE HCI-over-RPMsg sample.

Co-authored-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Co-authored-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-11-20 19:29:06 +01:00
Carles Cufi b32931277d samples: bluetooth: central_hr: Fix scanning
Fix scanning so that we always use active scanning in case the UUID we
are looking for is in the scan response, and disable duplicate filtering
to handle devices that modify their advertising data at runtime, such as
smartphones reacting to apps being opened and closed.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-11-19 15:25:46 -05:00
Johann Fischer 0ee2f14948 samples: ipsp: use log_strdup(transient_string)
Use log_strdup(transient_string).

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-11-12 16:43:52 +02:00
Johann Fischer 0df5aa54ec samples: ipsp: fix build reply function
Fix build reply function. The sample uses return value
from net_pkt_read() to determine data length,
but the return value is 0 on success.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-11-12 16:43:52 +02:00
Alex Porosanu 74248e26d9 samples: bluetooth: peripheral_hr: add VEGABoard sanity testing
Add a special target that's marked build_only so the BLE SW LL
implementation on VEGABoard is built daily. This helps ensuring
that it doesn't get inadvertedly broken by subsequent updates.
The name of the target is peripheral_hr_rv32m1_vega_ri5cy
and it can be run with the following command:

sanitycheck -v --all -p rv32m1_vega_ri5cy \
            -x=CMAKE_REQUIRED_FLAGS=-Wl,-dT=/dev/null \
            --test samples/bluetooth/peripheral_hr/\
              sample.bluetooth.peripheral_hr_rv32m1_vega_ri5cy

Note: The extra CMake flags are required if running with the official
      VEGABoard compiler, due to this linker issue:
      https://github.com/pulp-platform/pulpino/issues/240

Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2019-11-08 15:38:57 +01:00
Alex Porosanu d24213f4e4 samples: bluetooth: add overlays for RV32M1 SoC for BLW SW LL
Add the required specific HW configuration for SW defined
BLE LL on RV32M1 SoC, by means of DTS overlays:
- enable INTMUX0 channels 2 & 3
- route Generic FSK RF0 interrupt to INTMUX channel 3
- route LPTMR1 interrupt to INTMUX channel 2

This change is done for all Bluetooth samples that are intended to
run on RV32M1 using BLE SW LL.

Signed-off-by: George Stefan <george.stefan@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2019-11-08 15:38:57 +01:00
Trond Einar Snekvik 0151d6dc33 Bluetooth: Mesh: Model extension concept
Adds the model extension concept to the access layer, as described in
the Mesh Profile Specification, Section 2.3.6. Extensions are
implemented as a tree, using two pointers in each model:

The extends pointer points to the first extended model, and the next
pointer points to the next sibling or (if the NEXT_IS_PARENT flag is
set) the parent model in the tree, forming a cyclical "Left-child
right-sibling" (LCRS) tree. The tree root can be obtained by calling
bt_mesh_model_root_get(), and the extended models can be walked by
calling bt_mesh_model_tree_walk().

According to the Mesh Profile Specification Section 4.2.3, all models in
the same extension tree share one subscription list per element. This is
implemented by walking the model's extension tree, and pooling the
subscription lists of all models in the same element into one. If the
config server adds a subscription to a model, it may be stored in any of
the model tree's models' subscription lists. No two models in the same
extension tree and element will have duplicate groups listed. This
allows us to increase extended models' capacity for subscriptions
significantly.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-11-07 18:57:32 +02:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Sergiy Nikolayenko 25164654dd Bluetooth: Keys: add key overwrite feature for key storage.
Key overwrite feature allows to overwrite old pairing key
records when key storage is full and a new pairing request occurs,
or new keys are distributed. If enabled when key storage is full and
a keys storage slot is requested, the oldest keys added will be
removed. So new devices can be paired with no limitations and no need
to determine, which devices should be unpaired to free key storage
space explicitly in application. To enable the feature set
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y.

Oldest keys are determined by minimum value of up-counting aging
counter. If you set CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING=y
aging counter values will be updated each time the secure connection
is established. This might increase flash wear out if at least two
secure connections are established and shut down periodically. When
the option disabled aging counter is still updated on each new secure
connection, but not stored to flash.

Signed-off-by: Sergiy Nikolayenko <sergiy_nikolayenko@jabil.com>
2019-10-17 22:20:55 +03:00
Joakim Andersson 15f755a910 Bluetooth: samples: peripheral_dis: Failed to save with custom settings
The Peripheral Device Information Service (DIS) sample implements it's
own custom settings backend in order to load runtime settings.
This results in errors when the BT stack tries to save entries through
the custom handler since no save handler exists.
Error messages:
 - bt_settings: Failed to save ID (err -2)
 - bt_gatt: Failed to save Database Hash (err -2)

Since this is not a sample of how to do custom settings backend it is
best simply to remove using the custom backend, as it is not required
in order to load runtime settings.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-10-16 16:39:47 +03:00
Peter Bigot 336c90f87c Bluetooth: samples: Reduce the bbc_microbit RAM usage
Reduce the RAM usage in hci_uart to fit in the BBC Microbit's RAM.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-16 15:38:12 +03:00
Erwan Gouriou 35eb46cec3 samples/bluetooth: peripheral: Remove nucleo_f429zi from withelist
samples/bluetooth/peripheral couldn't build on nucleo_f429zi
since settings dependency on flash erase bock size.
On this series, flash erase are done per sector with sector
having varying size, so erase block size can't be used directly.
This has to be sorted, but for now nucleo_f429zi is removed from
sample withelist to unlock CI.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-10-16 11:40:05 +02:00
Erwan Gouriou e1ae80c038 samples/bluetooth: peripheral: Support of x_nucleo_idb05a1 ble shield
Aim is to test x_nucleo_idb05a1 shield


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-10-15 18:15:55 -05:00
Kamil Piszczek 366cf363b2 samples: migrating to NVS backend with settings
Bluetooth samples now use the NVS backend for Settings.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-10-11 14:55:24 +02:00
Peter Bigot e28f330a8e coccinelle: standardize k_thread create/define calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments
to k_thread_create and K_THREAD_DEFINE to use the standard timeout
macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Marti Bolivar 27e5dd131f doc: s/device tree/devicetree/
DTSpec writes this as a single word, presumably to make it easier to
grep for / more precise. Follow along in the rest of the docs now that
our main DT docs page agrees with this usage.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-10-08 11:53:40 +02:00
Joakim Andersson d2c6982191 Bluetooth: samples: Add newline when using printk
Improve readability of security_changed printk usage, add missing
newlines.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-10-07 20:50:14 +03:00
Peter Bigot 66c8756956 coccinelle: standardize kernel API timeout arguments
Re-run with updated script to detect missed cases.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-04 16:23:57 -04:00
Andrzej Głąbek 5239bef610 drivers: pwm_nrf5_sw: Remove PWM_NRF5_SW_0_DEV_NAME Kconfig option
This option determines the name under which the device represented by
the `sw_pwm` node is registered in the system. But when the value of
this option does not match the `label` property of the `sw_pwm` node,
a problem arises when the `sw_pwm` node is referenced by a "pwm-leds"
compatible node, since the `*_PWMS_CONTROLLER` macro that is generated
for this referencing node contains a non-existing device name (as it is
the `label` property value, not the Kconfig option value).
This commit solves the issue described above by removing the Kconfig
option and replacing all of its occurrences in sample applications
by the standard macro generated for the `sw_pwm` node, containing
the value of the `label` property of this node.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-10-04 17:21:32 +02:00
Radoslaw Koppel c68ff8b99c settings: Generic function to call set handler
This commit implements generic function to decide
witch functions to call for selected value name with given
loading parameters.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2019-09-24 14:15:38 +02:00
Radoslaw Koppel 6c2add5445 settings: Direct loading functionality
This commit allows loading data from settings permanent storage
directly to the given callback function.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2019-09-24 14:15:38 +02:00
Luiz Augusto von Dentz 03b9ce487c Bluetooth: GATT: Add support to setting permission on CCCD
This adds support to set different permissions to CCCD so security can
be checked when enabling notification which conforms to:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2360:

  '3.3.3.3 Client Characteristic Configuration

   Authentication and authorization may be required by the server to
   write the configuration descriptor.'

In addition to that also ensure that notification are not re-enabled
until the proper security level is reached to conform to the following
statement:

  '10.3.1.1 Handling of GATT indications and notifications

   A client “requests” a server to send indications and notifications
   by appropriately configuring the server via a Client Characteristic
   Configuration Descriptor. Since the configuration is persistent
   across a disconnection and reconnection, security requirements must
   be checked against the configuration upon a reconnection before
   sending indications or notifications. When a server reconnects to a
   client to send an indication or notification for which security is
   required, the server shall initiate or request encryption with the
   client prior to sending an indication or notification. If the client
   does not have an LTK indicating that the client has lost the bond,
   enabling encryption will fail.'

Fixes #17983

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-09-19 21:12:39 +03:00
Trond Einar Snekvik 056d44f905 Bluetooth: Mesh: Remove special stack config
Removes the special stack config setting in the Bluetooth Mesh sample to
allow it to run with other Bluetooth controllers.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-09-11 14:04:16 +03:00
Trond Einar Snekvik 827a852acf Bluetooth: Mesh: Same config for all nrf51_qfaa boards in sample
Renames the nrf51_blenano config file to something generic and uses that
same config for the nrf51_ble400 board, which has the same constraints.

Cannot rely on the CONFIG_SOC_NRF51_QFAA variable, as the CONF_FILE
variable must be set before the boilerplate.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-09-11 14:04:16 +03:00
Joakim Andersson 3320b51644 Bluetooth: Host: Rename long error codes
Rename AUTHENTICATION, to AUTH, since this is a well established short
form of the word.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-27 15:13:25 +02:00
Joakim Andersson 3e9888105e Bluetooth: Host: Rename API function to initiate bluetooth security.
Rename bt_conn_security to bt_conn_set_security, this makes the API
naming more consistent.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-27 15:13:25 +02:00
Joakim Andersson 1c48757d94 Bluetooth: Host: Rename security level enum
Rename security level enum, using level and number instead of low,
medium, high and fips.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-27 15:13:25 +02:00
Joakim Andersson 6d4b842a10 Bluetooth: Host: Add error to security changed callback
Add security error to security_changed callback. Call this callback when
security has failed and provide current security level and error.
Reason for failure can be.
 - Pairing procedure failed, pairing aborted before link encryption.
 - Link encrypt procedure failed
 - Link key refresh procedure failed.

Fix missing bt_conn_unref on encryption key refresh with error status.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-26 13:12:49 +02:00
Joakim Andersson 1fb68828ef Bluetooth: SMP: Add pairing failed reason
Forward the pairing failed SMP status code to the application

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-26 13:12:49 +02:00
Luiz Augusto von Dentz 5f3595e47c Bluetooth: GATT: Fix using variable size storage for CCC
This removes the necessity of registering the storage for CCC and make
it part of the declaration itself.

Fixes #18547

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-08-22 15:14:39 +03:00
Carles Cufi 9be6fb0ba2 Bluetooth: samples: Reduce the bbc_microbit RAM usage
Reduce the RAM usage in two of the Bluetooth samples in order for them
to fit in the BBC Microbit's RAM.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-08-15 15:07:12 +02:00
Joakim Andersson c1a754f665 Bluetooth: Host: Print error codes in hex
Error codes are listed in header files and in the core spec as hex
values. Always print them in hex in debug for easier error code
checking.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-05 12:18:17 +02:00
Anas Nashif ffaba63b10 boards: remove arduino 101 and related boards
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Anas Nashif a9b32e26b9 samples: hci_usb: remove whitelisting
Remove whitelisting and enable broader testing on all boards with needed
features.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-12 05:54:16 -07:00
Joakim Andersson 99e8710a50 Bluetooth: services: Delete unused IPSP sample
Delete IPSP sample file, this source file is not included in any build
files. The service contains no valuable logic other than advertising
with the IPSP service in the advertising data.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-11 13:21:14 +03:00
Joakim Andersson 26ca3682bd Bluetooth: services: Move HID over GATT service
Move the HID over GATT service into the sample that demonstrates it.
This avoids long build paths

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-11 13:21:14 +03:00
Joakim Andersson 88f13ebab6 Bluetooth: services: Move Current Time service sample
Move the Current Time service into the sample that demonstrates it.
This avoids long build paths

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-11 13:21:14 +03:00
Joakim Andersson eecc58fafd Bluetooth: services: Move health thermometer service
Move the health thermometer service into the sample folder that
demonstrates it. This avoids long build paths

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-11 13:21:14 +03:00
Joakim Andersson 029a66a195 Bluetooth: services: Move Heart rate service
This commit moves the BLE GATT heart rate service from
samples/bluetooth/gatt to subsys/bluetooth/services and adds a Kconfig
entry to enable and configure the service.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-11 13:21:14 +03:00
Emanuele Di Santo 30d65809fc Bluetooth: services: battery service enhancements
This commit moves the BLE GATT Battery service
from /samples/bluetooth/gatt to /subsys/bluetooth/services and
adds a Kconfig entry to enable and configure the service;
when enabled, it will register itself automatically.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-11 13:21:14 +03:00
Andy Ross f288d1e4a7 tests: samples: Apps shouldn't set tick rate
Tick rate is becoming a platform tunable in the tickless world.  Some
apps were setting it due to requirements of drivers or subsystems (or
sometimes for reasons that don't make much sense), but the dependency
goes the other way around now: board/soc/arch level code is
responsible for setting tick rates that work with their devices.

A few tests still use hard-configured tick rates, as they have
baked-in assumptions (like e.g. "a tick will be longer than a
millisecond") that need to be addressed first.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-07-02 22:52:29 -04:00
Aaron Tsui b0e58d62ab samples: bluetooth: peripheral_ht: Health Thermometer sample
Adding Health Thermometer Service sample. Refer to Health Thermometer
Profile Specification for detailed information about the Health
Thermometer Profile.

Signed-off-by: Aaron Tsui <aaron.tsui@outlook.com>
2019-07-02 17:06:07 +03:00
Johan Hedberg 0d9dab300e Bluetooth: Introduce separate pool for discardable events
Introduce a separate buffer pool for events which the HCI driver
considers discardable. Examples of such events could be e.g.
Advertising Reports. The benefit of having such a pool means that the
if there is a heavy inflow of such events it will not cause the
allocation for other critical events to block and may even eliminate
deadlocks in some cases.

Also update all mesh samples not to specify explicit RX buffer counts
anymore. Instead, create appropriate defaults in Kconfig so that we
only need to override this in the app for cases like the bbc:microbit
with limited memory.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-01 16:36:15 +03:00
Kumar Gala 284bc9d964 dts: Rename SW._GPIO_* -> DT_ALIAS_SW._GPIOS_*
We use the following commands to rename any
SW._GPIO_{CONTROLLER,PIN,FLAGS} to
DT_ALIAS_SW._GPIOS_{CONTROLLER,PIN,FLAGS}

git grep -l SW._GPIO_CONTROLLER | xargs sed -i 's/SW\(.\)_GPIO_CONTROLLER/DT_ALIAS_SW\1_GPIOS_CONTROLLER/g'
git grep -l SW._GPIO_PIN | xargs sed -i 's/SW\(.\)_GPIO_PIN/DT_ALIAS_SW\1_GPIOS_PIN/g'
git grep -l SW._GPIO_FLAGS | xargs sed -i 's/SW\(.\)_GPIO_FLAGS/DT_ALIAS_SW\1_GPIOS_FLAGS/g'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-01 07:14:36 -05:00
Anas Nashif efb8df5366 cleanup: include/: move misc/stack.h to debug/stack.h
move misc/stack.h to debug/stack.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5d001f3e41 cleanup: include/: move misc/byteorder.h to sys/byteorder.h
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif d1b2718687 cleanup: include/: move uart.h to drivers/uart.h
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif bd70f6f1ed cleanup: include/: move spi.h to drivers/spi.h
move spi.h to drivers/spi.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5843884887 cleanup: include/: move pwm.h to drivers/pwm.h
move pwm.h to drivers/pwm.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 6aa9c3a68f cleanup: include/: move gpio.h to drivers/gpio.h
move gpio.h to drivers/gpio.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Kumar Gala a614a026b7 dts: Rename DT_.*_GPIO_* to DT_.*_GPIOS_*
Convert DT_.*_GPIO_{CONTROLLER,PIN,FLAGS} ->
	DT_.*_GPIOS_{CONTROLLER,PIN,FLAGS)

Used the following commands to make these conversions:

git grep -l DT_.*_GPIO_CONTROLLER | xargs sed -i 's/DT_\(.*\)_GPIO_CONTROLLER/DT_\1_GPIOS_CONTROLLER/g'
git grep -l DT_.*_GPIO_PIN | xargs sed -i 's/DT_\(.*\)_GPIO_PIN/DT_\1_GPIOS_PIN/g'
git grep -l DT_.*_GPIO_FLAGS | xargs sed -i 's/DT_\(.*\)_GPIO_FLAGS/DT_\1_GPIOS_FLAGS/g'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-27 13:02:34 -05:00
Carles Cufi d4083b6638 Bluetooth: hci_uart: Assert if device is NULL
Assert if the UART device is NULL to help with debugging whenever
there's an issue locating the correct UART instance.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-06-26 12:37:04 +02:00
Carles Cufi 3b3bbc1ee0 Bluetooth: hci_uart: Use DT for the hci_uart UART
Use Device Tree,and in particular a new 'bt-c2h-uart' to select which
UART is being used to communicate with an external BLE Host when acting
as a Controller.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-06-26 12:37:04 +02:00