Google is committed to advancing racial equity for Black communities. See how.

fuchsia.bluetooth.le

PROTOCOLS

AdvertisedPeripheral

Defined in fuchsia.bluetooth.le/peripheral.fidl

Protocol that is valid for the duration of advertising. The caller can close the protocol to stop advertising. If the system internally stops advertising for any reason, the protocol will be closed to communicate this to the client.

OnConnected

Called when a remote LE central connects to this peripheral when connectable advertising is enabled via fuchsia.bluetooth.le/Peripheral.Advertise. When this call is made, the system has paused advertising, and will not continue until it receives a response.

The returned fuchsia.bluetooth.le/Connection protocol can be used to interact with the peer. It also represents a peripheral's ownership over the connection: the client can drop the protocol to request a disconnection. Similarly, the protocol is closed by the system to indicate that the connection to the peer has been lost.

  • request peer Information about the central that initiated the connection.
  • request connection Represents the connection.
  • response An empty response should be sent to acknowledge the connection and resume advertising (for flow control).

Request

NameType
peer Peer
connection Connection

Response

<EMPTY>

AdvertisingHandle

Defined in fuchsia.bluetooth.le/peripheral.fidl

Capability that is valid for the duration of advertising. The caller can close the handle to stop advertising. If the system internally stops advertising for any reason, the handle will be closed to communicate this to the client.

Central

Defined in fuchsia.bluetooth.le/central.fidl

Connect

Connect to the peer with the given identifier.

The requested fuchsia.bluetooth.le/Connection represents the client's interest on the LE connection to the peer. Closing the channel removes interest, but may not result in disconnection if another client holds a valid fuchsia.bluetooth.le/Connection to the same peer.

The fuchsia.bluetooth.le/Connection handle will be closed by the system if the connection to the peer is lost or an error occurs.

The following epitaphs may be sent by the server on error: + INVALID_ARGS: Some of the parameters are invalid. + NOT_CONNECTED: A connection could not be established.

  • request id Identifier of the peer to initiate a connection to.
  • request options Options used to configure the connection.
  • request handle Handle that remains valid for the duration of this connection.

Request

NameType
id fuchsia.bluetooth/PeerId
options ConnectionOptions
handle request<Connection>

ConnectPeripheral

Creates a connection to the peripheral device with the given identifier. Returns the status of the operation in status.

On success, gatt_client will be bound and can be used for GATT client role procedures. On failure, gatt_client will be closed and status will indicate an error.

DEPRECATED - Use Connect instead

Request

NameType
identifier fuchsia.bluetooth/PeerIdString
options ConnectionOptions
gatt_client request<fuchsia.bluetooth.gatt/Client>

Response

NameType
status fuchsia.bluetooth/Status

DisconnectPeripheral

Disconnects this Central's connection to the peripheral with the given identifier.

DEPRECATED

Request

NameType
identifier fuchsia.bluetooth/PeerIdString

Response

NameType
status fuchsia.bluetooth/Status

GetPeripheral

This method is not implemented by the Fuchsia core stack- TODO(fxbug.dev/1424)

Returns information about a single peripheral that is known to the system from previous scan, connection, and/or bonding procedures based on its unique identifier. Returns null if identifier is not recognized.

DEPRECATED

Request

NameType
identifier fuchsia.bluetooth/PeerIdString

Response

NameType
peripheral RemoteDevice?

GetPeripherals

Returns the list of peripherals that are known to the system from previous scan, connection, and/or bonding procedures. The results can be filtered based on service UUIDs that are known to be present on the peripheral.

This method only returns peripherals (i.e. connectable devices).

DEPRECATED

Request

NameType
service_uuids vector<string>?

Response

NameType
peripherals vector<RemoteDevice>

OnDeviceDiscovered

Called for each peripheral/broadcaster that is discovered during a scan session. rssi contains the received signal strength of the advertising packet that generated this event, if available.

DEPRECATED

Response

NameType
device RemoteDevice

OnPeripheralDisconnected

Called when this Central's connection to a peripheral with the given identifier is terminated.

DEPRECATED

Response

NameType
identifier fuchsia.bluetooth/PeerIdString

