@stoprocent/noble 1.10.3 → 1.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +77 -0
- package/.github/workflows/nodepackage.yml +6 -15
- package/README.md +13 -23
- package/binding.gyp +22 -0
- package/examples/advertisement-discovery.js +1 -1
- package/examples/cache-gatt-discovery.js +1 -1
- package/examples/cache-gatt-reconnect.js +1 -1
- package/examples/echo.js +1 -1
- package/examples/enter-exit.js +2 -2
- package/examples/ext-advertisement-discovery.js +65 -0
- package/examples/peripheral-explorer-async.js +1 -1
- package/examples/peripheral-explorer.js +1 -1
- package/examples/pizza/central.js +1 -1
- package/index.d.ts +187 -196
- package/index.js +1 -6
- package/lib/distributed/bindings.js +33 -33
- package/lib/hci-socket/bindings.js +1 -3
- package/lib/hci-socket/crypto.js +4 -4
- package/lib/hci-socket/gap.js +22 -18
- package/lib/hci-socket/gatt.js +4 -4
- package/lib/hci-socket/hci.js +3 -3
- package/lib/mac/binding.gyp +23 -11
- package/lib/noble.js +10 -6
- package/lib/peripheral.js +0 -7
- package/lib/resolve-bindings.js +39 -3
- package/lib/webbluetooth/bindings.js +2 -2
- package/lib/websocket/bindings.js +32 -32
- package/lib/win/binding.gyp +25 -5
- package/lib/win/src/ble_manager.cc +4 -1
- package/lib/win/src/ble_manager.h +1 -1
- package/lib/win/src/peripheral_winrt.cc +2 -0
- package/lib/win/src/radio_watcher.cc +1 -0
- package/lib/win/src/winrt_cpp.cc +1 -0
- package/package.json +31 -37
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/test/lib/distributed/bindings.test.js +15 -15
- package/test/lib/hci-socket/gap.test.js +39 -0
- package/test/lib/hci-socket/hci.test.js +1 -1
- package/test/lib/resolve-bindings.test.js +102 -0
- package/test/lib/webbluetooth/bindings.test.js +2 -2
- package/test/lib/websocket/bindings.test.js +2 -2
- package/test/mocha.setup.js +0 -0
- package/test/noble.test.js +12 -11
- package/test.custom.js +131 -0
- package/test.js +1 -1
- package/with-custom-binding.js +6 -0
- package/ws-slave.js +10 -10
- package/.github/workflows/npm-publish.yml +0 -26
- package/lib/hci-uart/bindings.js +0 -569
- package/lib/hci-uart/hci-serial-parser.js +0 -70
- package/lib/hci-uart/hci.js +0 -1360
- package/lib/manufacture.js +0 -46
- package/misc/0001-hci-uart-on-usb-cdc.patch +0 -161
- package/misc/nrf52840-usb-cdc.hex +0 -8907
- package/misc/nrf52840dk.hex +0 -6921
- package/misc/prj.conf +0 -43
- package/test/lib/manufacture.test.js +0 -77
package/index.d.ts
CHANGED
|
@@ -11,203 +11,194 @@
|
|
|
11
11
|
|
|
12
12
|
/// <reference types="node" />
|
|
13
13
|
|
|
14
|
+
import events = require("events");
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
export declare function startScanning(callback?: (error?: Error) => void): void;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
23
|
+
export declare function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void;
|
|
24
|
+
export declare function startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error?: Error) => void): void;
|
|
25
|
+
export declare function startScanningAsync(serviceUUIDs?: string[], allowDuplicates?: boolean): Promise<void>;
|
|
26
|
+
export declare function stopScanning(callback?: () => void): void;
|
|
27
|
+
export declare function stopScanningAsync(): Promise<void>;
|
|
28
|
+
export declare function cancelConnect(peripheralUuid: string, options?: object): void;
|
|
29
|
+
export declare function reset(): void;
|
|
30
|
+
|
|
31
|
+
export declare function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
|
32
|
+
export declare function on(event: "scanStart", listener: () => void): events.EventEmitter;
|
|
33
|
+
export declare function on(event: "scanStop", listener: () => void): events.EventEmitter;
|
|
34
|
+
export declare function on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
|
35
|
+
export declare function on(event: string, listener: Function): events.EventEmitter;
|
|
36
|
+
|
|
37
|
+
export declare function once(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
|
38
|
+
export declare function once(event: "scanStart", listener: () => void): events.EventEmitter;
|
|
39
|
+
export declare function once(event: "scanStop", listener: () => void): events.EventEmitter;
|
|
40
|
+
export declare function once(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
|
41
|
+
export declare function once(event: string, listener: Function): events.EventEmitter;
|
|
42
|
+
|
|
43
|
+
export declare function removeListener(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
|
44
|
+
export declare function removeListener(event: "scanStart", listener: () => void): events.EventEmitter;
|
|
45
|
+
export declare function removeListener(event: "scanStop", listener: () => void): events.EventEmitter;
|
|
46
|
+
export declare function removeListener(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
|
47
|
+
export declare function removeListener(event: string, listener: Function): events.EventEmitter;
|
|
48
|
+
|
|
49
|
+
export declare function removeAllListeners(event?: string): events.EventEmitter;
|
|
50
|
+
|
|
51
|
+
export declare var state: string;
|
|
52
|
+
|
|
53
|
+
export var _bindings: any;
|
|
54
|
+
|
|
55
|
+
export interface ServicesAndCharacteristics {
|
|
56
|
+
services: Service[];
|
|
57
|
+
characteristics: Characteristic[];
|
|
58
|
+
}
|
|
15
59
|
|
|
16
|
-
|
|
60
|
+
export declare class Peripheral extends events.EventEmitter {
|
|
61
|
+
id: string;
|
|
62
|
+
uuid: string;
|
|
63
|
+
address: string;
|
|
64
|
+
addressType: string;
|
|
65
|
+
connectable: boolean;
|
|
66
|
+
advertisement: Advertisement;
|
|
67
|
+
rssi: number;
|
|
68
|
+
mtu: number | null;
|
|
69
|
+
services: Service[];
|
|
70
|
+
state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected';
|
|
71
|
+
|
|
72
|
+
connect(callback?: (error: string) => void): void;
|
|
73
|
+
connectAsync(): Promise<void>;
|
|
74
|
+
disconnect(callback?: () => void): void;
|
|
75
|
+
disconnectAsync(): Promise<void>;
|
|
76
|
+
updateRssi(callback?: (error: string, rssi: number) => void): void;
|
|
77
|
+
updateRssiAsync(): Promise<number>;
|
|
78
|
+
discoverServices(): void;
|
|
79
|
+
discoverServicesAsync(): Promise<Service[]>;
|
|
80
|
+
discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void;
|
|
81
|
+
discoverServicesAsync(serviceUUIDs: string[]): Promise<Service[]>;
|
|
82
|
+
discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
|
|
83
|
+
discoverAllServicesAndCharacteristicsAsync(): Promise<ServicesAndCharacteristics>;
|
|
84
|
+
discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
|
|
85
|
+
discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise<ServicesAndCharacteristics>;
|
|
86
|
+
cancelConnect(options?: object): void;
|
|
87
|
+
|
|
88
|
+
readHandle(handle: number, callback: (error: string, data: Buffer) => void): void;
|
|
89
|
+
readHandleAsync(handle: number): Promise<Buffer>;
|
|
90
|
+
writeHandle(handle: number, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void;
|
|
91
|
+
writeHandleAsync(handle: number, data: Buffer, withoutResponse: boolean): Promise<void>;
|
|
92
|
+
toString(): string;
|
|
93
|
+
|
|
94
|
+
on(event: "connect", listener: (error: string) => void): this;
|
|
95
|
+
on(event: "disconnect", listener: (error: string) => void): this;
|
|
96
|
+
on(event: "rssiUpdate", listener: (rssi: number) => void): this;
|
|
97
|
+
on(event: "servicesDiscover", listener: (services: Service[]) => void): this;
|
|
98
|
+
on(event: string, listener: Function): this;
|
|
99
|
+
|
|
100
|
+
once(event: "connect", listener: (error: string) => void): this;
|
|
101
|
+
once(event: "disconnect", listener: (error: string) => void): this;
|
|
102
|
+
once(event: "rssiUpdate", listener: (rssi: number) => void): this;
|
|
103
|
+
once(event: "servicesDiscover", listener: (services: Service[]) => void): this;
|
|
104
|
+
once(event: string, listener: Function): this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface Advertisement {
|
|
108
|
+
localName: string;
|
|
109
|
+
serviceData: Array<{
|
|
110
|
+
uuid: string,
|
|
111
|
+
data: Buffer
|
|
112
|
+
}>;
|
|
113
|
+
txPowerLevel: number;
|
|
114
|
+
manufacturerData: Buffer;
|
|
115
|
+
serviceUuids: string[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare class Service extends events.EventEmitter {
|
|
119
|
+
uuid: string;
|
|
120
|
+
name: string;
|
|
121
|
+
type: string;
|
|
122
|
+
includedServiceUuids: string[];
|
|
123
|
+
characteristics: Characteristic[];
|
|
124
|
+
|
|
125
|
+
discoverIncludedServices(): void;
|
|
126
|
+
discoverIncludedServicesAsync(): Promise<string[]>;
|
|
127
|
+
discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void;
|
|
128
|
+
discoverIncludedServicesAsync(serviceUUIDs: string[]): Promise<string[]>;
|
|
129
|
+
discoverCharacteristics(): void;
|
|
130
|
+
discoverCharacteristicsAsync(): Promise<Characteristic[]>;
|
|
131
|
+
discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void;
|
|
132
|
+
discoverCharacteristicsAsync(characteristicUUIDs: string[]): Promise<Characteristic[]>;
|
|
133
|
+
toString(): string;
|
|
134
|
+
|
|
135
|
+
on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
|
|
136
|
+
on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
|
|
137
|
+
on(event: string, listener: Function): this;
|
|
138
|
+
|
|
139
|
+
once(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
|
|
140
|
+
once(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
|
|
141
|
+
once(event: string, listener: Function): this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export declare class Characteristic extends events.EventEmitter {
|
|
145
|
+
uuid: string;
|
|
146
|
+
name: string;
|
|
147
|
+
type: string;
|
|
148
|
+
properties: string[];
|
|
149
|
+
descriptors: Descriptor[];
|
|
150
|
+
|
|
151
|
+
read(callback?: (error: string, data: Buffer) => void): void;
|
|
152
|
+
readAsync(): Promise<Buffer>;
|
|
153
|
+
write(data: Buffer, withoutResponse: boolean, callback?: (error: string) => void): void;
|
|
154
|
+
writeAsync(data: Buffer, withoutResponse: boolean): Promise<void>;
|
|
155
|
+
broadcast(broadcast: boolean, callback?: (error: string) => void): void;
|
|
156
|
+
broadcastAsync(broadcast: boolean): Promise<void>;
|
|
157
|
+
notify(notify: boolean, callback?: (error: string) => void): void;
|
|
158
|
+
notifyAsync(notify: boolean): Promise<void>;
|
|
159
|
+
discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void;
|
|
160
|
+
discoverDescriptorsAsync(): Promise<Descriptor[]>;
|
|
161
|
+
toString(): string;
|
|
162
|
+
subscribe(callback?: (error: string) => void): void;
|
|
163
|
+
subscribeAsync(): Promise<void>;
|
|
164
|
+
unsubscribe(callback?: (error: string) => void): void;
|
|
165
|
+
unsubscribeAsync(): Promise<void>;
|
|
166
|
+
|
|
167
|
+
on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
168
|
+
on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
|
|
169
|
+
on(event: "broadcast", listener: (state: string) => void): this;
|
|
170
|
+
on(event: "notify", listener: (state: string) => void): this;
|
|
171
|
+
on(event: "data", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
172
|
+
on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
|
|
173
|
+
on(event: string, listener: Function): this;
|
|
174
|
+
on(event: string, option: boolean, listener: Function): this;
|
|
175
|
+
|
|
176
|
+
once(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
177
|
+
once(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
|
|
178
|
+
once(event: "broadcast", listener: (state: string) => void): this;
|
|
179
|
+
once(event: "notify", listener: (state: string) => void): this;
|
|
180
|
+
once(event: "data", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
181
|
+
once(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
|
|
182
|
+
once(event: string, listener: Function): this;
|
|
183
|
+
once(event: string, option: boolean, listener: Function): this;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export declare class Descriptor extends events.EventEmitter {
|
|
187
|
+
uuid: string;
|
|
188
|
+
name: string;
|
|
189
|
+
type: string;
|
|
190
|
+
|
|
191
|
+
readValue(callback?: (error: string, data: Buffer) => void): void;
|
|
192
|
+
readValueAsync(): Promise<Buffer>;
|
|
193
|
+
writeValue(data: Buffer, callback?: (error: string) => void): void;
|
|
194
|
+
writeValueAsync(data: Buffer): Promise<void>;
|
|
195
|
+
toString(): string;
|
|
196
|
+
|
|
197
|
+
on(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
|
|
198
|
+
on(event: "valueWrite", listener: (error: string) => void): this;
|
|
199
|
+
on(event: string, listener: Function): this;
|
|
17
200
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
export interface Noble {
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated
|
|
25
|
-
*/
|
|
26
|
-
startScanning(callback?: (error?: Error) => void): void;
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated
|
|
29
|
-
*/
|
|
30
|
-
startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void;
|
|
31
|
-
startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error?: Error) => void): void;
|
|
32
|
-
startScanningAsync(serviceUUIDs?: string[], allowDuplicates?: boolean): Promise<void>;
|
|
33
|
-
stopScanning(callback?: () => void): void;
|
|
34
|
-
stopScanningAsync(): Promise<void>;
|
|
35
|
-
cancelConnect(peripheralUuid: string, options?: object): void;
|
|
36
|
-
reset(): void;
|
|
37
|
-
|
|
38
|
-
on(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
|
39
|
-
on(event: "scanStart", listener: () => void): events.EventEmitter;
|
|
40
|
-
on(event: "scanStop", listener: () => void): events.EventEmitter;
|
|
41
|
-
on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
|
42
|
-
on(event: string, listener: Function): events.EventEmitter;
|
|
43
|
-
|
|
44
|
-
once(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
|
45
|
-
once(event: "scanStart", listener: () => void): events.EventEmitter;
|
|
46
|
-
once(event: "scanStop", listener: () => void): events.EventEmitter;
|
|
47
|
-
once(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
|
48
|
-
once(event: string, listener: Function): events.EventEmitter;
|
|
49
|
-
|
|
50
|
-
removeListener(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
|
51
|
-
removeListener(event: "scanStart", listener: () => void): events.EventEmitter;
|
|
52
|
-
removeListener(event: "scanStop", listener: () => void): events.EventEmitter;
|
|
53
|
-
removeListener(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
|
54
|
-
removeListener(event: string, listener: Function): events.EventEmitter;
|
|
55
|
-
|
|
56
|
-
removeAllListeners(event?: string): events.EventEmitter;
|
|
57
|
-
|
|
58
|
-
state: string;
|
|
59
|
-
|
|
60
|
-
_bindings: any;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface ServicesAndCharacteristics {
|
|
64
|
-
services: Service[];
|
|
65
|
-
characteristics: Characteristic[];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class Peripheral extends events.EventEmitter {
|
|
69
|
-
id: string;
|
|
70
|
-
uuid: string;
|
|
71
|
-
address: string;
|
|
72
|
-
addressType: string;
|
|
73
|
-
connectable: boolean;
|
|
74
|
-
advertisement: Advertisement;
|
|
75
|
-
rssi: number;
|
|
76
|
-
services: Service[];
|
|
77
|
-
state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected';
|
|
78
|
-
|
|
79
|
-
connect(callback?: (error: string) => void): void;
|
|
80
|
-
connectAsync(): Promise<void>;
|
|
81
|
-
disconnect(callback?: () => void): void;
|
|
82
|
-
disconnectAsync(): Promise<void>;
|
|
83
|
-
updateRssi(callback?: (error: string, rssi: number) => void): void;
|
|
84
|
-
updateRssiAsync(): Promise<number>;
|
|
85
|
-
discoverServices(): void;
|
|
86
|
-
discoverServicesAsync(): Promise<Service[]>;
|
|
87
|
-
discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void;
|
|
88
|
-
discoverServicesAsync(serviceUUIDs: string[]): Promise<Service[]>;
|
|
89
|
-
discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
|
|
90
|
-
discoverAllServicesAndCharacteristicsAsync(): Promise<ServicesAndCharacteristics>;
|
|
91
|
-
discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
|
|
92
|
-
discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise<ServicesAndCharacteristics>;
|
|
93
|
-
cancelConnect(options?: object): void;
|
|
94
|
-
|
|
95
|
-
readHandle(handle: number, callback: (error: string, data: Buffer) => void): void;
|
|
96
|
-
readHandleAsync(handle: number): Promise<Buffer>;
|
|
97
|
-
writeHandle(handle: number, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void;
|
|
98
|
-
writeHandleAsync(handle: number, data: Buffer, withoutResponse: boolean): Promise<void>;
|
|
99
|
-
toString(): string;
|
|
100
|
-
|
|
101
|
-
on(event: "connect", listener: (error: string) => void): this;
|
|
102
|
-
on(event: "disconnect", listener: (error: string) => void): this;
|
|
103
|
-
on(event: "rssiUpdate", listener: (rssi: number) => void): this;
|
|
104
|
-
on(event: "servicesDiscover", listener: (services: Service[]) => void): this;
|
|
105
|
-
on(event: string, listener: Function): this;
|
|
106
|
-
|
|
107
|
-
once(event: "connect", listener: (error: string) => void): this;
|
|
108
|
-
once(event: "disconnect", listener: (error: string) => void): this;
|
|
109
|
-
once(event: "rssiUpdate", listener: (rssi: number) => void): this;
|
|
110
|
-
once(event: "servicesDiscover", listener: (services: Service[]) => void): this;
|
|
111
|
-
once(event: string, listener: Function): this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface Advertisement {
|
|
115
|
-
localName: string;
|
|
116
|
-
serviceData: Array<{
|
|
117
|
-
uuid: string,
|
|
118
|
-
data: Buffer
|
|
119
|
-
}>;
|
|
120
|
-
txPowerLevel: number;
|
|
121
|
-
manufacturerData: Buffer;
|
|
122
|
-
serviceUuids: string[];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export class Service extends events.EventEmitter {
|
|
126
|
-
uuid: string;
|
|
127
|
-
name: string;
|
|
128
|
-
type: string;
|
|
129
|
-
includedServiceUuids: string[];
|
|
130
|
-
characteristics: Characteristic[];
|
|
131
|
-
|
|
132
|
-
discoverIncludedServices(): void;
|
|
133
|
-
discoverIncludedServicesAsync(): Promise<string[]>;
|
|
134
|
-
discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void;
|
|
135
|
-
discoverIncludedServicesAsync(serviceUUIDs: string[]): Promise<string[]>;
|
|
136
|
-
discoverCharacteristics(): void;
|
|
137
|
-
discoverCharacteristicsAsync(): Promise<Characteristic[]>;
|
|
138
|
-
discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void;
|
|
139
|
-
discoverCharacteristicsAsync(characteristicUUIDs: string[]): Promise<Characteristic[]>;
|
|
140
|
-
toString(): string;
|
|
141
|
-
|
|
142
|
-
on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
|
|
143
|
-
on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
|
|
144
|
-
on(event: string, listener: Function): this;
|
|
145
|
-
|
|
146
|
-
once(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
|
|
147
|
-
once(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
|
|
148
|
-
once(event: string, listener: Function): this;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export class Characteristic extends events.EventEmitter {
|
|
152
|
-
uuid: string;
|
|
153
|
-
name: string;
|
|
154
|
-
type: string;
|
|
155
|
-
properties: string[];
|
|
156
|
-
descriptors: Descriptor[];
|
|
157
|
-
|
|
158
|
-
read(callback?: (error: string, data: Buffer) => void): void;
|
|
159
|
-
readAsync(): Promise<Buffer>;
|
|
160
|
-
write(data: Buffer, withoutResponse: boolean, callback?: (error: string) => void): void;
|
|
161
|
-
writeAsync(data: Buffer, withoutResponse: boolean): Promise<void>;
|
|
162
|
-
broadcast(broadcast: boolean, callback?: (error: string) => void): void;
|
|
163
|
-
broadcastAsync(broadcast: boolean): Promise<void>;
|
|
164
|
-
notify(notify: boolean, callback?: (error: string) => void): void;
|
|
165
|
-
notifyAsync(notify: boolean): Promise<void>;
|
|
166
|
-
discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void;
|
|
167
|
-
discoverDescriptorsAsync(): Promise<Descriptor[]>;
|
|
168
|
-
toString(): string;
|
|
169
|
-
subscribe(callback?: (error: string) => void): void;
|
|
170
|
-
subscribeAsync(): Promise<void>;
|
|
171
|
-
unsubscribe(callback?: (error: string) => void): void;
|
|
172
|
-
unsubscribeAsync(): Promise<void>;
|
|
173
|
-
|
|
174
|
-
on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
175
|
-
on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
|
|
176
|
-
on(event: "broadcast", listener: (state: string) => void): this;
|
|
177
|
-
on(event: "notify", listener: (state: string) => void): this;
|
|
178
|
-
on(event: "data", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
179
|
-
on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
|
|
180
|
-
on(event: string, listener: Function): this;
|
|
181
|
-
on(event: string, option: boolean, listener: Function): this;
|
|
182
|
-
|
|
183
|
-
once(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
184
|
-
once(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
|
|
185
|
-
once(event: "broadcast", listener: (state: string) => void): this;
|
|
186
|
-
once(event: "notify", listener: (state: string) => void): this;
|
|
187
|
-
once(event: "data", listener: (data: Buffer, isNotification: boolean) => void): this;
|
|
188
|
-
once(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
|
|
189
|
-
once(event: string, listener: Function): this;
|
|
190
|
-
once(event: string, option: boolean, listener: Function): this;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export class Descriptor extends events.EventEmitter {
|
|
194
|
-
uuid: string;
|
|
195
|
-
name: string;
|
|
196
|
-
type: string;
|
|
197
|
-
|
|
198
|
-
readValue(callback?: (error: string, data: Buffer) => void): void;
|
|
199
|
-
readValueAsync(): Promise<Buffer>;
|
|
200
|
-
writeValue(data: Buffer, callback?: (error: string) => void): void;
|
|
201
|
-
writeValueAsync(data: Buffer): Promise<void>;
|
|
202
|
-
toString(): string;
|
|
203
|
-
|
|
204
|
-
on(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
|
|
205
|
-
on(event: "valueWrite", listener: (error: string) => void): this;
|
|
206
|
-
on(event: string, listener: Function): this;
|
|
207
|
-
|
|
208
|
-
once(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
|
|
209
|
-
once(event: "valueWrite", listener: (error: string) => void): this;
|
|
210
|
-
once(event: string, listener: Function): this;
|
|
211
|
-
}
|
|
201
|
+
once(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
|
|
202
|
+
once(event: "valueWrite", listener: (error: string) => void): this;
|
|
203
|
+
once(event: string, listener: Function): this;
|
|
212
204
|
}
|
|
213
|
-
export = noble;
|
package/index.js
CHANGED
|
@@ -84,10 +84,10 @@ NobleBindings.prototype._onMessage = function (ws, event) {
|
|
|
84
84
|
// TODO: handle duplicate peripheralUuid's
|
|
85
85
|
this._peripherals[peripheralUuid] = {
|
|
86
86
|
uuid: peripheralUuid,
|
|
87
|
-
address
|
|
88
|
-
advertisement
|
|
89
|
-
rssi
|
|
90
|
-
ws
|
|
87
|
+
address,
|
|
88
|
+
advertisement,
|
|
89
|
+
rssi,
|
|
90
|
+
ws
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
this.emit('discover', peripheralUuid, address, addressType, connectable, advertisement, rssi);
|
|
@@ -139,8 +139,8 @@ NobleBindings.prototype._sendCommand = function (ws, command) {
|
|
|
139
139
|
NobleBindings.prototype.startScanning = function (serviceUuids, allowDuplicates) {
|
|
140
140
|
this._startScanCommand = {
|
|
141
141
|
action: 'startScanning',
|
|
142
|
-
serviceUuids
|
|
143
|
-
allowDuplicates
|
|
142
|
+
serviceUuids,
|
|
143
|
+
allowDuplicates
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
this._sendCommand(null, this._startScanCommand);
|
|
@@ -191,7 +191,7 @@ NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) {
|
|
|
191
191
|
this._sendCommand(peripheral.ws, {
|
|
192
192
|
action: 'discoverServices',
|
|
193
193
|
peripheralUuid: peripheral.uuid,
|
|
194
|
-
uuids
|
|
194
|
+
uuids
|
|
195
195
|
});
|
|
196
196
|
};
|
|
197
197
|
|
|
@@ -201,8 +201,8 @@ NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, service
|
|
|
201
201
|
this._sendCommand(peripheral.ws, {
|
|
202
202
|
action: 'discoverIncludedServices',
|
|
203
203
|
peripheralUuid: peripheral.uuid,
|
|
204
|
-
serviceUuid
|
|
205
|
-
serviceUuids
|
|
204
|
+
serviceUuid,
|
|
205
|
+
serviceUuids
|
|
206
206
|
});
|
|
207
207
|
};
|
|
208
208
|
|
|
@@ -212,8 +212,8 @@ NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceU
|
|
|
212
212
|
this._sendCommand(peripheral.ws, {
|
|
213
213
|
action: 'discoverCharacteristics',
|
|
214
214
|
peripheralUuid: peripheral.uuid,
|
|
215
|
-
serviceUuid
|
|
216
|
-
characteristicUuids
|
|
215
|
+
serviceUuid,
|
|
216
|
+
characteristicUuids
|
|
217
217
|
});
|
|
218
218
|
};
|
|
219
219
|
|
|
@@ -223,8 +223,8 @@ NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristic
|
|
|
223
223
|
this._sendCommand(peripheral.ws, {
|
|
224
224
|
action: 'read',
|
|
225
225
|
peripheralUuid: peripheral.uuid,
|
|
226
|
-
serviceUuid
|
|
227
|
-
characteristicUuid
|
|
226
|
+
serviceUuid,
|
|
227
|
+
characteristicUuid
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
230
|
|
|
@@ -234,10 +234,10 @@ NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristi
|
|
|
234
234
|
this._sendCommand(peripheral.ws, {
|
|
235
235
|
action: 'write',
|
|
236
236
|
peripheralUuid: peripheral.uuid,
|
|
237
|
-
serviceUuid
|
|
238
|
-
characteristicUuid
|
|
237
|
+
serviceUuid,
|
|
238
|
+
characteristicUuid,
|
|
239
239
|
data: data.toString('hex'),
|
|
240
|
-
withoutResponse
|
|
240
|
+
withoutResponse
|
|
241
241
|
});
|
|
242
242
|
};
|
|
243
243
|
|
|
@@ -247,9 +247,9 @@ NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, character
|
|
|
247
247
|
this._sendCommand(peripheral.ws, {
|
|
248
248
|
action: 'broadcast',
|
|
249
249
|
peripheralUuid: peripheral.uuid,
|
|
250
|
-
serviceUuid
|
|
251
|
-
characteristicUuid
|
|
252
|
-
broadcast
|
|
250
|
+
serviceUuid,
|
|
251
|
+
characteristicUuid,
|
|
252
|
+
broadcast
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
255
|
|
|
@@ -259,9 +259,9 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist
|
|
|
259
259
|
this._sendCommand(peripheral.ws, {
|
|
260
260
|
action: 'notify',
|
|
261
261
|
peripheralUuid: peripheral.uuid,
|
|
262
|
-
serviceUuid
|
|
263
|
-
characteristicUuid
|
|
264
|
-
notify
|
|
262
|
+
serviceUuid,
|
|
263
|
+
characteristicUuid,
|
|
264
|
+
notify
|
|
265
265
|
});
|
|
266
266
|
};
|
|
267
267
|
|
|
@@ -271,8 +271,8 @@ NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid,
|
|
|
271
271
|
this._sendCommand(peripheral.ws, {
|
|
272
272
|
action: 'discoverDescriptors',
|
|
273
273
|
peripheralUuid: peripheral.uuid,
|
|
274
|
-
serviceUuid
|
|
275
|
-
characteristicUuid
|
|
274
|
+
serviceUuid,
|
|
275
|
+
characteristicUuid
|
|
276
276
|
});
|
|
277
277
|
};
|
|
278
278
|
|
|
@@ -282,9 +282,9 @@ NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, character
|
|
|
282
282
|
this._sendCommand(peripheral.ws, {
|
|
283
283
|
action: 'readValue',
|
|
284
284
|
peripheralUuid: peripheral.uuid,
|
|
285
|
-
serviceUuid
|
|
286
|
-
characteristicUuid
|
|
287
|
-
descriptorUuid
|
|
285
|
+
serviceUuid,
|
|
286
|
+
characteristicUuid,
|
|
287
|
+
descriptorUuid
|
|
288
288
|
});
|
|
289
289
|
};
|
|
290
290
|
|
|
@@ -294,9 +294,9 @@ NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characte
|
|
|
294
294
|
this._sendCommand(peripheral.ws, {
|
|
295
295
|
action: 'writeValue',
|
|
296
296
|
peripheralUuid: peripheral.uuid,
|
|
297
|
-
serviceUuid
|
|
298
|
-
characteristicUuid
|
|
299
|
-
descriptorUuid
|
|
297
|
+
serviceUuid,
|
|
298
|
+
characteristicUuid,
|
|
299
|
+
descriptorUuid,
|
|
300
300
|
data: data.toString('hex')
|
|
301
301
|
});
|
|
302
302
|
};
|
|
@@ -307,7 +307,7 @@ NobleBindings.prototype.readHandle = function (deviceUuid, handle) {
|
|
|
307
307
|
this._sendCommand(peripheral.ws, {
|
|
308
308
|
action: 'readHandle',
|
|
309
309
|
peripheralUuid: peripheral.uuid,
|
|
310
|
-
handle
|
|
310
|
+
handle
|
|
311
311
|
});
|
|
312
312
|
};
|
|
313
313
|
|
|
@@ -317,9 +317,9 @@ NobleBindings.prototype.writeHandle = function (deviceUuid, handle, data, withou
|
|
|
317
317
|
this._sendCommand(peripheral.ws, {
|
|
318
318
|
action: 'readHandle',
|
|
319
319
|
peripheralUuid: peripheral.uuid,
|
|
320
|
-
handle
|
|
320
|
+
handle,
|
|
321
321
|
data: data.toString('hex'),
|
|
322
|
-
withoutResponse
|
|
322
|
+
withoutResponse
|
|
323
323
|
});
|
|
324
324
|
};
|
|
325
325
|
|
|
@@ -303,9 +303,7 @@ NobleBindings.prototype.onLeConnComplete = function (
|
|
|
303
303
|
this.onConnectionParameterUpdateRequest.bind(this)
|
|
304
304
|
);
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
this._gatts[handle].exchangeMtu();
|
|
308
|
-
}, 0);
|
|
306
|
+
this._gatts[handle].exchangeMtu();
|
|
309
307
|
} else {
|
|
310
308
|
uuid = this._pendingConnectionUuid;
|
|
311
309
|
let statusMessage = Hci.STATUS_MAPPER[status] || 'HCI Error: Unknown';
|
package/lib/hci-socket/crypto.js
CHANGED
package/lib/hci-socket/gap.js
CHANGED
|
@@ -142,10 +142,12 @@ Gap.prototype.onHciLeAdvertisingReport = function (
|
|
|
142
142
|
address,
|
|
143
143
|
eir,
|
|
144
144
|
previouslyDiscovered,
|
|
145
|
-
|
|
145
|
+
type
|
|
146
146
|
);
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
if (process.env.DEBUG === 'gap') {
|
|
149
|
+
debug(`advertisement = ${JSON.stringify(advertisement, null, 0)}`);
|
|
150
|
+
}
|
|
149
151
|
|
|
150
152
|
const connectable =
|
|
151
153
|
type === LE_META_EVENT_TYPE_SCAN_RESPONSE && previouslyDiscovered
|
|
@@ -154,13 +156,13 @@ Gap.prototype.onHciLeAdvertisingReport = function (
|
|
|
154
156
|
const scannable = type === LE_META_EVENT_TYPE_SCANNABLE;
|
|
155
157
|
|
|
156
158
|
this._discoveries[address] = {
|
|
157
|
-
address
|
|
158
|
-
addressType
|
|
159
|
-
connectable
|
|
160
|
-
advertisement
|
|
161
|
-
rssi
|
|
159
|
+
address,
|
|
160
|
+
addressType,
|
|
161
|
+
connectable,
|
|
162
|
+
advertisement,
|
|
163
|
+
rssi,
|
|
162
164
|
count: discoveryCount,
|
|
163
|
-
hasScanResponse
|
|
165
|
+
hasScanResponse
|
|
164
166
|
};
|
|
165
167
|
|
|
166
168
|
// only report after a scan response event or if non-connectable or more than one discovery without a scan response, so more data can be collected
|
|
@@ -211,11 +213,13 @@ Gap.prototype.onHciLeExtendedAdvertisingReport = function (
|
|
|
211
213
|
address,
|
|
212
214
|
eir,
|
|
213
215
|
previouslyDiscovered,
|
|
214
|
-
|
|
216
|
+
type,
|
|
215
217
|
txpower
|
|
216
218
|
);
|
|
217
219
|
|
|
218
|
-
|
|
220
|
+
if (process.env.DEBUG === 'gap') {
|
|
221
|
+
debug(`advertisement = ${JSON.stringify(advertisement, null, 0)}`);
|
|
222
|
+
}
|
|
219
223
|
|
|
220
224
|
const connectable =
|
|
221
225
|
type & 0x8 && previouslyDiscovered
|
|
@@ -225,13 +229,13 @@ Gap.prototype.onHciLeExtendedAdvertisingReport = function (
|
|
|
225
229
|
const incomplete = type & LE_META_EXTENDED_EVENT_TYPE_INCOMPLETE_MASK ? 1 : 0;
|
|
226
230
|
|
|
227
231
|
this._discoveries[address] = {
|
|
228
|
-
address
|
|
229
|
-
addressType
|
|
230
|
-
connectable
|
|
231
|
-
advertisement
|
|
232
|
-
rssi
|
|
232
|
+
address,
|
|
233
|
+
addressType,
|
|
234
|
+
connectable,
|
|
235
|
+
advertisement,
|
|
236
|
+
rssi,
|
|
233
237
|
count: discoveryCount,
|
|
234
|
-
hasScanResponse
|
|
238
|
+
hasScanResponse
|
|
235
239
|
};
|
|
236
240
|
|
|
237
241
|
// only report after a scan response event or if non-connectable or more than one discovery without a scan response, so more data can be collected
|
|
@@ -258,7 +262,7 @@ Gap.prototype.parseServices = function (
|
|
|
258
262
|
address,
|
|
259
263
|
eir,
|
|
260
264
|
previouslyDiscovered,
|
|
261
|
-
|
|
265
|
+
leMetaEventType,
|
|
262
266
|
txpower
|
|
263
267
|
) {
|
|
264
268
|
let i = 0;
|
|
@@ -273,7 +277,7 @@ Gap.prototype.parseServices = function (
|
|
|
273
277
|
solicitationServiceUuids: []
|
|
274
278
|
};
|
|
275
279
|
|
|
276
|
-
if (
|
|
280
|
+
if (leMetaEventType !== LE_META_EVENT_TYPE_SCAN_RESPONSE) {
|
|
277
281
|
// reset service data every non-scan response event
|
|
278
282
|
advertisement.serviceData = [];
|
|
279
283
|
advertisement.serviceUuids = [];
|