incyclist-devices 1.4.5 → 1.4.6
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/Device.d.ts +1 -0
- package/lib/daum/ERGCyclingMode.js +2 -2
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -2
- package/lib/daum/premium/DaumPremiumAdapter.js +8 -24
- package/lib/daum/premium/bike.d.ts +2 -1
- package/lib/daum/premium/bike.js +5 -1
- package/lib/daum/premium/utils.js +4 -5
- package/package.json +1 -1
package/lib/Device.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare type DeviceData = {
|
|
|
12
12
|
deviceDistanceCounter?: number;
|
|
13
13
|
};
|
|
14
14
|
export declare type OnDeviceDataCallback = (data: DeviceData) => void;
|
|
15
|
+
export declare type OnDeviceStartCallback = (completed: number, total: number) => void;
|
|
15
16
|
export interface Bike {
|
|
16
17
|
setCyclingMode(mode: CyclingMode | string, settings?: any): void;
|
|
17
18
|
getSupportedCyclingModes(): Array<any>;
|
|
@@ -159,11 +159,11 @@ class ERGCyclingMode extends CyclingMode_1.CyclingModeBase {
|
|
|
159
159
|
}
|
|
160
160
|
data.speed = parseFloat(speed.toFixed(1));
|
|
161
161
|
data.power = Math.round(power);
|
|
162
|
-
data.distanceInternal =
|
|
162
|
+
data.distanceInternal = distanceInternal;
|
|
163
163
|
data.slope = slope;
|
|
164
164
|
data.pedalRpm = rpm;
|
|
165
165
|
data.gear = gear;
|
|
166
|
-
if (data.time)
|
|
166
|
+
if (data.time !== undefined)
|
|
167
167
|
data.time += duration;
|
|
168
168
|
else
|
|
169
169
|
data.time = 0;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Route } from '../../types/route';
|
|
2
1
|
import DaumAdapter from '../DaumAdapter';
|
|
3
2
|
export default class DaumPremiumDevice extends DaumAdapter {
|
|
4
3
|
static NAME: string;
|
|
@@ -8,7 +7,6 @@ export default class DaumPremiumDevice extends DaumAdapter {
|
|
|
8
7
|
getInterface(): any;
|
|
9
8
|
getSupportedCyclingModes(): Array<any>;
|
|
10
9
|
check(): Promise<unknown>;
|
|
11
|
-
initClassic(route: Route): Promise<boolean>;
|
|
12
10
|
start(props: any): Promise<unknown>;
|
|
13
11
|
getCurrentBikeData(): Promise<any>;
|
|
14
12
|
}
|
|
@@ -62,20 +62,6 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
62
62
|
}
|
|
63
63
|
}));
|
|
64
64
|
}
|
|
65
|
-
initClassic(route) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
if (!route)
|
|
68
|
-
return true;
|
|
69
|
-
let res;
|
|
70
|
-
const bikeType = this.getCyclingMode().getSetting('bikeType');
|
|
71
|
-
res = yield this.bike.programUpload(bikeType, route);
|
|
72
|
-
if (!res)
|
|
73
|
-
return false;
|
|
74
|
-
res = yield this.bike.startProgram(route.programId);
|
|
75
|
-
if (!res)
|
|
76
|
-
return false;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
65
|
start(props) {
|
|
80
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
67
|
this.logger.logEvent({ message: 'start()' });
|
|
@@ -99,18 +85,16 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
99
85
|
if (!info.version) {
|
|
100
86
|
info.version = yield this.bike.getProtocolVersion();
|
|
101
87
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
88
|
+
if (this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
89
|
+
const bikeType = this.getCyclingMode().getSetting('bikeType');
|
|
90
|
+
if (!info.upload)
|
|
91
|
+
info.upload = yield this.bike.programUpload(bikeType, route, props.onStatusUpdate);
|
|
92
|
+
if (!info.started)
|
|
93
|
+
info.started = yield this.bike.startProgram(route.programId);
|
|
104
94
|
}
|
|
105
|
-
|
|
106
|
-
info.init = true;
|
|
107
|
-
}
|
|
108
|
-
if (!info.person && this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
95
|
+
if (!info.person && this.getCyclingMode().getModeProperty('setPersonSupport')) {
|
|
109
96
|
info.person = yield this.bike.setPerson(user);
|
|
110
97
|
}
|
|
111
|
-
else {
|
|
112
|
-
info.person = true;
|
|
113
|
-
}
|
|
114
98
|
if (!this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
115
99
|
const gear = yield this.bike.setGear(this.daumRunData.gear || (opts.gear || 10));
|
|
116
100
|
return gear;
|
|
@@ -121,7 +105,7 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
121
105
|
console.error(err);
|
|
122
106
|
throw (new Error(`could not start device, reason:${err.message}`));
|
|
123
107
|
}
|
|
124
|
-
}), 5,
|
|
108
|
+
}), 5, 1500)
|
|
125
109
|
.then(data => {
|
|
126
110
|
this.startUpdatePull();
|
|
127
111
|
return data;
|
|
@@ -4,6 +4,7 @@ import { Queue } from '../../utils';
|
|
|
4
4
|
import { EventLogger } from 'gd-eventlog';
|
|
5
5
|
import { User } from "../../types/user";
|
|
6
6
|
import { Route } from "../../types/route";
|
|
7
|
+
import { OnDeviceStartCallback } from "../../Device";
|
|
7
8
|
declare class Daum8i {
|
|
8
9
|
portName: string;
|
|
9
10
|
logger: EventLogger;
|
|
@@ -98,7 +99,7 @@ declare class Daum8i {
|
|
|
98
99
|
programUploadStart(bikeType: BikeType, route: Route): Promise<Uint8Array>;
|
|
99
100
|
programUploadSendBlock(epp: Uint8Array, offset: number): Promise<boolean>;
|
|
100
101
|
programUploadDone(): Promise<boolean>;
|
|
101
|
-
programUpload(bikeType: BikeType, route: Route): Promise<boolean>;
|
|
102
|
+
programUpload(bikeType: BikeType, route: Route, onStatusUpdate?: OnDeviceStartCallback): Promise<boolean>;
|
|
102
103
|
startProgram(programId?: number): Promise<boolean>;
|
|
103
104
|
setGear(gear: any): Promise<number>;
|
|
104
105
|
getGear(): Promise<number>;
|
package/lib/daum/premium/bike.js
CHANGED
|
@@ -799,17 +799,21 @@ class Daum8i {
|
|
|
799
799
|
;
|
|
800
800
|
});
|
|
801
801
|
}
|
|
802
|
-
programUpload(bikeType, route) {
|
|
802
|
+
programUpload(bikeType, route, onStatusUpdate) {
|
|
803
803
|
return __awaiter(this, void 0, void 0, function* () {
|
|
804
804
|
yield this.programUploadInit();
|
|
805
805
|
const epp = yield this.programUploadStart(bikeType, route);
|
|
806
806
|
let success = true;
|
|
807
807
|
let done = false;
|
|
808
808
|
let offset = 0;
|
|
809
|
+
if (onStatusUpdate)
|
|
810
|
+
onStatusUpdate(0, epp.length);
|
|
809
811
|
while (success && !done) {
|
|
810
812
|
success = yield this.programUploadSendBlock(epp, offset);
|
|
811
813
|
offset += MAX_DATA_BLOCK_SIZE;
|
|
812
814
|
done = offset >= epp.length;
|
|
815
|
+
if (onStatusUpdate)
|
|
816
|
+
onStatusUpdate(done ? epp.length : offset, epp.length);
|
|
813
817
|
}
|
|
814
818
|
if (done) {
|
|
815
819
|
return yield this.programUploadDone();
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getPersonData = exports.parseTrainingData = exports.routeToEpp = exports.getBikeType = exports.BikeType = exports.ReservedCommands = exports.Int32ToIntArray = exports.Int16ToIntArray = exports.Float32ToIntArray = exports.Float32ToHex = exports.getAsciiArrayFromStr = exports.asciiArrayToString = exports.charArrayToString = exports.ascii = exports.append = exports.getHex = exports.hexstr = exports.getMessageData = exports.buildMessage = exports.checkSum = exports.esc2bin = exports.bin2esc = void 0;
|
|
7
7
|
const user_1 = require("../../types/user");
|
|
8
|
-
const utils_1 = require("../classic/utils");
|
|
9
8
|
const win32filetime_1 = __importDefault(require("win32filetime"));
|
|
10
9
|
const sum = (arr) => arr.reduce((a, b) => a + b, 0);
|
|
11
10
|
function bin2esc(arr) {
|
|
@@ -360,15 +359,15 @@ function getPersonData(user) {
|
|
|
360
359
|
}
|
|
361
360
|
buffer.writeInt32LE(user.sex === user_1.Gender.FEMALE ? 2 : 1, offset);
|
|
362
361
|
offset += 4;
|
|
363
|
-
buffer.writeInt32LE(user.age !== undefined ? user.age :
|
|
362
|
+
buffer.writeInt32LE(user.age !== undefined ? user.age : 1, offset);
|
|
364
363
|
offset += 4;
|
|
365
|
-
buffer.writeInt32LE(user.length !== undefined ? user.length :
|
|
364
|
+
buffer.writeInt32LE(user.length !== undefined ? user.length : 175, offset);
|
|
366
365
|
offset += 4;
|
|
367
|
-
buffer.writeFloatLE(user.weight !== undefined ? user.weight :
|
|
366
|
+
buffer.writeFloatLE(user.weight !== undefined ? user.weight : 70, offset);
|
|
368
367
|
offset += 4;
|
|
369
368
|
buffer.writeFloatLE(0, offset);
|
|
370
369
|
offset += 4;
|
|
371
|
-
buffer.writeUInt32LE(
|
|
370
|
+
buffer.writeUInt32LE(1, offset);
|
|
372
371
|
offset += 4;
|
|
373
372
|
return buffer;
|
|
374
373
|
}
|