OnScanStateChanged

Called when the scan state changes, e.g. when a scan session terminates due to a call to Central.StopScan() or another unexpected condition.

DEPRECATED

Response

NameType
scanning bool

Scan

Scans for nearby LE peripherals and broadcasters. If the scan cannot be initiated, then result_watcher will be closed with an epitaph.

A Central client is allowed to have only one active scan at a time. Accordingly, only one Scan request can be outstanding at a time. Additional calls to Scan will fail.

The lifetime of the scan session is tied to the result_watcher protocol provided. The scan will be stopped if the channel is closed.

Once a scan is started, the fuchsia.bluetooth.le/ScanResultWatcher can be used to watch for scan results.

  • request options Options used to configure the scan session.
  • request result_watcher Protocol that remains valid for the duration of this scan session.
  • response An empty response will be sent to acknowledge the scan has stopped.

The following epitaphs may be sent by the server on error:

  • error ALREADY_EXISTS: A scan is already in progress. Each Central protocol is only allowed 1 active scan.
  • error INVALID_ARGS: Some of the scan options are invalid. See the ScanOptions documentation.
  • error INTERNAL: An internal error occurred and a scan could not be started.

Request

NameType
options ScanOptions
result_watcher request<ScanResultWatcher>

Response

<EMPTY>

StartScan

Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress, filter will replace the existing session's filter.

If filter is null or empty (i.e. none of its fields has been populated) then the delegate will be notified for all discoverable devices that are found. This is not recommended; clients should generally filter results by at least one of filter.service_uuids, filter.service_data, and/or filter.manufacturer_identifier.

DEPRECATED - Use Scan instead

Request

NameType
filter ScanFilter?

Response

NameType
status fuchsia.bluetooth/Status

StopScan

Terminate a previously started scan session.

DEPRECATED

Request

<EMPTY>

Connection

Defined in fuchsia.bluetooth.le/peer.fidl

Protocol that represents the connection to a peer. This can be used to interact with GATT services and establish L2CAP channels.

This lifetime of this capability is tied to that of the LE connection it represents. Closing the channel results in a disconnection if no other clients hold a Connection to the same peer.

Peripheral

Defined in fuchsia.bluetooth.le/peripheral.fidl

Advertise

Start advertising continuously as a LE peripheral. If advertising cannot be initiated then advertised_peripheral will be closed and an error will be returned.

This method may be called any number of times. To reconfigure an advertisement, first close the original advertisement and then initiate a new advertisement after an empty response is returned.

If the client closes its end of the fuchsia.bluetooth.le/AdvertisedPeripheral channel, advertising will be stopped. If the handle is closed before the request is fulfilled, advertising may be briefly enabled before it is terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of the Peripheral protocol, but this may be changed in the future (fxbug.dev/77644).

  • request parameters Parameters used while configuring the advertising instance.
  • request advertised_peripheral Protocol that remains valid for the duration of this advertising session.
  • response An empty response will be sent when the advertisement is successfully stopped (due to release of the advertised_peripheral protocol). To prevent overlapping similar advertisements and transient errors with limited advertising resources, waiting for a response is recommended before calling Advertise again.
  • error If an error occurs, advertised_peripheral will be closed and a PeripheralError will be returned.

Request

NameType
parameters AdvertisingParameters
advertised_peripheral AdvertisedPeripheral

Response

NameType
result Peripheral_Advertise_Result

OnPeerConnected

Event delivered when a remote LE central initiates a connection to this Peripheral when connectable advertising is enabled via fuchsia.bluetooth.le/Peripheral.StartAdvertising.

The returned fuchsia.bluetooth.le/Connection handle can be used to interact with the peer. It also represents a peripheral's ownership over the connection: the client can drop the handle to request a disconnection. Similarly, the handle is closed by the system to indicate that the connection to the peer has been lost.

  • request peer Information about the central that initiated the connection.
  • request connection Represents the connection.

DEPRECATED

Response

NameType
peer Peer
connection Connection

StartAdvertising

