incyclist-devices 1.5.7 → 1.5.8
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/antv2/ant-interface.js +21 -5
- package/package.json +1 -1
|
@@ -139,8 +139,16 @@ class AntInterface extends events_1.default {
|
|
|
139
139
|
});
|
|
140
140
|
channel.on('detected', onDetected);
|
|
141
141
|
channel.on('data', this.onData.bind(this));
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
try {
|
|
143
|
+
const success = yield channel.startScanner();
|
|
144
|
+
this.logEvent({ message: 'scan started', success });
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
this.logEvent({ message: 'scan could not be started', error: err.message, stack: err.stack });
|
|
148
|
+
channel.off('detected', onDetected);
|
|
149
|
+
channel.off('data', this.onData.bind(this));
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
144
152
|
let iv;
|
|
145
153
|
return new Promise(resolve => {
|
|
146
154
|
this.activeScan = channel;
|
|
@@ -213,11 +221,12 @@ class AntInterface extends events_1.default {
|
|
|
213
221
|
return yield channel.startSensor(sensor);
|
|
214
222
|
}
|
|
215
223
|
catch (err) {
|
|
224
|
+
this.logEvent({ message: 'could not start sensor', error: err.message || err, stack: err.stack });
|
|
216
225
|
try {
|
|
217
226
|
yield channel.stopSensor(sensor);
|
|
218
227
|
}
|
|
219
228
|
catch (_a) { }
|
|
220
|
-
|
|
229
|
+
return false;
|
|
221
230
|
}
|
|
222
231
|
});
|
|
223
232
|
}
|
|
@@ -227,8 +236,15 @@ class AntInterface extends events_1.default {
|
|
|
227
236
|
return true;
|
|
228
237
|
const channel = sensor.getChannel();
|
|
229
238
|
channel.removeAllListeners('data');
|
|
230
|
-
if (channel)
|
|
231
|
-
|
|
239
|
+
if (channel) {
|
|
240
|
+
try {
|
|
241
|
+
return yield channel.stopSensor(sensor);
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
this.logEvent({ message: 'could not stop sensor', error: err.message || err, stack: err.stack });
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
232
248
|
});
|
|
233
249
|
}
|
|
234
250
|
isScanning() {
|