incyclist-devices 2.1.26 → 2.1.28
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/base/adapter.d.ts +1 -1
- package/lib/antv2/base/adapter.js +3 -2
- package/lib/antv2/base/interface.js +2 -2
- package/lib/base/adpater.d.ts +2 -0
- package/lib/base/adpater.js +16 -0
- package/lib/ble/base/adapter.d.ts +1 -1
- package/lib/ble/base/adapter.js +2 -1
- package/lib/serial/daum/DaumAdapter.d.ts +1 -1
- package/lib/serial/daum/DaumAdapter.js +4 -2
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +1 -1
- package/lib/serial/kettler/ergo-racer/adapter.js +2 -1
- package/package.json +1 -1
|
@@ -62,7 +62,7 @@ export default class AntAdapter<TDeviceData extends BaseDeviceData> extends Incy
|
|
|
62
62
|
reportStartStatus(): boolean;
|
|
63
63
|
protected waitForInitialData(startupTimeout: any): Promise<void>;
|
|
64
64
|
protected initSensor(props: any): Promise<boolean>;
|
|
65
|
-
start(
|
|
65
|
+
start(startProps?: AntDeviceProperties): Promise<boolean>;
|
|
66
66
|
stop(): Promise<boolean>;
|
|
67
67
|
startSensor(): Promise<boolean>;
|
|
68
68
|
stopSensor(): Promise<void>;
|
|
@@ -351,8 +351,9 @@ class AntAdapter extends adpater_1.default {
|
|
|
351
351
|
}
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
|
-
start(
|
|
354
|
+
start(startProps) {
|
|
355
355
|
return __awaiter(this, void 0, void 0, function* () {
|
|
356
|
+
const props = this.getStartProps(startProps);
|
|
356
357
|
const preCheckResult = yield this.startPreChecks(props);
|
|
357
358
|
if (preCheckResult === 'done')
|
|
358
359
|
return this.started;
|
|
@@ -361,7 +362,7 @@ class AntAdapter extends adpater_1.default {
|
|
|
361
362
|
this.logEvent({ message: 'starting device', device: this.getName(), props, isStarted: this.started });
|
|
362
363
|
this.resetStartStatus();
|
|
363
364
|
this.resetData();
|
|
364
|
-
const { startupTimeout = this.getDefaultStartupTimeout() } = props
|
|
365
|
+
const { startupTimeout = this.getDefaultStartupTimeout() } = props;
|
|
365
366
|
const retryDelay = this.getDefaultReconnectDelay();
|
|
366
367
|
const totalTimeout = Math.min(startupTimeout + 10000, (startupTimeout + retryDelay) * MAX_RETRIES);
|
|
367
368
|
const doStart = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,8 +33,8 @@ class AntInterface extends events_1.default {
|
|
|
33
33
|
this.connectPromise = null;
|
|
34
34
|
this.channelsInUse = [];
|
|
35
35
|
this.logEnabled = props.log || true;
|
|
36
|
-
const { binding
|
|
37
|
-
this.setLogger(
|
|
36
|
+
const { binding } = props;
|
|
37
|
+
this.setLogger(new gd_eventlog_1.EventLogger('Ant+'));
|
|
38
38
|
if (binding) {
|
|
39
39
|
this.setBinding(binding);
|
|
40
40
|
}
|
package/lib/base/adpater.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export default class IncyclistDevice<P extends DeviceProperties> extends EventEm
|
|
|
30
30
|
isSame(adapter: IAdapter): boolean;
|
|
31
31
|
isEqual(settings: DeviceSettings): boolean;
|
|
32
32
|
getInterface(): string;
|
|
33
|
+
restart(pause?: number): Promise<boolean>;
|
|
33
34
|
check(): Promise<boolean>;
|
|
34
35
|
start(props?: DeviceProperties): Promise<boolean>;
|
|
35
36
|
stop(): Promise<boolean>;
|
|
@@ -62,6 +63,7 @@ export default class IncyclistDevice<P extends DeviceProperties> extends EventEm
|
|
|
62
63
|
isStarted(): boolean;
|
|
63
64
|
isPaused(): boolean;
|
|
64
65
|
getData(): IncyclistAdapterData;
|
|
66
|
+
getStartProps(startProps?: P): P;
|
|
65
67
|
hasDataListeners(): boolean | OnDeviceDataCallback;
|
|
66
68
|
onData(callback: OnDeviceDataCallback): void;
|
|
67
69
|
}
|
package/lib/base/adpater.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const types_1 = require("../types");
|
|
16
16
|
const events_1 = __importDefault(require("events"));
|
|
17
17
|
const consts_1 = require("./consts");
|
|
18
|
+
const utils_1 = require("../utils/utils");
|
|
18
19
|
class IncyclistDevice extends events_1.default {
|
|
19
20
|
constructor(settings, props) {
|
|
20
21
|
super();
|
|
@@ -64,6 +65,16 @@ class IncyclistDevice extends events_1.default {
|
|
|
64
65
|
getInterface() {
|
|
65
66
|
return typeof this.settings.interface === 'string' ? this.settings.interface : this.settings.interface.getName();
|
|
66
67
|
}
|
|
68
|
+
restart(pause) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const stopped = yield this.stop();
|
|
71
|
+
if (!stopped)
|
|
72
|
+
return false;
|
|
73
|
+
if (pause)
|
|
74
|
+
yield (0, utils_1.sleep)(pause);
|
|
75
|
+
return yield this.start();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
67
78
|
check() { throw new Error("Method not implemented."); }
|
|
68
79
|
start(props) { throw new Error("Method not implemented."); }
|
|
69
80
|
stop() { throw new Error("Method not implemented."); }
|
|
@@ -234,6 +245,11 @@ class IncyclistDevice extends events_1.default {
|
|
|
234
245
|
getData() {
|
|
235
246
|
return this.data;
|
|
236
247
|
}
|
|
248
|
+
getStartProps(startProps) {
|
|
249
|
+
if (startProps)
|
|
250
|
+
this.props = startProps;
|
|
251
|
+
return startProps || {};
|
|
252
|
+
}
|
|
237
253
|
hasDataListeners() {
|
|
238
254
|
return this.onDataFn || this.listenerCount('data') > 0;
|
|
239
255
|
}
|
|
@@ -34,7 +34,7 @@ export default class BleAdapter<TDeviceData extends BleDeviceData, TDevice exten
|
|
|
34
34
|
setProperties(props: BleDeviceProperties): void;
|
|
35
35
|
check(): Promise<boolean>;
|
|
36
36
|
startPreChecks(props: BleStartProperties): Promise<'done' | 'connected' | 'connection-failed'>;
|
|
37
|
-
start(
|
|
37
|
+
start(startProps?: BleStartProperties): Promise<boolean>;
|
|
38
38
|
stop(): Promise<boolean>;
|
|
39
39
|
pause(): Promise<boolean>;
|
|
40
40
|
resume(): Promise<boolean>;
|
package/lib/ble/base/adapter.js
CHANGED
|
@@ -164,9 +164,10 @@ class BleAdapter extends adpater_1.default {
|
|
|
164
164
|
return 'connected';
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
start(
|
|
167
|
+
start(startProps) {
|
|
168
168
|
var _a;
|
|
169
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const props = this.getStartProps(startProps);
|
|
170
171
|
const preCheckResult = yield this.startPreChecks(props);
|
|
171
172
|
if (preCheckResult === 'done')
|
|
172
173
|
return this.started;
|
|
@@ -40,7 +40,7 @@ export default class DaumAdapter<S extends SerialDeviceSettings, P extends Devic
|
|
|
40
40
|
check(): Promise<boolean>;
|
|
41
41
|
performCheck(): Promise<boolean>;
|
|
42
42
|
waitForPrevStartFinished(): Promise<void>;
|
|
43
|
-
start(
|
|
43
|
+
start(startProps?: P): Promise<boolean>;
|
|
44
44
|
performStart(props?: P, isRelaunch?: boolean, wasPaused?: boolean): Promise<boolean>;
|
|
45
45
|
startUpdatePull(): void;
|
|
46
46
|
protected cleanupInterval(): void;
|
|
@@ -183,9 +183,10 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
start(
|
|
186
|
+
start(startProps) {
|
|
187
187
|
var _a;
|
|
188
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
const props = this.getStartProps(startProps);
|
|
189
190
|
yield this.waitForPrevCheckFinished();
|
|
190
191
|
yield this.waitForPrevStartFinished();
|
|
191
192
|
const isRelaunch = this.started;
|
|
@@ -197,7 +198,8 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
197
198
|
this.resume(false);
|
|
198
199
|
wasPaused = true;
|
|
199
200
|
}
|
|
200
|
-
|
|
201
|
+
const p = Object.keys(props).length ? props : undefined;
|
|
202
|
+
this.startPromise = this.performStart(p, isRelaunch, wasPaused).then((started) => __awaiter(this, void 0, void 0, function* () {
|
|
201
203
|
if (!started) {
|
|
202
204
|
this.logEvent({ message: 'start result: not started' });
|
|
203
205
|
this.started = false;
|
|
@@ -64,7 +64,7 @@ export default class KettlerRacerAdapter extends SerialIncyclistDevice<DevicePro
|
|
|
64
64
|
parseExtendedStatus(data: string): KettlerExtendedBikeData;
|
|
65
65
|
parseStatus(data: string): KettlerBikeData;
|
|
66
66
|
check(): Promise<boolean>;
|
|
67
|
-
start(
|
|
67
|
+
start(startProps?: any): Promise<boolean>;
|
|
68
68
|
startUpdatePull(): void;
|
|
69
69
|
canEmitData(): boolean;
|
|
70
70
|
stop(): Promise<boolean>;
|
|
@@ -271,8 +271,9 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
271
271
|
}));
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
|
-
start(
|
|
274
|
+
start(startProps) {
|
|
275
275
|
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
const props = this.getStartProps(startProps);
|
|
276
277
|
this.logEvent({ message: 'start()' });
|
|
277
278
|
var info = {};
|
|
278
279
|
yield this.waitForOpened(true);
|