-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.ts
62 lines (53 loc) · 1.51 KB
/
events.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import {
AdvertisementData,
Characteristic,
ConnectionStatus,
Device,
} from "./BluetoothLE";
export type ConnectionEventReason =
| "unknown"
| "success"
| "canceled"
| "notSupported" // The device does not have the required services.
| "timeout"
| "linkLoss"
| "bluetoothOff"
| "host" // The local device initiated disconnection.
| "peripheral"; // The remote device initiated graceful disconnection.
export type BluetoothState =
| "unknown"
| "off"
| "resetting"
| "unauthorized"
| "ready";
export interface BleBluetoothStateEvent {
readonly state: BluetoothState;
}
export interface ScanResult {
readonly device: Device;
readonly advertisementData: AdvertisementData;
}
export type BleScanResultEvent = ScanResult | { error: string };
export interface BleConnectionEvent {
readonly device: Device;
readonly connectionStatus: ConnectionStatus;
readonly reason: ConnectionEventReason;
}
export interface BleCharacteristicValueChangedEvent {
readonly device: Device;
readonly characteristic: Characteristic;
readonly data: number[];
}
/**
* Event map for {@link Pixel} class.
* This is the list of supported events where the property name
* is the event name and the property type the event data type.
* @category Pixels
*/
export interface BleEventMap {
bluetoothState: BleBluetoothStateEvent;
scanResult: BleScanResultEvent;
connectionEvent: BleConnectionEvent;
characteristicValueChanged: BleCharacteristicValueChangedEvent;
}
export type BleEvents = keyof BleEventMap;