incyclist-devices 2.0.38 → 2.1.0
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/antv2/adapter-factory.d.ts +4 -2
- package/lib/antv2/adapter.d.ts +3 -20
- package/lib/antv2/adapter.js +2 -92
- package/lib/antv2/fe/adapter.d.ts +9 -5
- package/lib/antv2/fe/adapter.js +25 -14
- package/lib/antv2/hr/adapter.d.ts +2 -1
- package/lib/antv2/pwr/adapter.d.ts +9 -5
- package/lib/antv2/pwr/adapter.js +19 -8
- package/lib/antv2/types.d.ts +2 -1
- package/lib/base/adpater.d.ts +31 -13
- package/lib/base/adpater.js +84 -28
- package/lib/ble/adapter-factory.d.ts +10 -9
- package/lib/ble/base/adapter.d.ts +9 -20
- package/lib/ble/base/adapter.js +13 -69
- package/lib/ble/ble-interface.d.ts +5 -4
- package/lib/ble/cp/adapter.d.ts +5 -8
- package/lib/ble/cp/adapter.js +26 -10
- package/lib/ble/elite/adapter.d.ts +6 -5
- package/lib/ble/elite/adapter.js +26 -2
- package/lib/ble/fm/adapter.d.ts +10 -9
- package/lib/ble/fm/adapter.js +38 -11
- package/lib/ble/hr/adapter.d.ts +5 -3
- package/lib/ble/peripheral-cache.d.ts +3 -2
- package/lib/ble/tacx/adapter.d.ts +2 -2
- package/lib/ble/wahoo/adapter.d.ts +2 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +4 -2
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ant-fe-adv-st-mode.d.ts +12 -0
- package/lib/modes/ant-fe-adv-st-mode.js +83 -0
- package/lib/modes/antble-erg.d.ts +31 -0
- package/lib/modes/antble-erg.js +28 -0
- package/lib/modes/antble-smarttrainer.d.ts +23 -0
- package/lib/modes/antble-smarttrainer.js +65 -0
- package/lib/modes/base.d.ts +29 -0
- package/lib/modes/{cycling-mode.js → base.js} +23 -26
- package/lib/modes/daum-classic-standard.d.ts +16 -0
- package/lib/modes/daum-classic-standard.js +54 -0
- package/lib/modes/daum-erg.d.ts +49 -0
- package/lib/{serial/daum/ERGCyclingMode.js → modes/daum-erg.js} +45 -73
- package/lib/modes/daum-power.d.ts +5 -0
- package/lib/{serial/daum/DaumPowerMeterCyclingMode.js → modes/daum-power.js} +1 -10
- package/lib/modes/daum-premium-standard.d.ts +23 -0
- package/lib/{serial/daum/premium/modes/daum-classic.js → modes/daum-premium-standard.js} +26 -38
- package/lib/modes/daum-smarttrainer.d.ts +82 -0
- package/lib/{serial/daum/SmartTrainerCyclingMode.js → modes/daum-smarttrainer.js} +23 -26
- package/lib/modes/kettler-erg.d.ts +44 -0
- package/lib/{serial/kettler/ergo-racer/modes/erg.js → modes/kettler-erg.js} +12 -23
- package/lib/modes/power-base.d.ts +28 -3
- package/lib/modes/power-base.js +182 -5
- package/lib/modes/power-meter.d.ts +10 -16
- package/lib/modes/power-meter.js +15 -54
- package/lib/modes/simulator.d.ts +37 -10
- package/lib/modes/simulator.js +14 -46
- package/lib/modes/{cycling-mode.d.ts → types.d.ts} +22 -19
- package/lib/modes/types.js +56 -0
- package/lib/serial/adapter-factory.d.ts +7 -5
- package/lib/serial/adapter.d.ts +2 -2
- package/lib/serial/adapter.js +5 -2
- package/lib/serial/daum/DaumAdapter.d.ts +27 -24
- package/lib/serial/daum/DaumAdapter.js +200 -128
- package/lib/serial/daum/classic/adapter.d.ts +20 -21
- package/lib/serial/daum/classic/adapter.js +83 -157
- package/lib/serial/daum/classic/comms.d.ts +19 -13
- package/lib/serial/daum/classic/comms.js +39 -12
- package/lib/serial/daum/classic/mock.d.ts +4 -0
- package/lib/serial/daum/classic/mock.js +14 -4
- package/lib/serial/daum/premium/adapter.d.ts +16 -11
- package/lib/serial/daum/premium/adapter.js +98 -95
- package/lib/serial/daum/premium/comms.d.ts +4 -1
- package/lib/serial/daum/premium/comms.js +25 -17
- package/lib/serial/daum/premium/mock.d.ts +4 -0
- package/lib/serial/daum/premium/mock.js +15 -5
- package/lib/serial/daum/types.d.ts +11 -0
- package/lib/serial/daum/types.js +5 -0
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +10 -8
- package/lib/serial/kettler/ergo-racer/adapter.js +17 -7
- package/lib/serial/serial-interface.js +1 -2
- package/lib/simulator/Simulator.d.ts +14 -17
- package/lib/simulator/Simulator.js +18 -47
- package/lib/types/adapter.d.ts +29 -8
- package/lib/types/adapter.js +68 -0
- package/lib/utils/utils.d.ts +1 -1
- package/package.json +3 -3
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/antv2/modes/ant-fe-adv-st-mode.js +0 -51
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +0 -6
- package/lib/antv2/modes/ant-fe-erg-mode.js +0 -14
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +0 -5
- package/lib/antv2/modes/ant-fe-st-mode.js +0 -13
- package/lib/modes/ble-erg-mode.d.ts +0 -18
- package/lib/modes/ble-erg-mode.js +0 -148
- package/lib/modes/ble-st-mode.d.ts +0 -15
- package/lib/modes/ble-st-mode.js +0 -96
- package/lib/serial/daum/DaumPowerMeterCyclingMode.d.ts +0 -8
- package/lib/serial/daum/ERGCyclingMode.d.ts +0 -26
- package/lib/serial/daum/SmartTrainerCyclingMode.d.ts +0 -42
- package/lib/serial/daum/classic/modes/daum-classic.d.ts +0 -13
- package/lib/serial/daum/classic/modes/daum-classic.js +0 -97
- package/lib/serial/daum/premium/modes/daum-classic.d.ts +0 -14
- package/lib/serial/kettler/ergo-racer/modes/erg.d.ts +0 -25
- /package/lib/serial/daum/{constants.d.ts → consts.d.ts} +0 -0
- /package/lib/serial/daum/{constants.js → consts.js} +0 -0
|
@@ -2,10 +2,12 @@ import { Profile } from "incyclist-ant-plus";
|
|
|
2
2
|
import { DeviceData } from "../types/data";
|
|
3
3
|
import AntAdapter, { BaseDeviceData } from "./adapter";
|
|
4
4
|
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile } from "./types";
|
|
5
|
+
import { Controllable } from "../types/adapter";
|
|
6
|
+
import { DeviceProperties } from "../types/device";
|
|
5
7
|
export type AntAdapterInfo = {
|
|
6
8
|
antProfile: Profile;
|
|
7
9
|
incyclistProfile: LegacyProfile;
|
|
8
|
-
Adapter: typeof AntAdapter<BaseDeviceData, DeviceData>;
|
|
10
|
+
Adapter: typeof AntAdapter<Controllable<DeviceProperties>, BaseDeviceData, DeviceData>;
|
|
9
11
|
};
|
|
10
12
|
export type AdapterQuery = {
|
|
11
13
|
antProfile?: Profile;
|
|
@@ -16,7 +18,7 @@ export default class AntAdapterFactory {
|
|
|
16
18
|
adapters: AntAdapterInfo[];
|
|
17
19
|
static getInstance(): AntAdapterFactory;
|
|
18
20
|
constructor();
|
|
19
|
-
register<TDeviceData extends BaseDeviceData, TData>(antProfile: Profile, incyclistProfile: LegacyProfile, Adapter: typeof AntAdapter<TDeviceData, TData>): void;
|
|
21
|
+
register<TDeviceData extends BaseDeviceData, TData>(antProfile: Profile, incyclistProfile: LegacyProfile, Adapter: typeof AntAdapter<Controllable<DeviceProperties>, TDeviceData, TData>): void;
|
|
20
22
|
getAdapter(query?: AdapterQuery): any;
|
|
21
23
|
createInstance(settings: AntDeviceSettings, props?: AntDeviceProperties): any;
|
|
22
24
|
createFromDetected(profile: Profile, deviceID: number, props?: AntDeviceProperties): any;
|
package/lib/antv2/adapter.d.ts
CHANGED
|
@@ -3,16 +3,13 @@ import { IChannel, ISensor, Profile } from 'incyclist-ant-plus';
|
|
|
3
3
|
import AntInterface from './ant-interface';
|
|
4
4
|
import IncyclistDevice from '../base/adpater';
|
|
5
5
|
import { AntDeviceProperties, AntDeviceSettings } from './types';
|
|
6
|
-
import {
|
|
7
|
-
import { Bike, IncyclistDeviceAdapter } from '../types/adapter';
|
|
8
|
-
import CyclingMode from '../modes/cycling-mode';
|
|
9
|
-
import { User } from '../types/user';
|
|
6
|
+
import { Controllable, IncyclistDeviceAdapter } from '../types/adapter';
|
|
10
7
|
export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
11
8
|
export type BaseDeviceData = {
|
|
12
9
|
DeviceID: number;
|
|
13
10
|
ManId?: number;
|
|
14
11
|
};
|
|
15
|
-
export default class AntAdapter<TDeviceData extends BaseDeviceData, TData> extends IncyclistDevice {
|
|
12
|
+
export default class AntAdapter<DC extends Controllable<AntDeviceProperties>, TDeviceData extends BaseDeviceData, TData> extends IncyclistDevice<DC, AntDeviceProperties> {
|
|
16
13
|
sensor: ISensor;
|
|
17
14
|
lastUpdate?: number;
|
|
18
15
|
data: TData;
|
|
@@ -32,7 +29,7 @@ export default class AntAdapter<TDeviceData extends BaseDeviceData, TData> exten
|
|
|
32
29
|
protected lastDataTS: number;
|
|
33
30
|
protected dataMsgCount: number;
|
|
34
31
|
protected ivWaitForData: NodeJS.Timeout;
|
|
35
|
-
constructor(settings: AntDeviceSettings, props?:
|
|
32
|
+
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
36
33
|
logEvent(event: any): void;
|
|
37
34
|
createSensor(settings: AntDeviceSettings): ISensor;
|
|
38
35
|
isEqual(settings: AntDeviceSettings): boolean;
|
|
@@ -55,17 +52,3 @@ export default class AntAdapter<TDeviceData extends BaseDeviceData, TData> exten
|
|
|
55
52
|
start(props?: AntDeviceProperties): Promise<boolean>;
|
|
56
53
|
stop(): Promise<boolean>;
|
|
57
54
|
}
|
|
58
|
-
export declare class ControllableAntAdapter<TDeviceData extends BaseDeviceData, TData> extends AntAdapter<TDeviceData, TData> implements Bike {
|
|
59
|
-
cyclingMode: CyclingMode;
|
|
60
|
-
user?: User;
|
|
61
|
-
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
62
|
-
isControllable(): boolean;
|
|
63
|
-
setUser(user: User): void;
|
|
64
|
-
setBikeProps(props: DeviceProperties): void;
|
|
65
|
-
getWeight(): number;
|
|
66
|
-
getSupportedCyclingModes(): any[];
|
|
67
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
68
|
-
setCyclingMode(mode: CyclingMode | string, settings?: any): void;
|
|
69
|
-
sendInitCommands(): Promise<boolean>;
|
|
70
|
-
getCyclingMode(): CyclingMode;
|
|
71
|
-
}
|
package/lib/antv2/adapter.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,13 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
13
|
};
|
|
37
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
15
|
+
exports.DEFAULT_UPDATE_FREQUENCY = void 0;
|
|
39
16
|
const ant_interface_1 = __importDefault(require("./ant-interface"));
|
|
40
|
-
const adpater_1 =
|
|
17
|
+
const adpater_1 = __importDefault(require("../base/adpater"));
|
|
41
18
|
const types_1 = require("./types");
|
|
42
19
|
const utils_1 = require("../utils/utils");
|
|
43
20
|
const capabilities_1 = require("../types/capabilities");
|
|
44
|
-
const adpater_2 = require("../base/adpater");
|
|
45
21
|
const utils_2 = require("./utils");
|
|
46
22
|
exports.DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
47
23
|
const NO_DATA_TIMEOUT = 5000;
|
|
@@ -267,69 +243,3 @@ class AntAdapter extends adpater_1.default {
|
|
|
267
243
|
}
|
|
268
244
|
}
|
|
269
245
|
exports.default = AntAdapter;
|
|
270
|
-
class ControllableAntAdapter extends AntAdapter {
|
|
271
|
-
constructor(settings, props) {
|
|
272
|
-
super(settings, props);
|
|
273
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
274
|
-
this.user = {};
|
|
275
|
-
}
|
|
276
|
-
isControllable() {
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
setUser(user) {
|
|
280
|
-
this.user = user;
|
|
281
|
-
if (!user.weight)
|
|
282
|
-
this.user.weight = adpater_2.DEFAULT_USER_WEIGHT;
|
|
283
|
-
}
|
|
284
|
-
setBikeProps(props) {
|
|
285
|
-
const { user, userWeight } = props || {};
|
|
286
|
-
if (user)
|
|
287
|
-
this.setUser(user);
|
|
288
|
-
if (userWeight)
|
|
289
|
-
this.user.weight = userWeight;
|
|
290
|
-
const keys = Object.keys(props);
|
|
291
|
-
keys.forEach(k => {
|
|
292
|
-
const p = props[k];
|
|
293
|
-
if (p === null)
|
|
294
|
-
delete this.props[k];
|
|
295
|
-
else if (p !== undefined)
|
|
296
|
-
this.props[k] = p;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
getWeight() {
|
|
300
|
-
const { user = {}, props = adpater_2.DEFAULT_PROPS } = this;
|
|
301
|
-
const userWeight = user.weight || props.userWeight || adpater_2.DEFAULT_USER_WEIGHT;
|
|
302
|
-
const bikeWeight = props.bikeWeight || adpater_1.DEFAULT_BIKE_WEIGHT;
|
|
303
|
-
return userWeight + bikeWeight;
|
|
304
|
-
}
|
|
305
|
-
getSupportedCyclingModes() { throw new Error('not implemented'); }
|
|
306
|
-
getDefaultCyclingMode() { throw new Error('not implemented'); }
|
|
307
|
-
setCyclingMode(mode, settings) {
|
|
308
|
-
let selectedMode;
|
|
309
|
-
if (typeof mode === 'string') {
|
|
310
|
-
const supported = this.getSupportedCyclingModes();
|
|
311
|
-
const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
|
|
312
|
-
if (CyclingModeClass) {
|
|
313
|
-
this.cyclingMode = new CyclingModeClass(this, settings);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
selectedMode = this.getDefaultCyclingMode();
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
selectedMode = mode;
|
|
320
|
-
}
|
|
321
|
-
this.cyclingMode = selectedMode;
|
|
322
|
-
this.cyclingMode.setSettings(settings);
|
|
323
|
-
}
|
|
324
|
-
sendInitCommands() {
|
|
325
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
326
|
-
return true;
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
getCyclingMode() {
|
|
330
|
-
if (!this.cyclingMode)
|
|
331
|
-
this.setCyclingMode(this.getDefaultCyclingMode());
|
|
332
|
-
return this.cyclingMode;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
exports.ControllableAntAdapter = ControllableAntAdapter;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FitnessEquipmentSensorState, ISensor, Profile } from "incyclist-ant-plus";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import AntAdapter from "../adapter";
|
|
3
|
+
import ICyclingMode, { CyclingMode, IncyclistBikeData, UpdateRequest } from '../../modes/types';
|
|
4
4
|
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile } from "../types";
|
|
5
|
+
import { ControllableDevice } from "../../base/adpater";
|
|
5
6
|
type FitnessEquipmentSensorData = {
|
|
6
7
|
speed: number;
|
|
7
8
|
slope: number;
|
|
@@ -11,7 +12,12 @@ type FitnessEquipmentSensorData = {
|
|
|
11
12
|
distance: number;
|
|
12
13
|
timestamp: number;
|
|
13
14
|
};
|
|
14
|
-
export
|
|
15
|
+
export declare class AntFeControl extends ControllableDevice<AntDeviceProperties> {
|
|
16
|
+
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
17
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
18
|
+
sendInitCommands(): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
export default class AntFEAdapter extends AntAdapter<AntFeControl, FitnessEquipmentSensorState, FitnessEquipmentSensorData> {
|
|
15
21
|
static INCYCLIST_PROFILE_NAME: LegacyProfile;
|
|
16
22
|
static ANT_PROFILE_NAME: Profile;
|
|
17
23
|
protected distanceInternal?: number;
|
|
@@ -23,8 +29,6 @@ export default class AntFEAdapter extends ControllableAntAdapter<FitnessEquipmen
|
|
|
23
29
|
getName(): string;
|
|
24
30
|
getUniqueName(): string;
|
|
25
31
|
getDisplayName(): string;
|
|
26
|
-
getSupportedCyclingModes(): Array<any>;
|
|
27
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
28
32
|
getLogData(data: any, excludeList: any): any;
|
|
29
33
|
sendUpdate(request: UpdateRequest, forced?: boolean): Promise<void>;
|
|
30
34
|
onDeviceData(deviceData: FitnessEquipmentSensorState): void;
|
package/lib/antv2/fe/adapter.js
CHANGED
|
@@ -12,25 +12,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
15
|
+
exports.AntFeControl = void 0;
|
|
16
|
+
const adapter_1 = __importDefault(require("../adapter"));
|
|
16
17
|
const utils_1 = require("../utils");
|
|
17
18
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
18
|
-
const
|
|
19
|
-
const ant_fe_erg_mode_1 = __importDefault(require("../modes/ant-fe-erg-mode"));
|
|
20
|
-
const ant_fe_adv_st_mode_1 = __importDefault(require("../modes/ant-fe-adv-st-mode"));
|
|
19
|
+
const ant_fe_adv_st_mode_1 = __importDefault(require("../../modes/ant-fe-adv-st-mode"));
|
|
21
20
|
const utils_2 = require("../../utils/utils");
|
|
22
21
|
const sensor_factory_1 = __importDefault(require("../sensor-factory"));
|
|
23
22
|
const capabilities_1 = require("../../types/capabilities");
|
|
24
23
|
const adpater_1 = require("../../base/adpater");
|
|
24
|
+
const antble_erg_1 = __importDefault(require("../../modes/antble-erg"));
|
|
25
|
+
const antble_smarttrainer_1 = __importDefault(require("../../modes/antble-smarttrainer"));
|
|
25
26
|
const DEFAULT_BIKE_WEIGHT_MOUNTAIN = 14.5;
|
|
26
27
|
const MAX_RETRIES = 3;
|
|
27
|
-
class
|
|
28
|
+
class AntFeControl extends adpater_1.ControllableDevice {
|
|
29
|
+
getSupportedCyclingModes() {
|
|
30
|
+
return [antble_smarttrainer_1.default, antble_erg_1.default, ant_fe_adv_st_mode_1.default];
|
|
31
|
+
}
|
|
32
|
+
getDefaultCyclingMode() {
|
|
33
|
+
return new antble_smarttrainer_1.default(this.adapter);
|
|
34
|
+
}
|
|
35
|
+
sendInitCommands() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.AntFeControl = AntFeControl;
|
|
42
|
+
class AntFEAdapter extends adapter_1.default {
|
|
28
43
|
constructor(settings, props) {
|
|
29
44
|
if (settings.protocol && settings.profile !== AntFEAdapter.INCYCLIST_PROFILE_NAME)
|
|
30
45
|
throw new Error('Incorrect Profile');
|
|
31
46
|
if (!settings.protocol && settings.profile !== AntFEAdapter.ANT_PROFILE_NAME)
|
|
32
47
|
throw new Error('Incorrect Profile');
|
|
33
48
|
super(settings, props);
|
|
49
|
+
this.setControl(new AntFeControl(this, props));
|
|
34
50
|
this.deviceData = {
|
|
35
51
|
DeviceID: this.sensor.getDeviceID()
|
|
36
52
|
};
|
|
@@ -69,12 +85,6 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
69
85
|
const pwrStr = InstantaneousPower ? ` (${InstantaneousPower})` : '';
|
|
70
86
|
return `${this.getUniqueName()}${pwrStr}`;
|
|
71
87
|
}
|
|
72
|
-
getSupportedCyclingModes() {
|
|
73
|
-
return [ant_fe_st_mode_1.default, ant_fe_erg_mode_1.default, ant_fe_adv_st_mode_1.default];
|
|
74
|
-
}
|
|
75
|
-
getDefaultCyclingMode() {
|
|
76
|
-
return new ant_fe_st_mode_1.default(this);
|
|
77
|
-
}
|
|
78
88
|
getLogData(data, excludeList) {
|
|
79
89
|
const logData = JSON.parse(JSON.stringify(data));
|
|
80
90
|
excludeList.forEach((key) => {
|
|
@@ -199,7 +209,7 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
199
209
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
200
210
|
const { startupTimeout = 20000, reconnectTimeout = 2000 } = props || {};
|
|
201
211
|
const totalTimeout = Math.min(startupTimeout + 10000, startupTimeout * 2);
|
|
202
|
-
let to;
|
|
212
|
+
let to, timeoutOccured = false;
|
|
203
213
|
const stopTimeoutCheck = () => {
|
|
204
214
|
if (to) {
|
|
205
215
|
clearTimeout(to);
|
|
@@ -210,13 +220,14 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
210
220
|
reject(new Error(`could not start device, reason:timeout`));
|
|
211
221
|
this.started = false;
|
|
212
222
|
to = null;
|
|
223
|
+
timeoutOccured = true;
|
|
213
224
|
}), totalTimeout);
|
|
214
225
|
this.setFEDefaultTimeout();
|
|
215
226
|
let success = false;
|
|
216
227
|
let status = { userSent: false, slopeSent: false };
|
|
217
228
|
let retry = 0;
|
|
218
229
|
let hasData = false;
|
|
219
|
-
while (!success && retry < MAX_RETRIES) {
|
|
230
|
+
while (!success && retry < MAX_RETRIES && !timeoutOccured) {
|
|
220
231
|
retry++;
|
|
221
232
|
if (!this.sensorConnected) {
|
|
222
233
|
this.logEvent({ message: 'start sensor', props });
|
|
@@ -339,7 +350,7 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
339
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
340
351
|
if (this.started && !this.stopped) {
|
|
341
352
|
try {
|
|
342
|
-
if (this.getCyclingMode() instanceof
|
|
353
|
+
if (this.getCyclingMode() instanceof antble_erg_1.default) {
|
|
343
354
|
const power = this.data.power;
|
|
344
355
|
const request = power ? { targetPower: power } : this.getCyclingMode().getBikeInitRequest();
|
|
345
356
|
yield this.sendUpdate(request, true);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { HeartRateSensorState, ISensor, Profile } from "incyclist-ant-plus";
|
|
2
2
|
import AntAdapter from "../adapter";
|
|
3
3
|
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile } from "../types";
|
|
4
|
+
import { NonControllableDevice } from "../../base/adpater";
|
|
4
5
|
type HeartRateSensorData = {
|
|
5
6
|
heartrate: number;
|
|
6
7
|
};
|
|
7
|
-
export default class AntHrAdapter extends AntAdapter<HeartRateSensorState, HeartRateSensorData> {
|
|
8
|
+
export default class AntHrAdapter extends AntAdapter<NonControllableDevice<AntDeviceProperties>, HeartRateSensorState, HeartRateSensorData> {
|
|
8
9
|
static INCYCLIST_PROFILE_NAME: LegacyProfile;
|
|
9
10
|
static ANT_PROFILE_NAME: Profile;
|
|
10
11
|
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BicyclePowerSensorState, ISensor, Profile } from "incyclist-ant-plus";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import AntAdapter from "../adapter";
|
|
3
|
+
import ICyclingMode, { CyclingMode, IncyclistBikeData } from '../../modes/types';
|
|
4
4
|
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile } from "../types";
|
|
5
|
+
import { ControllableDevice } from "../../base/adpater";
|
|
5
6
|
type PowerSensorData = {
|
|
6
7
|
speed: number;
|
|
7
8
|
slope: number;
|
|
@@ -10,7 +11,12 @@ type PowerSensorData = {
|
|
|
10
11
|
distance: number;
|
|
11
12
|
timestamp: number;
|
|
12
13
|
};
|
|
13
|
-
export
|
|
14
|
+
export declare class AntPwrControl extends ControllableDevice<AntDeviceProperties> {
|
|
15
|
+
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
16
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
17
|
+
sendInitCommands(): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
export default class AntPwrAdapter extends AntAdapter<AntPwrControl, BicyclePowerSensorState, PowerSensorData> {
|
|
14
20
|
static INCYCLIST_PROFILE_NAME: LegacyProfile;
|
|
15
21
|
static ANT_PROFILE_NAME: Profile;
|
|
16
22
|
protected distanceInternal?: number;
|
|
@@ -19,8 +25,6 @@ export default class AntPwrAdapter extends ControllableAntAdapter<BicyclePowerSe
|
|
|
19
25
|
getName(): string;
|
|
20
26
|
getUniqueName(): string;
|
|
21
27
|
getDisplayName(): string;
|
|
22
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
23
|
-
getSupportedCyclingModes(): any[];
|
|
24
28
|
getLogData(data: any, excludeList: any): any;
|
|
25
29
|
onDeviceData(deviceData: any): void;
|
|
26
30
|
canSendUpdate(): boolean;
|
package/lib/antv2/pwr/adapter.js
CHANGED
|
@@ -12,19 +12,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
15
|
+
exports.AntPwrControl = void 0;
|
|
16
|
+
const adapter_1 = __importDefault(require("../adapter"));
|
|
16
17
|
const utils_1 = require("../utils");
|
|
17
18
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
18
19
|
const power_meter_1 = __importDefault(require("../../modes/power-meter"));
|
|
19
20
|
const sensor_factory_1 = __importDefault(require("../sensor-factory"));
|
|
20
21
|
const capabilities_1 = require("../../types/capabilities");
|
|
21
|
-
|
|
22
|
+
const adpater_1 = require("../../base/adpater");
|
|
23
|
+
class AntPwrControl extends adpater_1.ControllableDevice {
|
|
24
|
+
getSupportedCyclingModes() {
|
|
25
|
+
return [power_meter_1.default];
|
|
26
|
+
}
|
|
27
|
+
getDefaultCyclingMode() {
|
|
28
|
+
return new power_meter_1.default(this.adapter);
|
|
29
|
+
}
|
|
30
|
+
sendInitCommands() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return false;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.AntPwrControl = AntPwrControl;
|
|
37
|
+
class AntPwrAdapter extends adapter_1.default {
|
|
22
38
|
constructor(settings, props) {
|
|
23
39
|
if (settings.protocol && settings.profile !== AntPwrAdapter.INCYCLIST_PROFILE_NAME)
|
|
24
40
|
throw new Error('Incorrect Profile');
|
|
25
41
|
if (!settings.protocol && settings.profile !== AntPwrAdapter.ANT_PROFILE_NAME)
|
|
26
42
|
throw new Error('Incorrect Profile');
|
|
27
43
|
super(settings, props);
|
|
44
|
+
this.setControl(new AntPwrControl(this, props));
|
|
28
45
|
this.deviceData = {
|
|
29
46
|
DeviceID: this.sensor.getDeviceID()
|
|
30
47
|
};
|
|
@@ -57,12 +74,6 @@ class AntPwrAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
57
74
|
const pwrStr = Power ? ` (${Power})` : '';
|
|
58
75
|
return `${this.getUniqueName()}${pwrStr}`;
|
|
59
76
|
}
|
|
60
|
-
getDefaultCyclingMode() {
|
|
61
|
-
return new power_meter_1.default(this);
|
|
62
|
-
}
|
|
63
|
-
getSupportedCyclingModes() {
|
|
64
|
-
return [power_meter_1.default];
|
|
65
|
-
}
|
|
66
77
|
getLogData(data, excludeList) {
|
|
67
78
|
const logData = JSON.parse(JSON.stringify(data));
|
|
68
79
|
excludeList.forEach((key) => {
|
package/lib/antv2/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Profile } from 'incyclist-ant-plus';
|
|
2
2
|
import IncyclistDevice from '../base/adpater';
|
|
3
3
|
import { DeviceProperties, DeviceSettings, IncyclistScanProps } from '../types/device';
|
|
4
|
+
import { Controllable } from '../types/adapter';
|
|
4
5
|
export interface AntDeviceSettings extends DeviceSettings {
|
|
5
6
|
deviceID?: string;
|
|
6
7
|
profile: Profile | LegacyProfile;
|
|
@@ -8,7 +9,7 @@ export interface AntDeviceSettings extends DeviceSettings {
|
|
|
8
9
|
}
|
|
9
10
|
export type LegacyProfile = 'Heartrate Monitor' | 'Power Meter' | 'Smart Trainer' | 'Speed Sensor' | 'Cadence Sensor' | 'Speed + Cadence Sensor';
|
|
10
11
|
export declare const isLegacyProfile: (o: unknown) => boolean;
|
|
11
|
-
export type DeviceFoundCallback = (device: IncyclistDevice
|
|
12
|
+
export type DeviceFoundCallback = (device: IncyclistDevice<Controllable<DeviceProperties>, DeviceProperties>, protocol: string) => void;
|
|
12
13
|
export type ScanFinishedCallback = (id: number) => void;
|
|
13
14
|
export interface AntScanProps extends IncyclistScanProps {
|
|
14
15
|
profiles?: Profile[];
|
package/lib/base/adpater.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import CyclingMode from "../modes/
|
|
2
|
+
import ICyclingMode, { CyclingMode } from "../modes/types";
|
|
3
3
|
import { DeviceProperties, DeviceSettings } from "../types/device";
|
|
4
|
-
import {
|
|
4
|
+
import { Controllable, IncyclistDeviceAdapter, OnDeviceDataCallback } from '../types/adapter';
|
|
5
5
|
import { User } from "../types/user";
|
|
6
6
|
import { IncyclistCapability } from "../types/capabilities";
|
|
7
7
|
import { EventLogger } from "gd-eventlog";
|
|
@@ -10,10 +10,9 @@ import EventEmitter from "events";
|
|
|
10
10
|
export declare const DEFAULT_BIKE_WEIGHT = 10;
|
|
11
11
|
export declare const DEFAULT_USER_WEIGHT = 75;
|
|
12
12
|
export declare const DEFAULT_PROPS: DeviceProperties;
|
|
13
|
-
export default class IncyclistDevice extends EventEmitter implements IncyclistDeviceAdapter {
|
|
13
|
+
export default class IncyclistDevice<B extends Controllable<P>, P extends DeviceProperties> extends EventEmitter implements IncyclistDeviceAdapter {
|
|
14
14
|
onDataFn: OnDeviceDataCallback;
|
|
15
15
|
settings: DeviceSettings;
|
|
16
|
-
props: DeviceProperties;
|
|
17
16
|
lastUpdate?: number;
|
|
18
17
|
updateFrequency: number;
|
|
19
18
|
capabilities: IncyclistCapability[];
|
|
@@ -21,7 +20,10 @@ export default class IncyclistDevice extends EventEmitter implements IncyclistDe
|
|
|
21
20
|
started: boolean;
|
|
22
21
|
stopped: boolean;
|
|
23
22
|
paused: boolean;
|
|
23
|
+
bikeControl: B;
|
|
24
|
+
props: DeviceProperties;
|
|
24
25
|
constructor(settings: DeviceSettings, props?: DeviceProperties);
|
|
26
|
+
setControl(control: B): void;
|
|
25
27
|
connect(): Promise<boolean>;
|
|
26
28
|
close(): Promise<boolean>;
|
|
27
29
|
check(): Promise<boolean>;
|
|
@@ -53,18 +55,34 @@ export default class IncyclistDevice extends EventEmitter implements IncyclistDe
|
|
|
53
55
|
isStarted(): boolean;
|
|
54
56
|
isPaused(): boolean;
|
|
55
57
|
hasDataListeners(): boolean | OnDeviceDataCallback;
|
|
58
|
+
setCyclingMode(mode: string | ICyclingMode, settings?: any, sendInitCommands?: boolean): void;
|
|
59
|
+
getSupportedCyclingModes(): any[];
|
|
60
|
+
getCyclingMode(): ICyclingMode;
|
|
61
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
62
|
+
setBikeProps(props: P): void;
|
|
63
|
+
setUser(user: User): void;
|
|
64
|
+
getUser(): User;
|
|
65
|
+
getWeight(): number;
|
|
66
|
+
sendInitCommands(): Promise<boolean>;
|
|
56
67
|
}
|
|
57
|
-
export declare class
|
|
58
|
-
cyclingMode: CyclingMode;
|
|
59
|
-
user?: User;
|
|
60
|
-
constructor(settings: DeviceSettings, props?: DeviceProperties);
|
|
68
|
+
export declare class NonControllableDevice<P extends DeviceProperties> extends Controllable<P> {
|
|
61
69
|
isControllable(): boolean;
|
|
62
|
-
|
|
70
|
+
setCyclingMode(mode: string | ICyclingMode, settings?: any, sendInitCommands?: boolean): void;
|
|
71
|
+
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
72
|
+
getCyclingMode(): ICyclingMode;
|
|
73
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
63
74
|
setBikeProps(props: DeviceProperties): void;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
setUser(user: User): void;
|
|
76
|
+
sendInitCommands(): Promise<boolean>;
|
|
77
|
+
}
|
|
78
|
+
export declare class ControllableDevice<P extends DeviceProperties> extends Controllable<P> {
|
|
79
|
+
protected cyclingMode: ICyclingMode;
|
|
80
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: P);
|
|
81
|
+
isControllable(): boolean;
|
|
82
|
+
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
83
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
84
|
+
setCyclingMode(mode: ICyclingMode | string, settings?: any): void;
|
|
67
85
|
sendInitCommands(): Promise<boolean>;
|
|
68
|
-
getCyclingMode():
|
|
86
|
+
getCyclingMode(): ICyclingMode;
|
|
69
87
|
getWeight(): number;
|
|
70
88
|
}
|
package/lib/base/adpater.js
CHANGED
|
@@ -12,7 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ControllableDevice = exports.DEFAULT_PROPS = exports.DEFAULT_USER_WEIGHT = exports.DEFAULT_BIKE_WEIGHT = void 0;
|
|
15
|
+
exports.ControllableDevice = exports.NonControllableDevice = exports.DEFAULT_PROPS = exports.DEFAULT_USER_WEIGHT = exports.DEFAULT_BIKE_WEIGHT = void 0;
|
|
16
|
+
const adapter_1 = require("../types/adapter");
|
|
16
17
|
const events_1 = __importDefault(require("events"));
|
|
17
18
|
exports.DEFAULT_BIKE_WEIGHT = 10;
|
|
18
19
|
exports.DEFAULT_USER_WEIGHT = 75;
|
|
@@ -30,13 +31,18 @@ class IncyclistDevice extends events_1.default {
|
|
|
30
31
|
this.started = false;
|
|
31
32
|
this.stopped = false;
|
|
32
33
|
this.paused = false;
|
|
34
|
+
this.bikeControl = new NonControllableDevice(this, props);
|
|
35
|
+
}
|
|
36
|
+
setControl(control) {
|
|
37
|
+
this.bikeControl = control;
|
|
33
38
|
}
|
|
34
39
|
connect() { throw new Error('not implemented'); }
|
|
35
40
|
close() { throw new Error('not implemented'); }
|
|
36
41
|
check() { throw new Error("Method not implemented."); }
|
|
37
|
-
getLogger() { return
|
|
42
|
+
getLogger() { return this.logger; }
|
|
38
43
|
isControllable() {
|
|
39
|
-
|
|
44
|
+
var _a;
|
|
45
|
+
return (_a = this.bikeControl) === null || _a === void 0 ? void 0 : _a.isControllable();
|
|
40
46
|
}
|
|
41
47
|
isEqual(settings) { throw new Error("Method not implemented."); }
|
|
42
48
|
getCapabilities() { return this.capabilities; }
|
|
@@ -124,46 +130,96 @@ class IncyclistDevice extends events_1.default {
|
|
|
124
130
|
hasDataListeners() {
|
|
125
131
|
return this.onDataFn || this.listenerCount('data') > 0;
|
|
126
132
|
}
|
|
133
|
+
setCyclingMode(mode, settings, sendInitCommands) {
|
|
134
|
+
var _a;
|
|
135
|
+
if (this.isControllable())
|
|
136
|
+
(_a = this.bikeControl) === null || _a === void 0 ? void 0 : _a.setCyclingMode(mode, settings, sendInitCommands);
|
|
137
|
+
}
|
|
138
|
+
getSupportedCyclingModes() {
|
|
139
|
+
var _a;
|
|
140
|
+
if (!this.isControllable())
|
|
141
|
+
return [];
|
|
142
|
+
return (_a = this.bikeControl) === null || _a === void 0 ? void 0 : _a.getSupportedCyclingModes();
|
|
143
|
+
}
|
|
144
|
+
getCyclingMode() {
|
|
145
|
+
if (this.isControllable())
|
|
146
|
+
return this.bikeControl.getCyclingMode();
|
|
147
|
+
}
|
|
148
|
+
getDefaultCyclingMode() {
|
|
149
|
+
if (this.isControllable())
|
|
150
|
+
return this.bikeControl.getDefaultCyclingMode();
|
|
151
|
+
}
|
|
152
|
+
setBikeProps(props) {
|
|
153
|
+
if (this.isControllable())
|
|
154
|
+
this.bikeControl.setBikeProps(props);
|
|
155
|
+
}
|
|
156
|
+
setUser(user) {
|
|
157
|
+
if (this.isControllable())
|
|
158
|
+
this.bikeControl.setUser(user);
|
|
159
|
+
}
|
|
160
|
+
getUser() {
|
|
161
|
+
var _a;
|
|
162
|
+
return ((_a = this.bikeControl) === null || _a === void 0 ? void 0 : _a.getUser()) || {};
|
|
163
|
+
}
|
|
164
|
+
getWeight() {
|
|
165
|
+
var _a;
|
|
166
|
+
return (_a = this.bikeControl) === null || _a === void 0 ? void 0 : _a.getWeight();
|
|
167
|
+
}
|
|
168
|
+
sendInitCommands() {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
if (this.isControllable())
|
|
171
|
+
return yield this.bikeControl.sendInitCommands();
|
|
172
|
+
return false;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
127
175
|
}
|
|
128
176
|
exports.default = IncyclistDevice;
|
|
129
|
-
class
|
|
130
|
-
constructor(settings, props) {
|
|
131
|
-
super(settings, props);
|
|
132
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
133
|
-
this.user = {};
|
|
134
|
-
}
|
|
177
|
+
class NonControllableDevice extends adapter_1.Controllable {
|
|
135
178
|
isControllable() {
|
|
136
|
-
return
|
|
179
|
+
return false;
|
|
137
180
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
181
|
+
setCyclingMode(mode, settings, sendInitCommands) {
|
|
182
|
+
throw new Error("Method not implemented.");
|
|
183
|
+
}
|
|
184
|
+
getSupportedCyclingModes() {
|
|
185
|
+
throw new Error("Method not implemented.");
|
|
186
|
+
}
|
|
187
|
+
getCyclingMode() {
|
|
188
|
+
throw new Error("Method not implemented.");
|
|
189
|
+
}
|
|
190
|
+
getDefaultCyclingMode() {
|
|
191
|
+
throw new Error("Method not implemented.");
|
|
142
192
|
}
|
|
143
193
|
setBikeProps(props) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (p === null)
|
|
153
|
-
delete this.props[k];
|
|
154
|
-
else if (p !== undefined)
|
|
155
|
-
this.props[k] = p;
|
|
194
|
+
throw new Error("Method not implemented.");
|
|
195
|
+
}
|
|
196
|
+
setUser(user) {
|
|
197
|
+
throw new Error("Method not implemented.");
|
|
198
|
+
}
|
|
199
|
+
sendInitCommands() {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
return false;
|
|
156
202
|
});
|
|
157
203
|
}
|
|
204
|
+
}
|
|
205
|
+
exports.NonControllableDevice = NonControllableDevice;
|
|
206
|
+
class ControllableDevice extends adapter_1.Controllable {
|
|
207
|
+
constructor(adapter, props) {
|
|
208
|
+
super(adapter, props);
|
|
209
|
+
this.cyclingMode = this.getDefaultCyclingMode();
|
|
210
|
+
}
|
|
211
|
+
isControllable() {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
158
214
|
getSupportedCyclingModes() { throw new Error('not implemented'); }
|
|
159
215
|
getDefaultCyclingMode() { throw new Error('not implemented'); }
|
|
160
216
|
setCyclingMode(mode, settings) {
|
|
161
217
|
let selectedMode;
|
|
162
218
|
if (typeof mode === 'string') {
|
|
163
219
|
const supported = this.getSupportedCyclingModes();
|
|
164
|
-
const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
|
|
220
|
+
const CyclingModeClass = supported.find(M => { const m = new M(this.adapter); return m.getName() === mode; });
|
|
165
221
|
if (CyclingModeClass) {
|
|
166
|
-
this.cyclingMode = new CyclingModeClass(this, settings);
|
|
222
|
+
this.cyclingMode = new CyclingModeClass(this.adapter, settings);
|
|
167
223
|
return;
|
|
168
224
|
}
|
|
169
225
|
selectedMode = this.getDefaultCyclingMode();
|