incyclist-services 1.0.48 → 1.0.50
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';
|
|
@@ -439,7 +439,6 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
439
439
|
}
|
|
440
440
|
if (changedIdx !== -1) {
|
|
441
441
|
prev[changedIdx].isScanning = ifDetails.isScanning;
|
|
442
|
-
prev[changedIdx].enabled = ifDetails.enabled;
|
|
443
442
|
prev[changedIdx].state = ifDetails.state;
|
|
444
443
|
}
|
|
445
444
|
this.emitStateChange({ interfaces: this.state.interfaces });
|
|
@@ -615,6 +614,10 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
615
614
|
const capabilites = adapter.getCapabilities();
|
|
616
615
|
capabilites.forEach(c => {
|
|
617
616
|
const info = this.getCapability(c);
|
|
617
|
+
if (!info) {
|
|
618
|
+
this.logEvent({ message: 'warning: capabability not found', c, caps: this.state.capabilities });
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
618
621
|
let device = this.getCapabilityDevice(c, udid);
|
|
619
622
|
if (device) {
|
|
620
623
|
device.connectState = 'connected';
|
|
@@ -732,6 +735,13 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
732
735
|
startPairing(adapters, props) {
|
|
733
736
|
return __awaiter(this, void 0, void 0, function* () {
|
|
734
737
|
this.emit('pairing-start');
|
|
738
|
+
const isReady = !this.state.interfaces.find(i => i.enabled && i.state === 'connecting');
|
|
739
|
+
if (!isReady) {
|
|
740
|
+
setTimeout(() => {
|
|
741
|
+
this.run();
|
|
742
|
+
}, 1000);
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
735
745
|
this.logEvent({ message: 'Start Pairing', adapters, props });
|
|
736
746
|
this.processConnectedDevices(adapters);
|
|
737
747
|
const selected = this.state.capabilities.map(c => c.selected);
|
|
@@ -771,11 +781,19 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
771
781
|
return __awaiter(this, void 0, void 0, function* () {
|
|
772
782
|
const interfaces = this.state.interfaces.filter(i => this.isInterfaceEnabled(i)) || [].map(i => i.name);
|
|
773
783
|
if (interfaces.length === 0) {
|
|
774
|
-
|
|
775
|
-
|
|
784
|
+
setTimeout(() => {
|
|
785
|
+
this.run();
|
|
786
|
+
}, 1000);
|
|
776
787
|
return;
|
|
777
788
|
}
|
|
778
789
|
this.emit('scanning-start');
|
|
790
|
+
const isReady = !this.state.interfaces.find(i => i.enabled && i.state === 'connecting');
|
|
791
|
+
if (!isReady) {
|
|
792
|
+
setTimeout(() => {
|
|
793
|
+
this.run();
|
|
794
|
+
}, 1000);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
779
797
|
this.logEvent({ message: 'Start Scanning', props });
|
|
780
798
|
this.initScanningCallbacks();
|
|
781
799
|
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.50",
|
|
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
|
}
|