incyclist-services 1.9.4 → 1.9.6
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/cjs/activities/active-rides/service.js +7 -7
- package/lib/cjs/activities/base/convert/fit/local-fit.js +4 -4
- package/lib/cjs/activities/base/repo/db.js +5 -5
- package/lib/cjs/activities/base/utils/activity.js +1 -1
- package/lib/cjs/activities/list/service.js +8 -7
- package/lib/cjs/activities/page/service.js +2 -2
- package/lib/cjs/activities/ride/service.js +12 -11
- package/lib/cjs/api/repository/json/index.js +1 -1
- package/lib/cjs/base/types/observer.js +1 -1
- package/lib/cjs/coaches/service.js +48 -29
- package/lib/cjs/devices/access/service.js +2 -2
- package/lib/cjs/devices/configuration/service.js +2 -2
- package/lib/cjs/devices/page/base/service.js +10 -7
- package/lib/cjs/devices/pairing/service.js +36 -27
- package/lib/cjs/devices/ride/service.js +4 -4
- package/lib/cjs/ride/base/base.js +4 -4
- package/lib/cjs/ride/display/service.js +12 -11
- package/lib/cjs/ride/page/service.js +4 -4
- package/lib/cjs/ride/route/FreeRideDisplayService.js +7 -6
- package/lib/cjs/ride/route/GpxDisplayService.js +10 -2
- package/lib/cjs/ride/route/RLVDisplayService.js +34 -4
- package/lib/cjs/ride/route/RouteDisplayService.js +1 -1
- package/lib/cjs/routes/base/parsers/gpx.js +2 -2
- package/lib/cjs/routes/download/service.js +2 -2
- package/lib/cjs/routes/free-ride/service.js +2 -2
- package/lib/cjs/routes/list/cards/RouteCard.js +12 -12
- package/lib/cjs/routes/list/loaders/DBLoader.js +1 -1
- package/lib/cjs/routes/list/loaders/StravaActivityLoader.js +1 -1
- package/lib/cjs/routes/list/loaders/api.js +5 -5
- package/lib/cjs/routes/list/loaders/db.js +11 -8
- package/lib/cjs/routes/list/loaders/types.js +1 -1
- package/lib/cjs/routes/list/service.js +27 -23
- package/lib/cjs/routes/page/service.js +2 -2
- package/lib/cjs/routes/sync/factory.js +2 -2
- package/lib/cjs/routes/sync/komoot/provider.js +3 -3
- package/lib/cjs/settings/service/service.js +3 -3
- package/lib/cjs/ui/service.js +6 -6
- package/lib/cjs/video/VideoConversion.js +13 -4
- package/lib/cjs/video/audio.js +14 -0
- package/lib/cjs/video/index.js +1 -0
- package/lib/cjs/workouts/calendar/service.js +3 -3
- package/lib/cjs/workouts/calendar/sync/factory.js +2 -2
- package/lib/cjs/workouts/calendar/sync/intervals/provider.js +2 -2
- package/lib/cjs/workouts/list/cards/ActiveImportCard.js +1 -1
- package/lib/cjs/workouts/list/cards/WorkoutCard.js +3 -3
- package/lib/cjs/workouts/list/loaders/api.js +3 -3
- package/lib/cjs/workouts/list/loaders/db.js +4 -4
- package/lib/cjs/workouts/list/service.js +2 -2
- package/lib/cjs/workouts/ride/service.js +14 -13
- package/lib/esm/activities/active-rides/service.js +7 -7
- package/lib/esm/activities/base/convert/fit/local-fit.js +4 -4
- package/lib/esm/activities/base/repo/db.js +5 -5
- package/lib/esm/activities/base/utils/activity.js +1 -1
- package/lib/esm/activities/list/service.js +8 -7
- package/lib/esm/activities/page/service.js +2 -2
- package/lib/esm/activities/ride/service.js +12 -11
- package/lib/esm/api/repository/json/index.js +1 -1
- package/lib/esm/base/types/observer.js +1 -1
- package/lib/esm/coaches/service.js +48 -29
- package/lib/esm/devices/access/service.js +2 -2
- package/lib/esm/devices/configuration/service.js +2 -2
- package/lib/esm/devices/page/base/service.js +10 -7
- package/lib/esm/devices/pairing/service.js +36 -27
- package/lib/esm/devices/ride/service.js +4 -4
- package/lib/esm/ride/base/base.js +4 -4
- package/lib/esm/ride/display/service.js +12 -11
- package/lib/esm/ride/page/service.js +4 -4
- package/lib/esm/ride/route/FreeRideDisplayService.js +7 -6
- package/lib/esm/ride/route/GpxDisplayService.js +10 -2
- package/lib/esm/ride/route/RLVDisplayService.js +35 -5
- package/lib/esm/ride/route/RouteDisplayService.js +1 -1
- package/lib/esm/routes/base/parsers/gpx.js +2 -2
- package/lib/esm/routes/download/service.js +2 -2
- package/lib/esm/routes/free-ride/service.js +2 -2
- package/lib/esm/routes/list/cards/RouteCard.js +12 -12
- package/lib/esm/routes/list/loaders/DBLoader.js +1 -1
- package/lib/esm/routes/list/loaders/StravaActivityLoader.js +1 -1
- package/lib/esm/routes/list/loaders/api.js +5 -5
- package/lib/esm/routes/list/loaders/db.js +11 -8
- package/lib/esm/routes/list/loaders/types.js +1 -1
- package/lib/esm/routes/list/service.js +27 -23
- package/lib/esm/routes/page/service.js +2 -2
- package/lib/esm/routes/sync/factory.js +2 -2
- package/lib/esm/routes/sync/komoot/provider.js +3 -3
- package/lib/esm/settings/service/service.js +3 -3
- package/lib/esm/ui/service.js +6 -6
- package/lib/esm/video/VideoConversion.js +13 -4
- package/lib/esm/video/audio.js +10 -0
- package/lib/esm/video/index.js +1 -0
- package/lib/esm/workouts/calendar/service.js +3 -3
- package/lib/esm/workouts/calendar/sync/factory.js +2 -2
- package/lib/esm/workouts/calendar/sync/intervals/provider.js +2 -2
- package/lib/esm/workouts/list/cards/ActiveImportCard.js +1 -1
- package/lib/esm/workouts/list/cards/WorkoutCard.js +3 -3
- package/lib/esm/workouts/list/loaders/api.js +3 -3
- package/lib/esm/workouts/list/loaders/db.js +4 -4
- package/lib/esm/workouts/list/service.js +2 -2
- package/lib/esm/workouts/ride/service.js +14 -13
- package/lib/types/api/video/index.d.ts +1 -0
- package/lib/types/coaches/service.d.ts +4 -2
- package/lib/types/devices/pairing/service.d.ts +2 -1
- package/lib/types/devices/types.d.ts +1 -0
- package/lib/types/ride/route/GpxDisplayService.d.ts +1 -0
- package/lib/types/ride/route/RLVDisplayService.d.ts +5 -0
- package/lib/types/video/VideoConversion.d.ts +3 -2
- package/lib/types/video/audio.d.ts +4 -0
- package/lib/types/video/index.d.ts +1 -0
- package/lib/types/video/types.d.ts +3 -0
- package/package.json +2 -2
|
@@ -53,20 +53,26 @@ let CoachesService = (() => {
|
|
|
53
53
|
let _classThis;
|
|
54
54
|
let _classSuper = IncyclistService;
|
|
55
55
|
let _instanceExtraInitializers = [];
|
|
56
|
+
let _getRouteList_decorators;
|
|
56
57
|
let _getDeviceRide_decorators;
|
|
57
58
|
let _getRideDisplay_decorators;
|
|
59
|
+
let _getUserSettings_decorators;
|
|
58
60
|
let _getUnitConverter_decorators;
|
|
59
61
|
let _getActivityRide_decorators;
|
|
60
62
|
var CoachesService = class extends _classSuper {
|
|
61
63
|
static { _classThis = this; }
|
|
62
64
|
static {
|
|
63
65
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
66
|
+
_getRouteList_decorators = [Injectable];
|
|
64
67
|
_getDeviceRide_decorators = [Injectable];
|
|
65
68
|
_getRideDisplay_decorators = [Injectable];
|
|
69
|
+
_getUserSettings_decorators = [Injectable];
|
|
66
70
|
_getUnitConverter_decorators = [Injectable];
|
|
67
71
|
_getActivityRide_decorators = [Injectable];
|
|
72
|
+
__esDecorate(this, null, _getRouteList_decorators, { kind: "method", name: "getRouteList", static: false, private: false, access: { has: obj => "getRouteList" in obj, get: obj => obj.getRouteList }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
68
73
|
__esDecorate(this, null, _getDeviceRide_decorators, { kind: "method", name: "getDeviceRide", static: false, private: false, access: { has: obj => "getDeviceRide" in obj, get: obj => obj.getDeviceRide }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
69
74
|
__esDecorate(this, null, _getRideDisplay_decorators, { kind: "method", name: "getRideDisplay", static: false, private: false, access: { has: obj => "getRideDisplay" in obj, get: obj => obj.getRideDisplay }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
75
|
+
__esDecorate(this, null, _getUserSettings_decorators, { kind: "method", name: "getUserSettings", static: false, private: false, access: { has: obj => "getUserSettings" in obj, get: obj => obj.getUserSettings }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
70
76
|
__esDecorate(this, null, _getUnitConverter_decorators, { kind: "method", name: "getUnitConverter", static: false, private: false, access: { has: obj => "getUnitConverter" in obj, get: obj => obj.getUnitConverter }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
71
77
|
__esDecorate(this, null, _getActivityRide_decorators, { kind: "method", name: "getActivityRide", static: false, private: false, access: { has: obj => "getActivityRide" in obj, get: obj => obj.getActivityRide }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
72
78
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
@@ -130,7 +136,7 @@ let CoachesService = (() => {
|
|
|
130
136
|
this.route = route;
|
|
131
137
|
const onDataUpdate = this.onCoachDataUpdate.bind(this);
|
|
132
138
|
this.coaches.forEach(c => {
|
|
133
|
-
const startSettings = this.
|
|
139
|
+
const startSettings = this.getStartSettings();
|
|
134
140
|
let pos = 0;
|
|
135
141
|
if (startSettings.type === 'Route') {
|
|
136
142
|
pos = startSettings.startPos;
|
|
@@ -140,11 +146,11 @@ let CoachesService = (() => {
|
|
|
140
146
|
c.setProgress(lead + pos);
|
|
141
147
|
c.setRiderPosition(pos);
|
|
142
148
|
this.setCoachPosition(c, lead + pos);
|
|
143
|
-
const user = this.
|
|
149
|
+
const user = this.getUserSettings().get('user', {});
|
|
144
150
|
const mode = this.getDeviceRide().getCyclingMode();
|
|
145
151
|
const bikeType = mode?.getSetting('bikeType') ?? 'Race';
|
|
146
152
|
c.initSimulator(user, bikeType);
|
|
147
|
-
c.start(onDataUpdate);
|
|
153
|
+
c.start(onDataUpdate).catch(err => { this.logError(err, 'startRide'); });
|
|
148
154
|
});
|
|
149
155
|
const setupListeners = (userRide) => {
|
|
150
156
|
userRide.on('data', this.onUserDataUpdate.bind(this));
|
|
@@ -168,9 +174,10 @@ let CoachesService = (() => {
|
|
|
168
174
|
}
|
|
169
175
|
};
|
|
170
176
|
waitNextTick().then(() => {
|
|
171
|
-
link();
|
|
172
177
|
this.observer.emit('started');
|
|
173
|
-
|
|
178
|
+
return link();
|
|
179
|
+
})
|
|
180
|
+
.catch(err => { this.logError(err, 'startRide'); });
|
|
174
181
|
}
|
|
175
182
|
catch (err) {
|
|
176
183
|
this.logError(err, 'startRide');
|
|
@@ -233,36 +240,48 @@ let CoachesService = (() => {
|
|
|
233
240
|
onCoachDataUpdate(coach, data) {
|
|
234
241
|
if (this.isPaused)
|
|
235
242
|
return;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
try {
|
|
244
|
+
const startSettings = this.getStartSettings();
|
|
245
|
+
const route = this.route;
|
|
246
|
+
if (!route || !coach || !data)
|
|
247
|
+
return;
|
|
248
|
+
const { distance } = data;
|
|
249
|
+
const prevRouteDistance = coach.getProgess() ?? 0;
|
|
250
|
+
const newRouteDistance = prevRouteDistance + distance;
|
|
251
|
+
coach.setProgress(newRouteDistance);
|
|
252
|
+
if (startSettings.type === 'Free-Ride')
|
|
253
|
+
return;
|
|
254
|
+
this.setCoachPosition(coach, distance);
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
this.logError(err, 'onCoachDataUpdate');
|
|
258
|
+
}
|
|
247
259
|
}
|
|
248
260
|
setCoachPosition(coach, distance) {
|
|
249
261
|
if (!this.observer)
|
|
250
262
|
return;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
try {
|
|
264
|
+
const { realityFactor = 0 } = this.getStartSettings();
|
|
265
|
+
const route = this.getRideDisplay().route;
|
|
266
|
+
if (!route)
|
|
267
|
+
return;
|
|
268
|
+
const prevPosition = coach.getPosition() || route.points[0];
|
|
269
|
+
if (distance > 0) {
|
|
270
|
+
const nextPosition = getNextPosition(route, { distance, prev: prevPosition });
|
|
271
|
+
if (nextPosition) {
|
|
272
|
+
const { slope } = nextPosition;
|
|
273
|
+
coach.sendDeviceUpdate({ slope: slope * realityFactor / 100 });
|
|
274
|
+
}
|
|
262
275
|
}
|
|
263
276
|
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
this.logError(err, 'setCoachPosition');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
getStartSettings() {
|
|
282
|
+
return (this.getRouteList().getStartSettings() ?? {});
|
|
264
283
|
}
|
|
265
|
-
|
|
284
|
+
getRouteList() {
|
|
266
285
|
return useRouteList();
|
|
267
286
|
}
|
|
268
287
|
getDeviceRide() {
|
|
@@ -277,7 +296,7 @@ let CoachesService = (() => {
|
|
|
277
296
|
get pairingService() {
|
|
278
297
|
return useDevicePairing();
|
|
279
298
|
}
|
|
280
|
-
|
|
299
|
+
getUserSettings() {
|
|
281
300
|
return useUserSettings();
|
|
282
301
|
}
|
|
283
302
|
getUnitConverter() {
|
|
@@ -120,7 +120,7 @@ let DeviceAccessService = (() => {
|
|
|
120
120
|
info.isScanning = !stopped;
|
|
121
121
|
this.emit('interface-changed', ifaceName, this.interfaces[ifaceName]);
|
|
122
122
|
if (stopped)
|
|
123
|
-
this.disableInterface(ifaceName);
|
|
123
|
+
this.disableInterface(ifaceName).catch(err => { this.logEvent({ message: 'Error', fn: 'disableInterface', error: err.message, stack: err.stack }); });
|
|
124
124
|
}
|
|
125
125
|
catch (err) {
|
|
126
126
|
this.logEvent({ message: 'Error', fn: 'disableInterface', error: err.message, stack: err.stack });
|
|
@@ -198,7 +198,7 @@ let DeviceAccessService = (() => {
|
|
|
198
198
|
if (!ifaceName) {
|
|
199
199
|
const interfaces = Object.keys(this.interfaces);
|
|
200
200
|
interfaces.forEach(name => { if (name)
|
|
201
|
-
this.connect(name); });
|
|
201
|
+
this.connect(name).catch(err => { this.logEvent({ message: 'Error', fn: 'connect', error: err.message, stack: err.stack }); }); });
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
if (this.interfaces[ifaceName]?.enabled === false)
|
|
@@ -137,7 +137,7 @@ let DeviceConfigurationService = (() => {
|
|
|
137
137
|
}
|
|
138
138
|
this.initWifiInterface();
|
|
139
139
|
this.verifyCapabilitySettings();
|
|
140
|
-
this.removeLegacySettings();
|
|
140
|
+
this.removeLegacySettings().catch(err => { this.logError(err, 'init()'); });
|
|
141
141
|
this.logEvent({ message: 'DeviceConfig.init done' });
|
|
142
142
|
this.emitInitialized();
|
|
143
143
|
}
|
|
@@ -648,7 +648,7 @@ let DeviceConfigurationService = (() => {
|
|
|
648
648
|
else
|
|
649
649
|
capabilities.push({ capability: IncyclistCapability.HeartRate, devices: [], selected: undefined, disabled: true });
|
|
650
650
|
}
|
|
651
|
-
this.removeLegacySettings();
|
|
651
|
+
this.removeLegacySettings().catch(err => { this.logError(err, 'init()'); });
|
|
652
652
|
this.settings = { devices, capabilities, interfaces };
|
|
653
653
|
this.updateUserSettings();
|
|
654
654
|
}
|
|
@@ -80,7 +80,7 @@ let PairingPageService = (() => {
|
|
|
80
80
|
return this.getPageObserver();
|
|
81
81
|
}
|
|
82
82
|
const onStateMachineUpdate = () => {
|
|
83
|
-
this.
|
|
83
|
+
this.updatePage();
|
|
84
84
|
};
|
|
85
85
|
this.stateMachine.start(onStateMachineUpdate);
|
|
86
86
|
if (this.stateMachine.state !== 'Idle') {
|
|
@@ -106,11 +106,11 @@ let PairingPageService = (() => {
|
|
|
106
106
|
this.isVisitOpen = false;
|
|
107
107
|
EventLogger.setGlobalConfig('page', null);
|
|
108
108
|
this.isPairingForRide = false;
|
|
109
|
+
void this.stateMachine.stop();
|
|
109
110
|
super.closePage();
|
|
110
111
|
if (!this.handingOffToRide)
|
|
111
112
|
this.stop().catch(err => { this.logError(err, 'closePage'); });
|
|
112
113
|
this.handingOffToRide = false;
|
|
113
|
-
void this.stateMachine.stop();
|
|
114
114
|
}
|
|
115
115
|
catch (err) {
|
|
116
116
|
this.logError(err, 'closePage');
|
|
@@ -209,7 +209,7 @@ let PairingPageService = (() => {
|
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
updatePage() {
|
|
212
|
-
this.getPageObserver()
|
|
212
|
+
this.getPageObserver()?.emit('page-update');
|
|
213
213
|
}
|
|
214
214
|
onEnableCapability(enabled) {
|
|
215
215
|
const all = this.state.capabilities ?? [];
|
|
@@ -227,7 +227,8 @@ let PairingPageService = (() => {
|
|
|
227
227
|
const capability = this.openedCapability;
|
|
228
228
|
this.logEvent({ message: 'device selected', capability, device: d.name });
|
|
229
229
|
this.closeDeviceSelection();
|
|
230
|
-
this.getDevicePairing().selectDevice(capability, d.udid, addAll)
|
|
230
|
+
this.getDevicePairing().selectDevice(capability, d.udid, addAll)
|
|
231
|
+
.catch(err => { this.logError(err, 'onDeviceSelected'); });
|
|
231
232
|
this.updatePage();
|
|
232
233
|
}
|
|
233
234
|
onCapabilityUnselect(cap) {
|
|
@@ -244,13 +245,15 @@ let PairingPageService = (() => {
|
|
|
244
245
|
onDeviceDelete(d) {
|
|
245
246
|
const capability = this.openedCapability;
|
|
246
247
|
this.logEvent({ message: 'device delete requested', capability, device: d.name });
|
|
247
|
-
this.getDevicePairing().deleteDevice(capability, d.udid)
|
|
248
|
+
this.getDevicePairing().deleteDevice(capability, d.udid)
|
|
249
|
+
.catch(err => { this.logError(err, 'onDeviceDelete'); });
|
|
248
250
|
this.updatePage();
|
|
249
251
|
}
|
|
250
252
|
closeDeviceSelection() {
|
|
251
253
|
this.logEvent({ message: 'capability closed', capability: this.openedCapability, caller: new Error().stack });
|
|
252
254
|
this.openedCapability = undefined;
|
|
253
|
-
this.stateMachine.onDeviceSelectionClosed()
|
|
255
|
+
Promise.resolve(this.stateMachine.onDeviceSelectionClosed())
|
|
256
|
+
.catch(err => { this.logError(err, 'closeDeviceSelection'); });
|
|
254
257
|
this.updatePage();
|
|
255
258
|
}
|
|
256
259
|
getButtonsDisplayProps() {
|
|
@@ -358,7 +361,7 @@ let PairingPageService = (() => {
|
|
|
358
361
|
this.getDevicePairing().usage = this.getUsageMode();
|
|
359
362
|
this.getDevicePairing().start(() => {
|
|
360
363
|
this.updatePage();
|
|
361
|
-
});
|
|
364
|
+
}).catch(err => { this.logError(err, 'start'); });
|
|
362
365
|
}
|
|
363
366
|
async stop(adapters = [], forExit = false) {
|
|
364
367
|
return await this.getDevicePairing().stop(adapters, forExit);
|
|
@@ -146,7 +146,7 @@ let DevicePairingService = (() => {
|
|
|
146
146
|
this.emit('page-ready');
|
|
147
147
|
}
|
|
148
148
|
else {
|
|
149
|
-
this.run();
|
|
149
|
+
this.run().catch(err => { this.logError(err, 'start'); });
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
catch (err) {
|
|
@@ -236,7 +236,7 @@ let DevicePairingService = (() => {
|
|
|
236
236
|
const startScan = async () => {
|
|
237
237
|
if (devices.length > 0)
|
|
238
238
|
await this.stopAdaptersWithCapability(capability);
|
|
239
|
-
this.stopPairing();
|
|
239
|
+
this.stopPairing().catch(err => { this.logError(err, 'startDeviceSelection'); });
|
|
240
240
|
this.emitStateChange({ capabilities: this.state.capabilities });
|
|
241
241
|
if (devices.length > 0)
|
|
242
242
|
await this.stopAdaptersWithCapability(capability);
|
|
@@ -244,14 +244,15 @@ let DevicePairingService = (() => {
|
|
|
244
244
|
};
|
|
245
245
|
this.deviceSelectState = { capability, devices: available };
|
|
246
246
|
if (devices.length === 0) {
|
|
247
|
-
startScan();
|
|
247
|
+
startScan().catch(err => { this.logError(err, 'startDeviceSelection'); });
|
|
248
248
|
}
|
|
249
249
|
else {
|
|
250
250
|
this.pauseScanDelay()
|
|
251
251
|
.then(() => {
|
|
252
252
|
if (this.deviceSelectState)
|
|
253
|
-
startScan();
|
|
254
|
-
})
|
|
253
|
+
return startScan();
|
|
254
|
+
})
|
|
255
|
+
.catch(err => { this.logError(err, 'startDeviceSelection'); });
|
|
255
256
|
}
|
|
256
257
|
return this.deviceSelectState;
|
|
257
258
|
}
|
|
@@ -325,7 +326,7 @@ let DevicePairingService = (() => {
|
|
|
325
326
|
const adapater = this.getDeviceConfiguration().getSelected(capability);
|
|
326
327
|
this.getDeviceConfiguration().disableCapability(capability, true);
|
|
327
328
|
if (adapater?.isStarted()) {
|
|
328
|
-
this.restart();
|
|
329
|
+
this.restart().catch(err => { this.logError(err, 'unselectDevices'); });
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
332
|
catch (err) {
|
|
@@ -365,7 +366,7 @@ let DevicePairingService = (() => {
|
|
|
365
366
|
if (this.state.check?.to)
|
|
366
367
|
clearTimeout(this.state.check?.to);
|
|
367
368
|
delete this.state.check;
|
|
368
|
-
this.run();
|
|
369
|
+
this.run().catch(err => { this.logError(err, 'restartPair'); });
|
|
369
370
|
}
|
|
370
371
|
async restart() {
|
|
371
372
|
const wasActive = this.isPairing() || this.isScanning();
|
|
@@ -391,11 +392,11 @@ let DevicePairingService = (() => {
|
|
|
391
392
|
if (wasActive) {
|
|
392
393
|
await this.rideService.stop();
|
|
393
394
|
await sleep(500);
|
|
394
|
-
this.run();
|
|
395
|
+
this.run().catch(err => { this.logError(err, 'restart'); });
|
|
395
396
|
}
|
|
396
397
|
if (this.state.waiting) {
|
|
397
398
|
this.state.waiting = false;
|
|
398
|
-
this.run();
|
|
399
|
+
this.run().catch(err => { this.logError(err, 'restart'); });
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
402
|
async _stop() {
|
|
@@ -453,10 +454,10 @@ let DevicePairingService = (() => {
|
|
|
453
454
|
}
|
|
454
455
|
else {
|
|
455
456
|
this.getDeviceConfiguration().once('initialized', (capabilitiesLoaded, interfacesLoaded) => {
|
|
456
|
-
this.onConfigLoaded(capabilitiesLoaded, interfacesLoaded);
|
|
457
|
+
this.onConfigLoaded(capabilitiesLoaded, interfacesLoaded).catch(err => { this.logError(err, 'waitForInit'); });
|
|
457
458
|
done();
|
|
458
459
|
});
|
|
459
|
-
this.getDeviceConfiguration().init();
|
|
460
|
+
this.getDeviceConfiguration().init().catch(err => { this.logError(err, 'waitForInit'); });
|
|
460
461
|
}
|
|
461
462
|
});
|
|
462
463
|
}
|
|
@@ -546,11 +547,13 @@ let DevicePairingService = (() => {
|
|
|
546
547
|
const current = getInterfaceSettings(ifName, prev);
|
|
547
548
|
if (settings.enabled && !current.enabled) {
|
|
548
549
|
const { port, protocol } = settings;
|
|
549
|
-
this.access.enableInterface(ifName, undefined, { port: Number(port), protocol, autoConnect: true })
|
|
550
|
+
this.access.enableInterface(ifName, undefined, { port: Number(port), protocol, autoConnect: true })
|
|
551
|
+
.catch(err => { this.logError(err, 'onInterfaceConfigChanged()'); });
|
|
550
552
|
this.selectFromInterface(ifName);
|
|
551
553
|
}
|
|
552
554
|
else if (!settings.enabled && current.enabled) {
|
|
553
|
-
this.access.disableInterface(ifName)
|
|
555
|
+
this.access.disableInterface(ifName)
|
|
556
|
+
.catch(err => { this.logError(err, 'onInterfaceConfigChanged()'); });
|
|
554
557
|
this.unselectOnInterface(ifName);
|
|
555
558
|
this.unselectDisabledInterfaces();
|
|
556
559
|
this.stopAdaptersOnInterface(ifName).catch(err => {
|
|
@@ -564,7 +567,7 @@ let DevicePairingService = (() => {
|
|
|
564
567
|
current.port = settings.port;
|
|
565
568
|
current.protocol = settings.protocol;
|
|
566
569
|
this.emitStateChange();
|
|
567
|
-
this.restart();
|
|
570
|
+
this.restart().catch(err => { this.logError(err, 'onInterfaceConfigChanged()'); });
|
|
568
571
|
}
|
|
569
572
|
catch (err) {
|
|
570
573
|
this.logError(err, 'onInterfaceConfigChanged()');
|
|
@@ -626,10 +629,10 @@ let DevicePairingService = (() => {
|
|
|
626
629
|
prev[changedIdx].state = ifDetails.state;
|
|
627
630
|
}
|
|
628
631
|
if (restartScan) {
|
|
629
|
-
this.restart();
|
|
632
|
+
this.restart().catch(err => { this.logError(err, 'onInterfaceStateChanged()'); });
|
|
630
633
|
}
|
|
631
634
|
if (restartPair && this.isInterfaceInUse(ifName)) {
|
|
632
|
-
this.restartPair();
|
|
635
|
+
this.restartPair().catch(err => { this.logError(err, 'onInterfaceStateChanged()'); });
|
|
633
636
|
}
|
|
634
637
|
this.emitStateChange({ interfaces: this.state.interfaces });
|
|
635
638
|
}
|
|
@@ -658,7 +661,7 @@ let DevicePairingService = (() => {
|
|
|
658
661
|
if (pairing.includes(ifName)) {
|
|
659
662
|
current.state = 'disconnected';
|
|
660
663
|
this.emitStateChange({ interfaces: this.state.interfaces });
|
|
661
|
-
this.reconnectInterface(ifName, 1000);
|
|
664
|
+
this.reconnectInterface(ifName, 1000).catch(err => { this.logError(err, 'reconnectInterface'); });
|
|
662
665
|
}
|
|
663
666
|
}
|
|
664
667
|
}
|
|
@@ -722,6 +725,8 @@ let DevicePairingService = (() => {
|
|
|
722
725
|
rideService.off('data', this.onDeviceDataHandler);
|
|
723
726
|
}
|
|
724
727
|
initScanningCallbacks() {
|
|
728
|
+
this.access.off('device', this.onDeviceDetectedHandler);
|
|
729
|
+
this.access.off('data', this.onDeviceDataHandler);
|
|
725
730
|
this.access.on('device', this.onDeviceDetectedHandler);
|
|
726
731
|
this.access.on('data', this.onDeviceDataHandler);
|
|
727
732
|
}
|
|
@@ -730,11 +735,11 @@ let DevicePairingService = (() => {
|
|
|
730
735
|
this.access?.off('data', this.onDeviceDataHandler);
|
|
731
736
|
this.deregisterScanningDataHandlers();
|
|
732
737
|
}
|
|
733
|
-
onPairingStatusUpdate(udid, connectState, notify = true) {
|
|
738
|
+
onPairingStatusUpdate(udid, connectState, notify = true, keepConnectAttempts = false) {
|
|
734
739
|
const capabilities = this.state.capabilities;
|
|
735
740
|
let changed = false;
|
|
736
741
|
capabilities.forEach(c => {
|
|
737
|
-
if (c.selected === udid) {
|
|
742
|
+
if (c.selected === udid && !(keepConnectAttempts && this.isConnectAttemptState(c.connectState))) {
|
|
738
743
|
if (c.connectState !== connectState) {
|
|
739
744
|
c.connectState = connectState;
|
|
740
745
|
changed = true;
|
|
@@ -745,7 +750,7 @@ let DevicePairingService = (() => {
|
|
|
745
750
|
}
|
|
746
751
|
}
|
|
747
752
|
const device = this.getCapabilityDevice(c);
|
|
748
|
-
if (device && device.
|
|
753
|
+
if (device?.udid === udid && !(keepConnectAttempts && this.isConnectAttemptState(device.connectState))) {
|
|
749
754
|
device.connectState = connectState;
|
|
750
755
|
}
|
|
751
756
|
});
|
|
@@ -902,7 +907,7 @@ let DevicePairingService = (() => {
|
|
|
902
907
|
else {
|
|
903
908
|
this.logEvent({ message: 'Could not get adapter', deviceSettings });
|
|
904
909
|
}
|
|
905
|
-
this.
|
|
910
|
+
this.onPairingStatusUpdate(udid, 'connected', true, true);
|
|
906
911
|
}
|
|
907
912
|
catch (err) {
|
|
908
913
|
this.logError(err, 'onDeviceDetected');
|
|
@@ -920,17 +925,21 @@ let DevicePairingService = (() => {
|
|
|
920
925
|
}
|
|
921
926
|
let device = this.getCapabilityDevice(c, udid);
|
|
922
927
|
if (device) {
|
|
923
|
-
device.connectState
|
|
928
|
+
if (!this.isConnectAttemptState(device.connectState))
|
|
929
|
+
device.connectState = 'connected';
|
|
924
930
|
}
|
|
925
931
|
else {
|
|
926
932
|
device = { udid, connectState: 'connected', selected: false, name: adapter.getUniqueName(), interface: adapter.getInterface() };
|
|
927
933
|
info.devices.push(device);
|
|
928
934
|
}
|
|
929
|
-
if (info.selected === udid) {
|
|
935
|
+
if (info.selected === udid && !this.isConnectAttemptState(info.connectState)) {
|
|
930
936
|
info.connectState = 'connected';
|
|
931
937
|
}
|
|
932
938
|
});
|
|
933
939
|
}
|
|
940
|
+
isConnectAttemptState(connectState) {
|
|
941
|
+
return connectState === 'connecting' || connectState === 'failed';
|
|
942
|
+
}
|
|
934
943
|
disconnectInterface(name) {
|
|
935
944
|
this.access.disableInterface(name)
|
|
936
945
|
.catch((err) => { this.logError(err, 'disableInterface'); });
|
|
@@ -1115,7 +1124,7 @@ let DevicePairingService = (() => {
|
|
|
1115
1124
|
return;
|
|
1116
1125
|
await sleep(this.getPairingRetryDelay());
|
|
1117
1126
|
if (!this.state.scan)
|
|
1118
|
-
this.run();
|
|
1127
|
+
this.run().catch(err => { this.logError(err, 'startPairing'); });
|
|
1119
1128
|
}
|
|
1120
1129
|
}
|
|
1121
1130
|
setRequestedCapabilties(selectedAdapters) {
|
|
@@ -1189,7 +1198,7 @@ let DevicePairingService = (() => {
|
|
|
1189
1198
|
}
|
|
1190
1199
|
if (!this.isPairing() && (!this.isScanning() || this.state.scan.preparing === preparing)) {
|
|
1191
1200
|
delete this.state.scan;
|
|
1192
|
-
this.run();
|
|
1201
|
+
this.run().catch(err => { this.logError(err, 'startScanning'); });
|
|
1193
1202
|
}
|
|
1194
1203
|
}, 1000);
|
|
1195
1204
|
return;
|
|
@@ -1228,7 +1237,7 @@ let DevicePairingService = (() => {
|
|
|
1228
1237
|
if (!props.enforcedScan) {
|
|
1229
1238
|
this.cleanupScan();
|
|
1230
1239
|
await sleep(500);
|
|
1231
|
-
this.run();
|
|
1240
|
+
this.run().catch(err => { this.logError(err, 'startScanning'); });
|
|
1232
1241
|
}
|
|
1233
1242
|
}
|
|
1234
1243
|
deregisterScanningDataHandlers() {
|
|
@@ -1490,7 +1499,7 @@ let DevicePairingService = (() => {
|
|
|
1490
1499
|
if (stop) {
|
|
1491
1500
|
if (wasScanning)
|
|
1492
1501
|
await this.stopAdaptersWithCapability(this.settings.capabilityForScan);
|
|
1493
|
-
this.run();
|
|
1502
|
+
this.run().catch(err => { this.logError(err, '_stopDeviceSelection'); });
|
|
1494
1503
|
}
|
|
1495
1504
|
}
|
|
1496
1505
|
numberOfSelectedCababilities(udid) {
|
|
@@ -101,7 +101,7 @@ let DeviceRideService = (() => {
|
|
|
101
101
|
if (config.isInitialized())
|
|
102
102
|
return done();
|
|
103
103
|
config.once('initialized', done);
|
|
104
|
-
config.init();
|
|
104
|
+
config.init().catch(err => { this.logError(err, 'waitForInit'); });
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async lazyInit() {
|
|
@@ -248,7 +248,7 @@ let DeviceRideService = (() => {
|
|
|
248
248
|
if (eppPreferences.programId > 32767)
|
|
249
249
|
eppPreferences.programId = 1;
|
|
250
250
|
}
|
|
251
|
-
userSettings.update({ eppPreferences });
|
|
251
|
+
userSettings.update({ eppPreferences }).catch(err => { this.logError(err, 'incrementEppProgramId'); });
|
|
252
252
|
return eppPreferences;
|
|
253
253
|
}
|
|
254
254
|
parseEppData(routeData, startPos, isLap, eppPreferences, rideMode, realityFactor) {
|
|
@@ -699,7 +699,7 @@ let DeviceRideService = (() => {
|
|
|
699
699
|
if (ai.isHealthy && (isAmber || isRed)) {
|
|
700
700
|
ai.isHealthy = false;
|
|
701
701
|
this.logEvent({ message: 'device unhealthy', device: ai.adapter.getUniqueName(), udid: ai.udid, noDataSince: (tsNow - tsLastData), tsLastData: new Date(tsLastData).toISOString() });
|
|
702
|
-
this.prepareReconnect(ai);
|
|
702
|
+
this.prepareReconnect(ai).catch(err => { this.logError(err, 'startHealthCheck'); });
|
|
703
703
|
}
|
|
704
704
|
else if (!ai.isHealthy && !isAmber && !isRed) {
|
|
705
705
|
ai.isHealthy = true;
|
|
@@ -1232,7 +1232,7 @@ let DeviceRideService = (() => {
|
|
|
1232
1232
|
if (currentMode.isERG()) {
|
|
1233
1233
|
const slope = adapter.getData().slope;
|
|
1234
1234
|
adapter.setCyclingMode(targetMode);
|
|
1235
|
-
this.resetCyclingMode(false);
|
|
1235
|
+
this.resetCyclingMode(false).catch(err => { this.logError(err, 'toggleCyclingMode'); });
|
|
1236
1236
|
const newMode = adapter.getCyclingMode();
|
|
1237
1237
|
if (newMode.isSIM()) {
|
|
1238
1238
|
request = { slope };
|
|
@@ -94,7 +94,7 @@ let RideModeService = (() => {
|
|
|
94
94
|
onActivityUpdate(activityPos, data) {
|
|
95
95
|
const limits = this.getWorkoutLimits();
|
|
96
96
|
const request = this.buildRequest({ limits });
|
|
97
|
-
this.sendUpdate(request);
|
|
97
|
+
this.sendUpdate(request).catch(err => { this.logError(err, 'onActivityUpdate'); });
|
|
98
98
|
this.prevLimits = limits;
|
|
99
99
|
}
|
|
100
100
|
onDeviceData(data, udid) {
|
|
@@ -136,7 +136,7 @@ let RideModeService = (() => {
|
|
|
136
136
|
if (!update || Object.keys(update).length === 0) {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
-
this.getDeviceRide().sendUpdate(update);
|
|
139
|
+
this.getDeviceRide().sendUpdate(update).catch(err => { this.logError(err, 'sendUpdate'); });
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
processPowerDeltaRequest(request) {
|
|
@@ -151,7 +151,7 @@ let RideModeService = (() => {
|
|
|
151
151
|
this.processing.shift();
|
|
152
152
|
if (this.queued.length > 0) {
|
|
153
153
|
const request = this.queued.shift();
|
|
154
|
-
send(request);
|
|
154
|
+
send(request).catch(err => { this.logError(err, 'processPowerDeltaRequest'); });
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
if (this.processing.length > 0) {
|
|
@@ -165,7 +165,7 @@ let RideModeService = (() => {
|
|
|
165
165
|
}
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
|
-
send(request);
|
|
168
|
+
send(request).catch(err => { this.logError(err, 'processPowerDeltaRequest'); });
|
|
169
169
|
}
|
|
170
170
|
isForcedERG() {
|
|
171
171
|
let forceErgMode = false;
|
|
@@ -152,7 +152,7 @@ let RideDisplayService = (() => {
|
|
|
152
152
|
}
|
|
153
153
|
this.startDevices();
|
|
154
154
|
this.startRide();
|
|
155
|
-
this.getCoaches().startRide(this.route);
|
|
155
|
+
this.getCoaches().startRide(this.route).catch(err => { this.logError(err, 'start'); });
|
|
156
156
|
this.setState('Starting');
|
|
157
157
|
this.logEvent({ message: 'overlay shown', overlay: 'start overlay' });
|
|
158
158
|
}
|
|
@@ -289,8 +289,8 @@ let RideDisplayService = (() => {
|
|
|
289
289
|
this.logError(err, 'stop');
|
|
290
290
|
}
|
|
291
291
|
await this.stopRide({ exit, noStateUpdates: true });
|
|
292
|
-
this.getActivityRide().cleanup();
|
|
293
|
-
this.getCoaches().stopRide();
|
|
292
|
+
this.getActivityRide().cleanup().catch(err => { this.logError(err, 'stop'); });
|
|
293
|
+
this.getCoaches().stopRide().catch(err => { this.logError(err, 'stop'); });
|
|
294
294
|
}
|
|
295
295
|
toggleCyclingMode() {
|
|
296
296
|
try {
|
|
@@ -298,7 +298,7 @@ let RideDisplayService = (() => {
|
|
|
298
298
|
this.getWorkoutRide().toggleCyclingMode();
|
|
299
299
|
}
|
|
300
300
|
else {
|
|
301
|
-
this.getDeviceRide().toggleCyclingMode();
|
|
301
|
+
this.getDeviceRide().toggleCyclingMode().catch(err => { this.logError(err, 'toggleCyclingMode'); });
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
catch (err) {
|
|
@@ -484,15 +484,16 @@ let RideDisplayService = (() => {
|
|
|
484
484
|
else {
|
|
485
485
|
const observerToClear = this.observer;
|
|
486
486
|
waitNextTick().then(() => { if (this.observer === observerToClear)
|
|
487
|
-
delete this.observer; })
|
|
487
|
+
delete this.observer; })
|
|
488
|
+
.catch(err => { this.logError(err, 'stopRide'); });
|
|
488
489
|
}
|
|
489
490
|
if (isRedundantCall) {
|
|
490
491
|
this.state = 'Idle';
|
|
491
492
|
return;
|
|
492
493
|
}
|
|
493
494
|
this.stopDevices(props.exit);
|
|
494
|
-
this.displayService.stop();
|
|
495
|
-
this.getActivityRide().stop();
|
|
495
|
+
this.displayService.stop().catch(err => { this.logError(err, 'stopRide'); });
|
|
496
|
+
this.getActivityRide().stop().catch(err => { this.logError(err, 'stopRide'); });
|
|
496
497
|
this.observer?.emit('state-update', this.state);
|
|
497
498
|
const workoutService = this.getWorkoutRide();
|
|
498
499
|
workoutService.stop({ clearFromList: true, completed: true });
|
|
@@ -639,7 +640,7 @@ let RideDisplayService = (() => {
|
|
|
639
640
|
if (this.state !== 'Active' && this.state !== 'Paused')
|
|
640
641
|
return;
|
|
641
642
|
if (this.getRideType() === 'Workout') {
|
|
642
|
-
this.stopRide();
|
|
643
|
+
this.stopRide().catch(err => { this.logError(err, 'onWorkoutCompleted'); });
|
|
643
644
|
}
|
|
644
645
|
this.checkCyclingModeToggle();
|
|
645
646
|
}
|
|
@@ -649,7 +650,7 @@ let RideDisplayService = (() => {
|
|
|
649
650
|
if (res?.changed) {
|
|
650
651
|
this.getRideModeService().sendUpdate();
|
|
651
652
|
}
|
|
652
|
-
});
|
|
653
|
+
}).catch(err => { this.logError(err, 'checkCyclingModeToggle'); });
|
|
653
654
|
}
|
|
654
655
|
}
|
|
655
656
|
onLapCompleted(oldLap, newLap) {
|
|
@@ -668,7 +669,7 @@ let RideDisplayService = (() => {
|
|
|
668
669
|
this.observer?.emit('view-changed');
|
|
669
670
|
return;
|
|
670
671
|
}
|
|
671
|
-
this.stopRide();
|
|
672
|
+
this.stopRide().catch(err => { this.logError(err, 'onRouteCompleted'); });
|
|
672
673
|
}
|
|
673
674
|
onForward(workoutTime, remaining) {
|
|
674
675
|
const time = Math.round(this.activity.time);
|
|
@@ -873,7 +874,7 @@ let RideDisplayService = (() => {
|
|
|
873
874
|
this.getDeviceRide().off('data', this.startDeviceHandlers?.deviceDataHandler);
|
|
874
875
|
this.resetDeviceHandlers();
|
|
875
876
|
if (exit)
|
|
876
|
-
this.getDeviceRide().stop();
|
|
877
|
+
this.getDeviceRide().stop().catch(err => { this.logError(err, 'stopDevices'); });
|
|
877
878
|
else
|
|
878
879
|
this.getDeviceRide().pause();
|
|
879
880
|
}
|