Start advertising as a LE peripheral. An empty response is sent to indicate when advertising has successfully initiated. If advertising cannot be initiated, then the response will contain a fuchsia.bluetooth.le/PeripheralError.

This method can get called any number of times and successive calls can be made to reconfigure the advertising parameters. However only the most recent fuchsia.bluetooth.le/AdvertisingHandle will remain valid.

An instance of fuchsia.bluetooth.le/Peripheral can only have one active advertisement at a time. Clients must obtain multiple Peripheral instances for multiple simultaneous advertisements.

If the client closes its end of the fuchsia.bluetooth.le/AdvertisingHandle channel, advertising will be stopped. If the handle is closed before the request is fulfilled, advertising will be briefly enabled before it is terminated.

  • request parameters Parameters used while configuring the advertising instance.
  • request handle Handle that remains valid for the duration of this advertising session.

DEPRECATED

Request

NameType
parameters AdvertisingParameters
handle request<AdvertisingHandle>

Response

NameType
result Peripheral_StartAdvertising_Result

ScanResultWatcher

Defined in fuchsia.bluetooth.le/central.fidl

Represents an active scan procedure. This protocol remains valid for the duration of a scan and can be used to obtain scan results. The client can close the protocol to stop scanning. If a scan is stopped by the system, the protocol will be closed with the epitaph CANCELED to communicate this to the client.

Watch

Returns a list of all LE peers that satisfy the filters indicated in ScanOptions. The first response(s) will return matching discovered peers immediately. Subsequent calls receive a response only when peers have been scanned or updated since the last call. If a second call to Watch is erronously sent while one call is already pending, the scan will be canceled and the protocol will be closed.

  • response updated Peers that were added or updated since the last call to Watch().

Request

<EMPTY>

Response

NameType
updated vector<Peer>

STRUCTS

AdvertisingDataDeprecated

Defined in fuchsia.bluetooth.le/types_deprecated.fidl

Represents advertising and scan response data advertised by a broadcaster or peripheral.

DEPRECATED - Use AdvertisingData instead

FieldTypeDescriptionDefault
name fuchsia.bluetooth/DeviceName

Name of the device.

No default
tx_power_level fuchsia.bluetooth/Int8?

The radio transmission power level reported in the advertisement.

No default
appearance fuchsia.bluetooth/UInt16?

The appearance reported in the advertisemet.

No default
service_uuids vector<string>?

List of service UUIDs reported in the advertisement.

No default
service_data vector<ServiceDataEntry>?

Service data included in the advertisement.

No default
manufacturer_specific_data vector<ManufacturerSpecificDataEntry>?

Manufacturer specific data entries.

No default
solicited_service_uuids vector<string>?

Service UUIDs that were solicited in the advertisement. Peripherals can invite centrals that expose certain services to connect to them using service solicitation.

No default
uris vector<string>?

URIs included in the advertising packet. These are full URIs (they are encoded/decoded automatically)

No default

ManufacturerData

Defined in fuchsia.bluetooth.le/advertising_data.fidl

Entry in the manufacturer_data field of a fuchsia.bluetooth.le/AdvertisingData.

FieldTypeDescriptionDefault
company_id uint16 No default
data vector<uint8>[252] No default

ManufacturerSpecificDataEntry

Defined in fuchsia.bluetooth.le/types_deprecated.fidl

DEPRECATED - Use ManufacturerData instead

FieldTypeDescriptionDefault
company_id uint16 No default
data vector<uint8> No default

Peripheral_Advertise_Response

Defined in fuchsia.bluetooth.le/peripheral.fidl

<EMPTY>

Peripheral_StartAdvertising_Response

Defined in fuchsia.bluetooth.le/peripheral.fidl

<EMPTY>

RemoteDevice

Defined in fuchsia.bluetooth.le/types_deprecated.fidl

Represents a remote Bluetooth Low Energy device. A RemoteDevice can represent a central, broadcaster, or peripheral based on the API from which it was received.

DEPRECATED - Use Peer instead

FieldTypeDescriptionDefault
identifier fuchsia.bluetooth/PeerIdString

Identifier that uniquely identifies this device on the current system.

No default
connectable bool

Whether or not this device is connectable. Non-connectable devices are typically acting in the LE broadcaster role.

