incyclist-devices 2.4.0 → 2.4.3
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/base/adapter.js
CHANGED
|
@@ -356,6 +356,10 @@ class BleAdapter extends adpater_1.default {
|
|
|
356
356
|
}
|
|
357
357
|
onDisconnectDone() {
|
|
358
358
|
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
+
try {
|
|
360
|
+
this.getBle().removeAllListeners('disconnect-done');
|
|
361
|
+
}
|
|
362
|
+
catch (_a) { }
|
|
359
363
|
this.logEvent({ message: 'disconnecting device', device: this.getName(), interface: this.getInterface() });
|
|
360
364
|
if (this.isStarting()) {
|
|
361
365
|
yield this.startTask.stop();
|
|
@@ -365,6 +369,7 @@ class BleAdapter extends adpater_1.default {
|
|
|
365
369
|
const sensor = this.getSensor();
|
|
366
370
|
try {
|
|
367
371
|
stopped = yield sensor.stopSensor();
|
|
372
|
+
this.logEvent({ message: 'disconnecting device completed', device: this.getName(), interface: this.getInterface() });
|
|
368
373
|
}
|
|
369
374
|
catch (err) {
|
|
370
375
|
reason = err.message;
|
|
@@ -52,6 +52,11 @@ class BlePeripheral {
|
|
|
52
52
|
}
|
|
53
53
|
this.connectPromise = new Promise((done) => {
|
|
54
54
|
const peripheral = this.getPeripheral();
|
|
55
|
+
this.connected = false;
|
|
56
|
+
this.ble.unregisterConnected(peripheral.id);
|
|
57
|
+
if (!this.ble.isConnected()) {
|
|
58
|
+
return done();
|
|
59
|
+
}
|
|
55
60
|
this.logEvent({ message: 'connect peripheral', address: peripheral.address });
|
|
56
61
|
peripheral.connectAsync().then(() => {
|
|
57
62
|
this.ble.registerConnected(this, peripheral.id);
|
|
@@ -92,6 +97,9 @@ class BlePeripheral {
|
|
|
92
97
|
}
|
|
93
98
|
peripheral.removeAllListeners();
|
|
94
99
|
}
|
|
100
|
+
else {
|
|
101
|
+
delete this.onDisconnectHandler;
|
|
102
|
+
}
|
|
95
103
|
this.ble.unregisterConnected(peripheral.id);
|
|
96
104
|
this.connected = false;
|
|
97
105
|
this.disconnecting = false;
|
package/lib/ble/base/sensor.js
CHANGED
|
@@ -117,6 +117,7 @@ class TBleSensor extends events_1.default {
|
|
|
117
117
|
}
|
|
118
118
|
reconnectSensor() {
|
|
119
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
this.logEvent({ message: 'reconnect sensor' });
|
|
120
121
|
let connected = false;
|
|
121
122
|
let subscribed = false;
|
|
122
123
|
let success = false;
|
package/lib/ble/fm/sensor.js
CHANGED
|
@@ -396,13 +396,14 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
396
396
|
}
|
|
397
397
|
writeFtmsMessage(requestedOpCode, data, props) {
|
|
398
398
|
return __awaiter(this, void 0, void 0, function* () {
|
|
399
|
+
var _a;
|
|
399
400
|
try {
|
|
400
401
|
this.logEvent({ message: 'fmts:write', device: this.getName(), data: data.toString('hex') });
|
|
401
402
|
let res;
|
|
402
403
|
let tsStart = Date.now();
|
|
403
404
|
if (props === null || props === void 0 ? void 0 : props.timeout) {
|
|
404
405
|
res = yield new task_1.InteruptableTask(this.write(consts_1.FTMS_CP, data, props), {
|
|
405
|
-
timeout: 800,
|
|
406
|
+
timeout: (_a = props.timeout) !== null && _a !== void 0 ? _a : 800,
|
|
406
407
|
errorOnTimeout: true
|
|
407
408
|
}).run();
|
|
408
409
|
}
|
|
@@ -72,21 +72,33 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
72
72
|
}
|
|
73
73
|
getConfig() {
|
|
74
74
|
const config = super.getConfig();
|
|
75
|
-
|
|
76
|
-
return config;
|
|
77
|
-
}
|
|
75
|
+
const virtShiftEnabled = this.getFeatureToogle().has('VirtualShifting');
|
|
78
76
|
let virtshift = config.properties.find(p => p.key === 'virtshift');
|
|
79
77
|
let startGear = config.properties.find(p => p.key === 'startGear');
|
|
80
|
-
if (!virtshift) {
|
|
81
|
-
|
|
78
|
+
if (!virtshift && !this.adapter.supportsVirtualShifting()) {
|
|
79
|
+
const options = virtShiftEnabled ? [
|
|
80
|
+
'Disabled',
|
|
81
|
+
{ key: 'Incyclist', display: 'App only (beta)' },
|
|
82
|
+
{ key: 'Mixed', display: 'App + Bike' }
|
|
83
|
+
] :
|
|
84
|
+
[
|
|
85
|
+
'Disabled',
|
|
86
|
+
{ key: 'Mixed', display: 'Enabled' }
|
|
87
|
+
];
|
|
88
|
+
virtshift = { key: 'virtshift', name: 'Virtual Shifting', description: 'Enable virtual shifting', type: types_1.CyclingModeProperyType.SingleSelect, options, default: 'Disabled' };
|
|
82
89
|
config.properties.push(virtshift);
|
|
83
90
|
}
|
|
84
|
-
if (this.adapter.supportsVirtualShifting()) {
|
|
91
|
+
if (!virtshift && virtShiftEnabled && this.adapter.supportsVirtualShifting()) {
|
|
85
92
|
virtshift.default = 'Enabled';
|
|
86
|
-
virtshift.options = [
|
|
93
|
+
virtshift.options = [
|
|
94
|
+
'Disabled',
|
|
95
|
+
{ key: 'Incyclist', display: 'App only (beta)' },
|
|
96
|
+
{ key: 'Mixed', display: 'App + Bike' },
|
|
97
|
+
{ key: 'SmartTrainer', display: 'SmartTreiner (beta)' }
|
|
98
|
+
];
|
|
87
99
|
virtshift.default = 'SmartTrainer';
|
|
88
100
|
}
|
|
89
|
-
if (!startGear) {
|
|
101
|
+
if (virtshift && !startGear) {
|
|
90
102
|
startGear = { key: 'startGear', name: 'Initial Gear', description: 'Initial Gear', type: types_1.CyclingModeProperyType.Integer, default: 12, min: 1, max: 24, condition: (s) => (s === null || s === void 0 ? void 0 : s.virtshift) === 'Incyclist' || (s === null || s === void 0 ? void 0 : s.virtshift) === 'SmartTrainer' };
|
|
91
103
|
config.properties.push(startGear);
|
|
92
104
|
}
|
|
@@ -59,7 +59,7 @@ class Simulator extends adpater_1.default {
|
|
|
59
59
|
this.setBikeProps(props);
|
|
60
60
|
return new Promise((resolve) => {
|
|
61
61
|
if (!this.isBot)
|
|
62
|
-
this.logEvent({ message: 'starting device', device: this.getName()
|
|
62
|
+
this.logEvent({ message: 'starting device', device: this.getName() });
|
|
63
63
|
if (this.started) {
|
|
64
64
|
return resolve(true);
|
|
65
65
|
}
|