BluetoothGattServer
Description#
The BluetoothGattServer interface of the Bluetooth API provides Bluetooth Generic Attribute Profile (GATT) server functionality to create Bluetooth GATT services and characteristics.
Interface overview#
Properties#
BluetoothGattServer.servicesread-onlyAn array of the services offered by this device.
Event handlers#
BluetoothGattServer.onconnectionstatechangedA handler to trigger as a result of the deviceconnectionstatechanged event firing; this occurs when a remote LE device has been connected or disconnected.BluetoothGattServer.onattributereadreqA handler to trigger as a result of the attributereadreq event firing; this occurs when a remote client has requested to read a server's characteristic or descriptor.BluetoothGattServer.onattributewritereqDefines a handler to trigger as a result of the attributewritereq event firing; this occurs when a remote client has requested to write a server's characteristic or descriptor.
Methods#
BluetoothGattServer.connect()Initiates a connection to a remote LE device.BluetoothGattServer.disconnect()Disconnects an already-established connection to a remote LE device.BluetoothGattServer.startAdvertising()Start advertising data to nearby devices.BluetoothGattServer.stopAdvertising()Stop advertising data to nearby devices.BluetoothGattServer.addservice()Adds a BluetoothGattService to the server's list of provided services.BluetoothGattServer.removeservice()Removes a BluetoothGattService from the server's list of provided services.BluetoothGattServer.notifyCharacteristicChanged()Sends a notification/indication that a local characteristic has been updated.BluetoothGattServer.sendResponse()Sends a response to a remote LE device's read or write request.