incyclist-devices 2.3.0-beta.13 → 2.3.0-beta.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/antv2/base/adapter.d.ts +2 -2
- package/lib/ble/base/adapter.d.ts +2 -2
- package/lib/ble/base/adapter.js +10 -8
- package/lib/ble/base/interface.js +6 -3
- package/lib/ble/fm/adapter.d.ts +1 -1
- package/lib/ble/fm/adapter.js +32 -22
- package/lib/ble/fm/sensor.d.ts +1 -1
- package/lib/ble/tacx/adapter.d.ts +1 -1
- package/lib/ble/tacx/adapter.js +12 -10
- package/package.json +1 -1
|
@@ -56,8 +56,8 @@ export default class AntAdapter<TDeviceData extends BaseDeviceData> extends Incy
|
|
|
56
56
|
getProfile(): Profile;
|
|
57
57
|
getLogData(data: any, excludeList: any): any;
|
|
58
58
|
check(): Promise<boolean>;
|
|
59
|
-
checkCapabilities(): Promise<void>;
|
|
60
|
-
initControl(): Promise<void>;
|
|
59
|
+
protected checkCapabilities(): Promise<void>;
|
|
60
|
+
protected initControl(): Promise<void>;
|
|
61
61
|
getDefaultStartupTimeout(): number;
|
|
62
62
|
startPreChecks(props: AntDeviceProperties): Promise<'done' | 'connected' | 'connection-failed'>;
|
|
63
63
|
resetStartStatus(): void;
|
|
@@ -21,7 +21,7 @@ export default class BleAdapter<TDeviceData extends BleDeviceData, TDevice exten
|
|
|
21
21
|
waitForPeripheral(): Promise<void>;
|
|
22
22
|
updateSensor(peripheral: IBlePeripheral): void;
|
|
23
23
|
close(): Promise<boolean>;
|
|
24
|
-
|
|
24
|
+
getSensor(): TDevice;
|
|
25
25
|
isEqual(settings: BleDeviceSettings): boolean;
|
|
26
26
|
isSame(adapter: IAdapter): boolean;
|
|
27
27
|
isConnected(): boolean;
|
|
@@ -44,7 +44,7 @@ export default class BleAdapter<TDeviceData extends BleDeviceData, TDevice exten
|
|
|
44
44
|
protected isStarting(): boolean;
|
|
45
45
|
protected hasData(): boolean;
|
|
46
46
|
protected waitForInitialData(startupTimeout: any): Promise<void>;
|
|
47
|
-
protected checkCapabilities(): void
|
|
47
|
+
protected checkCapabilities(): Promise<void>;
|
|
48
48
|
protected initControl(_props?: BleStartProperties): Promise<void>;
|
|
49
49
|
protected startAdapter(startProps?: BleStartProperties): Promise<boolean>;
|
|
50
50
|
startSensor(): Promise<boolean>;
|
package/lib/ble/base/adapter.js
CHANGED
|
@@ -63,7 +63,7 @@ class BleAdapter extends adpater_1.default {
|
|
|
63
63
|
return true;
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
getSensor() {
|
|
67
67
|
return this.device;
|
|
68
68
|
}
|
|
69
69
|
isEqual(settings) {
|
|
@@ -249,6 +249,8 @@ class BleAdapter extends adpater_1.default {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
checkCapabilities() {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
});
|
|
252
254
|
}
|
|
253
255
|
initControl(_props) {
|
|
254
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -284,7 +286,7 @@ class BleAdapter extends adpater_1.default {
|
|
|
284
286
|
return false;
|
|
285
287
|
}
|
|
286
288
|
yield this.waitForInitialData(timeout);
|
|
287
|
-
this.checkCapabilities();
|
|
289
|
+
yield this.checkCapabilities();
|
|
288
290
|
if (this.hasCapability(types_1.IncyclistCapability.Control))
|
|
289
291
|
yield this.initControl(startProps);
|
|
290
292
|
this.stopped = false;
|
|
@@ -310,13 +312,13 @@ class BleAdapter extends adpater_1.default {
|
|
|
310
312
|
startSensor() {
|
|
311
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
312
314
|
var _a;
|
|
313
|
-
if (!((_a = this.
|
|
315
|
+
if (!((_a = this.getSensor()) === null || _a === void 0 ? void 0 : _a.hasPeripheral())) {
|
|
314
316
|
yield this.waitForPeripheral();
|
|
315
317
|
}
|
|
316
|
-
if (!this.
|
|
318
|
+
if (!this.getSensor()) {
|
|
317
319
|
return false;
|
|
318
320
|
}
|
|
319
|
-
const sensor = this.
|
|
321
|
+
const sensor = this.getSensor();
|
|
320
322
|
const connected = yield sensor.startSensor();
|
|
321
323
|
yield sensor.subscribe();
|
|
322
324
|
if (connected) {
|
|
@@ -335,7 +337,7 @@ class BleAdapter extends adpater_1.default {
|
|
|
335
337
|
}
|
|
336
338
|
let reason = 'unknown';
|
|
337
339
|
let stopped = false;
|
|
338
|
-
const sensor = this.
|
|
340
|
+
const sensor = this.getSensor();
|
|
339
341
|
try {
|
|
340
342
|
stopped = yield sensor.stopSensor();
|
|
341
343
|
}
|
|
@@ -355,11 +357,11 @@ class BleAdapter extends adpater_1.default {
|
|
|
355
357
|
}
|
|
356
358
|
this.started = false;
|
|
357
359
|
this.resetData();
|
|
358
|
-
if (!this.
|
|
360
|
+
if (!this.getSensor()) {
|
|
359
361
|
this.logEvent({ message: 'device stopped - not started yet', device: this.getName(), interface: this.getInterface() });
|
|
360
362
|
return true;
|
|
361
363
|
}
|
|
362
|
-
const sensor = this.
|
|
364
|
+
const sensor = this.getSensor();
|
|
363
365
|
sensor.reset();
|
|
364
366
|
this.resetData();
|
|
365
367
|
this.stopped = true;
|
|
@@ -156,7 +156,7 @@ class BleInterface extends events_1.default {
|
|
|
156
156
|
.then(() => { return this.onScanDone(); })
|
|
157
157
|
.catch(() => []);
|
|
158
158
|
}
|
|
159
|
-
this.logEvent({ message: 'starting scan ..' });
|
|
159
|
+
this.logEvent({ message: 'starting scan ..', interface: 'ble' });
|
|
160
160
|
this.scanTask = new task_1.InteruptableTask(this.startScan(), {
|
|
161
161
|
timeout: props.timeout,
|
|
162
162
|
name: 'scan',
|
|
@@ -187,10 +187,12 @@ class BleInterface extends events_1.default {
|
|
|
187
187
|
return this.buildDeviceSettings(this.matching);
|
|
188
188
|
}
|
|
189
189
|
pauseLogging() {
|
|
190
|
+
this.logEvent({ message: 'pausing logging' });
|
|
190
191
|
this.logDisabled = true;
|
|
191
192
|
}
|
|
192
193
|
resumeLogging() {
|
|
193
194
|
this.logDisabled = false;
|
|
195
|
+
this.logEvent({ message: 'resuming logging' });
|
|
194
196
|
}
|
|
195
197
|
isLoggingPaused() {
|
|
196
198
|
return this.logDisabled;
|
|
@@ -368,6 +370,7 @@ class BleInterface extends events_1.default {
|
|
|
368
370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
369
371
|
if (!this.isConnected() || !this.isDiscovering())
|
|
370
372
|
return;
|
|
373
|
+
this.logEvent({ message: 'updateWithServices', peripheral: announcement.name });
|
|
371
374
|
try {
|
|
372
375
|
yield this.discoverServices(announcement);
|
|
373
376
|
return announcement;
|
|
@@ -581,13 +584,13 @@ class BleInterface extends events_1.default {
|
|
|
581
584
|
logEvent(event) {
|
|
582
585
|
if (this.logDisabled && event.message !== 'Error')
|
|
583
586
|
return;
|
|
584
|
-
this.getLogger().logEvent(event);
|
|
587
|
+
this.getLogger().logEvent(Object.assign(Object.assign({}, event), { interface: 'ble' }));
|
|
585
588
|
const emitPayload = Object.assign({}, event);
|
|
586
589
|
delete emitPayload.ts;
|
|
587
590
|
this.emit('log', emitPayload);
|
|
588
591
|
const w = global.window;
|
|
589
592
|
if (this.debug || (w === null || w === void 0 ? void 0 : w.SERVICE_DEBUG) || process.env.DEBUG)
|
|
590
|
-
console.log(`~~~ ${this.logger.getName().toUpperCase()}-SVC`, event);
|
|
593
|
+
console.log(`~~~ ${this.logger.getName().toUpperCase()}-SVC`, Object.assign(Object.assign({}, event), { interface: 'ble' }));
|
|
591
594
|
}
|
|
592
595
|
logError(err, fn, args) {
|
|
593
596
|
const logInfo = args || {};
|
package/lib/ble/fm/adapter.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export default class BleFmAdapter extends BleAdapter<IndoorBikeData, BleFitnessM
|
|
|
23
23
|
protected setConstants(): void;
|
|
24
24
|
protected establishControl(): Promise<boolean>;
|
|
25
25
|
protected sendInitialRequest(): Promise<void>;
|
|
26
|
-
protected checkCapabilities(): void
|
|
26
|
+
protected checkCapabilities(): Promise<void>;
|
|
27
27
|
sendUpdate(request: any, enforced?: boolean): Promise<void>;
|
|
28
28
|
sendInitCommands(): Promise<boolean>;
|
|
29
29
|
}
|
package/lib/ble/fm/adapter.js
CHANGED
|
@@ -47,7 +47,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
47
47
|
getSupportedCyclingModes() {
|
|
48
48
|
var _a;
|
|
49
49
|
const modes = [power_meter_1.default];
|
|
50
|
-
const features = (_a = this.
|
|
50
|
+
const features = (_a = this.getSensor()) === null || _a === void 0 ? void 0 : _a.features;
|
|
51
51
|
if (!features)
|
|
52
52
|
return [power_meter_1.default, antble_smarttrainer_1.default, antble_erg_1.default];
|
|
53
53
|
if (features.setPower === undefined || features.setPower)
|
|
@@ -58,7 +58,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
58
58
|
}
|
|
59
59
|
getDefaultCyclingMode() {
|
|
60
60
|
var _a;
|
|
61
|
-
const features = (_a = this.
|
|
61
|
+
const features = (_a = this.getSensor()) === null || _a === void 0 ? void 0 : _a.features;
|
|
62
62
|
if (!features)
|
|
63
63
|
return new antble_smarttrainer_1.default(this);
|
|
64
64
|
if (features.setSlope === undefined || features.setSlope)
|
|
@@ -128,7 +128,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
128
128
|
}
|
|
129
129
|
setConstants() {
|
|
130
130
|
const mode = this.getCyclingMode();
|
|
131
|
-
const sensor = this.
|
|
131
|
+
const sensor = this.getSensor();
|
|
132
132
|
if (mode === null || mode === void 0 ? void 0 : mode.getSetting('bikeType')) {
|
|
133
133
|
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
134
134
|
sensor.setCrr(consts_1.cRR);
|
|
@@ -151,7 +151,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
151
151
|
return false;
|
|
152
152
|
let hasControl = false;
|
|
153
153
|
let tryCnt = 0;
|
|
154
|
-
const sensor = this.
|
|
154
|
+
const sensor = this.getSensor();
|
|
155
155
|
return new Promise((resolve) => {
|
|
156
156
|
this.startTask.notifyOnStop(() => {
|
|
157
157
|
resolve(false);
|
|
@@ -182,23 +182,33 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
checkCapabilities() {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
var _a, _b, _c;
|
|
187
|
+
const before = this.capabilities.join(',');
|
|
188
|
+
const sensor = this.getSensor();
|
|
189
|
+
if (!sensor.features) {
|
|
190
|
+
try {
|
|
191
|
+
yield sensor.getFitnessMachineFeatures();
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
this.logEvent({ message: 'error getting fitness machine features', device: this.getName(), interface: this.getInterface(), error: err });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (((_a = sensor.features) === null || _a === void 0 ? void 0 : _a.heartrate) && !this.hasCapability(types_1.IncyclistCapability.HeartRate)) {
|
|
198
|
+
this.capabilities.push(types_1.IncyclistCapability.HeartRate);
|
|
199
|
+
}
|
|
200
|
+
if (((_b = sensor.features) === null || _b === void 0 ? void 0 : _b.cadence) && !this.hasCapability(types_1.IncyclistCapability.Cadence)) {
|
|
201
|
+
this.capabilities.push(types_1.IncyclistCapability.Cadence);
|
|
202
|
+
}
|
|
203
|
+
if (((_c = sensor.features) === null || _c === void 0 ? void 0 : _c.power) && !this.hasCapability(types_1.IncyclistCapability.Power)) {
|
|
204
|
+
this.capabilities.push(types_1.IncyclistCapability.Power);
|
|
205
|
+
}
|
|
206
|
+
const after = this.capabilities.join(',');
|
|
207
|
+
if (before !== after) {
|
|
208
|
+
this.logEvent({ message: 'device capabilities updated', name: this.getSettings().name, interface: this.getSettings().interface, capabilities: this.capabilities });
|
|
209
|
+
this.emit('device-info', this.getSettings(), { capabilities: this.capabilities });
|
|
210
|
+
}
|
|
211
|
+
});
|
|
202
212
|
}
|
|
203
213
|
sendUpdate(request_1) {
|
|
204
214
|
return __awaiter(this, arguments, void 0, function* (request, enforced = false) {
|
|
@@ -207,7 +217,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
207
217
|
try {
|
|
208
218
|
const update = this.getCyclingMode().sendBikeUpdate(request);
|
|
209
219
|
this.logEvent({ message: 'send bike update requested', profile: this.getProfile(), update, request });
|
|
210
|
-
const device = this.
|
|
220
|
+
const device = this.getSensor();
|
|
211
221
|
if (update.slope !== undefined) {
|
|
212
222
|
yield device.setSlope(update.slope);
|
|
213
223
|
}
|
package/lib/ble/fm/sensor.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export default class BleFitnessMachineDevice extends TBleSensor {
|
|
|
34
34
|
protected parseHrm(_data: Uint8Array): IndoorBikeData;
|
|
35
35
|
protected parseIndoorBikeData(_data: Uint8Array): IndoorBikeData;
|
|
36
36
|
protected parseFitnessMachineStatus(_data: Uint8Array): IndoorBikeData;
|
|
37
|
-
|
|
37
|
+
getFitnessMachineFeatures(): Promise<IndoorBikeFeatures | undefined>;
|
|
38
38
|
protected writeFtmsMessage(requestedOpCode: any, data: any, props?: BleWriteProps): Promise<number>;
|
|
39
39
|
setTargetInclination(inclination: number): Promise<boolean>;
|
|
40
40
|
setIndoorBikeSimulation(windSpeed: number, gradient: number, crr: number, cw: number): Promise<boolean>;
|
|
@@ -9,5 +9,5 @@ export default class BleTacxAdapter extends BleFmAdapter {
|
|
|
9
9
|
updateSensor(peripheral: IBlePeripheral): void;
|
|
10
10
|
getProfile(): LegacyProfile;
|
|
11
11
|
protected initControl(props?: BleStartProperties): Promise<void>;
|
|
12
|
-
protected checkCapabilities(): void
|
|
12
|
+
protected checkCapabilities(): Promise<void>;
|
|
13
13
|
}
|
package/lib/ble/tacx/adapter.js
CHANGED
|
@@ -41,7 +41,7 @@ class BleTacxAdapter extends fm_1.BleFmAdapter {
|
|
|
41
41
|
initControl(props) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
var _a;
|
|
44
|
-
const sensor = this.
|
|
44
|
+
const sensor = this.getSensor();
|
|
45
45
|
const { user, wheelDiameter, gearRatio, bikeWeight = consts_1.DEFAULT_BIKE_WEIGHT } = props || {};
|
|
46
46
|
const userWeight = ((_a = user === null || user === void 0 ? void 0 : user.weight) !== null && _a !== void 0 ? _a : consts_1.DEFAULT_USER_WEIGHT);
|
|
47
47
|
sensor.sendTrackResistance(0.0);
|
|
@@ -51,15 +51,17 @@ class BleTacxAdapter extends fm_1.BleFmAdapter {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
checkCapabilities() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const before = this.capabilities.join(',');
|
|
56
|
+
const sensor = this.getSensor();
|
|
57
|
+
if (sensor.features && sensor.features.heartrate && !this.hasCapability(types_1.IncyclistCapability.HeartRate)) {
|
|
58
|
+
this.capabilities.push(types_1.IncyclistCapability.HeartRate);
|
|
59
|
+
}
|
|
60
|
+
const after = this.capabilities.join(',');
|
|
61
|
+
if (before !== after) {
|
|
62
|
+
this.emit('device-info', this.getSettings(), { capabilities: this.capabilities });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
BleTacxAdapter.INCYCLIST_PROFILE_NAME = 'Smart Trainer';
|