No default
rssi fuchsia.bluetooth/Int8?

The last known RSSI of this device, if known.

No default
advertising_data AdvertisingDataDeprecated?

Advertising data broadcast by this device if this device is a broadcaster or peripheral.

No default

ScanFilter

Defined in fuchsia.bluetooth.le/types_deprecated.fidl

Filter parameters for use during a scan. A discovered peripheral or broadcaster will be reported to applications only if it satisfies all of the provided filter parameters. Null fields will be ignored.

DEPRECATED - Use Filter instead

FieldTypeDescriptionDefault
service_uuids vector<string>?

Filter based on advertised service UUIDs. A peripheral that advertises at least one of the entries in service_uuids will satisfy this filter.

No default
service_data_uuids vector<string>?

Filter based on service data containing one of the given UUIDs.

No default
manufacturer_identifier fuchsia.bluetooth/UInt16?

Filter based on a company identifier present in the manufacturer data. If this filter parameter is set, then the advertising payload must contain manufacturer specific data with the provided company identifier to satisfy this filter.

No default
connectable fuchsia.bluetooth/Bool?

Filter based on whether or not a device is connectable. For example, a client that is only interested in peripherals that it can connect to can set this to true. Similarly a client can scan only for braodcasters by setting this to false.

No default
name_substring fuchsia.bluetooth/DeviceName

Filter results based on a portion of the advertised device name.

No default
max_path_loss fuchsia.bluetooth/Int8?

Filter results based on the path loss of the radio wave. A device that matches this filter must satisfy the following:

  1. Radio transmission power level and received signal strength must be available for the path loss calculation;
  2. The calculated path loss value must be less than, or equal to, max_path_loss.
No default

ServiceData

Defined in fuchsia.bluetooth.le/advertising_data.fidl

Entry in the service_data field of a fuchsia.bluetooth.le/AdvertisingData.

FieldTypeDescriptionDefault
uuid fuchsia.bluetooth/Uuid No default
data vector<uint8>[252] No default

ServiceDataEntry

Defined in fuchsia.bluetooth.le/types_deprecated.fidl

DEPRECATED - Use ServiceData instead

FieldTypeDescriptionDefault
uuid fuchsia.bluetooth/UuidString No default
data vector<uint8> No default

ENUMS

AdvertisingModeHint strict

Type: uint8

Defined in fuchsia.bluetooth.le/peripheral.fidl

A client can indicate the transmission rate of advertising packets by specifying a mode. The mode provides a hint to the system when configuring the controller with advertising interval and window parameters.

The mode affects how quickly a scanner or central is able to discover the peripheral; however it can have an adverse effect on power consumption. While the system will try to honor a client's request, it is not guaranteed to do so.

NameValueDescription
VERY_FAST 1

Advertise with a very short interval and window for fast discovery at the cost of higher power consumption. This corresponds to a 30-60ms interval on the 1M PHYs and 90-180ms on the coded PHY.

FAST 2

Advertise with a short interval and window that uses less power than VERY_FAST. This corresponds to a 100-150ms interval on the 1M PHYs and 300-450ms on the coded PHY.

SLOW 3

Advertise with a moderate interval and window. This corresponds to 1-1.2s on the 1M PHYs and 3s on the coded PHY.

CentralError strict

Type: uint32

Defined in fuchsia.bluetooth.le/central.fidl

NameValueDescription
ABORTED 1

The request was aborted.

IN_PROGRESS 2

The request is already in progress.

INVALID_PARAMETERS 3

The provided parameters are invalid.

FAILED 4

Advertising could not be initiated due to a hardware or system error.

PeripheralError strict

Type: uint32

Defined in fuchsia.bluetooth.le/peripheral.fidl

NameValueDescription
NOT_SUPPORTED 1

The operation or parameters requested are not supported on the current hardware.

ADVERTISING_DATA_TOO_LONG 2

The provided advertising data exceeds the maximum allowed length when encoded.

SCAN_RESPONSE_DATA_TOO_LONG 3

The provided scan response data exceeds the maximum allowed length when encoded.

