incyclist-devices 1.4.32 → 1.4.33
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/lib/ble/ble-interface.js +8 -4
- package/package.json +1 -1
package/lib/ble/ble-interface.js
CHANGED
|
@@ -236,6 +236,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
|
|
|
236
236
|
yield this.connect();
|
|
237
237
|
}
|
|
238
238
|
const detectedPeripherals = {};
|
|
239
|
+
this.devices = [];
|
|
239
240
|
if (scanForDevice)
|
|
240
241
|
this.logEvent({ message: 'search device request', device, deviceTypes });
|
|
241
242
|
else
|
|
@@ -275,13 +276,16 @@ class BleInterface extends ble_1.BleInterfaceClass {
|
|
|
275
276
|
const d = new C({ peripheral });
|
|
276
277
|
d.setInterface(this);
|
|
277
278
|
if (scanForDevice) {
|
|
278
|
-
if ((device.id &&
|
|
279
|
+
if ((device.id && device.id !== '' && d.id === device.id) ||
|
|
280
|
+
(device.address && device.address !== '' && d.address === device.address) ||
|
|
281
|
+
(device.name && device.name !== '' && d.name === device.name))
|
|
279
282
|
cntFound++;
|
|
280
283
|
}
|
|
281
284
|
else
|
|
282
285
|
cntFound++;
|
|
283
|
-
|
|
284
|
-
|
|
286
|
+
const existing = this.devices.find(i => i.device.id === d.id);
|
|
287
|
+
if (cntFound > 0 && !existing) {
|
|
288
|
+
this.logEvent({ message: 'scan: device found', device: d.name, address: d.address, services: d.services.join(',') });
|
|
285
289
|
this.devices.push({ device: d, isConnected: false });
|
|
286
290
|
this.emit('device', d);
|
|
287
291
|
}
|
|
@@ -301,7 +305,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
|
|
|
301
305
|
});
|
|
302
306
|
this.scanState.timeout = setTimeout(() => {
|
|
303
307
|
this.scanState.timeout = null;
|
|
304
|
-
this.logEvent({ message: 'scan result: devices found', devices: this.devices.map(i => i.device.name) });
|
|
308
|
+
this.logEvent({ message: 'scan result: devices found', devices: this.devices.map(i => i.device.name + (!i.device.name || i.device.name === '') ? `addr=${i.device.address}` : '') });
|
|
305
309
|
resolve(this.devices.map(i => i.device));
|
|
306
310
|
bleBinding.stopScanning(() => {
|
|
307
311
|
this.scanState.isScanning = false;
|