这个页面的 最新开发版本 可能比这个发布的 2.3-beta.1 版本新。

通用访问配置文件(GAP)

API 参考

group bt_gap

Generic Access Profile (GAP)

Defines

BT_ID_DEFAULT

Convenience macro for specifying the default identity. This helps make the code more readable, especially when only one identity is supported.

BT_DATA_SERIALIZED_SIZE(data_len)

Bluetooth data serialized size.

Get the size of a serialized bt_data given its data length.

Size of ‘AD Structure’->’Length’ field, equal to 1. Size of ‘AD Structure’->’Data’->’AD Type’ field, equal to 1. Size of ‘AD Structure’->’Data’->’AD Data’ field, equal to data_len.

See Core Specification Version 5.4 Vol. 3 Part C, 11, Figure 11.1.

BT_DATA(_type, _data, _data_len)

Helper to declare elements of bt_data arrays.

This macro is mainly for creating an array of struct bt_data elements which is then passed to e.g. bt_le_adv_start().

参数:
  • _type – Type of advertising data field

  • _data – Pointer to the data field payload

  • _data_len – Number of bytes behind the _data pointer

BT_DATA_BYTES(_type, _bytes...)

Helper to declare elements of bt_data arrays.

This macro is mainly for creating an array of struct bt_data elements which is then passed to e.g. bt_le_adv_start().

参数:
  • _type – Type of advertising data field

  • _bytes – Variable number of single-byte parameters

BT_LE_ADV_PARAM_INIT(_options, _int_min, _int_max, _peer)

Initialize advertising parameters.

参数:
  • _options – Advertising Options

  • _int_min – Minimum advertising interval

  • _int_max – Maximum advertising interval

  • _peer – Peer address, set to NULL for undirected advertising or address of peer for directed advertising.

BT_LE_ADV_PARAM(_options, _int_min, _int_max, _peer)

Helper to declare advertising parameters inline.

参数:
  • _options – Advertising Options

  • _int_min – Minimum advertising interval

  • _int_max – Maximum advertising interval

  • _peer – Peer address, set to NULL for undirected advertising or address of peer for directed advertising.

BT_LE_ADV_CONN_DIR(_peer)
BT_LE_ADV_CONN
BT_LE_ADV_CONN_NAME
BT_LE_ADV_CONN_NAME_AD
BT_LE_ADV_CONN_DIR_LOW_DUTY(_peer)
BT_LE_ADV_NCONN

Non-connectable advertising with private address

BT_LE_ADV_NCONN_NAME

Non-connectable advertising with BT_LE_ADV_OPT_USE_NAME

BT_LE_ADV_NCONN_IDENTITY

Non-connectable advertising with BT_LE_ADV_OPT_USE_IDENTITY

BT_LE_EXT_ADV_CONN_NAME

Connectable extended advertising with BT_LE_ADV_OPT_USE_NAME

BT_LE_EXT_ADV_SCAN_NAME

Scannable extended advertising with BT_LE_ADV_OPT_USE_NAME

BT_LE_EXT_ADV_NCONN

Non-connectable extended advertising with private address

BT_LE_EXT_ADV_NCONN_NAME

Non-connectable extended advertising with BT_LE_ADV_OPT_USE_NAME

BT_LE_EXT_ADV_NCONN_IDENTITY

Non-connectable extended advertising with BT_LE_ADV_OPT_USE_IDENTITY

BT_LE_EXT_ADV_CODED_NCONN

Non-connectable extended advertising on coded PHY with private address

BT_LE_EXT_ADV_CODED_NCONN_NAME

Non-connectable extended advertising on coded PHY with BT_LE_ADV_OPT_USE_NAME

BT_LE_EXT_ADV_CODED_NCONN_IDENTITY

Non-connectable extended advertising on coded PHY with BT_LE_ADV_OPT_USE_IDENTITY

BT_LE_EXT_ADV_START_PARAM_INIT(_timeout, _n_evts)

Helper to initialize extended advertising start parameters inline

参数:
  • _timeout – Advertiser timeout

  • _n_evts – Number of advertising events

BT_LE_EXT_ADV_START_PARAM(_timeout, _n_evts)

Helper to declare extended advertising start parameters inline

参数:
  • _timeout – Advertiser timeout

  • _n_evts – Number of advertising events

BT_LE_EXT_ADV_START_DEFAULT
BT_LE_PER_ADV_PARAM_INIT(_int_min, _int_max, _options)

Helper to declare periodic advertising parameters inline

参数:
  • _int_min – Minimum periodic advertising interval

  • _int_max – Maximum periodic advertising interval

  • _options – Periodic advertising properties bitfield.

BT_LE_PER_ADV_PARAM(_int_min, _int_max, _options)

Helper to declare periodic advertising parameters inline

参数:
  • _int_min – Minimum periodic advertising interval

  • _int_max – Maximum periodic advertising interval

  • _options – Periodic advertising properties bitfield.

BT_LE_PER_ADV_DEFAULT
BT_LE_SCAN_OPT_FILTER_WHITELIST
BT_LE_SCAN_PARAM_INIT(_type, _options, _interval, _window)

Initialize scan parameters.

参数:
  • _type – Scan Type, BT_LE_SCAN_TYPE_ACTIVE or BT_LE_SCAN_TYPE_PASSIVE.

  • _options – Scan options

  • _interval – Scan Interval (N * 0.625 ms)

  • _window – Scan Window (N * 0.625 ms)

BT_LE_SCAN_PARAM(_type, _options, _interval, _window)

Helper to declare scan parameters inline.

参数:
  • _type – Scan Type, BT_LE_SCAN_TYPE_ACTIVE or BT_LE_SCAN_TYPE_PASSIVE.

  • _options – Scan options

  • _interval – Scan Interval (N * 0.625 ms)

  • _window – Scan Window (N * 0.625 ms)

BT_LE_SCAN_ACTIVE

Helper macro to enable active scanning to discover new devices.

BT_LE_SCAN_PASSIVE

Helper macro to enable passive scanning to discover new devices.

This macro should be used if information required for device identification (e.g., UUID) are known to be placed in Advertising Data.

BT_LE_SCAN_CODED_ACTIVE

Helper macro to enable active scanning to discover new devices. Include scanning on Coded PHY in addition to 1M PHY.

BT_LE_SCAN_CODED_PASSIVE

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.

Typedefs

typedef void (*bt_ready_cb_t)(int err)

Callback for notifying that Bluetooth has been enabled.

Param err:

zero on success or (negative) error code otherwise.

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)

Callback type for reporting LE scan results.

A function of this type is given to the bt_le_scan_start() function and will be called for any discovered LE device.

Param addr:

Advertiser LE address and type.

Param rssi:

Strength of advertiser signal.

Param adv_type:

Type of advertising response from advertiser. Uses the BT_GAP_ADV_TYPE_* values.

Param buf:

Buffer containing advertiser data.

typedef void bt_br_discovery_cb_t(struct bt_br_discovery_result *results, size_t count)

Callback type for reporting BR/EDR discovery (inquiry) results.

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.

Param results:

Storage used for discovery results

Param count:

Number of valid discovery results.

Enums

enum bt_le_adv_option

Advertising options

Values:

enumerator BT_LE_ADV_OPT_NONE

Convenience value when no options are specified.

enumerator BT_LE_ADV_OPT_CONNECTABLE

Advertise as connectable.

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 and/or enabling privacy CONFIG_BT_PRIVACY.

enumerator BT_LE_ADV_OPT_ONE_TIME

Advertise one time.

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 (peripheral) 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 bt_le_ext_adv_start then this behavior is the default behavior and this flag has no effect.

enumerator BT_LE_ADV_OPT_USE_IDENTITY

Advertise using identity address.

Advertise using the identity address as the advertiser address.

备注

The address used for advertising will not be the same as returned by bt_le_oob_get_local, instead bt_id_get should be used to get the LE address.

警告

This will compromise the privacy of the device, so care must be taken when using this option.

enumerator BT_LE_ADV_OPT_USE_NAME

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 BT_LE_ADV_OPT_EXT_ADV and not 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. 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.

The application can set the device name itself by including the following in the advertising data.

BT_DATA(BT_DATA_NAME_COMPLETE, name, sizeof(name) - 1)

enumerator BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY

Low duty cycle directed advertising.

Use low duty directed advertising mode, otherwise high duty mode will be used.

enumerator BT_LE_ADV_OPT_DIR_ADDR_RPA

Directed advertising to privacy-enabled peer.

Enable use of Resolvable Private Address (RPA) as the target address in directed advertisements. 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.

enumerator BT_LE_ADV_OPT_FILTER_SCAN_REQ

Use filter accept list to filter devices that can request scan response data.

enumerator BT_LE_ADV_OPT_FILTER_CONN

Use filter accept list to filter devices that can connect.

enumerator BT_LE_ADV_OPT_NOTIFY_SCAN_REQ

Notify the application when a scan response data has been sent to an active scanner.

enumerator BT_LE_ADV_OPT_SCANNABLE

Support scan response data.

When used together with BT_LE_ADV_OPT_EXT_ADV then this option cannot be used together with the BT_LE_ADV_OPT_CONNECTABLE option. When used together with BT_LE_ADV_OPT_EXT_ADV then scan response data must be set.

enumerator BT_LE_ADV_OPT_EXT_ADV

Advertise with extended advertising.

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.

Without this option the advertiser will send advertising data on the three primary advertising channels.

备注

Enabling this option requires extended advertising support in the peer devices scanning for advertisement packets.

enumerator BT_LE_ADV_OPT_NO_2M

Disable use of LE 2M PHY on the secondary advertising channel.

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.

备注

Cannot be set if BT_LE_ADV_OPT_CODED is set.

备注

Requires BT_LE_ADV_OPT_EXT_ADV.

enumerator BT_LE_ADV_OPT_CODED

Advertise on the LE Coded PHY (Long Range).

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.

备注

Requires BT_LE_ADV_OPT_EXT_ADV

enumerator BT_LE_ADV_OPT_ANONYMOUS

Advertise without a device address (identity or RPA).

备注

Requires BT_LE_ADV_OPT_EXT_ADV

enumerator BT_LE_ADV_OPT_USE_TX_POWER

Advertise with transmit power.

备注

Requires BT_LE_ADV_OPT_EXT_ADV

enumerator BT_LE_ADV_OPT_DISABLE_CHAN_37

Disable advertising on channel index 37.

enumerator BT_LE_ADV_OPT_DISABLE_CHAN_38

Disable advertising on channel index 38.

enumerator BT_LE_ADV_OPT_DISABLE_CHAN_39

Disable advertising on channel index 39.

enumerator BT_LE_ADV_OPT_FORCE_NAME_IN_AD

Put GAP device name into advert data.

