incyclist-devices 2.2.9 → 2.3.0
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/antv2/base/interface.js +2 -2
- package/lib/antv2/factories/index.d.ts +1 -0
- package/lib/antv2/factories/index.js +17 -0
- package/lib/antv2/fe/adapter.js +5 -4
- package/lib/antv2/index.d.ts +1 -0
- package/lib/antv2/index.js +12 -8
- package/lib/base/adpater.js +1 -1
- package/lib/ble/adapter-factory.d.ts +20 -24
- package/lib/ble/adapter-factory.js +13 -36
- package/lib/ble/base/adapter.d.ts +16 -5
- package/lib/ble/base/adapter.js +169 -52
- package/lib/ble/base/comms.d.ts +2 -74
- package/lib/ble/base/comms.js +3 -596
- package/lib/ble/base/interface.d.ts +96 -0
- package/lib/ble/base/interface.js +544 -0
- package/lib/ble/base/peripheral.d.ts +34 -0
- package/lib/ble/base/peripheral.js +286 -0
- package/lib/ble/base/sensor.d.ts +31 -0
- package/lib/ble/base/sensor.js +130 -0
- package/lib/ble/base/types.d.ts +7 -0
- package/lib/ble/base/types.js +7 -0
- package/lib/ble/bindings/mock.js +6 -0
- package/lib/ble/bindings/types.d.ts +3 -4
- package/lib/ble/ble-interface.d.ts +7 -4
- package/lib/ble/ble-interface.js +16 -2
- package/lib/ble/ble-peripheral.d.ts +1 -0
- package/lib/ble/ble-peripheral.js +7 -11
- package/lib/ble/consts.d.ts +0 -6
- package/lib/ble/consts.js +1 -7
- package/lib/ble/cp/adapter.d.ts +3 -3
- package/lib/ble/cp/adapter.js +12 -13
- package/lib/ble/cp/comm.d.ts +1 -1
- package/lib/ble/cp/comm.js +2 -2
- package/lib/ble/cp/index.d.ts +1 -1
- package/lib/ble/cp/index.js +2 -2
- package/lib/ble/cp/sensor.d.ts +27 -0
- package/lib/ble/cp/sensor.js +107 -0
- package/lib/ble/elite/comms.d.ts +1 -1
- package/lib/ble/elite/comms.js +2 -2
- package/lib/ble/factories/adapter-factory.d.ts +32 -0
- package/lib/ble/factories/adapter-factory.js +104 -0
- package/lib/ble/factories/index.d.ts +2 -0
- package/lib/ble/factories/index.js +18 -0
- package/lib/ble/factories/interface-factory.d.ts +7 -0
- package/lib/ble/factories/interface-factory.js +18 -0
- package/lib/ble/fm/adapter.d.ts +9 -4
- package/lib/ble/fm/adapter.js +104 -108
- package/lib/ble/fm/comms.d.ts +1 -1
- package/lib/ble/fm/comms.js +3 -3
- package/lib/ble/fm/consts.d.ts +93 -0
- package/lib/ble/fm/consts.js +55 -1
- package/lib/ble/fm/index.d.ts +1 -1
- package/lib/ble/fm/index.js +2 -2
- package/lib/ble/fm/sensor.d.ts +44 -0
- package/lib/ble/fm/sensor.js +384 -0
- package/lib/ble/hr/adapter.d.ts +3 -3
- package/lib/ble/hr/adapter.js +5 -8
- package/lib/ble/hr/comm.d.ts +1 -1
- package/lib/ble/hr/comm.js +2 -2
- package/lib/ble/hr/index.d.ts +1 -1
- package/lib/ble/hr/index.js +2 -2
- package/lib/ble/hr/sensor.d.ts +17 -0
- package/lib/ble/hr/sensor.js +52 -0
- package/lib/ble/index.d.ts +4 -3
- package/lib/ble/index.js +29 -13
- package/lib/ble/tacx/adapter.d.ts +4 -2
- package/lib/ble/tacx/adapter.js +26 -66
- package/lib/ble/tacx/comms.d.ts +1 -1
- package/lib/ble/tacx/comms.js +2 -2
- package/lib/ble/tacx/consts.d.ts +23 -0
- package/lib/ble/tacx/consts.js +27 -0
- package/lib/ble/tacx/index.d.ts +1 -1
- package/lib/ble/tacx/index.js +2 -2
- package/lib/ble/tacx/sensor.d.ts +63 -0
- package/lib/ble/tacx/sensor.js +596 -0
- package/lib/ble/types.d.ts +81 -52
- package/lib/ble/utils.d.ts +7 -2
- package/lib/ble/utils.js +84 -9
- package/lib/ble/wahoo/adapter.d.ts +2 -2
- package/lib/ble/wahoo/adapter.js +4 -72
- package/lib/ble/wahoo/comms.d.ts +1 -1
- package/lib/ble/wahoo/comms.js +2 -2
- package/lib/ble/wahoo/consts.d.ts +16 -0
- package/lib/ble/wahoo/consts.js +7 -0
- package/lib/ble/wahoo/index.d.ts +1 -1
- package/lib/ble/wahoo/index.js +2 -2
- package/lib/ble/wahoo/sensor.d.ts +48 -0
- package/lib/ble/wahoo/sensor.js +356 -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/interface.d.ts +75 -0
- package/lib/direct-connect/base/interface.js +306 -0
- package/lib/direct-connect/base/peripheral.d.ts +50 -0
- package/lib/direct-connect/base/peripheral.js +413 -0
- package/lib/direct-connect/base/sensor.d.ts +3 -0
- package/lib/direct-connect/base/sensor.js +7 -0
- package/lib/direct-connect/bindings/index.d.ts +1 -0
- package/lib/direct-connect/bindings/index.js +17 -0
- package/lib/direct-connect/bindings/types.d.ts +36 -0
- package/lib/direct-connect/bindings/types.js +2 -0
- package/lib/direct-connect/consts.d.ts +17 -0
- package/lib/direct-connect/consts.js +20 -0
- package/lib/direct-connect/index.d.ts +3 -0
- package/lib/direct-connect/index.js +22 -0
- package/lib/direct-connect/messages/CharacteristicNotification.d.ts +12 -0
- package/lib/direct-connect/messages/CharacteristicNotification.js +23 -0
- package/lib/direct-connect/messages/DiscoverCharacteristics.d.ts +22 -0
- package/lib/direct-connect/messages/DiscoverCharacteristics.js +43 -0
- package/lib/direct-connect/messages/DiscoverServices.d.ts +15 -0
- package/lib/direct-connect/messages/DiscoverServices.js +33 -0
- package/lib/direct-connect/messages/EnableCharacteristicNotifications.d.ts +18 -0
- package/lib/direct-connect/messages/EnableCharacteristicNotifications.js +35 -0
- package/lib/direct-connect/messages/ReadCharacteristic.d.ts +18 -0
- package/lib/direct-connect/messages/ReadCharacteristic.js +34 -0
- package/lib/direct-connect/messages/WriteCharacteristic.d.ts +18 -0
- package/lib/direct-connect/messages/WriteCharacteristic.js +36 -0
- package/lib/direct-connect/messages/error.d.ts +5 -0
- package/lib/direct-connect/messages/error.js +18 -0
- package/lib/direct-connect/messages/factory.d.ts +6 -0
- package/lib/direct-connect/messages/factory.js +44 -0
- package/lib/direct-connect/messages/index.d.ts +9 -0
- package/lib/direct-connect/messages/index.js +25 -0
- package/lib/direct-connect/messages/message.d.ts +20 -0
- package/lib/direct-connect/messages/message.js +90 -0
- package/lib/direct-connect/types.d.ts +24 -0
- package/lib/direct-connect/types.js +9 -0
- package/lib/direct-connect/utils.d.ts +5 -0
- package/lib/direct-connect/utils.js +73 -0
- package/lib/factories/adapters.js +16 -4
- package/lib/factories/interfaces.d.ts +2 -1
- package/lib/factories/interfaces.js +10 -7
- package/lib/index.d.ts +5 -4
- package/lib/index.js +6 -2
- package/lib/serial/bindings/tcp.d.ts +5 -4
- package/lib/serial/bindings/tcp.js +16 -23
- package/lib/types/device.d.ts +2 -1
- package/lib/types/device.js +1 -0
- package/lib/utils/operation.d.ts +17 -0
- package/lib/utils/operation.js +20 -0
- package/lib/utils/task.d.ts +44 -0
- package/lib/utils/task.js +127 -0
- package/package.json +3 -1
package/lib/ble/fm/adapter.js
CHANGED
|
@@ -16,33 +16,30 @@ const gd_eventlog_1 = require("gd-eventlog");
|
|
|
16
16
|
const power_meter_1 = __importDefault(require("../../modes/power-meter"));
|
|
17
17
|
const antble_smarttrainer_1 = __importDefault(require("../../modes/antble-smarttrainer"));
|
|
18
18
|
const antble_erg_1 = __importDefault(require("../../modes/antble-erg"));
|
|
19
|
-
const
|
|
19
|
+
const sensor_1 = __importDefault(require("./sensor"));
|
|
20
20
|
const adapter_1 = __importDefault(require("../base/adapter"));
|
|
21
21
|
const consts_1 = require("./consts");
|
|
22
|
-
const utils_1 = require("../../utils/utils");
|
|
23
22
|
const types_1 = require("../../types");
|
|
23
|
+
const task_1 = require("../../utils/task");
|
|
24
24
|
class BleFmAdapter extends adapter_1.default {
|
|
25
25
|
constructor(settings, props) {
|
|
26
26
|
super(settings, props);
|
|
27
27
|
this.distanceInternal = 0;
|
|
28
28
|
this.logger = new gd_eventlog_1.EventLogger('BLE-FM');
|
|
29
|
-
|
|
30
|
-
const logger = this.logger;
|
|
31
|
-
const ble = this.ble;
|
|
32
|
-
this.device = new comms_1.default({ id, address, name, ble, logger });
|
|
29
|
+
this.device = new sensor_1.default(this.getPeripheral(), { logger: this.logger });
|
|
33
30
|
this.capabilities = [
|
|
34
31
|
types_1.IncyclistCapability.Power, types_1.IncyclistCapability.Speed, types_1.IncyclistCapability.Cadence,
|
|
35
32
|
types_1.IncyclistCapability.Control
|
|
36
33
|
];
|
|
37
34
|
}
|
|
35
|
+
updateSensor(peripheral) {
|
|
36
|
+
this.device = new sensor_1.default(peripheral, { logger: this.logger });
|
|
37
|
+
}
|
|
38
38
|
isSame(device) {
|
|
39
39
|
if (!(device instanceof BleFmAdapter))
|
|
40
40
|
return false;
|
|
41
41
|
return this.isEqual(device.settings);
|
|
42
42
|
}
|
|
43
|
-
getName() {
|
|
44
|
-
return `${this.device.name}`;
|
|
45
|
-
}
|
|
46
43
|
isControllable() {
|
|
47
44
|
return true;
|
|
48
45
|
}
|
|
@@ -70,6 +67,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
70
67
|
return new power_meter_1.default(this);
|
|
71
68
|
}
|
|
72
69
|
mapData(deviceData) {
|
|
70
|
+
var _a, _b, _c;
|
|
73
71
|
const data = {
|
|
74
72
|
isPedalling: false,
|
|
75
73
|
power: 0,
|
|
@@ -80,9 +78,9 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
80
78
|
slope: undefined,
|
|
81
79
|
time: undefined
|
|
82
80
|
};
|
|
83
|
-
data.power = (deviceData
|
|
84
|
-
data.pedalRpm = (deviceData
|
|
85
|
-
data.time = (deviceData
|
|
81
|
+
data.power = (_a = deviceData === null || deviceData === void 0 ? void 0 : deviceData.instantaneousPower) !== null && _a !== void 0 ? _a : data.power;
|
|
82
|
+
data.pedalRpm = (_b = deviceData === null || deviceData === void 0 ? void 0 : deviceData.cadence) !== null && _b !== void 0 ? _b : data.pedalRpm;
|
|
83
|
+
data.time = (_c = deviceData === null || deviceData === void 0 ? void 0 : deviceData.time) !== null && _c !== void 0 ? _c : data.time;
|
|
86
84
|
data.isPedalling = data.pedalRpm > 0 || (data.pedalRpm === undefined && data.power > 0);
|
|
87
85
|
data.heartrate = deviceData.heartrate || data.heartrate;
|
|
88
86
|
return data;
|
|
@@ -107,107 +105,105 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
107
105
|
};
|
|
108
106
|
return data;
|
|
109
107
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
108
|
+
checkResume() {
|
|
109
|
+
const wasPaused = this.paused;
|
|
110
|
+
const wasStopped = this.stopped;
|
|
111
|
+
if (wasPaused)
|
|
112
|
+
this.resume();
|
|
113
|
+
this.stopped = false;
|
|
114
|
+
if (this.started && !wasPaused && !wasStopped)
|
|
115
|
+
return [wasPaused, true];
|
|
116
|
+
return [wasPaused, false];
|
|
117
|
+
}
|
|
118
|
+
initControl(_startProps) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
this.setConstants();
|
|
121
|
+
yield this.establishControl();
|
|
122
|
+
this.setConstants();
|
|
123
|
+
yield this.sendInitialRequest();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
setConstants() {
|
|
127
|
+
const mode = this.getCyclingMode();
|
|
128
|
+
const sensor = this.getComms();
|
|
129
|
+
if (mode === null || mode === void 0 ? void 0 : mode.getSetting('bikeType')) {
|
|
130
|
+
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
131
|
+
sensor.setCrr(consts_1.cRR);
|
|
132
|
+
switch (bikeType) {
|
|
133
|
+
case 'race':
|
|
134
|
+
sensor.setCw(consts_1.cwABike.race);
|
|
135
|
+
break;
|
|
136
|
+
case 'triathlon':
|
|
137
|
+
sensor.setCw(consts_1.cwABike.triathlon);
|
|
138
|
+
break;
|
|
139
|
+
case 'mountain':
|
|
140
|
+
sensor.setCw(consts_1.cwABike.mountain);
|
|
141
|
+
break;
|
|
143
142
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
comms.setCw(consts_1.cwABike.mountain);
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
establishControl() {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
if (!this.isStarting())
|
|
148
|
+
return false;
|
|
149
|
+
let waitTask;
|
|
150
|
+
let iv;
|
|
151
|
+
const sensor = this.getComms();
|
|
152
|
+
const wait = () => {
|
|
153
|
+
const res = new Promise((resolve) => {
|
|
154
|
+
iv = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
if (!this.isStarting() || !(waitTask === null || waitTask === void 0 ? void 0 : waitTask.isRunning)) {
|
|
156
|
+
resolve(false);
|
|
157
|
+
clearInterval(iv);
|
|
158
|
+
return;
|
|
163
159
|
}
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
yield (0, utils_1.sleep)(1000);
|
|
169
|
-
hasControl = yield comms.requestControl();
|
|
170
|
-
retry++;
|
|
171
|
-
}
|
|
160
|
+
const hasControl = yield sensor.requestControl();
|
|
161
|
+
if (hasControl) {
|
|
162
|
+
clearInterval(iv);
|
|
163
|
+
resolve(true);
|
|
172
164
|
}
|
|
173
|
-
if (!
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.capabilities.push(types_1.IncyclistCapability.Cadence);
|
|
190
|
-
}
|
|
191
|
-
if (comms.features.power && !this.hasCapability(types_1.IncyclistCapability.Power)) {
|
|
192
|
-
this.capabilities.push(types_1.IncyclistCapability.Power);
|
|
193
|
-
}
|
|
194
|
-
const after = this.capabilities.join(',');
|
|
195
|
-
if (before !== after) {
|
|
196
|
-
this.emit('device-info', this.getSettings(), { capabilities: this.capabilities });
|
|
197
|
-
}
|
|
198
|
-
this.resetData();
|
|
199
|
-
this.stopped = false;
|
|
200
|
-
this.started = true;
|
|
201
|
-
this.resume();
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
catch (err) {
|
|
206
|
-
this.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
207
|
-
throw new Error(`could not start device, reason:${err.message}`);
|
|
208
|
-
}
|
|
165
|
+
else if (!this.isStarting() || !(waitTask === null || waitTask === void 0 ? void 0 : waitTask.isRunning)) {
|
|
166
|
+
resolve(false);
|
|
167
|
+
clearInterval(iv);
|
|
168
|
+
}
|
|
169
|
+
}), 1000);
|
|
170
|
+
});
|
|
171
|
+
return res;
|
|
172
|
+
};
|
|
173
|
+
waitTask = new task_1.InteruptableTask(wait(), {
|
|
174
|
+
errorOnTimeout: false,
|
|
175
|
+
timeout: 10000
|
|
176
|
+
});
|
|
177
|
+
const hasControl = yield waitTask.run();
|
|
178
|
+
clearInterval(iv);
|
|
179
|
+
if (!hasControl && this.isStarting())
|
|
180
|
+
throw new Error('could not establish control');
|
|
209
181
|
});
|
|
210
182
|
}
|
|
183
|
+
sendInitialRequest() {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
186
|
+
yield this.sendUpdate(startRequest, true);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
checkCapabilities() {
|
|
190
|
+
var _a, _b, _c;
|
|
191
|
+
const before = this.capabilities.join(',');
|
|
192
|
+
const sensor = this.getComms();
|
|
193
|
+
if (((_a = sensor.features) === null || _a === void 0 ? void 0 : _a.heartrate) && !this.hasCapability(types_1.IncyclistCapability.HeartRate)) {
|
|
194
|
+
this.capabilities.push(types_1.IncyclistCapability.HeartRate);
|
|
195
|
+
}
|
|
196
|
+
if (((_b = sensor.features) === null || _b === void 0 ? void 0 : _b.cadence) && !this.hasCapability(types_1.IncyclistCapability.Cadence)) {
|
|
197
|
+
this.capabilities.push(types_1.IncyclistCapability.Cadence);
|
|
198
|
+
}
|
|
199
|
+
if (((_c = sensor.features) === null || _c === void 0 ? void 0 : _c.power) && !this.hasCapability(types_1.IncyclistCapability.Power)) {
|
|
200
|
+
this.capabilities.push(types_1.IncyclistCapability.Power);
|
|
201
|
+
}
|
|
202
|
+
const after = this.capabilities.join(',');
|
|
203
|
+
if (before !== after) {
|
|
204
|
+
this.emit('device-info', this.getSettings(), { capabilities: this.capabilities });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
211
207
|
sendUpdate(request_1) {
|
|
212
208
|
return __awaiter(this, arguments, void 0, function* (request, enforced = false) {
|
|
213
209
|
if (!enforced && (this.paused || !this.device))
|
package/lib/ble/fm/comms.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BleProtocol, BleWriteProps, IBlePeripheralConnector } from "../types";
|
|
2
2
|
import { IndoorBikeData, IndoorBikeFeatures } from "./types";
|
|
3
|
-
import { BleComms } from "../base/
|
|
3
|
+
import { BleComms } from "../base/sensor";
|
|
4
4
|
import { LegacyProfile } from "../../antv2/types";
|
|
5
5
|
export default class BleFitnessMachineDevice extends BleComms {
|
|
6
6
|
static protocol: BleProtocol;
|
package/lib/ble/fm/comms.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const consts_1 = require("../consts");
|
|
13
|
-
const
|
|
13
|
+
const sensor_1 = require("../base/sensor");
|
|
14
14
|
const utils_1 = require("../utils");
|
|
15
15
|
const bit = (nr) => (1 << nr);
|
|
16
16
|
const IndoorBikeDataFlag = {
|
|
@@ -66,7 +66,7 @@ const TargetSettingFeatureFlag = {
|
|
|
66
66
|
SpinDownControlSupported: bit(15),
|
|
67
67
|
TargetedCadenceConfigurationSupported: bit(16)
|
|
68
68
|
};
|
|
69
|
-
class BleFitnessMachineDevice extends
|
|
69
|
+
class BleFitnessMachineDevice extends sensor_1.BleComms {
|
|
70
70
|
constructor(props) {
|
|
71
71
|
super(props);
|
|
72
72
|
this.features = undefined;
|
|
@@ -92,7 +92,7 @@ class BleFitnessMachineDevice extends comms_1.BleComms {
|
|
|
92
92
|
subscribeWriteResponse(cuuid) {
|
|
93
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
94
|
this.logEvent({ message: 'subscribe to CP response', characteristics: cuuid });
|
|
95
|
-
const connector = this.
|
|
95
|
+
const connector = this.getPeripheral();
|
|
96
96
|
const isAlreadySubscribed = connector.isSubscribed(cuuid);
|
|
97
97
|
if (!isAlreadySubscribed) {
|
|
98
98
|
connector.removeAllListeners(cuuid);
|
package/lib/ble/fm/consts.d.ts
CHANGED
|
@@ -4,3 +4,96 @@ export declare const cwABike: {
|
|
|
4
4
|
mountain: number;
|
|
5
5
|
};
|
|
6
6
|
export declare const cRR = 0.0036;
|
|
7
|
+
export declare const enum OpCode {
|
|
8
|
+
RequestControl = 0,
|
|
9
|
+
Reset = 1,
|
|
10
|
+
SetTargetSpeed = 2,
|
|
11
|
+
SetTargetInclination = 3,
|
|
12
|
+
SetTargetResistance = 4,
|
|
13
|
+
SetTargetPower = 5,
|
|
14
|
+
SetTargetHeartRate = 6,
|
|
15
|
+
StartOrResume = 7,
|
|
16
|
+
StopOrPause = 8,
|
|
17
|
+
SetIndoorBikeSimulation = 17,
|
|
18
|
+
SetWheelCircumference = 18,
|
|
19
|
+
SpinDownControl = 19,
|
|
20
|
+
SetTargetedCadence = 20,
|
|
21
|
+
ResponseCode = 128
|
|
22
|
+
}
|
|
23
|
+
export declare const enum FitnessMachineStatusOpCode {
|
|
24
|
+
Reset = 1,
|
|
25
|
+
FitnessMachineStoppedOrPaused = 2,
|
|
26
|
+
FitnessMachineStoppedBySafetyKey = 3,
|
|
27
|
+
FitnessMachineStartedOrResumed = 4,
|
|
28
|
+
TargetSpeedChanged = 5,
|
|
29
|
+
TargetInclineChanged = 6,
|
|
30
|
+
TargetResistanceLevelChanged = 7,
|
|
31
|
+
TargetPowerChanged = 8,
|
|
32
|
+
TargetHeartRateChanged = 9,
|
|
33
|
+
TargetExpendedEnergyChanged = 10,
|
|
34
|
+
IndoorBikeSimulationParametersChanged = 18,
|
|
35
|
+
WheelCircumferenceChanged = 19,
|
|
36
|
+
SpinDownStatus = 20,
|
|
37
|
+
TargetedCadenceChanged = 21,
|
|
38
|
+
ControlPermissionLost = 255
|
|
39
|
+
}
|
|
40
|
+
export declare const enum OpCodeResut {
|
|
41
|
+
Success = 1,
|
|
42
|
+
OpCodeNotSupported = 2,
|
|
43
|
+
InvalidParameter = 3,
|
|
44
|
+
OperationFailed = 4,
|
|
45
|
+
ControlNotPermitted = 5
|
|
46
|
+
}
|
|
47
|
+
export declare const IndoorBikeDataFlag: {
|
|
48
|
+
MoreData: number;
|
|
49
|
+
AverageSpeedPresent: number;
|
|
50
|
+
InstantaneousCadence: number;
|
|
51
|
+
AverageCadencePresent: number;
|
|
52
|
+
TotalDistancePresent: number;
|
|
53
|
+
ResistanceLevelPresent: number;
|
|
54
|
+
InstantaneousPowerPresent: number;
|
|
55
|
+
AveragePowerPresent: number;
|
|
56
|
+
ExpendedEnergyPresent: number;
|
|
57
|
+
HeartRatePresent: number;
|
|
58
|
+
MetabolicEquivalentPresent: number;
|
|
59
|
+
ElapsedTimePresent: number;
|
|
60
|
+
RemainingTimePresent: number;
|
|
61
|
+
};
|
|
62
|
+
export declare const FitnessMachineFeatureFlag: {
|
|
63
|
+
AverageSpeedSupported: number;
|
|
64
|
+
CadenceSupported: number;
|
|
65
|
+
TotalDistanceSupported: number;
|
|
66
|
+
InclinationSupported: number;
|
|
67
|
+
ElevationGainSupported: number;
|
|
68
|
+
PaceSupported: number;
|
|
69
|
+
StepCountSupported: number;
|
|
70
|
+
ResistanceLevelSupported: number;
|
|
71
|
+
StrideCountSupported: number;
|
|
72
|
+
ExpendedEnergySupported: number;
|
|
73
|
+
HeartRateMeasurementSupported: number;
|
|
74
|
+
MetabolicEquivalentSupported: number;
|
|
75
|
+
ElapsedTimeSupported: number;
|
|
76
|
+
RemainingTimeSupported: number;
|
|
77
|
+
PowerMeasurementSupported: number;
|
|
78
|
+
ForceOnBeltAndPowerOutputSupported: number;
|
|
79
|
+
UserDataRetentionSupported: number;
|
|
80
|
+
};
|
|
81
|
+
export declare const TargetSettingFeatureFlag: {
|
|
82
|
+
SpeedTargetSettingSupported: number;
|
|
83
|
+
InclinationTargetSettingSupported: number;
|
|
84
|
+
ResistanceTargetSettingSupported: number;
|
|
85
|
+
PowerTargetSettingSupported: number;
|
|
86
|
+
HeartRateTargetSettingSupported: number;
|
|
87
|
+
TargetedExpendedEnergyConfigurationSupported: number;
|
|
88
|
+
TargetedStepNumberConfigurationSupported: number;
|
|
89
|
+
TargetedStrideNumberConfigurationSupported: number;
|
|
90
|
+
TargetedDistanceConfigurationSupported: number;
|
|
91
|
+
TargetedTrainingTimeConfigurationSupported: number;
|
|
92
|
+
TargetedTimeInTwoHeartRateZonesConfigurationSupported: number;
|
|
93
|
+
TargetedTimeInThreeHeartRateZonesConfigurationSupported: number;
|
|
94
|
+
TargetedTimeInFiveHeartRateZonesConfigurationSupported: number;
|
|
95
|
+
IndoorBikeSimulationParametersSupported: number;
|
|
96
|
+
WheelCircumferenceConfigurationSupported: number;
|
|
97
|
+
SpinDownControlSupported: number;
|
|
98
|
+
TargetedCadenceConfigurationSupported: number;
|
|
99
|
+
};
|
package/lib/ble/fm/consts.js
CHANGED
|
@@ -1,9 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cRR = exports.cwABike = void 0;
|
|
3
|
+
exports.TargetSettingFeatureFlag = exports.FitnessMachineFeatureFlag = exports.IndoorBikeDataFlag = exports.cRR = exports.cwABike = void 0;
|
|
4
4
|
exports.cwABike = {
|
|
5
5
|
race: 0.35,
|
|
6
6
|
triathlon: 0.29,
|
|
7
7
|
mountain: 0.57
|
|
8
8
|
};
|
|
9
9
|
exports.cRR = 0.0036;
|
|
10
|
+
const bit = (nr) => (1 << nr);
|
|
11
|
+
exports.IndoorBikeDataFlag = {
|
|
12
|
+
MoreData: bit(0),
|
|
13
|
+
AverageSpeedPresent: bit(1),
|
|
14
|
+
InstantaneousCadence: bit(2),
|
|
15
|
+
AverageCadencePresent: bit(3),
|
|
16
|
+
TotalDistancePresent: bit(4),
|
|
17
|
+
ResistanceLevelPresent: bit(5),
|
|
18
|
+
InstantaneousPowerPresent: bit(6),
|
|
19
|
+
AveragePowerPresent: bit(7),
|
|
20
|
+
ExpendedEnergyPresent: bit(8),
|
|
21
|
+
HeartRatePresent: bit(9),
|
|
22
|
+
MetabolicEquivalentPresent: bit(10),
|
|
23
|
+
ElapsedTimePresent: bit(11),
|
|
24
|
+
RemainingTimePresent: bit(12)
|
|
25
|
+
};
|
|
26
|
+
exports.FitnessMachineFeatureFlag = {
|
|
27
|
+
AverageSpeedSupported: bit(0),
|
|
28
|
+
CadenceSupported: bit(1),
|
|
29
|
+
TotalDistanceSupported: bit(2),
|
|
30
|
+
InclinationSupported: bit(3),
|
|
31
|
+
ElevationGainSupported: bit(4),
|
|
32
|
+
PaceSupported: bit(5),
|
|
33
|
+
StepCountSupported: bit(6),
|
|
34
|
+
ResistanceLevelSupported: bit(7),
|
|
35
|
+
StrideCountSupported: bit(8),
|
|
36
|
+
ExpendedEnergySupported: bit(9),
|
|
37
|
+
HeartRateMeasurementSupported: bit(10),
|
|
38
|
+
MetabolicEquivalentSupported: bit(11),
|
|
39
|
+
ElapsedTimeSupported: bit(12),
|
|
40
|
+
RemainingTimeSupported: bit(13),
|
|
41
|
+
PowerMeasurementSupported: bit(14),
|
|
42
|
+
ForceOnBeltAndPowerOutputSupported: bit(15),
|
|
43
|
+
UserDataRetentionSupported: bit(16)
|
|
44
|
+
};
|
|
45
|
+
exports.TargetSettingFeatureFlag = {
|
|
46
|
+
SpeedTargetSettingSupported: bit(0),
|
|
47
|
+
InclinationTargetSettingSupported: bit(1),
|
|
48
|
+
ResistanceTargetSettingSupported: bit(2),
|
|
49
|
+
PowerTargetSettingSupported: bit(3),
|
|
50
|
+
HeartRateTargetSettingSupported: bit(4),
|
|
51
|
+
TargetedExpendedEnergyConfigurationSupported: bit(5),
|
|
52
|
+
TargetedStepNumberConfigurationSupported: bit(6),
|
|
53
|
+
TargetedStrideNumberConfigurationSupported: bit(7),
|
|
54
|
+
TargetedDistanceConfigurationSupported: bit(8),
|
|
55
|
+
TargetedTrainingTimeConfigurationSupported: bit(9),
|
|
56
|
+
TargetedTimeInTwoHeartRateZonesConfigurationSupported: bit(10),
|
|
57
|
+
TargetedTimeInThreeHeartRateZonesConfigurationSupported: bit(11),
|
|
58
|
+
TargetedTimeInFiveHeartRateZonesConfigurationSupported: bit(12),
|
|
59
|
+
IndoorBikeSimulationParametersSupported: bit(13),
|
|
60
|
+
WheelCircumferenceConfigurationSupported: bit(14),
|
|
61
|
+
SpinDownControlSupported: bit(15),
|
|
62
|
+
TargetedCadenceConfigurationSupported: bit(16)
|
|
63
|
+
};
|
package/lib/ble/fm/index.d.ts
CHANGED
package/lib/ble/fm/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.cwABike = exports.cRR = exports.BleFmComms = exports.BleFmAdapter = void 0;
|
|
7
|
-
const
|
|
8
|
-
exports.BleFmComms =
|
|
7
|
+
const sensor_1 = __importDefault(require("./sensor"));
|
|
8
|
+
exports.BleFmComms = sensor_1.default;
|
|
9
9
|
const adapter_1 = __importDefault(require("./adapter"));
|
|
10
10
|
exports.BleFmAdapter = adapter_1.default;
|
|
11
11
|
const consts_1 = require("./consts");
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LegacyProfile } from "../../antv2/types";
|
|
2
|
+
import { BleProtocol, BleWriteProps } from "../types";
|
|
3
|
+
import { IndoorBikeData, IndoorBikeFeatures } from "./types";
|
|
4
|
+
import { TBleSensor } from "../base/sensor";
|
|
5
|
+
export default class BleFitnessMachineDevice extends TBleSensor {
|
|
6
|
+
static readonly profile: LegacyProfile;
|
|
7
|
+
static readonly protocol: BleProtocol;
|
|
8
|
+
static readonly services: string[];
|
|
9
|
+
static readonly characteristics: string[];
|
|
10
|
+
static readonly detectionPriority: number;
|
|
11
|
+
protected data: IndoorBikeData;
|
|
12
|
+
protected _features: IndoorBikeFeatures;
|
|
13
|
+
protected hasControl: boolean;
|
|
14
|
+
protected isCheckingControl: boolean;
|
|
15
|
+
protected isCPSubscribed: boolean;
|
|
16
|
+
protected crr: number;
|
|
17
|
+
protected cw: number;
|
|
18
|
+
protected windSpeed: number;
|
|
19
|
+
protected wheelSize: number;
|
|
20
|
+
constructor(peripheral: any, props?: any);
|
|
21
|
+
get features(): IndoorBikeFeatures;
|
|
22
|
+
reset(): void;
|
|
23
|
+
protected getRequiredCharacteristics(): Array<string>;
|
|
24
|
+
onData(characteristic: string, data: Buffer): boolean;
|
|
25
|
+
setCrr(crr: number): void;
|
|
26
|
+
getCrr(): number;
|
|
27
|
+
setCw(cw: number): void;
|
|
28
|
+
getCw(): number;
|
|
29
|
+
setWindSpeed(windSpeed: number): void;
|
|
30
|
+
getWindSpeed(): number;
|
|
31
|
+
requestControl(): Promise<boolean>;
|
|
32
|
+
setTargetPower(power: number): Promise<boolean>;
|
|
33
|
+
setSlope(slope: any): Promise<boolean>;
|
|
34
|
+
protected parseHrm(_data: Uint8Array): IndoorBikeData;
|
|
35
|
+
protected parseIndoorBikeData(_data: Uint8Array): IndoorBikeData;
|
|
36
|
+
protected parseFitnessMachineStatus(_data: Uint8Array): IndoorBikeData;
|
|
37
|
+
protected getFitnessMachineFeatures(): Promise<IndoorBikeFeatures | undefined>;
|
|
38
|
+
protected writeFtmsMessage(requestedOpCode: any, data: any, props?: BleWriteProps): Promise<number>;
|
|
39
|
+
setTargetInclination(inclination: number): Promise<boolean>;
|
|
40
|
+
setIndoorBikeSimulation(windSpeed: number, gradient: number, crr: number, cw: number): Promise<boolean>;
|
|
41
|
+
startRequest(): Promise<boolean>;
|
|
42
|
+
stopRequest(): Promise<boolean>;
|
|
43
|
+
PauseRequest(): Promise<boolean>;
|
|
44
|
+
}
|