incyclist-devices 2.3.11 → 2.3.13
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/adapter.js +7 -7
- package/lib/ble/fm/sensor.js +3 -3
- package/package.json +1 -1
package/lib/ble/fm/adapter.js
CHANGED
|
@@ -229,19 +229,19 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
229
229
|
return __awaiter(this, arguments, void 0, function* (request, enforced = false) {
|
|
230
230
|
if (!enforced && (this.paused || !this.device))
|
|
231
231
|
return;
|
|
232
|
-
if (!this.hasCapability(types_1.IncyclistCapability.Control))
|
|
233
|
-
return;
|
|
234
232
|
if (!enforced && (this.stopped && !this.isStarting()))
|
|
235
233
|
return;
|
|
236
234
|
try {
|
|
237
235
|
const update = this.getCyclingMode().sendBikeUpdate(request);
|
|
238
236
|
this.logEvent({ message: 'send bike update requested', profile: this.getProfile(), update, request });
|
|
239
237
|
const device = this.getSensor();
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
238
|
+
if (this.hasCapability(types_1.IncyclistCapability.Control)) {
|
|
239
|
+
if (update.slope !== undefined) {
|
|
240
|
+
yield device.setSlope(update.slope);
|
|
241
|
+
}
|
|
242
|
+
if (update.targetPower !== undefined) {
|
|
243
|
+
yield device.setTargetPower(update.targetPower);
|
|
244
|
+
}
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
catch (err) {
|
package/lib/ble/fm/sensor.js
CHANGED
|
@@ -144,9 +144,9 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
144
144
|
}
|
|
145
145
|
parseIndoorBikeData(_data) {
|
|
146
146
|
const data = Buffer.from(_data);
|
|
147
|
+
let offset = 2;
|
|
147
148
|
try {
|
|
148
149
|
const flags = data.readUInt16LE(0);
|
|
149
|
-
let offset = 2;
|
|
150
150
|
if ((flags & consts_2.IndoorBikeDataFlag.MoreData) === 0) {
|
|
151
151
|
this.data.speed = data.readUInt16LE(offset) / 100;
|
|
152
152
|
offset += 2;
|
|
@@ -196,7 +196,7 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
196
196
|
}
|
|
197
197
|
if (flags & consts_2.IndoorBikeDataFlag.MetabolicEquivalentPresent) {
|
|
198
198
|
this.data.metabolicEquivalent = data.readUInt8(offset) / 10;
|
|
199
|
-
offset +=
|
|
199
|
+
offset += 1;
|
|
200
200
|
}
|
|
201
201
|
if (flags & consts_2.IndoorBikeDataFlag.ElapsedTimePresent) {
|
|
202
202
|
this.data.time = data.readUInt16LE(offset);
|
|
@@ -207,7 +207,7 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
catch (err) {
|
|
210
|
-
this.logEvent({ message: 'error', fn: 'parseIndoorBikeData()', error: err.message | err, stack: err.stack });
|
|
210
|
+
this.logEvent({ message: 'error', fn: 'parseIndoorBikeData()', data: data.toString('hex'), offset, error: err.message | err, stack: err.stack });
|
|
211
211
|
}
|
|
212
212
|
return Object.assign(Object.assign({}, this.data), { raw: `2ad2:${data.toString('hex')}` });
|
|
213
213
|
}
|