incyclist-devices 1.5.12 → 1.5.14
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/pwr.js +1 -0
- package/lib/ble/tacx.js +3 -1
- package/lib/ble/wahoo-kickr.js +3 -1
- package/lib/daum/DaumAdapter.d.ts +1 -0
- package/lib/daum/DaumAdapter.js +9 -0
- package/lib/daum/classic/DaumClassicAdapter.d.ts +5 -0
- package/lib/daum/classic/DaumClassicAdapter.js +56 -50
- package/package.json +1 -1
package/lib/ble/pwr.js
CHANGED
package/lib/ble/tacx.js
CHANGED
|
@@ -229,9 +229,11 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
229
229
|
if (flags & 0x1)
|
|
230
230
|
data.readUInt8(offset++);
|
|
231
231
|
if (flags & 0x4) {
|
|
232
|
-
data.readUInt16LE(offset);
|
|
233
232
|
offset += 2;
|
|
234
233
|
}
|
|
234
|
+
if (flags & 0x10) {
|
|
235
|
+
offset += 6;
|
|
236
|
+
}
|
|
235
237
|
if (flags & 0x20) {
|
|
236
238
|
const crankData = {
|
|
237
239
|
revolutions: data.readUInt16LE(offset),
|
package/lib/ble/wahoo-kickr.js
CHANGED
|
@@ -150,9 +150,11 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
150
150
|
if (flags & 0x1)
|
|
151
151
|
data.readUInt8(offset++);
|
|
152
152
|
if (flags & 0x4) {
|
|
153
|
-
data.readUInt16LE(offset);
|
|
154
153
|
offset += 2;
|
|
155
154
|
}
|
|
155
|
+
if (flags & 0x10) {
|
|
156
|
+
offset += 6;
|
|
157
|
+
}
|
|
156
158
|
if (flags & 0x20) {
|
|
157
159
|
const crankData = {
|
|
158
160
|
revolutions: data.readUInt16LE(offset),
|
package/lib/daum/DaumAdapter.js
CHANGED
|
@@ -165,6 +165,15 @@ class DaumAdapterBase extends device_1.default {
|
|
|
165
165
|
start(props) {
|
|
166
166
|
throw new Error('Method not implemented.');
|
|
167
167
|
}
|
|
168
|
+
stopUpdatePull() {
|
|
169
|
+
if (!this.iv)
|
|
170
|
+
return;
|
|
171
|
+
if (this.iv.sync)
|
|
172
|
+
clearInterval(this.iv.sync);
|
|
173
|
+
if (this.iv.update)
|
|
174
|
+
clearInterval(this.iv.update);
|
|
175
|
+
this.iv = undefined;
|
|
176
|
+
}
|
|
168
177
|
startUpdatePull() {
|
|
169
178
|
if (this.iv)
|
|
170
179
|
return;
|
|
@@ -18,5 +18,10 @@ export default class DaumClassicAdapter extends DaumAdapter {
|
|
|
18
18
|
relaunch(props: any): Promise<unknown>;
|
|
19
19
|
start(props: any): Promise<unknown>;
|
|
20
20
|
launch(props: any, isRelaunch?: boolean): Promise<unknown>;
|
|
21
|
+
startRide(props?: {
|
|
22
|
+
user?: any;
|
|
23
|
+
bikeSettings?: any;
|
|
24
|
+
gear?: any;
|
|
25
|
+
}): Promise<unknown>;
|
|
21
26
|
getCurrentBikeData(): any;
|
|
22
27
|
}
|
|
@@ -114,59 +114,10 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
114
114
|
}
|
|
115
115
|
launch(props, isRelaunch = false) {
|
|
116
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
const opts = props || {};
|
|
118
|
-
const { user, bikeSettings } = opts;
|
|
119
|
-
if (user && user.weight)
|
|
120
|
-
this.userSettings.weight = user.weight;
|
|
121
|
-
if (bikeSettings && bikeSettings.weight)
|
|
122
|
-
this.bikeSettings.weight = bikeSettings.weight;
|
|
123
|
-
this.initData();
|
|
124
117
|
if (isRelaunch) {
|
|
125
118
|
yield this.stop();
|
|
126
119
|
}
|
|
127
|
-
|
|
128
|
-
return (0, utils_1.runWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
try {
|
|
130
|
-
if (!this.bike.isConnected())
|
|
131
|
-
yield this.bike.saveConnect();
|
|
132
|
-
yield this.getBike().resetDevice();
|
|
133
|
-
if (!startState.setProg) {
|
|
134
|
-
yield this.getBike().setProg(0);
|
|
135
|
-
startState.setProg = true;
|
|
136
|
-
}
|
|
137
|
-
if (!startState.setPerson) {
|
|
138
|
-
yield this.getBike().setPerson(user);
|
|
139
|
-
startState.setPerson = true;
|
|
140
|
-
}
|
|
141
|
-
if (!startState.setBikeType) {
|
|
142
|
-
const bikeType = this.getCyclingMode().getSetting('bikeType') || 'race';
|
|
143
|
-
yield this.getBike().setBikeType(bikeType.toLowerCase());
|
|
144
|
-
startState.setBikeType = true;
|
|
145
|
-
}
|
|
146
|
-
if (!startState.startProg) {
|
|
147
|
-
yield this.getBike().startProg();
|
|
148
|
-
startState.startProg = true;
|
|
149
|
-
}
|
|
150
|
-
if (!startState.setGear) {
|
|
151
|
-
yield this.bike.setGear(this.cyclingData.gear || (opts.gear || 10));
|
|
152
|
-
startState.setGear = true;
|
|
153
|
-
}
|
|
154
|
-
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
155
|
-
yield this.sendRequest(startRequest);
|
|
156
|
-
startState.checkRunData = true;
|
|
157
|
-
const data = yield this.bike.runData();
|
|
158
|
-
if (startRequest.targetPower && startRequest.targetPower !== 25 && data.power === 25) {
|
|
159
|
-
throw new Error('invalid device response: runData');
|
|
160
|
-
}
|
|
161
|
-
return data;
|
|
162
|
-
}
|
|
163
|
-
catch (err) {
|
|
164
|
-
if (startState.checkRunData) {
|
|
165
|
-
startState = {};
|
|
166
|
-
}
|
|
167
|
-
throw (new Error(`could not start device, reason:${err.message}`));
|
|
168
|
-
}
|
|
169
|
-
}), 5, 1000)
|
|
120
|
+
return this.startRide(props)
|
|
170
121
|
.then(data => {
|
|
171
122
|
this.stopped = false;
|
|
172
123
|
this.paused = false;
|
|
@@ -175,6 +126,61 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
175
126
|
});
|
|
176
127
|
});
|
|
177
128
|
}
|
|
129
|
+
startRide(props = {}) {
|
|
130
|
+
this.stopUpdatePull();
|
|
131
|
+
const { user, bikeSettings } = props;
|
|
132
|
+
if (user && user.weight)
|
|
133
|
+
this.userSettings.weight = user.weight;
|
|
134
|
+
if (bikeSettings && bikeSettings.weight)
|
|
135
|
+
this.bikeSettings.weight = bikeSettings.weight;
|
|
136
|
+
this.initData();
|
|
137
|
+
let startState = {};
|
|
138
|
+
return (0, utils_1.runWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
try {
|
|
140
|
+
if (!this.bike.isConnected())
|
|
141
|
+
yield this.bike.saveConnect();
|
|
142
|
+
yield this.getBike().resetDevice();
|
|
143
|
+
if (!startState.setProg) {
|
|
144
|
+
yield this.getBike().setProg(0);
|
|
145
|
+
startState.setProg = true;
|
|
146
|
+
}
|
|
147
|
+
if (!startState.setPerson) {
|
|
148
|
+
yield this.getBike().setPerson(user);
|
|
149
|
+
startState.setPerson = true;
|
|
150
|
+
}
|
|
151
|
+
if (!startState.setBikeType) {
|
|
152
|
+
const bikeType = this.getCyclingMode().getSetting('bikeType') || 'race';
|
|
153
|
+
yield this.getBike().setBikeType(bikeType.toLowerCase());
|
|
154
|
+
startState.setBikeType = true;
|
|
155
|
+
}
|
|
156
|
+
if (!startState.startProg) {
|
|
157
|
+
yield this.getBike().startProg();
|
|
158
|
+
startState.startProg = true;
|
|
159
|
+
}
|
|
160
|
+
if (!startState.setGear) {
|
|
161
|
+
yield this.bike.setGear(this.cyclingData.gear || (props.gear || 10));
|
|
162
|
+
startState.setGear = true;
|
|
163
|
+
}
|
|
164
|
+
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
165
|
+
yield this.sendRequest(startRequest);
|
|
166
|
+
startState.checkRunData = true;
|
|
167
|
+
const data = yield this.bike.runData();
|
|
168
|
+
if (startRequest.targetPower && startRequest.targetPower !== 25 && data.power === 25) {
|
|
169
|
+
throw new Error('invalid device response: runData');
|
|
170
|
+
}
|
|
171
|
+
this.stopped = false;
|
|
172
|
+
this.paused = false;
|
|
173
|
+
this.startUpdatePull();
|
|
174
|
+
return data;
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
if (startState.checkRunData) {
|
|
178
|
+
startState = {};
|
|
179
|
+
}
|
|
180
|
+
throw (new Error(`could not start device, reason:${err.message}`));
|
|
181
|
+
}
|
|
182
|
+
}), 5, 1000);
|
|
183
|
+
}
|
|
178
184
|
getCurrentBikeData() {
|
|
179
185
|
return this.getBike().runData();
|
|
180
186
|
}
|