-
Notifications
You must be signed in to change notification settings - Fork 23
/
types.d.ts
199 lines (182 loc) · 8.22 KB
/
types.d.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import * as stream from 'stream';
import * as DBus from 'dbus';
declare class Bluez extends NodeJS.EventEmitter {
constructor(options?: {
bus?: DBus.DBusConnection,
service?: DBus.DBusService | string | null,
objectPath?: string
});
getAdapter(dev?: string): Promise<Bluez.Adapter>;
findAdapter(filterFn: (props: any) => boolean): Promise<Bluez.Adapter | null>;
getDevice(address: string): Promise<Bluez.Device>;
findDevice(filterFn: (props: Bluez.DeviceProps) => boolean): Promise<Bluez.Device | null>;
getAllDevicesProps(): Bluez.DeviceProps[];
getUserService(): any;
getUserServiceObject(): any;
init(): Promise<void>;
registerAgent(agent: Bluez.Agent, capabilities: "DisplayOnly" | "DisplayYesNo" | "KeyboardOnly" | "NoInputNoOutput" | "KeyboardDisplay", requestAsDefault?: boolean): Promise<void>;
registerStaticKeyAgent(pin: number | string, requestAsDefault?: boolean): Promise<void>;
registerSimplePairingAgent(requestAsDefault?: boolean): Promise<void>;
registerProfile(profile: Bluez.Profile, options: any): Promise<void>;
registerSerialProfile(listener: (device: Bluez.Device, socket: Bluez.BluetoothSocket) => void, mode?: string, options?: stream.DuplexOptions): Promise<void>;
on(event: "device", listener: (address: string, props: Bluez.DeviceProps) => void): this;
on(event: "error", listener: (error: Error) => void): this;
}
declare namespace Bluez {
class DbusInterfaceBase extends NodeJS.EventEmitter {
constructor(dbusInterface: DBus.DBusInterface, bluez: Bluez);
getProperties(): Promise<any>;
getProperty(name: string): Promise<any>;
setProperty(name: string, value: any): Promise<void>;
on(event: "PropertiesChanged", listener: (properties: { [key: string]: any }, invalidated: string[]) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
}
class Adapter extends DbusInterfaceBase {
RemoveDevice(devicePath: string | Device): Promise<void>;
SetDiscoveryFilter(filter: any): Promise<void>;
GetDiscoveryFilters(): Promise<string[]>;
StartDiscovery(): Promise<void>;
StopDiscovery(): Promise<void>;
Address(): Promise<string>;
Alias(): Promise<string>;
Alias(value: string): Promise<void>;
Class(): Promise<number>;
Discoverable(): Promise<boolean>;
Discoverable(value: boolean): Promise<void>;
DiscoverableTimeout(): Promise<number>;
DiscoverableTimeout(value: number): Promise<void>;
Discovering(): Promise<boolean>;
Modalias(): Promise<string>;
Name(): Promise<string>;
Pairable(): Promise<boolean>;
Pairable(value: boolean): Promise<void>;
PairableTimeout(): Promise<void>;
PairableTimeout(value: number): Promise<number>;
Powered(): Promise<boolean>;
Powered(value: boolean): Promise<void>;
UUIDs(): Promise<string[]>;
}
class Agent {
constructor(bluez: Bluez, dbusObject: DBus.DBusServiceObject);
Unregister(): Promise<void>;
AuthorizeService(device: string, uuid: string, callback: (err?: Error | null) => void): void;
Cancel(callback: (err?: Error | null) => void): void;
DisplayPasskey(device: string, pincode: number, callback: (err?: Error | null) => void): void;
DisplayPinCode(device: string, pincode: string, callback: (err?: Error | null) => void): void;
Release(callback: (err?: Error | null) => void): void;
RequestAuthorization(device: string, callback: (err?: Error | null) => void): void;
RequestConfirmation(device: string, pincode: string, callback: (err?: Error | null) => void): void;
RequestPasskey(device: string, callback: (err?: Error | null, pin?: number) => void): void;
RequestPinCode(device: string, callback: (err?: Error | null, pin?: string) => void): void;
}
class StaticKeyAgent extends Agent { }
class SimplePairingAgent extends Agent { }
interface DeviceProps {
Adapter: any;
Address: string;
AdvertisingFlags?: any;
Alias: string;
Appearance?: number;
Blocked: boolean;
Class?: number;
Connected: boolean;
Icon?: string;
LegacyPairing: boolean;
ManufacturerData?: any;
Modalias?: string;
Name?: string;
Paired: boolean;
RSSI?: number;
ServiceData?: any;
ServicesResolved: boolean;
Trusted: boolean;
TxPower?: number;
UUIDs?: string[];
}
class Device extends DbusInterfaceBase {
getService(uuid: string): Promise<Service | null>;
Connect(timeout?: number): Promise<void>;
ConnectProfile(uuid: string, timeout?: number): Promise<void>;
Disconnect(): Promise<void>;
DisconnectProfile(uuid: string): Promise<void>;
Pair(): Promise<void>;
CancelPairing(): Promise<void>;
getProperties(): Promise<DeviceProps>;
getProperty<T extends keyof DeviceProps>(name: T): Promise<DeviceProps[T]>;
getProperty(name: string): Promise<any>;
setProperty<T extends keyof DeviceProps>(name: T, value: DeviceProps[T]): Promise<void>;
setProperty(name: string, value: any): Promise<void>;
Adapter(): Promise<any>;
Address(): Promise<string>;
AdvertisingFlags(): Promise<any>;
Alias(): Promise<string>;
Alias(value: string): Promise<void>;
Appearance(): Promise<number>;
Blocked(): Promise<boolean>;
Blocked(value: boolean): Promise<void>;
Class(): Promise<number>;
Connected(): Promise<boolean>;
Icon(): Promise<string>;
LegacyPairing(): Promise<boolean>;
ManufacturerData(): Promise<any>;
Modalias(): Promise<string>;
Name(): Promise<string>;
Paired(): Promise<boolean>;
RSSI(): Promise<number>;
ServiceData(): Promise<any>;
ServicesResolved(): Promise<boolean>;
Trusted(): Promise<boolean>;
Trusted(value: boolean): Promise<void>;
TxPower(): Promise<number>;
UUIDs(): Promise<string[]>;
}
class Service extends DbusInterfaceBase {
getCharacteristic(uuid: string): Promise<Characteristic | null>;
UUID(): Promise<string>;
Primary(): Promise<boolean>;
Device(): Promise<any>;
Includes(): Promise<any[]>;
}
class Characteristic extends DbusInterfaceBase {
getDescriptor(uuid: string): Promise<Descriptor | null>;
ReadValue(options?: any): Promise<Buffer>;
WriteValue(value: Buffer | number[], options?: any): Promise<void>;
AcquireWrite(options?: any): Promise<BluetoothSocket>;
AcquireNotify(options?: any): Promise<BluetoothSocket>;
StartNotify(): Promise<void>;
StopNotify(): Promise<void>;
on(event: "notify", listener: (value: Buffer) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
UUID(): Promise<string>;
Service(): Promise<string>;
Value(): Promise<Buffer>;
WriteAcquired(): Promise<boolean>;
NotifyAcquired(): Promise<boolean>;
Notifying(): Promise<boolean>;
Flags(): Promise<string[]>;
}
class Descriptor extends DbusInterfaceBase {
UUID(): Promise<string>;
Characteristic(): Promise<any>;
Value(): Promise<number[]>;
Flags(): Promise<string>;
}
class Profile {
public readonly uuid: string;
protected bluez: Bluez;
protected _DBusObject: any;
protected _DBusInterface: any;
public constructor(bluez: Bluez, dbusObject: DBus.DBusServiceObject);
public NewConnection(device: string, fd: number, options: any, callback: Function): void;
public Release(callback: Function): void;
public RequestDisconnection(device: string, callback: Function): void;
}
class SerialProfile extends Profile {
public static uuid: string;
protected listener: Function;
public constructor(...args: any[]);
public NewConnection(device: string, fd: number, options: any, callback: Function): void;
}
class BluetoothSocket extends stream.Duplex { }
}
export = Bluez;