Will place the GAP device name into the advertising data rather than the scan response data.

备注

Requires BT_LE_ADV_OPT_USE_NAME

enumerator BT_LE_ADV_OPT_USE_NRPA

Advertise using a Non-Resolvable Private Address.

A new NRPA is set when updating the advertising parameters.

This is an advanced feature; most users will want to enable CONFIG_BT_EXT_ADV instead.

备注

Not implemented when CONFIG_BT_PRIVACY.

备注

Mutually exclusive with BT_LE_ADV_OPT_USE_IDENTITY.

enum bt_le_per_adv_option

Periodic Advertising options

Values:

enumerator BT_LE_PER_ADV_OPT_NONE

Convenience value when no options are specified.

enumerator BT_LE_PER_ADV_OPT_USE_TX_POWER

Advertise with transmit power.

备注

Requires BT_LE_ADV_OPT_EXT_ADV

enumerator BT_LE_PER_ADV_OPT_INCLUDE_ADI

Advertise with included AdvDataInfo (ADI).

备注

Requires BT_LE_ADV_OPT_EXT_ADV

enum bt_le_per_adv_sync_option

Periodic advertising sync options

Values:

enumerator BT_LE_PER_ADV_SYNC_OPT_NONE

Convenience value when no options are specified.

enumerator BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST

Use the periodic advertising list to sync with advertiser.

When this option is set, the address and SID of the parameters are ignored.

enumerator BT_LE_PER_ADV_SYNC_OPT_REPORTING_INITIALLY_DISABLED

Disables periodic advertising reports.

No advertisement reports will be handled until enabled.

enumerator BT_LE_PER_ADV_SYNC_OPT_FILTER_DUPLICATE

Filter duplicate Periodic Advertising reports

enumerator BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOA

Sync with Angle of Arrival (AoA) constant tone extension

enumerator BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOD_1US

Sync with Angle of Departure (AoD) 1 us constant tone extension

enumerator BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOD_2US

Sync with Angle of Departure (AoD) 2 us constant tone extension

enumerator BT_LE_PER_ADV_SYNC_OPT_SYNC_ONLY_CONST_TONE_EXT

Do not sync to packets without a constant tone extension

enum bt_le_per_adv_sync_transfer_option

Periodic Advertising Sync Transfer options

Values:

enumerator BT_LE_PER_ADV_SYNC_TRANSFER_OPT_NONE

Convenience value when no options are specified.

enumerator BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOA

No Angle of Arrival (AoA)

Do not sync with Angle of Arrival (AoA) constant tone extension

enumerator BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOD_1US

No Angle of Departure (AoD) 1 us.

Do not sync with Angle of Departure (AoD) 1 us constant tone extension

enumerator BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOD_2US

No Angle of Departure (AoD) 2.

Do not sync with Angle of Departure (AoD) 2 us constant tone extension

enumerator BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_ONLY_CTE

Only sync to packets with constant tone extension

enumerator BT_LE_PER_ADV_SYNC_TRANSFER_OPT_REPORTING_INITIALLY_DISABLED

Sync to received PAST packets but don’t generate sync reports.

This option must not be set at the same time as BT_LE_PER_ADV_SYNC_TRANSFER_OPT_FILTER_DUPLICATES.

enumerator BT_LE_PER_ADV_SYNC_TRANSFER_OPT_FILTER_DUPLICATES

Sync to received PAST packets and generate sync reports with duplicate filtering.

This option must not be set at the same time as BT_LE_PER_ADV_SYNC_TRANSFER_OPT_REPORTING_INITIALLY_DISABLED.

enum bt_le_scan_option

Values:

enumerator BT_LE_SCAN_OPT_NONE

Convenience value when no options are specified.

enumerator BT_LE_SCAN_OPT_FILTER_DUPLICATE

Filter duplicates.

enumerator BT_LE_SCAN_OPT_FILTER_ACCEPT_LIST

Filter using filter accept list.

enumerator BT_LE_SCAN_OPT_CODED

Enable scan on coded PHY (Long Range).

enumerator BT_LE_SCAN_OPT_NO_1M

Disable scan on 1M phy.

备注

Requires BT_LE_SCAN_OPT_CODED.

enum bt_le_scan_type

Values:

enumerator BT_LE_SCAN_TYPE_PASSIVE

Scan without requesting additional information from advertisers.

enumerator BT_LE_SCAN_TYPE_ACTIVE

Scan and request additional information from advertisers.

Using this scan type will automatically send scan requests to all devices. Scan responses are received in the same manner and using the same callbacks as advertising reports.

Functions

int bt_enable(bt_ready_cb_t cb)

Enable Bluetooth.

Enable Bluetooth. Must be the called before any calls that require communication with the local Bluetooth hardware.

When CONFIG_BT_SETTINGS is enabled, the application must load the Bluetooth settings after this API call successfully completes before Bluetooth APIs can be used. Loading the settings before calling this function is insufficient. Bluetooth settings can be loaded with settings_load() or settings_load_subtree() with argument “bt”. The latter selectively loads only Bluetooth settings and is recommended if settings_load() has been called earlier.

参数:

cb – Callback to notify completion or NULL to perform the enabling synchronously.

返回:

Zero on success or (negative) error code otherwise.

int bt_disable(void)

Disable Bluetooth.

Disable Bluetooth. Can’t be called before bt_enable has completed.

Close and release HCI resources. Result is architecture dependent.

返回:

Zero on success or (negative) error code otherwise.

bool bt_is_ready(void)

Check if Bluetooth is ready.

返回:

true when Bluetooth is ready, false otherwise

int bt_set_name(const char *name)

Set Bluetooth Device Name.

Set Bluetooth GAP Device Name.

When advertising with device name in the advertising data the name should be updated by calling bt_le_adv_update_data or bt_le_ext_adv_set_data.

参见

CONFIG_BT_DEVICE_NAME_MAX.

备注

Requires CONFIG_BT_DEVICE_NAME_DYNAMIC.

参数:

name – New name

返回:

Zero on success or (negative) error code otherwise.

const char *bt_get_name(void)

Get Bluetooth Device Name.

Get Bluetooth GAP Device Name.

返回:

Bluetooth Device Name

uint16_t bt_get_appearance(void)

Get local Bluetooth appearance.

Bluetooth Appearance is a description of the external appearance of a device in terms of an Appearance Value.

返回:

Appearance Value of local Bluetooth host.

int bt_set_appearance(uint16_t new_appearance)

Set local Bluetooth appearance.

Automatically preserves the new appearance across reboots if CONFIG_BT_SETTINGS is enabled.

This symbol is linkable if CONFIG_BT_DEVICE_APPEARANCE_DYNAMIC is enabled.

参数:

new_appearance – Appearance Value

返回值:
  • 0 – Success.

  • other – Persistent storage failed. Appearance was not updated.

void bt_id_get(bt_addr_le_t *addrs, size_t *count)

Get the currently configured identities.

Returns an array of the currently configured identity addresses. To make sure all available identities can be retrieved, the number of elements in the 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 addrs array.

If addrs is passed as NULL, then returned count contains the count of all available identities that can be retrieved with a subsequent call to this function with non-NULL addrs parameter.

备注

Deleted identities may show up as BT_ADDR_LE_ANY in the returned array.

参数:
  • addrs – Array where to store the configured identities.

  • count – Should be initialized to the array size. Once the function returns it will contain the number of returned identities.

int bt_id_create(bt_addr_le_t *addr, uint8_t *irk)

Create a new identity.

Create a new identity using the given address and IRK. This function can be called before calling bt_enable(). 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.

Generating random static address or random IRK is not supported when calling this function before bt_enable().

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.

参数:
  • addr – Address to use for the new identity. If NULL or initialized to BT_ADDR_LE_ANY the stack will generate a new random static address for the identity and copy it to the given parameter upon return from this function (in case the parameter was non-NULL).

  • 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 CONFIG_BT_PRIVACY is not enabled this parameter must be NULL.

返回:

Identity identifier (>= 0) in case of success, or a negative error code on failure.

int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk)

Reset/reclaim an identity for reuse.

The semantics of the addr and irk parameters of this function are the same as with bt_id_create(). The difference is the first 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 addr and irk parameters.

备注

the default identity (BT_ID_DEFAULT) cannot be reset, i.e. this API will return an error if asked to do that.

参数:
  • id – Existing identity identifier.

  • 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).

  • 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 CONFIG_BT_PRIVACY is not enabled this parameter must be NULL.

返回:

Identity identifier (>= 0) in case of success, or a negative error code on failure.

int bt_id_delete(uint8_t id)

Delete an identity.

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.

备注

the default identity (BT_ID_DEFAULT) cannot be deleted, i.e. this API will return an error if asked to do that.

参数:

id – Existing identity identifier.

返回:

0 in case of success, or a negative error code on failure.

size_t bt_data_get_len(const struct bt_data data[], size_t data_count)

Get the total size (in bytes) of a given set of bt_data structures.

参数:
  • data[in] Array of bt_data structures.

  • data_count[in] Number of bt_data structures in data.

返回:

Size of the concatenated data, built from the bt_data structure set.

size_t bt_data_serialize(const struct bt_data *input, uint8_t *output)

Serialize a bt_data struct into an advertising structure (a flat byte array).

The data are formatted according to the Bluetooth Core Specification v. 5.4, vol. 3, part C, 11.

参数:
  • input[in] Single bt_data structure to read from.

  • output[out] Buffer large enough to store the advertising structure in input. The size of it must be at least the size of the `input->data_len + 2` (for the type and the length).

返回:

Number of bytes written in output.

int bt_le_adv_start(const struct bt_le_adv_param *param, const struct bt_data *ad, size_t ad_len, const struct bt_data *sd, size_t sd_len)

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 BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT.

参数:
  • param – Advertising parameters.

  • ad – Data to be used in advertisement packets.

  • ad_len – Number of elements in ad

  • sd – Data to be used in scan response packets.

  • sd_len – Number of elements in sd

返回:

Zero on success or (negative) error code otherwise.

返回:

-ENOMEM No free connection objects available for connectable advertiser.

返回:

-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.

int bt_le_adv_update_data(const struct bt_data *ad, size_t ad_len, const struct bt_data *sd, size_t sd_len)

Update advertising.

Update advertisement and scan response data.

参数:
  • ad – Data to be used in advertisement packets.

  • ad_len – Number of elements in ad

  • sd – Data to be used in scan response packets.

  • sd_len – Number of elements in sd

返回:

Zero on success or (negative) error code otherwise.

int bt_le_adv_stop(void)

Stop advertising.

Stops ongoing advertising.

返回:

Zero on success or (negative) error code otherwise.

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)

Create advertising set.

