-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
55 lines (46 loc) · 2.03 KB
/
Copy pathtypes.ts
File metadata and controls
55 lines (46 loc) · 2.03 KB
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
// Web Bluetooth API type definitions to satisfy the compiler
// This avoids needing to install @types/web-bluetooth
export type BluetoothServiceUUID = number | string;
export type BluetoothCharacteristicUUID = number | string;
export interface BluetoothDevice extends EventTarget {
readonly id: string;
readonly name?: string;
readonly gatt?: BluetoothRemoteGATTServer;
addEventListener(type: 'gattserverdisconnected', listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: 'gattserverdisconnected', callback: (this: this, ev: Event) => any, useCapture?: boolean): void;
}
export interface BluetoothRemoteGATTServer {
readonly device: BluetoothDevice;
readonly connected: boolean;
connect(): Promise<BluetoothRemoteGATTServer>;
disconnect(): void;
getPrimaryService(service: BluetoothServiceUUID): Promise<BluetoothRemoteGATTService>;
}
export interface BluetoothRemoteGATTService {
getCharacteristic(characteristic: BluetoothCharacteristicUUID): Promise<BluetoothRemoteGATTCharacteristic>;
}
export interface BluetoothRemoteGATTCharacteristic extends EventTarget {
readonly value?: DataView;
startNotifications(): Promise<BluetoothRemoteGATTCharacteristic>;
addEventListener(type: 'characteristicvaluechanged', listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: 'characteristicvaluechanged', callback: (this: this, ev: Event) => any, useCapture?: boolean): void;
}
export interface BluetoothRequestDeviceOptions {
filters?: { services?: BluetoothServiceUUID[] }[];
optionalServices?: BluetoothServiceUUID[];
}
declare global {
interface Navigator {
bluetooth: {
requestDevice(options?: BluetoothRequestDeviceOptions): Promise<BluetoothDevice>;
};
}
}
export type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
export interface Prediction {
timestamp: number;
scores: Record<string, number>;
}
export interface HydrationEntry {
time: Date;
}