Commit graph

169 commits

Author SHA1 Message Date
Johan Hedberg 5b01cb1a46 Bluetooth: Introduce new bt_set_id_addr() API
There are certain use cases where the application needs to be able to
explicitly set a specific identity address. This was previously
possible using the bt_storage API, however now that it's gone another
solution is needed.

This patch adds a ne bt_set_id_addr() API which the application can
use to set a specific identity address before calling bt_enable().

Fixes #7434

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-10 22:39:04 +02:00
Johan Hedberg d22b7c9f2d Bluetooth: Remove bt_storage API
The same functionality is now supported by the settings-based
solution, so remove bt_storage out of the way. There were stubs in
bt_storage to handle per-peer information (e.g. pairing keys) but this
was never actually implemented in full. The next step is to add this
support to the settings-based solution.

Leave the code for generating temporary IRK and identity address in
case BT_SETTINGS is not enabled. Also leave the code for using vendor
HCI to read the identity address, in which case the settings
implementation will not touch it.

Introduce a new bt_unpair() API to replace the removed
bt_storage_clear(), since the latter was actually doing more than just
storage management: it was also handling runtime storage of pairing
information. Later, the bt_unpair() implementation will be extended to
clear settings-based pairing storage.

There is one feature that the bt shell module looses: the ability to
give a specific identity address to the "init" command as a parameter.
We might look later in the future if this is really needed, and add a
separate API for this.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-04 17:26:05 -04:00
Johan Hedberg ac133268a5 Bluetooth: Remove 'own_addr' from advertising parameters
This was originally added as a work-around to avoid the heavy stack
consumption of the TinyCrypt PRNG when generating NRPAs. This is
no-longer an issue, and there are in fact no (in-tree) users of this.
Remove it before it gains any wider users, since it was in many ways a
hack/work-around to begin with.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-03-21 18:11:49 +02:00
Johan Hedberg 7d4514a8b0 Bluetooth: Add option to force using identity address for advertising
In some cases the app may want to force using the identity address
regardless of privacy support or what type of advertising is done.
Provide such an option in bt_le_adv_param.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-03-21 18:11:49 +02:00
Johan Hedberg b452d6f348 Bluetooth: Add support for decoding new address types
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-10-05 13:14:08 +03:00
David B. Kinder 2c850d7547 doc: fix misspellings in include (API docs)
Fix misspellings in .h files missed during code reviews
and affecting generated API documentation

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-10 12:22:19 -04:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Johan Hedberg a5ae267e92 Bluetooth: Introduce new BT_LE_ADV_OPT_ONE_TIME advertising option
In some cases applications may want better control of advertising
instead of the stack doing automated re-enablement. Introduce a new
option that can be used to do more "manual" advertising control.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-06-29 15:08:00 +03:00
David B. Kinder fc5f2b3832 doc: spelling check doxygen comments include/
fix misspellings found in doxygen comments used for API docs

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-05-02 22:21:37 -04:00
Kumar Gala d0eb235510 Bluetooth: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I8f57a17f78e674aca5400f005db8975c9f9e150e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 13:25:23 -05:00
Johan Hedberg 042624fb62 Bluetooth: Move crypto APIs to dedicated header file
This avoids overpopulating the high-level bluetooth.h

Change-Id: Icab8500be92003aa45d837ff111a8d93689865cc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada a91dd34830 Bluetooth: Make LE Encrypt helpers public
Expose LE Encrypt helpers to applications. If software-
based controller is compiled-in, then controller's AES
hardware will be used by the exposed helper interface.

Change-id: I2bac9dfa5ccb3dd50447079affb52d920ae5bd81
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>.
2017-03-21 17:05:42 -07:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Szymon Janc bddf039736 Bluetooth: Make BR/EDR discovery be limited only by time
If more inquiry results were received during discovery than fits in
storage results with lowest RSSI will be skipped. This is to improve
API usefulness in busy environments where results with low RSSI (likely
more far away than high RSSI) could consume provided result space,

Change-Id: I1e9ca901b693f608d58575916809e8bd8bfe710f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-12-24 08:42:15 +02:00
Johan Hedberg b94a69e346 Bluetooth: Fix format specifier in address helpers
Instead of %2.2x we should use %02x since printk doesn't (currently)
support the former.

