incyclist-devices 1.2.0 → 1.4.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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/lib/CyclingMode.d.ts +72 -0
  3. package/lib/CyclingMode.js +66 -0
  4. package/lib/Device.d.ts +48 -10
  5. package/lib/Device.js +9 -8
  6. package/lib/DeviceProtocol.d.ts +40 -12
  7. package/lib/DeviceProtocol.js +16 -16
  8. package/lib/DeviceRegistry.d.ts +4 -4
  9. package/lib/DeviceRegistry.js +10 -10
  10. package/lib/DeviceSupport.d.ts +4 -3
  11. package/lib/DeviceSupport.js +32 -8
  12. package/lib/ant/AntAdapter.d.ts +9 -2
  13. package/lib/ant/AntAdapter.js +26 -2
  14. package/lib/ant/AntScanner.d.ts +16 -6
  15. package/lib/ant/AntScanner.js +379 -138
  16. package/lib/ant/antfe/AntFEAdapter.d.ts +4 -2
  17. package/lib/ant/antfe/AntFEAdapter.js +209 -72
  18. package/lib/ant/anthrm/AntHrmAdapter.d.ts +4 -1
  19. package/lib/ant/anthrm/AntHrmAdapter.js +73 -19
  20. package/lib/ant/utils.js +2 -1
  21. package/lib/calculations.d.ts +12 -13
  22. package/lib/calculations.js +88 -125
  23. package/lib/daum/DaumAdapter.d.ts +29 -6
  24. package/lib/daum/DaumAdapter.js +219 -96
  25. package/lib/daum/ERGCyclingMode.d.ts +28 -0
  26. package/lib/daum/ERGCyclingMode.js +207 -0
  27. package/lib/daum/PowerMeterCyclingMode.d.ts +18 -0
  28. package/lib/daum/PowerMeterCyclingMode.js +79 -0
  29. package/lib/daum/SmartTrainerCyclingMode.d.ts +41 -0
  30. package/lib/daum/SmartTrainerCyclingMode.js +344 -0
  31. package/lib/daum/classic/DaumClassicAdapter.d.ts +3 -1
  32. package/lib/daum/classic/DaumClassicAdapter.js +46 -32
  33. package/lib/daum/classic/DaumClassicCyclingMode.d.ts +13 -0
  34. package/lib/daum/classic/DaumClassicCyclingMode.js +98 -0
  35. package/lib/daum/classic/DaumClassicProtocol.d.ts +5 -3
  36. package/lib/daum/classic/DaumClassicProtocol.js +39 -6
  37. package/lib/daum/classic/ERGCyclingMode.d.ts +23 -0
  38. package/lib/daum/classic/ERGCyclingMode.js +171 -0
  39. package/lib/daum/classic/bike.d.ts +41 -37
  40. package/lib/daum/classic/bike.js +86 -53
  41. package/lib/daum/classic/utils.d.ts +3 -3
  42. package/lib/daum/classic/utils.js +16 -10
  43. package/lib/daum/indoorbike.d.ts +2 -1
  44. package/lib/daum/indoorbike.js +23 -21
  45. package/lib/daum/premium/DaumPremiumAdapter.d.ts +2 -2
  46. package/lib/daum/premium/DaumPremiumAdapter.js +30 -20
  47. package/lib/daum/premium/DaumPremiumProtocol.d.ts +11 -2
  48. package/lib/daum/premium/DaumPremiumProtocol.js +49 -8
  49. package/lib/daum/premium/bike.d.ts +63 -52
  50. package/lib/daum/premium/bike.js +258 -207
  51. package/lib/daum/premium/tcpserial.d.ts +18 -14
  52. package/lib/daum/premium/tcpserial.js +50 -20
  53. package/lib/daum/premium/utils.d.ts +2 -2
  54. package/lib/simulator/Simulator.d.ts +13 -7
  55. package/lib/simulator/Simulator.js +62 -21
  56. package/lib/utils.d.ts +3 -1
  57. package/lib/utils.js +39 -18
  58. package/package.json +12 -11
  59. package/lib/ant/AntScanner.unit.tests.d.ts +0 -1
  60. package/lib/ant/AntScanner.unit.tests.js +0 -25
  61. package/lib/ant/antfe/AntFEProcessor.d.ts +0 -40
  62. package/lib/ant/antfe/AntFEProcessor.js +0 -238
  63. package/lib/ant/antfe/AntHrmProtocol.d.ts +0 -9
  64. package/lib/ant/antfe/AntHrmProtocol.js +0 -30
  65. package/lib/ant/antfe/bike.d.ts +0 -47
  66. package/lib/ant/antfe/bike.js +0 -602
  67. package/lib/ant/anthrm/anthrm.d.ts +0 -33
  68. package/lib/ant/anthrm/anthrm.js +0 -523
  69. package/lib/simulator/Simulator.unit.tests.d.ts +0 -1
  70. package/lib/simulator/Simulator.unit.tests.js +0 -79
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Incyclist
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,72 @@
1
+ import { Device } from "./DeviceProtocol";
2
+ export declare type UpdateRequest = {
3
+ slope?: number;
4
+ minPower?: number;
5
+ maxPower?: number;
6
+ targetPower?: number;
7
+ reset?: boolean;
8
+ refresh?: boolean;
9
+ };
10
+ export declare enum CyclingModeProperyType {
11
+ Integer = "Integer",
12
+ Boolean = "Boolean",
13
+ Float = "Float",
14
+ String = "String",
15
+ SingleSelect = "SingleSelect",
16
+ MultiSelect = "MultiSelect"
17
+ }
18
+ export declare type CyclingModeProperty = {
19
+ key: string;
20
+ name: string;
21
+ description: string;
22
+ type: CyclingModeProperyType;
23
+ min?: number;
24
+ max?: number;
25
+ default?: any;
26
+ options?: any[];
27
+ };
28
+ export declare type IncyclistBikeData = {
29
+ isPedalling: boolean;
30
+ power: number;
31
+ pedalRpm: number;
32
+ speed: number;
33
+ heartrate: number;
34
+ distance: number;
35
+ distanceInternal: number;
36
+ time?: number;
37
+ gear?: number;
38
+ slope?: number;
39
+ };
40
+ export declare type Settings = {
41
+ [key: string]: any;
42
+ };
43
+ export default interface CyclingMode {
44
+ getName(): string;
45
+ getDescription(): string;
46
+ getBikeInitRequest(): UpdateRequest;
47
+ sendBikeUpdate(request: UpdateRequest): UpdateRequest;
48
+ updateData(data: IncyclistBikeData): IncyclistBikeData;
49
+ getProperties(): CyclingModeProperty[];
50
+ getProperty(name: string): CyclingModeProperty;
51
+ setSettings(settings: any): any;
52
+ setSetting(name: string, value: any): void;
53
+ getSetting(name: string): any;
54
+ getSettings(): Settings;
55
+ }
56
+ export declare class CyclingModeBase implements CyclingMode {
57
+ adapter: Device;
58
+ settings: Settings;
59
+ constructor(adapter: Device, props?: any);
60
+ setAdapter(adapter: Device): void;
61
+ getBikeInitRequest(): UpdateRequest;
62
+ getName(): string;
63
+ getDescription(): string;
64
+ sendBikeUpdate(request: UpdateRequest): UpdateRequest;
65
+ updateData(data: IncyclistBikeData): IncyclistBikeData;
66
+ getProperties(): CyclingModeProperty[];
67
+ getProperty(name: string): CyclingModeProperty;
68
+ setSettings(settings?: any): void;
69
+ setSetting(name: string, value: any): void;
70
+ getSetting(name: string): any;
71
+ getSettings(): Settings;
72
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CyclingModeBase = exports.CyclingModeProperyType = void 0;
4
+ var CyclingModeProperyType;
5
+ (function (CyclingModeProperyType) {
6
+ CyclingModeProperyType["Integer"] = "Integer";
7
+ CyclingModeProperyType["Boolean"] = "Boolean";
8
+ CyclingModeProperyType["Float"] = "Float";
9
+ CyclingModeProperyType["String"] = "String";
10
+ CyclingModeProperyType["SingleSelect"] = "SingleSelect";
11
+ CyclingModeProperyType["MultiSelect"] = "MultiSelect";
12
+ })(CyclingModeProperyType = exports.CyclingModeProperyType || (exports.CyclingModeProperyType = {}));
13
+ class CyclingModeBase {
14
+ constructor(adapter, props) {
15
+ this.settings = {};
16
+ if (!adapter)
17
+ throw new Error('IllegalArgument: adapter is null');
18
+ this.setAdapter(adapter);
19
+ this.setSettings(props);
20
+ }
21
+ setAdapter(adapter) {
22
+ this.adapter = adapter;
23
+ }
24
+ getBikeInitRequest() {
25
+ return {};
26
+ }
27
+ getName() {
28
+ throw new Error("Method not implemented.");
29
+ }
30
+ getDescription() {
31
+ throw new Error("Method not implemented.");
32
+ }
33
+ sendBikeUpdate(request) {
34
+ throw new Error("Method not implemented.");
35
+ }
36
+ updateData(data) {
37
+ throw new Error("Method not implemented.");
38
+ }
39
+ getProperties() {
40
+ throw new Error("Method not implemented.");
41
+ }
42
+ getProperty(name) {
43
+ throw new Error("Method not implemented.");
44
+ }
45
+ setSettings(settings) {
46
+ if (settings) {
47
+ this.settings = settings;
48
+ }
49
+ }
50
+ setSetting(name, value) {
51
+ this.settings[name] = value;
52
+ }
53
+ getSetting(name) {
54
+ const res = this.settings[name];
55
+ if (res !== undefined)
56
+ return res;
57
+ const prop = this.getProperties().find(p => p.key === name);
58
+ if (prop && prop.default !== undefined)
59
+ return prop.default;
60
+ return undefined;
61
+ }
62
+ getSettings() {
63
+ return this.settings;
64
+ }
65
+ }
66
+ exports.CyclingModeBase = CyclingModeBase;
package/lib/Device.d.ts CHANGED
@@ -1,16 +1,54 @@
1
- import DeviceProtocol from './DeviceProtocol';
2
- export default class Device {
1
+ import { DeviceProtocol, Device } from './DeviceProtocol';
2
+ import CyclingMode from './CyclingMode';
3
+ export declare type OnDeviceDataCallback = (data: any) => void;
4
+ export interface Bike {
5
+ setCyclingMode(mode: CyclingMode | string, settings?: any): void;
6
+ getSupportedCyclingModes(): Array<any>;
7
+ getCyclingMode(): CyclingMode;
8
+ getDefaultCyclingMode(): CyclingMode;
9
+ setUserSettings(userSettings: any): void;
10
+ setBikeSettings(bikeSettings: any): void;
11
+ }
12
+ export interface DeviceAdapter extends Device {
13
+ isBike(): boolean;
14
+ isPower(): boolean;
15
+ isHrm(): boolean;
16
+ getID(): string;
17
+ getDisplayName(): string;
18
+ getName(): string;
19
+ getPort(): string;
20
+ getProtocol(): DeviceProtocol;
21
+ getProtocolName(): string;
22
+ setIgnoreHrm(ignore: boolean): void;
23
+ setIgnorePower(ignore: boolean): void;
24
+ setIgnoreBike(ignore: boolean): void;
25
+ select(): void;
26
+ unselect(): void;
27
+ isSelected(): boolean;
28
+ setDetected(detected?: boolean): void;
29
+ isDetected(): boolean;
30
+ start(props?: any): Promise<any>;
31
+ stop(): Promise<boolean>;
32
+ pause(): Promise<boolean>;
33
+ resume(): Promise<boolean>;
34
+ sendUpdate(request: any): void;
35
+ onData(callback: OnDeviceDataCallback): void;
36
+ }
37
+ export default class DeviceAdapterBase implements DeviceAdapter {
3
38
  protocol: DeviceProtocol;
4
39
  detected: boolean;
5
40
  selected: boolean;
6
- onDataFn: any;
7
- constructor(proto: any);
8
- getID(): void;
9
- getDisplayName(): void;
10
- getName(): void;
11
- getPort(): void;
41
+ onDataFn: OnDeviceDataCallback;
42
+ constructor(proto: DeviceProtocol);
43
+ isBike(): boolean;
44
+ isPower(): boolean;
45
+ isHrm(): boolean;
46
+ getID(): string;
47
+ getDisplayName(): string;
48
+ getName(): string;
49
+ getPort(): string;
12
50
  getProtocol(): DeviceProtocol;
13
- getProtocolName(): void;
51
+ getProtocolName(): string | undefined;
14
52
  setIgnoreHrm(ignore: any): void;
15
53
  setIgnorePower(ignore: any): void;
16
54
  setIgnoreBike(ignore: any): void;
@@ -28,5 +66,5 @@ export default class Device {
28
66
  pause(): Promise<boolean>;
29
67
  resume(): Promise<boolean>;
30
68
  sendUpdate(request: any): void;
31
- onData(callback: any): void;
69
+ onData(callback: OnDeviceDataCallback): void;
32
70
  }
package/lib/Device.js CHANGED
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- class Device {
3
+ class DeviceAdapterBase {
4
4
  constructor(proto) {
5
5
  this.protocol = proto;
6
6
  this.detected = false;
7
7
  this.selected = false;
8
8
  this.onDataFn = undefined;
9
9
  }
10
- getID() { }
10
+ isBike() { throw new Error('not implemented'); }
11
+ isPower() { throw new Error('not implemented'); }
12
+ isHrm() { throw new Error('not implemented'); }
13
+ getID() { throw new Error('not implemented'); }
11
14
  getDisplayName() { return this.getName(); }
12
- getName() { }
13
- getPort() { }
14
- getProtocol() {
15
- return this.protocol;
16
- }
15
+ getName() { throw new Error('not implemented'); }
16
+ getPort() { throw new Error('not implemented'); }
17
+ getProtocol() { return this.protocol; }
17
18
  getProtocolName() {
18
19
  return this.protocol ? this.protocol.getName() : undefined;
19
20
  }
@@ -38,4 +39,4 @@ class Device {
38
39
  this.onDataFn = callback;
39
40
  }
40
41
  }
41
- exports.default = Device;
42
+ exports.default = DeviceAdapterBase;
@@ -6,25 +6,54 @@ export declare const INTERFACE: {
6
6
  TCPIP: string;
7
7
  SIMULATOR: string;
8
8
  };
9
- declare type DeviceFoundCallback = (device: any, protocol: DeviceProtocol) => void;
10
- declare type ScanFinishedCallback = (id: number) => void;
9
+ export declare type Device = {
10
+ getID(): string;
11
+ getName(): string;
12
+ getPort(): string;
13
+ getProtocol(): DeviceProtocol;
14
+ getProtocolName(): string;
15
+ };
16
+ export interface DeviceSettings {
17
+ name: string;
18
+ port: string;
19
+ }
20
+ export declare type DeviceFoundCallback = (device: Device, protocol: DeviceProtocolBase) => void;
21
+ export declare type ScanFinishedCallback = (id: number) => void;
11
22
  export declare type ScanProps = {
12
23
  id: number;
13
24
  onDeviceFound?: DeviceFoundCallback;
14
25
  onScanFinished?: ScanFinishedCallback;
15
26
  };
16
- export default class DeviceProtocol {
17
- devices: Array<any>;
27
+ export interface DeviceProtocol {
28
+ add(props: DeviceSettings): any;
29
+ getName(): string;
30
+ getInterfaces(): Array<string>;
31
+ isBike(): boolean;
32
+ isHrm(): boolean;
33
+ isPower(): boolean;
34
+ scan(props: ScanProps): void;
35
+ stopScan(): void;
36
+ isScanning(): boolean;
37
+ getDevices(): Array<any>;
38
+ setAnt(antClass: any): void;
39
+ getAnt(): any;
40
+ setSerialPort(serialClass: any): void;
41
+ getSerialPort(): any;
42
+ setNetImpl(netClass: any): void;
43
+ getNetImpl(): any;
44
+ }
45
+ export default class DeviceProtocolBase {
46
+ devices: Array<Device>;
18
47
  constructor();
19
- getName(): void;
20
- getInterfaces(): void;
21
- isBike(): void;
22
- isHrm(): void;
23
- isPower(): void;
48
+ getName(): string;
49
+ getInterfaces(): Array<string>;
50
+ isBike(): boolean;
51
+ isHrm(): boolean;
52
+ isPower(): boolean;
24
53
  scan(props: ScanProps): void;
25
54
  stopScan(): void;
26
- isScanning(): void;
27
- getDevices(): any[];
55
+ isScanning(): boolean;
56
+ getDevices(): Array<Device>;
28
57
  setAnt(antClass: any): void;
29
58
  getAnt(): any;
30
59
  setSerialPort(serialClass: any): void;
@@ -38,4 +67,3 @@ export default class DeviceProtocol {
38
67
  static setNetImpl(netClass: any): void;
39
68
  static getNetImpl(): any;
40
69
  }
41
- export {};
@@ -10,25 +10,25 @@ exports.INTERFACE = {
10
10
  SIMULATOR: 'simulator'
11
11
  };
12
12
  let _ant, _serial, _net;
13
- class DeviceProtocol {
13
+ class DeviceProtocolBase {
14
14
  constructor() {
15
15
  this.devices = [];
16
16
  }
17
- getName() { }
18
- getInterfaces() { }
19
- isBike() { }
20
- isHrm() { }
21
- isPower() { }
22
- scan(props) { }
23
- stopScan() { }
24
- isScanning() { }
17
+ getName() { throw new Error('not implemented'); }
18
+ getInterfaces() { throw new Error('not implemented'); }
19
+ isBike() { throw new Error('not implemented'); }
20
+ isHrm() { throw new Error('not implemented'); }
21
+ isPower() { throw new Error('not implemented'); }
22
+ scan(props) { throw new Error('not implemented'); }
23
+ stopScan() { throw new Error('not implemented'); }
24
+ isScanning() { throw new Error('not implemented'); }
25
25
  getDevices() { return this.devices; }
26
- setAnt(antClass) { DeviceProtocol.setAnt(antClass); }
27
- getAnt() { return DeviceProtocol.getAnt(); }
28
- setSerialPort(serialClass) { DeviceProtocol.setSerialPort(serialClass); }
29
- getSerialPort() { DeviceProtocol.getSerialPort(); }
30
- setNetImpl(netClass) { DeviceProtocol.setNetImpl(netClass); }
31
- getNetImpl() { return DeviceProtocol.getNetImpl(); }
26
+ setAnt(antClass) { DeviceProtocolBase.setAnt(antClass); }
27
+ getAnt() { return DeviceProtocolBase.getAnt(); }
28
+ setSerialPort(serialClass) { DeviceProtocolBase.setSerialPort(serialClass); }
29
+ getSerialPort() { DeviceProtocolBase.getSerialPort(); }
30
+ setNetImpl(netClass) { DeviceProtocolBase.setNetImpl(netClass); }
31
+ getNetImpl() { return DeviceProtocolBase.getNetImpl(); }
32
32
  static setAnt(antClass) { _ant = antClass; }
33
33
  static getAnt() { return _ant; }
34
34
  static setSerialPort(serialClass) { _serial = serialClass; }
@@ -36,4 +36,4 @@ class DeviceProtocol {
36
36
  static setNetImpl(netClass) { _net = netClass; }
37
37
  static getNetImpl() { return _net; }
38
38
  }
39
- exports.default = DeviceProtocol;
39
+ exports.default = DeviceProtocolBase;
@@ -1,8 +1,8 @@
1
- import DeviceProtocol from './DeviceProtocol';
1
+ import { DeviceProtocol } from './DeviceProtocol';
2
2
  export default class DeviceRegistry {
3
3
  static _reset(): void;
4
4
  static _get(): any[];
5
- static register(device: any): void;
6
- static findByName(name: any): DeviceProtocol;
7
- static findByInterface(interf: any): Array<DeviceProtocol>;
5
+ static register(protocol: DeviceProtocol): void;
6
+ static findByName(name: string): DeviceProtocol;
7
+ static findByInterface(interf: string): Array<DeviceProtocol>;
8
8
  }
@@ -1,33 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- let _devices = [];
3
+ let _protocols = [];
4
4
  class DeviceRegistry {
5
5
  static _reset() {
6
- _devices = [];
6
+ _protocols = [];
7
7
  }
8
8
  static _get() {
9
- return _devices;
9
+ return _protocols;
10
10
  }
11
- static register(device) {
12
- if (!device)
11
+ static register(protocol) {
12
+ if (!protocol)
13
13
  return;
14
- const idx = _devices.findIndex(d => d.getName() === device.getName());
14
+ const idx = _protocols.findIndex(d => d.getName() === protocol.getName());
15
15
  if (idx !== -1) {
16
- _devices[idx] = device;
16
+ _protocols[idx] = protocol;
17
17
  }
18
18
  else {
19
- _devices.push(device);
19
+ _protocols.push(protocol);
20
20
  }
21
21
  }
22
22
  static findByName(name) {
23
23
  if (!name)
24
24
  return;
25
- return _devices.find(d => d.getName() === name);
25
+ return _protocols.find(d => d.getName() === name);
26
26
  }
27
27
  static findByInterface(interf) {
28
28
  if (!interf)
29
29
  return;
30
- return _devices.filter(d => d.getInterfaces().findIndex(i => i === interf) !== -1);
30
+ return _protocols.filter(d => d.getInterfaces().findIndex(i => i === interf) !== -1);
31
31
  }
32
32
  }
33
33
  exports.default = DeviceRegistry;
@@ -1,13 +1,14 @@
1
1
  import DeviceRegistry from './DeviceRegistry';
2
- import Device from './Device';
3
- import DeviceProtocol, { INTERFACE } from './DeviceProtocol';
2
+ import DeviceAdapter from './Device';
3
+ import DeviceProtocolBase, { INTERFACE, DeviceProtocol } from './DeviceProtocol';
4
4
  import SimulatorProtocol from './simulator/Simulator';
5
5
  import DaumPremiumProtocol from './daum/premium/DaumPremiumProtocol';
6
6
  import DaumClassicProtocol from './daum/classic/DaumClassicProtocol';
7
7
  import { AntScanner } from './ant/AntScanner';
8
+ import { CyclingModeProperyType } from './CyclingMode';
8
9
  declare const Protocols: {
9
10
  SimulatorProtocol: typeof SimulatorProtocol;
10
11
  DaumClassicProtocol: typeof DaumClassicProtocol;
11
12
  DaumPremiumProtocol: typeof DaumPremiumProtocol;
12
13
  };
13
- export { DeviceProtocol, DeviceRegistry, INTERFACE, Device, Protocols, AntScanner, };
14
+ export { DeviceProtocolBase, DeviceProtocol, DeviceRegistry, INTERFACE, DeviceAdapter as Device, Protocols, AntScanner, CyclingModeProperyType };
@@ -1,18 +1,42 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
2
24
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AntScanner = exports.Protocols = exports.Device = exports.INTERFACE = exports.DeviceRegistry = exports.DeviceProtocol = void 0;
4
- const DeviceRegistry_1 = require("./DeviceRegistry");
25
+ exports.CyclingModeProperyType = exports.AntScanner = exports.Protocols = exports.Device = exports.INTERFACE = exports.DeviceRegistry = exports.DeviceProtocolBase = void 0;
26
+ const DeviceRegistry_1 = __importDefault(require("./DeviceRegistry"));
5
27
  exports.DeviceRegistry = DeviceRegistry_1.default;
6
- const Device_1 = require("./Device");
28
+ const Device_1 = __importDefault(require("./Device"));
7
29
  exports.Device = Device_1.default;
8
- const DeviceProtocol_1 = require("./DeviceProtocol");
9
- exports.DeviceProtocol = DeviceProtocol_1.default;
30
+ const DeviceProtocol_1 = __importStar(require("./DeviceProtocol"));
31
+ exports.DeviceProtocolBase = DeviceProtocol_1.default;
10
32
  Object.defineProperty(exports, "INTERFACE", { enumerable: true, get: function () { return DeviceProtocol_1.INTERFACE; } });
11
- const Simulator_1 = require("./simulator/Simulator");
12
- const DaumPremiumProtocol_1 = require("./daum/premium/DaumPremiumProtocol");
13
- const DaumClassicProtocol_1 = require("./daum/classic/DaumClassicProtocol");
33
+ const Simulator_1 = __importDefault(require("./simulator/Simulator"));
34
+ const DaumPremiumProtocol_1 = __importDefault(require("./daum/premium/DaumPremiumProtocol"));
35
+ const DaumClassicProtocol_1 = __importDefault(require("./daum/classic/DaumClassicProtocol"));
14
36
  const AntScanner_1 = require("./ant/AntScanner");
15
37
  Object.defineProperty(exports, "AntScanner", { enumerable: true, get: function () { return AntScanner_1.AntScanner; } });
38
+ const CyclingMode_1 = require("./CyclingMode");
39
+ Object.defineProperty(exports, "CyclingModeProperyType", { enumerable: true, get: function () { return CyclingMode_1.CyclingModeProperyType; } });
16
40
  const Protocols = {
17
41
  SimulatorProtocol: Simulator_1.default,
18
42
  DaumClassicProtocol: DaumClassicProtocol_1.default,
@@ -1,8 +1,9 @@
1
- import Device from "../Device";
1
+ import DeviceAdapter from "../Device";
2
2
  import { EventLogger } from 'gd-eventlog';
3
3
  export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
4
- export default class AntAdapter extends Device {
4
+ export default class AntAdapter extends DeviceAdapter {
5
5
  paused: boolean;
6
+ stopped: boolean;
6
7
  ignoreHrm: boolean;
7
8
  ignoreBike: boolean;
8
9
  ignorePower: boolean;
@@ -10,19 +11,23 @@ export default class AntAdapter extends Device {
10
11
  port: string;
11
12
  stick: any;
12
13
  channel: number;
14
+ sensor: any;
13
15
  deviceData: any;
14
16
  data: any;
15
17
  logger: EventLogger;
16
18
  lastUpdate?: number;
17
19
  updateFrequency: number;
18
20
  constructor(protocol: any);
21
+ setSensor(sensor: any): void;
19
22
  getID(): string;
20
23
  setIgnoreHrm(ignore: any): void;
21
24
  setIgnoreBike(ignore: any): void;
22
25
  setIgnorePower(ignore: any): void;
26
+ getProfile(): string;
23
27
  getPort(): string;
24
28
  setChannel(channel: any): void;
25
29
  setStick(stick: any): void;
30
+ isStopped(): boolean;
26
31
  onDeviceData(data: any): void;
27
32
  onDeviceEvent(data: any): void;
28
33
  onAttached(): void;
@@ -32,4 +37,6 @@ export default class AntAdapter extends Device {
32
37
  close(): void;
33
38
  pause(): Promise<boolean>;
34
39
  resume(): Promise<boolean>;
40
+ start(props?: any): Promise<any>;
41
+ stop(): Promise<boolean>;
35
42
  }
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.DEFAULT_UPDATE_FREQUENCY = void 0;
4
- const Device_1 = require("../Device");
7
+ const Device_1 = __importDefault(require("../Device"));
5
8
  exports.DEFAULT_UPDATE_FREQUENCY = 1000;
6
9
  class AntAdapter extends Device_1.default {
7
10
  constructor(protocol) {
8
11
  super(protocol);
9
12
  this.paused = false;
13
+ this.stopped = false;
10
14
  this.ignoreHrm = false;
11
15
  this.ignoreBike = false;
12
16
  this.ignorePower = false;
@@ -18,6 +22,9 @@ class AntAdapter extends Device_1.default {
18
22
  this.data = {};
19
23
  this.updateFrequency = exports.DEFAULT_UPDATE_FREQUENCY;
20
24
  }
25
+ setSensor(sensor) {
26
+ this.sensor = sensor;
27
+ }
21
28
  getID() {
22
29
  return this.deviceID;
23
30
  }
@@ -30,16 +37,21 @@ class AntAdapter extends Device_1.default {
30
37
  setIgnorePower(ignore) {
31
38
  this.ignorePower = ignore;
32
39
  }
40
+ getProfile() {
41
+ return "unknown";
42
+ }
33
43
  getPort() {
34
44
  return this.port;
35
45
  }
36
46
  setChannel(channel) {
37
- console.log('~~setChannel', this.getName(), channel);
38
47
  this.channel = channel;
39
48
  }
40
49
  setStick(stick) {
41
50
  this.stick = stick;
42
51
  }
52
+ isStopped() {
53
+ return this.stopped;
54
+ }
43
55
  onDeviceData(data) { }
44
56
  onDeviceEvent(data) { }
45
57
  onAttached() { }
@@ -59,5 +71,17 @@ class AntAdapter extends Device_1.default {
59
71
  resolve(true);
60
72
  });
61
73
  }
74
+ start(props) {
75
+ return new Promise(resolve => {
76
+ this.stopped = false;
77
+ resolve(true);
78
+ });
79
+ }
80
+ stop() {
81
+ return new Promise(resolve => {
82
+ this.stopped = true;
83
+ resolve(true);
84
+ });
85
+ }
62
86
  }
63
87
  exports.default = AntAdapter;