Create a new advertising set and set advertising parameters. Advertising parameters can be updated with bt_le_ext_adv_update_param.

参数:
  • param[in] Advertising parameters.

  • cb[in] Callback struct to notify about advertiser activity. Can be NULL. Must point to valid memory during the lifetime of the advertising set.

  • adv[out] Valid advertising set object on success.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_start_param *param)

Start advertising with the given advertising set.

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.

参数:
  • adv – Advertising set object.

  • param – Advertise start parameters.

int bt_le_ext_adv_stop(struct bt_le_ext_adv *adv)

Stop advertising with the given advertising set.

Stop advertising with a specific advertising set. When using this function the advertising sent callback will not be called.

参数:

adv – Advertising set object.

返回:

Zero on success or (negative) error code otherwise.

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)

Set an advertising set’s advertising or scan response data.

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.

When both BT_LE_ADV_OPT_EXT_ADV and BT_LE_ADV_OPT_SCANNABLE are enabled then advertising data is ignored. When BT_LE_ADV_OPT_SCANNABLE is not enabled then scan response data is ignored.

If the advertising set has been configured to send advertising data on the primary advertising channels then the maximum data length is 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 BT_GAP_ADV_MAX_EXT_ADV_DATA_LEN bytes.

备注

Not all scanners support extended data length advertising data.

备注

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.

参数:
  • adv – Advertising set object.

  • ad – Data to be used in advertisement packets.

  • ad_len – Number of elements in ad

  • sd – Data to be used in scan response packets.

  • sd_len – Number of elements in sd

返回:

Zero on success or (negative) error code otherwise.

int bt_le_ext_adv_update_param(struct bt_le_ext_adv *adv, const struct bt_le_adv_param *param)

Update advertising parameters.

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.

备注

When changing the option BT_LE_ADV_OPT_USE_NAME then bt_le_ext_adv_set_data needs to be called in order to update the advertising data and scan response data.

参数:
  • adv – Advertising set object.

  • param – Advertising parameters.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_ext_adv_delete(struct bt_le_ext_adv *adv)

Delete advertising set.

Delete advertising set. This will free up the advertising set and make it possible to create a new advertising set.

返回:

Zero on success or (negative) error code otherwise.

uint8_t bt_le_ext_adv_get_index(struct bt_le_ext_adv *adv)

Get array index of an advertising set.

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.

参数:

adv – Advertising set.

返回:

Index of the advertising set object. The range of the returned value is 0..CONFIG_BT_EXT_ADV_MAX_ADV_SET-1

int bt_le_ext_adv_get_info(const struct bt_le_ext_adv *adv, struct bt_le_ext_adv_info *info)

Get advertising set info.

参数:
  • adv – Advertising set object

  • info – Advertising set info object

返回:

Zero on success or (negative) error code on failure.

int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv, const struct bt_le_per_adv_param *param)

Set or update the periodic advertising parameters.

The periodic advertising parameters can only be set or updated on an extended advertisement set which is neither scannable, connectable nor anonymous.

参数:
  • adv – Advertising set object.

  • param – Advertising parameters.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_set_data(const struct bt_le_ext_adv *adv, const struct bt_data *ad, size_t ad_len)

Set or update the periodic advertising data.

The periodic advertisement data can only be set or updated on an extended advertisement set which is neither scannable, connectable nor anonymous.

参数:
  • adv – Advertising set object.

  • ad – Advertising data.

  • ad_len – Advertising data length.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_set_subevent_data(const struct bt_le_ext_adv *adv, uint8_t num_subevents, const struct bt_le_per_adv_subevent_data_params *params)

Set the periodic advertising with response subevent data.

Set the data for one or more subevents of a Periodic Advertising with Responses Advertiser in reply data request.

参数:
  • adv – The extended advertiser the PAwR train belongs to.

  • num_subevents – The number of subevents to set data for.

  • params – Subevent parameters.

Pre:

There are num_subevents elements in params.

Pre:

The controller has requested data for the subevents in params.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_start(struct bt_le_ext_adv *adv)

Starts periodic advertising.

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.

Once periodic advertising has been enabled, it will continue advertising until bt_le_per_adv_stop() has been called, or if the advertising set is deleted by bt_le_ext_adv_delete(). Calling bt_le_ext_adv_stop() will not stop the periodic advertising.

参数:

adv – Advertising set object.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_stop(struct bt_le_ext_adv *adv)

Stops periodic advertising.

Disabling the periodic advertising can be done independently of extended advertising. Disabling periodic advertising will not disable extended advertising.

参数:

adv – Advertising set object.

返回:

Zero on success or (negative) error code otherwise.

uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync)

Get array index of an periodic advertising sync object.

This function is get the index of an array of periodic advertising sync objects. The array has CONFIG_BT_PER_ADV_SYNC_MAX elements.

参数:

per_adv_sync – The periodic advertising sync object.

返回:

Index of the periodic advertising sync object. The range of the returned value is 0..CONFIG_BT_PER_ADV_SYNC_MAX-1

struct bt_le_per_adv_sync *bt_le_per_adv_sync_lookup_index(uint8_t index)

Get a periodic advertising sync object from the array index.

This function is to get the periodic advertising sync object from the array index. The array has CONFIG_BT_PER_ADV_SYNC_MAX elements.

参数:

index – The index of the periodic advertising sync object. The range of the index value is 0..CONFIG_BT_PER_ADV_SYNC_MAX-1

返回:

The periodic advertising sync object of the array index or NULL if invalid index.

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)

Get periodic adv sync information.

参数:
  • per_adv_sync – Periodic advertising sync object.

  • info – Periodic advertising sync info object

返回:

Zero on success or (negative) error code on failure.

struct bt_le_per_adv_sync *bt_le_per_adv_sync_lookup_addr(const bt_addr_le_t *adv_addr, uint8_t sid)

Look up an existing periodic advertising sync object by advertiser address.

参数:
  • adv_addr – Advertiser address.

  • sid – The advertising set ID.

返回:

Periodic advertising sync object or NULL if not found.

int bt_le_per_adv_sync_create(const struct bt_le_per_adv_sync_param *param, struct bt_le_per_adv_sync **out_sync)

Create a periodic advertising sync object.

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.

参数:
  • param[in] Periodic advertising sync parameters.

  • out_sync[out] Periodic advertising sync object on.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_sync_delete(struct bt_le_per_adv_sync *per_adv_sync)

Delete periodic advertising sync.

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.

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.

参数:

per_adv_sync – The periodic advertising sync object.

返回:

Zero on success or (negative) error code otherwise.

void bt_le_per_adv_sync_cb_register(struct bt_le_per_adv_sync_cb *cb)

Register periodic advertising sync callbacks.

Adds the callback structure to the list of callback structures for periodic advertising syncs.

This callback will be called for all periodic advertising sync activity, such as synced, terminated and when data is received.

参数:

cb – Callback struct. Must point to memory that remains valid.

int bt_le_per_adv_sync_recv_enable(struct bt_le_per_adv_sync *per_adv_sync)

Enables receiving periodic advertising reports for a sync.

If the sync is already receiving the reports, -EALREADY is returned.

参数:

per_adv_sync – The periodic advertising sync object.

返回:

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)

Disables receiving periodic advertising reports for a sync.

If the sync report receiving is already disabled, -EALREADY is returned.

参数:

per_adv_sync – The periodic advertising sync object.

返回:

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)

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.

参数:
  • per_adv_sync – The periodic advertising sync to transfer.

  • conn – The peer device that will receive the sync information.

  • service_data – Application service data provided to the remote host.

返回:

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)

Transfer the information about a periodic advertising set.

This will allow another device to quickly synchronize to periodic advertising set from this device.

参数:
  • adv – The periodic advertising set to transfer info of.

  • conn – The peer device that will receive the information.

  • service_data – Application service data provided to the remote host.

返回:

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)

Subscribe to periodic advertising sync transfers (PASTs).

Sets the parameters and allow other devices to transfer periodic advertising syncs.

参数:
  • 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 – The periodic advertising sync transfer parameters.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_sync_transfer_unsubscribe(const struct bt_conn *conn)

Unsubscribe from periodic advertising sync transfers (PASTs).

Remove the parameters that allow other devices to transfer periodic advertising syncs.

参数:

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.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_list_add(const bt_addr_le_t *addr, uint8_t sid)

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.

参数:
  • addr – Bluetooth LE identity address.

  • sid – The advertising set ID. This value is obtained from the bt_le_scan_recv_info in the scan callback.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_list_remove(const bt_addr_le_t *addr, uint8_t sid)

Remove a device from the periodic advertising list.

Removes peer device LE address from the periodic advertising list.

参数:
  • addr – Bluetooth LE identity address.

  • sid – The advertising set ID. This value is obtained from the bt_le_scan_recv_info in the scan callback.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_per_adv_list_clear(void)

Clear the periodic advertising list.

Clears the entire periodic advertising list.

返回:

Zero on success or (negative) error code otherwise.

int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb)

Start (LE) scanning.

Start LE scanning with given parameters and provide results through the specified callback.

备注

The LE scanner by default does not use the Identity Address of the local device when CONFIG_BT_PRIVACY is disabled. This is to prevent the active scanner from disclosing the identity information when requesting additional information from advertisers. In order to enable directed advertiser reports then CONFIG_BT_SCAN_WITH_IDENTITY must be enabled.

参数:
  • param – Scan parameters.

  • cb – Callback to notify scan results. May be NULL if callback registration through bt_le_scan_cb_register is preferred.

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

int bt_le_scan_stop(void)

Stop (LE) scanning.

Stops ongoing LE scanning.

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

void bt_le_scan_cb_register(struct bt_le_scan_cb *cb)

Register scanner packet callbacks.

Adds the callback structure to the list of callback structures that monitors scanner activity.

This callback will be called for all scanner activity, regardless of what API was used to start the scanner.

参数:

cb – Callback struct. Must point to memory that remains valid.

void bt_le_scan_cb_unregister(struct bt_le_scan_cb *cb)

Unregister scanner packet callbacks.

Remove the callback structure from the list of scanner callbacks.

参数:

cb – Callback struct. Must point to memory that remains valid.

int bt_le_scan_check_state(void)

Check (LE) scanning state.

返回:

LE Scan state. Zero means scan not working, positive means bt dev is scanning 1 indicates passive scan and 2 means active scan.

int bt_le_filter_accept_list_add(const bt_addr_le_t *addr)

Add device (LE) to filter accept list.

Add peer device LE address to the filter accept list.

备注

The filter accept list cannot be modified when an LE role is using the filter accept list, i.e advertiser or scanner using a filter accept list or automatic connecting to devices using filter accept list.

参数:

addr – Bluetooth LE identity address.

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

