incyclist-devices 2.0.26 → 2.0.28
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.
|
@@ -50,7 +50,7 @@ export default class DaumAdapterBase extends SerialIncyclistDevice implements Da
|
|
|
50
50
|
sendRequests(): Promise<void>;
|
|
51
51
|
bikeSync(): Promise<void>;
|
|
52
52
|
updateData(prev: any, bikeData: any): IncyclistBikeData;
|
|
53
|
-
transformData(): DeviceData;
|
|
53
|
+
transformData(cyclingData: IncyclistBikeData): DeviceData;
|
|
54
54
|
sendRequest(request: any): Promise<any>;
|
|
55
55
|
refreshRequests(): void;
|
|
56
56
|
processClientRequest(request: any): Promise<unknown>;
|
|
@@ -235,22 +235,21 @@ class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
|
|
|
235
235
|
}
|
|
236
236
|
update() {
|
|
237
237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
-
this.logEvent({ message: 'bike update request', stopped: this.stopped, updateBusy: this.updateBusy });
|
|
239
238
|
if (this.stopped)
|
|
240
239
|
return;
|
|
241
240
|
this.updateBusy = true;
|
|
242
241
|
this.getCurrentBikeData()
|
|
243
242
|
.then(bikeData => {
|
|
244
|
-
this.updateData(this.cyclingData, bikeData);
|
|
245
|
-
const data = this.transformData();
|
|
243
|
+
const incyclistData = this.updateData(this.cyclingData, bikeData);
|
|
244
|
+
const data = this.transformData(incyclistData);
|
|
246
245
|
this.updateBusy = false;
|
|
247
246
|
this.emitData(data);
|
|
248
247
|
})
|
|
249
248
|
.catch(err => {
|
|
250
249
|
this.logEvent({ message: 'bike update error', error: err.message, stack: err.stack });
|
|
251
250
|
const { isPedalling, power, pedalRpm, speed, distanceInternal, heartrate, slope } = this.cyclingData;
|
|
252
|
-
this.updateData(this.cyclingData, { isPedalling, power, pedalRpm, speed, distanceInternal, heartrate, slope });
|
|
253
|
-
this.transformData();
|
|
251
|
+
const incyclistData = this.updateData(this.cyclingData, { isPedalling, power, pedalRpm, speed, distanceInternal, heartrate, slope });
|
|
252
|
+
this.transformData(incyclistData);
|
|
254
253
|
this.updateBusy = false;
|
|
255
254
|
});
|
|
256
255
|
});
|
|
@@ -310,25 +309,23 @@ class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
|
|
|
310
309
|
this.cyclingData = this.getCyclingMode().updateData(data);
|
|
311
310
|
return this.cyclingData;
|
|
312
311
|
}
|
|
313
|
-
transformData() {
|
|
314
|
-
if (this.cyclingData === undefined)
|
|
315
|
-
return;
|
|
312
|
+
transformData(cyclingData) {
|
|
316
313
|
let distance = 0;
|
|
317
|
-
if (this.distanceInternal !== undefined &&
|
|
318
|
-
distance =
|
|
314
|
+
if (this.distanceInternal !== undefined && cyclingData.distanceInternal !== undefined) {
|
|
315
|
+
distance = cyclingData.distanceInternal - this.distanceInternal;
|
|
319
316
|
}
|
|
320
|
-
if (
|
|
321
|
-
this.distanceInternal =
|
|
317
|
+
if (cyclingData.distanceInternal !== undefined)
|
|
318
|
+
this.distanceInternal = cyclingData.distanceInternal;
|
|
322
319
|
let data = {
|
|
323
|
-
speed:
|
|
324
|
-
slope:
|
|
325
|
-
power: (0, utils_1.intVal)(
|
|
326
|
-
cadence: (0, utils_1.intVal)(
|
|
327
|
-
heartrate: (0, utils_1.intVal)(
|
|
320
|
+
speed: cyclingData.speed || 0,
|
|
321
|
+
slope: cyclingData.slope,
|
|
322
|
+
power: (0, utils_1.intVal)(cyclingData.power || 0),
|
|
323
|
+
cadence: (0, utils_1.intVal)(cyclingData.pedalRpm),
|
|
324
|
+
heartrate: (0, utils_1.intVal)(cyclingData.heartrate),
|
|
328
325
|
distance,
|
|
329
326
|
timestamp: Date.now(),
|
|
330
|
-
deviceTime:
|
|
331
|
-
deviceDistanceCounter:
|
|
327
|
+
deviceTime: cyclingData.time,
|
|
328
|
+
deviceDistanceCounter: cyclingData.distanceInternal
|
|
332
329
|
};
|
|
333
330
|
if (this.ignoreHrm)
|
|
334
331
|
delete data.heartrate;
|