@stoprocent/noble 1.10.1 → 1.10.3

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/index.d.ts CHANGED
@@ -11,193 +11,203 @@
11
11
 
12
12
  /// <reference types="node" />
13
13
 
14
- import events = require("events");
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
- }
59
14
 
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
- services: Service[];
69
- state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected';
70
-
71
- connect(callback?: (error: string) => void): void;
72
- connectAsync(): Promise<void>;
73
- disconnect(callback?: () => void): void;
74
- disconnectAsync(): Promise<void>;
75
- updateRssi(callback?: (error: string, rssi: number) => void): void;
76
- updateRssiAsync(): Promise<number>;
77
- discoverServices(): void;
78
- discoverServicesAsync(): Promise<Service[]>;
79
- discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void;
80
- discoverServicesAsync(serviceUUIDs: string[]): Promise<Service[]>;
81
- discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
82
- discoverAllServicesAndCharacteristicsAsync(): Promise<ServicesAndCharacteristics>;
83
- discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
84
- discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise<ServicesAndCharacteristics>;
85
- cancelConnect(options?: object): void;
86
-
87
- readHandle(handle: number, callback: (error: string, data: Buffer) => void): void;
88
- readHandleAsync(handle: number): Promise<Buffer>;
89
- writeHandle(handle: number, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void;
90
- writeHandleAsync(handle: number, data: Buffer, withoutResponse: boolean): Promise<void>;
91
- toString(): string;
92
-
93
- on(event: "connect", listener: (error: string) => void): this;
94
- on(event: "disconnect", listener: (error: string) => void): this;
95
- on(event: "rssiUpdate", listener: (rssi: number) => void): this;
96
- on(event: "servicesDiscover", listener: (services: Service[]) => void): this;
97
- on(event: string, listener: Function): this;
98
-
99
- once(event: "connect", listener: (error: string) => void): this;
100
- once(event: "disconnect", listener: (error: string) => void): this;
101
- once(event: "rssiUpdate", listener: (rssi: number) => void): this;
102
- once(event: "servicesDiscover", listener: (services: Service[]) => void): this;
103
- once(event: string, listener: Function): this;
104
- }
105
15
 
106
- export interface Advertisement {
107
- localName: string;
108
- serviceData: Array<{
109
- uuid: string,
110
- data: Buffer
111
- }>;
112
- txPowerLevel: number;
113
- manufacturerData: Buffer;
114
- serviceUuids: string[];
115
- }
116
-
117
- export declare class Service extends events.EventEmitter {
118
- uuid: string;
119
- name: string;
120
- type: string;
121
- includedServiceUuids: string[];
122
- characteristics: Characteristic[];
123
-
124
- discoverIncludedServices(): void;
125
- discoverIncludedServicesAsync(): Promise<string[]>;
126
- discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void;
127
- discoverIncludedServicesAsync(serviceUUIDs: string[]): Promise<string[]>;
128
- discoverCharacteristics(): void;
129
- discoverCharacteristicsAsync(): Promise<Characteristic[]>;
130
- discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void;
131
- discoverCharacteristicsAsync(characteristicUUIDs: string[]): Promise<Characteristic[]>;
132
- toString(): string;
133
-
134
- on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
135
- on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
136
- on(event: string, listener: Function): this;
137
-
138
- once(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
139
- once(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
140
- once(event: string, listener: Function): this;
141
- }
142
-
143
- export declare class Characteristic extends events.EventEmitter {
144
- uuid: string;
145
- name: string;
146
- type: string;
147
- properties: string[];
148
- descriptors: Descriptor[];
149
-
150
- read(callback?: (error: string, data: Buffer) => void): void;
151
- readAsync(): Promise<Buffer>;
152
- write(data: Buffer, withoutResponse: boolean, callback?: (error: string) => void): void;
153
- writeAsync(data: Buffer, withoutResponse: boolean): Promise<void>;
154
- broadcast(broadcast: boolean, callback?: (error: string) => void): void;
155
- broadcastAsync(broadcast: boolean): Promise<void>;
156
- notify(notify: boolean, callback?: (error: string) => void): void;
157
- notifyAsync(notify: boolean): Promise<void>;
158
- discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void;
159
- discoverDescriptorsAsync(): Promise<Descriptor[]>;
160
- toString(): string;
161
- subscribe(callback?: (error: string) => void): void;
162
- subscribeAsync(): Promise<void>;
163
- unsubscribe(callback?: (error: string) => void): void;
164
- unsubscribeAsync(): Promise<void>;
165
-
166
- on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
167
- on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
168
- on(event: "broadcast", listener: (state: string) => void): this;
169
- on(event: "notify", listener: (state: string) => void): this;
170
- on(event: "data", listener: (data: Buffer, isNotification: boolean) => void): this;
171
- on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
172
- on(event: string, listener: Function): this;
173
- on(event: string, option: boolean, listener: Function): this;
174
-
175
- once(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
176
- once(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
177
- once(event: "broadcast", listener: (state: string) => void): this;
178
- once(event: "notify", listener: (state: string) => void): this;
179
- once(event: "data", listener: (data: Buffer, isNotification: boolean) => void): this;
180
- once(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
181
- once(event: string, listener: Function): this;
182
- once(event: string, option: boolean, listener: Function): this;
183
- }
184
-
185
- export declare class Descriptor extends events.EventEmitter {
186
- uuid: string;
187
- name: string;
188
- type: string;
189
-
190
- readValue(callback?: (error: string, data: Buffer) => void): void;
191
- readValueAsync(): Promise<Buffer>;
192
- writeValue(data: Buffer, callback?: (error: string) => void): void;
193
- writeValueAsync(data: Buffer): Promise<void>;
194
- toString(): string;
195
-
196
- on(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
197
- on(event: "valueWrite", listener: (error: string) => void): this;
198
- on(event: string, listener: Function): this;
16
+ import events = require("events");
199
17
 
200
- once(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
201
- once(event: "valueWrite", listener: (error: string) => void): this;
202
- once(event: string, listener: Function): this;
18
+ declare function noble(option?: any): noble.Noble;
19
+
20
+ declare namespace noble
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
+ }
203
212
  }
213
+ export = noble;
@@ -4,8 +4,6 @@ const tryRequire = modulePath => {
4
4
  try {
5
5
  return require(modulePath);
6
6
  } catch (e) {
7
- console.error(`ERROR:\tCould not load manufacturer list from "${modulePath}".`);
8
- console.error(`\tPlease see "${path.join(__dirname, '..', 'scripts', 'manufactures', 'README.md')}" for instructions.`);
9
7
  return {};
10
8
  }
11
9
  };
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "license": "MIT",
8
8
  "name": "@stoprocent/noble",
9
9
  "description": "A Node.js BLE (Bluetooth Low Energy) central library.",
10
- "version": "1.10.1",
10
+ "version": "1.10.3",
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/stoprocent/noble.git"