static inline int bt_le_whitelist_add(const bt_addr_le_t *addr)
int bt_le_filter_accept_list_remove(const bt_addr_le_t *addr)

Remove device (LE) from filter accept list.

Remove peer device LE address from the filter accept list.

备注

The filter accept list cannot be modified when an LE role is using the filter accept list, i.e advertiser or scanner using a filter accept list or automatic connecting to devices using filter accept list.

参数:

addr – Bluetooth LE identity address.

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

static inline int bt_le_whitelist_rem(const bt_addr_le_t *addr)
int bt_le_filter_accept_list_clear(void)

Clear filter accept list.

Clear all devices from the filter accept list.

备注

The filter accept list cannot be modified when an LE role is using the filter accept list, i.e advertiser or scanner using a filter accept list or automatic connecting to devices using filter accept list.

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

static inline int bt_le_whitelist_clear(void)
int bt_le_set_chan_map(uint8_t chan_map[5])

Set (LE) channel map.

参数:

chan_map – Channel map.

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

int bt_le_set_rpa_timeout(uint16_t new_rpa_timeout)

Set the Resolvable Private Address timeout in runtime.

The new RPA timeout value will be used for the next RPA rotation and all subsequent rotations until another override is scheduled with this API.

Initially, the if CONFIG_BT_RPA_TIMEOUT is used as the RPA timeout.

This symbol is linkable if CONFIG_BT_RPA_TIMEOUT_DYNAMIC is enabled.

参数:

new_rpa_timeout – Resolvable Private Address timeout in seconds

返回值:
  • 0 – Success.

  • -EINVAL – RPA timeout value is invalid. Valid range is 1s - 3600s.

void bt_data_parse(struct net_buf_simple *ad, bool (*func)(struct bt_data *data, void *user_data), void *user_data)

Helper for parsing advertising (or EIR or OOB) data.

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().

警告

This helper function will consume `ad` when parsing. The user should make a copy if the original data is to be used afterwards

参数:
  • ad – Advertising data as given to the bt_le_scan_cb_t callback.

  • 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.

  • user_data – User data to be passed to the callback.

int bt_le_oob_get_local(uint8_t id, struct bt_le_oob *oob)

Get local LE Out of Band (OOB) information.

This function allows to get local information that are useful for Out of Band pairing or connection creation.

If privacy CONFIG_BT_PRIVACY is enabled this will result in generating new Resolvable Private Address (RPA) that is valid for CONFIG_BT_RPA_TIMEOUT seconds. This address will be used for advertising started by bt_le_adv_start, active scanning and connection creation.

备注

If privacy is enabled the RPA cannot be refreshed in the following cases:

  • Creating a connection in progress, wait for the connected callback. In addition when extended advertising CONFIG_BT_EXT_ADV is 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.

参数:
  • id[in] Local identity, in most cases BT_ID_DEFAULT.

  • oob[out] LE OOB information

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv, struct bt_le_oob *oob)

Get local LE Out of Band (OOB) information.

This function allows to get local information that are useful for Out of Band pairing or connection creation.

If privacy CONFIG_BT_PRIVACY is enabled this will result in generating new Resolvable Private Address (RPA) that is valid for CONFIG_BT_RPA_TIMEOUT seconds. This address will be used by the advertising set.

备注

When generating OOB information for multiple advertising set all OOB information needs to be generated at the same time.

备注

If privacy is enabled the RPA cannot be refreshed in the following cases:

  • Creating a connection in progress, wait for the connected callback.

参数:
  • adv[in] The advertising set object

  • oob[out] LE OOB information

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

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)

Start BR/EDR discovery.

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.

参数:
  • param – Discovery parameters.

  • results – Storage for discovery results.

  • count – Number of results in storage. Valid range: 1-255.

  • cb – Callback to notify discovery results.

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error

int bt_br_discovery_stop(void)

Stop BR/EDR discovery.

Stops ongoing BR/EDR discovery. If discovery was stopped by this call results won’t be reported

返回:

Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error.

int bt_br_oob_get_local(struct bt_br_oob *oob)

Get BR/EDR local Out Of Band information.

This function allows to get local controller information that are useful for Out Of Band pairing or connection creation process.

参数:

oob – Out Of Band information

int bt_br_set_discoverable(bool enable)

Enable/disable set controller in discoverable state.

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.

参数:

enable – Value allowing/disallowing controller to become discoverable.

返回:

Negative if fail set to requested state or requested state has been already set. Zero if done successfully.

int bt_br_set_connectable(bool enable)

Enable/disable set controller in connectable state.

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.

参数:

enable – Value allowing/disallowing controller to be connectable.

返回:

Negative if fail set to requested state or requested state has been already set. Zero if done successfully.

int bt_unpair(uint8_t id, const bt_addr_le_t *addr)

Clear pairing information.

参数:
  • id – Local identity (mostly just BT_ID_DEFAULT).

  • addr – Remote address, NULL or BT_ADDR_LE_ANY to clear all remote devices.

返回:

0 on success or negative error value on failure.

void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info, void *user_data), void *user_data)

Iterate through all existing bonds.

参数:
  • id – Local identity (mostly just BT_ID_DEFAULT).

  • func – Function to call for each bond.

  • user_data – Data to pass to the callback function.

int bt_configure_data_path(uint8_t dir, uint8_t id, uint8_t vs_config_len, const uint8_t *vs_config)

Configure vendor data path.

Request the Controller to configure the data transport path in a given direction between the Controller and the Host.

参数:
  • dir – Direction to be configured, BT_HCI_DATAPATH_DIR_HOST_TO_CTLR or BT_HCI_DATAPATH_DIR_CTLR_TO_HOST

  • id – Vendor specific logical transport channel ID, range [BT_HCI_DATAPATH_ID_VS..BT_HCI_DATAPATH_ID_VS_END]

  • vs_config_len – Length of additional vendor specific configuration data

  • vs_config – Pointer to additional vendor specific configuration data

返回:

0 in case of success or negative value in case of error.

int bt_le_per_adv_sync_subevent(struct bt_le_per_adv_sync *per_adv_sync, struct bt_le_per_adv_sync_subevent_params *params)

Synchronize with a subset of subevents.

Until this command is issued, the subevent(s) the controller is synchronized to is unspecified.

参数:
  • per_adv_sync – The periodic advertising sync object.

  • params – Parameters.

返回:

0 in case of success or negative value in case of error.

int bt_le_per_adv_set_response_data(struct bt_le_per_adv_sync *per_adv_sync, const struct bt_le_per_adv_response_params *params, const struct net_buf_simple *data)

Set the data for a response slot in a specific subevent of the PAwR.

This function is called by the application to set the response data. The data for a response slot shall be transmitted only once.

参数:
  • per_adv_sync – The periodic advertising sync object.

  • params – Parameters.

  • data – The response data to send.

返回:

Zero on success or (negative) error code otherwise.

struct bt_le_ext_adv_sent_info
struct bt_le_ext_adv_connected_info
struct bt_le_ext_adv_scanned_info
struct bt_le_per_adv_data_request
struct bt_le_per_adv_response_info
struct bt_le_ext_adv_cb
struct bt_data

Bluetooth data.

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.

struct bt_le_adv_param

LE Advertising Parameters.

struct bt_le_per_adv_param
struct bt_le_ext_adv_start_param
struct bt_le_ext_adv_info

Advertising set info structure.

struct bt_le_per_adv_subevent_data_params
struct bt_le_per_adv_sync_synced_info
struct bt_le_per_adv_sync_term_info
struct bt_le_per_adv_sync_recv_info
struct bt_le_per_adv_sync_state_info
struct bt_le_per_adv_sync_cb
struct bt_le_per_adv_sync_param
struct bt_le_per_adv_sync_info

Advertising set info structure.

struct bt_le_per_adv_sync_transfer_param
struct bt_le_scan_param

LE scan parameters

struct bt_le_scan_recv_info

LE advertisement and scan response packet information

struct bt_le_scan_cb

Listener context for (LE) scanning.

struct bt_le_oob_sc_data

LE Secure Connections pairing Out of Band data.

struct bt_le_oob

LE Out of Band information.

struct bt_br_discovery_result

BR/EDR discovery result structure.

struct bt_br_discovery_param

BR/EDR discovery parameters

struct bt_br_oob
struct bt_bond_info

Information about a bond with a remote device.

struct bt_le_per_adv_sync_subevent_params
struct bt_le_per_adv_response_params
group bt_addr

Bluetooth device address definitions and utilities.

Defines

BT_ADDR_LE_PUBLIC
BT_ADDR_LE_RANDOM
BT_ADDR_LE_PUBLIC_ID
BT_ADDR_LE_RANDOM_ID
BT_ADDR_LE_UNRESOLVED
BT_ADDR_LE_ANONYMOUS
BT_ADDR_SIZE

Length in bytes of a standard Bluetooth address

BT_ADDR_LE_SIZE

Length in bytes of an LE Bluetooth address. Not packed, so no sizeof()

BT_ADDR_ANY

Bluetooth device “any” address, not a valid address

BT_ADDR_NONE

Bluetooth device “none” address, not a valid address

BT_ADDR_LE_ANY

Bluetooth LE device “any” address, not a valid address

BT_ADDR_LE_NONE

Bluetooth LE device “none” address, not a valid address

BT_ADDR_IS_RPA(a)

Check if a Bluetooth LE random address is resolvable private address.

BT_ADDR_IS_NRPA(a)

Check if a Bluetooth LE random address is a non-resolvable private address.

BT_ADDR_IS_STATIC(a)

Check if a Bluetooth LE random address is a static address.

BT_ADDR_SET_RPA(a)

Set a Bluetooth LE random address as a resolvable private address.

BT_ADDR_SET_NRPA(a)

Set a Bluetooth LE random address as a non-resolvable private address.

BT_ADDR_SET_STATIC(a)

Set a Bluetooth LE random address as a static address.

BT_ADDR_STR_LEN

Recommended length of user string buffer for Bluetooth address.

The recommended length guarantee the output of address conversion will not lose valuable information about address being processed.

BT_ADDR_LE_STR_LEN

Recommended length of user string buffer for Bluetooth LE address.

The recommended length guarantee the output of address conversion will not lose valuable information about address being processed.

Functions

static inline int bt_addr_cmp(const bt_addr_t *a, const bt_addr_t *b)

Compare Bluetooth device addresses.

参数:
  • a – First Bluetooth device address to compare

  • b – Second Bluetooth device address to compare

返回:

negative value if a < b, 0 if a == b, else positive

static inline bool bt_addr_eq(const bt_addr_t *a, const bt_addr_t *b)

Determine equality of two Bluetooth device addresses.

返回值:
  • true – if the two addresses are equal

  • false – otherwise

static inline int bt_addr_le_cmp(const bt_addr_le_t *a, const bt_addr_le_t *b)

