incyclist-devices 1.4.68 → 1.4.71

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.
@@ -108,8 +108,6 @@ class BleDevice extends ble_1.BleDeviceClass {
108
108
  }
109
109
  init() {
110
110
  return __awaiter(this, void 0, void 0, function* () {
111
- if (this.isInitialized)
112
- return Promise.resolve(true);
113
111
  return yield this.initDevice();
114
112
  });
115
113
  }
@@ -269,7 +267,7 @@ class BleDevice extends ble_1.BleDeviceClass {
269
267
  const updatedQueue = [];
270
268
  let hasTimeout = false;
271
269
  this.writeQueue.forEach(writeItem => {
272
- if (writeItem.timeout && writeItem.timeout > now) {
270
+ if (writeItem.timeout && writeItem.timeout < now) {
273
271
  if (writeItem.reject) {
274
272
  hasTimeout = true;
275
273
  writeItem.reject(new Error('timeout'));
@@ -326,7 +324,7 @@ class BleDevice extends ble_1.BleDeviceClass {
326
324
  else {
327
325
  const writeId = this.writeQueue.length;
328
326
  let messageDeleted = false;
329
- this.writeQueue.push({ uuid: characteristicUuid.toLocaleLowerCase(), data, timeout: Date.now() + 1000, resolve, reject });
327
+ this.writeQueue.push({ uuid: characteristicUuid.toLocaleLowerCase(), data, timeout: Date.now() + 2500, resolve, reject });
330
328
  const to = setTimeout(() => {
331
329
  if (this.writeQueue.length > writeId && !messageDeleted)
332
330
  this.writeQueue.splice(writeId, 1);
package/lib/ble/fm.js CHANGED
@@ -424,9 +424,11 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
424
424
  }
425
425
  setIndoorBikeSimulation(windSpeed, gradient, crr, cw) {
426
426
  return __awaiter(this, void 0, void 0, function* () {
427
- if (!this.hasControl)
428
- return;
429
427
  const hasControl = yield this.requestControl();
428
+ if (!hasControl) {
429
+ this.logEvent({ message: 'setIndoorBikeSimulation failed', reason: 'control is disabled' });
430
+ return false;
431
+ }
430
432
  const data = Buffer.alloc(7);
431
433
  data.writeUInt8(17, 0);
432
434
  data.writeInt16LE(Math.round(windSpeed * 1000), 1);
@@ -34,6 +34,7 @@ export default class WahooAdvancedFitnessMachineDevice extends BleFitnessMachine
34
34
  currentCrankData: CrankData;
35
35
  timeOffset: number;
36
36
  tsPrevWrite: any;
37
+ prevSlope: any;
37
38
  constructor(props?: any);
38
39
  isMatching(characteristics: string[]): boolean;
39
40
  init(): Promise<boolean>;
@@ -37,7 +37,7 @@ const Device_1 = require("../Device");
37
37
  const gd_eventlog_1 = require("gd-eventlog");
38
38
  const fm_1 = __importStar(require("./fm"));
39
39
  const WAHOO_ADVANCED_FTMS = 'a026e00b';
40
- const WAHOO_ADVANCED_TRAINER_CP = 'a026e037';
40
+ const WAHOO_ADVANCED_TRAINER_CP = 'a026e005';
41
41
  const cwABike = {
42
42
  race: 0.35,
43
43
  triathlon: 0.29,
@@ -52,6 +52,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
52
52
  this.currentCrankData = undefined;
53
53
  this.timeOffset = 0;
54
54
  this.tsPrevWrite = undefined;
55
+ this.prevSlope = undefined;
55
56
  this.data = {};
56
57
  }
57
58
  isMatching(characteristics) {
@@ -196,6 +197,8 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
196
197
  if (this.hasControl)
197
198
  return true;
198
199
  this.logEvent({ message: 'requestControl' });
200
+ this.hasControl = true;
201
+ return;
199
202
  const data = Buffer.alloc(2);
200
203
  data.writeUInt8(0xEE, 0);
201
204
  data.writeUInt8(0xFC, 1);
@@ -295,8 +298,23 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
295
298
  setSlope(slope) {
296
299
  return __awaiter(this, void 0, void 0, function* () {
297
300
  this.logEvent({ message: 'setSlope', slope });
298
- const { windSpeed, crr, cw } = this;
299
- return yield this.setIndoorBikeSimulation(windSpeed, slope, crr, cw);
301
+ if (this.prevSlope !== undefined && slope === this.prevSlope)
302
+ return;
303
+ try {
304
+ const hasControl = yield this.requestControl();
305
+ if (!hasControl) {
306
+ this.logEvent({ message: 'setTargetPower failed', reason: 'control is disabled' });
307
+ return false;
308
+ }
309
+ const res = yield this.setSimGrade(slope);
310
+ this.logEvent({ message: 'setSlope result', res });
311
+ this.prevSlope = slope;
312
+ return res;
313
+ }
314
+ catch (err) {
315
+ this.logEvent({ message: 'setSlope failed', reason: err.message || err });
316
+ this.prevSlope = undefined;
317
+ }
300
318
  });
301
319
  }
302
320
  reset() {
@@ -304,7 +322,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
304
322
  }
305
323
  }
306
324
  exports.default = WahooAdvancedFitnessMachineDevice;
307
- WahooAdvancedFitnessMachineDevice.services = ['a026ee0b'];
325
+ WahooAdvancedFitnessMachineDevice.services = ['1818'];
308
326
  WahooAdvancedFitnessMachineDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', WAHOO_ADVANCED_TRAINER_CP];
309
327
  ble_interface_1.default.register('WahooAdvancedFitnessMachineDevice', 'wahoo-fm', WahooAdvancedFitnessMachineDevice, WahooAdvancedFitnessMachineDevice.services);
310
328
  class WahooAdvancedFmAdapter extends fm_1.FmAdapter {
@@ -1,7 +1,7 @@
1
1
  export declare const DEFAULT_AGE = 30;
2
2
  export declare const DEFAULT_USER_WEIGHT = 75;
3
3
  export declare const DEFAULT_BIKE_WEIGHT = 10;
4
- export declare function getCockpit(c: any): "Cardio" | "Fitness" | "Vita De Luxe" | "8008" | "8008 TRS" | "8080" | "Therapie" | "8008 TRS Pro" | "8008 TRS3" | "Unknown";
4
+ export declare function getCockpit(c: any): "Cardio" | "Fitness" | "Vita De Luxe" | "8008" | "8008 TRS" | "8080" | "Therapie" | "8008 TRS Pro" | "8008 TRS3" | "ergo_lyps Cardio Pro" | "Unknown";
5
5
  export declare function getBikeType(type: any): 1 | 0;
6
6
  export declare function getGender(sex: any): 1 | 2;
7
7
  export declare function getLength(length: any): number;
@@ -24,6 +24,8 @@ function getCockpit(c) {
24
24
  return "8008 TRS Pro";
25
25
  case 160:
26
26
  return "8008 TRS3";
27
+ case 0x8D:
28
+ return "ergo_lyps Cardio Pro";
27
29
  default:
28
30
  return "Unknown";
29
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.4.68",
3
+ "version": "1.4.71",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",