incyclist-services 1.0.48 → 1.0.49
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.
|
@@ -28,6 +28,7 @@ export declare class DeviceConfigurationService extends EventEmitter {
|
|
|
28
28
|
init(): Promise<void>;
|
|
29
29
|
setFeature(name: string, enabled: boolean): void;
|
|
30
30
|
protected isNewUi(): boolean;
|
|
31
|
+
protected verifyCapabilityExists(capability: any): void;
|
|
31
32
|
protected verifyCapabilitySettings(): void;
|
|
32
33
|
protected initCapabilties(): void;
|
|
33
34
|
protected initInterfaces(): void;
|
|
@@ -45,6 +45,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
45
45
|
this.logEvent({ message: 'error', fn, error: err.message, stack: err.stack });
|
|
46
46
|
}
|
|
47
47
|
init() {
|
|
48
|
+
var _a, _b, _c;
|
|
48
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
50
|
yield this.userSettings.init();
|
|
50
51
|
if (this.isInitialized()) {
|
|
@@ -59,32 +60,34 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
59
60
|
settings.modeSettings = this.userSettings.get('preferences.gear', {});
|
|
60
61
|
try {
|
|
61
62
|
yield this.initFromLegacy(settings);
|
|
62
|
-
this.verifyCapabilitySettings();
|
|
63
63
|
}
|
|
64
64
|
catch (err) {
|
|
65
|
+
console.log('~~~ ERROR', err);
|
|
65
66
|
this.logError(err, 'init()');
|
|
66
67
|
}
|
|
67
|
-
this.emitInitialized();
|
|
68
|
-
return;
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
else {
|
|
70
|
+
yield this.userSettings.init();
|
|
71
|
+
this.settings = {
|
|
72
|
+
devices: this.userSettings.get('devices', []),
|
|
73
|
+
capabilities: this.userSettings.get('capabilities', []),
|
|
74
|
+
interfaces: this.userSettings.get('interfaces', [])
|
|
75
|
+
};
|
|
76
|
+
}
|
|
76
77
|
let emptyConfig = false;
|
|
77
|
-
if (!this.settings
|
|
78
|
+
if (!this.settings)
|
|
79
|
+
this.settings = {};
|
|
80
|
+
if (!this.settings.capabilities || ((_a = this.settings.capabilities) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
78
81
|
this.initCapabilties();
|
|
79
82
|
emptyConfig = true;
|
|
80
83
|
}
|
|
81
|
-
if (!this.settings.interfaces || this.settings.interfaces.length === 0) {
|
|
84
|
+
if (!this.settings.interfaces || ((_b = this.settings.interfaces) === null || _b === void 0 ? void 0 : _b.length) === 0) {
|
|
82
85
|
this.initInterfaces();
|
|
83
86
|
emptyConfig = true;
|
|
84
87
|
}
|
|
85
88
|
if (emptyConfig)
|
|
86
89
|
this.updateUserSettings();
|
|
87
|
-
if (!this.settings.devices)
|
|
90
|
+
if (!((_c = this.settings) === null || _c === void 0 ? void 0 : _c.devices))
|
|
88
91
|
this.settings.devices = [];
|
|
89
92
|
this.settings.devices.forEach(d => {
|
|
90
93
|
try {
|
|
@@ -106,12 +109,24 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
106
109
|
isNewUi() {
|
|
107
110
|
return this.features['NEW_UI'] === true;
|
|
108
111
|
}
|
|
112
|
+
verifyCapabilityExists(capability) {
|
|
113
|
+
const { capabilities } = this.settings;
|
|
114
|
+
const found = capabilities.find(c => c.capability === capability);
|
|
115
|
+
if (!found) {
|
|
116
|
+
capabilities.push({ capability, devices: [], disabled: false, selected: undefined });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
109
119
|
verifyCapabilitySettings() {
|
|
110
120
|
var _a;
|
|
111
121
|
const { capabilities } = this.settings;
|
|
112
122
|
const isNewUi = this.isNewUi();
|
|
113
123
|
const bikeCapIdx = capabilities.findIndex(c => c.capability === 'bike');
|
|
114
124
|
if (isNewUi) {
|
|
125
|
+
this.verifyCapabilityExists(incyclist_devices_1.IncyclistCapability.Control);
|
|
126
|
+
this.verifyCapabilityExists(incyclist_devices_1.IncyclistCapability.Power);
|
|
127
|
+
this.verifyCapabilityExists(incyclist_devices_1.IncyclistCapability.HeartRate);
|
|
128
|
+
this.verifyCapabilityExists(incyclist_devices_1.IncyclistCapability.Speed);
|
|
129
|
+
this.verifyCapabilityExists(incyclist_devices_1.IncyclistCapability.Cadence);
|
|
115
130
|
if (bikeCapIdx !== -1) {
|
|
116
131
|
capabilities.splice(bikeCapIdx, 1);
|
|
117
132
|
}
|
|
@@ -206,11 +221,13 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
206
221
|
const gears = (0, clone_1.default)(gearSelection || {});
|
|
207
222
|
const { bikes = [], hrms = [] } = gears;
|
|
208
223
|
this.settings = { interfaces: [], devices: [], capabilities: [] };
|
|
224
|
+
this.initCapabilties();
|
|
209
225
|
const { interfaces, devices, capabilities } = this.settings;
|
|
226
|
+
const get = ((x, def) => x === undefined || x === null ? def : x);
|
|
210
227
|
interfaces.push({ name: 'ant', enabled: ((_a = connections === null || connections === void 0 ? void 0 : connections.ant) === null || _a === void 0 ? void 0 : _a.enabled) || true });
|
|
211
228
|
interfaces.push({ name: 'ble', enabled: true });
|
|
212
|
-
interfaces.push({ name: 'serial', enabled: ((_b = connections === null || connections === void 0 ? void 0 : connections.serial) === null || _b === void 0 ? void 0 : _b.enabled
|
|
213
|
-
interfaces.push({ name: 'tcpip', enabled: ((_e = connections === null || connections === void 0 ? void 0 : connections.tcpip) === null || _e === void 0 ? void 0 : _e.enabled
|
|
229
|
+
interfaces.push({ name: 'serial', enabled: get((_b = connections === null || connections === void 0 ? void 0 : connections.serial) === null || _b === void 0 ? void 0 : _b.enabled, true), protocol: (_d = (_c = connections === null || connections === void 0 ? void 0 : connections.serial) === null || _c === void 0 ? void 0 : _c.protocols) === null || _d === void 0 ? void 0 : _d.find(p => p.selected).name });
|
|
230
|
+
interfaces.push({ name: 'tcpip', enabled: get((_e = connections === null || connections === void 0 ? void 0 : connections.tcpip) === null || _e === void 0 ? void 0 : _e.enabled, false), protocol: 'Daum Premium', port: 51955 });
|
|
214
231
|
bikes.forEach(bike => {
|
|
215
232
|
if (bike.protocol === 'Simulator')
|
|
216
233
|
bike.interface = 'simulator';
|
|
@@ -615,6 +615,10 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
615
615
|
const capabilites = adapter.getCapabilities();
|
|
616
616
|
capabilites.forEach(c => {
|
|
617
617
|
const info = this.getCapability(c);
|
|
618
|
+
if (!info) {
|
|
619
|
+
this.logEvent({ message: 'warning: capabability not found', c, caps: this.state.capabilities });
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
618
622
|
let device = this.getCapabilityDevice(c, udid);
|
|
619
623
|
if (device) {
|
|
620
624
|
device.connectState = 'connected';
|
|
@@ -732,6 +736,13 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
732
736
|
startPairing(adapters, props) {
|
|
733
737
|
return __awaiter(this, void 0, void 0, function* () {
|
|
734
738
|
this.emit('pairing-start');
|
|
739
|
+
const isReady = !this.state.interfaces.find(i => i.state === 'connecting');
|
|
740
|
+
if (!isReady) {
|
|
741
|
+
setTimeout(() => {
|
|
742
|
+
this.run();
|
|
743
|
+
}, 1000);
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
735
746
|
this.logEvent({ message: 'Start Pairing', adapters, props });
|
|
736
747
|
this.processConnectedDevices(adapters);
|
|
737
748
|
const selected = this.state.capabilities.map(c => c.selected);
|
|
@@ -771,11 +782,19 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
771
782
|
return __awaiter(this, void 0, void 0, function* () {
|
|
772
783
|
const interfaces = this.state.interfaces.filter(i => this.isInterfaceEnabled(i)) || [].map(i => i.name);
|
|
773
784
|
if (interfaces.length === 0) {
|
|
774
|
-
|
|
775
|
-
|
|
785
|
+
setTimeout(() => {
|
|
786
|
+
this.run();
|
|
787
|
+
}, 1000);
|
|
776
788
|
return;
|
|
777
789
|
}
|
|
778
790
|
this.emit('scanning-start');
|
|
791
|
+
const isReady = !this.state.interfaces.find(i => i.state === 'connecting');
|
|
792
|
+
if (!isReady) {
|
|
793
|
+
setTimeout(() => {
|
|
794
|
+
this.run();
|
|
795
|
+
}, 1000);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
779
798
|
this.logEvent({ message: 'Start Scanning', props });
|
|
780
799
|
this.initScanningCallbacks();
|
|
781
800
|
const timeout = props.enforcedScan ? 1000 * 60 * 60 : undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.24"
|
|
6
6
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"axios": "^1.6.1",
|
|
42
|
-
"incyclist-devices": "^2.1.
|
|
42
|
+
"incyclist-devices": "^2.1.21",
|
|
43
43
|
"uuid": "^9.0.0"
|
|
44
44
|
}
|
|
45
45
|
}
|