Compare Bluetooth LE device addresses.

参见

bt_addr_le_eq

参数:
  • a – First Bluetooth LE device address to compare

  • b – Second Bluetooth LE device address to compare

返回:

negative value if a < b, 0 if a == b, else positive

static inline bool bt_addr_le_eq(const bt_addr_le_t *a, const bt_addr_le_t *b)

Determine equality of two Bluetooth LE device addresses.

The Bluetooth LE addresses are equal iff both the types and the 48-bit addresses are numerically equal.

返回值:
  • true – if the two addresses are equal

  • false – otherwise

static inline void bt_addr_copy(bt_addr_t *dst, const bt_addr_t *src)

Copy Bluetooth device address.

参数:
  • dst – Bluetooth device address destination buffer.

  • src – Bluetooth device address source buffer.

static inline void bt_addr_le_copy(bt_addr_le_t *dst, const bt_addr_le_t *src)

Copy Bluetooth LE device address.

参数:
  • dst – Bluetooth LE device address destination buffer.

  • src – Bluetooth LE device address source buffer.

int bt_addr_le_create_nrpa(bt_addr_le_t *addr)

Create a Bluetooth LE random non-resolvable private address.

int bt_addr_le_create_static(bt_addr_le_t *addr)

Create a Bluetooth LE random static address.

static inline bool bt_addr_le_is_rpa(const bt_addr_le_t *addr)

Check if a Bluetooth LE address is a random private resolvable address.

参数:

addr – Bluetooth LE device address.

返回:

true if address is a random private resolvable address.

static inline bool bt_addr_le_is_identity(const bt_addr_le_t *addr)

Check if a Bluetooth LE address is valid identity address.

Valid Bluetooth LE identity addresses are either public address or random static address.

参数:

addr – Bluetooth LE device address.

返回:

true if address is a valid identity address.

static inline int bt_addr_to_str(const bt_addr_t *addr, char *str, size_t len)

Converts binary Bluetooth address to string.

参数:
  • addr – Address of buffer containing binary Bluetooth address.

  • str – Address of user buffer with enough room to store formatted string containing binary address.

  • len – Length of data to be copied to user string buffer. Refer to BT_ADDR_STR_LEN about recommended value.

返回:

Number of successfully formatted bytes from binary address.

static inline int bt_addr_le_to_str(const bt_addr_le_t *addr, char *str, size_t len)

Converts binary LE Bluetooth address to string.

参数:
  • addr – Address of buffer containing binary LE Bluetooth address.

  • str – Address of user buffer with enough room to store formatted string containing binary LE address.

  • len – Length of data to be copied to user string buffer. Refer to BT_ADDR_LE_STR_LEN about recommended value.

返回:

Number of successfully formatted bytes from binary address.

int bt_addr_from_str(const char *str, bt_addr_t *addr)

Convert Bluetooth address from string to binary.

参数:
  • str[in] The string representation of a Bluetooth address.

  • addr[out] Address of buffer to store the Bluetooth address

返回值:

0 – Success. The parsed address is stored in addr.

返回:

-EINVAL Invalid address string. str is not a well-formed Bluetooth address.

int bt_addr_le_from_str(const char *str, const char *type, bt_addr_le_t *addr)

Convert LE Bluetooth address from string to binary.

参数:
  • str[in] The string representation of an LE Bluetooth address.

  • type[in] The string representation of the LE Bluetooth address type.

  • addr[out] Address of buffer to store the LE Bluetooth address

返回:

Zero on success or (negative) error code otherwise.

Variables

const bt_addr_t bt_addr_any
const bt_addr_t bt_addr_none
const bt_addr_le_t bt_addr_le_any
const bt_addr_le_t bt_addr_le_none
struct bt_addr_t

Bluetooth Device Address

struct bt_addr_le_t

Bluetooth LE Device Address

group bt_gap_defines

Bluetooth Generic Access Profile defines and Assigned Numbers.

Company Identifiers (see Bluetooth Assigned Numbers)

BT_COMP_ID_LF

WinnerMicro

EIR/AD data type definitions

BT_DATA_FLAGS

AD flags

BT_DATA_UUID16_SOME

16-bit UUID, more available

BT_DATA_UUID16_ALL

16-bit UUID, all listed

BT_DATA_UUID32_SOME

32-bit UUID, more available

BT_DATA_UUID32_ALL

32-bit UUID, all listed

BT_DATA_UUID128_SOME

128-bit UUID, more available

BT_DATA_UUID128_ALL

128-bit UUID, all listed

BT_DATA_NAME_SHORTENED

Shortened name

BT_DATA_NAME_COMPLETE

Complete name

BT_DATA_TX_POWER

Tx Power

BT_DATA_SM_TK_VALUE

Security Manager TK Value

BT_DATA_SM_OOB_FLAGS

Security Manager OOB Flags

BT_DATA_PERIPHERAL_INT_RANGE

Peripheral Connection Interval Range

BT_DATA_SOLICIT16

Solicit UUIDs, 16-bit

BT_DATA_SOLICIT128

Solicit UUIDs, 128-bit

BT_DATA_SVC_DATA16

Service data, 16-bit UUID

BT_DATA_PUB_TARGET_ADDR

Public Target Address

BT_DATA_RAND_TARGET_ADDR

Random Target Address

BT_DATA_GAP_APPEARANCE

GAP appearance

BT_DATA_ADV_INT

Advertising Interval

BT_DATA_LE_BT_DEVICE_ADDRESS

LE Bluetooth Device Address

BT_DATA_LE_ROLE

LE Role

BT_DATA_SIMPLE_PAIRING_HASH

Simple Pairing Hash C256

BT_DATA_SIMPLE_PAIRING_RAND

Simple Pairing Randomizer R256

BT_DATA_SOLICIT32

Solicit UUIDs, 32-bit

BT_DATA_SVC_DATA32

Service data, 32-bit UUID

BT_DATA_SVC_DATA128

Service data, 128-bit UUID

BT_DATA_LE_SC_CONFIRM_VALUE

LE SC Confirmation Value

BT_DATA_LE_SC_RANDOM_VALUE

LE SC Random Value

BT_DATA_URI

URI

BT_DATA_INDOOR_POS

Indoor Positioning

BT_DATA_TRANS_DISCOVER_DATA

Transport Discovery Data

BT_DATA_LE_SUPPORTED_FEATURES

LE Supported Features

BT_DATA_CHANNEL_MAP_UPDATE_IND

Channel Map Update Indication

BT_DATA_MESH_PROV

Mesh Provisioning PDU

BT_DATA_MESH_MESSAGE

Mesh Networking PDU

BT_DATA_MESH_BEACON

Mesh Beacon

BT_DATA_BIG_INFO

BIGInfo

BT_DATA_BROADCAST_CODE

Broadcast Code

BT_DATA_CSIS_RSI

CSIS Random Set ID type

BT_DATA_ADV_INT_LONG

Advertising Interval long

BT_DATA_BROADCAST_NAME

Broadcast Name

BT_DATA_ENCRYPTED_AD_DATA

Encrypted Advertising Data

BT_DATA_3D_INFO

3D Information Data

BT_DATA_MANUFACTURER_DATA

Manufacturer Specific Data

BT_LE_AD_LIMITED

Limited Discoverable

BT_LE_AD_GENERAL

General Discoverable

BT_LE_AD_NO_BREDR

BR/EDR not supported

Appearance Values

Last Modified on 2023-01-05

BT_APPEARANCE_UNKNOWN

Generic Unknown

BT_APPEARANCE_GENERIC_PHONE

Generic Phone

BT_APPEARANCE_GENERIC_COMPUTER

Generic Computer

BT_APPEARANCE_COMPUTER_DESKTOP_WORKSTATION

Desktop Workstation

BT_APPEARANCE_COMPUTER_SERVER_CLASS

Server-class Computer

BT_APPEARANCE_COMPUTER_LAPTOP

Laptop

BT_APPEARANCE_COMPUTER_HANDHELD_PCPDA

Handheld PC/PDA (clamshell)

BT_APPEARANCE_COMPUTER_PALMSIZE_PCPDA

Palm­size PC/PDA

BT_APPEARANCE_COMPUTER_WEARABLE_COMPUTER

Wearable computer (watch size)

BT_APPEARANCE_COMPUTER_TABLET

Tablet

BT_APPEARANCE_COMPUTER_DOCKING_STATION

Docking Station

BT_APPEARANCE_COMPUTER_ALL_IN_ONE

All in One

BT_APPEARANCE_COMPUTER_BLADE_SERVER

Blade Server

BT_APPEARANCE_COMPUTER_CONVERTIBLE

Convertible

BT_APPEARANCE_COMPUTER_DETACHABLE

Detachable

BT_APPEARANCE_COMPUTER_IOT_GATEWAY

IoT Gateway

BT_APPEARANCE_COMPUTER_MINI_PC

Mini PC

BT_APPEARANCE_COMPUTER_STICK_PC

Stick PC

BT_APPEARANCE_GENERIC_WATCH

Generic Watch

BT_APPEARANCE_SPORTS_WATCH

Sports Watch

BT_APPEARANCE_SMARTWATCH

Smartwatch

BT_APPEARANCE_GENERIC_CLOCK

Generic Clock

BT_APPEARANCE_GENERIC_DISPLAY

Generic Display

BT_APPEARANCE_GENERIC_REMOTE

Generic Remote Control

BT_APPEARANCE_GENERIC_EYEGLASSES

Generic Eye-glasses

BT_APPEARANCE_GENERIC_TAG

Generic Tag

BT_APPEARANCE_GENERIC_KEYRING

Generic Keyring

BT_APPEARANCE_GENERIC_MEDIA_PLAYER

Generic Media Player

BT_APPEARANCE_GENERIC_BARCODE_SCANNER

Generic Barcode Scanner

BT_APPEARANCE_GENERIC_THERMOMETER

Generic Thermometer

BT_APPEARANCE_THERMOMETER_EAR

Ear Thermometer

BT_APPEARANCE_GENERIC_HEART_RATE

Generic Heart Rate Sensor

BT_APPEARANCE_HEART_RATE_BELT

Heart Rate Belt

BT_APPEARANCE_GENERIC_BLOOD_PRESSURE

Generic Blood Pressure

BT_APPEARANCE_BLOOD_PRESSURE_ARM

Arm Blood Pressure

BT_APPEARANCE_BLOOD_PRESSURE_WRIST

Wrist Blood Pressure

BT_APPEARANCE_GENERIC_HID

Generic Human Interface Device

BT_APPEARANCE_HID_KEYBOARD

Keyboard

BT_APPEARANCE_HID_MOUSE

Mouse

BT_APPEARANCE_HID_JOYSTICK

Joystick