INVALID_PARAMETERS 4

The requested parameters are invalid.

ABORTED 5

The request to start advertising was aborted, for example by issuing a new request with new parameters.

FAILED 6

Advertising could not be initiated due to a hardware or system error.

TABLES

AdvertisingData

Defined in fuchsia.bluetooth.le/advertising_data.fidl

Represents advertising and scan response data that are transmitted by a LE peripheral or broadcaster.

OrdinalFieldTypeDescription
1 name fuchsia.bluetooth/DeviceName

Long or short name of the device.

2 appearance fuchsia.bluetooth/Appearance

The appearance of the device.

3 tx_power_level int8

DEPRECATED - Use include_tx_power_level instead. This value will be ignored.

4 service_uuids vector<fuchsia.bluetooth/Uuid>

Service UUIDs.

5 service_data vector<ServiceData>

Service data entries.

6 manufacturer_data vector<ManufacturerData>

Manufacturer-specific data entries.

7 uris vector<string>

String representing a URI to be advertised, as defined in IETF STD 66. Each entry should be a UTF-8 string including the scheme. For more information, see:

  • https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml for allowed schemes;
  • https://www.bluetooth.com/specifications/assigned-numbers/uri-scheme-name-string-mapping for code-points used by the system to compress the scheme to save space in the payload.
8 include_tx_power_level bool

Indicates whether the current TX power level should be included in the advertising data.

AdvertisingParameters

Defined in fuchsia.bluetooth.le/peripheral.fidl

Represents the parameters for configuring advertisements.

OrdinalFieldTypeDescription
1 data AdvertisingData

The fields that will be encoded in the data section of advertising packets.

This field is required.

2 scan_response AdvertisingData

The fields that are to be sent in a scan response packet. Clients may use this to send additional data that does not fit inside an advertising packet on platforms that do not support the advertising data length extensions.

If present advertisements will be configured to be scannable.

3 mode_hint AdvertisingModeHint

The desired advertising frequency. See fuchsia.bluetooth.le/AdvertisingModeHint. Defaults to fuchsia.bluetooth.le/AdvertisingModeHint.SLOW if not present.

4 connectable bool

If present and true then the controller will broadcast connectable advertisements which allows remote LE centrals to initiate a connection to the Peripheral. If false or otherwise not present then the advertisements will be non-connectable.

DEPRECATED - Prefer to use the connection_options field for new code.

5 connection_options ConnectionOptions

If present, the controller will broadcast connectable advertisements which allow peers to initiate connections to the Peripheral. The fields of ConnectionOptions will configure any connections set up from advertising.

ConnectionOptions

Defined in fuchsia.bluetooth.le/connection_options.fidl

Represents parameters that are set on a per-connection basis by FIDL protocols that create Low Energy connections.

OrdinalFieldTypeDescription
1 bondable_mode bool

When true, the connection operates in bondable mode. This means pairing will form a bond, or persist across disconnections, if the peer is also in bondable mode. When not present, the connection defaults to bondable mode. When false, the connection operates in non- bondable mode, which means the local device only allows pairing that does not form a bond.

2 service_filter fuchsia.bluetooth/Uuid

When present, service discovery performed following the connection is restricted to primary services that match this field. Otherwise, by default all available services are discovered.

Filter

Defined in fuchsia.bluetooth.le/central.fidl

Filter parameters for use during a scan. A discovered peer only matches the filter if it satisfies all of the present filter parameters.

OrdinalFieldTypeDescription
1 service_uuid fuchsia.bluetooth/Uuid

Filter based on advertised service UUID.

2 service_data_uuid fuchsia.bluetooth/Uuid

Filter based on service data containing the given UUID.

3 manufacturer_id uint16

Filter based on a manufacturer identifier present in the manufacturer data. If this filter parameter is set, then the advertising payload must contain manufacturer specific data with the provided company identifier to satisfy this filter. Manufacturer identifiers can be found at https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/

4 connectable bool

Filter based on whether or not a device is connectable. For example, a client that is only interested in peripherals that it can connect to can set this to true. Similarly a client can scan only for broadcasters by setting this to false.

