incyclist-devices 3.0.48 → 3.0.49
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.
|
@@ -26,6 +26,7 @@ class BleInterface extends node_events_1.EventEmitter {
|
|
|
26
26
|
logDisabled;
|
|
27
27
|
internalEvents;
|
|
28
28
|
services = [];
|
|
29
|
+
pendingWaits = [];
|
|
29
30
|
incompleteServices = [];
|
|
30
31
|
unsupported = [];
|
|
31
32
|
expectedServices = ['180d', '1818', '1826', '6e40fec1'];
|
|
@@ -318,9 +319,19 @@ class BleInterface extends node_events_1.EventEmitter {
|
|
|
318
319
|
this.off('device', onDevice);
|
|
319
320
|
if (timer)
|
|
320
321
|
clearTimeout(timer);
|
|
322
|
+
this.pendingWaits = this.pendingWaits.filter(w => w !== pending);
|
|
321
323
|
if (temporary || !wasDiscovering)
|
|
322
324
|
this.stopPeripheralScan().catch(() => { });
|
|
323
325
|
};
|
|
326
|
+
const pending = {
|
|
327
|
+
address: settings.address,
|
|
328
|
+
name: settings.name,
|
|
329
|
+
cancel: () => {
|
|
330
|
+
finish();
|
|
331
|
+
reject(new Error('peripheral wait cancelled'));
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
this.pendingWaits.push(pending);
|
|
324
335
|
const onDevice = (device) => {
|
|
325
336
|
if (device.address === settings.address) {
|
|
326
337
|
const peripheral = this.createPeripheralFromSettings(device);
|
|
@@ -345,6 +356,11 @@ class BleInterface extends node_events_1.EventEmitter {
|
|
|
345
356
|
this.startPeripheralScan();
|
|
346
357
|
});
|
|
347
358
|
}
|
|
359
|
+
cancelWait(settings) {
|
|
360
|
+
this.pendingWaits
|
|
361
|
+
.filter(w => settings.address !== undefined ? w.address === settings.address : w.name === settings.name)
|
|
362
|
+
.forEach(w => w.cancel());
|
|
363
|
+
}
|
|
348
364
|
createDeviceSetting(service) {
|
|
349
365
|
const { peripheral } = service;
|
|
350
366
|
if (peripheral.address === undefined || peripheral.address === '')
|
|
@@ -23,6 +23,7 @@ export class BleInterface extends EventEmitter {
|
|
|
23
23
|
logDisabled;
|
|
24
24
|
internalEvents;
|
|
25
25
|
services = [];
|
|
26
|
+
pendingWaits = [];
|
|
26
27
|
incompleteServices = [];
|
|
27
28
|
unsupported = [];
|
|
28
29
|
expectedServices = ['180d', '1818', '1826', '6e40fec1'];
|
|
@@ -315,9 +316,19 @@ export class BleInterface extends EventEmitter {
|
|
|
315
316
|
this.off('device', onDevice);
|
|
316
317
|
if (timer)
|
|
317
318
|
clearTimeout(timer);
|
|
319
|
+
this.pendingWaits = this.pendingWaits.filter(w => w !== pending);
|
|
318
320
|
if (temporary || !wasDiscovering)
|
|
319
321
|
this.stopPeripheralScan().catch(() => { });
|
|
320
322
|
};
|
|
323
|
+
const pending = {
|
|
324
|
+
address: settings.address,
|
|
325
|
+
name: settings.name,
|
|
326
|
+
cancel: () => {
|
|
327
|
+
finish();
|
|
328
|
+
reject(new Error('peripheral wait cancelled'));
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
this.pendingWaits.push(pending);
|
|
321
332
|
const onDevice = (device) => {
|
|
322
333
|
if (device.address === settings.address) {
|
|
323
334
|
const peripheral = this.createPeripheralFromSettings(device);
|
|
@@ -342,6 +353,11 @@ export class BleInterface extends EventEmitter {
|
|
|
342
353
|
this.startPeripheralScan();
|
|
343
354
|
});
|
|
344
355
|
}
|
|
356
|
+
cancelWait(settings) {
|
|
357
|
+
this.pendingWaits
|
|
358
|
+
.filter(w => settings.address !== undefined ? w.address === settings.address : w.name === settings.name)
|
|
359
|
+
.forEach(w => w.cancel());
|
|
360
|
+
}
|
|
345
361
|
createDeviceSetting(service) {
|
|
346
362
|
const { peripheral } = service;
|
|
347
363
|
if (peripheral.address === undefined || peripheral.address === '')
|
|
@@ -23,6 +23,11 @@ export declare class BleInterface extends EventEmitter implements IBleInterface<
|
|
|
23
23
|
protected logDisabled: boolean;
|
|
24
24
|
protected internalEvents: EventEmitter;
|
|
25
25
|
protected services: Announcement[];
|
|
26
|
+
protected pendingWaits: Array<{
|
|
27
|
+
address?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
cancel: () => void;
|
|
30
|
+
}>;
|
|
26
31
|
protected incompleteServices: BlePeripheralAnnouncement[];
|
|
27
32
|
protected unsupported: BlePeripheralAnnouncement[];
|
|
28
33
|
protected expectedServices: string[];
|
|
@@ -74,6 +79,7 @@ export declare class BleInterface extends EventEmitter implements IBleInterface<
|
|
|
74
79
|
createPeripheral(announcement: BlePeripheralAnnouncement): IBlePeripheral;
|
|
75
80
|
createPeripheralFromSettings(settings: BleDeviceSettings): IBlePeripheral;
|
|
76
81
|
waitForPeripheral(settings: BleDeviceSettings): Promise<IBlePeripheral>;
|
|
82
|
+
cancelWait(settings: BleDeviceSettings): void;
|
|
77
83
|
createDeviceSetting(service: BlePeripheralAnnouncement): BleDeviceSettings;
|
|
78
84
|
protected reconnect(): Promise<void>;
|
|
79
85
|
protected startPeripheralScan(retry?: boolean, force?: boolean): Promise<void>;
|