BT_APPEARANCE_HID_GAMEPAD

Gamepad

BT_APPEARANCE_HID_DIGITIZER_TABLET

Digitizer Tablet

BT_APPEARANCE_HID_CARD_READER

Card Reader

BT_APPEARANCE_HID_DIGITAL_PEN

Digital Pen

BT_APPEARANCE_HID_BARCODE_SCANNER

Barcode Scanner

BT_APPEARANCE_HID_TOUCHPAD

Touchpad

BT_APPEARANCE_HID_PRESENTATION_REMOTE

Presentation Remote

BT_APPEARANCE_GENERIC_GLUCOSE

Generic Glucose Meter

BT_APPEARANCE_GENERIC_WALKING

Generic Running Walking Sensor

BT_APPEARANCE_WALKING_IN_SHOE

In-Shoe Running Walking Sensor

BT_APPEARANCE_WALKING_ON_SHOE

On-Shoe Running Walking Sensor

BT_APPEARANCE_WALKING_ON_HIP

On-Hip Running Walking Sensor

BT_APPEARANCE_GENERIC_CYCLING

Generic Cycling

BT_APPEARANCE_CYCLING_COMPUTER

Cycling Computer

BT_APPEARANCE_CYCLING_SPEED

Speed Sensor

BT_APPEARANCE_CYCLING_CADENCE

Cadence Sensor

BT_APPEARANCE_CYCLING_POWER

Power Sensor

BT_APPEARANCE_CYCLING_SPEED_CADENCE

Speed and Cadence Sensor

BT_APPEARANCE_GENERIC_CONTROL_DEVICE

Generic Control Device

BT_APPEARANCE_CONTROL_SWITCH

Switch

BT_APPEARANCE_CONTROL_MULTI_SWITCH

Multi-switch

BT_APPEARANCE_CONTROL_BUTTON

Button

BT_APPEARANCE_CONTROL_SLIDER

Slider

BT_APPEARANCE_CONTROL_ROTARY_SWITCH

Rotary Switch

BT_APPEARANCE_CONTROL_TOUCH_PANEL

Touch Panel

BT_APPEARANCE_CONTROL_SINGLE_SWITCH

Single Switch

BT_APPEARANCE_CONTROL_DOUBLE_SWITCH

Double Switch

BT_APPEARANCE_CONTROL_TRIPLE_SWITCH

Triple Switch

BT_APPEARANCE_CONTROL_BATTERY_SWITCH

Battery Switch

BT_APPEARANCE_CONTROL_ENERGY_HARVESTING_SWITCH

Energy Harvesting Switch

BT_APPEARANCE_CONTROL_PUSH_BUTTON

Push Button

BT_APPEARANCE_GENERIC_NETWORK_DEVICE

Generic Network Device

BT_APPEARANCE_NETWORK_ACCESS_POINT

Access Point

BT_APPEARANCE_NETWORK_MESH_DEVICE

Mesh Device

BT_APPEARANCE_NETWORK_MESH_PROXY

Mesh Network Proxy

BT_APPEARANCE_GENERIC_SENSOR

Generic Sensor

BT_APPEARANCE_SENSOR_MOTION

Motion Sensor

BT_APPEARANCE_SENSOR_AIR_QUALITY

Air quality Sensor

BT_APPEARANCE_SENSOR_TEMPERATURE

Temperature Sensor

BT_APPEARANCE_SENSOR_HUMIDITY

Humidity Sensor

BT_APPEARANCE_SENSOR_LEAK

Leak Sensor

BT_APPEARANCE_SENSOR_SMOKE

Smoke Sensor

BT_APPEARANCE_SENSOR_OCCUPANCY

Occupancy Sensor

BT_APPEARANCE_SENSOR_CONTACT

Contact Sensor

BT_APPEARANCE_SENSOR_CARBON_MONOXIDE

Carbon Monoxide Sensor

BT_APPEARANCE_SENSOR_CARBON_DIOXIDE

Carbon Dioxide Sensor

BT_APPEARANCE_SENSOR_AMBIENT_LIGHT

Ambient Light Sensor

BT_APPEARANCE_SENSOR_ENERGY

Energy Sensor

BT_APPEARANCE_SENSOR_COLOR_LIGHT

Color Light Sensor

BT_APPEARANCE_SENSOR_RAIN

Rain Sensor

BT_APPEARANCE_SENSOR_FIRE

Fire Sensor

BT_APPEARANCE_SENSOR_WIND

Wind Sensor

BT_APPEARANCE_SENSOR_PROXIMITY

Proximity Sensor

BT_APPEARANCE_SENSOR_MULTI

Multi-Sensor

BT_APPEARANCE_SENSOR_FLUSH_MOUNTED

Flush Mounted Sensor

BT_APPEARANCE_SENSOR_CEILING_MOUNTED

Ceiling Mounted Sensor

BT_APPEARANCE_SENSOR_WALL_MOUNTED

Wall Mounted Sensor

BT_APPEARANCE_MULTISENSOR

Multisensor

BT_APPEARANCE_SENSOR_ENERGY_METER

Energy Meter

BT_APPEARANCE_SENSOR_FLAME_DETECTOR

Flame Detector

BT_APPEARANCE_SENSOR_VEHICLE_TIRE_PRESSURE

Vehicle Tire Pressure Sensor

BT_APPEARANCE_GENERIC_LIGHT_FIXTURES

Generic Light Fixtures

BT_APPEARANCE_LIGHT_FIXTURES_WALL

Wall Light

BT_APPEARANCE_LIGHT_FIXTURES_CEILING

Ceiling Light

BT_APPEARANCE_LIGHT_FIXTURES_FLOOR

Floor Light

BT_APPEARANCE_LIGHT_FIXTURES_CABINET

Cabinet Light

BT_APPEARANCE_LIGHT_FIXTURES_DESK

Desk Light

BT_APPEARANCE_LIGHT_FIXTURES_TROFFER

Troffer Light

BT_APPEARANCE_LIGHT_FIXTURES_PENDANT

Pendant Light

BT_APPEARANCE_LIGHT_FIXTURES_IN_GROUND

In-ground Light

BT_APPEARANCE_LIGHT_FIXTURES_FLOOD

Flood Light

BT_APPEARANCE_LIGHT_FIXTURES_UNDERWATER

Underwater Light

BT_APPEARANCE_LIGHT_FIXTURES_BOLLARD_WITH

Bollard with Light

BT_APPEARANCE_LIGHT_FIXTURES_PATHWAY

Pathway Light

BT_APPEARANCE_LIGHT_FIXTURES_GARDEN

Garden Light

BT_APPEARANCE_LIGHT_FIXTURES_POLE_TOP

Pole-top Light

BT_APPEARANCE_SPOT_LIGHT

Spotlight

BT_APPEARANCE_LIGHT_FIXTURES_LINEAR

Linear Light

BT_APPEARANCE_LIGHT_FIXTURES_STREET

Street Light

BT_APPEARANCE_LIGHT_FIXTURES_SHELVES

Shelves Light

BT_APPEARANCE_LIGHT_FIXTURES_BAY

Bay Light

BT_APPEARANCE_LIGHT_FIXTURES_EMERGENCY_EXIT

Emergency Exit Light

BT_APPEARANCE_LIGHT_FIXTURES_CONTROLLER

Light Controller

BT_APPEARANCE_LIGHT_FIXTURES_DRIVER

Light Driver

BT_APPEARANCE_LIGHT_FIXTURES_BULB

Bulb

BT_APPEARANCE_LIGHT_FIXTURES_LOW_BAY

Low-bay Light

BT_APPEARANCE_LIGHT_FIXTURES_HIGH_BAY

High-bay Light

BT_APPEARANCE_GENERIC_FAN

Generic Fan

BT_APPEARANCE_FAN_CEILING

Ceiling Fan

BT_APPEARANCE_FAN_AXIAL

Axial Fan

BT_APPEARANCE_FAN_EXHAUST

Exhaust Fan

BT_APPEARANCE_FAN_PEDESTAL

Pedestal Fan

BT_APPEARANCE_FAN_DESK

Desk Fan

BT_APPEARANCE_FAN_WALL

Wall Fan

BT_APPEARANCE_GENERIC_HVAC

Generic HVAC

BT_APPEARANCE_HVAC_THERMOSTAT

Thermostat

BT_APPEARANCE_HVAC_HUMIDIFIER

Humidifier

BT_APPEARANCE_HVAC_DEHUMIDIFIER

De-humidifier

BT_APPEARANCE_HVAC_HEATER

Heater

BT_APPEARANCE_HVAC_RADIATOR

Radiator

BT_APPEARANCE_HVAC_BOILER

Boiler

BT_APPEARANCE_HVAC_HEAT_PUMP

Heat Pump

BT_APPEARANCE_HVAC_INFRARED_HEATER

Infrared Heater

BT_APPEARANCE_HVAC_RADIANT_PANEL_HEATER

Radiant Panel Heater

BT_APPEARANCE_HVAC_FAN_HEATER

Fan Heater

BT_APPEARANCE_HVAC_AIR_CURTAIN

Air Curtain

BT_APPEARANCE_GENERIC_AIR_CONDITIONING

Generic Air Conditioning

BT_APPEARANCE_GENERIC_HUMIDIFIER

Generic Humidifier

BT_APPEARANCE_GENERIC_HEATING

Generic Heating

BT_APPEARANCE_HEATING_RADIATOR

Radiator

BT_APPEARANCE_HEATING_BOILER

Boiler

BT_APPEARANCE_HEATING_HEAT_PUMP

Heat Pump

BT_APPEARANCE_HEATING_INFRARED_HEATER

Infrared Heater

BT_APPEARANCE_HEATING_RADIANT_PANEL_HEATER

Radiant Panel Heater

BT_APPEARANCE_HEATING_FAN_HEATER

Fan Heater

BT_APPEARANCE_HEATING_AIR_CURTAIN

Air Curtain

BT_APPEARANCE_GENERIC_ACCESS_CONTROL

Generic Access Control

BT_APPEARANCE_CONTROL_ACCESS_DOOR

Access Door

BT_APPEARANCE_CONTROL_GARAGE_DOOR

Garage Door

BT_APPEARANCE_CONTROL_EMERGENCY_EXIT_DOOR

Emergency Exit Door

BT_APPEARANCE_CONTROL_ACCESS_LOCK

Access Lock

BT_APPEARANCE_CONTROL_ELEVATOR

Elevator

BT_APPEARANCE_CONTROL_WINDOW

Window

BT_APPEARANCE_CONTROL_ENTRANCE_GATE

Entrance Gate

BT_APPEARANCE_CONTROL_DOOR_LOCK

Door Lock

BT_APPEARANCE_CONTROL_LOCKER

Locker

