incyclist-devices 2.3.15-beta.1 → 2.3.16
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.
|
@@ -391,7 +391,6 @@ class BleInterface extends events_1.default {
|
|
|
391
391
|
if (announcement.name.includes('KICKR')) {
|
|
392
392
|
const supported = announcement.serviceUUIDs.map(s => (0, utils_1.beautifyUUID)(s));
|
|
393
393
|
if (supported.length === 1 && (supported[0] === '1818' || supported[0] === 'FC82')) {
|
|
394
|
-
this.logEvent({ message: 'wahoo enhancement detected', name: announcement.name, supported });
|
|
395
394
|
return true;
|
|
396
395
|
}
|
|
397
396
|
}
|
|
@@ -533,7 +532,6 @@ class BleInterface extends events_1.default {
|
|
|
533
532
|
}
|
|
534
533
|
addService(service) {
|
|
535
534
|
try {
|
|
536
|
-
this.logEvent({ message: 'ble peripheral announced', service });
|
|
537
535
|
const isSuported = this.isSupportedPeripheral(service);
|
|
538
536
|
if (!isSuported) {
|
|
539
537
|
return;
|
package/lib/ble/fm/sensor.js
CHANGED
|
@@ -217,10 +217,16 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
217
217
|
const OpCode = data.readUInt8(0);
|
|
218
218
|
switch (OpCode) {
|
|
219
219
|
case 8:
|
|
220
|
-
|
|
220
|
+
if (data.length >= 3)
|
|
221
|
+
this.data.targetPower = data.readInt16LE(1);
|
|
222
|
+
else
|
|
223
|
+
this.logEvent({ message: 'warning', fn: 'parseFitnessMachineStatus()', warning: 'invalid message - message too short', data: data.toString('hex') });
|
|
221
224
|
break;
|
|
222
225
|
case 6:
|
|
223
|
-
|
|
226
|
+
if (data.length >= 3)
|
|
227
|
+
this.data.targetInclination = data.readInt16LE(1) / 10;
|
|
228
|
+
else
|
|
229
|
+
this.logEvent({ message: 'warning', fn: 'parseFitnessMachineStatus()', warning: 'invalid message - message too short', data: data.toString('hex') });
|
|
224
230
|
break;
|
|
225
231
|
case 4:
|
|
226
232
|
this.data.status = "STARTED";
|
|
@@ -230,7 +236,7 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
230
236
|
this.data.status = "STOPPED";
|
|
231
237
|
break;
|
|
232
238
|
case 20:
|
|
233
|
-
{
|
|
239
|
+
if (data.length >= 2) {
|
|
234
240
|
const spinDownStatus = data.readUInt8(1);
|
|
235
241
|
switch (spinDownStatus) {
|
|
236
242
|
case 1:
|
|
@@ -248,10 +254,14 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
248
254
|
default: break;
|
|
249
255
|
}
|
|
250
256
|
}
|
|
257
|
+
else {
|
|
258
|
+
this.logEvent({ message: 'warning', fn: 'parseFitnessMachineStatus()', warning: 'invalid message - message too short', data: data.toString('hex') });
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
251
261
|
}
|
|
252
262
|
}
|
|
253
263
|
catch (err) {
|
|
254
|
-
this.logEvent({ message: 'error', fn: 'parseFitnessMachineStatus()', error: err.message
|
|
264
|
+
this.logEvent({ message: 'error', fn: 'parseFitnessMachineStatus()', error: err.message, data: data.toString('hex'), stack: err.stack });
|
|
255
265
|
}
|
|
256
266
|
return Object.assign(Object.assign({}, this.data), { raw: `2ada:${data.toString('hex')}` });
|
|
257
267
|
}
|
|
@@ -238,7 +238,6 @@ class DirectConnectInterface extends events_1.default {
|
|
|
238
238
|
try {
|
|
239
239
|
service.transport = this.getName();
|
|
240
240
|
const existing = this.find(service);
|
|
241
|
-
this.logEvent({ message: 'wifi service announced', device: service.name, announcement: service, source, existing, interface: 'wifi' });
|
|
242
241
|
if (existing) {
|
|
243
242
|
const idx = this.services.indexOf(existing);
|
|
244
243
|
this.services[idx] = { ts: Date.now(), service };
|
|
@@ -52,7 +52,7 @@ export default class DaumAdapter<S extends SerialDeviceSettings, P extends Devic
|
|
|
52
52
|
logEvent(event: any): void;
|
|
53
53
|
stop(): Promise<boolean>;
|
|
54
54
|
sendUpdate(request: any): Promise<UpdateRequest | void>;
|
|
55
|
-
update():
|
|
55
|
+
update(): void;
|
|
56
56
|
sendRequests(): Promise<void>;
|
|
57
57
|
bikeSync(): Promise<void>;
|
|
58
58
|
updateData(bikeData: IncyclistBikeData): IncyclistBikeData;
|
|
@@ -131,13 +131,13 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
131
131
|
const resumed = yield _super.resume.call(this);
|
|
132
132
|
(_a = this.comms) === null || _a === void 0 ? void 0 : _a.resume();
|
|
133
133
|
if (startUpdatePull)
|
|
134
|
-
|
|
134
|
+
this.startUpdatePull();
|
|
135
135
|
return resumed;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
waitForPrevCheckFinished() {
|
|
139
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
if (this.checkPromise) {
|
|
140
|
+
if (this.checkPromise !== undefined && this.checkPromise !== null) {
|
|
141
141
|
this.logEvent({ message: "waiting for previous check device", port: this.getPort() });
|
|
142
142
|
try {
|
|
143
143
|
yield this.checkPromise;
|
|
@@ -173,7 +173,7 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
173
173
|
}
|
|
174
174
|
waitForPrevStartFinished() {
|
|
175
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
if (this.startPromise) {
|
|
176
|
+
if (this.startPromise !== undefined && this.startPromise !== null) {
|
|
177
177
|
this.logEvent({ message: "waiting for previous device launch", port: this.getPort() });
|
|
178
178
|
try {
|
|
179
179
|
yield this.startPromise;
|
|
@@ -239,10 +239,7 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
239
239
|
return;
|
|
240
240
|
this.logEvent({ message: 'start update pull', port: this.getPort() });
|
|
241
241
|
const ivSync = setInterval(() => {
|
|
242
|
-
|
|
243
|
-
this.bikeSync();
|
|
244
|
-
}
|
|
245
|
-
catch (_a) { }
|
|
242
|
+
this.bikeSync().catch();
|
|
246
243
|
}, this.pullFrequency);
|
|
247
244
|
const ivUpdate = setInterval(() => {
|
|
248
245
|
try {
|
|
@@ -273,7 +270,8 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
273
270
|
}
|
|
274
271
|
stopUpdatePull() {
|
|
275
272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
-
|
|
273
|
+
var _a;
|
|
274
|
+
if (!((_a = this.iv) === null || _a === void 0 ? void 0 : _a.emitter))
|
|
277
275
|
return;
|
|
278
276
|
return new Promise(done => {
|
|
279
277
|
this.iv.emitter.on('stop-done', () => {
|
|
@@ -373,26 +371,24 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
373
371
|
});
|
|
374
372
|
}
|
|
375
373
|
update() {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
374
|
+
if (!this.canEmitData() || this.updateBusy)
|
|
375
|
+
return;
|
|
376
|
+
this.updateBusy = true;
|
|
377
|
+
this.getCurrentBikeData()
|
|
378
|
+
.then(bikeData => {
|
|
379
|
+
const incyclistData = this.updateData(bikeData);
|
|
380
|
+
const data = this.transformData(incyclistData);
|
|
381
|
+
this.updateBusy = false;
|
|
382
|
+
this.emitData(data);
|
|
383
|
+
})
|
|
384
|
+
.catch(err => {
|
|
380
385
|
try {
|
|
381
|
-
|
|
382
|
-
const incyclistData = this.updateData(
|
|
383
|
-
|
|
384
|
-
this.updateBusy = false;
|
|
385
|
-
this.emitData(data);
|
|
386
|
-
}
|
|
387
|
-
catch (err) {
|
|
388
|
-
try {
|
|
389
|
-
this.logEvent({ message: 'bike update error', port: this.getPort(), error: err.message, stack: err.stack });
|
|
390
|
-
const incyclistData = this.updateData(this.deviceData);
|
|
391
|
-
this.transformData(incyclistData, false);
|
|
392
|
-
}
|
|
393
|
-
catch (_a) { }
|
|
394
|
-
this.updateBusy = false;
|
|
386
|
+
this.logEvent({ message: 'bike update error', port: this.getPort(), error: err.message, stack: err.stack });
|
|
387
|
+
const incyclistData = this.updateData(this.deviceData);
|
|
388
|
+
this.transformData(incyclistData, false);
|
|
395
389
|
}
|
|
390
|
+
catch (_a) { }
|
|
391
|
+
this.updateBusy = false;
|
|
396
392
|
});
|
|
397
393
|
}
|
|
398
394
|
sendRequests() {
|
|
@@ -428,7 +424,7 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
428
424
|
if (!((_a = this.iv) === null || _a === void 0 ? void 0 : _a.stopRequested))
|
|
429
425
|
yield this.sendRequests();
|
|
430
426
|
if (!((_b = this.iv) === null || _b === void 0 ? void 0 : _b.stopRequested))
|
|
431
|
-
|
|
427
|
+
this.update();
|
|
432
428
|
if ((_c = this.iv) === null || _c === void 0 ? void 0 : _c.stopRequested) {
|
|
433
429
|
this.iv.emitter.emit('stop-done', 'bikeSync');
|
|
434
430
|
}
|
|
@@ -518,12 +514,15 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
518
514
|
if (request.slope !== undefined) {
|
|
519
515
|
this.deviceData.slope = request.slope;
|
|
520
516
|
}
|
|
521
|
-
return new Promise((resolve) =>
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
517
|
+
return new Promise((resolve) => {
|
|
518
|
+
const fn = () => __awaiter(this, void 0, void 0, function* () {
|
|
519
|
+
let bikeRequest = this.getCyclingMode().sendBikeUpdate(request);
|
|
520
|
+
this.logEvent({ message: 'add request', request: bikeRequest });
|
|
521
|
+
this.requests.push(bikeRequest);
|
|
522
|
+
resolve(bikeRequest);
|
|
523
|
+
});
|
|
524
|
+
fn();
|
|
525
|
+
});
|
|
527
526
|
}
|
|
528
527
|
getDeviceInfo() {
|
|
529
528
|
return __awaiter(this, void 0, void 0, function* () {
|