Change-Id: I773972e63071b81c95c65de292f12ab14d7c310b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-09 08:18:24 +02:00
Johan Hedberg a4b6b2417d Bluetooth: Switch from printf to printk functions
There's now snprintk available that's more light-weight on the stack
than snprintf.

Change-Id: I6b3e4409703ca92fe6b8f4146ff47c490ab826cb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-09 08:18:24 +02:00
Johan Hedberg 5ac059b6b9 Bluetooth: Extend advertising parameters with optional own address
Applications may want finer control of the NRPA used for
non-connectable beacons, and provide it up-front rather than letting
the stack generate one.

Change-Id: I84d459372cc85ed09a8f9cde16dbb9b98dec2a43
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-09 08:18:24 +02:00
Johan Hedberg 195e1b89b1 Bluetooth: Fix usage of C++ reserved word
'private' is a C++ reserved word and will lead to compilation errors:

  C++     ble.o
In file included from ble.cpp:7:0:
 include/bluetooth/bluetooth.h:284:10: error: expected unqualified-id before 'private'
  uint8_t private[4];

Change-Id: I36aef5a84af4fc66e1c810bd0c56e5ab5f803294
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-09 08:57:52 +02:00
Johan Hedberg a8de2de1f2 Bluetooth: Fix compiler warnings/errors related to string casts
Fix the following compiler warnings/errors that show up with llvm:

    tests/bluetooth/shell/src/main.c:594:2: error:
          initializing 'const uint8_t *' (aka 'const unsigned char *') with an
          expression of type 'char [11]' converts between pointers to integer types
          with different sign [-Werror,-Wpointer-sign]
            BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    include/bluetooth/bluetooth.h:93:11: note: expanded
          from macro 'BT_DATA'
                    .data = (_data), \
                            ^~~~~~~
    1 error generated.
    net/bluetooth/hci_core.c:1759:22: error: passing
          'uint8_t [248]' to parameter of type 'const char *' converts between
          pointers to integer types with different sign [-Werror,-Wpointer-sign]
                            name_len = strlen(evt->name);
                                              ^~~~~~~~~
    lib/libc/minimal/include/string.h:32:34: note: passing
          argument to parameter 's' here
    extern size_t strlen(const char *s);
                                     ^
      CC      net/bluetooth/log.o
    net/bluetooth/hci_core.c:3136:10: error: passing
          'uint8_t [248]' to parameter of type 'char *' converts between pointers to
          integer types with different sign [-Werror,-Wpointer-sign]
            strncpy(name_cp->local_name, CONFIG_BLUETOOTH_BREDR_NAME,
                    ^~~~~~~~~~~~~~~~~~~
    lib/libc/minimal/include/string.h:30:39: note: passing
          argument to parameter 'd' here
    extern char  *strncpy(char *_Restrict d, const char *_Restrict s, size_t n);
    net/bluetooth/conn.c:301:10: error: passing
          'uint8_t [16]' to parameter of type 'char *' converts between pointers to
          integer types with different sign [-Werror,-Wpointer-sign]
            strncpy(cp->pin_code, pin, sizeof(cp->pin_code));
                    ^~~~~~~~~~~~
    lib/libc/minimal/include/string.h:30:39: note: passing
          argument to parameter 'd' here
    extern char  *strncpy(char *_Restrict d, const char *_Restrict s, size_t n);

Change-Id: I342131c6c2b25445382b2317d673561c4087096b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-04 12:44:24 +00:00
Szymon Janc d2549115ca Bluetooth: Rename connectable_addr member in struct bt_le_oob
Depending on advertising options this can be non-connectable address.
NFC pairing application document also allows broadcaster/observer
roles.

Change-Id: I9b104ac8fb9752a083a7a31fc20598c66f23f608
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-22 13:09:30 +02:00
Szymon Janc c6bcb591f6 Bluetooth: Add initial support for OOB data
This allows to query information needed for Out Of Band pairing
or connection creation. Currently supports only BT addresses.

Change-Id: I60bf9344baee552e7743fa8fc1b3cfb3a4765334
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-20 20:20:44 +02:00
Johan Hedberg 211ae314e8 Bluetooth: Pass net_buf_simple to scan callback
This lets the callback take advantage of the powerful net_buf API for
parsing the advertising data content.

Change-Id: Id65e6e83efd60c0f36c47bc5446a2e8ec2833d7c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-20 16:19:01 +00:00
Johan Hedberg 502f4a1581 Bluetooth: Add convenience enum value for no advertising options
This makes the code be a bit clearer by letting it specify a more
descriptive value than '0'.

Change-Id: I2e6b46f0924581d0d13f13479aa15170cc9e0e70
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-27 11:09:51 +03:00
Johan Hedberg fbb2fe8acf Bluetooth: Make random number generation API public
Applications or higher level profiles that are not part of the core
Bluetooth stack may need an easy way to generate random numbers. Since
we already have an internal helper for this export it for others to
use as well.

Change-Id: I29af7cab30ad8f60d481bc847984e781eaecd6bf
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-27 11:09:51 +03:00
Inaky Perez-Gonzalez ee4c153f0a doc: fix warnings introduced in bluetooth headers
- Missed/mispelled argument types
- Needed @typedefs to workaround tool limitations

Change-Id: I1655eca96d30d04959154c5d468e1b3b330fafc5
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-06-16 13:11:06 -07:00
Johan Hedberg 8ea57bd5d3 Bluetooth: Shorten limited discovery parameter name
The parameter is already inside a struct that's specific to BR/EDR
discovery, so there's no need to repeat "discovery" in its name.

Change-Id: Idb95788bfc9d62ecd52adecc35104e212724cb78
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 11:28:59 +03:00
Johan Hedberg 1a756d6f8d Bluetooth: Fix validity check for Inquiry parameters
Since we only have a single user we can enforce length > 0x01. We
should also ensure that the results count is 1-255.

Change-Id: Id5d91acae06c6c6fc66dd59c0e367682a98dc08c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 10:58:50 +03:00
Johan Hedberg c2a5ab1917 Bluetooth: Add BR/EDR Inquiry length to bt_br_discovery_param
This way the application can control the maximum duration of the
Inquiry. The value 0x00 (which is invalid for HCI) is still accepted
for backwards compatibility and gets mapped to the old hard-coded 0x30
value.

Change-Id: Ibc9eb86bbb6c9e45b7b351278517b4a688015195
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 10:21:15 +03:00
Johan Hedberg 0aa4398f35 Bluetooth: Clarify language in discovery API documentation
Current language is a bit confusing, reword it in a clearer way.

Change-Id: Iaf2d29ab838cf2c5f50d7f2bdb2cdfa83c9a44c7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 09:56:54 +03:00
Johan Hedberg 0dc25e3849 Bluetooth: Put bluetooth.h APIs behind a GAP subgroup
This way the APIs don't dangle on their own under the master Bluetooth
group but are nicely behind a subgroup like everything else.

Change-Id: I608b6019e970db86a1bcdb29f0a52ce4a3165fbe
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-15 09:55:55 +00:00
Johan Hedberg 58a1568943 Bluetooth: Remove #ifdefs from public header files
These prevent the documentation from being included in the generated
doxygen output.

Change-Id: Iffe38c15055b8283d4b9f16b1c830c9f269ba6e4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-15 09:55:41 +00:00
Johan Hedberg ebd5011adf Bluetooth: Update Intel copyright for files modified in 2016
Change-Id: I10a7cab9a7f911b9f64e17bf24ddce82c2f08c40
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-10 12:10:53 +03:00
Johan Hedberg 7753e335f7 Bluetooth: Fix advertising parameters documentation
Change-Id: I67af3d5928ffa76cfe8c8f7a25ad65eb6493821f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-05-27 14:44:15 +03:00
Johan Hedberg 37c0944d05 Bluetooth: doc: Use proper grouping for APIs
Change-Id: Ifb3483d300409d280ca12aef5f49a983eff92496
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-05-16 20:14:28 +00:00
Szymon Janc 6d5ed390b1 Bluetooth: Simplify advertising API
Instead of requiring application to provide both advertising type
and address type used just require app to provide info if advertising
is connectable or not. Advertising type is set based on provided
SCAN_RSP and local privacy support.

When local privacy is enabled it is no longer possible to advertise
using identity address. If such feature is to be required later on
advertising options can be extended.

This gives BT stack full control over what type of address is used
for advertising and is a preparation for random address rotation
and OOB support.

Change-Id: I90e9a683ef3794f155707343c874f75585439325
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-05-04 11:11:34 +00:00
Johan Hedberg 5ccb20c591 Bluetooth: Use bt_addr_t inside bt_addr_le_t
In many cases when we want to access the 'val' member of bt_addr_le_t
it's in situations where the type needed is actually bt_addr_t. To
avoid unnecessary typecasts in these places simply embed bt_addr_t
inside bt_addr_le_t.

Change-Id: I7eecf129bee1dcf085abc83ec2f32e1a10b0b5aa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Johan Hedberg 13be3947ab Bluetooth: Add Privacy Feature support
Add initial support for the Privacy Feature, including the ability to
manage a local IRK and to use Resolvable Random Addresses.

Change-Id: I1c70aea67078dd2a5d07f3b797c37746ebe9ab61
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Szymon Janc e23e4c76e2 Bluetooth: Add support for resolving BR/EDR names
If BR/EDR device didn't provide name in EIR (or no EIR at all) names
are resolved after discovery is completed. Resolved names are put into
EIR block.

> HCI Event: Extended Inquiry Result (0x2f) plen 255
        Num responses: 1
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x280424
          Major class: Audio/Video (headset, speaker, stereo, video, vcr)
          Minor class: Set-top box
          Capturing (Scanner, Microphone)
          Audio (Speaker, Microphone, Headset)
        Clock offset: 0x47d5
        RSSI: -88 dBm (0xa8)
> HCI Event: Inquiry Complete (0x01) plen 1
        Status: Success (0x00)
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x47d5
> HCI Event: Command Status (0x0f) plen 4
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Success (0x00)
> HCI Event: Remote Name Req Complete (0x07) plen 255
        Status: Success (0x00)
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Name: Nexus Player

Change-Id: Ica5f6cc8a7d9dc7a925025bc62faab2caec47dbb
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-26 05:57:34 +00:00
Szymon Janc ca662c14f1 Bluetooth: Add initial support for BR/EDR discovery
This allows to start (general or limited) BR/EDR discovery. Inquiry
is active until explicitly disabled by application. This is to keep
BR/EDR discovery API similar to LE scan API.

< HCI Command: Inquiry (0x01|0x0001) plen 5
        Access code: 0x9e8b33 (General Inquiry)
        Length: 61.44s (0x30)
        Num responses: 0
> HCI Event: Command Status (0x0f) plen 4
      Inquiry (0x01|0x0001) ncmd 1
        Status: Success (0x00)
> HCI Event: Inquiry Complete (0x01) plen 1
        Status: Success (0x00)

Change-Id: I946fbd881e6d0460be28a9975acd564ae32896e8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-24 20:25:02 +00:00
Peter Mitsis 173877cff3 bluetooth doc: Fix parameter name in documentation
Change-Id: If537f3557dfc75ca2999f977ca8c2e7dbad36d5a
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-11 20:11:03 +00:00
Johan Hedberg 479d25d035 Bluetooth: Rename BT_LE_ADV_ADDR_PUBLIC to BT_LE_ADV_ADDR_IDENTITY
In anticipation of supporting a local static random address in the
future it makes more sense to call BT_LE_ADV_ADDR_PUBLIC
BT_LE_ADV_ADDR_IDENTITY.

Change-Id: I4826f1dfb50b54e13a35cbe7ee74e28641c81ad1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:31 -05:00
Johan Hedberg 08c594049d Bluetooth: Update documentation of BT_DATA & BT_DATA_BYTES
Change-Id: Ia523cc2f0602dcd9b7c0877121c678b049d64956
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:31 -05:00
Johan Hedberg 7d8303bbbf Bluetooth: Introduce BT_DATA_BYTES convenience macro
This way we don't need a special BT_BYTES macro and avoid bugs coming
from wrongly counted number of bytes (which is now evaluated at
build-time).

Change-Id: Ic6319234a816fe2fab6229b3bb980d0e3503e241
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:31 -05:00
Peter Mitsis a0e4568760 c++: Add extern "C" { } block to header files
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ source files.

Change-Id: Ia4db0c36a5dac5d3de351184a297d2af0df64532
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:22 -05:00
Johan Hedberg 25f6579016 Bluetooth: Move all bt_conn related APIs to conn.h
To have some proper split of conn.h and bluetooth.h APIs make sure all
bt_conn related ones are in conn.h. This also helps avoid forward
declarations for some upcoming patches where we need bluetooth.h
defines from within conn.h.

Change-Id: Ief3d32118a6749fb5785dab6cb3fee4ebb86ddb4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 0df7a2fac6 Bluetooth: Add error return to authentication APIs
The authentication APIs may fail, so it's fair to give the application
a chance to catch these errors.

Change-Id: I323df86b94a823b201fe22d412e6bbcaa9029550
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 3c47e9515c Bluetooth: Update advertising API
Update the advertising API according to what has recently been
discussed and agreed upon.

Naming-wise the most important change is the removal of "EIR" which
was confusing since this is mainly used with LE at the moment. The
Core Specification Supplement consistently uses the generic terms data
and data type to describe what we're dealing with here, so the new
names are bt_data and BT_DATA.

Another change is to detach the actual data from the struct by
converting it from an array to a pointer. This is not only essential
for supporting BR/EDR (which has a different length) but to also
minimize memory usage.

Another change is to require the caller of bt_le_adv_start() to
provide the array lengths of the ad and sd paramters. This way we
don't have to have the empty (8-byte) element at the end of each
array.

Lastly, the bt_le_adv_start() logic is slightly modified so that it
will always clear the respective data if necessary. Previously the
user might have been left with a previous callers data if it passed
NULL to the API.

Change-Id: I318026ceb1b52bb688edf4dcfed82613bd15c3e1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 005b9904a4 Bluetooth: Don't pass length of PIN code to bt_auth_pincode_entry
We can calculate the length with strlen() and there should be no need
to consider anything else except nul-terminated C strings.

Change-Id: I02ec4b1dddbb1bd457f035926c86b27f4c2ab050
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:10 -05:00
Szymon Janc 0542d6df90 Bluetooth: Add passive scan helper macro
This allows to conveniently start passive scan from central
applications.

Change-Id: Idf470be747ab7c6e7413cc368227b0b69e7b78a4
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:10 -05:00
Arkadiusz Lichwa 98f1ef7192 Bluetooth: BR/EDR: Add PIN code authentication API
Defines authentication interface for legacy 2.0 devices

Change-Id: I28fe07fa4f5b9f4e0bcb707eab73a0cd5df2b425
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa bce38d9f9e Bluetooth: BR/EDR: Enable authentication interface
Gets included authentication API in BR/EDR variant

Change-Id: I4fa55bb3baa8db79f6e9f5f1c65c0d93f8f8780a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Johan Hedberg 966acc1980 Bluetooth: Don't default to continuous scanning with BT_LE_SCAN_ACTIVE
Change-Id: I76d7db24bb9459f1df1d1e9881accc970b60aaf8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:03 -05:00
Johan Hedberg 4087728345 Bluetooth: Provide API to advertise with local NRPA
Applications may want to protect the privacy (identity of the local
device). One way to do this is to generate a Non-resolvable Private
Address and use that when advertising.

Change-Id: Ib852b03c14af062f914aa99a14e50c2e52ac78c2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 47044cd677 Bluetooth: Add advertising interval to LE adv params API
Change-Id: Id61589ca723c822ea8eb84c67ac9ed57b00cc305
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 9533fbcfe1 Bluetooth: Add latency & timeout to LE conn param API
Change-Id: Icd6122b9056dd686d70a2d213a18dcab34f5e80a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 1a32d5ed55 Bluetooth: Add support for specifying connection parameters
Applications may want fine-grained control of connection parameters.
The two APIs to provide this through are bt_le_set_auto_conn() as well
as bt_conn_create_le().

Change-Id: If5cddbbf017b868d768d18d2a09daf4af8aa00d8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 70669756ff Bluetooth: Add convenience macros for defined GAP timers
Change-Id: I6315c7791249d07fa2df0682decc0049718b5a06
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 266721018d Bluetooth: Add proper defines for scan enable parameters
Change-Id: I2d915517986007356c14e805eaed60a0f4290109
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 5a5061ef97 Bluetooth: Convert bt_conn_set_auto_conn to bt_le_set_auto_conn
Once we start persistently storing the addresses of devices we want to
reconnect to we also need a way to reload them to the stack. Since we
don't have a connection object at this point the API cannot take that
as a parameter. Instead rename the function and have it take
bt_addr_le_t as a parameter.

The feature was also lacking proper reference counting for the
connection, which this patch now adds (the flag itself owns a
reference). The function is now also possible to call before bt_init()
so that if we load the stack with multiple devices the HCI doesn't get
bombarded with lots of scan enable/disable commands.

Change-Id: I9072bf061eb64f2ecec96f74fb176be13e5bdaee
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 3226780a3c Bluetooth: Add LE scan interval & window to bt_le_scan_param
Change-Id: If2ae26625b98485c3495f4f4f48e49600a1ffd14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 610d32311e Bluetooth: Add LE scan type to bt_le_scan_param
This way the app can start passive scanning if it wants.

Change-Id: Iab3e60863d5a1a013a5f069a98664628c7b14418
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg dd353487c4 Bluetooth: Create active scanning helper macro
All current user just want basic active scanning so a corresponding
macro makes more sense than something based on duplicate filtering.

Change-Id: I97787be24b89fad66f2a952c5d53ab76f4e062fb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg f5a238b665 Bluetooth: Add ability to specify dedicated LE advertising parameters
We'll need to have a much more flexible LE advertising API. This is a
first step in that direction. A convenience BT_LE_ADV() macro is
provided to ease converting application code.

Change-Id: I74854487bbdfb4b1cf1bee0b6351d1750a56ff86
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg 6f470dcbce Bluetooth: Add ability to specify dedicated LE scan parameters
We'll need to have a much more flexible LE scanning API. This is a
first step towards it. The existing BT_LE_SCAN_FILTER_DUP_* enum
values are converted to macros to avoid having to update application
code at this point.

Change-Id: I0c8d29dc156bad67cddc9401c0d72aee8ec6d8de
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg 52989aeecc Bluetooth: Move bt_le_scan_cb_t definition to better place
Change-Id: I9b17d2237654e651465d054f60f6c4e44576250b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg f1d4b686b6 Bluetooth: Rename bt_bredr_* prefix to bt_br_*
bt_br_* is equally understandable and the same length as the
corresponding bt_le_* prefix on the LE side.

Change-Id: I1820f9b9fab6363b696072f6b70d57c0bc780078
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg 5619d1114b Bluetooth: Rename LE scan & advertising APIs for consistency
To have a clear split between LE & BR/EDR rename these APIs with the
appropriate prefixes.

Change-Id: I983df2b5880947d96f0ad289d12f3383f44894be
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Arkadiusz Lichwa 2ebf636fe2 Bluetooth: BR/EDR: Add basic SCAN support
Adds capability to stack to make controller discoverable and
connectable.

Change-Id: Iffe380d2bde0c193f806b76cce3933914c9a4796
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:59 -05:00
Szymon Janc 48249bf34a Bluetooth: Add public API for passkey confirmation
This allows to request user to confirm displayed passkey with remote
device. This allows to have authenticated LE SC link resulting in FIPS
security level.

Change-Id: I5b6c1666e3d1687cc04c5d66529372db090dd000
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Johan Hedberg 3822aecd24 Bluetooth: Merge buf.[ch] functionality into hci_core.[ch]
There's no need to maintain a separate module for this anymore.
Subsequent patches will have further simplifications thanks to this
being now handled in a single c-file.

Change-Id: I4510c9f72b121e1e5fd19eeb8b5d5ddf2f4bfffe
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Dan Kalowsky 978851fb6a checkpatch: code_indent failures
Corrects the checkpatch code_indent failures

Change-Id: I2ff93b8907d3eddbaa543ccbd12aecef8af7f698
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Szymon Janc 68382388ce Bluetooth: Disable parts of public API if not configured
Depending on selected Kconfig options some parts of public API
are disabled with #ifdefs. This should make it easy for user to
figure out which options should be enabled to specific API.

Change-Id: I4ae1bfd7bf535ea45869772c429ccd3d3d4c214e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:24 -05:00
Szymon Janc 01c76d9fa4 Bluetooth: SMP: Add support for passkey entry
This allows to request passkey being entered by user.

Change-Id: I6a56c65ca689473659a13c19f8578058476d2685
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:37 -05:00
Szymon Janc 947f7100c5 Bluetooth: Validate callbacks in bt_auth_cb_register
This adds validation for passed callbacks. Previously registered
callbacks need to be explicitly unregistered by passing NULL.
It is no longer possible to implicitly overwrite callback
structure.

Input Output Capabilities generation is factored out to separate
function. This is in preparation for adding more callbacks.

Change-Id: Ie809ea2daa80f9c54585efb459b49af1107007d3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:24 -05:00
Szymon Janc 8423871b90 Bluetooth: Add initial support for authenticated pairing
This allows to register agent with display capability resulting
in DisplayOnly InputOuput Capability being used.

Change-Id: I98931af35c51a71882b60303c0f5d4da19eefbc4
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:24 -05:00
Szymon Janc faec70c367 Bluetooth: Move security levels to conn.h
For now this is used only in conn.h. Allows to reduce includes
dependencies.

Change-Id: I60dbe588e711fa0332049cbea43ffb6838a58823
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:24 -05:00
Johan Hedberg 79696d3b34 Bluetooth: Redesign Bluetooth init API
We need to be able to perform the init procedure asynchronously
through a callback. The RX fiber is a good candidate to use for the
callback since it's not active in its normal operation before
drv->open has been called. In order to prepare for a future
bt_disable() API the init API is renamed from bt_init() to
bt_enable(). If a NULL pointer is given as the callback the API
behaves synchronously like the old bt_init().

Change-Id: I4e78fa8f32dcf5477ea05a8db75aca5cdce591fd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:44 -05:00
Mariusz Skamra 6b4f7025f2 Bluetooth: Start using atomic flags to indicate bt_dev state
With this patch advertising state and scanning state are stored as flags.

Change-Id: I5d2dc37972620ee89aaf55d45e294e8be82863d3
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:43 -05:00
Johan Hedberg fe41cec885 Bluetooth: Move bt_security to conn.h and rename it appropriately
Change-Id: Ibea6e4ef08c68e9debf0c53036dd2e4f75ea9a72
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg a33047f7a5 Bluetooth: Move bt_connect_le to conn.c and rename it appropriately
This function operates on bt_conn so it should be in conn.c and
exported through conn.h. Rename it with the appropriate bt_conn_*
prefix.

Change-Id: Id17c67f0e95cc1afb10aa7742b2d2ce0110ea616
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg 824135122f Bluetooth: Move bt_disconnect to conn.[ch] and rename it appropriately
The bt_disconnect deals with the bt_conn object and should therefore
reside in conn.c and be exported through conn.h. It should also have
the appropriate bt_conn_* prefix.

Change-Id: I75eb648fd9aa8ced9a991d472c319d25f4b772af
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Mariusz Skamra f45bbec4a1 Bluetooth: hci: Add bt_stop_advertising
This adds above function to stop ongoing advertising.

Change-Id: I16b3913524a61e844a81cbe733f2b8e6072ab442
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg 410a8a8165 Bluetooth: Fix doxygen documentation for bt_connect_le()
Change-Id: Ib40d5a23ee60dad16686f43dee172a31c456e7e1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Mariusz Skamra 296c76c7a8 Bluetooth: Fix status returned by bt_stop_scanning and bt_start_scanning
If the Command Complete status is read, this status shall be returned.

Change-Id: Ic3fe102c16da4b01d002a2d39952fd401e9f832d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:34 -05:00
Anas Nashif 20764a2e8d doxygen: javadoc style
Change all occurances of /*! to /** to match javadoc
style.

Change-Id: I3a759d34e0e928216f61252682266e64c5b875f8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:32 -05:00
Mariusz Skamra 30b50a3227 Bluetooth: Cancel pending connection
Adds HCI routine to cancel creation of outgoing connection.
bt_disconnect is called to cancel connection or disconnect based on current
connection state.

Change-Id: I462a61308a580bb24aa9a6c398eb7e443b995655
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:31 -05:00
Arkadiusz Lichwa b62f778664 Bluetooth: Start outgoing connection with tracking
Enables make outgoing connection with error handling.
Free connection objects maintained in polls are assigned to active
connection by result of lookup on the polls based on input
peer LE address.
Updates shell application to reflect above changes in stack.

Change-Id: Ibc71343c0d122cc78c48bac2ff1e50533369b7d2
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:31 -05:00
Szymon Janc a14314e913 Bluetooth: Move security related code to bluetooth.h
Also rename bt_conn_security function to bt_security and
bt_conn_security_t to bt__security_t.

Change-Id: I543c7b97241c4389ef0eb491b6869f93105ae533
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:31 -05:00
Johan Hedberg 32388b9a5f Bluetooth: Clean up doxygen documentation in bluetooth.h
Make the documentation style consistent and add documentation to
functions that were missing it.

Change-Id: I1822480a604bb2efcb0dbfc63ae0675ebf4b5987
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:24 -05:00
Johan Hedberg 55218cd6de Bluetooth: Be consistent with the spelling of 'Bluetooth'
Change-Id: Ic9cbfe792f0b46071e38b52d1e082ce1da83e708
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:24 -05:00
Arkadiusz Lichwa 1d748ba760 Bluetooth: Address conversion user helpers
Adds user helper functions dealing with formatting bluetooth
address.
Refactors internal helpers using public ones.

Change-Id: If7b9f9a93b2aef3d25df55d6cfae9de05d8830b0
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:24 -05:00
Arkadiusz Lichwa d81689e915 Bluetooth: Introduce LE scan callback
Enables sending LE discovery results to user app.
Updates central apps to use new scan API.

Change-Id: Id319c96e15554f2eed4cf507cddd114ca74aa8e5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:24 -05:00
Johan Hedberg fe669a52e8 Bluetooth: Clean up document style in bluetooth.h
Change-Id: Icd5cbda6ff73b7f4b2d6a4183bb23138fd1ad0be
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 8c26ce63d1 Bluetooth: Remove bt_hci_reset() API
There's no clear need for this API (at least for now) and supporting
it means we really need to get all state cleanup procedures correct.
Remove it for now.

Change-Id: Ia2c7d51d410117bef12bc08f4f97a4e38ccfb77a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 9bea2c3cfc Bluetooth: Move HCI driver API to dedicated header file
This makes it clearer that this is a specialized API not intended for
general app usage (unlike most other things in bluetooth.h).

Change-Id: I0ce1d5903610a9b3a99cf0be9f0e1462b04bf45a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 939544b75d Bluetooth: Move logging helpers to a dedicated header file
To make it clearer that these helpers are intended only for
Bluetooth-subsystem internal code, move them to a separate file.

Change-Id: Iea64780f5c61c1c96e12c9df378676bc49498fe4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Szymon Janc 19fe40764c Bluetooth: Make bt_stop_scanning parameters explicit void
Change-Id: I47ece76e00719d2fef702763c061055a1e9c5f76
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:23 -05:00
Mariusz Skamra b2574b645b Bluetooth: Terminate connection
Adds routine for termination of connection.

Change-Id: I444e4cba3297c51fbd9f89bbdba89db45af195c6
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:23 -05:00
Arkadiusz Lichwa f5ae4b70f1 Bluetooth: Add basic interface for LE connection
Adds internal HCI interface routine for creation of basic ACL LE link.
Most of the command interface parameters are fixed.
The internal interface is then used directly by simple public interface with
no connection validation.

Change-Id: I8ed72a9d01348e2a05b62facc9e85060e4500631
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:23 -05:00