BT_APPEARANCE_GENERIC_MOTORIZED_DEVICE

Generic Motorized Device

BT_APPEARANCE_MOTORIZED_GATE

Motorized Gate

BT_APPEARANCE_MOTORIZED_AWNING

Awning

BT_APPEARANCE_MOTORIZED_BLINDS_OR_SHADES

Blinds or Shades

BT_APPEARANCE_MOTORIZED_CURTAINS

Curtains

BT_APPEARANCE_MOTORIZED_SCREEN

Screen

BT_APPEARANCE_GENERIC_POWER_DEVICE

Generic Power Device

BT_APPEARANCE_POWER_OUTLET

Power Outlet

BT_APPEARANCE_POWER_STRIP

Power Strip

BT_APPEARANCE_POWER_PLUG

Plug

BT_APPEARANCE_POWER_SUPPLY

Power Supply

BT_APPEARANCE_POWER_LED_DRIVER

LED Driver

BT_APPEARANCE_POWER_FLUORESCENT_LAMP_GEAR

Fluorescent Lamp Gear

BT_APPEARANCE_POWER_HID_LAMP_GEAR

HID Lamp Gear

BT_APPEARANCE_POWER_CHARGE_CASE

Charge Case

BT_APPEARANCE_POWER_POWER_BANK

Power Bank

BT_APPEARANCE_GENERIC_LIGHT_SOURCE

Generic Light Source

BT_APPEARANCE_LIGHT_SOURCE_INCANDESCENT_BULB

Incandescent Light Bulb

BT_APPEARANCE_LIGHT_SOURCE_LED_LAMP

LED Lamp

BT_APPEARANCE_LIGHT_SOURCE_HID_LAMP

HID Lamp

BT_APPEARANCE_LIGHT_SOURCE_FLUORESCENT_LAMP

Fluorescent Lamp

BT_APPEARANCE_LIGHT_SOURCE_LED_ARRAY

LED Array

BT_APPEARANCE_LIGHT_SOURCE_MULTICOLOR_LED_ARRAY

Multi-Color LED Array

BT_APPEARANCE_LIGHT_SOURCE_LOW_VOLTAGE_HALOGEN

Low voltage halogen

BT_APPEARANCE_LIGHT_SOURCE_OLED

Organic light emitting diode

BT_APPEARANCE_GENERIC_WINDOW_COVERING

Generic Window Covering

BT_APPEARANCE_WINDOW_SHADES

Window Shades

BT_APPEARANCE_WINDOW_BLINDS

Window Blinds

BT_APPEARANCE_WINDOW_AWNING

Window Awning

BT_APPEARANCE_WINDOW_CURTAIN

Window Curtain

BT_APPEARANCE_WINDOW_EXTERIOR_SHUTTER

Exterior Shutter

BT_APPEARANCE_WINDOW_EXTERIOR_SCREEN

Exterior Screen

BT_APPEARANCE_GENERIC_AUDIO_SINK

Generic Audio Sink

BT_APPEARANCE_AUDIO_SINK_STANDALONE_SPEAKER

Standalone Speaker

BT_APPEARANCE_AUDIO_SINK_SOUNDBAR

Soundbar

BT_APPEARANCE_AUDIO_SINK_BOOKSHELF_SPEAKER

Bookshelf Speaker

BT_APPEARANCE_AUDIO_SINK_STANDMOUNTED_SPEAKER

Standmounted Speaker

BT_APPEARANCE_AUDIO_SINK_SPEAKERPHONE

Speakerphone

BT_APPEARANCE_GENERIC_AUDIO_SOURCE

Generic Audio Source

BT_APPEARANCE_AUDIO_SOURCE_MICROPHONE

Microphone

BT_APPEARANCE_AUDIO_SOURCE_ALARM

Alarm

BT_APPEARANCE_AUDIO_SOURCE_BELL

Bell

BT_APPEARANCE_AUDIO_SOURCE_HORN

Horn

BT_APPEARANCE_AUDIO_SOURCE_BROADCASTING_DEVICE

Broadcasting Device

BT_APPEARANCE_AUDIO_SOURCE_SERVICE_DESK

Service Desk

BT_APPEARANCE_AUDIO_SOURCE_KIOSK

Kiosk

BT_APPEARANCE_AUDIO_SOURCE_BROADCASTING_ROOM

Broadcasting Room

BT_APPEARANCE_AUDIO_SOURCE_AUDITORIUM

Auditorium

BT_APPEARANCE_GENERIC_MOTORIZED_VEHICLE

Generic Motorized Vehicle

BT_APPEARANCE_VEHICLE_CAR

Car

BT_APPEARANCE_VEHICLE_LARGE_GOODS

Large Goods Vehicle

BT_APPEARANCE_VEHICLE_TWO_WHEELED

2-Wheeled Vehicle

BT_APPEARANCE_VEHICLE_MOTORBIKE

Motorbike

BT_APPEARANCE_VEHICLE_SCOOTER

Scooter

BT_APPEARANCE_VEHICLE_MOPED

Moped

BT_APPEARANCE_VEHICLE_THREE_WHEELED

3-Wheeled Vehicle

BT_APPEARANCE_VEHICLE_LIGHT

Light Vehicle

BT_APPEARANCE_VEHICLE_QUAD_BIKE

Quad Bike

BT_APPEARANCE_VEHICLE_MINIBUS

Minibus

BT_APPEARANCE_VEHICLE_BUS

Bus

BT_APPEARANCE_VEHICLE_TROLLEY

Trolley

BT_APPEARANCE_VEHICLE_AGRICULTURAL

Agricultural Vehicle

BT_APPEARANCE_VEHICLE_CAMPER_OR_CARAVAN

Camper/Caravan

BT_APPEARANCE_VEHICLE_RECREATIONAL

Recreational Vehicle/Motor Home

BT_APPEARANCE_GENERIC_DOMESTIC_APPLIANCE

Generic Domestic Appliance

BT_APPEARANCE_APPLIANCE_REFRIGERATOR

Refrigerator

BT_APPEARANCE_APPLIANCE_FREEZER

Freezer

BT_APPEARANCE_APPLIANCE_OVEN

Oven

BT_APPEARANCE_APPLIANCE_MICROWAVE

Microwave

BT_APPEARANCE_APPLIANCE_TOASTER

Toaster

BT_APPEARANCE_APPLIANCE_WASHING_MACHINE

Washing Machine

BT_APPEARANCE_APPLIANCE_DRYER

Dryer

BT_APPEARANCE_APPLIANCE_COFFEE_MAKER

Coffee maker

BT_APPEARANCE_APPLIANCE_CLOTHES_IRON

Clothes iron

BT_APPEARANCE_APPLIANCE_CURLING_IRON

Curling iron

BT_APPEARANCE_APPLIANCE_HAIR_DRYER

Hair dryer

BT_APPEARANCE_APPLIANCE_VACUUM_CLEANER

Vacuum cleaner

BT_APPEARANCE_APPLIANCE_ROBOTIC_VACUUM_CLEANER

Robotic vacuum cleaner

BT_APPEARANCE_APPLIANCE_RICE_COOKER

Rice cooker

BT_APPEARANCE_APPLIANCE_CLOTHES_STEAMER

Clothes steamer

BT_APPEARANCE_GENERIC_WEARABLE_AUDIO_DEVICE

Generic Wearable Audio Device

BT_APPEARANCE_WEARABLE_AUDIO_DEVICE_EARBUD

Earbud

BT_APPEARANCE_WEARABLE_AUDIO_DEVICE_HEADSET

Headset

BT_APPEARANCE_WEARABLE_AUDIO_DEVICE_HEADPHONES

Headphones

BT_APPEARANCE_WEARABLE_AUDIO_DEVICE_NECK_BAND

Neck Band

BT_APPEARANCE_GENERIC_AIRCRAFT

Generic Aircraft

BT_APPEARANCE_AIRCRAFT_LIGHT

Light Aircraft

BT_APPEARANCE_AIRCRAFT_MICROLIGHT

Microlight

BT_APPEARANCE_AIRCRAFT_PARAGLIDER

Paraglider

BT_APPEARANCE_AIRCRAFT_LARGE_PASSENGER

Large Passenger Aircraft

BT_APPEARANCE_GENERIC_AV_EQUIPMENT

Generic AV Equipment

BT_APPEARANCE_AV_EQUIPMENT_AMPLIFIER

Amplifier

BT_APPEARANCE_AV_EQUIPMENT_RECEIVER

Receiver

BT_APPEARANCE_AV_EQUIPMENT_RADIO

Radio

BT_APPEARANCE_AV_EQUIPMENT_TUNER

Tuner

BT_APPEARANCE_AV_EQUIPMENT_TURNTABLE

Turntable

BT_APPEARANCE_AV_EQUIPMENT_CD_PLAYER

CD Player

BT_APPEARANCE_AV_EQUIPMENT_DVD_PLAYER

DVD Player

BT_APPEARANCE_AV_EQUIPMENT_BLURAY_PLAYER

Bluray Player

BT_APPEARANCE_AV_EQUIPMENT_OPTICAL_DISC_PLAYER

Optical Disc Player

BT_APPEARANCE_AV_EQUIPMENT_SET_TOP_BOX

Set-Top Box

BT_APPEARANCE_GENERIC_DISPLAY_EQUIPMENT

Generic Display Equipment

BT_APPEARANCE_DISPLAY_EQUIPMENT_TELEVISION

Television

BT_APPEARANCE_DISPLAY_EQUIPMENT_MONITOR

Monitor

BT_APPEARANCE_DISPLAY_EQUIPMENT_PROJECTOR

Projector

BT_APPEARANCE_GENERIC_HEARING_AID

Generic Hearing aid

BT_APPEARANCE_HEARING_AID_IN_EAR

In-ear hearing aid

BT_APPEARANCE_HEARING_AID_BEHIND_EAR

Behind-ear hearing aid

BT_APPEARANCE_HEARING_AID_COCHLEAR_IMPLANT

Cochlear Implant

BT_APPEARANCE_GENERIC_GAMING

Generic Gaming

BT_APPEARANCE_HOME_VIDEO_GAME_CONSOLE

Home Video Game Console

BT_APPEARANCE_PORTABLE_HANDHELD_CONSOLE

Portable handheld console

BT_APPEARANCE_GENERIC_SIGNAGE

Generic Signage

BT_APPEARANCE_SIGNAGE_DIGITAL

Digital Signage

BT_APPEARANCE_SIGNAGE_ELECTRONIC_LABEL

Electronic Label

BT_APPEARANCE_GENERIC_PULSE_OXIMETER

Generic Pulse Oximeter

BT_APPEARANCE_PULSE_OXIMETER_FINGERTIP

Fingertip Pulse Oximeter

