WebBluetoothService
Provides access to the Web Bluetooth API for connecting to Bluetooth Low Energy (BLE) devices. Supports device discovery, GATT service/characteristic read/write, and notifications.
TypeScriptexample.ts
import { WebBluetoothService } from '@angular-helpers/browser-web-apis/experimental'# Methods
| Method | Signature | Returns | Description |
|---|---|---|---|
isSupported | isSupported(): boolean | boolean | Public method isSupported. |
requestDevice | requestDevice(options?: BluetoothRequestDeviceOptions): Promise<BluetoothDevice> | Promise<BluetoothDevice> | Requests a Bluetooth device from the user matching the specified options. |
getDevices | getDevices(): Promise<BluetoothDevice[]> | Promise<BluetoothDevice[]> | Gets a list of permitted Bluetooth devices for this origin. |
getAvailability | getAvailability(): Promise<boolean> | Promise<boolean> | Queries whether Bluetooth is available on the user's device/adapter. |
connectGatt | connectGatt(device: BluetoothDevice): Promise<BluetoothRemoteGATTServer> | Promise<BluetoothRemoteGATTServer> | Connects to the GATT server on the specified device. |
disconnectGatt | disconnectGatt(device: BluetoothDevice): void | void | Disconnects from the GATT server on the specified device. |
readCharacteristic | readCharacteristic(characteristic: BluetoothRemoteGATTCharacteristic): Promise<DataView> | Promise<DataView> | Reads the value of a GATT characteristic. |
writeCharacteristic | writeCharacteristic(characteristic: BluetoothRemoteGATTCharacteristic, data: BufferSource, withoutResponse: any): Promise<void> | Promise<void> | Writes data to a GATT characteristic. |
watchCharacteristicNotifications | watchCharacteristicNotifications(characteristic: BluetoothRemoteGATTCharacteristic): Observable<DataView> | Observable<DataView> | Observes value changes (notifications/indications) on a GATT characteristic. |