incyclist-devices 2.0.2 → 2.0.4
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 -3
- package/lib/antv2/adapter.d.ts +10 -6
- package/lib/antv2/fe/adapter.d.ts +12 -2
- package/lib/antv2/fe/adapter.js +4 -2
- package/lib/antv2/hr/adapter.d.ts +5 -1
- package/lib/antv2/pwr/adapter.d.ts +12 -4
- package/lib/antv2/pwr/adapter.js +1 -1
- package/lib/modes/ble-erg-mode.js +1 -0
- package/lib/modes/ble-st-mode.js +1 -0
- package/lib/serial/daum/premium/adapter.js +2 -0
- package/lib/serial/serial-interface.js +2 -0
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Profile } from "incyclist-ant-plus";
|
|
2
|
-
import
|
|
2
|
+
import { DeviceData } from "../types/data";
|
|
3
|
+
import AntAdapter, { BaseDeviceData } from "./adapter";
|
|
3
4
|
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile } from "./types";
|
|
4
5
|
export type AntAdapterInfo = {
|
|
5
6
|
antProfile: Profile;
|
|
6
7
|
incyclistProfile: LegacyProfile;
|
|
7
|
-
Adapter: typeof AntAdapter
|
|
8
|
+
Adapter: typeof AntAdapter<BaseDeviceData, DeviceData>;
|
|
8
9
|
};
|
|
9
10
|
export type AdapterQuery = {
|
|
10
11
|
antProfile?: Profile;
|
|
@@ -15,7 +16,7 @@ export default class AntAdapterFactory {
|
|
|
15
16
|
adapters: AntAdapterInfo[];
|
|
16
17
|
static getInstance(): AntAdapterFactory;
|
|
17
18
|
constructor();
|
|
18
|
-
register(antProfile: Profile, incyclistProfile: LegacyProfile, Adapter: typeof AntAdapter): void;
|
|
19
|
+
register<TDeviceData extends BaseDeviceData, TData>(antProfile: Profile, incyclistProfile: LegacyProfile, Adapter: typeof AntAdapter<TDeviceData, TData>): void;
|
|
19
20
|
getAdapter(query?: AdapterQuery): any;
|
|
20
21
|
createInstance(settings: AntDeviceSettings, props?: AntDeviceProperties): any;
|
|
21
22
|
createFromDetected(profile: Profile, deviceID: number, props?: AntDeviceProperties): any;
|
package/lib/antv2/adapter.d.ts
CHANGED
|
@@ -4,15 +4,19 @@ import AntInterface from './ant-interface';
|
|
|
4
4
|
import IncyclistDevice from '../base/adpater';
|
|
5
5
|
import { AntDeviceProperties, AntDeviceSettings } from './types';
|
|
6
6
|
import { DeviceProperties } from '../types/device';
|
|
7
|
-
import { Bike, IncyclistDeviceAdapter
|
|
7
|
+
import { Bike, IncyclistDeviceAdapter } from '../types/adapter';
|
|
8
8
|
import CyclingMode from '../modes/cycling-mode';
|
|
9
9
|
import { User } from '../types/user';
|
|
10
10
|
export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
11
|
-
export
|
|
11
|
+
export type BaseDeviceData = {
|
|
12
|
+
DeviceID: number;
|
|
13
|
+
ManId?: number;
|
|
14
|
+
};
|
|
15
|
+
export default class AntAdapter<TDeviceData extends BaseDeviceData, TData> extends IncyclistDevice {
|
|
12
16
|
sensor: ISensor;
|
|
13
17
|
lastUpdate?: number;
|
|
14
|
-
data:
|
|
15
|
-
deviceData:
|
|
18
|
+
data: TData;
|
|
19
|
+
deviceData: TDeviceData;
|
|
16
20
|
updateFrequency: number;
|
|
17
21
|
channel: IChannel;
|
|
18
22
|
ant: AntInterface;
|
|
@@ -22,7 +26,7 @@ export default class AntAdapter extends IncyclistDevice {
|
|
|
22
26
|
bikeSettings: {
|
|
23
27
|
weight?: number;
|
|
24
28
|
};
|
|
25
|
-
onDataFn:
|
|
29
|
+
onDataFn: (data: TData) => void;
|
|
26
30
|
startupRetryPause: number;
|
|
27
31
|
protected ivDataTimeout: NodeJS.Timer;
|
|
28
32
|
protected lastDataTS: number;
|
|
@@ -50,7 +54,7 @@ export default class AntAdapter extends IncyclistDevice {
|
|
|
50
54
|
start(props?: AntDeviceProperties): Promise<boolean>;
|
|
51
55
|
stop(): Promise<boolean>;
|
|
52
56
|
}
|
|
53
|
-
export declare class ControllableAntAdapter extends AntAdapter implements Bike {
|
|
57
|
+
export declare class ControllableAntAdapter<TDeviceData extends BaseDeviceData, TData> extends AntAdapter<TDeviceData, TData> implements Bike {
|
|
54
58
|
cyclingMode: CyclingMode;
|
|
55
59
|
user?: User;
|
|
56
60
|
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
@@ -2,7 +2,16 @@ import { FitnessEquipmentSensorState, ISensor, Profile } from "incyclist-ant-plu
|
|
|
2
2
|
import { ControllableAntAdapter } from "../adapter";
|
|
3
3
|
import CyclingMode, { IncyclistBikeData, UpdateRequest } from '../../modes/cycling-mode';
|
|
4
4
|
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile } from "../types";
|
|
5
|
-
|
|
5
|
+
type FitnessEquipmentSensorData = {
|
|
6
|
+
speed: number;
|
|
7
|
+
slope: number;
|
|
8
|
+
power: number;
|
|
9
|
+
cadence: number;
|
|
10
|
+
heartrate: number;
|
|
11
|
+
distance: number;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
};
|
|
14
|
+
export default class AntFEAdapter extends ControllableAntAdapter<FitnessEquipmentSensorState, FitnessEquipmentSensorData> {
|
|
6
15
|
static INCYCLIST_PROFILE_NAME: LegacyProfile;
|
|
7
16
|
static ANT_PROFILE_NAME: Profile;
|
|
8
17
|
protected distanceInternal?: number;
|
|
@@ -20,9 +29,10 @@ export default class AntFEAdapter extends ControllableAntAdapter {
|
|
|
20
29
|
onDeviceData(deviceData: FitnessEquipmentSensorState): void;
|
|
21
30
|
canSendUpdate(): boolean;
|
|
22
31
|
mapToCycleModeData(deviceData: FitnessEquipmentSensorState): IncyclistBikeData;
|
|
23
|
-
transformData(bikeData: IncyclistBikeData):
|
|
32
|
+
transformData(bikeData: IncyclistBikeData): FitnessEquipmentSensorData;
|
|
24
33
|
start(props?: any): Promise<any>;
|
|
25
34
|
setFEDefaultTimeout(): void;
|
|
26
35
|
reconnect(): Promise<boolean>;
|
|
27
36
|
setCyclingMode(mode: string | CyclingMode, settings?: any): void;
|
|
28
37
|
}
|
|
38
|
+
export {};
|
package/lib/antv2/fe/adapter.js
CHANGED
|
@@ -166,7 +166,7 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
166
166
|
}
|
|
167
167
|
if (bikeData.distanceInternal !== undefined)
|
|
168
168
|
this.distanceInternal = bikeData.distanceInternal;
|
|
169
|
-
|
|
169
|
+
const data = {
|
|
170
170
|
speed: bikeData.speed,
|
|
171
171
|
slope: bikeData.slope,
|
|
172
172
|
power: bikeData.power !== undefined ? Math.round(bikeData.power) : undefined,
|
|
@@ -180,6 +180,7 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
180
180
|
start(props) {
|
|
181
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
182
|
const wasPaused = this.paused;
|
|
183
|
+
this.startProps = props || {};
|
|
183
184
|
if (wasPaused)
|
|
184
185
|
this.resume();
|
|
185
186
|
if (this.started && !wasPaused) {
|
|
@@ -188,7 +189,6 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
188
189
|
const connected = yield this.connect();
|
|
189
190
|
if (!connected)
|
|
190
191
|
throw new Error(`could not start device, reason:could not connect`);
|
|
191
|
-
this.startProps = props;
|
|
192
192
|
this.logEvent({ message: 'starting device', props, isStarted: this.started, isReconnecting: this.isReconnecting });
|
|
193
193
|
const opts = props || {};
|
|
194
194
|
const { args = {}, user = {} } = opts;
|
|
@@ -223,7 +223,9 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
223
223
|
}
|
|
224
224
|
if (this.started && startSuccess === 1) {
|
|
225
225
|
try {
|
|
226
|
+
console.log('~~~ Device: waiting for data', 'timeout=', timeout || 'unknown');
|
|
226
227
|
yield this.waitForData(timeout);
|
|
228
|
+
console.log('~~~ Device: data received');
|
|
227
229
|
}
|
|
228
230
|
catch (err) {
|
|
229
231
|
stopTimeoutCheck();
|
|
@@ -1,7 +1,10 @@
|
|
|
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
|
-
|
|
4
|
+
type HeartRateSensorData = {
|
|
5
|
+
heartrate: number;
|
|
6
|
+
};
|
|
7
|
+
export default class AntHrAdapter extends AntAdapter<HeartRateSensorState, HeartRateSensorData> {
|
|
5
8
|
static INCYCLIST_PROFILE_NAME: LegacyProfile;
|
|
6
9
|
static ANT_PROFILE_NAME: Profile;
|
|
7
10
|
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
@@ -13,3 +16,4 @@ export default class AntHrAdapter extends AntAdapter {
|
|
|
13
16
|
mapData(deviceData: HeartRateSensorState): void;
|
|
14
17
|
hasData(): boolean;
|
|
15
18
|
}
|
|
19
|
+
export {};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { ISensor, Profile } from "incyclist-ant-plus";
|
|
1
|
+
import { BicyclePowerSensorState, ISensor, Profile } from "incyclist-ant-plus";
|
|
2
2
|
import { ControllableAntAdapter } from "../adapter";
|
|
3
3
|
import CyclingMode, { IncyclistBikeData } from '../../modes/cycling-mode';
|
|
4
4
|
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile } from "../types";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type PowerSensorData = {
|
|
6
|
+
speed: number;
|
|
7
|
+
slope: number;
|
|
8
|
+
power: number;
|
|
9
|
+
cadence: number;
|
|
10
|
+
distance: number;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
};
|
|
13
|
+
export default class AntPwrAdapter extends ControllableAntAdapter<BicyclePowerSensorState, PowerSensorData> {
|
|
7
14
|
static INCYCLIST_PROFILE_NAME: LegacyProfile;
|
|
8
15
|
static ANT_PROFILE_NAME: Profile;
|
|
9
16
|
protected distanceInternal?: number;
|
|
@@ -19,6 +26,7 @@ export default class AntPwrAdapter extends ControllableAntAdapter {
|
|
|
19
26
|
canSendUpdate(): boolean;
|
|
20
27
|
sendUpdate(request: any): void;
|
|
21
28
|
mapData(deviceData: any): IncyclistBikeData;
|
|
22
|
-
transformData(bikeData: IncyclistBikeData):
|
|
29
|
+
transformData(bikeData: IncyclistBikeData): PowerSensorData;
|
|
23
30
|
hasData(): boolean;
|
|
24
31
|
}
|
|
32
|
+
export {};
|
package/lib/antv2/pwr/adapter.js
CHANGED
|
@@ -119,7 +119,7 @@ class AntPwrAdapter extends adapter_1.ControllableAntAdapter {
|
|
|
119
119
|
}
|
|
120
120
|
if (bikeData.distanceInternal !== undefined)
|
|
121
121
|
this.distanceInternal = bikeData.distanceInternal;
|
|
122
|
-
|
|
122
|
+
const data = {
|
|
123
123
|
speed: bikeData.speed,
|
|
124
124
|
slope: bikeData.slope,
|
|
125
125
|
power: bikeData.power,
|
|
@@ -34,6 +34,7 @@ class BleERGCyclingMode extends power_base_1.default {
|
|
|
34
34
|
}
|
|
35
35
|
getBikeInitRequest() {
|
|
36
36
|
const startPower = Number(this.getSetting('startPower'));
|
|
37
|
+
this.prevRequest = { targetPower: startPower };
|
|
37
38
|
return { targetPower: startPower };
|
|
38
39
|
}
|
|
39
40
|
sendBikeUpdate(request) {
|
package/lib/modes/ble-st-mode.js
CHANGED
|
@@ -25,6 +25,7 @@ const DAUM_PREMIUM_DEFAULT_PORT = 51955;
|
|
|
25
25
|
const START_RETRY_TIMEOUT = 1500;
|
|
26
26
|
const DEFAULT_GEAR = 10;
|
|
27
27
|
const getBikeProps = (props) => {
|
|
28
|
+
console.log('~~~getBikeProps', props);
|
|
28
29
|
const { host, port = DAUM_PREMIUM_DEFAULT_PORT, interface: ifaceName } = props;
|
|
29
30
|
let serial;
|
|
30
31
|
if (ifaceName && typeof ifaceName === 'string') {
|
|
@@ -46,6 +47,7 @@ const getBikeProps = (props) => {
|
|
|
46
47
|
};
|
|
47
48
|
class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
48
49
|
constructor(settings, props) {
|
|
50
|
+
console.log('~~~ new premium adapter');
|
|
49
51
|
const logger = new gd_eventlog_1.EventLogger('DaumPremium');
|
|
50
52
|
const commProps = Object.assign(Object.assign({}, getBikeProps(settings)), { logger });
|
|
51
53
|
const bike = new comms_1.default(commProps);
|
|
@@ -85,11 +85,13 @@ exports.SinglePathScanner = SinglePathScanner;
|
|
|
85
85
|
class SerialInterface extends events_1.default {
|
|
86
86
|
static getInstance(props) {
|
|
87
87
|
const { ifaceName, binding, logger } = props;
|
|
88
|
+
console.log('~~~ new instance #1', ifaceName, serialport_1.default.getInstance().getBinding(ifaceName));
|
|
88
89
|
let instance = SerialInterface._instances.find(i => i.ifaceName === ifaceName);
|
|
89
90
|
if (!instance) {
|
|
90
91
|
if (binding)
|
|
91
92
|
instance = new SerialInterface(props);
|
|
92
93
|
else {
|
|
94
|
+
console.log('~~~ new instance', ifaceName, serialport_1.default.getInstance().getBinding(ifaceName));
|
|
93
95
|
instance = new SerialInterface({ ifaceName, binding: serialport_1.default.getInstance().getBinding(ifaceName), logger });
|
|
94
96
|
if (instance)
|
|
95
97
|
SerialInterface._instances.push(instance);
|