incyclist-devices 2.0.13 → 2.0.14

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 (49) hide show
  1. package/lib/antv2/adapter-factory.d.ts +2 -2
  2. package/lib/antv2/adapter-factory.js +3 -3
  3. package/lib/antv2/adapter.d.ts +1 -1
  4. package/lib/antv2/ant-interface.js +8 -8
  5. package/lib/antv2/fe/adapter.d.ts +1 -1
  6. package/lib/antv2/hr/adapter.d.ts +1 -1
  7. package/lib/antv2/pwr/adapter.d.ts +1 -1
  8. package/lib/antv2/types.d.ts +3 -3
  9. package/lib/ble/adapter-factory.js +4 -4
  10. package/lib/ble/base/comms.d.ts +1 -1
  11. package/lib/ble/bindings/mock.d.ts +1 -1
  12. package/lib/ble/bindings/types.d.ts +4 -4
  13. package/lib/ble/ble-interface.js +15 -15
  14. package/lib/ble/ble-peripheral.d.ts +1 -1
  15. package/lib/ble/cp/types.d.ts +2 -2
  16. package/lib/ble/fm/types.d.ts +2 -2
  17. package/lib/ble/hr/types.d.ts +1 -1
  18. package/lib/ble/tacx/types.d.ts +2 -2
  19. package/lib/ble/types.d.ts +7 -7
  20. package/lib/ble/utils.d.ts +1 -1
  21. package/lib/ble/wahoo/types.d.ts +1 -1
  22. package/lib/modes/cycling-mode.d.ts +4 -4
  23. package/lib/modes/simulator.d.ts +1 -1
  24. package/lib/serial/adapter-factory.js +3 -3
  25. package/lib/serial/adapter.js +4 -4
  26. package/lib/serial/comm.d.ts +1 -1
  27. package/lib/serial/daum/ERGCyclingMode.d.ts +1 -1
  28. package/lib/serial/daum/classic/comms.d.ts +2 -2
  29. package/lib/serial/daum/classic/mock.d.ts +3 -3
  30. package/lib/serial/daum/classic/mock.js +4 -4
  31. package/lib/serial/daum/classic/utils.d.ts +1 -1
  32. package/lib/serial/daum/premium/mock.d.ts +1 -1
  33. package/lib/serial/daum/premium/mock.js +4 -4
  34. package/lib/serial/daum/premium/types.d.ts +2 -2
  35. package/lib/serial/kettler/comms.d.ts +1 -1
  36. package/lib/serial/kettler/ergo-racer/mock.d.ts +1 -1
  37. package/lib/serial/kettler/ergo-racer/mock.js +4 -4
  38. package/lib/serial/kettler/ergo-racer/modes/erg.d.ts +1 -1
  39. package/lib/serial/serial-interface.d.ts +1 -1
  40. package/lib/serial/serial-interface.js +18 -19
  41. package/lib/serial/serialport.d.ts +3 -3
  42. package/lib/serial/serialport.js +4 -4
  43. package/lib/types/adapter.d.ts +1 -1
  44. package/lib/types/data.d.ts +1 -1
  45. package/lib/types/device.d.ts +4 -4
  46. package/lib/types/interface.d.ts +1 -1
  47. package/lib/types/route.d.ts +2 -2
  48. package/lib/types/user.d.ts +1 -1
  49. package/package.json +1 -1
