Version: Smart Feature Phone 2.5Version: Smart Feature Phone 2.6

BluetoothGatt

Description#

The BluetoothGatt interface of the Bluetooth API handles initial communications and connections with Gatt services.

Interface overview#

[Exposed=Window]
interface BluetoothGatt : EventTarget
{
[Cached, Pure]
readonly attribute sequence<BluetoothGattService> services;
readonly attribute BluetoothConnectionState connectionState;
attribute EventHandler oncharacteristicchanged;
attribute EventHandler onconnectionstatechanged;
[NewObject] Promise<void> connect();
[NewObject] Promise<void> disconnect();
[NewObject] Promise<void> discoverServices();
[NewObject] Promise<short> readRemoteRssi();
};
enum BluetoothConnectionState
{
"disconnected",
"disconnecting",
"connected",
"connecting"
};

Properties#

  • BluetoothGatt.services read-only Returns the list of BluetoothGattService offered by the remote LE device. This property is set to an empty array by default before a connection is established.

  • BluetoothGatt.connectionState read-only The current connection state of GATT client to the remote LE device. This property is set to disconnected by default, before a connection is established.

Event handlers#

  • BluetoothGatt.oncharacteristicchanged Defines a handler to trigger as a result of the characteristicchanged event firing; this occurs when a remote characteristic changes.

  • BluetoothGatt.onconnectionstatechanged Defines a handler to trigger as a result of the connectionstatechanged event firing; this occurs when the connection state of the GATT client to the remote LE device (i.e. the BluetoothGatt.connectionState property) changes.

Methods#