incyclist-services 1.0.38 → 1.0.40
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/LICENSE +21 -21
- package/README.MD +29 -29
- package/lib/devices/access/index.d.ts +0 -0
- package/lib/devices/access/index.js +0 -0
- package/lib/devices/access/mock.d.ts +0 -0
- package/lib/devices/access/mock.js +0 -0
- package/lib/devices/access/model.d.ts +0 -0
- package/lib/devices/access/model.js +0 -0
- package/lib/devices/access/service.d.ts +0 -0
- package/lib/devices/access/service.js +0 -2
- package/lib/devices/configuration/index.d.ts +0 -0
- package/lib/devices/configuration/index.js +0 -0
- package/lib/devices/configuration/mock.d.ts +0 -0
- package/lib/devices/configuration/mock.js +0 -0
- package/lib/devices/configuration/model/app/index.d.ts +0 -0
- package/lib/devices/configuration/model/app/index.js +0 -0
- package/lib/devices/configuration/model/index.d.ts +0 -0
- package/lib/devices/configuration/model/index.js +0 -0
- package/lib/devices/configuration/model/repository/index.d.ts +0 -0
- package/lib/devices/configuration/model/repository/index.js +0 -0
- package/lib/devices/configuration/model/repository/legacy.d.ts +0 -0
- package/lib/devices/configuration/model/repository/legacy.js +0 -0
- package/lib/devices/configuration/model/service/index.d.ts +0 -0
- package/lib/devices/configuration/model/service/index.js +0 -0
- package/lib/devices/configuration/service.d.ts +5 -2
- package/lib/devices/configuration/service.js +49 -21
- package/lib/devices/index.d.ts +0 -0
- package/lib/devices/index.js +0 -0
- package/lib/devices/pairing/index.d.ts +0 -0
- package/lib/devices/pairing/index.js +0 -0
- package/lib/devices/pairing/model.d.ts +27 -14
- package/lib/devices/pairing/model.js +0 -0
- package/lib/devices/pairing/service.d.ts +39 -19
- package/lib/devices/pairing/service.js +454 -272
- package/lib/devices/ride/index.d.ts +0 -0
- package/lib/devices/ride/index.js +0 -0
- package/lib/devices/ride/model.d.ts +0 -0
- package/lib/devices/ride/model.js +0 -0
- package/lib/devices/ride/service.d.ts +0 -0
- package/lib/devices/ride/service.js +0 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.js +0 -0
- package/lib/settings/index.d.ts +0 -0
- package/lib/settings/index.js +0 -0
- package/lib/settings/user/bindings/index.d.ts +0 -0
- package/lib/settings/user/bindings/index.js +0 -0
- package/lib/settings/user/bindings/json.d.ts +0 -0
- package/lib/settings/user/bindings/json.js +0 -0
- package/lib/settings/user/bindings/types.d.ts +0 -0
- package/lib/settings/user/bindings/types.js +0 -0
- package/lib/settings/user/mock.d.ts +0 -0
- package/lib/settings/user/mock.js +0 -0
- package/lib/settings/user/service.d.ts +0 -0
- package/lib/settings/user/service.js +0 -0
- package/lib/utils/clone.d.ts +0 -0
- package/lib/utils/clone.js +0 -0
- package/lib/utils/index.d.ts +0 -0
- package/lib/utils/index.js +0 -0
- package/lib/utils/logging.d.ts +0 -0
- package/lib/utils/logging.js +0 -0
- package/lib/utils/merge.d.ts +0 -0
- package/lib/utils/merge.js +0 -0
- package/lib/utils/sleep.d.ts +0 -0
- package/lib/utils/sleep.js +0 -0
- package/lib/utils/valid.d.ts +0 -0
- package/lib/utils/valid.js +0 -0
- package/package.json +44 -44
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Incyclist
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Incyclist
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.MD
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# incyclist-services
|
|
2
|
-
|
|
3
|
-
This Library contains the business logic used by the React components of the [Incyclist](https://incyclist.com) Indoor Cycling App.
|
|
4
|
-
|
|
5
|
-
Incyclist uses React to render the App Front-End for PC platforms ( Windows, Mac. Linux). It is planned that in the future, React Native will be used to render the Front-Ends for other platforms ( Android, IOS, AppleTV,...)
|
|
6
|
-
|
|
7
|
-
All Services will be accessed by the Front-End using
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
import {useXXX, initXXX} from {incyclist-devices}
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
- useXXX can be used to consume a Service (e.g. `useDeviceConfiguration()` )
|
|
15
|
-
- initXXX can be used to perform a lazy initialization of the Service (e.g. `initUserSettings(binding)` )
|
|
16
|
-
|
|
17
|
-
where XXX represents the Service name
|
|
18
|
-
|
|
19
|
-
The following Services are currently implemented in this library:
|
|
20
|
-
|
|
21
|
-
## Settings
|
|
22
|
-
- [UserSettings](./doc/classes/UserSettingsService.md): manages the user settings
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## Devices
|
|
26
|
-
- [DeviceConfiguration](./doc/classes/DeviceConfigurationService.md): manages the user configuration of scanned/added/selected devices
|
|
27
|
-
- [DeviceAccess](./doc/classes/DeviceAccessService.md): manages the basic communication to the device (setting up interfacs, scanning,... )
|
|
28
|
-
- [Device](./src/devices/device/README.MD): allows the Front-End to communicate with a device (reading, writing data)
|
|
29
|
-
- [DevicePairing](./doc/classes/DevicePairingService.md): implements the business logic og the DevicePairing screens
|
|
1
|
+
# incyclist-services
|
|
2
|
+
|
|
3
|
+
This Library contains the business logic used by the React components of the [Incyclist](https://incyclist.com) Indoor Cycling App.
|
|
4
|
+
|
|
5
|
+
Incyclist uses React to render the App Front-End for PC platforms ( Windows, Mac. Linux). It is planned that in the future, React Native will be used to render the Front-Ends for other platforms ( Android, IOS, AppleTV,...)
|
|
6
|
+
|
|
7
|
+
All Services will be accessed by the Front-End using
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
import {useXXX, initXXX} from {incyclist-devices}
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
- useXXX can be used to consume a Service (e.g. `useDeviceConfiguration()` )
|
|
15
|
+
- initXXX can be used to perform a lazy initialization of the Service (e.g. `initUserSettings(binding)` )
|
|
16
|
+
|
|
17
|
+
where XXX represents the Service name
|
|
18
|
+
|
|
19
|
+
The following Services are currently implemented in this library:
|
|
20
|
+
|
|
21
|
+
## Settings
|
|
22
|
+
- [UserSettings](./doc/classes/UserSettingsService.md): manages the user settings
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Devices
|
|
26
|
+
- [DeviceConfiguration](./doc/classes/DeviceConfigurationService.md): manages the user configuration of scanned/added/selected devices
|
|
27
|
+
- [DeviceAccess](./doc/classes/DeviceAccessService.md): manages the basic communication to the device (setting up interfacs, scanning,... )
|
|
28
|
+
- [Device](./src/devices/device/README.MD): allows the Front-End to communicate with a device (reading, writing data)
|
|
29
|
+
- [DevicePairing](./doc/classes/DevicePairingService.md): implements the business logic og the DevicePairing screens
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -281,8 +281,6 @@ class DeviceAccessService extends events_1.default {
|
|
|
281
281
|
i.removeAllListeners('device');
|
|
282
282
|
i.off('data', onDataHandlers[i.getName()]);
|
|
283
283
|
this.interfaces[i.getName()].isScanning = false;
|
|
284
|
-
if (i.getName() === 'tcpip')
|
|
285
|
-
this.interfaces[i.getName()];
|
|
286
284
|
});
|
|
287
285
|
adapters.forEach(adapter => adapter.removeAllListeners('data'));
|
|
288
286
|
this.emitScanStateChange('stopped');
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -23,6 +23,7 @@ export declare class DeviceConfigurationService extends EventEmitter {
|
|
|
23
23
|
protected logEvent(e: any): void;
|
|
24
24
|
protected logError(err: Error, fn: string): void;
|
|
25
25
|
init(): Promise<void>;
|
|
26
|
+
protected isNewUi(): any;
|
|
26
27
|
protected verifyCapabilitySettings(): void;
|
|
27
28
|
protected initCapabilties(): void;
|
|
28
29
|
protected initInterfaces(): void;
|
|
@@ -40,8 +41,10 @@ export declare class DeviceConfigurationService extends EventEmitter {
|
|
|
40
41
|
select(udid: string, capability: ExtendedIncyclistCapability, props?: {
|
|
41
42
|
noRecursive?: boolean;
|
|
42
43
|
legacy?: boolean;
|
|
44
|
+
emit?: boolean;
|
|
43
45
|
}): void;
|
|
44
|
-
|
|
46
|
+
private selectSingleDevice;
|
|
47
|
+
unselect(capability: ExtendedIncyclistCapability, shouldEmit?: boolean): void;
|
|
45
48
|
add(deviceSettings: IncyclistDeviceSettings, props?: {
|
|
46
49
|
legacy?: boolean;
|
|
47
50
|
}): string;
|
|
@@ -57,7 +60,7 @@ export declare class DeviceConfigurationService extends EventEmitter {
|
|
|
57
60
|
setMode(udid: string, mode: string): void;
|
|
58
61
|
setModeSettings(udid: string, mode: string, settings: any): void;
|
|
59
62
|
emitModeChanged(udid: string, mode: string, settings: any): void;
|
|
60
|
-
getAdapters(): AdapterInfo[];
|
|
63
|
+
getAdapters(onlySelected?: boolean): AdapterInfo[];
|
|
61
64
|
getAllAdapters(): AdapterInfo[];
|
|
62
65
|
getSelected(capability: ExtendedIncyclistCapability): IncyclistDeviceAdapter | undefined;
|
|
63
66
|
protected isDisabled(capability: ExtendedIncyclistCapability): boolean;
|
|
@@ -99,9 +99,12 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
99
99
|
this.emitInitialized();
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
+
isNewUi() {
|
|
103
|
+
return (this.userSettings.isInitialized && this.userSettings.get('NEW_UI', false));
|
|
104
|
+
}
|
|
102
105
|
verifyCapabilitySettings() {
|
|
103
106
|
const { capabilities } = this.settings;
|
|
104
|
-
const isNewUi = this.
|
|
107
|
+
const isNewUi = this.isNewUi();
|
|
105
108
|
if (isNewUi) {
|
|
106
109
|
const bikeCapIdx = capabilities.findIndex(c => c.capability === 'bike');
|
|
107
110
|
if (bikeCapIdx !== -1) {
|
|
@@ -149,7 +152,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
initCapabilties() {
|
|
152
|
-
const isNewUi = this.
|
|
155
|
+
const isNewUi = this.isNewUi();
|
|
153
156
|
const target = [incyclist_devices_1.IncyclistCapability.Control, incyclist_devices_1.IncyclistCapability.Power, incyclist_devices_1.IncyclistCapability.Cadence, incyclist_devices_1.IncyclistCapability.Speed, incyclist_devices_1.IncyclistCapability.HeartRate];
|
|
154
157
|
if (!isNewUi) {
|
|
155
158
|
target.push('bike');
|
|
@@ -182,7 +185,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
182
185
|
var _a, _b, _c, _d, _e;
|
|
183
186
|
const { gearSelection, connections, modeSettings = {} } = settings;
|
|
184
187
|
this.logEvent({ message: 'converting settings.json', gearSelection, connections });
|
|
185
|
-
const isNewUi = this.
|
|
188
|
+
const isNewUi = this.isNewUi();
|
|
186
189
|
const all = [incyclist_devices_1.IncyclistCapability.Control, incyclist_devices_1.IncyclistCapability.Power, incyclist_devices_1.IncyclistCapability.Cadence, incyclist_devices_1.IncyclistCapability.Speed, incyclist_devices_1.IncyclistCapability.HeartRate];
|
|
187
190
|
if (!isNewUi) {
|
|
188
191
|
all.push('bike');
|
|
@@ -366,10 +369,10 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
366
369
|
this.emitCapabiltyChanged();
|
|
367
370
|
}
|
|
368
371
|
select(udid, capability, props) {
|
|
369
|
-
var _a, _b, _c
|
|
372
|
+
var _a, _b, _c;
|
|
370
373
|
this.logEvent({ message: 'select device', udid, capability, props });
|
|
371
|
-
const isNewUi = this.
|
|
372
|
-
const { noRecursive = false, legacy = false } = props || {};
|
|
374
|
+
const isNewUi = this.isNewUi();
|
|
375
|
+
const { noRecursive = false, legacy = false, emit = true } = props || {};
|
|
373
376
|
const deviceSettings = (_b = (_a = this.settings.devices) === null || _a === void 0 ? void 0 : _a.find(d => d.udid === udid)) === null || _b === void 0 ? void 0 : _b.settings;
|
|
374
377
|
if (!deviceSettings)
|
|
375
378
|
return;
|
|
@@ -378,14 +381,19 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
378
381
|
this.logEvent({ message: 'error: could not find adapter', fn: 'select', udid, capability, adapters: (_c = Object.keys(this.adapters)) === null || _c === void 0 ? void 0 : _c.join(',') });
|
|
379
382
|
return;
|
|
380
383
|
}
|
|
381
|
-
if (
|
|
384
|
+
if (isNewUi) {
|
|
385
|
+
if (capability === 'bike')
|
|
386
|
+
return;
|
|
387
|
+
this.selectSingleDevice(udid, capability);
|
|
388
|
+
if (emit)
|
|
389
|
+
this.emitCapabiltyChanged(capability);
|
|
390
|
+
this.updateUserSettings();
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if ((capability === 'bike') && !adapter.isControllable())
|
|
382
394
|
return;
|
|
383
395
|
const isControl = adapter.hasCapability(incyclist_devices_1.IncyclistCapability.Control) || (legacy && !isNewUi && capability === 'bike');
|
|
384
|
-
this.
|
|
385
|
-
const capSettings = (_d = this.settings.capabilities) === null || _d === void 0 ? void 0 : _d.find(c => c.capability === capability);
|
|
386
|
-
capSettings.selected = udid;
|
|
387
|
-
if (capSettings.disabled)
|
|
388
|
-
delete capSettings.disabled;
|
|
396
|
+
this.selectSingleDevice(udid, capability);
|
|
389
397
|
this.emitCapabiltyChanged(capability);
|
|
390
398
|
if (noRecursive)
|
|
391
399
|
return;
|
|
@@ -430,7 +438,15 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
430
438
|
}
|
|
431
439
|
this.updateUserSettings();
|
|
432
440
|
}
|
|
433
|
-
|
|
441
|
+
selectSingleDevice(udid, capability) {
|
|
442
|
+
var _a;
|
|
443
|
+
this.addToCapability(udid, capability);
|
|
444
|
+
const capSettings = (_a = this.settings.capabilities) === null || _a === void 0 ? void 0 : _a.find(c => c.capability === capability);
|
|
445
|
+
capSettings.selected = udid;
|
|
446
|
+
if (capSettings.disabled)
|
|
447
|
+
delete capSettings.disabled;
|
|
448
|
+
}
|
|
449
|
+
unselect(capability, shouldEmit = true) {
|
|
434
450
|
this.logEvent({ message: 'unselect device', capability });
|
|
435
451
|
if (!this.settings || !this.settings.capabilities)
|
|
436
452
|
return;
|
|
@@ -438,14 +454,15 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
438
454
|
if (settings) {
|
|
439
455
|
settings.selected = null;
|
|
440
456
|
this.updateUserSettings();
|
|
441
|
-
|
|
457
|
+
if (shouldEmit)
|
|
458
|
+
this.emitCapabiltyChanged(settings.capability);
|
|
442
459
|
}
|
|
443
460
|
}
|
|
444
461
|
add(deviceSettings, props) {
|
|
445
462
|
var _a, _b;
|
|
446
|
-
const isNewUi = this.
|
|
463
|
+
const isNewUi = this.isNewUi();
|
|
447
464
|
let udid = this.getUdid(deviceSettings);
|
|
448
|
-
const { legacy =
|
|
465
|
+
const { legacy = false } = props || {};
|
|
449
466
|
this.logEvent({ message: 'add device', udid, deviceSettings, legacy });
|
|
450
467
|
const deviceAlreadyExists = udid !== undefined;
|
|
451
468
|
let adapter;
|
|
@@ -468,7 +485,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
468
485
|
this.initCapabilties();
|
|
469
486
|
this.settings.capabilities.forEach(c => {
|
|
470
487
|
if (c.devices.includes(udid))
|
|
471
|
-
return;
|
|
488
|
+
return udid;
|
|
472
489
|
const isBike = adapter.hasCapability(incyclist_devices_1.IncyclistCapability.Control);
|
|
473
490
|
const isPower = adapter.hasCapability(incyclist_devices_1.IncyclistCapability.Power);
|
|
474
491
|
if (legacy && !isNewUi) {
|
|
@@ -556,7 +573,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
556
573
|
}
|
|
557
574
|
}
|
|
558
575
|
addToCapability(udid, capability) {
|
|
559
|
-
const isNewUi = this.
|
|
576
|
+
const isNewUi = this.isNewUi();
|
|
560
577
|
if (isNewUi && capability === 'bike')
|
|
561
578
|
return;
|
|
562
579
|
if (!this.settings)
|
|
@@ -606,7 +623,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
606
623
|
this.userSettings.set('interfaces', this.settings.interfaces);
|
|
607
624
|
}
|
|
608
625
|
canStartRide() {
|
|
609
|
-
const isNewUi = this.
|
|
626
|
+
const isNewUi = this.isNewUi();
|
|
610
627
|
const { devices, capabilities } = this.settings || {};
|
|
611
628
|
if (!devices || !capabilities)
|
|
612
629
|
return false;
|
|
@@ -642,7 +659,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
642
659
|
modes = adapter.getSupportedCyclingModes();
|
|
643
660
|
if (!mode) {
|
|
644
661
|
modeObj = adapter.getDefaultCyclingMode();
|
|
645
|
-
mode = modeObj.getName();
|
|
662
|
+
mode = modeObj === null || modeObj === void 0 ? void 0 : modeObj.getName();
|
|
646
663
|
}
|
|
647
664
|
}
|
|
648
665
|
settings = (device.modes ? device.modes[mode] : undefined) || {};
|
|
@@ -687,7 +704,18 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
687
704
|
emitModeChanged(udid, mode, settings) {
|
|
688
705
|
this.emit('mode-changed', udid, mode, settings);
|
|
689
706
|
}
|
|
690
|
-
getAdapters() {
|
|
707
|
+
getAdapters(onlySelected = true) {
|
|
708
|
+
if (!onlySelected) {
|
|
709
|
+
const udids = Object.keys(this.adapters);
|
|
710
|
+
if (!udids || udids.length === 0)
|
|
711
|
+
return [];
|
|
712
|
+
const info = [];
|
|
713
|
+
udids.forEach(udid => {
|
|
714
|
+
const adapter = this.adapters[udid];
|
|
715
|
+
info.push({ udid, adapter, capabilities: adapter.getCapabilities() });
|
|
716
|
+
});
|
|
717
|
+
return info;
|
|
718
|
+
}
|
|
691
719
|
const { capabilities, devices } = this.settings || {};
|
|
692
720
|
const adapters = [];
|
|
693
721
|
capabilities.forEach(c => {
|
package/lib/devices/index.d.ts
CHANGED
|
File without changes
|
package/lib/devices/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DeviceData, DeviceSettings, IncyclistCapability } from "incyclist-devices";
|
|
1
|
+
import { DeviceData, DeviceSettings, IncyclistCapability, IncyclistDeviceAdapter } from "incyclist-devices";
|
|
2
2
|
import { EnrichedInterfaceSetting } from "../access";
|
|
3
|
-
import {
|
|
3
|
+
import { RideServiceCheckFilter } from "../ride";
|
|
4
|
+
import { AdapterInfo } from "../configuration";
|
|
4
5
|
export interface DevicePairingData {
|
|
5
6
|
udid: string;
|
|
6
7
|
name: string;
|
|
@@ -9,6 +10,7 @@ export interface DevicePairingData {
|
|
|
9
10
|
value?: number;
|
|
10
11
|
unit?: string;
|
|
11
12
|
selected: boolean;
|
|
13
|
+
interfaceInactive?: boolean;
|
|
12
14
|
}
|
|
13
15
|
export interface CapabilityData {
|
|
14
16
|
capability: IncyclistCapability;
|
|
@@ -17,7 +19,7 @@ export interface CapabilityData {
|
|
|
17
19
|
connectState?: DevicePairingStatus;
|
|
18
20
|
deviceName: string;
|
|
19
21
|
deviceNames: string;
|
|
20
|
-
selected
|
|
22
|
+
selected?: string;
|
|
21
23
|
disabled: boolean;
|
|
22
24
|
interface: string;
|
|
23
25
|
devices: Array<DevicePairingData>;
|
|
@@ -30,23 +32,34 @@ export interface PairingProps {
|
|
|
30
32
|
filter?: RideServiceCheckFilter;
|
|
31
33
|
enforcedScan?: boolean;
|
|
32
34
|
}
|
|
33
|
-
export interface
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
export interface PairingState {
|
|
36
|
+
capabilities?: Array<CapabilityData>;
|
|
37
|
+
interfaces?: Array<EnrichedInterfaceSetting>;
|
|
38
|
+
canStartRide?: boolean;
|
|
39
|
+
adapters?: Array<AdapterInfo>;
|
|
40
|
+
}
|
|
41
|
+
export interface InternalPairingState extends PairingState {
|
|
42
|
+
initialized: boolean;
|
|
43
|
+
stopRequested?: boolean;
|
|
44
|
+
stopped?: boolean;
|
|
45
|
+
check?: {
|
|
46
|
+
promise: Promise<boolean>;
|
|
47
|
+
};
|
|
48
|
+
scan?: {
|
|
49
|
+
promise: Promise<DeviceSettings[]>;
|
|
50
|
+
adapters?: Array<{
|
|
51
|
+
udid: string;
|
|
52
|
+
adapter: IncyclistDeviceAdapter;
|
|
53
|
+
handler: any;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
props?: PairingProps;
|
|
38
57
|
data?: Array<{
|
|
39
58
|
udid: string;
|
|
40
59
|
data: DeviceData;
|
|
41
60
|
ts: number;
|
|
42
61
|
}>;
|
|
43
62
|
}
|
|
44
|
-
export interface PairingState {
|
|
45
|
-
capabilities?: Array<CapabilityData>;
|
|
46
|
-
interfaces?: Array<EnrichedInterfaceSetting>;
|
|
47
|
-
canStartRide?: boolean;
|
|
48
|
-
adapters?: Array<AdapterRideInfo>;
|
|
49
|
-
}
|
|
50
63
|
export interface DeviceSelectState {
|
|
51
64
|
capability: IncyclistCapability;
|
|
52
65
|
devices: Array<DevicePairingData>;
|
|
File without changes
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { DeviceAccessService } from "../access/service";
|
|
3
|
-
import { CapabilityInformation, DeviceConfigurationInfo, DeviceConfigurationService, IncyclistDeviceSettings, InterfaceSetting } from "../configuration";
|
|
4
|
-
import { CapabilityData, DevicePairingData, DevicePairingStatus, DeviceSelectState,
|
|
3
|
+
import { AdapterInfo, CapabilityInformation, DeviceConfigurationInfo, DeviceConfigurationService, IncyclistDeviceSettings, InterfaceSetting } from "../configuration";
|
|
4
|
+
import { CapabilityData, DevicePairingData, DevicePairingStatus, DeviceSelectState, InternalPairingState, PairingProps, PairingSettings, PairingState } from "./model";
|
|
5
5
|
import { EventLogger } from 'gd-eventlog';
|
|
6
|
-
import { DeviceData, IncyclistCapability } from "incyclist-devices";
|
|
7
|
-
import {
|
|
6
|
+
import { DeviceData, IncyclistCapability, IncyclistDeviceAdapter } from "incyclist-devices";
|
|
7
|
+
import { AdapterStateInfo, DeviceRideService } from "../ride";
|
|
8
8
|
import EventEmitter from "events";
|
|
9
9
|
export declare const mappedCapability: (c: CapabilityInformation) => CapabilityData;
|
|
10
10
|
export declare const mappedCapabilities: (capabilities: DeviceConfigurationInfo) => Array<CapabilityData>;
|
|
@@ -18,16 +18,15 @@ export declare class DevicePairingService extends EventEmitter {
|
|
|
18
18
|
protected configuration: DeviceConfigurationService;
|
|
19
19
|
protected access: DeviceAccessService;
|
|
20
20
|
protected rideService: DeviceRideService;
|
|
21
|
-
protected initialized: boolean;
|
|
22
21
|
protected logger: EventLogger;
|
|
23
22
|
protected debug: any;
|
|
24
|
-
protected pairingInfo: PairingInfo;
|
|
25
23
|
protected settings: PairingSettings;
|
|
26
|
-
protected state:
|
|
24
|
+
protected state: InternalPairingState;
|
|
25
|
+
protected deviceSelectState: DeviceSelectState | null;
|
|
27
26
|
protected onPairingStartedHandler: any;
|
|
28
27
|
protected onPairingSuccessHandler: any;
|
|
29
28
|
protected onPairingErrorHandler: any;
|
|
30
|
-
protected
|
|
29
|
+
protected onDeviceDataHandler: any;
|
|
31
30
|
protected onScanningDataHandler: any;
|
|
32
31
|
protected onInterfaceConfigChangedHandler: any;
|
|
33
32
|
protected onConfigurationUpdateHandler: any;
|
|
@@ -36,12 +35,16 @@ export declare class DevicePairingService extends EventEmitter {
|
|
|
36
35
|
static getInstance(): DevicePairingService;
|
|
37
36
|
constructor(services?: Services);
|
|
38
37
|
start(onStateChanged: (newState: PairingState) => void): Promise<void>;
|
|
38
|
+
protected initConfigHandlers(): void;
|
|
39
|
+
protected removeConfigHandlers(): void;
|
|
39
40
|
stop(): Promise<void>;
|
|
40
41
|
startDeviceSelection(capability: IncyclistCapability, onDeviceSelectStateChanged: (newState: DeviceSelectState) => void): DeviceSelectState;
|
|
41
42
|
stopDeviceSelection(): Promise<void>;
|
|
42
43
|
selectDevice(capability: IncyclistCapability, udid: string, addAll?: boolean): Promise<void>;
|
|
43
|
-
|
|
44
|
+
deleteDevice(capability: IncyclistCapability, udid: string, deleteAll?: boolean): Promise<void>;
|
|
44
45
|
changeInterfaceSettings(name: string, settings: InterfaceSetting): Promise<void>;
|
|
46
|
+
private restart;
|
|
47
|
+
protected _stop(): Promise<void>;
|
|
45
48
|
protected logEvent(event: any): void;
|
|
46
49
|
protected setDebug(enabled: boolean): void;
|
|
47
50
|
protected logError(err: Error, fn: string): void;
|
|
@@ -49,7 +52,7 @@ export declare class DevicePairingService extends EventEmitter {
|
|
|
49
52
|
protected getCapabilityDevice(capability: IncyclistCapability | CapabilityData, udid?: string): DevicePairingData;
|
|
50
53
|
protected onConfigLoaded(capabilitiesLoaded: DeviceConfigurationInfo, interfacesLoaded: Array<InterfaceSetting>): Promise<void>;
|
|
51
54
|
protected waitForInit(): Promise<void>;
|
|
52
|
-
protected
|
|
55
|
+
protected getExternaState(toEmit: PairingState): PairingState;
|
|
53
56
|
protected emitStateChange(newState?: PairingState): void;
|
|
54
57
|
protected onInterfaceConfigChanged(ifName: string, settings: InterfaceSetting): void;
|
|
55
58
|
protected mergeState(current: any, newState: any): void;
|
|
@@ -63,26 +66,43 @@ export declare class DevicePairingService extends EventEmitter {
|
|
|
63
66
|
protected removeScanningCallbacks(): void;
|
|
64
67
|
protected onPairingStatusUpdate(udid: string, connectState: DevicePairingStatus, notify?: boolean): void;
|
|
65
68
|
protected onPairingStarted(): void;
|
|
69
|
+
protected checkDevicePairingState(): any[];
|
|
66
70
|
protected onPairingSuccess(info: AdapterStateInfo | string): void;
|
|
67
71
|
protected onPairingError(info: AdapterStateInfo | string): void;
|
|
68
72
|
protected verifyNoRecentData(data: DeviceData, udid: string): boolean;
|
|
69
|
-
protected
|
|
73
|
+
protected onDeviceData(data: DeviceData, udid: string): void;
|
|
70
74
|
protected onDeviceDetected(deviceSettings: IncyclistDeviceSettings): void;
|
|
75
|
+
private markConnected;
|
|
71
76
|
protected disconnectInterface(name: string): void;
|
|
72
|
-
protected disableInterfaceInCapabilities(name: string): boolean;
|
|
73
77
|
protected connectInterface(name: string): void;
|
|
74
|
-
protected enableInterfaceInCapabilities(name: string): boolean;
|
|
75
78
|
protected checkCanStart(): boolean;
|
|
76
79
|
protected checkPairingSuccess(): boolean;
|
|
80
|
+
private stopScanning;
|
|
81
|
+
private stopPairing;
|
|
77
82
|
protected run(props?: PairingProps): Promise<void>;
|
|
83
|
+
private startPairing;
|
|
84
|
+
private processConnectedDevices;
|
|
85
|
+
private startScanning;
|
|
86
|
+
protected deregisterScanningDataHandlers(): void;
|
|
87
|
+
protected cleanupScan(): void;
|
|
78
88
|
protected getPairingRetryDelay(): number;
|
|
79
|
-
protected
|
|
80
|
-
protected
|
|
81
|
-
protected
|
|
82
|
-
protected
|
|
89
|
+
protected getScanDelay(): number;
|
|
90
|
+
protected pauseScanDelay(): Promise<boolean>;
|
|
91
|
+
protected getAdaptersOnInterface(ifaceName: string): AdapterInfo[];
|
|
92
|
+
protected stopAdaptersOnInterface(ifaceName: string, maxRetry?: number): Promise<void>;
|
|
93
|
+
protected disableAdaptersOnInterface(name: string): void;
|
|
94
|
+
protected failAdaptersOnInterface(name: string): void;
|
|
95
|
+
protected enableAdaptersOnInterface(name: string): void;
|
|
96
|
+
protected getDeviceAdapter(udid: string): IncyclistDeviceAdapter;
|
|
97
|
+
protected stopAdaptersWithCapability(capability: IncyclistCapability | CapabilityData, udid?: string): Promise<void>;
|
|
98
|
+
protected pauseAdapters(adapters: AdapterInfo[], enforced?: boolean): void;
|
|
83
99
|
protected getDeviceSelectionState(): DeviceSelectState;
|
|
84
100
|
protected emitDeviceSelectState(c: CapabilityData): void;
|
|
85
|
-
protected selectCapabilityDevice(capability: IncyclistCapability, udid: string):
|
|
86
|
-
protected deleteCapabilityDevice(capability: IncyclistCapability, udid: string): void;
|
|
101
|
+
protected selectCapabilityDevice(capability: IncyclistCapability, udid: string, emitUpdate?: boolean): boolean;
|
|
102
|
+
protected deleteCapabilityDevice(capability: IncyclistCapability, udid: string, shouldEmit?: boolean): void;
|
|
103
|
+
protected isScanning(): boolean;
|
|
104
|
+
protected isPairing(): boolean;
|
|
105
|
+
protected _stopDeviceSelection(changed: boolean): Promise<void>;
|
|
106
|
+
private numberOfSelectedCababilities;
|
|
87
107
|
}
|
|
88
108
|
export declare const useDevicePairing: () => DevicePairingService;
|