5 name fuchsia.bluetooth/DeviceName

Filter results based on a portion of the advertised device name. Substring matches are allowed.

6 max_path_loss int8

Filter results based on the path loss of the radio wave. A device that matches this filter must satisfy the following:

  1. Radio transmission power level and received signal strength must be available for the path loss calculation;
  2. The calculated path loss value must be less than, or equal to, max_path_loss.

NOTE: This field is calculated using the RSSI and TX Power information obtained from advertising and scan response data during a scan procedure. It should NOT be confused with information for an active connection obtained using the "Path Loss Reporting" feature.

Peer

Defined in fuchsia.bluetooth.le/peer.fidl

Represents a Bluetooth Low Energy peer that may act in the broadcaster, peripheral, or central role. The peer's role depends on whether it is obtained from the Central or Peripheral protocol.

OrdinalFieldTypeDescription
1 id fuchsia.bluetooth/PeerId

Uniquely identifies this peer on the current system.

This field is always present.

2 connectable bool

Whether or not this peer is connectable. Non-connectable peers are typically in the LE broadcaster role.

This field is always present.

3 rssi int8

The last observed signal strength of this peer. This field is only present for a peer that is broadcasting. The RSSI can be stale if the peer has not been advertising.

NOTE: This field should NOT be confused with the "connection RSSI" of a peer that is currently connected to the system.

4 advertising_data AdvertisingData

DEPRECATED - Use `data` instead

5 name fuchsia.bluetooth/DeviceName

The name of this peer. The name is often obtained during a scan procedure and can get updated during the name discovery procedure following a connection.

This field is present if the name is known.

6 data ScanData

Information from advertising and scan response data broadcast by this peer. When present, this contains the advertising data last received from the peer.

7 bonded bool

Whether or not this peer is bonded.

This field is always present.

8 last_updated zx/time

The value of the system monotonic clock, measured at the time this peer was last updated (e.g. due to reception of an advertisement).

This field is always present.

ScanData

Defined in fuchsia.bluetooth.le/peer.fidl

Information obtained from advertising and scan response data broadcast by a peer.

OrdinalFieldTypeDescription
1 tx_power int8

The radio transmit power level reported by an advertising and/or scannable peer.

NOTE: This field should NOT be confused with the "connection TX Power Level" of a peer that is currently connected to the system obtained via the "Transmit Power reporting" feature.

2 appearance fuchsia.bluetooth/Appearance

The appearance of the device.

3 service_uuids vector<fuchsia.bluetooth/Uuid>

Service UUIDs.

4 service_data vector<ServiceData>

Service data entries.

5 manufacturer_data vector<ManufacturerData>

Manufacturer-specific data entries.

6 uris vector<string>

String representing a URI to be advertised, as defined in IETF STD 66. Each entry should be a UTF-8 string including the scheme. For more information, see https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml for allowed schemes; NOTE: Bluetooth advertising compresses schemas over the air to save space. See https://www.bluetooth.com/specifications/assigned-numbers/uri-scheme-name-string-mapping.

7 timestamp zx/time

The monotonic time when this scan data was received.

ScanOptions

Defined in fuchsia.bluetooth.le/central.fidl

Parameters used during a scan.

OrdinalFieldTypeDescription
1 filters vector<Filter>

List of filters for use during a scan. A peripheral that satisfies any of these filters will be reported. At least 1 filter must be specified. While not recommended, clients that require that all peripherals be reported can specify an empty filter.

UNIONS

Peripheral_Advertise_Result strict

Defined in fuchsia.bluetooth.le/peripheral.fidl

Ordinal
VariantTypeDescription
1 response Peripheral_Advertise_Response
2 err PeripheralError

Peripheral_StartAdvertising_Result strict

Defined in fuchsia.bluetooth.le/peripheral.fidl

Ordinal
VariantTypeDescription
1 response Peripheral_StartAdvertising_Response
2 err PeripheralError

CONSTANTS

NameValueTypeDescription
MAX_MANUFACTURER_DATA_LENGTH 252 uint8
MAX_SERVICE_DATA_LENGTH 252 uint8
MAX_URI_LENGTH 278 uint16