Commit Graph

1012 Commits

Author SHA1 Message Date
Joakim Andersson ae841d0a11 Bluetooth: host: Add enum for LE read transmit power PHY values
Add enum for LE Read Transmit Power phy values, which are different
form the values used for PHY update procedure since it includes values
for the LE Coded PHY coding schemes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-10 13:33:12 +01:00
Kamil Piszczek fd8d03bd8b bluetooth: conn: add api for getting tx power level
Added a new Bluetooth API that can be used to read the current and
maximum transmit power level of the radio. The reading operation is
performed over HCI.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2020-12-10 13:33:12 +01:00
Kamil Piszczek 87468360b5 bluetooth: uuid: add tx power service uuids
Added UUIDs definitions that are used in the Tx Power Service.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2020-12-10 13:33:12 +01:00
Vinayak Kariappa Chettimada aca176463b Bluetooth: Add helper defines for Extended Advertising parameters
Add helper defines for Extended Advertising parameters that
can be used while creating Extended Advertising sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-03 13:54:25 -05:00
Joakim Andersson fae964c008 Bluetooth: host: Make bt_conn_ref return NULL if the ref count is zero
Make bt_conn_ref return NULL if the reference count has reached zero.
This makes it possible to re-use bt_conn_ref internally to re-use the
reference count mechanism to check if the reference is in use.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-03 13:52:02 +01:00
Wolfgang Puffitsch 9437a6a08d Bluetooth: hci: Add definitions for codec and controller delay info
Add defines and structs for reading information about supported codes,
codec capabilities and controller delays. Return parameter structs for
commands that return multiple variable-length fields only model the
fixed-length fields to minimize inconsistencies.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-11-26 15:46:17 +01:00
Joakim Andersson 8d3b9bae3b Bluetooth: host: Make acl_data extension of bt_buf user data explicit
Clarify that the acl_data struct includes the bt_buf type as the
first variable in the user data struct.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-26 13:15:03 +01:00
Joakim Andersson d76aebcf9c Bluetooth: host: Document functions and macros in addr.h
Document helper functions and definitions in addr.h header.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-26 13:15:03 +01:00
Joakim Andersson 4978c19c05 Bluetooth: host: Refactor out address handling to new file
Refactor implementation of functions defined in addr.h to its own
source file addr.c.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-26 13:15:03 +01:00
Piotr Pryga 2589b7ace2 Bluetooth: controller: hci: Add set connection CTE transmit params
Add implementation of HCI_LE_Set_Connection_CTE_Transmit_Parameters
for Bluetooth 5.1 Direction Finding.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-11-26 13:14:17 +01:00
Piotr Pryga 14890c8eb6 Bluetooth: host: Add read antenna information HCI command
Add Bluetooth 5.1 Direction Finding HCI command:
HCI_LE_Read_Antenna_Information handling to Host.
Add wrapper function to handle send the command
and receive response from Controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-11-26 13:14:17 +01:00
Vinayak Kariappa Chettimada d80d79e7f9 Bluetooth: controller: Use HCI defines for constants
Use HCI defines for PHY, and RSSI constants.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-23 17:01:50 +01:00
Asger Munk Nielsen 3df64a306b Bluetooth: controller: Create HCI stubs for CIG/CIS and ISO tests
Put infrastructure for the following HCI commands/events in place:
* LE Setup ISO Data Path command
* LE Remove ISO Data Path command
* Configure Data Path command
* LE Set CIG Parameters Test command
* LE ISO Read Test Counters command
* LE ISO Receive Test command
* LE ISO Test End command
* LE ISO Transmit Test command

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
2020-11-20 10:56:51 +01:00
Joakim Andersson 58be4c89f6 Bluetooth: host: Document security changed and no security level change
Document the security changed callback can be called with no change
in the security level when the encryption key has been changed
in the link-layer.

Also update the documentation for set security function to include
the bond information so that it matches the documentation for security
changed callback.

Update pairing process to pairing procedure for consistency.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-17 19:40:58 +01:00
Emil Gydesen 919ba04988 Bluetooth: host: Periodic advertiser list support
Adds support for using the periodic advertiser list.
This list allows the application to rely on specific
devices when creating periodic advertising syncs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-16 16:35:44 +01:00
Emil Gydesen 1dada244c1 Bluetooth: host: Periodic Advertising Sync Transfer
Adds support for the periodic advertising sync transfer
(PAST) feature, which allows a synced device, or an
advertiser, to transfer synchronization of a periodic
advertising train to a connected device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-16 13:40:09 +01:00
Joakim Andersson bd7a2fc395 Bluetooth: host: Change directed advertising to privacy-enabled peer
Change the advertising option that controls if the directed advertiser
will use an RPA or the identity address of the peer for the initiator
address.
This option currently has two issues:
 - It behaves differently if the privacy feature has been enabled,
   which can be confusing for application to use.
 - It cannot start a directed advertiser towards a peer that is not
   privacy-enabled and has distributed an IRK.

