incyclist-devices 2.3.12 → 2.3.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/adapter-factory.d.ts +34 -0
- package/lib/ble/adapter-factory.js +110 -0
- package/lib/ble/base/comms-utils.d.ts +7 -0
- package/lib/ble/base/comms-utils.js +90 -0
- package/lib/ble/base/comms.d.ts +75 -0
- package/lib/ble/base/comms.js +599 -0
- package/lib/ble/ble-interface.d.ts +84 -0
- package/lib/ble/ble-interface.js +622 -0
- package/lib/ble/ble-peripheral.d.ts +39 -0
- package/lib/ble/ble-peripheral.js +252 -0
- package/lib/ble/cp/comm.d.ts +30 -0
- package/lib/ble/cp/comm.js +126 -0
- package/lib/ble/elite/adapter.d.ts +21 -0
- package/lib/ble/elite/adapter.js +118 -0
- package/lib/ble/elite/comms.d.ts +31 -0
- package/lib/ble/elite/comms.js +127 -0
- package/lib/ble/elite/index.d.ts +3 -0
- package/lib/ble/elite/index.js +10 -0
- package/lib/ble/fm/comms.d.ts +49 -0
- package/lib/ble/fm/comms.js +506 -0
- package/lib/ble/fm/sensor.js +3 -3
- package/lib/ble/hr/comm.d.ts +19 -0
- package/lib/ble/hr/comm.js +65 -0
- package/lib/ble/peripheral-cache.d.ts +45 -0
- package/lib/ble/peripheral-cache.js +109 -0
- package/lib/ble/tacx/comms.d.ts +59 -0
- package/lib/ble/tacx/comms.js +634 -0
- package/lib/ble/wahoo/comms.d.ts +64 -0
- package/lib/ble/wahoo/comms.js +399 -0
- package/lib/direct-connect/base/comms.d.ts +3 -0
- package/lib/direct-connect/base/comms.js +7 -0
- package/lib/direct-connect/base/sensor.d.ts +3 -0
- package/lib/direct-connect/base/sensor.js +7 -0
- package/lib/direct-connect/utils.d.ts +5 -0
- package/lib/direct-connect/utils.js +73 -0
- package/lib/factories/index.d.ts +3 -0
- package/lib/factories/index.js +10 -0
- package/lib/modes/power-base.js +8 -5
- package/lib/utils/operation.d.ts +17 -0
- package/lib/utils/operation.js +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _1 = require(".");
|
|
4
|
+
const comms_1 = require("../base/comms");
|
|
5
|
+
const consts_1 = require("../consts");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
class BleEliteDevice extends comms_1.BleComms {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.instantaneousPower = undefined;
|
|
11
|
+
this.balance = undefined;
|
|
12
|
+
this.accTorque = undefined;
|
|
13
|
+
this.rpm = undefined;
|
|
14
|
+
this.timeOffset = 0;
|
|
15
|
+
this.time = undefined;
|
|
16
|
+
this.currentCrankData = undefined;
|
|
17
|
+
this.prevCrankData = undefined;
|
|
18
|
+
}
|
|
19
|
+
static isMatching(characteristics) {
|
|
20
|
+
if (!characteristics)
|
|
21
|
+
return false;
|
|
22
|
+
const announced = characteristics.map(c => (0, utils_1.uuid)(c));
|
|
23
|
+
const hasCPMeasurement = announced.find(c => c === consts_1.CSP_MEASUREMENT) !== undefined;
|
|
24
|
+
const hasCPFeature = announced.find(c => c === consts_1.CSP_FEATURE) !== undefined;
|
|
25
|
+
return hasCPMeasurement && hasCPFeature;
|
|
26
|
+
}
|
|
27
|
+
getProfile() {
|
|
28
|
+
return 'Power Meter';
|
|
29
|
+
}
|
|
30
|
+
getProtocol() {
|
|
31
|
+
return _1.BleEliteComms.protocol;
|
|
32
|
+
}
|
|
33
|
+
getServiceUUids() {
|
|
34
|
+
return BleEliteDevice.services;
|
|
35
|
+
}
|
|
36
|
+
parseCrankData(crankData) {
|
|
37
|
+
if (!this.prevCrankData)
|
|
38
|
+
this.prevCrankData = { revolutions: 0, time: 0, cntUpdateMissing: -1 };
|
|
39
|
+
const c = this.currentCrankData = crankData;
|
|
40
|
+
const p = this.prevCrankData;
|
|
41
|
+
let rpm = this.rpm;
|
|
42
|
+
let hasUpdate = c.time !== p.time;
|
|
43
|
+
if (hasUpdate) {
|
|
44
|
+
let time = c.time - p.time;
|
|
45
|
+
let revs = c.revolutions - p.revolutions;
|
|
46
|
+
if (c.time < p.time) {
|
|
47
|
+
time += 0x10000;
|
|
48
|
+
this.timeOffset += 0x10000;
|
|
49
|
+
}
|
|
50
|
+
if (c.revolutions < p.revolutions)
|
|
51
|
+
revs += 0x10000;
|
|
52
|
+
rpm = 1024 * 60 * revs / time;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if (p.cntUpdateMissing < 0 || p.cntUpdateMissing > 2) {
|
|
56
|
+
rpm = 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const cntUpdateMissing = p.cntUpdateMissing;
|
|
60
|
+
this.prevCrankData = this.currentCrankData;
|
|
61
|
+
if (hasUpdate)
|
|
62
|
+
this.prevCrankData.cntUpdateMissing = 0;
|
|
63
|
+
else
|
|
64
|
+
this.prevCrankData.cntUpdateMissing = cntUpdateMissing + 1;
|
|
65
|
+
return { rpm, time: this.timeOffset + c.time };
|
|
66
|
+
}
|
|
67
|
+
parsePower(_data) {
|
|
68
|
+
const data = Buffer.from(_data);
|
|
69
|
+
try {
|
|
70
|
+
let offset = 4;
|
|
71
|
+
const flags = data.readUInt16LE(0);
|
|
72
|
+
this.instantaneousPower = data.readUInt16LE(2);
|
|
73
|
+
if (flags & 0x1)
|
|
74
|
+
this.balance = data.readUInt8(offset++);
|
|
75
|
+
if (flags & 0x4) {
|
|
76
|
+
this.accTorque = data.readUInt16LE(offset);
|
|
77
|
+
offset += 2;
|
|
78
|
+
}
|
|
79
|
+
if (flags & 0x10) {
|
|
80
|
+
}
|
|
81
|
+
if (flags & 0x20) {
|
|
82
|
+
const crankData = {
|
|
83
|
+
revolutions: data.readUInt16LE(offset),
|
|
84
|
+
time: data.readUInt16LE(offset + 2)
|
|
85
|
+
};
|
|
86
|
+
const { rpm, time } = this.parseCrankData(crankData);
|
|
87
|
+
this.rpm = rpm;
|
|
88
|
+
this.time = time;
|
|
89
|
+
offset += 4;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
}
|
|
94
|
+
const { instantaneousPower, balance, accTorque, rpm, time } = this;
|
|
95
|
+
return { instantaneousPower, balance, accTorque, rpm, time, raw: `2a63:${data.toString('hex')}` };
|
|
96
|
+
}
|
|
97
|
+
onData(characteristic, data) {
|
|
98
|
+
const hasData = super.onData(characteristic, data);
|
|
99
|
+
if (!hasData)
|
|
100
|
+
return false;
|
|
101
|
+
if ((0, utils_1.matches)(characteristic, consts_1.CSP_MEASUREMENT)) {
|
|
102
|
+
const res = this.parsePower(data);
|
|
103
|
+
this.emit('data', res);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
subscribeAll(conn) {
|
|
109
|
+
const characteristics = [consts_1.CSP_MEASUREMENT];
|
|
110
|
+
return this.subscribeMultiple(characteristics, conn);
|
|
111
|
+
}
|
|
112
|
+
reset() {
|
|
113
|
+
this.instantaneousPower = undefined;
|
|
114
|
+
this.balance = undefined;
|
|
115
|
+
this.accTorque = undefined;
|
|
116
|
+
this.rpm = undefined;
|
|
117
|
+
this.timeOffset = 0;
|
|
118
|
+
this.time = undefined;
|
|
119
|
+
this.currentCrankData = undefined;
|
|
120
|
+
this.prevCrankData = undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
BleEliteDevice.protocol = 'elite';
|
|
124
|
+
BleEliteDevice.services = [consts_1.ELITE_TRAINER_SVC];
|
|
125
|
+
BleEliteDevice.characteristics = [consts_1.CSP_MEASUREMENT, consts_1.CSP_FEATURE, '2a5d', '2a3c'];
|
|
126
|
+
BleEliteDevice.detectionPriority = 10;
|
|
127
|
+
exports.default = BleEliteDevice;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BleEliteComms = exports.BleEliteAdapter = void 0;
|
|
7
|
+
const adapter_1 = __importDefault(require("./adapter"));
|
|
8
|
+
exports.BleEliteAdapter = adapter_1.default;
|
|
9
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
10
|
+
exports.BleEliteComms = comms_1.default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BleProtocol, BleWriteProps, IBlePeripheralConnector } from "../types";
|
|
2
|
+
import { IndoorBikeData, IndoorBikeFeatures } from "./types";
|
|
3
|
+
import { BleComms } from "../base/comms";
|
|
4
|
+
import { LegacyProfile } from "../../antv2/types";
|
|
5
|
+
export default class BleFitnessMachineDevice extends BleComms {
|
|
6
|
+
static protocol: BleProtocol;
|
|
7
|
+
static services: string[];
|
|
8
|
+
static characteristics: string[];
|
|
9
|
+
static detectionPriority: number;
|
|
10
|
+
data: IndoorBikeData;
|
|
11
|
+
features: IndoorBikeFeatures;
|
|
12
|
+
hasControl: boolean;
|
|
13
|
+
isCheckingControl: boolean;
|
|
14
|
+
isCPSubscribed: boolean;
|
|
15
|
+
crr: number;
|
|
16
|
+
cw: number;
|
|
17
|
+
windSpeed: number;
|
|
18
|
+
wheelSize: number;
|
|
19
|
+
constructor(props?: any);
|
|
20
|
+
static isMatching(characteristics: string[]): boolean;
|
|
21
|
+
subscribeWriteResponse(cuuid: string): Promise<void>;
|
|
22
|
+
subscribeAll(conn?: IBlePeripheralConnector): Promise<void>;
|
|
23
|
+
init(): Promise<boolean>;
|
|
24
|
+
onDisconnect(): Promise<void>;
|
|
25
|
+
getProfile(): LegacyProfile;
|
|
26
|
+
getProtocol(): BleProtocol;
|
|
27
|
+
getServiceUUids(): string[];
|
|
28
|
+
parseHrm(_data: Uint8Array): IndoorBikeData;
|
|
29
|
+
setCrr(crr: number): void;
|
|
30
|
+
getCrr(): number;
|
|
31
|
+
setCw(cw: number): void;
|
|
32
|
+
getCw(): number;
|
|
33
|
+
setWindSpeed(windSpeed: number): void;
|
|
34
|
+
getWindSpeed(): number;
|
|
35
|
+
parseIndoorBikeData(_data: Uint8Array): IndoorBikeData;
|
|
36
|
+
parseFitnessMachineStatus(_data: Uint8Array): IndoorBikeData;
|
|
37
|
+
getFitnessMachineFeatures(): Promise<IndoorBikeFeatures | undefined>;
|
|
38
|
+
onData(characteristic: string, data: Buffer): boolean;
|
|
39
|
+
writeFtmsMessage(requestedOpCode: any, data: any, props?: BleWriteProps): Promise<number>;
|
|
40
|
+
requestControl(): Promise<boolean>;
|
|
41
|
+
setTargetPower(power: number): Promise<boolean>;
|
|
42
|
+
setSlope(slope: any): Promise<boolean>;
|
|
43
|
+
setTargetInclination(inclination: number): Promise<boolean>;
|
|
44
|
+
setIndoorBikeSimulation(windSpeed: number, gradient: number, crr: number, cw: number): Promise<boolean>;
|
|
45
|
+
startRequest(): Promise<boolean>;
|
|
46
|
+
stopRequest(): Promise<boolean>;
|
|
47
|
+
PauseRequest(): Promise<boolean>;
|
|
48
|
+
reset(): void;
|
|
49
|
+
}
|