2015-07-01 16:47:13 -04:00
|
|
|
/** @file
|
2015-06-16 17:38:26 +03:00
|
|
|
* @brief Bluetooth subsystem core APIs.
|
|
|
|
*/
|
2015-04-14 14:38:13 +03:00
|
|
|
|
|
|
|
/*
|
2017-03-15 11:19:27 +01:00
|
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
2016-06-10 12:10:18 +03:00
|
|
|
* Copyright (c) 2015-2016 Intel Corporation
|
2015-04-14 14:38:13 +03:00
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-14 14:38:13 +03:00
|
|
|
*/
|
2018-09-14 10:43:44 -07:00
|
|
|
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_BLUETOOTH_H_
|
|
|
|
#define ZEPHYR_INCLUDE_BLUETOOTH_BLUETOOTH_H_
|
2015-04-14 14:38:13 +03:00
|
|
|
|
2016-05-16 19:54:24 +03:00
|
|
|
/**
|
|
|
|
* @brief Bluetooth APIs
|
|
|
|
* @defgroup bluetooth Bluetooth APIs
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-07-23 11:35:59 +02:00
|
|
|
#include <stdbool.h>
|
2015-06-17 15:46:38 +02:00
|
|
|
#include <string.h>
|
2019-06-26 10:33:55 -04:00
|
|
|
#include <sys/util.h>
|
2016-07-19 13:58:02 +03:00
|
|
|
#include <net/buf.h>
|
2019-10-16 12:00:16 +02:00
|
|
|
#include <bluetooth/gap.h>
|
2019-10-16 12:09:26 +02:00
|
|
|
#include <bluetooth/addr.h>
|
2017-03-16 10:50:04 +02:00
|
|
|
#include <bluetooth/crypto.h>
|
2015-04-14 15:04:46 +03:00
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-01-27 20:05:13 +02:00
|
|
|
/**
|
|
|
|
* @brief Generic Access Profile
|
|
|
|
* @defgroup bt_gap Generic Access Profile
|
|
|
|
* @ingroup bluetooth
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @def BT_ID_DEFAULT
|
2018-07-04 12:58:10 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Convenience macro for specifying the default identity. This helps
|
|
|
|
* make the code more readable, especially when only one identity is
|
|
|
|
* supported.
|
2018-07-04 12:58:10 +03:00
|
|
|
*/
|
|
|
|
#define BT_ID_DEFAULT 0
|
|
|
|
|
2020-02-01 18:27:39 +01:00
|
|
|
/** Opaque type representing an advertiser. */
|
|
|
|
struct bt_le_ext_adv;
|
|
|
|
|
2020-05-06 22:38:23 +02:00
|
|
|
/** Opaque type representing an periodic advertising sync. */
|
|
|
|
struct bt_le_per_adv_sync;
|
|
|
|
|
2020-02-01 18:27:39 +01:00
|
|
|
/* Don't require everyone to include conn.h */
|
|
|
|
struct bt_conn;
|
|
|
|
|
2020-08-12 14:22:51 +02:00
|
|
|
/* Don't require everyone to include iso.h */
|
|
|
|
struct bt_iso_biginfo;
|
|
|
|
|
2021-04-22 11:10:43 +02:00
|
|
|
/* Don't require everyone to include direction.h */
|
|
|
|
struct bt_df_per_adv_sync_iq_samples_report;
|
|
|
|
|
2020-02-01 18:27:39 +01:00
|
|
|
struct bt_le_ext_adv_sent_info {
|
|
|
|
/** The number of advertising events completed. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t num_sent;
|
2020-02-01 18:27:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_ext_adv_connected_info {
|
|
|
|
/** Connection object of the new connection */
|
|
|
|
struct bt_conn *conn;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_ext_adv_scanned_info {
|
|
|
|
/** Active scanner LE address and type */
|
|
|
|
bt_addr_le_t *addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_ext_adv_cb {
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief The advertising set has finished sending adv data.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This callback notifies the application that the advertising set has
|
|
|
|
* finished sending advertising data.
|
|
|
|
* The advertising set can either have been stopped by a timeout or
|
|
|
|
* because the specified number of advertising events has been reached.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv The advertising set object.
|
|
|
|
* @param info Information about the sent event.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
void (*sent)(struct bt_le_ext_adv *adv,
|
|
|
|
struct bt_le_ext_adv_sent_info *info);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief The advertising set has accepted a new connection.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This callback notifies the application that the advertising set has
|
|
|
|
* accepted a new connection.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv The advertising set object.
|
|
|
|
* @param info Information about the connected event.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
void (*connected)(struct bt_le_ext_adv *adv,
|
|
|
|
struct bt_le_ext_adv_connected_info *info);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief The advertising set has sent scan response data.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This callback notifies the application that the advertising set has
|
|
|
|
* has received a Scan Request packet, and has sent a Scan Response
|
|
|
|
* packet.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv The advertising set object.
|
|
|
|
* @param addr Information about the scanned event.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
void (*scanned)(struct bt_le_ext_adv *adv,
|
|
|
|
struct bt_le_ext_adv_scanned_info *info);
|
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @typedef bt_ready_cb_t
|
|
|
|
* @brief Callback for notifying that Bluetooth has been enabled.
|
2015-06-12 14:25:28 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param err zero on success or (negative) error code otherwise.
|
2015-07-28 18:23:19 +03:00
|
|
|
*/
|
|
|
|
typedef void (*bt_ready_cb_t)(int err);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Enable Bluetooth
|
2015-07-28 18:23:19 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Enable Bluetooth. Must be the called before any calls that
|
|
|
|
* require communication with the local Bluetooth hardware.
|
2015-07-28 18:23:19 +03:00
|
|
|
*
|
2021-06-28 17:13:40 +02:00
|
|
|
* When @kconfig{CONFIG_BT_SETTINGS} has been enabled and the application is not
|
2021-06-16 09:53:04 +02:00
|
|
|
* managing identities of the stack itself then the application must call
|
|
|
|
* @ref settings_load() before the stack is fully enabled.
|
|
|
|
* See @ref bt_id_create() for more information.
|
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param cb Callback to notify completion or NULL to perform the
|
|
|
|
* enabling synchronously.
|
2015-06-12 14:25:28 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2015-06-12 14:25:28 +03:00
|
|
|
*/
|
2015-07-28 18:23:19 +03:00
|
|
|
int bt_enable(bt_ready_cb_t cb);
|
2015-04-14 14:38:13 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Set Bluetooth Device Name
|
2018-07-09 15:12:04 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Set Bluetooth GAP Device Name.
|
2018-07-09 15:12:04 +03:00
|
|
|
*
|
2021-02-22 15:21:46 +01:00
|
|
|
* When advertising with device name in the advertising data the name should
|
|
|
|
* be updated by calling @ref bt_le_adv_update_data or
|
|
|
|
* @ref bt_le_ext_adv_set_data.
|
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param name New name
|
2018-07-09 15:12:04 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2018-07-09 15:12:04 +03:00
|
|
|
*/
|
|
|
|
int bt_set_name(const char *name);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get Bluetooth Device Name
|
2018-07-09 15:12:04 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Get Bluetooth GAP Device Name.
|
2018-07-09 15:12:04 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Bluetooth Device Name
|
2018-07-09 15:12:04 +03:00
|
|
|
*/
|
|
|
|
const char *bt_get_name(void);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get the currently configured identities.
|
2018-07-13 12:04:39 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Returns an array of the currently configured identity addresses. To
|
|
|
|
* make sure all available identities can be retrieved, the number of
|
|
|
|
* elements in the @a addrs array should be CONFIG_BT_ID_MAX. The identity
|
|
|
|
* identifier that some APIs expect (such as advertising parameters) is
|
|
|
|
* simply the index of the identity in the @a addrs array.
|
2018-07-13 12:04:39 +03:00
|
|
|
*
|
2020-12-15 18:45:45 +05:30
|
|
|
* If @a addrs is passed as NULL, then returned @a count contains the
|
|
|
|
* count of all available identities that can be retrieved with a
|
|
|
|
* subsequent call to this function with non-NULL @a addrs parameter.
|
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Deleted identities may show up as BT_LE_ADDR_ANY in the returned
|
|
|
|
* array.
|
2018-08-02 11:25:57 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param addrs Array where to store the configured identities.
|
|
|
|
* @param count Should be initialized to the array size. Once the function
|
|
|
|
* returns it will contain the number of returned identities.
|
2018-07-13 12:04:39 +03:00
|
|
|
*/
|
|
|
|
void bt_id_get(bt_addr_le_t *addrs, size_t *count);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Create a new identity.
|
|
|
|
*
|
|
|
|
* Create a new identity using the given address and IRK. This function
|
|
|
|
* can be called before calling bt_enable(), in which case it can be used
|
|
|
|
* to override the controller's public address (in case it has one). However,
|
|
|
|
* the new identity will only be stored persistently in flash when this API
|
|
|
|
* is used after bt_enable(). The reason is that the persistent settings
|
|
|
|
* are loaded after bt_enable() and would therefore cause potential conflicts
|
|
|
|
* with the stack blindly overwriting what's stored in flash. The identity
|
|
|
|
* will also not be written to flash in case a pre-defined address is
|
|
|
|
* provided, since in such a situation the app clearly has some place it got
|
|
|
|
* the address from and will be able to repeat the procedure on every power
|
|
|
|
* cycle, i.e. it would be redundant to also store the information in flash.
|
|
|
|
*
|
2021-01-19 15:39:41 +01:00
|
|
|
* Generating random static address or random IRK is not supported when calling
|
|
|
|
* this function before bt_enable().
|
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* If the application wants to have the stack randomly generate identities
|
|
|
|
* and store them in flash for later recovery, the way to do it would be
|
|
|
|
* to first initialize the stack (using bt_enable), then call settings_load(),
|
|
|
|
* and after that check with bt_id_get() how many identities were recovered.
|
|
|
|
* If an insufficient amount of identities were recovered the app may then
|
|
|
|
* call bt_id_create() to create new ones.
|
|
|
|
*
|
|
|
|
* @param addr Address to use for the new identity. If NULL or initialized
|
2021-01-19 15:39:41 +01:00
|
|
|
* to BT_ADDR_LE_ANY the stack will generate a new random
|
|
|
|
* static address for the identity and copy it to the given
|
2020-09-11 10:45:31 -03:00
|
|
|
* parameter upon return from this function (in case the
|
|
|
|
* parameter was non-NULL).
|
|
|
|
* @param irk Identity Resolving Key (16 bytes) to be used with this
|
|
|
|
* identity. If set to all zeroes or NULL, the stack will
|
|
|
|
* generate a random IRK for the identity and copy it back
|
|
|
|
* to the parameter upon return from this function (in case
|
|
|
|
* the parameter was non-NULL). If privacy
|
2021-06-28 17:13:40 +02:00
|
|
|
* @kconfig{CONFIG_BT_PRIVACY} is not enabled this parameter must
|
2020-09-11 10:45:31 -03:00
|
|
|
* be NULL.
|
|
|
|
*
|
|
|
|
* @return Identity identifier (>= 0) in case of success, or a negative
|
|
|
|
* error code on failure.
|
2018-07-13 12:04:39 +03:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_id_create(bt_addr_le_t *addr, uint8_t *irk);
|
2018-07-13 12:04:39 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Reset/reclaim an identity for reuse.
|
|
|
|
*
|
|
|
|
* The semantics of the @a addr and @a irk parameters of this function
|
|
|
|
* are the same as with bt_id_create(). The difference is the first
|
|
|
|
* @a id parameter that needs to be an existing identity (if it doesn't
|
|
|
|
* exist this function will return an error). When given an existing
|
|
|
|
* identity this function will disconnect any connections created using it,
|
|
|
|
* remove any pairing keys or other data associated with it, and then create
|
|
|
|
* a new identity in the same slot, based on the @a addr and @a irk
|
|
|
|
* parameters.
|
|
|
|
*
|
|
|
|
* @note the default identity (BT_ID_DEFAULT) cannot be reset, i.e. this
|
|
|
|
* API will return an error if asked to do that.
|
|
|
|
*
|
|
|
|
* @param id Existing identity identifier.
|
|
|
|
* @param addr Address to use for the new identity. If NULL or initialized
|
|
|
|
* to BT_ADDR_LE_ANY the stack will generate a new static
|
|
|
|
* random address for the identity and copy it to the given
|
|
|
|
* parameter upon return from this function (in case the
|
|
|
|
* parameter was non-NULL).
|
|
|
|
* @param irk Identity Resolving Key (16 bytes) to be used with this
|
|
|
|
* identity. If set to all zeroes or NULL, the stack will
|
|
|
|
* generate a random IRK for the identity and copy it back
|
|
|
|
* to the parameter upon return from this function (in case
|
|
|
|
* the parameter was non-NULL). If privacy
|
2021-06-28 17:13:40 +02:00
|
|
|
* @kconfig{CONFIG_BT_PRIVACY} is not enabled this parameter must
|
2020-09-11 10:45:31 -03:00
|
|
|
* be NULL.
|
|
|
|
*
|
|
|
|
* @return Identity identifier (>= 0) in case of success, or a negative
|
|
|
|
* error code on failure.
|
2018-07-18 13:47:04 +03:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk);
|
2018-07-18 13:47:04 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Delete an identity.
|
2018-08-02 11:25:57 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* When given a valid identity this function will disconnect any connections
|
|
|
|
* created using it, remove any pairing keys or other data associated with
|
|
|
|
* it, and then flag is as deleted, so that it can not be used for any
|
|
|
|
* operations. To take back into use the slot the identity was occupying the
|
|
|
|
* bt_id_reset() API needs to be used.
|
2018-08-02 11:25:57 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note the default identity (BT_ID_DEFAULT) cannot be deleted, i.e. this
|
|
|
|
* API will return an error if asked to do that.
|
2018-08-02 11:25:57 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param id Existing identity identifier.
|
2018-08-02 11:25:57 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return 0 in case of success, or a negative error code on failure.
|
2018-08-02 11:25:57 +03:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_id_delete(uint8_t id);
|
2018-08-02 11:25:57 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Bluetooth data.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Description of different data types that can be encoded into
|
|
|
|
* advertising data. Used to form arrays that are passed to the
|
|
|
|
* bt_le_adv_start() function.
|
2020-03-17 10:32:20 +01:00
|
|
|
*/
|
2016-01-13 12:53:54 +02:00
|
|
|
struct bt_data {
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t data_len;
|
|
|
|
const uint8_t *data;
|
2016-01-13 12:53:54 +02:00
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Helper to declare elements of bt_data arrays
|
2016-01-30 13:51:22 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This macro is mainly for creating an array of struct bt_data
|
|
|
|
* elements which is then passed to e.g. @ref bt_le_adv_start().
|
2016-01-30 13:51:22 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _type Type of advertising data field
|
|
|
|
* @param _data Pointer to the data field payload
|
|
|
|
* @param _data_len Number of bytes behind the _data pointer
|
2016-01-30 13:51:22 +02:00
|
|
|
*/
|
2016-01-13 12:53:54 +02:00
|
|
|
#define BT_DATA(_type, _data, _data_len) \
|
2016-01-30 13:51:22 +02:00
|
|
|
{ \
|
|
|
|
.type = (_type), \
|
|
|
|
.data_len = (_data_len), \
|
2020-05-27 11:26:57 -05:00
|
|
|
.data = (const uint8_t *)(_data), \
|
2016-01-30 13:51:22 +02:00
|
|
|
}
|
2015-04-30 16:07:09 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Helper to declare elements of bt_data arrays
|
2016-01-30 13:51:22 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This macro is mainly for creating an array of struct bt_data
|
|
|
|
* elements which is then passed to e.g. @ref bt_le_adv_start().
|
2016-01-30 13:51:22 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _type Type of advertising data field
|
|
|
|
* @param _bytes Variable number of single-byte parameters
|
2016-01-30 13:51:22 +02:00
|
|
|
*/
|
2016-01-30 13:26:23 +02:00
|
|
|
#define BT_DATA_BYTES(_type, _bytes...) \
|
2020-05-27 11:26:57 -05:00
|
|
|
BT_DATA(_type, ((uint8_t []) { _bytes }), \
|
|
|
|
sizeof((uint8_t []) { _bytes }))
|
2016-01-30 13:26:23 +02:00
|
|
|
|
2016-05-02 15:18:28 +02:00
|
|
|
/** Advertising options */
|
2015-12-07 08:11:41 +02:00
|
|
|
enum {
|
2016-06-27 10:31:51 +03:00
|
|
|
/** Convenience value when no options are specified. */
|
|
|
|
BT_LE_ADV_OPT_NONE = 0,
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise as connectable.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Advertise as connectable. If not connectable then the type of
|
|
|
|
* advertising is determined by providing scan response data.
|
|
|
|
* The advertiser address is determined by the type of advertising
|
2021-06-28 17:13:40 +02:00
|
|
|
* and/or enabling privacy @kconfig{CONFIG_BT_PRIVACY}.
|
2016-04-04 12:55:11 +03:00
|
|
|
*/
|
2016-05-02 15:18:28 +02:00
|
|
|
BT_LE_ADV_OPT_CONNECTABLE = BIT(0),
|
2017-06-29 14:13:39 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise one time.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Don't try to resume connectable advertising after a connection.
|
|
|
|
* This option is only meaningful when used together with
|
|
|
|
* BT_LE_ADV_OPT_CONNECTABLE. If set the advertising will be stopped
|
|
|
|
* when bt_le_adv_stop() is called or when an incoming (slave)
|
|
|
|
* connection happens. If this option is not set the stack will
|
|
|
|
* take care of keeping advertising enabled even as connections
|
|
|
|
* occur.
|
|
|
|
* If Advertising directed or the advertiser was started with
|
|
|
|
* @ref bt_le_ext_adv_start then this behavior is the default behavior
|
|
|
|
* and this flag has no effect.
|
2017-06-29 14:13:39 +03:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_ONE_TIME = BIT(1),
|
2018-03-20 16:57:00 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise using identity address.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Advertise using the identity address as the advertiser address.
|
|
|
|
* @warning This will compromise the privacy of the device, so care
|
|
|
|
* must be taken when using this option.
|
|
|
|
* @note The address used for advertising will not be the same as
|
|
|
|
* returned by @ref bt_le_oob_get_local, instead @ref bt_id_get
|
|
|
|
* should be used to get the LE address.
|
2018-03-20 16:57:00 +02:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_USE_IDENTITY = BIT(2),
|
2018-07-10 10:14:23 +03:00
|
|
|
|
2021-02-22 15:21:46 +01:00
|
|
|
/** Advertise using GAP device name.
|
|
|
|
*
|
|
|
|
* Include the GAP device name automatically when advertising.
|
|
|
|
* By default the GAP device name is put at the end of the scan
|
|
|
|
* response data.
|
|
|
|
* When advertising using @ref BT_LE_ADV_OPT_EXT_ADV and not
|
|
|
|
* @ref BT_LE_ADV_OPT_SCANNABLE then it will be put at the end of the
|
|
|
|
* advertising data.
|
|
|
|
* If the GAP device name does not fit into advertising data it will be
|
|
|
|
* converted to a shortened name if possible.
|
2021-04-16 11:57:45 +01:00
|
|
|
* @ref BT_LE_ADV_OPT_FORCE_NAME_IN_AD can be used to force the device
|
|
|
|
* name to appear in the advertising data of an advert with scan
|
|
|
|
* response data.
|
2021-02-22 15:21:46 +01:00
|
|
|
*
|
|
|
|
* The application can set the device name itself by including the
|
|
|
|
* following in the advertising data.
|
|
|
|
* @code
|
|
|
|
* BT_DATA(BT_DATA_NAME_COMPLETE, name, strlen(name))
|
|
|
|
* @endcode
|
|
|
|
*/
|
2018-07-10 10:14:23 +03:00
|
|
|
BT_LE_ADV_OPT_USE_NAME = BIT(3),
|
2018-08-20 14:44:42 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Low duty cycle directed advertising.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Use low duty directed advertising mode, otherwise high duty mode
|
|
|
|
* will be used.
|
2018-08-20 14:44:42 +02:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY = BIT(4),
|
2019-03-28 15:18:23 +01:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Directed advertising to privacy-enabled peer.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Enable use of Resolvable Private Address (RPA) as the target address
|
2020-11-05 10:53:19 +01:00
|
|
|
* in directed advertisements.
|
2020-09-11 10:45:31 -03:00
|
|
|
* This is required if the remote device is privacy-enabled and
|
|
|
|
* supports address resolution of the target address in directed
|
|
|
|
* advertisement.
|
|
|
|
* It is the responsibility of the application to check that the remote
|
|
|
|
* device supports address resolution of directed advertisements by
|
|
|
|
* reading its Central Address Resolution characteristic.
|
2019-03-28 15:18:23 +01:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_DIR_ADDR_RPA = BIT(5),
|
2019-07-22 13:13:38 +02:00
|
|
|
|
2020-04-28 19:47:46 +02:00
|
|
|
/** Use whitelist to filter devices that can request scan response data.
|
2019-07-22 13:13:38 +02:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_FILTER_SCAN_REQ = BIT(6),
|
|
|
|
|
2019-08-15 09:39:09 +03:00
|
|
|
/** Use whitelist to filter devices that can connect. */
|
2019-07-22 13:13:38 +02:00
|
|
|
BT_LE_ADV_OPT_FILTER_CONN = BIT(7),
|
2020-02-01 18:27:39 +01:00
|
|
|
|
|
|
|
/** Notify the application when a scan response data has been sent to an
|
|
|
|
* active scanner.
|
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_NOTIFY_SCAN_REQ = BIT(8),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Support scan response data.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* When used together with @ref BT_LE_ADV_OPT_EXT_ADV then this option
|
|
|
|
* cannot be used together with the @ref BT_LE_ADV_OPT_CONNECTABLE
|
|
|
|
* option.
|
|
|
|
* When used together with @ref BT_LE_ADV_OPT_EXT_ADV then scan
|
|
|
|
* response data must be set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_SCANNABLE = BIT(9),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise with extended advertising.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This options enables extended advertising in the advertising set.
|
|
|
|
* In extended advertising the advertising set will send a small header
|
|
|
|
* packet on the three primary advertising channels. This small header
|
|
|
|
* points to the advertising data packet that will be sent on one of
|
|
|
|
* the 37 secondary advertising channels.
|
|
|
|
* The advertiser will send primary advertising on LE 1M PHY, and
|
|
|
|
* secondary advertising on LE 2M PHY.
|
|
|
|
* Connections will be established on LE 2M PHY.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Without this option the advertiser will send advertising data on the
|
|
|
|
* three primary advertising channels.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Enabling this option requires extended advertising support in
|
|
|
|
* the peer devices scanning for advertisement packets.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_EXT_ADV = BIT(10),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Disable use of LE 2M PHY on the secondary advertising
|
|
|
|
* channel.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Disabling the use of LE 2M PHY could be necessary if scanners don't
|
|
|
|
* support the LE 2M PHY.
|
|
|
|
* The advertiser will send primary advertising on LE 1M PHY, and
|
|
|
|
* secondary advertising on LE 1M PHY.
|
|
|
|
* Connections will be established on LE 1M PHY.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Cannot be set if BT_LE_ADV_OPT_CODED is set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_NO_2M = BIT(11),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise on the LE Coded PHY (Long Range).
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* The advertiser will send both primary and secondary advertising
|
|
|
|
* on the LE Coded PHY. This gives the advertiser increased range with
|
|
|
|
* the trade-off of lower data rate and higher power consumption.
|
|
|
|
* Connections will be established on LE Coded PHY.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_CODED = BIT(12),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise without a device address (identity or RPA).
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_ANONYMOUS = BIT(13),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise with transmit power.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_USE_TX_POWER = BIT(14),
|
2020-09-29 13:49:41 +02:00
|
|
|
|
|
|
|
/** Disable advertising on channel index 37. */
|
|
|
|
BT_LE_ADV_OPT_DISABLE_CHAN_37 = BIT(15),
|
|
|
|
|
|
|
|
/** Disable advertising on channel index 38. */
|
|
|
|
BT_LE_ADV_OPT_DISABLE_CHAN_38 = BIT(16),
|
|
|
|
|
|
|
|
/** Disable advertising on channel index 39. */
|
|
|
|
BT_LE_ADV_OPT_DISABLE_CHAN_39 = BIT(17),
|
2021-04-16 11:57:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Put GAP device name into advert data
|
|
|
|
*
|
|
|
|
* Will place the GAP device name into the advertising data rather
|
|
|
|
* than the scan response data.
|
|
|
|
*
|
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_USE_NAME
|
|
|
|
*/
|
|
|
|
BT_LE_ADV_OPT_FORCE_NAME_IN_AD = BIT(18),
|
2015-12-07 08:11:41 +02:00
|
|
|
};
|
|
|
|
|
2015-12-05 21:50:43 +02:00
|
|
|
/** LE Advertising Parameters. */
|
2015-12-03 15:27:19 +02:00
|
|
|
struct bt_le_adv_param {
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Local identity.
|
2020-04-18 18:30:12 +02:00
|
|
|
*
|
2021-06-28 17:13:40 +02:00
|
|
|
* @note When extended advertising @kconfig{CONFIG_BT_EXT_ADV} is not
|
2020-09-11 10:45:31 -03:00
|
|
|
* enabled or not supported by the controller it is not possible
|
|
|
|
* to scan and advertise simultaneously using two different
|
|
|
|
* random addresses.
|
2020-04-18 18:30:12 +02:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t id;
|
2018-07-04 12:58:10 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertising Set Identifier, valid range 0x00 - 0x0f.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
|
2020-02-01 18:27:39 +01:00
|
|
|
**/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t sid;
|
2020-02-01 18:27:39 +01:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Secondary channel maximum skip count.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Maximum advertising events the advertiser can skip before it must
|
|
|
|
* send advertising data on the secondary advertising channel.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t secondary_max_skip;
|
2020-02-01 18:27:39 +01:00
|
|
|
|
2016-05-02 15:18:28 +02:00
|
|
|
/** Bit-field of advertising options */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t options;
|
2015-12-07 08:11:41 +02:00
|
|
|
|
2021-01-18 19:07:58 +03:00
|
|
|
/** Minimum Advertising Interval (N * 0.625 milliseconds)
|
|
|
|
* Minimum Advertising Interval shall be less than or equal to the
|
|
|
|
* Maximum Advertising Interval. The Minimum Advertising Interval and
|
|
|
|
* Maximum Advertising Interval should not be the same value (as stated
|
|
|
|
* in Bluetooth Core Spec 5.2, section 7.8.5)
|
|
|
|
* Range: 0x0020 to 0x4000
|
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t interval_min;
|
2015-12-05 21:50:43 +02:00
|
|
|
|
2021-01-18 19:07:58 +03:00
|
|
|
/** Maximum Advertising Interval (N * 0.625 milliseconds)
|
|
|
|
* Minimum Advertising Interval shall be less than or equal to the
|
|
|
|
* Maximum Advertising Interval. The Minimum Advertising Interval and
|
|
|
|
* Maximum Advertising Interval should not be the same value (as stated
|
|
|
|
* in Bluetooth Core Spec 5.2, section 7.8.5)
|
|
|
|
* Range: 0x0020 to 0x4000
|
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t interval_max;
|
2020-04-09 20:06:02 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Directed advertising to peer
|
2020-04-09 20:06:02 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* When this parameter is set the advertiser will send directed
|
|
|
|
* advertising to the remote device.
|
2020-04-09 20:06:02 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* The advertising type will either be high duty cycle, or low duty
|
|
|
|
* cycle if the BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY option is enabled.
|
2020-10-26 13:09:08 +01:00
|
|
|
* When using @ref BT_LE_ADV_OPT_EXT_ADV then only low duty cycle is
|
|
|
|
* allowed.
|
2020-04-09 20:06:02 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* In case of connectable high duty cycle if the connection could not
|
|
|
|
* be established within the timeout the connected() callback will be
|
|
|
|
* called with the status set to @ref BT_HCI_ERR_ADV_TIMEOUT.
|
2020-04-09 20:06:02 +02:00
|
|
|
*/
|
|
|
|
const bt_addr_le_t *peer;
|
2015-12-03 15:27:19 +02:00
|
|
|
};
|
|
|
|
|
2020-05-01 16:51:17 +02:00
|
|
|
|
|
|
|
/** Periodic Advertising options */
|
|
|
|
enum {
|
|
|
|
/** Convenience value when no options are specified. */
|
|
|
|
BT_LE_PER_ADV_OPT_NONE = 0,
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertise with transmit power.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
|
2020-05-01 16:51:17 +02:00
|
|
|
*/
|
|
|
|
BT_LE_PER_ADV_OPT_USE_TX_POWER = BIT(1),
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_per_adv_param {
|
2021-04-22 12:32:42 +02:00
|
|
|
/**
|
|
|
|
* @brief Minimum Periodic Advertising Interval (N * 1.25 ms)
|
|
|
|
*
|
|
|
|
* Shall be greater or equal to BT_GAP_PER_ADV_MIN_INTERVAL and
|
|
|
|
* less or equal to interval_max.
|
|
|
|
*/
|
2020-05-01 16:51:17 +02:00
|
|
|
uint16_t interval_min;
|
|
|
|
|
2021-04-22 12:32:42 +02:00
|
|
|
/**
|
|
|
|
* @brief Maximum Periodic Advertising Interval (N * 1.25 ms)
|
|
|
|
*
|
|
|
|
* Shall be less or equal to BT_GAP_PER_ADV_MAX_INTERVAL and
|
|
|
|
* greater or equal to interval_min.
|
|
|
|
*/
|
2020-05-01 16:51:17 +02:00
|
|
|
uint16_t interval_max;
|
|
|
|
|
|
|
|
/** Bit-field of periodic advertising options */
|
|
|
|
uint32_t options;
|
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Initialize advertising parameters
|
2020-04-30 10:49:54 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _options Advertising Options
|
|
|
|
* @param _int_min Minimum advertising interval
|
|
|
|
* @param _int_max Maximum advertising interval
|
|
|
|
* @param _peer Peer address, set to NULL for undirected advertising or
|
|
|
|
* address of peer for directed advertising.
|
2020-04-30 10:49:54 +02:00
|
|
|
*/
|
|
|
|
#define BT_LE_ADV_PARAM_INIT(_options, _int_min, _int_max, _peer) \
|
|
|
|
{ \
|
|
|
|
.id = BT_ID_DEFAULT, \
|
|
|
|
.sid = 0, \
|
|
|
|
.secondary_max_skip = 0, \
|
|
|
|
.options = (_options), \
|
|
|
|
.interval_min = (_int_min), \
|
|
|
|
.interval_max = (_int_max), \
|
|
|
|
.peer = (_peer), \
|
|
|
|
}
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Helper to declare advertising parameters inline
|
2020-03-17 10:32:20 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _options Advertising Options
|
|
|
|
* @param _int_min Minimum advertising interval
|
|
|
|
* @param _int_max Maximum advertising interval
|
|
|
|
* @param _peer Peer address, set to NULL for undirected advertising or
|
|
|
|
* address of peer for directed advertising.
|
2020-03-17 10:32:20 +01:00
|
|
|
*/
|
2020-04-09 20:06:02 +02:00
|
|
|
#define BT_LE_ADV_PARAM(_options, _int_min, _int_max, _peer) \
|
2020-04-30 10:49:54 +02:00
|
|
|
((struct bt_le_adv_param[]) { \
|
|
|
|
BT_LE_ADV_PARAM_INIT(_options, _int_min, _int_max, _peer) \
|
|
|
|
})
|
2015-12-05 21:50:43 +02:00
|
|
|
|
2020-04-09 20:06:02 +02:00
|
|
|
#define BT_LE_ADV_CONN_DIR(_peer) BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \
|
|
|
|
BT_LE_ADV_OPT_ONE_TIME, 0, 0,\
|
|
|
|
_peer)
|
|
|
|
|
|
|
|
|
2016-05-02 15:18:28 +02:00
|
|
|
#define BT_LE_ADV_CONN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
2020-04-09 20:06:02 +02:00
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
2016-05-02 15:18:28 +02:00
|
|
|
|
2018-07-10 11:26:19 +03:00
|
|
|
#define BT_LE_ADV_CONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \
|
|
|
|
BT_LE_ADV_OPT_USE_NAME, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
2020-04-09 20:06:02 +02:00
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
2018-07-10 11:26:19 +03:00
|
|
|
|
2021-04-16 11:57:45 +01:00
|
|
|
#define BT_LE_ADV_CONN_NAME_AD BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \
|
|
|
|
BT_LE_ADV_OPT_USE_NAME | \
|
|
|
|
BT_LE_ADV_OPT_FORCE_NAME_IN_AD, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
|
|
|
|
2020-04-09 20:06:02 +02:00
|
|
|
#define BT_LE_ADV_CONN_DIR_LOW_DUTY(_peer) \
|
2018-08-20 14:44:42 +02:00
|
|
|
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME | \
|
|
|
|
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY, \
|
2020-04-09 20:06:02 +02:00
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, BT_GAP_ADV_FAST_INT_MAX_2, \
|
|
|
|
_peer)
|
2018-08-20 14:44:42 +02:00
|
|
|
|
2020-10-12 09:13:19 -05:00
|
|
|
/** Non-connectable advertising with private address */
|
2016-05-02 15:18:28 +02:00
|
|
|
#define BT_LE_ADV_NCONN BT_LE_ADV_PARAM(0, BT_GAP_ADV_FAST_INT_MIN_2, \
|
2020-04-09 20:06:02 +02:00
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
2015-12-03 15:27:19 +02:00
|
|
|
|
2020-10-12 09:13:19 -05:00
|
|
|
/** Non-connectable advertising with @ref BT_LE_ADV_OPT_USE_NAME */
|
2018-07-10 11:26:19 +03:00
|
|
|
#define BT_LE_ADV_NCONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_USE_NAME, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
2020-04-09 20:06:02 +02:00
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
2018-07-10 11:26:19 +03:00
|
|
|
|
2020-10-12 09:13:19 -05:00
|
|
|
/** Non-connectable advertising with @ref BT_LE_ADV_OPT_USE_IDENTITY */
|
|
|
|
#define BT_LE_ADV_NCONN_IDENTITY BT_LE_ADV_PARAM(BT_LE_ADV_OPT_USE_IDENTITY, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, \
|
|
|
|
NULL)
|
|
|
|
|
2021-04-28 11:55:00 +02:00
|
|
|
/** Connectable extended advertising with @ref BT_LE_ADV_OPT_USE_NAME */
|
|
|
|
#define BT_LE_EXT_ADV_CONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
|
|
|
|
BT_LE_ADV_OPT_CONNECTABLE | \
|
|
|
|
BT_LE_ADV_OPT_USE_NAME, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, \
|
|
|
|
NULL)
|
|
|
|
|
2021-07-27 20:57:02 +05:30
|
|
|
/** Scannable extended advertising with @ref BT_LE_ADV_OPT_USE_NAME */
|
|
|
|
#define BT_LE_EXT_ADV_SCAN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
|
|
|
|
BT_LE_ADV_OPT_SCANNABLE | \
|
|
|
|
BT_LE_ADV_OPT_USE_NAME, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, \
|
|
|
|
NULL)
|
|
|
|
|
2020-11-10 13:23:17 +05:30
|
|
|
/** Non-connectable extended advertising with private address */
|
|
|
|
#define BT_LE_EXT_ADV_NCONN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
|
|
|
|
|
|
|
/** Non-connectable extended advertising with @ref BT_LE_ADV_OPT_USE_NAME */
|
|
|
|
#define BT_LE_EXT_ADV_NCONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
|
|
|
|
BT_LE_ADV_OPT_USE_NAME, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, \
|
|
|
|
NULL)
|
|
|
|
|
|
|
|
/** Non-connectable extended advertising with @ref BT_LE_ADV_OPT_USE_IDENTITY */
|
|
|
|
#define BT_LE_EXT_ADV_NCONN_IDENTITY \
|
|
|
|
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
|
|
|
|
BT_LE_ADV_OPT_USE_IDENTITY, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
|
|
|
|
|
|
|
/** Non-connectable extended advertising on coded PHY with private address */
|
|
|
|
#define BT_LE_EXT_ADV_CODED_NCONN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
|
|
|
|
BT_LE_ADV_OPT_CODED, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, \
|
|
|
|
NULL)
|
|
|
|
|
|
|
|
/** Non-connectable extended advertising on coded PHY with
|
|
|
|
* @ref BT_LE_ADV_OPT_USE_NAME
|
|
|
|
*/
|
|
|
|
#define BT_LE_EXT_ADV_CODED_NCONN_NAME \
|
|
|
|
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CODED | \
|
|
|
|
BT_LE_ADV_OPT_USE_NAME, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
|
|
|
|
|
|
|
/** Non-connectable extended advertising on coded PHY with
|
|
|
|
* @ref BT_LE_ADV_OPT_USE_IDENTITY
|
|
|
|
*/
|
|
|
|
#define BT_LE_EXT_ADV_CODED_NCONN_IDENTITY \
|
|
|
|
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CODED | \
|
|
|
|
BT_LE_ADV_OPT_USE_IDENTITY, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MIN_2, \
|
|
|
|
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to initialize extended advertising start parameters inline
|
|
|
|
*
|
|
|
|
* @param _timeout Advertiser timeout
|
|
|
|
* @param _n_evts Number of advertising events
|
|
|
|
*/
|
|
|
|
#define BT_LE_EXT_ADV_START_PARAM_INIT(_timeout, _n_evts) \
|
|
|
|
{ \
|
|
|
|
.timeout = (_timeout), \
|
|
|
|
.num_events = (_n_evts), \
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to declare extended advertising start parameters inline
|
|
|
|
*
|
|
|
|
* @param _timeout Advertiser timeout
|
|
|
|
* @param _n_evts Number of advertising events
|
|
|
|
*/
|
|
|
|
#define BT_LE_EXT_ADV_START_PARAM(_timeout, _n_evts) \
|
|
|
|
((struct bt_le_ext_adv_start_param[]) { \
|
|
|
|
BT_LE_EXT_ADV_START_PARAM_INIT((_timeout), (_n_evts)) \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define BT_LE_EXT_ADV_START_DEFAULT BT_LE_EXT_ADV_START_PARAM(0, 0)
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* Helper to declare periodic advertising parameters inline
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _int_min Minimum periodic advertising interval
|
|
|
|
* @param _int_max Maximum periodic advertising interval
|
|
|
|
* @param _options Periodic advertising properties bitfield.
|
2020-05-01 16:51:17 +02:00
|
|
|
*/
|
|
|
|
#define BT_LE_PER_ADV_PARAM_INIT(_int_min, _int_max, _options) \
|
|
|
|
{ \
|
|
|
|
.interval_min = (_int_min), \
|
|
|
|
.interval_max = (_int_max), \
|
|
|
|
.options = (_options), \
|
|
|
|
}
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* Helper to declare periodic advertising parameters inline
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _int_min Minimum periodic advertising interval
|
|
|
|
* @param _int_max Maximum periodic advertising interval
|
|
|
|
* @param _options Periodic advertising properties bitfield.
|
2020-05-01 16:51:17 +02:00
|
|
|
*/
|
|
|
|
#define BT_LE_PER_ADV_PARAM(_int_min, _int_max, _options) \
|
|
|
|
((struct bt_le_per_adv_param[]) { \
|
|
|
|
BT_LE_PER_ADV_PARAM_INIT(_int_min, _int_max, _options) \
|
|
|
|
})
|
|
|
|
|
2021-08-24 13:31:35 +02:00
|
|
|
#define BT_LE_PER_ADV_DEFAULT BT_LE_PER_ADV_PARAM(BT_GAP_PER_ADV_SLOW_INT_MIN, \
|
|
|
|
BT_GAP_PER_ADV_SLOW_INT_MAX, \
|
2020-05-01 16:51:17 +02:00
|
|
|
BT_LE_PER_ADV_OPT_NONE)
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Start advertising
|
|
|
|
*
|
|
|
|
* Set advertisement data, scan response data, advertisement parameters
|
|
|
|
* and start advertising.
|
|
|
|
*
|
|
|
|
* When the advertisement parameter peer address has been set the advertising
|
|
|
|
* will be directed to the peer. In this case advertisement data and scan
|
|
|
|
* response data parameters are ignored. If the mode is high duty cycle
|
|
|
|
* the timeout will be @ref BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT.
|
|
|
|
*
|
|
|
|
* @param param Advertising parameters.
|
|
|
|
* @param ad Data to be used in advertisement packets.
|
|
|
|
* @param ad_len Number of elements in ad
|
|
|
|
* @param sd Data to be used in scan response packets.
|
|
|
|
* @param sd_len Number of elements in sd
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
* @return -ENOMEM No free connection objects available for connectable
|
|
|
|
* advertiser.
|
|
|
|
* @return -ECONNREFUSED When connectable advertising is requested and there
|
|
|
|
* is already maximum number of connections established
|
|
|
|
* in the controller.
|
|
|
|
* This error code is only guaranteed when using Zephyr
|
|
|
|
* controller, for other controllers code returned in
|
|
|
|
* this case may be -EIO.
|
2015-06-12 14:25:28 +03:00
|
|
|
*/
|
2015-12-03 15:27:19 +02:00
|
|
|
int bt_le_adv_start(const struct bt_le_adv_param *param,
|
2016-01-13 12:53:54 +02:00
|
|
|
const struct bt_data *ad, size_t ad_len,
|
|
|
|
const struct bt_data *sd, size_t sd_len);
|
2015-06-02 17:28:00 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Update advertising
|
2018-10-25 15:20:09 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Update advertisement and scan response data.
|
2018-10-25 15:20:09 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param ad Data to be used in advertisement packets.
|
|
|
|
* @param ad_len Number of elements in ad
|
|
|
|
* @param sd Data to be used in scan response packets.
|
|
|
|
* @param sd_len Number of elements in sd
|
2018-10-25 15:20:09 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2018-10-25 15:20:09 +02:00
|
|
|
*/
|
|
|
|
int bt_le_adv_update_data(const struct bt_data *ad, size_t ad_len,
|
|
|
|
const struct bt_data *sd, size_t sd_len);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Stop advertising
|
2015-07-08 12:17:01 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Stops ongoing advertising.
|
2015-07-08 12:17:01 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2015-07-08 12:17:01 +02:00
|
|
|
*/
|
2015-12-03 10:19:38 +02:00
|
|
|
int bt_le_adv_stop(void);
|
2015-07-08 12:17:01 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Create advertising set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Create a new advertising set and set advertising parameters.
|
|
|
|
* Advertising parameters can be updated with @ref bt_le_ext_adv_update_param.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param[in] param Advertising parameters.
|
|
|
|
* @param[in] cb Callback struct to notify about advertiser activity. Can be
|
|
|
|
* NULL. Must point to valid memory during the lifetime of the
|
|
|
|
* advertising set.
|
|
|
|
* @param[out] adv Valid advertising set object on success.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_create(const struct bt_le_adv_param *param,
|
|
|
|
const struct bt_le_ext_adv_cb *cb,
|
|
|
|
struct bt_le_ext_adv **adv);
|
|
|
|
|
|
|
|
struct bt_le_ext_adv_start_param {
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertiser timeout (N * 10 ms).
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Application will be notified by the advertiser sent callback.
|
|
|
|
* Set to zero for no timeout.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* When using high duty cycle directed connectable advertising then
|
|
|
|
* this parameters must be set to a non-zero value less than or equal
|
|
|
|
* to the maximum of @ref BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT.
|
2020-04-09 20:06:02 +02:00
|
|
|
*
|
2021-06-28 17:13:40 +02:00
|
|
|
* If privacy @kconfig{CONFIG_BT_PRIVACY} is enabled then the timeout
|
|
|
|
* must be less than @kconfig{CONFIG_BT_RPA_TIMEOUT}.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t timeout;
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Number of advertising events.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Application will be notified by the advertiser sent callback.
|
|
|
|
* Set to zero for no limit.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t num_events;
|
2020-02-01 18:27:39 +01:00
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Start advertising with the given advertising set
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* If the advertiser is limited by either the timeout or number of advertising
|
|
|
|
* events the application will be notified by the advertiser sent callback once
|
|
|
|
* the limit is reached.
|
|
|
|
* If the advertiser is limited by both the timeout and the number of
|
|
|
|
* advertising events then the limit that is reached first will stop the
|
|
|
|
* advertiser.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
|
|
|
* @param param Advertise start parameters.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_start(struct bt_le_ext_adv *adv,
|
|
|
|
struct bt_le_ext_adv_start_param *param);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Stop advertising with the given advertising set
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Stop advertising with a specific advertising set. When using this function
|
|
|
|
* the advertising sent callback will not be called.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_stop(struct bt_le_ext_adv *adv);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Set an advertising set's advertising or scan response data.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Set advertisement data or scan response data. If the advertising set is
|
|
|
|
* currently advertising then the advertising data will be updated in
|
|
|
|
* subsequent advertising events.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* When both @ref BT_LE_ADV_OPT_EXT_ADV and @ref BT_LE_ADV_OPT_SCANNABLE are
|
|
|
|
* enabled then advertising data is ignored.
|
|
|
|
* When @ref BT_LE_ADV_OPT_SCANNABLE is not enabled then scan response data is
|
|
|
|
* ignored.
|
2020-08-07 11:14:28 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* If the advertising set has been configured to send advertising data on the
|
|
|
|
* primary advertising channels then the maximum data length is
|
|
|
|
* @ref BT_GAP_ADV_MAX_ADV_DATA_LEN bytes.
|
|
|
|
* If the advertising set has been configured for extended advertising,
|
|
|
|
* then the maximum data length is defined by the controller with the maximum
|
|
|
|
* possible of @ref BT_GAP_ADV_MAX_EXT_ADV_DATA_LEN bytes.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Not all scanners support extended data length advertising data.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note When updating the advertising data while advertising the advertising
|
|
|
|
* data and scan response data length must be smaller or equal to what
|
|
|
|
* can be fit in a single advertising packet. Otherwise the
|
|
|
|
* advertiser must be stopped.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
|
|
|
* @param ad Data to be used in advertisement packets.
|
|
|
|
* @param ad_len Number of elements in ad
|
|
|
|
* @param sd Data to be used in scan response packets.
|
|
|
|
* @param sd_len Number of elements in sd
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_set_data(struct bt_le_ext_adv *adv,
|
|
|
|
const struct bt_data *ad, size_t ad_len,
|
|
|
|
const struct bt_data *sd, size_t sd_len);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Update advertising parameters.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Update the advertising parameters. The function will return an error if the
|
|
|
|
* advertiser set is currently advertising. Stop the advertising set before
|
|
|
|
* calling this function.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2021-08-13 13:35:36 +02:00
|
|
|
* @note When changing the option @ref BT_LE_ADV_OPT_USE_NAME then
|
|
|
|
* @ref bt_le_ext_adv_set_data needs to be called in order to update the
|
|
|
|
* advertising data and scan response data.
|
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
|
|
|
* @param param Advertising parameters.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_update_param(struct bt_le_ext_adv *adv,
|
|
|
|
const struct bt_le_adv_param *param);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Delete advertising set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Delete advertising set. This will free up the advertising set and make it
|
|
|
|
* possible to create a new advertising set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_delete(struct bt_le_ext_adv *adv);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get array index of an advertising set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This function is used to map bt_adv to index of an array of
|
|
|
|
* advertising sets. The array has CONFIG_BT_EXT_ADV_MAX_ADV_SET elements.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Index of the advertising set object.
|
|
|
|
* The range of the returned value is 0..CONFIG_BT_EXT_ADV_MAX_ADV_SET-1
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t bt_le_ext_adv_get_index(struct bt_le_ext_adv *adv);
|
2020-02-01 18:27:39 +01:00
|
|
|
|
|
|
|
/** @brief Advertising set info structure. */
|
|
|
|
struct bt_le_ext_adv_info {
|
|
|
|
/* Local identity */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t id;
|
2020-02-01 18:27:39 +01:00
|
|
|
|
|
|
|
/** Currently selected Transmit Power (dBM). */
|
2020-05-27 11:26:57 -05:00
|
|
|
int8_t tx_power;
|
2020-02-01 18:27:39 +01:00
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get advertising set info
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object
|
|
|
|
* @param info Advertising set info object
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code on failure.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_get_info(const struct bt_le_ext_adv *adv,
|
|
|
|
struct bt_le_ext_adv_info *info);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @typedef bt_le_scan_cb_t
|
|
|
|
* @brief Callback type for reporting LE scan results.
|
2015-12-03 14:52:42 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* A function of this type is given to the bt_le_scan_start() function
|
|
|
|
* and will be called for any discovered LE device.
|
2015-12-03 14:52:42 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param addr Advertiser LE address and type.
|
|
|
|
* @param rssi Strength of advertiser signal.
|
|
|
|
* @param adv_type Type of advertising response from advertiser.
|
|
|
|
* @param buf Buffer containing advertiser data.
|
2015-12-03 14:52:42 +02:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
typedef void bt_le_scan_cb_t(const bt_addr_le_t *addr, int8_t rssi,
|
|
|
|
uint8_t adv_type, struct net_buf_simple *buf);
|
2015-12-03 14:52:42 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Set or update the periodic advertising parameters.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* The periodic advertising parameters can only be set or updated on an
|
|
|
|
* extended advertisement set which is neither scannable, connectable nor
|
|
|
|
* anonymous.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
|
|
|
* @param param Advertising parameters.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-05-01 16:51:17 +02:00
|
|
|
*/
|
|
|
|
int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv,
|
|
|
|
const struct bt_le_per_adv_param *param);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Set or update the periodic advertising data.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* The periodic advertisement data can only be set or updated on an
|
|
|
|
* extended advertisement set which is neither scannable, connectable nor
|
|
|
|
* anonymous.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
|
|
|
* @param ad Advertising data.
|
|
|
|
* @param ad_len Advertising data length.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-05-01 16:51:17 +02:00
|
|
|
*/
|
|
|
|
int bt_le_per_adv_set_data(const struct bt_le_ext_adv *adv,
|
|
|
|
const struct bt_data *ad, size_t ad_len);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Starts periodic advertising.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Enabling the periodic advertising can be done independently of extended
|
|
|
|
* advertising, but both periodic advertising and extended advertising
|
|
|
|
* shall be enabled before any periodic advertising data is sent. The
|
|
|
|
* periodic advertising and extended advertising can be enabled in any order.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Once periodic advertising has been enabled, it will continue advertising
|
|
|
|
* until @ref bt_le_per_adv_stop() has been called, or if the advertising set
|
|
|
|
* is deleted by @ref bt_le_ext_adv_delete(). Calling @ref bt_le_ext_adv_stop()
|
|
|
|
* will not stop the periodic advertising.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-05-01 16:51:17 +02:00
|
|
|
*/
|
|
|
|
int bt_le_per_adv_start(struct bt_le_ext_adv *adv);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Stops periodic advertising.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Disabling the periodic advertising can be done independently of extended
|
|
|
|
* advertising. Disabling periodic advertising will not disable extended
|
|
|
|
* advertising.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param adv Advertising set object.
|
2020-05-01 16:51:17 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-05-01 16:51:17 +02:00
|
|
|
*/
|
|
|
|
int bt_le_per_adv_stop(struct bt_le_ext_adv *adv);
|
|
|
|
|
2020-05-06 22:38:23 +02:00
|
|
|
struct bt_le_per_adv_sync_synced_info {
|
|
|
|
/** Advertiser LE address and type. */
|
|
|
|
const bt_addr_le_t *addr;
|
|
|
|
|
|
|
|
/** Advertiser SID */
|
|
|
|
uint8_t sid;
|
|
|
|
|
|
|
|
/** Periodic advertising interval (N * 1.25 ms) */
|
|
|
|
uint16_t interval;
|
|
|
|
|
|
|
|
/** Advertiser PHY */
|
|
|
|
uint8_t phy;
|
2020-10-12 14:13:19 +02:00
|
|
|
|
|
|
|
/** True if receiving periodic advertisements, false otherwise. */
|
|
|
|
bool recv_enabled;
|
2020-09-23 22:39:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Service Data provided by the peer when sync is transferred
|
|
|
|
*
|
|
|
|
* Will always be 0 when the sync is locally created.
|
|
|
|
*/
|
|
|
|
uint16_t service_data;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Peer that transferred the periodic advertising sync
|
|
|
|
*
|
|
|
|
* Will always be 0 when the sync is locally created.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct bt_conn *conn;
|
2020-05-06 22:38:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_per_adv_sync_term_info {
|
|
|
|
/** Advertiser LE address and type. */
|
|
|
|
const bt_addr_le_t *addr;
|
|
|
|
|
|
|
|
/** Advertiser SID */
|
|
|
|
uint8_t sid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_per_adv_sync_recv_info {
|
|
|
|
/** Advertiser LE address and type. */
|
|
|
|
const bt_addr_le_t *addr;
|
|
|
|
|
|
|
|
/** Advertiser SID */
|
|
|
|
uint8_t sid;
|
|
|
|
|
|
|
|
/** The TX power of the advertisement. */
|
|
|
|
int8_t tx_power;
|
|
|
|
|
|
|
|
/** The RSSI of the advertisement excluding any CTE. */
|
|
|
|
int8_t rssi;
|
|
|
|
|
2021-05-06 02:51:58 +02:00
|
|
|
/** The Constant Tone Extension (CTE) of the advertisement (@ref bt_df_cte_type) */
|
2020-05-06 22:38:23 +02:00
|
|
|
uint8_t cte_type;
|
|
|
|
};
|
|
|
|
|
2020-10-12 14:13:19 +02:00
|
|
|
|
|
|
|
struct bt_le_per_adv_sync_state_info {
|
|
|
|
/** True if receiving periodic advertisements, false otherwise. */
|
|
|
|
bool recv_enabled;
|
|
|
|
};
|
|
|
|
|
2020-05-06 22:38:23 +02:00
|
|
|
struct bt_le_per_adv_sync_cb {
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief The periodic advertising has been successfully synced.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This callback notifies the application that the periodic advertising
|
|
|
|
* set has been successfully synced, and will now start to
|
|
|
|
* receive periodic advertising reports.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param sync The periodic advertising sync object.
|
|
|
|
* @param info Information about the sync event.
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
void (*synced)(struct bt_le_per_adv_sync *sync,
|
|
|
|
struct bt_le_per_adv_sync_synced_info *info);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief The periodic advertising sync has been terminated.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This callback notifies the application that the periodic advertising
|
|
|
|
* sync has been terminated, either by local request, remote request or
|
|
|
|
* because due to missing data, e.g. by being out of range or sync.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param sync The periodic advertising sync object.
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
void (*term)(struct bt_le_per_adv_sync *sync,
|
|
|
|
const struct bt_le_per_adv_sync_term_info *info);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Periodic advertising data received.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This callback notifies the application of an periodic advertising
|
|
|
|
* report.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param sync The advertising set object.
|
|
|
|
* @param info Information about the periodic advertising event.
|
|
|
|
* @param buf Buffer containing the periodic advertising data.
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
void (*recv)(struct bt_le_per_adv_sync *sync,
|
|
|
|
const struct bt_le_per_adv_sync_recv_info *info,
|
|
|
|
struct net_buf_simple *buf);
|
2020-09-28 10:33:07 +02:00
|
|
|
|
2020-10-12 14:13:19 +02:00
|
|
|
/**
|
|
|
|
* @brief The periodic advertising sync state has changed.
|
|
|
|
*
|
|
|
|
* This callback notifies the application about changes to the sync
|
|
|
|
* state. Initialize sync and termination is handled by their individual
|
|
|
|
* callbacks, and won't be notified here.
|
|
|
|
*
|
|
|
|
* @param sync The periodic advertising sync object.
|
|
|
|
* @param info Information about the state change.
|
|
|
|
*/
|
|
|
|
void (*state_changed)(struct bt_le_per_adv_sync *sync,
|
|
|
|
const struct bt_le_per_adv_sync_state_info *info);
|
|
|
|
|
2020-08-12 14:22:51 +02:00
|
|
|
/**
|
|
|
|
* @brief BIGInfo advertising report received.
|
|
|
|
*
|
|
|
|
* This callback notifies the application of a BIGInfo advertising report.
|
|
|
|
* This is received if the advertiser is broadcasting isochronous streams in a BIG.
|
|
|
|
* See iso.h for more information.
|
|
|
|
*
|
|
|
|
* @param sync The advertising set object.
|
|
|
|
* @param biginfo The BIGInfo report.
|
|
|
|
*/
|
|
|
|
void (*biginfo)(struct bt_le_per_adv_sync *sync, const struct bt_iso_biginfo *biginfo);
|
2020-10-12 14:13:19 +02:00
|
|
|
|
2021-04-22 11:10:43 +02:00
|
|
|
/**
|
|
|
|
* @brief Callback for IQ samples report collected when sampling
|
|
|
|
* CTE received with periodic advertising PDU.
|
|
|
|
*
|
|
|
|
* @param sync The periodic advertising sync object.
|
|
|
|
* @param info Information about the sync event.
|
|
|
|
*/
|
|
|
|
void (*cte_report_cb)(struct bt_le_per_adv_sync *sync,
|
|
|
|
struct bt_df_per_adv_sync_iq_samples_report const *info);
|
|
|
|
|
2020-09-28 10:33:07 +02:00
|
|
|
sys_snode_t node;
|
2020-05-06 22:38:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Periodic advertising sync options */
|
|
|
|
enum {
|
|
|
|
/** Convenience value when no options are specified. */
|
|
|
|
BT_LE_PER_ADV_SYNC_OPT_NONE = 0,
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Use the periodic advertising list to sync with advertiser
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* When this option is set, the address and SID of the parameters
|
|
|
|
* are ignored.
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST = BIT(0),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Disables periodic advertising reports
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* No advertisement reports will be handled until enabled.
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
BT_LE_PER_ADV_SYNC_OPT_REPORTING_INITIALLY_DISABLED = BIT(1),
|
|
|
|
|
|
|
|
/** Sync with Angle of Arrival (AoA) constant tone extension */
|
|
|
|
BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOA = BIT(2),
|
|
|
|
|
|
|
|
/** Sync with Angle of Departure (AoD) 1 us constant tone extension */
|
|
|
|
BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOD_1US = BIT(3),
|
|
|
|
|
|
|
|
/** Sync with Angle of Departure (AoD) 2 us constant tone extension */
|
|
|
|
BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOD_2US = BIT(4),
|
|
|
|
|
|
|
|
/** Do not sync to packets without a constant tone extension */
|
|
|
|
BT_LE_PER_ADV_SYNC_OPT_SYNC_ONLY_CONST_TONE_EXT = BIT(5),
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_per_adv_sync_param {
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Periodic Advertiser Address
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Only valid if not using the periodic advertising list
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
bt_addr_le_t addr;
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertiser SID
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Only valid if not using the periodic advertising list
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
uint8_t sid;
|
|
|
|
|
|
|
|
/** Bit-field of periodic advertising sync options. */
|
|
|
|
uint32_t options;
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Maximum event skip
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Maximum number of periodic advertising events that can be
|
|
|
|
* skipped after a successful receive
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
uint16_t skip;
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Synchronization timeout (N * 10 ms)
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Synchronization timeout for the periodic advertising sync.
|
|
|
|
* Range 0x000A to 0x4000 (100 ms to 163840 ms)
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
uint16_t timeout;
|
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get array index of an periodic advertising sync object.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This function is get the index of an array of periodic advertising sync
|
|
|
|
* objects. The array has CONFIG_BT_PER_ADV_SYNC_MAX elements.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param per_adv_sync The periodic advertising sync object.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Index of the periodic advertising sync object.
|
|
|
|
* The range of the returned value is 0..CONFIG_BT_PER_ADV_SYNC_MAX-1
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync);
|
|
|
|
|
2021-03-24 15:53:04 +01:00
|
|
|
/** @brief Advertising set info structure. */
|
|
|
|
struct bt_le_per_adv_sync_info {
|
|
|
|
/** Periodic Advertiser Address */
|
|
|
|
bt_addr_le_t addr;
|
|
|
|
|
|
|
|
/** Advertiser SID */
|
|
|
|
uint8_t sid;
|
|
|
|
|
|
|
|
/** Periodic advertising interval (N * 1.25 ms) */
|
|
|
|
uint16_t interval;
|
|
|
|
|
|
|
|
/** Advertiser PHY */
|
|
|
|
uint8_t phy;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get periodic adv sync information.
|
|
|
|
*
|
|
|
|
* @param per_adv_sync Periodic advertising sync object.
|
|
|
|
* @param info Periodic advertising sync info object
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code on failure.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_get_info(struct bt_le_per_adv_sync *per_adv_sync,
|
|
|
|
struct bt_le_per_adv_sync_info *info);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Look up an existing periodic advertising sync object by advertiser address.
|
|
|
|
*
|
|
|
|
* @param adv_addr Advertiser address.
|
|
|
|
* @param sid The advertising set ID.
|
|
|
|
*
|
|
|
|
* @return Periodic advertising sync object or NULL if not found.
|
|
|
|
*/
|
|
|
|
struct bt_le_per_adv_sync *bt_le_per_adv_sync_lookup_addr(const bt_addr_le_t *adv_addr,
|
|
|
|
uint8_t sid);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Create a periodic advertising sync object.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Create a periodic advertising sync object that can try to synchronize
|
|
|
|
* to periodic advertising reports from an advertiser. Scan shall either be
|
|
|
|
* disabled or extended scan shall be enabled.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-28 10:33:07 +02:00
|
|
|
* @param[in] param Periodic advertising sync parameters.
|
|
|
|
* @param[out] out_sync Periodic advertising sync object on.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_create(const struct bt_le_per_adv_sync_param *param,
|
|
|
|
struct bt_le_per_adv_sync **out_sync);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Delete periodic advertising sync.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Delete the periodic advertising sync object. Can be called regardless of the
|
|
|
|
* state of the sync. If the syncing is currently syncing, the syncing is
|
|
|
|
* cancelled. If the sync has been established, it is terminated. The
|
|
|
|
* periodic advertising sync object will be invalidated afterwards.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-10-21 14:54:37 +02:00
|
|
|
* If the state of the sync object is syncing, then a new periodic advertising
|
|
|
|
* sync object may not be created until the controller has finished canceling
|
|
|
|
* this object.
|
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param per_adv_sync The periodic advertising sync object.
|
2020-05-06 22:38:23 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
2020-05-06 22:38:23 +02:00
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_delete(struct bt_le_per_adv_sync *per_adv_sync);
|
|
|
|
|
2020-09-28 10:33:07 +02:00
|
|
|
/**
|
|
|
|
* @brief Register periodic advertising sync callbacks.
|
|
|
|
*
|
|
|
|
* Adds the callback structure to the list of callback structures for periodic
|
|
|
|
* adverising syncs.
|
|
|
|
*
|
|
|
|
* This callback will be called for all periodic advertising sync activity,
|
|
|
|
* such as synced, terminated and when data is received.
|
|
|
|
*
|
|
|
|
* @param cb Callback struct. Must point to memory that remains valid.
|
|
|
|
*/
|
|
|
|
void bt_le_per_adv_sync_cb_register(struct bt_le_per_adv_sync_cb *cb);
|
|
|
|
|
2020-10-12 14:13:19 +02:00
|
|
|
/**
|
|
|
|
* @brief Enables receiving periodic advertising reports for a sync.
|
|
|
|
*
|
|
|
|
* If the sync is already receiving the reports, -EALREADY is returned.
|
|
|
|
*
|
|
|
|
* @param per_adv_sync The periodic advertising sync object.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_recv_enable(struct bt_le_per_adv_sync *per_adv_sync);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disables receiving periodic advertising reports for a sync.
|
|
|
|
*
|
|
|
|
* If the sync report receiving is already disabled, -EALREADY is returned.
|
|
|
|
*
|
|
|
|
* @param per_adv_sync The periodic advertising sync object.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_recv_disable(struct bt_le_per_adv_sync *per_adv_sync);
|
|
|
|
|
2020-09-23 22:39:29 +02:00
|
|
|
/** Periodic Advertising Sync Transfer options */
|
|
|
|
enum {
|
|
|
|
/** Convenience value when no options are specified. */
|
|
|
|
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_NONE = 0,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief No Angle of Arrival (AoA)
|
|
|
|
*
|
|
|
|
* Do not sync with Angle of Arrival (AoA) constant tone extension
|
|
|
|
**/
|
|
|
|
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOA = BIT(0),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief No Angle of Departure (AoD) 1 us
|
|
|
|
*
|
|
|
|
* Do not sync with Angle of Departure (AoD) 1 us
|
|
|
|
* constant tone extension
|
|
|
|
*/
|
|
|
|
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOD_1US = BIT(1),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief No Angle of Departure (AoD) 2
|
|
|
|
*
|
|
|
|
* Do not sync with Angle of Departure (AoD) 2 us
|
|
|
|
* constant tone extension
|
|
|
|
*/
|
|
|
|
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOD_2US = BIT(2),
|
|
|
|
|
|
|
|
/** Only sync to packets with constant tone extension */
|
|
|
|
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_ONLY_CTE = BIT(3),
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_le_per_adv_sync_transfer_param {
|
|
|
|
/**
|
|
|
|
* @brief Maximum event skip
|
|
|
|
*
|
|
|
|
* The number of periodic advertising packets that can be skipped
|
|
|
|
* after a successful receive.
|
|
|
|
*/
|
|
|
|
uint16_t skip;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Synchronization timeout (N * 10 ms)
|
|
|
|
*
|
|
|
|
* Synchronization timeout for the periodic advertising sync.
|
|
|
|
* Range 0x000A to 0x4000 (100 ms to 163840 ms)
|
|
|
|
*/
|
|
|
|
uint16_t timeout;
|
|
|
|
|
|
|
|
/** Periodic Advertising Sync Transfer options */
|
|
|
|
uint32_t options;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Transfer the periodic advertising sync information to a peer device.
|
|
|
|
*
|
|
|
|
* This will allow another device to quickly synchronize to the same periodic
|
|
|
|
* advertising train that this device is currently synced to.
|
|
|
|
*
|
|
|
|
* @param per_adv_sync The periodic advertising sync to transfer.
|
|
|
|
* @param conn The peer device that will receive the sync information.
|
|
|
|
* @param service_data Application service data provided to the remote host.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_transfer(const struct bt_le_per_adv_sync *per_adv_sync,
|
|
|
|
const struct bt_conn *conn,
|
|
|
|
uint16_t service_data);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Transfer the information about a periodic advertising set.
|
|
|
|
*
|
|
|
|
* This will allow another device to quickly synchronize to periodic
|
|
|
|
* advertising set from this device.
|
|
|
|
*
|
|
|
|
* @param adv The periodic advertising set to transfer info of.
|
|
|
|
* @param conn The peer device that will receive the information.
|
|
|
|
* @param service_data Application service data provided to the remote host.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_set_info_transfer(const struct bt_le_ext_adv *adv,
|
|
|
|
const struct bt_conn *conn,
|
|
|
|
uint16_t service_data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Subscribe to periodic advertising sync transfers (PASTs).
|
|
|
|
*
|
|
|
|
* Sets the parameters and allow other devices to transfer periodic advertising
|
|
|
|
* syncs.
|
|
|
|
*
|
|
|
|
* @param conn The connection to set the parameters for. If NULL default
|
|
|
|
* parameters for all connections will be set. Parameters set
|
|
|
|
* for specific connection will always have precedence.
|
|
|
|
* @param param The periodic advertising sync transfer parameters.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_transfer_subscribe(
|
|
|
|
const struct bt_conn *conn,
|
|
|
|
const struct bt_le_per_adv_sync_transfer_param *param);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Unsubscribe from periodic advertising sync transfers (PASTs).
|
|
|
|
*
|
|
|
|
* Remove the parameters that allow other devices to transfer periodic
|
|
|
|
* advertising syncs.
|
|
|
|
*
|
|
|
|
* @param conn The connection to remove the parameters for. If NULL default
|
|
|
|
* parameters for all connections will be removed. Unsubscribing
|
|
|
|
* for a specific device, will still allow other devices to
|
|
|
|
* transfer periodic advertising syncs.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_sync_transfer_unsubscribe(const struct bt_conn *conn);
|
|
|
|
|
2020-10-12 16:10:15 +02:00
|
|
|
/**
|
|
|
|
* @brief Add a device to the periodic advertising list.
|
|
|
|
*
|
|
|
|
* Add peer device LE address to the periodic advertising list. This will make
|
|
|
|
* it possibly to automatically create a periodic advertising sync to this
|
|
|
|
* device.
|
|
|
|
*
|
|
|
|
* @param addr Bluetooth LE identity address.
|
|
|
|
* @param sid The advertising set ID. This value is obtained from the
|
|
|
|
* @ref bt_le_scan_recv_info in the scan callback.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_list_add(const bt_addr_le_t *addr, uint8_t sid);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Remove a device from the periodic advertising list.
|
|
|
|
*
|
|
|
|
* Removes peer device LE address from the periodic advertising list.
|
|
|
|
*
|
|
|
|
* @param addr Bluetooth LE identity address.
|
|
|
|
* @param sid The advertising set ID. This value is obtained from the
|
|
|
|
* @ref bt_le_scan_recv_info in the scan callback.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_list_remove(const bt_addr_le_t *addr, uint8_t sid);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clear the periodic advertising list.
|
|
|
|
*
|
|
|
|
* Clears the entire periodic advertising list.
|
|
|
|
*
|
|
|
|
* @return Zero on success or (negative) error code otherwise.
|
|
|
|
*/
|
|
|
|
int bt_le_per_adv_list_clear(void);
|
|
|
|
|
2019-07-22 13:13:38 +02:00
|
|
|
enum {
|
2020-02-01 20:06:35 +01:00
|
|
|
/** Convenience value when no options are specified. */
|
|
|
|
BT_LE_SCAN_OPT_NONE = 0,
|
|
|
|
|
2020-03-17 10:32:20 +01:00
|
|
|
/** Filter duplicates. */
|
2020-02-01 20:06:35 +01:00
|
|
|
BT_LE_SCAN_OPT_FILTER_DUPLICATE = BIT(0),
|
2019-07-22 13:13:38 +02:00
|
|
|
|
2020-03-17 10:32:20 +01:00
|
|
|
/** Filter using whitelist. */
|
2020-02-01 20:06:35 +01:00
|
|
|
BT_LE_SCAN_OPT_FILTER_WHITELIST = BIT(1),
|
2019-07-22 13:13:38 +02:00
|
|
|
|
2020-02-01 20:57:05 +01:00
|
|
|
/** Enable scan on coded PHY (Long Range).*/
|
|
|
|
BT_LE_SCAN_OPT_CODED = BIT(2),
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Disable scan on 1M phy.
|
2020-02-01 20:57:05 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note Requires @ref BT_LE_SCAN_OPT_CODED.
|
2020-02-01 20:57:05 +01:00
|
|
|
*/
|
|
|
|
BT_LE_SCAN_OPT_NO_1M = BIT(3),
|
2019-07-22 13:13:38 +02:00
|
|
|
};
|
|
|
|
|
2019-10-16 10:20:50 +02:00
|
|
|
enum {
|
2020-03-17 10:32:20 +01:00
|
|
|
/** Scan without requesting additional information from advertisers. */
|
2019-10-16 10:20:50 +02:00
|
|
|
BT_LE_SCAN_TYPE_PASSIVE = 0x00,
|
|
|
|
|
2020-03-17 10:32:20 +01:00
|
|
|
/** Scan and request additional information from advertisers. */
|
2019-10-16 10:20:50 +02:00
|
|
|
BT_LE_SCAN_TYPE_ACTIVE = 0x01,
|
|
|
|
};
|
|
|
|
|
2015-12-03 22:39:11 +02:00
|
|
|
/** LE scan parameters */
|
2015-12-03 15:17:10 +02:00
|
|
|
struct bt_le_scan_param {
|
2019-10-16 10:20:50 +02:00
|
|
|
/** Scan type (BT_LE_SCAN_TYPE_ACTIVE or BT_LE_SCAN_TYPE_PASSIVE) */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t type;
|
2015-12-03 22:39:11 +02:00
|
|
|
|
2021-01-20 16:05:03 +01:00
|
|
|
/** Bit-field of scanning options. */
|
|
|
|
uint32_t options;
|
2015-12-03 22:39:11 +02:00
|
|
|
|
2015-12-05 21:39:44 +02:00
|
|
|
/** Scan interval (N * 0.625 ms) */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t interval;
|
2015-12-03 22:39:11 +02:00
|
|
|
|
2015-12-05 21:39:44 +02:00
|
|
|
/** Scan window (N * 0.625 ms) */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t window;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Scan timeout (N * 10 ms)
|
2020-02-01 20:57:05 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Application will be notified by the scan timeout callback.
|
|
|
|
* Set zero to disable timeout.
|
2020-02-01 20:57:05 +01:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t timeout;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Scan interval LE Coded PHY (N * 0.625 MS)
|
2020-02-01 20:57:05 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Set zero to use same as LE 1M PHY scan interval.
|
2020-02-01 20:57:05 +01:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t interval_coded;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Scan window LE Coded PHY (N * 0.625 MS)
|
2020-02-01 20:57:05 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Set zero to use same as LE 1M PHY scan window.
|
2020-02-01 20:57:05 +01:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t window_coded;
|
2015-12-03 15:17:10 +02:00
|
|
|
};
|
2015-07-23 11:35:59 +02:00
|
|
|
|
2019-12-20 14:13:11 +01:00
|
|
|
/** LE advertisement packet information */
|
2020-02-11 16:59:35 +01:00
|
|
|
struct bt_le_scan_recv_info {
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertiser LE address and type.
|
2020-02-01 20:57:05 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* If advertiser is anonymous then this address will be
|
|
|
|
* @ref BT_ADDR_LE_ANY.
|
2020-02-01 20:57:05 +01:00
|
|
|
*/
|
2019-12-20 14:13:11 +01:00
|
|
|
const bt_addr_le_t *addr;
|
|
|
|
|
2020-04-28 19:47:46 +02:00
|
|
|
/** Advertising Set Identifier. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t sid;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
|
|
|
/** Strength of advertiser signal. */
|
2020-05-27 11:26:57 -05:00
|
|
|
int8_t rssi;
|
2019-12-20 14:13:11 +01:00
|
|
|
|
2020-02-01 20:57:05 +01:00
|
|
|
/** Transmit power of the advertiser. */
|
2020-05-27 11:26:57 -05:00
|
|
|
int8_t tx_power;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
|
|
|
/** Advertising packet type. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t adv_type;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
|
|
|
/** Advertising packet properties. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t adv_props;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
2020-05-04 16:14:38 +02:00
|
|
|
/**
|
|
|
|
* @brief Periodic advertising interval.
|
|
|
|
*
|
2020-05-06 22:38:23 +02:00
|
|
|
* If 0 there is no periodic advertising.
|
2020-05-04 16:14:38 +02:00
|
|
|
*/
|
|
|
|
uint16_t interval;
|
|
|
|
|
2020-04-28 19:47:46 +02:00
|
|
|
/** Primary advertising channel PHY. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t primary_phy;
|
2020-02-01 20:57:05 +01:00
|
|
|
|
2020-04-28 19:47:46 +02:00
|
|
|
/** Secondary advertising channel PHY. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t secondary_phy;
|
2019-12-20 14:13:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Listener context for (LE) scanning. */
|
|
|
|
struct bt_le_scan_cb {
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Advertisement packet received callback.
|
2019-12-20 14:13:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param info Advertiser packet information.
|
|
|
|
* @param buf Buffer containing advertiser data.
|
2019-12-20 14:13:11 +01:00
|
|
|
*/
|
2020-02-11 16:59:35 +01:00
|
|
|
void (*recv)(const struct bt_le_scan_recv_info *info,
|
2019-12-20 14:13:11 +01:00
|
|
|
struct net_buf_simple *buf);
|
|
|
|
|
2020-02-01 20:57:05 +01:00
|
|
|
/** @brief The scanner has stopped scanning after scan timeout. */
|
|
|
|
void (*timeout)(void);
|
|
|
|
|
2019-12-20 14:13:11 +01:00
|
|
|
sys_snode_t node;
|
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Initialize scan parameters
|
2020-04-30 10:49:54 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _type Scan Type, BT_LE_SCAN_TYPE_ACTIVE or
|
|
|
|
* BT_LE_SCAN_TYPE_PASSIVE.
|
|
|
|
* @param _options Scan options
|
|
|
|
* @param _interval Scan Interval (N * 0.625 ms)
|
|
|
|
* @param _window Scan Window (N * 0.625 ms)
|
2020-04-30 10:49:54 +02:00
|
|
|
*/
|
|
|
|
#define BT_LE_SCAN_PARAM_INIT(_type, _options, _interval, _window) \
|
|
|
|
{ \
|
|
|
|
.type = (_type), \
|
|
|
|
.options = (_options), \
|
|
|
|
.interval = (_interval), \
|
|
|
|
.window = (_window), \
|
|
|
|
.timeout = 0, \
|
|
|
|
.interval_coded = 0, \
|
|
|
|
.window_coded = 0, \
|
|
|
|
}
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Helper to declare scan parameters inline
|
2020-03-17 10:32:20 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param _type Scan Type, BT_LE_SCAN_TYPE_ACTIVE or
|
|
|
|
* BT_LE_SCAN_TYPE_PASSIVE.
|
|
|
|
* @param _options Scan options
|
|
|
|
* @param _interval Scan Interval (N * 0.625 ms)
|
|
|
|
* @param _window Scan Window (N * 0.625 ms)
|
2020-03-17 10:32:20 +01:00
|
|
|
*/
|
2020-02-01 20:06:35 +01:00
|
|
|
#define BT_LE_SCAN_PARAM(_type, _options, _interval, _window) \
|
2020-04-30 10:49:54 +02:00
|
|
|
((struct bt_le_scan_param[]) { \
|
|
|
|
BT_LE_SCAN_PARAM_INIT(_type, _options, _interval, _window) \
|
|
|
|
})
|
2015-12-05 21:39:44 +02:00
|
|
|
|
2020-11-10 13:23:17 +05:30
|
|
|
/**
|
|
|
|
* @brief Helper macro to enable active scanning to discover new devices.
|
|
|
|
*/
|
2019-10-16 10:20:50 +02:00
|
|
|
#define BT_LE_SCAN_ACTIVE BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_ACTIVE, \
|
2020-02-01 20:06:35 +01:00
|
|
|
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
|
2015-12-05 21:39:44 +02:00
|
|
|
BT_GAP_SCAN_FAST_INTERVAL, \
|
2015-12-07 12:18:30 +02:00
|
|
|
BT_GAP_SCAN_FAST_WINDOW)
|
2015-12-05 21:39:44 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Helper macro to enable passive scanning to discover new devices.
|
2015-12-18 11:59:01 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This macro should be used if information required for device identification
|
|
|
|
* (e.g., UUID) are known to be placed in Advertising Data.
|
2015-12-18 11:59:01 +01:00
|
|
|
*/
|
2019-10-16 10:20:50 +02:00
|
|
|
#define BT_LE_SCAN_PASSIVE BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_PASSIVE, \
|
2020-02-01 20:06:35 +01:00
|
|
|
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
|
2015-12-18 11:59:01 +01:00
|
|
|
BT_GAP_SCAN_FAST_INTERVAL, \
|
|
|
|
BT_GAP_SCAN_FAST_WINDOW)
|
|
|
|
|
2020-11-10 13:23:17 +05:30
|
|
|
/**
|
|
|
|
* @brief Helper macro to enable active scanning to discover new devices.
|
|
|
|
* Include scanning on Coded PHY in addition to 1M PHY.
|
|
|
|
*/
|
|
|
|
#define BT_LE_SCAN_CODED_ACTIVE \
|
|
|
|
BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_ACTIVE, \
|
|
|
|
BT_LE_SCAN_OPT_CODED | \
|
|
|
|
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
|
|
|
|
BT_GAP_SCAN_FAST_INTERVAL, \
|
|
|
|
BT_GAP_SCAN_FAST_WINDOW)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Helper macro to enable passive scanning to discover new devices.
|
|
|
|
* Include scanning on Coded PHY in addition to 1M PHY.
|
|
|
|
*
|
|
|
|
* This macro should be used if information required for device identification
|
|
|
|
* (e.g., UUID) are known to be placed in Advertising Data.
|
|
|
|
*/
|
|
|
|
#define BT_LE_SCAN_CODED_PASSIVE \
|
|
|
|
BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_PASSIVE, \
|
|
|
|
BT_LE_SCAN_OPT_CODED | \
|
|
|
|
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
|
|
|
|
BT_GAP_SCAN_FAST_INTERVAL, \
|
|
|
|
BT_GAP_SCAN_FAST_WINDOW)
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Start (LE) scanning
|
2015-06-18 10:43:23 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Start LE scanning with given parameters and provide results through
|
|
|
|
* the specified callback.
|
2015-06-18 10:43:23 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note The LE scanner by default does not use the Identity Address of the
|
2021-06-28 17:13:40 +02:00
|
|
|
* local device when @kconfig{CONFIG_BT_PRIVACY} is disabled. This is to
|
2020-09-11 10:45:31 -03:00
|
|
|
* prevent the active scanner from disclosing the identity information
|
|
|
|
* when requesting additional information from advertisers.
|
|
|
|
* In order to enable directed advertiser reports then
|
2021-06-28 17:13:40 +02:00
|
|
|
* @kconfig{CONFIG_BT_SCAN_WITH_IDENTITY} must be enabled.
|
2020-01-30 18:44:46 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param param Scan parameters.
|
|
|
|
* @param cb Callback to notify scan results. May be NULL if callback
|
|
|
|
* registration through @ref bt_le_scan_cb_register is preferred.
|
2015-06-18 10:43:23 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2015-06-18 10:43:23 +03:00
|
|
|
*/
|
2015-12-03 15:17:10 +02:00
|
|
|
int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb);
|
2015-06-18 10:43:23 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Stop (LE) scanning.
|
2015-06-18 10:43:23 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Stops ongoing LE scanning.
|
2015-06-18 10:43:23 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2015-06-18 10:43:23 +03:00
|
|
|
*/
|
2015-12-03 10:19:38 +02:00
|
|
|
int bt_le_scan_stop(void);
|
2015-04-17 13:59:34 +03:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Register scanner packet callbacks.
|
2019-12-20 14:13:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Adds the callback structure to the list of callback structures that monitors
|
|
|
|
* scanner activity.
|
2019-12-20 14:13:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This callback will be called for all scanner activity, regardless of what
|
|
|
|
* API was used to start the scanner.
|
2019-12-20 14:13:11 +01:00
|
|
|
*
|
2020-09-28 10:33:07 +02:00
|
|
|
* @param cb Callback struct. Must point to memory that remains valid.
|
2019-12-20 14:13:11 +01:00
|
|
|
*/
|
|
|
|
void bt_le_scan_cb_register(struct bt_le_scan_cb *cb);
|
|
|
|
|
2021-01-11 14:45:54 +08:00
|
|
|
/**
|
|
|
|
* @brief Unregister scanner packet callbacks.
|
|
|
|
*
|
|
|
|
* Remove the callback structure from the list of scanner callbacks.
|
|
|
|
*
|
|
|
|
* @param cb Callback struct. Must point to memory that remains valid.
|
|
|
|
*/
|
|
|
|
void bt_le_scan_cb_unregister(struct bt_le_scan_cb *cb);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Add device (LE) to whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Add peer device LE address to the whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note The whitelist cannot be modified when an LE role is using
|
|
|
|
* the whitelist, i.e advertiser or scanner using a whitelist or automatic
|
|
|
|
* connecting to devices using whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param addr Bluetooth LE identity address.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2019-07-22 13:13:38 +02:00
|
|
|
*/
|
|
|
|
int bt_le_whitelist_add(const bt_addr_le_t *addr);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Remove device (LE) from whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Remove peer device LE address from the whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note The whitelist cannot be modified when an LE role is using
|
|
|
|
* the whitelist, i.e advertiser or scanner using a whitelist or automatic
|
|
|
|
* connecting to devices using whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param addr Bluetooth LE identity address.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2019-07-22 13:13:38 +02:00
|
|
|
*/
|
|
|
|
int bt_le_whitelist_rem(const bt_addr_le_t *addr);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Clear whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Clear all devices from the whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note The whitelist cannot be modified when an LE role is using
|
|
|
|
* the whitelist, i.e advertiser or scanner using a whitelist or automatic
|
|
|
|
* connecting to devices using whitelist.
|
2019-07-22 13:13:38 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2019-07-22 13:13:38 +02:00
|
|
|
*/
|
|
|
|
int bt_le_whitelist_clear(void);
|
2018-09-13 13:28:21 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Set (LE) channel map.
|
2018-09-13 13:28:21 +02:00
|
|
|
*
|
|
|
|
* @param chan_map Channel map.
|
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2018-09-13 13:28:21 +02:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_le_set_chan_map(uint8_t chan_map[5]);
|
2018-09-13 13:28:21 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Helper for parsing advertising (or EIR or OOB) data.
|
2018-06-26 13:48:56 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* A helper for parsing the basic data types used for Extended Inquiry
|
|
|
|
* Response (EIR), Advertising Data (AD), and OOB data blocks. The most
|
|
|
|
* common scenario is to call this helper on the advertising data
|
|
|
|
* received in the callback that was given to bt_le_scan_start().
|
2018-06-26 13:48:56 +03:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param ad Advertising data as given to the bt_le_scan_cb_t callback.
|
|
|
|
* @param func Callback function which will be called for each element
|
|
|
|
* that's found in the data. The callback should return
|
|
|
|
* true to continue parsing, or false to stop parsing.
|
|
|
|
* @param user_data User data to be passed to the callback.
|
2018-06-26 13:48:56 +03:00
|
|
|
*/
|
|
|
|
void bt_data_parse(struct net_buf_simple *ad,
|
|
|
|
bool (*func)(struct bt_data *data, void *user_data),
|
|
|
|
void *user_data);
|
|
|
|
|
2020-03-10 14:15:36 +01:00
|
|
|
/** LE Secure Connections pairing Out of Band data. */
|
2019-03-12 10:57:42 +01:00
|
|
|
struct bt_le_oob_sc_data {
|
|
|
|
/** Random Number. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t r[16];
|
2019-03-12 10:57:42 +01:00
|
|
|
|
|
|
|
/** Confirm Value. */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t c[16];
|
2019-03-12 10:57:42 +01:00
|
|
|
};
|
|
|
|
|
2020-03-10 14:15:36 +01:00
|
|
|
/** LE Out of Band information. */
|
2016-07-20 12:07:46 +02:00
|
|
|
struct bt_le_oob {
|
2020-03-10 14:15:36 +01:00
|
|
|
/** LE address. If privacy is enabled this is a Resolvable Private
|
2016-07-22 12:26:01 +02:00
|
|
|
* Address.
|
2016-07-20 12:07:46 +02:00
|
|
|
*/
|
2016-07-22 12:26:01 +02:00
|
|
|
bt_addr_le_t addr;
|
2019-03-12 10:57:42 +01:00
|
|
|
|
2020-03-10 14:15:36 +01:00
|
|
|
/** LE Secure Connections pairing Out of Band data. */
|
2019-03-12 10:57:42 +01:00
|
|
|
struct bt_le_oob_sc_data le_sc_data;
|
2016-07-20 12:07:46 +02:00
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get local LE Out of Band (OOB) information.
|
2016-07-20 12:07:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This function allows to get local information that are useful for
|
|
|
|
* Out of Band pairing or connection creation.
|
2016-07-20 12:07:46 +02:00
|
|
|
*
|
2021-06-28 17:13:40 +02:00
|
|
|
* If privacy @kconfig{CONFIG_BT_PRIVACY} is enabled this will result in
|
2020-09-11 10:45:31 -03:00
|
|
|
* generating new Resolvable Private Address (RPA) that is valid for
|
2021-06-28 17:13:40 +02:00
|
|
|
* @kconfig{CONFIG_BT_RPA_TIMEOUT} seconds. This address will be used for
|
2020-09-11 10:45:31 -03:00
|
|
|
* advertising started by @ref bt_le_adv_start, active scanning and
|
|
|
|
* connection creation.
|
2016-07-20 12:07:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note If privacy is enabled the RPA cannot be refreshed in the following
|
|
|
|
* cases:
|
|
|
|
* - Creating a connection in progress, wait for the connected callback.
|
2021-06-28 17:13:40 +02:00
|
|
|
* In addition when extended advertising @kconfig{CONFIG_BT_EXT_ADV} is
|
2020-09-11 10:45:31 -03:00
|
|
|
* not enabled or not supported by the controller:
|
|
|
|
* - Advertiser is enabled using a Random Static Identity Address for a
|
|
|
|
* different local identity.
|
|
|
|
* - The local identity conflicts with the local identity used by other
|
|
|
|
* roles.
|
2020-03-10 14:16:43 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param[in] id Local identity, in most cases BT_ID_DEFAULT.
|
|
|
|
* @param[out] oob LE OOB information
|
2019-03-12 10:57:42 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2016-07-20 12:07:46 +02:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_le_oob_get_local(uint8_t id, struct bt_le_oob *oob);
|
2016-07-20 12:07:46 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get local LE Out of Band (OOB) information.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This function allows to get local information that are useful for
|
|
|
|
* Out of Band pairing or connection creation.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2021-06-28 17:13:40 +02:00
|
|
|
* If privacy @kconfig{CONFIG_BT_PRIVACY} is enabled this will result in
|
2020-09-11 10:45:31 -03:00
|
|
|
* generating new Resolvable Private Address (RPA) that is valid for
|
2021-06-28 17:13:40 +02:00
|
|
|
* @kconfig{CONFIG_BT_RPA_TIMEOUT} seconds. This address will be used by the
|
2020-09-11 10:45:31 -03:00
|
|
|
* advertising set.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note When generating OOB information for multiple advertising set all
|
|
|
|
* OOB information needs to be generated at the same time.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @note If privacy is enabled the RPA cannot be refreshed in the following
|
|
|
|
* cases:
|
|
|
|
* - Creating a connection in progress, wait for the connected callback.
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param[in] adv The advertising set object
|
|
|
|
* @param[out] oob LE OOB information
|
2020-02-01 18:27:39 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case
|
|
|
|
* of protocol error or negative (POSIX) in case of stack internal error.
|
2020-02-01 18:27:39 +01:00
|
|
|
*/
|
|
|
|
int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv,
|
|
|
|
struct bt_le_oob *oob);
|
|
|
|
|
2016-03-10 11:58:56 +01:00
|
|
|
/** @brief BR/EDR discovery result structure */
|
|
|
|
struct bt_br_discovery_result {
|
2016-03-17 18:35:58 +01:00
|
|
|
/** private */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t _priv[4];
|
2016-03-17 18:35:58 +01:00
|
|
|
|
2016-03-10 11:58:56 +01:00
|
|
|
/** Remote device address */
|
|
|
|
bt_addr_t addr;
|
|
|
|
|
|
|
|
/** RSSI from inquiry */
|
2020-05-27 11:26:57 -05:00
|
|
|
int8_t rssi;
|
2016-03-10 11:58:56 +01:00
|
|
|
|
|
|
|
/** Class of Device */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t cod[3];
|
2016-03-10 11:58:56 +01:00
|
|
|
|
|
|
|
/** Extended Inquiry Response */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t eir[240];
|
2016-03-10 11:58:56 +01:00
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @typedef bt_br_discovery_cb_t
|
|
|
|
* @brief Callback type for reporting BR/EDR discovery (inquiry)
|
|
|
|
* results.
|
2016-03-10 11:58:56 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* A callback of this type is given to the bt_br_discovery_start()
|
|
|
|
* function and will be called at the end of the discovery with
|
|
|
|
* information about found devices populated in the results array.
|
2016-03-10 11:58:56 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param results Storage used for discovery results
|
|
|
|
* @param count Number of valid discovery results.
|
2016-03-10 11:58:56 +01:00
|
|
|
*/
|
|
|
|
typedef void bt_br_discovery_cb_t(struct bt_br_discovery_result *results,
|
|
|
|
size_t count);
|
|
|
|
|
|
|
|
/** BR/EDR discovery parameters */
|
|
|
|
struct bt_br_discovery_param {
|
2016-06-16 10:21:15 +03:00
|
|
|
/** Maximum length of the discovery in units of 1.28 seconds.
|
|
|
|
* Valid range is 0x01 - 0x30.
|
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t length;
|
2016-06-16 10:21:15 +03:00
|
|
|
|
2016-03-10 11:58:56 +01:00
|
|
|
/** True if limited discovery procedure is to be used. */
|
2016-06-16 11:28:59 +03:00
|
|
|
bool limited;
|
2016-03-10 11:58:56 +01:00
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Start BR/EDR discovery
|
2016-03-10 11:58:56 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Start BR/EDR discovery (inquiry) and provide results through the specified
|
|
|
|
* callback. When bt_br_discovery_cb_t is called it indicates that discovery
|
|
|
|
* has completed. If more inquiry results were received during session than
|
|
|
|
* fits in provided result storage, only ones with highest RSSI will be
|
|
|
|
* reported.
|
2016-03-10 11:58:56 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param param Discovery parameters.
|
|
|
|
* @param results Storage for discovery results.
|
|
|
|
* @param count Number of results in storage. Valid range: 1-255.
|
|
|
|
* @param cb Callback to notify discovery results.
|
2016-03-10 11:58:56 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case
|
|
|
|
* of protocol error or negative (POSIX) in case of stack internal error
|
2016-03-10 11:58:56 +01:00
|
|
|
*/
|
|
|
|
int bt_br_discovery_start(const struct bt_br_discovery_param *param,
|
|
|
|
struct bt_br_discovery_result *results, size_t count,
|
|
|
|
bt_br_discovery_cb_t cb);
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Stop BR/EDR discovery.
|
2016-03-10 11:58:56 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Stops ongoing BR/EDR discovery. If discovery was stopped by this call
|
|
|
|
* results won't be reported
|
2016-03-10 11:58:56 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Zero on success or error code otherwise, positive in case of
|
|
|
|
* protocol error or negative (POSIX) in case of stack internal error.
|
2016-03-10 11:58:56 +01:00
|
|
|
*/
|
|
|
|
int bt_br_discovery_stop(void);
|
|
|
|
|
2016-07-20 12:07:46 +02:00
|
|
|
struct bt_br_oob {
|
|
|
|
/** BR/EDR address. */
|
|
|
|
bt_addr_t addr;
|
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Get BR/EDR local Out Of Band information
|
2016-07-20 12:07:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* This function allows to get local controller information that are useful
|
|
|
|
* for Out Of Band pairing or connection creation process.
|
2016-07-20 12:07:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param oob Out Of Band information
|
2016-07-20 12:07:46 +02:00
|
|
|
*/
|
|
|
|
int bt_br_oob_get_local(struct bt_br_oob *oob);
|
|
|
|
|
2019-05-29 10:50:08 +02:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Enable/disable set controller in discoverable state.
|
2015-11-26 14:47:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Allows make local controller to listen on INQUIRY SCAN channel and responds
|
|
|
|
* to devices making general inquiry. To enable this state it's mandatory
|
|
|
|
* to first be in connectable state.
|
2015-11-26 14:47:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param enable Value allowing/disallowing controller to become discoverable.
|
2015-11-26 14:47:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Negative if fail set to requested state or requested state has been
|
|
|
|
* already set. Zero if done successfully.
|
2015-11-26 14:47:11 +01:00
|
|
|
*/
|
2015-12-03 10:35:25 +02:00
|
|
|
int bt_br_set_discoverable(bool enable);
|
2015-11-26 14:47:11 +01:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Enable/disable set controller in connectable state.
|
2015-11-26 14:47:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* Allows make local controller to be connectable. It means the controller
|
|
|
|
* start listen to devices requests on PAGE SCAN channel. If disabled also
|
|
|
|
* resets discoverability if was set.
|
2015-11-26 14:47:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param enable Value allowing/disallowing controller to be connectable.
|
2015-11-26 14:47:11 +01:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return Negative if fail set to requested state or requested state has been
|
|
|
|
* already set. Zero if done successfully.
|
2015-11-26 14:47:11 +01:00
|
|
|
*/
|
2015-12-03 10:35:25 +02:00
|
|
|
int bt_br_set_connectable(bool enable);
|
2016-01-22 12:38:49 -05:00
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Clear pairing information.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param id Local identity (mostly just BT_ID_DEFAULT).
|
|
|
|
* @param addr Remote address, NULL or BT_ADDR_LE_ANY to clear all remote
|
|
|
|
* devices.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @return 0 on success or negative error value on failure.
|
2020-04-28 19:47:46 +02:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_unpair(uint8_t id, const bt_addr_le_t *addr);
|
2018-04-27 10:31:13 +03:00
|
|
|
|
2018-09-20 15:19:40 +03:00
|
|
|
/** Information about a bond with a remote device. */
|
|
|
|
struct bt_bond_info {
|
|
|
|
/** Address of the remote device. */
|
|
|
|
bt_addr_le_t addr;
|
|
|
|
};
|
|
|
|
|
2020-09-11 10:45:31 -03:00
|
|
|
/**
|
|
|
|
* @brief Iterate through all existing bonds.
|
2020-04-28 19:47:46 +02:00
|
|
|
*
|
2020-09-11 10:45:31 -03:00
|
|
|
* @param id Local identity (mostly just BT_ID_DEFAULT).
|
|
|
|
* @param func Function to call for each bond.
|
|
|
|
* @param user_data Data to pass to the callback function.
|
2020-04-28 19:47:46 +02:00
|
|
|
*/
|
2020-05-27 11:26:57 -05:00
|
|
|
void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info,
|
2018-09-20 15:19:40 +03:00
|
|
|
void *user_data),
|
|
|
|
void *user_data);
|
|
|
|
|
2016-06-15 11:03:11 +03:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2016-05-16 19:54:24 +03:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2018-09-14 10:43:44 -07:00
|
|
|
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_BLUETOOTH_H_ */
|