This commit includes the following changes:
 - When privacy has been enabled in order to advertise towards a
   privacy-enabled peer the BT_LE_ADV_OPT_DIR_ADDR_RPA option must now
   be set (same as when privacy has been disabled).
 - It is now possible to start a directed advertiser using the identity
   address of the peer when privacy-enabled.
 - When privacy has been enabled the advertising option combination
   of using the local identity address and an RPA as the initiator
   address is now disallowed and will return an error code.
   This is done because this combination did not actually work and would
   have used the identity address of the peer instead.
 - If the controller does not support controller-based privacy then
   using the option BT_LE_ADV_OPT_DIR_ADDR_RPA will return ENOTSUP
   because this behavior cannot be done with host-based privacy.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-11 13:22:02 +01:00
Jordan Yates ffab099eb9 Bluetooth: add destroy callback to indication
Adds a `destroy` callback to the `struct bt_gatt_indicate_params` which
is used to signify to the application that the indication operation has
completed and the struct instance can be freed/destroyed.

This is required as the number of indication value callbacks that will
be triggered is not known by the caller when the `conn` parameter is
`NULL`.

Tracking when this callback should be run is mananged by a private
reference counter inside the struct.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-11-10 11:21:46 +01:00
Jordan Yates 170f17e0e7 Bluetooth: indication callback signature update
Update the signature of the `bt_gatt_indicate_func_t` callback type by
replacing the attr pointer with a pointer to the
`bt_gatt_indicate_params` struct that was used to start the indication.

This allows the callback to free the `bt_gatt_indicate_params` instance
if it was allocated from storage, while still allowing the
`bt_gatt_attr` value to be accessed through `params->attr`.

Allocating the `bt_gatt_indicate_params` instance from storage is
desirable as multiple indications can be queued, however each instance
must be valid until the callback is run.

Implements API update from #29357

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-11-10 11:21:46 +01:00
Trond Einar Snekvik ad2fd44d7a Bluetooth: Mesh: Encapsulate feature config
Moves mesh feature configuration to a separate module, deprecating the
bt_mesh_cfg_srv structure. The initial values for the features should
now be enabled through KConfig, where new config entries have been added
for each feature.

This removes the upward dependency on the config server from the core
stack, and makes the config server a pure frontend for the configuration
states, as all spec mandated behavior around the feature states is now
encapsulated.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-09 11:23:34 +02:00
Trond Einar Snekvik 8e284750c8 Bluetooth: Mesh: Document Heartbeat
Adds public documentation for the Heartbeat feature in a separate page
under Bluetooth Mesh.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-09 11:23:34 +02:00
Trond Einar Snekvik 0dc9e5cd96 Bluetooth: Mesh: Move heartbeat to separate module
Encapsulates the Heartbeat state and functionality in a separate
heartbeat module, removing all manipulation of the heartbeat state from
the transport and config server modules.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-09 11:23:34 +02:00
Emil Gydesen 12ceb6c195 Bluetooth: host: Handle PA sync cancel event
The sync established event caused by a cancel by the host
was not properly handled. When cancelling the sync established
event is created, and the sync object should not be deleted
before that event is received.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-03 11:04:07 +01:00
Joakim Andersson 92deb9ddba Bluetooth: host: Document and check for disallowed directed advertising
Document and validate advertising parameters for the disallowed
advertising mode high duty cycle directed connectable advertising
using extended advertising PDUs.

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

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2020-10-29 14:13:36 +02:00
Lingao Meng 5374245dd6 Bluetooth: Mesh: split prov.c into two separate modules
Currently all provisioning procedure into common source
files call `prov.c`, that will not compile separately.

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

Add more provisioner OOB authentication method.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-28 12:53:09 +02:00
Joakim Andersson f2a23ee166 Bluetooth: host: Document peripheral bt_conn_le_conn_update behavior
Document the behavior of the bt_conn_le_conn_update API when the
local device is the peripheral role.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-26 16:16:35 +02:00
Lingao Meng 27739fcc43 Bluetooth: Mesh: Add queue_size and recv_win to lpn_cb
Add Queue Size and Receive Window information to lpn
callback function to notify upper layer to determine
currently friend node information, which may be used
in future.

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

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

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-10-24 10:57:45 +03:00
Joakim Andersson 6ae68c48f4 Bluetooth: UUID: Document endianness in UUID helper macros
Improve the documentation of the UUID header by adding documentation
for all helper macros.
Be explicit in which macros that expects host endianness, and which
ones that expects little endian format.

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

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

Part of #27842.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-10-22 14:36:02 +03:00
Emil Gydesen 44f00358a6 Bluetooth: host: PA sync receive enable/disable
Adds support for enabling/disabling PA sync receive,
which allows applications to control when to receive data
while a sync is established.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-22 13:28:41 +02:00
Emil Gydesen 8640eec822 Bluetooth: Added BT_UUID size macros
Added macros that denote the different allowed UUID sizes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-21 16:31:25 +02:00
Emil Gydesen 68153f048d Bluetooth: controller: HCI stubs for BIG commands
Adds initial HCI stubs for the BIG commands to be used for
broadcast isochronous channels.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-19 18:59:49 +02:00
Peter Bigot 56c3c11d6a bluetooth: add helper for advertising with identity
Document the distinction between the existing non-connectable
advertising configurations, and add one that uses identity which will
be the same for all beacons.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-10-15 22:22:16 +03:00
Joakim Andersson ea273100ef Bluetooth: host: Add advertising options to disable channel
Add advertising options to disable the individual advertising
channel 37, 38 and 39 per advertising instance.

