incyclist-devices 1.5.6 → 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.
@@ -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
- const success = yield channel.startScanner();
143
- this.logEvent({ message: 'scan started', success });
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
- throw err;
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
- return yield channel.stopSensor(sensor);
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() {
@@ -3,7 +3,7 @@ import DeviceProtocolBase, { DeviceProtocol, DeviceSettings, ScanProps } from ".
3
3
  import AntDeviceBinding from './ant-binding';
4
4
  import AntAdapter from "./ant-device";
5
5
  import AntInterface from "./ant-interface";
6
- export declare const mapAntProfile: (antProfile: any) => "SmartTrainer" | "Heartrate Monitor" | "Power Meter";
6
+ export declare const mapAntProfile: (antProfile: any) => "Heartrate Monitor" | "Power Meter" | "Smart Trainer";
7
7
  export declare const mapIncyclistProfile: (incyclistProfile: any) => "PWR" | "HR" | "FE";
8
8
  export interface AntDeviceSettings extends DeviceSettings {
9
9
  deviceID?: string;
@@ -42,7 +42,7 @@ const mapAntProfile = (antProfile) => {
42
42
  switch (antProfile) {
43
43
  case 'HR': return 'Heartrate Monitor';
44
44
  case 'PWR': return 'Power Meter';
45
- case 'FE': return 'SmartTrainer';
45
+ case 'FE': return 'Smart Trainer';
46
46
  }
47
47
  };
48
48
  exports.mapAntProfile = mapAntProfile;
@@ -50,7 +50,7 @@ const mapIncyclistProfile = (incyclistProfile) => {
50
50
  switch (incyclistProfile) {
51
51
  case 'Heartrate Monitor': return 'HR';
52
52
  case 'Power Meter': return 'PWR';
53
- case 'SmartTrainer': return 'FE';
53
+ case 'Smart Trainer': return 'FE';
54
54
  }
55
55
  };
56
56
  exports.mapIncyclistProfile = mapIncyclistProfile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",