incyclist-devices 1.4.73 → 1.4.74
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/tacx.d.ts +8 -1
- package/lib/ble/tacx.js +57 -29
- package/package.json +1 -1
package/lib/ble/tacx.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ interface BleFeBikeData extends IndoorBikeData {
|
|
|
13
13
|
AccumulatedPower?: number;
|
|
14
14
|
TrainerStatus?: number;
|
|
15
15
|
TargetStatus?: 'OnTarget' | 'LowSpeed' | 'HighSpeed';
|
|
16
|
+
HwVersion?: number;
|
|
17
|
+
ManId?: number;
|
|
18
|
+
ModelNum?: number;
|
|
19
|
+
SwVersion?: number;
|
|
20
|
+
SerialNumber?: number;
|
|
16
21
|
}
|
|
17
22
|
declare type CrankData = {
|
|
18
23
|
revolutions?: number;
|
|
@@ -37,6 +42,7 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
|
|
|
37
42
|
isBike(): boolean;
|
|
38
43
|
isPower(): boolean;
|
|
39
44
|
isHrm(): boolean;
|
|
45
|
+
requestControl(): Promise<boolean>;
|
|
40
46
|
parseCrankData(crankData: any): {
|
|
41
47
|
rpm: number;
|
|
42
48
|
time: any;
|
|
@@ -46,8 +52,9 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
|
|
|
46
52
|
parseFEState(capStateBF: number): void;
|
|
47
53
|
parseGeneralFE(data: Buffer): BleFeBikeData;
|
|
48
54
|
parseTrainerData(data: Buffer): BleFeBikeData;
|
|
55
|
+
parseProductInformation(data: Buffer): BleFeBikeData;
|
|
49
56
|
parseFECMessage(_data: Buffer): BleFeBikeData;
|
|
50
|
-
onData(characteristic: string, data: Buffer):
|
|
57
|
+
onData(characteristic: string, data: Buffer): any;
|
|
51
58
|
getChecksum(message: any[]): number;
|
|
52
59
|
buildMessage(payload?: number[], msgID?: number): Buffer;
|
|
53
60
|
sendMessage(message: Buffer): Promise<boolean>;
|
package/lib/ble/tacx.js
CHANGED
|
@@ -114,6 +114,11 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
114
114
|
isHrm() {
|
|
115
115
|
return this.hasService('180d');
|
|
116
116
|
}
|
|
117
|
+
requestControl() {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
return true;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
117
122
|
parseCrankData(crankData) {
|
|
118
123
|
if (!this.prevCrankData)
|
|
119
124
|
this.prevCrankData = { revolutions: 0, time: 0, cntUpdateMissing: -1 };
|
|
@@ -346,8 +351,22 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
346
351
|
this.parseFEState(flagStateBF);
|
|
347
352
|
return this.data;
|
|
348
353
|
}
|
|
354
|
+
parseProductInformation(data) {
|
|
355
|
+
const swRevSup = data.readUInt8(2);
|
|
356
|
+
const swRevMain = data.readUInt8(3);
|
|
357
|
+
const serial = data.readInt32LE(4);
|
|
358
|
+
this.data.SwVersion = swRevMain;
|
|
359
|
+
if (swRevSup !== 0xFF) {
|
|
360
|
+
this.data.SwVersion += swRevSup / 1000;
|
|
361
|
+
}
|
|
362
|
+
if (serial !== 0xFFFFFFFF) {
|
|
363
|
+
this.data.SerialNumber = serial;
|
|
364
|
+
}
|
|
365
|
+
return this.data;
|
|
366
|
+
}
|
|
349
367
|
parseFECMessage(_data) {
|
|
350
368
|
const data = Buffer.from(_data);
|
|
369
|
+
this.logEvent({ message: 'FE-C message', data: data.toString('hex') });
|
|
351
370
|
const c = data.readUInt8(0);
|
|
352
371
|
if (c !== SYNC_BYTE) {
|
|
353
372
|
this.logEvent({ message: 'SYNC missing', raw: data.toString('hex') });
|
|
@@ -359,45 +378,54 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
359
378
|
let res;
|
|
360
379
|
switch (messageId) {
|
|
361
380
|
case ANTMessages.generalFE:
|
|
362
|
-
res = this.parseGeneralFE(data.slice(4, len +
|
|
381
|
+
res = this.parseGeneralFE(data.slice(4, len + 3));
|
|
363
382
|
break;
|
|
364
383
|
case ANTMessages.trainerData:
|
|
365
|
-
res = this.parseTrainerData(data.slice(4, len +
|
|
384
|
+
res = this.parseTrainerData(data.slice(4, len + 3));
|
|
385
|
+
break;
|
|
386
|
+
case ANTMessages.productInformation:
|
|
387
|
+
res = this.parseProductInformation(data.slice(4, len + 3));
|
|
366
388
|
break;
|
|
367
389
|
}
|
|
368
390
|
res.raw = data.toString('hex');
|
|
369
391
|
return res;
|
|
370
392
|
}
|
|
371
393
|
onData(characteristic, data) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
try {
|
|
395
|
+
super.onData(characteristic, data);
|
|
396
|
+
const uuid = characteristic.toLocaleLowerCase();
|
|
397
|
+
let res = undefined;
|
|
398
|
+
if (uuid && uuid.startsWith(TACX_FE_C_RX)) {
|
|
399
|
+
res = this.parseFECMessage(data);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
switch (uuid) {
|
|
403
|
+
case '2a63':
|
|
404
|
+
if (!this.hasFECData)
|
|
405
|
+
res = this.parsePower(data);
|
|
406
|
+
break;
|
|
407
|
+
case '2ad2':
|
|
408
|
+
if (!this.hasFECData)
|
|
409
|
+
res = this.parseIndoorBikeData(data);
|
|
410
|
+
break;
|
|
411
|
+
case '2a37':
|
|
412
|
+
res = this.parseHrm(data);
|
|
413
|
+
break;
|
|
414
|
+
case '2ada':
|
|
415
|
+
if (!this.hasFECData)
|
|
416
|
+
res = this.parseFitnessMachineStatus(data);
|
|
417
|
+
break;
|
|
418
|
+
default:
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
397
421
|
}
|
|
422
|
+
if (res)
|
|
423
|
+
this.emit('data', res);
|
|
424
|
+
return res;
|
|
425
|
+
}
|
|
426
|
+
catch (err) {
|
|
427
|
+
this.logEvent({ message: 'error', fn: 'tacx.onData()', error: err.message || err, stack: err.stack });
|
|
398
428
|
}
|
|
399
|
-
if (res)
|
|
400
|
-
this.emit('data', res);
|
|
401
429
|
}
|
|
402
430
|
getChecksum(message) {
|
|
403
431
|
let checksum = 0;
|