Fixes: #26732

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-15 13:21:26 +03:00
Joakim Andersson b322fa2f34 Bluetooth: GATT: Document use of attribute parameter in discovery cb
Document which fields in the attribute parameter in the discovery
callback contains valid information.
Document the type of the user_data so that the application can cast
this to a valid type in order to retrieve the information.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-15 11:08:48 +02:00
Joakim Andersson 24f62eeea1 Bluetooth: GATT: Use UUID of attribute to check for a characteristic
Update check in the bt_gatt_attr_value_handle API function to use the
UUID of the function, in case the attribute has been declared with a
different read handler, or the attribute is a temporary object
where the read attribute has not been set.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-15 11:08:48 +02:00
Joakim Andersson da5ea438c7 Bluetooth: GATT: Add init macro for struct bt_gatt_chrc
Add init macro for struct bt_gatt_chrc so that it can be re-used
other places.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-15 11:08:48 +02:00
Joakim Andersson 1c21808808 Bluetooth: GATT: Fix alignment of bt_gatt_resubscribe parameters
Fix alignment of bt_gatt_resubscribe parameters.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-14 18:43:00 +02:00
Joakim Andersson 5c5cc87d74 Bluetooth: GATT: Move struct documentation inline
Move struct documentation of member variables to inline documentation,
which is consistent with the rest of the struct definitions.

Removes documentation of a struct variable that does not exist for
bt_gatt_ccc_cfg.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-14 18:43:00 +02:00
Joakim Andersson e000c0a74a Bluetooth: GATT: Remove struct member variables alignment.
Remove struct member alignment that has become broken by the search
and replace of the uintX_t vs uX_t types.
Remove the alignment since maintaining this causes annoying whitespace
changes when a new variable is added with a longer type name.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-10-14 18:43:00 +02:00
Vinayak Kariappa Chettimada 552fa84cc8 Bluetooth: HCI: Add the missing set per adv receive enable definition
Add the missing LE Set Periodic Advertising Receive Enable
command definition.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-07 17:45:23 +02:00
Emil Gydesen 8cc051ccac Bluetooth: host: Change PA sync callbacks to global callbacks
Changes the callbacks for periodic sync callbacks such that multiple
applications can register callbacks, similar to the connection and
scan callbacks.

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

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-10-02 11:49:13 +02:00
Peter A. Bigot 776e0db03d bluetooth: att: provide named constant for successful result
BT_HCI_ERR and BT_SECURITY_ERR both define success constants which can
be used to check the results and make the intended value domain clear.
Add the same for ATT error values.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-10-02 11:45:03 +02:00
YanBiao Hao dc89bfcc7f Bluetooth: Mesh: Config Client network transmit set/get API
Get/Set network transmit parameter of a node.

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2020-10-02 11:30:12 +02:00
Luiz Augusto von Dentz 0c1fa00340 Bluetooth: L2CAP: Document behavior of alloc_buf
Channel that requires segmentation must set alloc_buf in order for the
stack to be able to reassemble segments of an SDU.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-22 10:56:27 +03:00
Luiz Augusto von Dentz 9efd93adde Bluetooth: UUID: Fix BT_UUID_ES_TRIGGER_SETTING
BT_UUID_ES_TRIGGER_SETTING was incorrectly using
BT_UUID_ES_MEASUREMENT_VAL as value instead of
BT_UUID_ES_TRIGGER_SETTING_VAL.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-21 17:15:19 +03:00
Fabio Utzig c5a7e15fd8 doc: update bluetooth to use @option ALIAS
The bluetooth.h header file uses a different tabulation style in the
documentation headers, which for recent Doxygen versions generates
verbatim blocks. This disables usage of the @option ALIAS because
verbatim blocks cannot be nested. With this commit the documentation's
tabulation is fixed and `@option` is used to resolve Kconfig options.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-09-15 15:25:01 +02:00
Fabio Utzig 39fa56b834 doc: update Kconfig options to use @option ALIAS
This updates Kconfig options in the Doxygen documentation to use the new
@option ALIAS. There are three categories of fixes:

* Use of `:option:` inside Doxygen headers, which is not valid (this is
  rST syntax!).
* Kconfig options that were just written as plain text and were no
  references were generated.
* Use of `@rst` blocks where the only reason for using them was to have
  Kconfig options resolved.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-09-15 15:25:01 +02:00
Luiz Augusto von Dentz 95cec8354c Bluetooth: GATT: Introduce bt_gatt_attr_get_handle
This introduces bt_gatt_attr_get_handle which can be used to resolve
handles of static attributes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-05 11:06:21 +02:00