incyclist-devices 1.4.69 → 1.4.72

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/fm.js CHANGED
@@ -426,8 +426,8 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
426
426
  return __awaiter(this, void 0, void 0, function* () {
427
427
  const hasControl = yield this.requestControl();
428
428
  if (!hasControl) {
429
- this.logEvent({ message: 'setTargetInclination failed', reason: 'control is disabled' });
430
- return;
429
+ this.logEvent({ message: 'setIndoorBikeSimulation failed', reason: 'control is disabled' });
430
+ return false;
431
431
  }
432
432
  const data = Buffer.alloc(7);
433
433
  data.writeUInt8(17, 0);
@@ -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);
@@ -264,8 +267,9 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
264
267
  setSimGrade(slope) {
265
268
  return __awaiter(this, void 0, void 0, function* () {
266
269
  const value = (Math.min(1, Math.max(-1, slope)) + 1.0) * 65535 / 2.0;
270
+ const slopeVal = Math.floor(value);
267
271
  const data = Buffer.alloc(2);
268
- data.writeInt16LE(Math.round(value), 0);
272
+ data.writeInt16LE(slopeVal, 0);
269
273
  const res = yield this.writeWahooFtmsMessage(70, data);
270
274
  return res;
271
275
  });
@@ -295,8 +299,23 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
295
299
  setSlope(slope) {
296
300
  return __awaiter(this, void 0, void 0, function* () {
297
301
  this.logEvent({ message: 'setSlope', slope });
298
- const { windSpeed, crr, cw } = this;
299
- return yield this.setIndoorBikeSimulation(windSpeed, slope, crr, cw);
302
+ if (this.prevSlope !== undefined && slope === this.prevSlope)
303
+ return;
304
+ try {
305
+ const hasControl = yield this.requestControl();
306
+ if (!hasControl) {
307
+ this.logEvent({ message: 'setTargetPower failed', reason: 'control is disabled' });
308
+ return false;
309
+ }
310
+ const res = yield this.setSimGrade(slope);
311
+ this.logEvent({ message: 'setSlope result', res });
312
+ this.prevSlope = slope;
313
+ return res;
314
+ }
315
+ catch (err) {
316
+ this.logEvent({ message: 'setSlope failed', reason: err.message || err });
317
+ this.prevSlope = undefined;
318
+ }
300
319
  });
301
320
  }
302
321
  reset() {
@@ -304,7 +323,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
304
323
  }
305
324
  }
306
325
  exports.default = WahooAdvancedFitnessMachineDevice;
307
- WahooAdvancedFitnessMachineDevice.services = ['a026ee0b'];
326
+ WahooAdvancedFitnessMachineDevice.services = ['1818'];
308
327
  WahooAdvancedFitnessMachineDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', WAHOO_ADVANCED_TRAINER_CP];
309
328
  ble_interface_1.default.register('WahooAdvancedFitnessMachineDevice', 'wahoo-fm', WahooAdvancedFitnessMachineDevice, WahooAdvancedFitnessMachineDevice.services);
310
329
  class WahooAdvancedFmAdapter extends fm_1.FmAdapter {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.4.69",
3
+ "version": "1.4.72",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",