incyclist-devices 1.4.86 → 1.4.88
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-device.js +2 -1
- package/lib/ble/wahoo-kickr.d.ts +1 -0
- package/lib/ble/wahoo-kickr.js +11 -5
- package/package.json +1 -1
package/lib/ble/ble-device.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.BleDevice = void 0;
|
|
|
13
13
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
14
14
|
const ble_1 = require("./ble");
|
|
15
15
|
const CONNECT_WAIT_TIMEOUT = 10000;
|
|
16
|
+
const BLE_TIMEOUT = 1000;
|
|
16
17
|
class BleDevice extends ble_1.BleDeviceClass {
|
|
17
18
|
constructor(props) {
|
|
18
19
|
super();
|
|
@@ -344,7 +345,7 @@ class BleDevice extends ble_1.BleDeviceClass {
|
|
|
344
345
|
else {
|
|
345
346
|
const writeId = this.writeQueue.length;
|
|
346
347
|
let messageDeleted = false;
|
|
347
|
-
this.writeQueue.push({ uuid: characteristicUuid.toLocaleLowerCase(), data, timeout: Date.now() +
|
|
348
|
+
this.writeQueue.push({ uuid: characteristicUuid.toLocaleLowerCase(), data, timeout: Date.now() + BLE_TIMEOUT, resolve, reject });
|
|
348
349
|
const to = setTimeout(() => {
|
|
349
350
|
if (this.writeQueue.length > writeId && !messageDeleted)
|
|
350
351
|
this.writeQueue.splice(writeId, 1);
|
package/lib/ble/wahoo-kickr.d.ts
CHANGED
package/lib/ble/wahoo-kickr.js
CHANGED
|
@@ -54,6 +54,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
54
54
|
this.timeOffset = 0;
|
|
55
55
|
this.tsPrevWrite = undefined;
|
|
56
56
|
this.prevSlope = undefined;
|
|
57
|
+
this.weight = Device_1.DEFAULT_BIKE_WEIGHT + Device_1.DEFAULT_USER_WEIGHT;
|
|
57
58
|
this.data = {};
|
|
58
59
|
this.wahooCP = consts_1.WAHOO_ADVANCED_TRAINER_CP;
|
|
59
60
|
}
|
|
@@ -277,6 +278,9 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
277
278
|
this.logEvent({ message: 'setSimMode failed', reason: 'control is disabled' });
|
|
278
279
|
return false;
|
|
279
280
|
}
|
|
281
|
+
this.weight = weight;
|
|
282
|
+
this.crr = crr;
|
|
283
|
+
this.cw = cw;
|
|
280
284
|
const data = Buffer.alloc(6);
|
|
281
285
|
data.writeInt16LE(Math.round(weight * 100), 0);
|
|
282
286
|
data.writeInt16LE(Math.round(crr * 10000), 2);
|
|
@@ -326,7 +330,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
326
330
|
return __awaiter(this, void 0, void 0, function* () {
|
|
327
331
|
this.logger.logEvent({ message: 'setSimGrade', slope });
|
|
328
332
|
try {
|
|
329
|
-
const value = (
|
|
333
|
+
const value = (slope / 100.0 + 1.0) * 32768;
|
|
330
334
|
const slopeVal = Math.floor(value);
|
|
331
335
|
const data = Buffer.alloc(2);
|
|
332
336
|
data.writeInt16LE(slopeVal, 0);
|
|
@@ -374,10 +378,11 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
374
378
|
if (this.prevSlope !== undefined && slope === this.prevSlope)
|
|
375
379
|
return;
|
|
376
380
|
try {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
this.
|
|
380
|
-
|
|
381
|
+
if (!this.isSimMode) {
|
|
382
|
+
const { weight, crr, cw } = this;
|
|
383
|
+
const hasSimMode = yield this.setSimMode(weight, crr, cw);
|
|
384
|
+
if (!hasSimMode)
|
|
385
|
+
throw new Error('Sim Mode not enabled');
|
|
381
386
|
}
|
|
382
387
|
const res = yield this.setSimGrade(slope);
|
|
383
388
|
this.logEvent({ message: 'setSlope result', res });
|
|
@@ -387,6 +392,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
387
392
|
catch (err) {
|
|
388
393
|
this.logEvent({ message: 'setSlope failed', reason: err.message || err });
|
|
389
394
|
this.prevSlope = undefined;
|
|
395
|
+
return false;
|
|
390
396
|
}
|
|
391
397
|
});
|
|
392
398
|
}
|