Commit graph

169 commits

Author SHA1 Message Date
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Joakim Andersson a2a7cc9fe6 Bluetooth: host: Only persist advertising with bt_le_adv_start API
Only persist advertising when the bt_le_adv_start API is used to start
the advertiser. For multiple advertising set a connectable advertiser
can only be started if there is a connection object available for the
advertiser. Leave the decision on which advertising set should be
advertising up to the application instead of suspending advertising
when no connection object is available.

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

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-04 17:48:22 +03:00
Joakim Andersson 78a6cdb07c Bluetooth: host: Avoid use of array compound literals in API
Attempt to fix C++ error: taking address of temporary array.

According to GCC documentation:
  In C++, a compound literal designates a temporary object that only
  lives until the end of its full-expression.

Finishing with this recommendation:
  As an optimization, G++ sometimes gives array compound literals
  longer lifetimes: when the array either appears outside a function
  or has a const-qualified type.
  But it is probably safest just to avoid the use of array compound
  literals in C++ code.

Fix the issue by introducing INIT macros as an alternative, and use
these in the inline functions to avoid the use of array compound
literals in Bluetooth headers.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-02 13:08:59 +03:00
Joakim Andersson 89d1bbc639 Bluetooth: doc: Fix detailed API description rendered into text boxes
Fix detailed API description rendered into text boxes.
API documentation with more that one paragraph must use the @brief tag
to be rendered correctly.
Fix indentation level of '*' in doxygen documentation.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:34:28 +02:00
Joakim Andersson d4f22a8216 Bluetooth: host: Add support for multiple advertising set
Add support for multiple advertising set. Move the advertising state
flags to be per advertising set and loop over advertising sets instead
of looking up legacy advertiser set or handle 0.

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

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

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

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

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

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-15 10:57:38 +03:00
Joakim Andersson 0158b76096 Bluetooth: host: Fix scan filter_dup parameter on big endian systems
Fix filter_dup and options in union with mixed size integral types,
this is not portable, and causes malfunction on big-endian systems.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-08 17:58:53 +03:00
Joakim Andersson 69a82170c4 Bluetooth: host: Add scan API for extended scanner
Add scanner API for extended scanner. This includes the options to scan
on the LE Coded PHY for long range, configuring scan timeout with scan
timeout callback and additional information received from the extended
advertising report.

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 b8f48410e5 Bluetooth: host: Add API for advertising sets
Add API for creating and starting advertising sets. This allows to start
and advertising set for a specific timeout or number of events.
The advertising set can be configured to advertise extended data on
secondary advertising channels or advertise on LE Coded PHY to give the
advertiser longer range.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson 6339cd0c96 Bluetooth: host: Minor header file doxygen fixes
Minor header file doxygen fixes:
 - Use /** @brief consistently
 - Indent all comments to the same level
 - Use @note instead of NOTE:
 - Align @note text
 - Align @return text
 - Add /** to documentation comments

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-17 21:13:35 +02:00
Joakim Andersson 628b3bc416 Bluetooth: host: Allow get local OOB data while advertiser is enabled
Allow to get local OOB data while advertiser, scanner or whitelist
initiator is active. If direct initiator is active or the advertiser
is using the random address as a random static identity address then
the function will return error.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 17:16:51 +02:00
Joakim Andersson ba2a327c5b Bluetooth: host: Update documentation regarding LE SC and OOB pairing
Update documentation regarding LE SC and OOB to include full name
befor starting to use abbreviations. Rephrase some sentences to be more
clear and add references to Kconfig options.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 17:16:51 +02:00
Alexey Eremin 6f3f3c230c Bluetooth: Make macro definition compatible with 7-2018-q2-update g++
In C++ designated initializers require that designators used in the
expression must appear in the same order as the data members.

In addition, 7-2018-q2-update version of g++ doesn't support
implicit member initialization, so all members must be
initialized.

Signed-off-by: Alexey Eremin <a.eremin.msu@gmail.com>
2020-03-06 11:27:46 +02:00
Joakim Andersson 08a39851dc Bluetooth: host: Rename scan recv callback info struct
Rename the scan recv callback info struct so that it reflects that it
is part of the scan recv callback. This will make it consistent with
future plans for advertising callbacks.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-11 23:57:27 +02:00
Joakim Andersson 499b4e0ce0 Bluetooth: host: Document privacy-disabled directed advertising reports
Document why a privacy-disabled scanner will not notify about directed
advertising reports. This is the default behaviour of the
privacy-disabled scanner. In order to receive the reports the option
BT_SCAN_WITH_IDENTITY must be enabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-03 12:44:39 +02:00
Joakim Andersson c353fdfa0f Bluetooth: host: Document connection object behaviour
Add documentation for why connection objects are still in use during the
disconnected callback and document error code when starting connectable
advertiser with no free connection object available.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-14 14:27:31 +01:00
Trond Einar Snekvik 5b14ab4481 Bluetooth: Add dynamic le scan listener interface
Adds a way to register listeners for incoming scanner packets, in
addition to the callback passed in bt_le_scan_enable.

This allows application modules to add multiple scan packet listeners
without owning the scanner life cycle API, enabling use cases like
beacon scanning alongside Bluetooth Mesh.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-01-13 14:27:01 +01:00
Peter A. Bigot 2802fa4e6d treewide: avoid address-of-compound-literal idiom in headers
In C99 the construct (T){init-list} is called a compound literal, and
is an lvalue.  In C++ it is simply a cast expression to non-rvalue
type, which is a prvalue.  In both languages the expression is a
temporary, but in C99 taking its address is well-defined while in C++
it is an error diagnosed as "taking address of temporary".

Headers that may be used in C++ application code must avoid invalid
expressions.  Replace all uses of &(T){init-list} in headers with the
functionally equivalent but C++-legal (T[]){{init-list}}.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-12-18 21:53:17 +01:00
Joakim Andersson 063a5342c3 Bluetooth: Host: Move Bluetooth Device address definition to own header
Move the Bluetooth device address definition out of the HCI header file.
This definition is used by higher layer which should not have to include
the HCI specific header file to get the address definition used by the
host API.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-10-17 10:04:06 +02:00
Joakim Andersson 6d9807b31e Bluetooth: Host: Move GAP and GAP defined assigned numbers to own header
Move the GAP defines and the GAP related bluetooth assigned numbers out
from hci to a GAP specific public header file.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-10-17 10:04:06 +02:00
Joakim Andersson a121a9a17d Bluetooth: Host: Add non-HCI defines for scan type
Introduce defines for scan type that does not depend on the HCI defines.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-10-17 10:04:06 +02:00
Johan Hedberg 638b26f309 Bluetooth: Fix missing doxygen markers for advertising options
Several advertising options were not being picked into the
documentation due to missing doxygen markers.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-15 11:40:19 +02:00
Joakim Andersson a463d117f6 Bluetooth: Host: Add whitelist support in Bluetooth Host API
Add whitelist support in the bluetooth host.
Supported features:
 - Advertising with whitelist on scan requests, connect request ,or both
 - Scanning with whitelist
 - Creating connections using a whitelist (Auto connection procedure).

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-09 16:26:10 +02:00
Joakim Andersson 67c66bd09d Bluetooth: Host: Fix bluetooth address string length
The string "xx:xx:xx:xx:xx:xx (random-id)" is 30 characters including
zero termination.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-08-05 12:17:57 +02:00
Joakim Andersson 0ac83180fd Bluetooth: host: Move address string parsing to bluetooth API
Bluetooth address parsing has been duplicated across the different
sub-shell files. Also missing parsing of identity/resolved addresses.
Move parsing of string close to parsing to string for a symmetrical API

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-07-16 12:44:18 +02: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
Kamil Piszczek edea2f0803 Bluetooth: extending API for OOB pairing
This change extends the Bluetooth API to support pairing with the OOB
data that are used in the Authentication Stage of the pairing procedure.
The LE Secure Connections specific API for OOB pairing is also added.
The general OOB API should be able to accomodate the LE legacy pairing
later on.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-05-27 13:50:46 +02:00
Joakim Andersson 710adac50d Bluetooth: host: Add RPA in directed advertisement support
In order to advertise directed to a privacy enabled central the
initiator field of the directed adv packet needs to set to an RPA.
To instruct the controller to use an RPA in the initiator field own
address type should be set to either 0x02 or 0x03.
Since it is not certain that a remote device supports address resolution
of the initiator address we add an option to turn this on and give the
application the responsibility to check if peer supports this.

Fixes #14743

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-04-02 13:19:00 +02:00
Filip Kubicz 1d199181ac Bluetooth: host: Meaningful error codes on advertising start
Translate HCI error codes to POSIX error codes in order to be able to
distinguish reason of connectable advertising start failure.

Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-02-07 12:56:26 +02:00
Johan Hedberg cb2e4b6150 Bluetooth: Fix doxygen parameter reference for bt_le_scan_cb_t
The last parameter is called 'buf' and not 'data'.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-27 21:44:33 -05:00
Johan Hedberg a1ee480bdb Bluetooth: Move BT_ID_DEFAULT macro under the right subgroup
The macro should be under GAP instead of being on the top-level
Bluetooth group.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-27 21:44:33 -05:00
Mariusz Skamra 45411bc08d Bluetooth: Update advertising data without advertising restart
This adds new API fuction to update running advertising data.
It will remove the need of advertising restarting.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-10-29 12:30:34 +02:00
Johan Hedberg 559578c09a Bluetooth: Add API to iterate through existing bonds
So far the stack hasn't provided any way for the application to access
the existing bonds. This patch adds such an API.

Fixes #10122

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-09-24 13:27:26 +03:00
Joakim Andersson 139beac5cf Bluetooth: host: Add set channel map command
Add functionality for setting the host channel classification in
the controller using the HCI command.
This closes issue #9851

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2018-09-19 15:51:57 +03:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Kamil Piszczek 9af28ddc09 Bluetooth: host: directed advertising support
Added implementation to the directed advertising API in the Connection
Management module. Introduced a new connection state for this type of
advertising. The new state is symmetric to the connection state used for
scanning.

Added a new advertising option that can be used to trigger low and high
duty directed advertising. Added macros for default values of
Advertising Parameters, which are used to trigger directed advertising.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2018-09-13 14:21:21 +02:00
David B. Kinder 7b548c42ee doc: fix misspellings in API documentation
Fix misspellings in doxygen API comments missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-28 13:58:22 -04:00
Johan Hedberg 346f815d9e Bluetooth: Introduce bt_id_delete() API
This API makes it possible to delete an existing identity and to flag
its storage slot as unused.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg 7dba2512e3 Bluetooth: Introduce bt_id_reset() API
Add a new API which can be used to reclaim an identity slot for a new
identity. When called, any previous pairings, connections, or other
data will be cleared, and then a new identity will be generated in the
place of the old one.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg e70c556dcc Bluetooth: Add full storage support for multiple identities
Update the storage handling to take into account multiple identities.
We can save a bit of code by using the new bt_id_create() API from
within settings.c.

Also make the treatment of addr & irk parameters to bt_id_create()
consistent, in that NULL is acceptable for both of them.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg 1d8dab811e Bluetooth: Add initial APIs for identity manipulation
Add APIs for getting current identities as well as for creating new
ones.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg 5708f1e8b1 Bluetooth: Add infrastructure to handle multiple identities
Make it possible to have multiple identity addresses as an LE
peripheral. For central role only the default identity is supported
for now. This also extends the flash storage in a backward compatible
way.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
David B. Kinder 9a3d7a43a0 doc: fix misspellings in API docs
Fix doxygen misspellings affecting API documentation missed during
regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-08 01:47:51 -05:00
Luiz Augusto von Dentz 2e2f122d51 Bluetooth: samples: Make use of BT_LE_ADV_OPT_USE_NAME
Use BT_LE_ADV_OPT_USE_NAME whenver possible since it does properly
track updates.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-07-23 14:45:58 +03:00
Luiz Augusto von Dentz acc3e5129e Bluetooth: Add BT_LE_ADV_OPT_USE_NAME
This introduces a new advertising flag BT_LE_ADV_OPT_USE_NAME which can
be used by applications to make the stack automatically include the
Bluetooth Device Name in the Scan Response.

The name is also updated in case there is already an advertising
instance using it.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-07-23 14:45:58 +03:00
Luiz Augusto von Dentz 2637c978fe Bluetooth: Store device name
This uses bt_dev to store the name and allow changing it at runtime, in
addtion to that if CONFIG_BT_SETTINGS is defined make the name
persistent.

Fixes #8357

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-07-23 14:45:58 +03:00
Johan Hedberg 8818244959 Bluetooth: Add helper for parsing advertising data
It is quite easy to implement a buggy or security vulnerable
advertising data parser. Provide a helper for this purpose, which uses
the existing bt_data struct which is used for programming the local
advertising data.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-06-26 19:34:57 +03:00