incyclist-services 1.0.37 → 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/lib/devices/access/service.js +0 -3
- package/lib/devices/configuration/service.d.ts +5 -2
- package/lib/devices/configuration/service.js +75 -28
- package/lib/devices/pairing/model.d.ts +27 -14
- package/lib/devices/pairing/service.d.ts +39 -19
- package/lib/devices/pairing/service.js +454 -273
- package/package.json +12 -11
- package/lib/devices/access/index.js.map +0 -1
- package/lib/devices/access/mock.js.map +0 -1
- package/lib/devices/access/model.js.map +0 -1
- package/lib/devices/access/service.js.map +0 -1
- package/lib/devices/configuration/index.js.map +0 -1
- package/lib/devices/configuration/mock.js.map +0 -1
- package/lib/devices/configuration/model/app/index.js.map +0 -1
- package/lib/devices/configuration/model/index.js.map +0 -1
- package/lib/devices/configuration/model/repository/index.js.map +0 -1
- package/lib/devices/configuration/model/repository/legacy.js.map +0 -1
- package/lib/devices/configuration/model/service/index.js.map +0 -1
- package/lib/devices/configuration/service.js.map +0 -1
- package/lib/devices/consume/service.js +0 -19
- package/lib/devices/index.js.map +0 -1
- package/lib/devices/pairing/index.js.map +0 -1
- package/lib/devices/pairing/model.js.map +0 -1
- package/lib/devices/pairing/service.js.map +0 -1
- package/lib/devices/ride/index.js.map +0 -1
- package/lib/devices/ride/model.js.map +0 -1
- package/lib/devices/ride/service.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/settings/index.js.map +0 -1
- package/lib/settings/user/bindings/index.js.map +0 -1
- package/lib/settings/user/bindings/json.js.map +0 -1
- package/lib/settings/user/bindings/types.js.map +0 -1
- package/lib/settings/user/mock.js.map +0 -1
- package/lib/settings/user/service.js.map +0 -1
- package/lib/utils/clone.js.map +0 -1
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/logging.js.map +0 -1
- package/lib/utils/merge.js.map +0 -1
- package/lib/utils/sleep.js.map +0 -1
- package/lib/utils/valid.js.map +0 -1
|
@@ -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');
|
|
@@ -418,7 +416,6 @@ class DeviceAccessService extends events_1.default {
|
|
|
418
416
|
const remaining = selectedInterfaces.filter(i => interfaceFilter.includes(i));
|
|
419
417
|
interfaces = remaining.map(name => this.interfaces[name].interface);
|
|
420
418
|
}
|
|
421
|
-
console.log('~~getINterfacesForScan', filter, interfaces);
|
|
422
419
|
return interfaces;
|
|
423
420
|
}
|
|
424
421
|
}
|
|
@@ -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,11 +99,19 @@ 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.
|
|
105
|
-
if (isNewUi)
|
|
107
|
+
const isNewUi = this.isNewUi();
|
|
108
|
+
if (isNewUi) {
|
|
109
|
+
const bikeCapIdx = capabilities.findIndex(c => c.capability === 'bike');
|
|
110
|
+
if (bikeCapIdx !== -1) {
|
|
111
|
+
capabilities.splice(bikeCapIdx, 1);
|
|
112
|
+
}
|
|
106
113
|
return;
|
|
114
|
+
}
|
|
107
115
|
for (const capability of ['bike', incyclist_devices_1.IncyclistCapability.Control]) {
|
|
108
116
|
const info = capabilities.find(c => c.capability === capability);
|
|
109
117
|
if (info && info.devices.length > 0 && info.selected === undefined)
|
|
@@ -144,11 +152,16 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
154
|
initCapabilties() {
|
|
155
|
+
const isNewUi = this.isNewUi();
|
|
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];
|
|
157
|
+
if (!isNewUi) {
|
|
158
|
+
target.push('bike');
|
|
159
|
+
}
|
|
147
160
|
if (!this.settings)
|
|
148
161
|
this.settings = {};
|
|
149
162
|
if (!this.settings.capabilities)
|
|
150
163
|
this.settings.capabilities = [];
|
|
151
|
-
|
|
164
|
+
target.forEach(capability => {
|
|
152
165
|
if (!this.settings.capabilities.find(c => c.capability === capability))
|
|
153
166
|
this.settings.capabilities.push({ capability, devices: [], selected: undefined, disabled: false });
|
|
154
167
|
});
|
|
@@ -172,6 +185,11 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
172
185
|
var _a, _b, _c, _d, _e;
|
|
173
186
|
const { gearSelection, connections, modeSettings = {} } = settings;
|
|
174
187
|
this.logEvent({ message: 'converting settings.json', gearSelection, connections });
|
|
188
|
+
const isNewUi = this.isNewUi();
|
|
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];
|
|
190
|
+
if (!isNewUi) {
|
|
191
|
+
all.push('bike');
|
|
192
|
+
}
|
|
175
193
|
const gears = (0, clone_1.default)(gearSelection || {});
|
|
176
194
|
const { bikes = [], hrms = [] } = gears;
|
|
177
195
|
this.settings = { interfaces: [], devices: [], capabilities: [] };
|
|
@@ -221,12 +239,13 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
221
239
|
}
|
|
222
240
|
this.adapters[udid] = adapter;
|
|
223
241
|
}
|
|
224
|
-
|
|
242
|
+
const target = all.filter(c => c !== incyclist_devices_1.IncyclistCapability.HeartRate);
|
|
243
|
+
target.forEach((cc) => {
|
|
225
244
|
if (cc !== incyclist_devices_1.IncyclistCapability.Control || adapter.hasCapability(cc))
|
|
226
245
|
this.addToCapability(udid, cc);
|
|
227
246
|
if (isSelected) {
|
|
228
247
|
const cap = cc;
|
|
229
|
-
if (cap === 'bike' || adapter.hasCapability(cap)) {
|
|
248
|
+
if ((!isNewUi && cap === 'bike') || adapter.hasCapability(cap)) {
|
|
230
249
|
const selectedDevice = capabilities.find(c => c.capability === cap);
|
|
231
250
|
selectedDevice.selected = udid;
|
|
232
251
|
}
|
|
@@ -350,9 +369,10 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
350
369
|
this.emitCapabiltyChanged();
|
|
351
370
|
}
|
|
352
371
|
select(udid, capability, props) {
|
|
353
|
-
var _a, _b, _c
|
|
372
|
+
var _a, _b, _c;
|
|
354
373
|
this.logEvent({ message: 'select device', udid, capability, props });
|
|
355
|
-
const
|
|
374
|
+
const isNewUi = this.isNewUi();
|
|
375
|
+
const { noRecursive = false, legacy = false, emit = true } = props || {};
|
|
356
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;
|
|
357
377
|
if (!deviceSettings)
|
|
358
378
|
return;
|
|
@@ -361,24 +381,30 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
361
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(',') });
|
|
362
382
|
return;
|
|
363
383
|
}
|
|
364
|
-
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();
|
|
365
391
|
return;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
delete capSettings.disabled;
|
|
392
|
+
}
|
|
393
|
+
if ((capability === 'bike') && !adapter.isControllable())
|
|
394
|
+
return;
|
|
395
|
+
const isControl = adapter.hasCapability(incyclist_devices_1.IncyclistCapability.Control) || (legacy && !isNewUi && capability === 'bike');
|
|
396
|
+
this.selectSingleDevice(udid, capability);
|
|
372
397
|
this.emitCapabiltyChanged(capability);
|
|
373
398
|
if (noRecursive)
|
|
374
399
|
return;
|
|
375
400
|
if (isControl) {
|
|
376
401
|
if (capability !== 'bike' && capability !== incyclist_devices_1.IncyclistCapability.Control) {
|
|
377
|
-
|
|
402
|
+
if (!isNewUi)
|
|
403
|
+
this.select(udid, 'bike', { noRecursive: true, legacy });
|
|
378
404
|
this.select(udid, incyclist_devices_1.IncyclistCapability.Control, { noRecursive: true, legacy });
|
|
379
405
|
}
|
|
380
406
|
else {
|
|
381
|
-
if (capability === 'bike' && isControl) {
|
|
407
|
+
if (!isNewUi && capability === 'bike' && isControl) {
|
|
382
408
|
this.select(udid, incyclist_devices_1.IncyclistCapability.Control, { noRecursive: true, legacy });
|
|
383
409
|
this.select(udid, incyclist_devices_1.IncyclistCapability.Power, { noRecursive: true, legacy });
|
|
384
410
|
if (legacy) {
|
|
@@ -406,13 +432,21 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
406
432
|
});
|
|
407
433
|
}
|
|
408
434
|
}
|
|
409
|
-
else if (!isControl && capability === 'bike') {
|
|
435
|
+
else if (!isControl && !isNewUi && capability === 'bike') {
|
|
410
436
|
this.unselect(incyclist_devices_1.IncyclistCapability.Control);
|
|
411
437
|
this.select(udid, incyclist_devices_1.IncyclistCapability.Power, { noRecursive: true, legacy });
|
|
412
438
|
}
|
|
413
439
|
this.updateUserSettings();
|
|
414
440
|
}
|
|
415
|
-
|
|
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) {
|
|
416
450
|
this.logEvent({ message: 'unselect device', capability });
|
|
417
451
|
if (!this.settings || !this.settings.capabilities)
|
|
418
452
|
return;
|
|
@@ -420,11 +454,13 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
420
454
|
if (settings) {
|
|
421
455
|
settings.selected = null;
|
|
422
456
|
this.updateUserSettings();
|
|
423
|
-
|
|
457
|
+
if (shouldEmit)
|
|
458
|
+
this.emitCapabiltyChanged(settings.capability);
|
|
424
459
|
}
|
|
425
460
|
}
|
|
426
461
|
add(deviceSettings, props) {
|
|
427
462
|
var _a, _b;
|
|
463
|
+
const isNewUi = this.isNewUi();
|
|
428
464
|
let udid = this.getUdid(deviceSettings);
|
|
429
465
|
const { legacy = false } = props || {};
|
|
430
466
|
this.logEvent({ message: 'add device', udid, deviceSettings, legacy });
|
|
@@ -449,10 +485,10 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
449
485
|
this.initCapabilties();
|
|
450
486
|
this.settings.capabilities.forEach(c => {
|
|
451
487
|
if (c.devices.includes(udid))
|
|
452
|
-
return;
|
|
488
|
+
return udid;
|
|
453
489
|
const isBike = adapter.hasCapability(incyclist_devices_1.IncyclistCapability.Control);
|
|
454
490
|
const isPower = adapter.hasCapability(incyclist_devices_1.IncyclistCapability.Power);
|
|
455
|
-
if (legacy) {
|
|
491
|
+
if (legacy && !isNewUi) {
|
|
456
492
|
const isBikeCap = c.capability === 'bike';
|
|
457
493
|
const isControlCap = c.capability === incyclist_devices_1.IncyclistCapability.Control;
|
|
458
494
|
const isHrmCap = c.capability === incyclist_devices_1.IncyclistCapability.HeartRate;
|
|
@@ -470,7 +506,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
470
506
|
}
|
|
471
507
|
}
|
|
472
508
|
else {
|
|
473
|
-
if (adapter.hasCapability(c.capability) || (c.capability === 'bike' && (isBike || isPower))) {
|
|
509
|
+
if (adapter.hasCapability(c.capability) || (!isNewUi && c.capability === 'bike' && (isBike || isPower))) {
|
|
474
510
|
c.devices.push(udid);
|
|
475
511
|
if (!c.selected && !c.disabled && (isBike || c.capability === incyclist_devices_1.IncyclistCapability.HeartRate))
|
|
476
512
|
c.selected = udid;
|
|
@@ -491,7 +527,6 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
491
527
|
const singleDelete = capability && ((capability !== 'bike' && capability !== incyclist_devices_1.IncyclistCapability.Control) || forceSingle);
|
|
492
528
|
if (singleDelete) {
|
|
493
529
|
const record = capabilities.find(c => c.capability === capability);
|
|
494
|
-
console.log('~~~ record', record);
|
|
495
530
|
if (record) {
|
|
496
531
|
const deviceIdx = record.devices.findIndex(d => d === udid);
|
|
497
532
|
if (record.selected === udid) {
|
|
@@ -505,10 +540,8 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
505
540
|
}
|
|
506
541
|
}
|
|
507
542
|
if (deviceIdx !== -1) {
|
|
508
|
-
console.log('~~~ remove device', deviceIdx);
|
|
509
543
|
record.devices.splice(deviceIdx, 1);
|
|
510
544
|
if (forceSingle) {
|
|
511
|
-
console.log('~~~ emit Update', deviceIdx);
|
|
512
545
|
this.emitCapabiltyChanged(capability);
|
|
513
546
|
this.updateUserSettings();
|
|
514
547
|
}
|
|
@@ -540,6 +573,9 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
540
573
|
}
|
|
541
574
|
}
|
|
542
575
|
addToCapability(udid, capability) {
|
|
576
|
+
const isNewUi = this.isNewUi();
|
|
577
|
+
if (isNewUi && capability === 'bike')
|
|
578
|
+
return;
|
|
543
579
|
if (!this.settings)
|
|
544
580
|
this.settings = {};
|
|
545
581
|
if (!this.settings.capabilities)
|
|
@@ -587,7 +623,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
587
623
|
this.userSettings.set('interfaces', this.settings.interfaces);
|
|
588
624
|
}
|
|
589
625
|
canStartRide() {
|
|
590
|
-
const isNewUi = this.
|
|
626
|
+
const isNewUi = this.isNewUi();
|
|
591
627
|
const { devices, capabilities } = this.settings || {};
|
|
592
628
|
if (!devices || !capabilities)
|
|
593
629
|
return false;
|
|
@@ -623,7 +659,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
623
659
|
modes = adapter.getSupportedCyclingModes();
|
|
624
660
|
if (!mode) {
|
|
625
661
|
modeObj = adapter.getDefaultCyclingMode();
|
|
626
|
-
mode = modeObj.getName();
|
|
662
|
+
mode = modeObj === null || modeObj === void 0 ? void 0 : modeObj.getName();
|
|
627
663
|
}
|
|
628
664
|
}
|
|
629
665
|
settings = (device.modes ? device.modes[mode] : undefined) || {};
|
|
@@ -668,7 +704,18 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
668
704
|
emitModeChanged(udid, mode, settings) {
|
|
669
705
|
this.emit('mode-changed', udid, mode, settings);
|
|
670
706
|
}
|
|
671
|
-
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
|
+
}
|
|
672
719
|
const { capabilities, devices } = this.settings || {};
|
|
673
720
|
const adapters = [];
|
|
674
721
|
capabilities.forEach(c => {
|
|
@@ -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>;
|
|
@@ -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;
|