BT_APPEARANCE_PULSE_OXIMETER_WRIST

Wrist Worn Pulse Oximeter

BT_APPEARANCE_GENERIC_WEIGHT_SCALE

Generic Weight Scale

BT_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE

Generic Personal Mobility Device

BT_APPEARANCE_MOBILITY_POWERED_WHEELCHAIR

Powered Wheelchair

BT_APPEARANCE_MOBILITY_SCOOTER

Mobility Scooter

BT_APPEARANCE_CONTINUOUS_GLUCOSE_MONITOR

Continuous Glucose Monitor

BT_APPEARANCE_GENERIC_INSULIN_PUMP

Generic Insulin Pump

BT_APPEARANCE_INSULIN_PUMP_DURABLE

Insulin Pump, durable pump

BT_APPEARANCE_INSULIN_PUMP_PATCH

Insulin Pump, patch pump

BT_APPEARANCE_INSULIN_PEN

Insulin Pen

BT_APPEARANCE_GENERIC_MEDICATION_DELIVERY

Generic Medication Delivery

BT_APPEARANCE_GENERIC_SPIROMETER

Generic Spirometer

BT_APPEARANCE_SPIROMETER_HANDHELD

Handheld Spirometer

BT_APPEARANCE_GENERIC_OUTDOOR_SPORTS

Generic Outdoor Sports Activity

BT_APPEARANCE_OUTDOOR_SPORTS_LOCATION

Location Display

BT_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV

Location and Navigation Display

BT_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD

Location Pod

BT_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV

Location and Navigation Pod

Defined GAP timers

BT_GAP_SCAN_FAST_INTERVAL
BT_GAP_SCAN_FAST_WINDOW
BT_GAP_SCAN_SLOW_INTERVAL_1
BT_GAP_SCAN_SLOW_WINDOW_1
BT_GAP_SCAN_SLOW_INTERVAL_2
BT_GAP_SCAN_SLOW_WINDOW_2
BT_GAP_ADV_FAST_INT_MIN_1
BT_GAP_ADV_FAST_INT_MAX_1
BT_GAP_ADV_FAST_INT_MIN_2
BT_GAP_ADV_FAST_INT_MAX_2
BT_GAP_ADV_SLOW_INT_MIN
BT_GAP_ADV_SLOW_INT_MAX
BT_GAP_PER_ADV_FAST_INT_MIN_1
BT_GAP_PER_ADV_FAST_INT_MAX_1
BT_GAP_PER_ADV_FAST_INT_MIN_2
BT_GAP_PER_ADV_FAST_INT_MAX_2
BT_GAP_PER_ADV_SLOW_INT_MIN
BT_GAP_PER_ADV_SLOW_INT_MAX
BT_GAP_INIT_CONN_INT_MIN
BT_GAP_INIT_CONN_INT_MAX

Defines

BT_GAP_ADV_MAX_ADV_DATA_LEN

Maximum advertising data length.

BT_GAP_ADV_MAX_EXT_ADV_DATA_LEN

Maximum extended advertising data length.

备注

The maximum advertising data length that can be sent by an extended advertiser is defined by the controller.

BT_GAP_TX_POWER_INVALID
BT_GAP_RSSI_INVALID
BT_GAP_SID_INVALID
BT_GAP_NO_TIMEOUT
BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT
BT_GAP_DATA_LEN_DEFAULT

Default data length

BT_GAP_DATA_LEN_MAX

Maximum data length

BT_GAP_DATA_TIME_DEFAULT

Default data time

BT_GAP_DATA_TIME_MAX

Maximum data time

BT_GAP_SID_MAX

Maximum advertising set number

BT_GAP_PER_ADV_MAX_SKIP

Maximum number of consecutive periodic advertisement events that can be skipped after a successful receive.

BT_GAP_PER_ADV_MIN_TIMEOUT

Minimum Periodic Advertising Timeout (N * 10 ms)

BT_GAP_PER_ADV_MAX_TIMEOUT

Maximum Periodic Advertising Timeout (N * 10 ms)

BT_GAP_PER_ADV_MIN_INTERVAL

Minimum Periodic Advertising Interval (N * 1.25 ms)

BT_GAP_PER_ADV_MAX_INTERVAL

Maximum Periodic Advertising Interval (N * 1.25 ms)

BT_GAP_PER_ADV_INTERVAL_TO_MS(interval)

Convert periodic advertising interval (N * 1.25 ms) to milliseconds.

5 / 4 represents 1.25 ms unit.

BT_LE_SUPP_FEAT_40_ENCODE(w64)

Encode 40 least significant bits of 64-bit LE Supported Features into array values in little-endian format.

Helper macro to encode 40 least significant bits of 64-bit LE Supported Features value into advertising data. The number of bits that are encoded is a number of LE Supported Features defined by BT 5.3 Core specification.

Example of how to encode the `0x000000DFF00DF00D` into advertising data.

BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_40_ENCODE(0x000000DFF00DF00D))
参数:
  • w64 – LE Supported Features value (64-bits)

返回:

The comma separated values for LE Supported Features value that may be used directly as an argument for BT_DATA_BYTES.

BT_LE_SUPP_FEAT_32_ENCODE(w64)

Encode 4 least significant bytes of 64-bit LE Supported Features into 4 bytes long array of values in little-endian format.

Helper macro to encode 64-bit LE Supported Features value into advertising data. The macro encodes 4 least significant bytes into advertising data. Other 4 bytes are not encoded.

Example of how to encode the `0x000000DFF00DF00D` into advertising data.

BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_32_ENCODE(0x000000DFF00DF00D))
参数:
  • w64 – LE Supported Features value (64-bits)

返回:

The comma separated values for LE Supported Features value that may be used directly as an argument for BT_DATA_BYTES.

BT_LE_SUPP_FEAT_24_ENCODE(w64)

Encode 3 least significant bytes of 64-bit LE Supported Features into 3 bytes long array of values in little-endian format.

Helper macro to encode 64-bit LE Supported Features value into advertising data. The macro encodes 3 least significant bytes into advertising data. Other 5 bytes are not encoded.

Example of how to encode the `0x000000DFF00DF00D` into advertising data.

BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_24_ENCODE(0x000000DFF00DF00D))
参数:
  • w64 – LE Supported Features value (64-bits)

返回:

The comma separated values for LE Supported Features value that may be used directly as an argument for BT_DATA_BYTES.

BT_LE_SUPP_FEAT_16_ENCODE(w64)

Encode 2 least significant bytes of 64-bit LE Supported Features into 2 bytes long array of values in little-endian format.

Helper macro to encode 64-bit LE Supported Features value into advertising data. The macro encodes 3 least significant bytes into advertising data. Other 6 bytes are not encoded.

Example of how to encode the `0x000000DFF00DF00D` into advertising data.

BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_16_ENCODE(0x000000DFF00DF00D))
参数:
  • w64 – LE Supported Features value (64-bits)

返回:

The comma separated values for LE Supported Features value that may be used directly as an argument for BT_DATA_BYTES.

BT_LE_SUPP_FEAT_8_ENCODE(w64)

Encode the least significant byte of 64-bit LE Supported Features into single byte long array.

Helper macro to encode 64-bit LE Supported Features value into advertising data. The macro encodes the least significant byte into advertising data. Other 7 bytes are not encoded.

Example of how to encode the `0x000000DFF00DF00D` into advertising data.

BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_8_ENCODE(0x000000DFF00DF00D))
参数:
  • w64 – LE Supported Features value (64-bits)

返回:

The value of least significant byte of LE Supported Features value that may be used directly as an argument for BT_DATA_BYTES.

BT_LE_SUPP_FEAT_VALIDATE(w64)

Validate whether LE Supported Features value does not use bits that are reserved for future use.

Helper macro to check if w64 has zeros as bits 40-63. The macro is compliant with BT 5.3 Core Specification where bits 0-40 has assigned values. In case of invalid value, build time error is reported.

Enums

enum bt_gap_le_phy

LE PHY types

Values:

enumerator BT_GAP_LE_PHY_NONE

Convenience macro for when no PHY is set.

enumerator BT_GAP_LE_PHY_1M

LE 1M PHY

enumerator BT_GAP_LE_PHY_2M

LE 2M PHY

enumerator BT_GAP_LE_PHY_CODED

LE Coded PHY

enum bt_gap_adv_type

Advertising PDU types

Values:

enumerator BT_GAP_ADV_TYPE_ADV_IND

Scannable and connectable advertising.

enumerator BT_GAP_ADV_TYPE_ADV_DIRECT_IND

Directed connectable advertising.

enumerator BT_GAP_ADV_TYPE_ADV_SCAN_IND

Non-connectable and scannable advertising.

enumerator BT_GAP_ADV_TYPE_ADV_NONCONN_IND

Non-connectable and non-scannable advertising.

enumerator BT_GAP_ADV_TYPE_SCAN_RSP

Additional advertising data requested by an active scanner.

enumerator BT_GAP_ADV_TYPE_EXT_ADV

Extended advertising, see advertising properties.

enum bt_gap_adv_prop

Advertising PDU properties

Values:

enumerator BT_GAP_ADV_PROP_CONNECTABLE

Connectable advertising.

enumerator BT_GAP_ADV_PROP_SCANNABLE

Scannable advertising.

enumerator BT_GAP_ADV_PROP_DIRECTED

Directed advertising.

enumerator BT_GAP_ADV_PROP_SCAN_RESPONSE

Additional advertising data requested by an active scanner.

enumerator BT_GAP_ADV_PROP_EXT_ADV

Extended advertising.

enum bt_gap_cte

Constant Tone Extension (CTE) types

Values:

enumerator BT_GAP_CTE_AOA

Angle of Arrival

enumerator BT_GAP_CTE_AOD_1US

Angle of Departure with 1 us slots

enumerator BT_GAP_CTE_AOD_2US

Angle of Departure with 2 us slots

enumerator BT_GAP_CTE_NONE

No extensions

enum bt_gap_sca

Peripheral sleep clock accuracy (SCA) in ppm (parts per million)

Values:

enumerator BT_GAP_SCA_UNKNOWN

Unknown

enumerator BT_GAP_SCA_251_500

251 ppm to 500 ppm

enumerator BT_GAP_SCA_151_250

151 ppm to 250 ppm

enumerator BT_GAP_SCA_101_150

101 ppm to 150 ppm

enumerator BT_GAP_SCA_76_100

76 ppm to 100 ppm

enumerator BT_GAP_SCA_51_75

51 ppm to 75 ppm

enumerator BT_GAP_SCA_31_50

31 ppm to 50 ppm

enumerator BT_GAP_SCA_21_30

21 ppm to 30 ppm

enumerator BT_GAP_SCA_0_20

0 ppm to 20 ppm