@@ -2,12 +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
- export declare type AntAdapterInfo = {
5
+ export type AntAdapterInfo = {
6
6
  antProfile: Profile;
7
7
  incyclistProfile: LegacyProfile;
8
8
  Adapter: typeof AntAdapter<BaseDeviceData, DeviceData>;
9
9
  };
10
- export declare type AdapterQuery = {
10
+ export type AdapterQuery = {
11
11
  antProfile?: Profile;
12
12
  incyclistProfile?: LegacyProfile;
13
13
  };
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class AntAdapterFactory {
4
- constructor() {
5
- this.adapters = [];
6
- }
7
4
  static getInstance() {
8
5
  if (!AntAdapterFactory._instance)
9
6
  AntAdapterFactory._instance = new AntAdapterFactory();
10
7
  return AntAdapterFactory._instance;
11
8
  }
9
+ constructor() {
10
+ this.adapters = [];
11
+ }
12
12
  register(antProfile, incyclistProfile, Adapter) {
13
13
  const info = Object.assign({}, { antProfile, incyclistProfile, Adapter });
14
14
  const existing = this.adapters.findIndex(a => a.antProfile === antProfile);
@@ -8,7 +8,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 declare type BaseDeviceData = {
11
+ export type BaseDeviceData = {
12
12
  DeviceID: number;
13
13
  ManId?: number;
14
14
  };
@@ -16,6 +16,14 @@ const events_1 = __importDefault(require("events"));
16
16
  const gd_eventlog_1 = require("gd-eventlog");
17
17
  const sensor_factory_1 = __importDefault(require("./sensor-factory"));
18
18
  class AntInterface extends events_1.default {
19
+ static getInstance(props = {}) {
20
+ if (AntInterface._instance === undefined)
21
+ AntInterface._instance = new AntInterface(props);
22
+ return AntInterface._instance;
23
+ }
24
+ static hasInstance() {
25
+ return AntInterface._instance !== undefined;
26
+ }
19
27
  constructor(props) {
20
28
  super();
21
29
  this.props = props;
@@ -34,14 +42,6 @@ class AntInterface extends events_1.default {
34
42
  this.Binding = binding;
35
43
  }
36
44
  }
37
- static getInstance(props = {}) {
38
- if (AntInterface._instance === undefined)
39
- AntInterface._instance = new AntInterface(props);
40
- return AntInterface._instance;
41
- }
42
- static hasInstance() {
43
- return AntInterface._instance !== undefined;
44
- }
45
45
  getName() {
46
46
  return AntInterface.INTERFACE_NAME;
47
47
  }
@@ -2,7 +2,7 @@ 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
- declare type FitnessEquipmentSensorData = {
5
+ type FitnessEquipmentSensorData = {
6
6
  speed: number;
7
7
  slope: number;
8
8
  power: number;
@@ -1,7 +1,7 @@
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
- declare type HeartRateSensorData = {
4
+ type HeartRateSensorData = {
5
5
  heartrate: number;
6
6
  };
7
7
  export default class AntHrAdapter extends AntAdapter<HeartRateSensorState, HeartRateSensorData> {
@@ -2,7 +2,7 @@ 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
- declare type PowerSensorData = {
5
+ type PowerSensorData = {
6
6
  speed: number;
7
7
  slope: number;
8
8
  power: number;
@@ -6,10 +6,10 @@ export interface AntDeviceSettings extends DeviceSettings {
6
6
  profile: Profile | LegacyProfile;
7
7
  protocol?: string;
8
8
  }
9
- export declare type LegacyProfile = 'Heartrate Monitor' | 'Power Meter' | 'Smart Trainer' | 'Speed Sensor' | 'Cadence Sensor' | 'Speed + Cadence Sensor';
9
+ export type LegacyProfile = 'Heartrate Monitor' | 'Power Meter' | 'Smart Trainer' | 'Speed Sensor' | 'Cadence Sensor' | 'Speed + Cadence Sensor';
10
10
  export declare const isLegacyProfile: (o: unknown) => boolean;
11
- export declare type DeviceFoundCallback = (device: IncyclistDevice, protocol: string) => void;
12
- export declare type ScanFinishedCallback = (id: number) => void;
11
+ export type DeviceFoundCallback = (device: IncyclistDevice, protocol: string) => void;
12
+ export type ScanFinishedCallback = (id: number) => void;
13
13
  export interface AntScanProps extends IncyclistScanProps {
14
14
  profiles?: Profile[];
15
15
  id?: number;
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const comms_utils_1 = require("./base/comms-utils");
4
4
  const utils_1 = require("./utils");
5
5
  class BleAdapterFactory {
6
- constructor() {
7
- this.implementations = [];
8
- this.instances = [];
9
- }
10
6
  static getInstance() {
11
7
  if (!BleAdapterFactory._instance)
12
8
  BleAdapterFactory._instance = new BleAdapterFactory();
13
9
  return BleAdapterFactory._instance;
14
10
  }
11
+ constructor() {
12
+ this.implementations = [];
13
+ this.instances = [];
14
+ }
15
15
  getAdapterInfo(protocol) {
16
16
  return this.implementations.find(a => a.protocol === protocol);
17
17
  }
@@ -7,7 +7,7 @@ import { LegacyProfile } from "../../antv2/types";
7
7
  import BleInterface from "../ble-interface";
8
8
  import BlePeripheralConnector from "../ble-peripheral";
9
9
  import { BleCharacteristic, BleCommsConnectProps, BleDeviceConstructProps, BleDeviceInfo, BleDeviceSettings, BlePeripheral, BleProtocol, BleWriteProps, ConnectState, IBlePeripheralConnector } from "../types";
10
- declare type CommandQueueItem = {
10
+ type CommandQueueItem = {
11
11
  uuid: string;
12
12
  data: Buffer;
13
13
  timeout: number;
@@ -1,5 +1,5 @@
1
1
  import { PrimaryService } from './types';
2
- export declare type BleMockPeripheral = {
2
+ export type BleMockPeripheral = {
3
3
  services: PrimaryService[];
4
4
  id: string;
5
5
  name: string;
@@ -3,12 +3,12 @@
3
3
  /// <reference types="node" />
4
4
  import EventEmitter from "events";
5
5
  import { BleCharacteristic } from "../types";
6
- export declare type Property = 'read' | 'write' | 'notify' | 'indicate';
7
- export declare type Descriptor = {
6
+ export type Property = 'read' | 'write' | 'notify' | 'indicate';
7
+ export type Descriptor = {
8
8
  uuid: string;
9
9
  value: string | Buffer;
10
10
  };
11
- export declare type Characteristic = {
11
+ export type Characteristic = {
12
12
  uuid: string;
13
13
  properties: Property[];
14
14
  secure?: boolean;
@@ -51,7 +51,7 @@ export declare abstract class StaticNotifyCharacteristic extends MockCharacteris
51
51
  startNotify(): void;
52
52
  stopNotify(): void;
53
53
  }
54
- export declare type PrimaryService = {
54
+ export type PrimaryService = {
55
55
  uuid: string;
56
56
  characteristics: Characteristic[];
57
57
  };
@@ -21,21 +21,6 @@ const events_1 = __importDefault(require("events"));
21
21
  const utils_2 = require("../utils/utils");
22
22
  const DEFAULT_SCAN_TIMEOUT = 20000;
23
23
  class BleInterface extends events_1.default {
24
- constructor(props = {}) {
25
- super();
26
- this.scanState = { isScanning: false, isConnecting: false, timeout: undefined, isBackgroundScan: false };
27
- this.connectState = { isConnecting: false, isConnected: false, isInitSuccess: false };
28
- this.emittingAdapters = [];
29
- this.props = props;
30
- if (props.binding)
31
- this.setBinding(props.binding);
32
- this.peripheralCache = new peripheral_cache_1.default();
33
- this.connectedDevices = [];
34
- if (props.logger)
35
- this.logger = props.logger;
36
- else
37
- this.logger = new gd_eventlog_1.EventLogger('BLE');
38
- }
39
24
  static getInstance(props = {}) {
40
25
  if (!BleInterface._instance) {
41
26
  BleInterface._instance = new BleInterface(props);
@@ -53,6 +38,21 @@ class BleInterface extends events_1.default {
53
38
  }
54
39
  return BleInterface._instance;
55
40
  }
41
+ constructor(props = {}) {
42
+ super();
43
+ this.scanState = { isScanning: false, isConnecting: false, timeout: undefined, isBackgroundScan: false };
44
+ this.connectState = { isConnecting: false, isConnected: false, isInitSuccess: false };
45
+ this.emittingAdapters = [];
46
+ this.props = props;
47
+ if (props.binding)
48
+ this.setBinding(props.binding);
49
+ this.peripheralCache = new peripheral_cache_1.default();
50
+ this.connectedDevices = [];
51
+ if (props.logger)
52
+ this.logger = props.logger;
53
+ else
54
+ this.logger = new gd_eventlog_1.EventLogger('BLE');
55
+ }
56
56
  getBinding() { return this.binding; }
57
57
  setBinding(binding) { if (binding)
58
58
  this.binding = binding; }
@@ -1,5 +1,5 @@
1
1
  import { BleCharacteristic, BlePeripheral, IBlePeripheralConnector } from './types';
2
- export declare type ConnectorState = {
2
+ export type ConnectorState = {
3
3
  isConnected: boolean;
4
4
  isConnecting: boolean;
5
5
  isInitialized: boolean;
@@ -1,4 +1,4 @@
1
- export declare type PowerData = {
1
+ export type PowerData = {
2
2
  instantaneousPower?: number;
3
3
  balance?: number;
4
4
  accTorque?: number;
@@ -6,7 +6,7 @@ export declare type PowerData = {
6
6
  rpm: number;
7
7
  raw?: string;
8
8
  };
9
- export declare type CrankData = {
9
+ export type CrankData = {
10
10
  revolutions?: number;
11
11
  time?: number;
12
12
  cntUpdateMissing?: number;
@@ -1,4 +1,4 @@
1
- export declare type IndoorBikeData = {
1
+ export type IndoorBikeData = {
2
2
  speed?: number;
3
3
  averageSpeed?: number;
4
4
  cadence?: number;
@@ -19,7 +19,7 @@ export declare type IndoorBikeData = {
19
19
  targetInclination?: number;
20
20
  status?: string;
21
21
  };
22
- export declare type IndoorBikeFeatures = {
22
+ export type IndoorBikeFeatures = {
23
23
  fitnessMachine: number;
24
24
  targetSettings: number;
25
25
  power?: boolean;
@@ -1,4 +1,4 @@
1
- export declare type HrmData = {
1
+ export type HrmData = {
2
2
  heartrate: number;
3
3
  rr: number;
4
4
  raw: string;
@@ -15,11 +15,11 @@ export interface BleFeBikeData extends IndoorBikeData {
15
15
  SwVersion?: number;
16
16
  SerialNumber?: number;
17
17
  }
18
- export declare type MessageInfo = {
18
+ export type MessageInfo = {
19
19
  message: string;
20
20
  ts: number;
21
21
  uuid: string;
22
22
  };
23
- export declare type MessageLog = {
23
+ export type MessageLog = {
24
24
  [uuid: string]: MessageInfo;
25
25
  };
@@ -4,8 +4,8 @@ import EventEmitter from "events";
4
4
  import { EventLogger } from "gd-eventlog";
5
5
  import { DeviceProperties, DeviceSettings, DeviceStartProperties, IncyclistScanProps } from "../types/device";
6
6
  import { InterfaceProps } from "../types/interface";
7
- export declare type BleProtocol = 'hr' | 'fm' | 'cp' | 'tacx' | 'wahoo' | 'elite';
8
- export declare type BleInterfaceState = 'unknown' | 'resetting' | 'unsupported' | 'unauthorized' | 'poweredOff' | 'poweredOn';
7
+ export type BleProtocol = 'hr' | 'fm' | 'cp' | 'tacx' | 'wahoo' | 'elite';
8
+ export type BleInterfaceState = 'unknown' | 'resetting' | 'unsupported' | 'unauthorized' | 'poweredOff' | 'poweredOn';
9
9
  export interface BleBinding extends EventEmitter {
10
10
  startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error?: Error) => void): void;
11
11
  stopScanning(callback?: () => void): void;
@@ -48,10 +48,10 @@ export interface BleInterfaceProps extends InterfaceProps {
48
48
  timeout?: number;
49
49
  reconnect?: boolean;
50
50
  }
51
- export declare type BleService = {
51
+ export type BleService = {
52
52
  uuid: string;
53
53
  };
54
- export declare type DiscoverResult = {
54
+ export type DiscoverResult = {
55
55
  services: BleService[];
56
56
  characteristics: BleCharacteristic[];
57
57
  };
@@ -90,14 +90,14 @@ export interface BleCharacteristic extends EventEmitter {
90
90
  read(callback: (err: Error | undefined, data: Buffer) => void): void;
91
91
  write(data: Buffer, withoutResponse: boolean, callback?: (err: Error | undefined) => void): void;
92
92
  }
93
- export declare type BleDeviceProps = {
93
+ export type BleDeviceProps = {
94
94
  id?: string;
95
95
  address?: string;
96
96
  name?: string;
97
97
  services?: string[];
98
98
  peripheral?: BlePeripheral;
99
99
  };
100
- export declare type BleCommsConnectProps = {
100
+ export type BleCommsConnectProps = {
101
101
  timeout?: number;
102
102
  reconnect?: boolean;
103
103
  };
@@ -118,7 +118,7 @@ export interface ConnectState {
118
118
  isConnected: boolean;
119
119
  isDisconnecting: boolean;
120
120
  }
121
- export declare type BleDeviceInfo = {
121
+ export type BleDeviceInfo = {
122
122
  manufacturer?: string;
123
123
  hwRevision?: string;
124
124
  swRevision?: string;
@@ -1,6 +1,6 @@
1
1
  import { LegacyProfile } from "../antv2/types";
2
2
  import { BleCharacteristic, BlePeripheral, BleProtocol } from "./types";
3
- declare type MappingRecord = {
3
+ type MappingRecord = {
4
4
  profile: LegacyProfile;
5
5
  protocol: BleProtocol;
6
6
  };
@@ -1,4 +1,4 @@
1
- export declare type IndoorBikeData = {
1
+ export type IndoorBikeData = {
2
2
  speed?: number;
3
3
  averageSpeed?: number;
4
4
  cadence?: number;
@@ -1,5 +1,5 @@
1
1
  import { IncyclistDeviceAdapter } from "../types/adapter";
2
- export declare type UpdateRequest = {
2
+ export type UpdateRequest = {
3
3
  slope?: number;
4
4
  minPower?: number;
5
5
  maxPower?: number;
@@ -17,7 +17,7 @@ export declare enum CyclingModeProperyType {
17
17
  SingleSelect = "SingleSelect",
18
18
  MultiSelect = "MultiSelect"
19
19
  }
20
- export declare type CyclingModeProperty = {
20
+ export type CyclingModeProperty = {
21
21
  key: string;
22
22
  name: string;
23
23
  description: string;
@@ -27,7 +27,7 @@ export declare type CyclingModeProperty = {
27
27
  default?: any;
28
28
  options?: any[];
29
29
  };
30
- export declare type IncyclistBikeData = {
30
+ export type IncyclistBikeData = {
31
31
  isPedalling: boolean;
32
32
  power: number;
33
33
  pedalRpm: number;
@@ -38,7 +38,7 @@ export declare type IncyclistBikeData = {
38
38
  gear?: number;
39
39
  slope?: number;
40
40
  };
41
- export declare type Settings = {
41
+ export type Settings = {
42
42
  [key: string]: any;
43
43
  };
44
44
  export default interface CyclingMode {
@@ -2,7 +2,7 @@ import { EventLogger } from "gd-eventlog";
2
2
  import { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "../modes/cycling-mode";
3
3
  import { Simulator } from "../simulator/Simulator";
4
4
  import PowerBasedCyclingModeBase from "./power-base";
5
- export declare type ERGEvent = {
5
+ export type ERGEvent = {
6
6
  rpmUpdated?: boolean;
7
7
  gearUpdated?: boolean;
8
8
  starting?: boolean;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class SerialAdapterFactory {
4
- constructor() {
5
- this.adapters = [];
6
- }
7
4
  static getInstance() {
8
5
  if (!SerialAdapterFactory._instance)
9
6
  SerialAdapterFactory._instance = new SerialAdapterFactory();
10
7
  return SerialAdapterFactory._instance;
11
8
  }
9
+ constructor() {
10
+ this.adapters = [];
11
+ }
12
12
  registerAdapter(protocol, AdapterClass) {
13
13
  const existing = this.adapters.findIndex(a => a.protocol === protocol);
14
14
  if (existing !== -1)
@@ -13,14 +13,14 @@ exports.SerialIncyclistDevice = void 0;
13
13
  const adpater_1 = require("../base/adpater");
14
14
  const DEFAULT_PULL_FREQUENCY = 1000;
15
15
  class SerialIncyclistDevice extends adpater_1.ControllableDevice {
16
- constructor(settings, props) {
17
- super(settings, props);
18
- this.pullFrequency = DEFAULT_PULL_FREQUENCY;
19
- }
20
16
  check() {
21
17
  return __awaiter(this, void 0, void 0, function* () { throw new Error('not implemnted'); });
22
18
  }
23
19
  ;
20
+ constructor(settings, props) {
21
+ super(settings, props);
22
+ this.pullFrequency = DEFAULT_PULL_FREQUENCY;
23
+ }
24
24
  isEqual(settings) {
25
25
  if (settings.interface !== this.getInterface())
26
26
  return false;
@@ -1,6 +1,6 @@
1
1
  import { EventLogger } from "gd-eventlog";
2
2
  import SerialInterface from "./serial-interface";
3
- export declare type SerialCommProps = {
3
+ export type SerialCommProps = {
4
4
  serial: SerialInterface;
5
5
  path: string;
6
6
  logger?: EventLogger;
@@ -1,7 +1,7 @@
1
1
  import CyclingMode, { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "../../modes/cycling-mode";
2
2
  import DaumAdapter from "./DaumAdapter";
3
3
  import PowerBasedCyclingModeBase from "../../modes/power-base";
4
- export declare type ERGEvent = {
4
+ export type ERGEvent = {
5
5
  rpmUpdated?: boolean;
6
6
  gearUpdated?: boolean;
7
7
  starting?: boolean;
@@ -3,8 +3,8 @@ import { Queue } from '../../../utils/utils';
3
3
  import { User } from '../../../types/user';
4
4
  import { SerialInterface, SerialPortProvider } from '../..';
5
5
  import { SerialCommProps } from '../../comm';
6
- declare type SuccessCallbackFn = (data: any) => void;
7
- declare type ErrorCallbackFn = (status: number, error: any) => void;
6
+ type SuccessCallbackFn = (data: any) => void;
7
+ type ErrorCallbackFn = (status: number, error: any) => void;
8
8
  interface CommandInstructions {
9
9
  logStr: string;
10
10
  payload: Array<number>;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
3
3
  import { BindingInterface } from '@serialport/bindings-interface';
4
- export declare type MockProps = {
4
+ export type MockProps = {
5
5
  interface: string;
6
6
  path: string;
7
7
  };
@@ -27,7 +27,7 @@ export declare class DaumClassicMockImpl {
27
27
  list(): Promise<import("@serialport/bindings-interface").PortInfo[]>;
28
28
  open(options: any): Promise<DaumClassicMockBinding>;
29
29
  }
30
- export declare type DaumClassicUser = {
30
+ export type DaumClassicUser = {
31
31
  weight: number;
32
32
  length?: number;
33
33
  age?: number;
@@ -70,7 +70,7 @@ export declare class DaumClassicSimulator {
70
70
  simulateTimeout(ms: number): void;
71
71
  simulateNoResponse(cnt?: number): void;
72
72
  simulateIllegalResponse(cnt?: number): void;
73
- isPedalling(): 1 | 0;
73
+ isPedalling(): 0 | 1;
74
74
  }
75
75
  export declare class DaumClassicMockBinding extends MockPortBinding {
76
76
  prevCommand: Buffer;
@@ -36,10 +36,6 @@ exports.DaumClassicMock = {
36
36
  }
37
37
  };
38
38
  class DaumClassicMockImpl {
39
- constructor() {
40
- this.simulators = new Map();
41
- this.ports = [];
42
- }
43
39
  static getInstance() {
44
40
  if (!DaumClassicMockImpl._instance)
45
41
  DaumClassicMockImpl._instance = new DaumClassicMockImpl();
@@ -50,6 +46,10 @@ class DaumClassicMockImpl {
50
46
  __1.SerialPortProvider._instance = undefined;
51
47
  __1.SerialInterface._instances = [];
52
48
  }
49
+ constructor() {
50
+ this.simulators = new Map();
51
+ this.ports = [];
52
+ }
53
53
  setSimulator(path, simulator) {
54
54
  this.simulators.set(path, simulator);
55
55
  }
@@ -2,7 +2,7 @@ export declare const DEFAULT_AGE = 30;
2
2
  export declare const DEFAULT_USER_WEIGHT = 75;
3
3
  export declare const DEFAULT_BIKE_WEIGHT = 10;
4
4
  export declare function getCockpit(c: any): "Cardio" | "Fitness" | "Vita De Luxe" | "8008" | "8008 TRS" | "8080" | "Therapie" | "8008 TRS Pro" | "8008 TRS3" | "ergo_lyps Cardio Pro" | "Unknown";
5
- export declare function getBikeType(type: any): 1 | 0;
5
+ export declare function getBikeType(type: any): 0 | 1;
6
6
  export declare function getGender(sex: any): 1 | 2;
7
7
  export declare function getLength(length: any): number;
8
8
  export declare function getWeight(weight?: any): number;
@@ -2,7 +2,7 @@
2
2
  import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
3
3
  import { BindingInterface, PortInfo } from '@serialport/bindings-interface';
4
4
  import { User } from '../../../types/user';
5
- export declare type MockProps = {
5
+ export type MockProps = {
6
6
  interface: string;
7
7
  path: string;
8
8
  };
@@ -34,10 +34,6 @@ exports.Daum8iMock = {
34
34
  }
35
35
  };
36
36
  class Daum8iMockImpl {
37
- constructor() {
38
- this.simulators = new Map();
39
- this.ports = [];
40
- }
41
37
  static getInstance() {
42
38
  if (!Daum8iMockImpl._instance)
43
39
  Daum8iMockImpl._instance = new Daum8iMockImpl();
@@ -48,6 +44,10 @@ class Daum8iMockImpl {
48
44
  __1.SerialPortProvider._instance = undefined;
49
45
  __1.SerialInterface._instances = [];
50
46
  }
47
+ constructor() {
48
+ this.simulators = new Map();
49
+ this.ports = [];
50
+ }
51
51
  setSimulator(path, simulator) {
52
52
  this.simulators.set(path, simulator);
53
53
  }
@@ -1,7 +1,7 @@
1
1
  import { DeviceProperties } from "../../../types/device";
2
2
  import { Route } from "../../../types/route";
3
- export declare type OnDeviceStartCallback = (completed: number, total: number) => void;
4
- export declare type DaumPremiumAdapterProps = {
3
+ export type OnDeviceStartCallback = (completed: number, total: number) => void;
4
+ export type DaumPremiumAdapterProps = {
5
5
  path: string;
6
6
  ifaceName: string;
7
7
  };
@@ -4,7 +4,7 @@ import { EventLogger } from "gd-eventlog";
4
4
  import { Command } from "../../types/command";
5
5
  import EventEmitter from "events";
6
6
  import { SerialInterface } from "..";
7
- export declare type SerialCommsProps = {
7
+ export type SerialCommsProps = {
8
8
  logger?: EventLogger;
9
9
  interface: string | SerialInterface;
10
10
  port: string;
@@ -2,7 +2,7 @@
2
2
  import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
3
3
  import { BindingInterface, PortInfo } from '@serialport/bindings-interface';
4
4
  import { User } from '../../../types/user';
5
- export declare type MockProps = {
5
+ export type MockProps = {
6
6
  interface: string;
7
7
  path: string;
8
8
  };
@@ -40,10 +40,6 @@ exports.KettlerRacerMock = {
40
40
  }
41
41
  };
42
42
  class KettlerRacerMockImpl {
43
- constructor() {
44
- this.simulators = new Map();
45
- this.ports = [];
46
- }
47
43
  static getInstance() {
48
44
  if (!KettlerRacerMockImpl._instance)
49
45
  KettlerRacerMockImpl._instance = new KettlerRacerMockImpl();
@@ -54,6 +50,10 @@ class KettlerRacerMockImpl {
54
50
  __1.SerialPortProvider._instance = undefined;
55
51
  __1.SerialInterface._instances = [];
56
52
  }
53
+ constructor() {
54
+ this.simulators = new Map();
55
+ this.ports = [];
56
+ }
57
57
  setSimulator(path, simulator) {
58
58
  this.simulators.set(path, simulator);
59
59
  }
@@ -1,7 +1,7 @@
1
1
  import CyclingMode, { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from '../../../../modes/cycling-mode';
2
2
  import KettlerAdapter from "../adapter";
3
3
  import PowerBasedCyclingModeBase from '../../../../modes/power-base';
4
- export declare type ERGEvent = {
4
+ export type ERGEvent = {
5
5
  rpmUpdated?: boolean;
6
6
  gearUpdated?: boolean;
7
7
  starting?: boolean;
@@ -15,7 +15,7 @@ export interface SerialInterfaceProps extends InterfaceProps {
15
15
  ifaceName: string;
16
16
  binding?: BindingInterface;
17
17
  }
18
- export declare type PortMapping = {
18
+ export type PortMapping = {
19
19
  path: string;
20
20
  port: SerialPortStream;
21
21
  };
@@ -90,24 +90,6 @@ class SinglePathScanner {
90
90
  }
91
91
  exports.SinglePathScanner = SinglePathScanner;
92
92
  class SerialInterface extends events_1.default {
93
- constructor(props) {
94
- super();
95
- const { ifaceName, binding } = props;
96
- this.ifaceName = ifaceName;
97
- this.binding = undefined;
98
- this.ports = [];
99
- this.isScanning = false;
100
- this.isStopScanRequested = false;
101
- this.scanEvents = new events_1.default();
102
- this.scanEvents.setMaxListeners(100);
103
- this.logger = props.logger || new gd_eventlog_1.EventLogger(`Serial:${ifaceName}`);
104
- this.connected = false;
105
- this.logEvent({ message: 'new serial interface', ifaceName });
106
- if (binding) {
107
- this.setBinding(binding);
108
- }
109
- SerialInterface._add(this);
110
- }
111
93
  static getInstance(props) {
112
94
  const { ifaceName, binding, logger } = props;
113
95
  let instance = SerialInterface._instances.find(i => i.ifaceName === ifaceName);
@@ -129,6 +111,24 @@ class SerialInterface extends events_1.default {
129
111
  else
130
112
  SerialInterface._instances.push(instance);
131
113
  }
114
+ constructor(props) {
115
+ super();
116
+ const { ifaceName, binding } = props;
117
+ this.ifaceName = ifaceName;
118
+ this.binding = undefined;
119
+ this.ports = [];
120
+ this.isScanning = false;
121
+ this.isStopScanRequested = false;
122
+ this.scanEvents = new events_1.default();
123
+ this.scanEvents.setMaxListeners(100);
124
+ this.logger = props.logger || new gd_eventlog_1.EventLogger(`Serial:${ifaceName}`);
125
+ this.connected = false;
126
+ this.logEvent({ message: 'new serial interface', ifaceName });
127
+ if (binding) {
128
+ this.setBinding(binding);
129
+ }
130
+ SerialInterface._add(this);
131
+ }
132
132
  logEvent(event) {
133
133
  if (this.logger) {
134
134
  this.logger.logEvent(event);
@@ -187,7 +187,6 @@ class SerialInterface extends events_1.default {
187
187
  this.ports.splice(existing, 1);
188
188
  }
189
189
  }
190
- this.logEvent({ message: 'opening port - getSerialPort()', path });
191
190
  const port = serialport_1.default.getInstance().getSerialPort(this.ifaceName, { path });
192
191
  if (!port) {
193
192
  this.logEvent({ message: 'opening port - port does not exist', path });
@@ -1,14 +1,14 @@
1
1
  import { BindingInterface } from '@serialport/bindings-interface';
2
- export declare type InterfaceBinding = {
2
+ export type InterfaceBinding = {
3
3
  name: string;
4
4
  binding: BindingInterface;
5
5
  };
6
- export declare type InterfaceImplementation = {
6
+ export type InterfaceImplementation = {
7
7
  name: string;
8
8
  Serialport: any;
9
9
  implementation?: any;
10
10
  };
11
- export declare type SerialPortProps = {
11
+ export type SerialPortProps = {
12
12
  interface: string;
13
13
  port?: string;
14
14
  };
@@ -13,15 +13,15 @@ exports.useSerialPortProvider = void 0;
13
13
  const { SerialPortStream } = require('@serialport/stream');
14
14
  const DEFAULT_BAUD_RATE = 9600;
15
15
  class SerialPortProvider {
16
- constructor() {
17
- this.interfaces = [];
18
- this.implemenations = [];
19
- }
20
16
  static getInstance() {
21
17
  if (!SerialPortProvider._instance)
22
18
  SerialPortProvider._instance = new SerialPortProvider();
23
19
  return SerialPortProvider._instance;
24
20
  }
21
+ constructor() {
22
+ this.interfaces = [];
23
+ this.implemenations = [];
24
+ }
25
25
  setBinding(ifaceName, binding) {
26
26
  const existing = this.interfaces.find(ib => ib.name === ifaceName);
27
27
  if (existing)
@@ -5,7 +5,7 @@ import { IncyclistCapability } from "./capabilities";
5
5
  import { DeviceData } from "./data";
6
6
  import { DeviceProperties, DeviceSettings } from "./device";
7
7
  import { User } from "./user";
8
- export declare type OnDeviceDataCallback = (data: DeviceData) => void;
8
+ export type OnDeviceDataCallback = (data: DeviceData) => void;
9
9
  export interface IncyclistDeviceAdapter extends EventEmitter {
10
10
  connect(): Promise<boolean>;
11
11
  close(): Promise<boolean>;
@@ -1,4 +1,4 @@
1
- export declare type DeviceData = {
1
+ export type DeviceData = {
2
2
  speed?: number;
3
3
  slope?: number;
4
4
  power?: number;
@@ -9,12 +9,12 @@ export declare const INTERFACE: {
9
9
  USB: string;
10
10
  SIMULATOR: string;
11
11
  };
12
- export declare type Device = {
12
+ export type Device = {
13
13
  getID(): string;
14
14
  getName(): string;
15
15
  getInterface(): string;
16
16
  };
17
- export declare type DeviceProperties = {
17
+ export type DeviceProperties = {
18
18
  user?: User;
19
19
  userWeight?: number;
20
20
  bikeWeight?: number;
@@ -22,11 +22,11 @@ export declare type DeviceProperties = {
22
22
  export interface DeviceStartProperties extends DeviceProperties {
23
23
  timeout?: number;
24
24
  }
25
- export declare type IncyclistScanProps = {
25
+ export type IncyclistScanProps = {
26
26
  timeout?: number;
27
27
  logger?: EventLogger;
28
28
  };
29
- export declare type DeviceSettings = {
29
+ export type DeviceSettings = {
30
30
  interface: string | IncyclistInterface;
31
31
  name?: string;
32
32
  };
@@ -2,7 +2,7 @@
2
2
  import EventEmitter from "events";
3
3
  import { EventLogger } from "gd-eventlog";
4
4
  import { IncyclistScanProps, DeviceSettings } from "./device";
5
- export declare type InterfaceProps = {
5
+ export type InterfaceProps = {
6
6
  binding?: any;
7
7
  logger?: EventLogger;
8
8
  log?: boolean;
@@ -1,4 +1,4 @@
1
- export declare type Point = {
1
+ export type Point = {
2
2
  lat?: number;
3
3
  lng?: number;
4
4
  elevation?: number;
@@ -10,7 +10,7 @@ export declare enum RouteType {
10
10
  FOLLOW_ROUTE = "follow route",
11
11
  VIDEO = "video"
12
12
  }
13
- export declare type Route = {
13
+ export type Route = {
14
14
  programId: number;
15
15
  points: Point[];
16
16
  type: string;
@@ -3,7 +3,7 @@ export declare enum Gender {
3
3
  FEMALE = "F",
4
4
  OTHERS = "o"
5
5
  }
6
- export declare type User = {
6
+ export type User = {
7
7
  weight?: number;
8
8
  length?: number;
9
9
  age?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.13",
3
+ "version": "2.0.14",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",