UNPKG

webbluetooth

Version:

Node.js implementation of the Web Bluetooth Specification

32 lines (31 loc) 1.85 kB
import type { EventEmitter } from 'events'; import type { BluetoothDeviceImpl } from '../device'; import type { BluetoothRemoteGATTServiceImpl } from '../service'; import type { BluetoothRemoteGATTCharacteristicImpl } from '../characteristic'; import type { BluetoothRemoteGATTDescriptorImpl } from '../descriptor'; /** * @hidden */ export interface Adapter extends EventEmitter { getEnabled: () => Promise<boolean>; getAdapters: () => Array<{ index: number; address: string; active: boolean; }>; useAdapter: (index: number) => void; startScan: (serviceUUIDs: Array<string>, foundFn: (device: Partial<BluetoothDeviceImpl>) => void) => Promise<void>; stopScan: () => void; connect: (handle: string, disconnectFn?: () => void) => Promise<void>; disconnect: (handle: string) => Promise<void>; discoverServices: (handle: string, serviceUUIDs?: Array<string>) => Promise<Array<Partial<BluetoothRemoteGATTServiceImpl>>>; discoverIncludedServices: (handle: string, serviceUUIDs?: Array<string>) => Promise<Array<Partial<BluetoothRemoteGATTServiceImpl>>>; discoverCharacteristics: (handle: string, characteristicUUIDs?: Array<string>) => Promise<Array<Partial<BluetoothRemoteGATTCharacteristicImpl>>>; discoverDescriptors: (handle: string, descriptorUUIDs?: Array<string>) => Promise<Array<Partial<BluetoothRemoteGATTDescriptorImpl>>>; readCharacteristic: (handle: string) => Promise<DataView>; writeCharacteristic: (handle: string, value: DataView, withoutResponse?: boolean) => Promise<void>; enableNotify: (handle: string, notifyFn: (value: DataView) => void) => Promise<void>; disableNotify: (handle: string) => Promise<void>; readDescriptor: (handle: string) => Promise<DataView>; writeDescriptor: (handle: string, value: DataView) => Promise<void>; }