incyclist-devices 1.4.85 → 1.4.86
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-interface.js +1 -1
- package/lib/ble/pwr.d.ts +0 -1
- package/lib/ble/pwr.js +0 -1
- package/lib/ble/wahoo-kickr.d.ts +5 -0
- package/lib/ble/wahoo-kickr.js +14 -0
- package/package.json +1 -1
package/lib/ble/ble-interface.js
CHANGED
|
@@ -362,7 +362,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
|
|
|
362
362
|
createDevice(DeviceClass, peripheral, characteristics) {
|
|
363
363
|
try {
|
|
364
364
|
const C = DeviceClass;
|
|
365
|
-
const device = new C({ peripheral
|
|
365
|
+
const device = new C({ peripheral });
|
|
366
366
|
const cids = characteristics ? characteristics.map(c => (0, ble_1.uuid)(c.uuid)) : [];
|
|
367
367
|
this.logEvent({ message: 'trying to create device', peripheral: peripheral.address, characteristics: cids, profile: device.getProfile() });
|
|
368
368
|
const existingDevice = this.devices.find(i => i.device.id === device.id && i.device.getProfile() === device.getProfile());
|
package/lib/ble/pwr.d.ts
CHANGED
package/lib/ble/pwr.js
CHANGED
|
@@ -173,7 +173,6 @@ class PwrAdapter extends Device_1.default {
|
|
|
173
173
|
this.mode = this.getDefaultCyclingMode();
|
|
174
174
|
this.logger = new gd_eventlog_1.EventLogger('Ble-CP');
|
|
175
175
|
}
|
|
176
|
-
select() { this.selected = true; }
|
|
177
176
|
isBike() { return true; }
|
|
178
177
|
isHrm() { return false; }
|
|
179
178
|
isPower() { return true; }
|
package/lib/ble/wahoo-kickr.d.ts
CHANGED
|
@@ -37,6 +37,11 @@ export default class WahooAdvancedFitnessMachineDevice extends BleFitnessMachine
|
|
|
37
37
|
prevSlope: any;
|
|
38
38
|
wahooCP: string;
|
|
39
39
|
isSimMode: boolean;
|
|
40
|
+
simModeSettings: {
|
|
41
|
+
weight: number;
|
|
42
|
+
crr: number;
|
|
43
|
+
cw: number;
|
|
44
|
+
};
|
|
40
45
|
constructor(props?: any);
|
|
41
46
|
isMatching(characteristics: string[]): boolean;
|
|
42
47
|
init(): Promise<boolean>;
|
package/lib/ble/wahoo-kickr.js
CHANGED
|
@@ -252,6 +252,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
252
252
|
this.setPowerAdjusting();
|
|
253
253
|
this.data.targetPower = power;
|
|
254
254
|
this.isSimMode = false;
|
|
255
|
+
this.simModeSettings = undefined;
|
|
255
256
|
}
|
|
256
257
|
return res;
|
|
257
258
|
}
|
|
@@ -265,12 +266,24 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
265
266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
266
267
|
this.logger.logEvent({ message: 'setSimMode', weight, crr, cw });
|
|
267
268
|
try {
|
|
269
|
+
if (this.isSimMode && this.simModeSettings) {
|
|
270
|
+
if (weight === this.simModeSettings.weight &&
|
|
271
|
+
crr === this.simModeSettings.crr &&
|
|
272
|
+
cw === this.simModeSettings.cw)
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
const hasControl = yield this.requestControl();
|
|
276
|
+
if (!hasControl) {
|
|
277
|
+
this.logEvent({ message: 'setSimMode failed', reason: 'control is disabled' });
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
268
280
|
const data = Buffer.alloc(6);
|
|
269
281
|
data.writeInt16LE(Math.round(weight * 100), 0);
|
|
270
282
|
data.writeInt16LE(Math.round(crr * 10000), 2);
|
|
271
283
|
data.writeInt16LE(Math.round(cw * 1000), 4);
|
|
272
284
|
const res = yield this.writeWahooFtmsMessage(67, data);
|
|
273
285
|
this.isSimMode = true;
|
|
286
|
+
this.simModeSettings = { weight, crr, cw };
|
|
274
287
|
return res;
|
|
275
288
|
}
|
|
276
289
|
catch (err) {
|
|
@@ -380,6 +393,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
380
393
|
reset() {
|
|
381
394
|
this.data = {};
|
|
382
395
|
this.isSimMode = undefined;
|
|
396
|
+
this.simModeSettings = undefined;
|
|
383
397
|
}
|
|
384
398
|
}
|
|
385
399
|
exports.default = WahooAdvancedFitnessMachineDevice;
|