incyclist-devices 1.3.0 → 1.4.1

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 (71) hide show
  1. package/lib/CyclingMode.d.ts +72 -0
  2. package/lib/CyclingMode.js +66 -0
  3. package/lib/Device.d.ts +48 -10
  4. package/lib/Device.js +9 -8
  5. package/lib/DeviceProtocol.d.ts +40 -12
  6. package/lib/DeviceProtocol.js +16 -16
  7. package/lib/DeviceRegistry.d.ts +4 -4
  8. package/lib/DeviceRegistry.js +10 -10
  9. package/lib/DeviceSupport.d.ts +4 -3
  10. package/lib/DeviceSupport.js +32 -8
  11. package/lib/ant/AntAdapter.d.ts +7 -3
  12. package/lib/ant/AntAdapter.js +23 -3
  13. package/lib/ant/AntScanner.d.ts +15 -6
  14. package/lib/ant/AntScanner.js +372 -128
  15. package/lib/ant/antfe/AntFEAdapter.d.ts +1 -1
  16. package/lib/ant/antfe/AntFEAdapter.js +191 -92
  17. package/lib/ant/anthrm/AntHrmAdapter.d.ts +3 -1
  18. package/lib/ant/anthrm/AntHrmAdapter.js +70 -19
  19. package/lib/ant/utils.js +2 -1
  20. package/lib/calculations.d.ts +12 -13
  21. package/lib/calculations.js +88 -125
  22. package/lib/daum/DaumAdapter.d.ts +29 -6
  23. package/lib/daum/DaumAdapter.js +219 -96
  24. package/lib/daum/ERGCyclingMode.d.ts +28 -0
  25. package/lib/daum/ERGCyclingMode.js +207 -0
  26. package/lib/daum/PowerMeterCyclingMode.d.ts +18 -0
  27. package/lib/daum/PowerMeterCyclingMode.js +79 -0
  28. package/lib/daum/SmartTrainerCyclingMode.d.ts +41 -0
  29. package/lib/daum/SmartTrainerCyclingMode.js +344 -0
  30. package/lib/daum/classic/DaumClassicAdapter.d.ts +3 -1
  31. package/lib/daum/classic/DaumClassicAdapter.js +46 -32
  32. package/lib/daum/classic/DaumClassicCyclingMode.d.ts +13 -0
  33. package/lib/daum/classic/DaumClassicCyclingMode.js +98 -0
  34. package/lib/daum/classic/DaumClassicProtocol.d.ts +5 -3
  35. package/lib/daum/classic/DaumClassicProtocol.js +47 -8
  36. package/lib/daum/classic/ERGCyclingMode.d.ts +23 -0
  37. package/lib/daum/classic/ERGCyclingMode.js +171 -0
  38. package/lib/daum/classic/bike.d.ts +41 -37
  39. package/lib/daum/classic/bike.js +86 -53
  40. package/lib/daum/classic/utils.d.ts +3 -3
  41. package/lib/daum/classic/utils.js +18 -10
  42. package/lib/daum/indoorbike.d.ts +2 -1
  43. package/lib/daum/indoorbike.js +23 -21
  44. package/lib/daum/premium/DaumPremiumAdapter.d.ts +2 -2
  45. package/lib/daum/premium/DaumPremiumAdapter.js +30 -20
  46. package/lib/daum/premium/DaumPremiumProtocol.d.ts +11 -2
  47. package/lib/daum/premium/DaumPremiumProtocol.js +57 -10
  48. package/lib/daum/premium/bike.d.ts +63 -52
  49. package/lib/daum/premium/bike.js +254 -207
  50. package/lib/daum/premium/tcpserial.d.ts +18 -14
  51. package/lib/daum/premium/tcpserial.js +44 -20
  52. package/lib/daum/premium/utils.d.ts +2 -2
  53. package/lib/simulator/Simulator.d.ts +13 -7
  54. package/lib/simulator/Simulator.js +62 -21
  55. package/lib/utils.d.ts +3 -1
  56. package/lib/utils.js +39 -18
  57. package/package.json +12 -11
  58. package/lib/ant/AntScanner.unit.tests.d.ts +0 -1
  59. package/lib/ant/AntScanner.unit.tests.js +0 -25
  60. package/lib/ant/antfe/AntFEProcessor.d.ts +0 -40
  61. package/lib/ant/antfe/AntFEProcessor.js +0 -238
  62. package/lib/ant/antfe/AntHrmProtocol.d.ts +0 -9
  63. package/lib/ant/antfe/AntHrmProtocol.js +0 -30
  64. package/lib/ant/antfe/FEDevice.d.ts +0 -1
  65. package/lib/ant/antfe/FEDevice.js +0 -7
  66. package/lib/ant/antfe/bike.d.ts +0 -47
  67. package/lib/ant/antfe/bike.js +0 -602
  68. package/lib/ant/anthrm/anthrm.d.ts +0 -33
  69. package/lib/ant/anthrm/anthrm.js +0 -523
  70. package/lib/simulator/Simulator.unit.tests.d.ts +0 -1
  71. package/lib/simulator/Simulator.unit.tests.js +0 -79
@@ -1,29 +1,33 @@
1
+ import { EventLogger } from 'gd-eventlog';
1
2
  export default class TcpSocketPort {
2
- static setResponse(command: any, fn: any): void;
3
- static getReponseHandler(command: any): any;
4
- static reset(): void;
5
- constructor(props: any);
6
- callbacks: {};
7
- isOpen: boolean;
8
- props: any;
9
- enabled: any;
10
- host: any;
11
- port: any;
3
+ callbacks: any;
4
+ enabled: boolean;
5
+ host: string;
6
+ port: number;
12
7
  net: any;
13
- path: string;
8
+ props: any;
14
9
  socket: any;
15
- outputQueue: any[];
10
+ id: number;
11
+ isOpen: boolean;
12
+ isClosed: boolean;
13
+ path: string;
14
+ outputQueue: Array<any>;
16
15
  iv: any;
16
+ logger: EventLogger;
17
+ constructor(props: any);
17
18
  flush(): void;
18
- open(): void;
19
+ open(retry?: boolean): void;
19
20
  close(): void;
20
- isClosed: boolean;
21
21
  onTimeout(): void;
22
22
  onConnect(): void;
23
23
  onError(err: any): void;
24
24
  on(event: any, callback: any): void;
25
+ removeAllListeners(): void;
25
26
  emit(event: any, ...args: any[]): void;
26
27
  write(message: any): void;
27
28
  unpipe(): void;
28
29
  pipe(transformer: any): any;
30
+ static setResponse(command: any, fn: any): void;
31
+ static getReponseHandler(command: any): any;
32
+ static reset(): void;
29
33
  }
@@ -1,12 +1,19 @@
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
- const net_1 = require("net");
4
- const TIMEOUT_OPEN = 2000;
6
+ const net_1 = __importDefault(require("net"));
7
+ const gd_eventlog_1 = require("gd-eventlog");
8
+ const TIMEOUT_OPEN = 1000;
9
+ var __responses = {};
5
10
  class TcpSocketPort {
6
11
  constructor(props) {
7
12
  this.callbacks = {};
8
13
  this.isOpen = false;
14
+ this.isClosed = false;
9
15
  this.props = props || {};
16
+ this.logger = new gd_eventlog_1.EventLogger('TCPSocket') || props.logger;
10
17
  this.enabled = this.props.enabled || true;
11
18
  this.host = this.props.host || '127.0.0.1';
12
19
  this.port = this.props.port || 10000;
@@ -19,46 +26,60 @@ class TcpSocketPort {
19
26
  }
20
27
  flush() {
21
28
  }
22
- open() {
29
+ open(retry = false) {
23
30
  try {
24
- this.socket.setTimeout(TIMEOUT_OPEN, (e) => { });
25
- this.socket.on('timeout', () => { this.onTimeout(); });
26
- this.socket.on('connect', () => { this.onConnect(); });
27
- this.socket.on('error', (err) => { this.onError(err); });
28
- this.socket.on('ready', () => {
29
- this.isOpen = true;
30
- this.emit('open');
31
- });
31
+ if (!retry) {
32
+ this.id = Date.now();
33
+ this.socket.on('timeout', () => { this.onTimeout(); });
34
+ this.socket.on('connect', () => { this.onConnect(); });
35
+ this.socket.on('error', (err) => { this.onError(err); });
36
+ this.socket.on('ready', () => {
37
+ this.logger.logEvent({ message: 'ready' });
38
+ });
39
+ }
40
+ this.logger.logEvent({ message: 'opening', id: this.id, retry });
32
41
  this.socket.connect(this.port, this.host);
33
42
  }
34
43
  catch (err) {
44
+ this.logger.logEvent({ message: 'opening error', id: this.id, error: err.message, stack: err.stack });
35
45
  this.emit('error', err);
36
46
  }
37
47
  }
38
48
  close() {
49
+ this.logger.logEvent({ message: 'closing', id: this.id });
39
50
  this.isOpen = false;
40
51
  this.isClosed = true;
41
52
  try {
42
- this.socket.close();
53
+ this.socket.removeAllListeners();
43
54
  this.socket.destroy();
44
- this.socket.on('timeout', () => { });
45
- this.socket.on('connect', () => { });
46
55
  this.socket.on('error', () => { });
47
- this.socket.on('ready', () => { });
48
56
  }
49
57
  catch (err) {
58
+ console.log(err);
50
59
  }
51
60
  this.emit('close');
52
- setTimeout(() => { this.callbacks = {}; }, 100);
61
+ setTimeout(() => { this.removeAllListeners(); }, 100);
53
62
  }
54
63
  onTimeout() {
64
+ if (this.isOpen)
65
+ return;
66
+ this.logger.logEvent({ message: 'timeout', id: this.id });
67
+ try {
68
+ this.socket.end();
69
+ }
70
+ catch (_a) { }
55
71
  if (this.isClosed)
56
72
  return;
73
+ this.emit('error', new Error('timeout'));
57
74
  }
58
75
  onConnect() {
76
+ this.logger.logEvent({ message: 'connected', id: this.id });
77
+ this.isOpen = true;
59
78
  this.isClosed = false;
79
+ this.emit('open');
60
80
  }
61
81
  onError(err) {
82
+ this.logger.logEvent({ message: 'error', error: err.message });
62
83
  if (this.callbacks['error'])
63
84
  this.callbacks['error'](err);
64
85
  }
@@ -69,6 +90,9 @@ class TcpSocketPort {
69
90
  }
70
91
  this.socket.on(event, callback);
71
92
  }
93
+ removeAllListeners() {
94
+ this.callbacks = {};
95
+ }
72
96
  emit(event, ...args) {
73
97
  if (event === 'open' || event === 'close' || event === 'error') {
74
98
  if (this.callbacks[event])
@@ -86,15 +110,15 @@ class TcpSocketPort {
86
110
  return this.socket.pipe(transformer);
87
111
  }
88
112
  static setResponse(command, fn) {
89
- if (!global.responses)
113
+ if (!__responses)
90
114
  this.reset();
91
- global.responses[command] = fn;
115
+ __responses[command] = fn;
92
116
  }
93
117
  static getReponseHandler(command) {
94
- return global.responses[command];
118
+ return __responses[command];
95
119
  }
96
120
  static reset() {
97
- global.responses = {};
121
+ __responses = {};
98
122
  }
99
123
  }
100
124
  exports.default = TcpSocketPort;
@@ -1,9 +1,9 @@
1
1
  export declare function bin2esc(arr: any): any[];
2
2
  export declare function esc2bin(arr: any): any[];
3
3
  export declare function checkSum(cmdArr: any, payload: any): string;
4
- export declare function buildMessage(command: any, payload: any): any[];
4
+ export declare function buildMessage(command: any, payload?: any): any[];
5
5
  export declare function getMessageData(command: any): any[];
6
- export declare function hexstr(arr: any, start: any, len: any): string;
6
+ export declare function hexstr(arr: any, start?: any, len?: any): string;
7
7
  export declare function getHex(i: any): string;
8
8
  export declare function append(cmd: any, arr: any): void;
9
9
  export declare function ascii(c: any): any;
@@ -1,7 +1,7 @@
1
- import DeviceProtocol from '../DeviceProtocol';
2
- import Device from '../Device';
1
+ import DeviceProtocolBase, { DeviceSettings } from '../DeviceProtocol';
2
+ import DeviceAdapter from '../Device';
3
3
  import { EventLogger } from 'gd-eventlog';
4
- export declare class Simulator extends Device {
4
+ export declare class Simulator extends DeviceAdapter {
5
5
  static NAME: string;
6
6
  logger: EventLogger;
7
7
  speed: number;
@@ -14,26 +14,32 @@ export declare class Simulator extends Device {
14
14
  slope: number;
15
15
  limit: any;
16
16
  startProps?: any;
17
- constructor(protocol: any);
17
+ constructor(protocol?: any);
18
+ isBike(): boolean;
19
+ isHrm(): boolean;
20
+ isPower(): boolean;
21
+ getID(): string;
18
22
  getName(): string;
19
23
  getPort(): string;
20
24
  start(props?: any): Promise<unknown>;
21
25
  stop(): Promise<boolean>;
22
26
  pause(): Promise<boolean>;
27
+ resume(): Promise<boolean>;
23
28
  toggle(): Promise<boolean>;
24
29
  faster(): void;
25
30
  slower(): void;
26
31
  update(): void;
27
32
  calculateDistance(speedKps: any, timeS: any): number;
28
- sendUpdate(request: any): void;
33
+ sendUpdate(request: any): any;
29
34
  }
30
- export default class SimulatorProtocol extends DeviceProtocol {
35
+ export default class SimulatorProtocol extends DeviceProtocolBase {
31
36
  static NAME: string;
32
37
  constructor();
38
+ add(settings: DeviceSettings): void;
33
39
  getName(): string;
34
40
  getInterfaces(): string[];
35
41
  isBike(): boolean;
36
42
  isHrm(): boolean;
37
43
  isPower(): boolean;
38
- getDevices(): any[];
44
+ getDevices(): import("../DeviceProtocol").Device[];
39
45
  }
@@ -1,11 +1,33 @@
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
25
  exports.Simulator = void 0;
4
- const DeviceProtocol_1 = require("../DeviceProtocol");
5
- const DeviceRegistry_1 = require("../DeviceRegistry");
6
- const Device_1 = require("../Device");
26
+ const DeviceProtocol_1 = __importStar(require("../DeviceProtocol"));
27
+ const DeviceRegistry_1 = __importDefault(require("../DeviceRegistry"));
28
+ const Device_1 = __importDefault(require("../Device"));
7
29
  const gd_eventlog_1 = require("gd-eventlog");
8
- const calculations_1 = require("../calculations");
30
+ const calculations_1 = __importDefault(require("../calculations"));
9
31
  class Simulator extends Device_1.default {
10
32
  constructor(protocol) {
11
33
  const proto = protocol || DeviceRegistry_1.default.findByName('Simulator');
@@ -21,12 +43,12 @@ class Simulator extends Device_1.default {
21
43
  this.slope = 0;
22
44
  this.limit = {};
23
45
  }
24
- getName() {
25
- return Simulator.NAME;
26
- }
27
- getPort() {
28
- return 'local';
29
- }
46
+ isBike() { return true; }
47
+ isHrm() { return false; }
48
+ isPower() { return true; }
49
+ getID() { return Simulator.NAME; }
50
+ getName() { return Simulator.NAME; }
51
+ getPort() { return 'local'; }
30
52
  start(props) {
31
53
  this.startProps = props;
32
54
  return new Promise((resolve) => {
@@ -50,24 +72,30 @@ class Simulator extends Device_1.default {
50
72
  return new Promise((resolve, reject) => {
51
73
  this.logger.logEvent({ message: 'stop', iv: this.iv });
52
74
  this.started = false;
53
- try {
54
- clearInterval(this.iv);
55
- this.iv = undefined;
56
- }
57
- catch (err) {
58
- this.logger.logEvent({ message: 'stop Error', error: err.message });
59
- }
75
+ clearInterval(this.iv);
76
+ this.iv = undefined;
60
77
  this.paused = undefined;
61
78
  resolve(true);
62
79
  });
63
80
  }
64
81
  pause() {
65
82
  return new Promise((resolve, reject) => {
83
+ if (!this.started)
84
+ return reject(new Error('illegal state - pause() has been called before start()'));
66
85
  this.logger.logEvent({ message: 'pause', iv: this.iv });
67
86
  this.paused = true;
68
87
  resolve(true);
69
88
  });
70
89
  }
90
+ resume() {
91
+ return new Promise((resolve, reject) => {
92
+ if (!this.started)
93
+ reject(new Error('illegal state - resume() has been called before start()'));
94
+ this.logger.logEvent({ message: 'resume', iv: this.iv });
95
+ this.paused = false;
96
+ resolve(true);
97
+ });
98
+ }
71
99
  toggle() {
72
100
  if (this.started) {
73
101
  return this.stop();
@@ -108,18 +136,22 @@ class Simulator extends Device_1.default {
108
136
  if (this.speed === undefined)
109
137
  this.speed = 30;
110
138
  this.power = calculations_1.default.calculatePower(75, this.speed / 3.6, this.slope);
139
+ if (this.limit.targetPower) {
140
+ this.power = this.limit.targetPower;
141
+ this.speed = calculations_1.default.calculateSpeed(75, this.power, this.slope);
142
+ }
111
143
  if (this.limit.maxPower && this.power > this.limit.maxPower) {
112
144
  this.power = this.limit.maxPower;
113
145
  this.speed = calculations_1.default.calculateSpeed(75, this.power, this.slope);
114
146
  }
115
- if (this.limit.minPower && this.power < this.limit.minPower) {
147
+ else if (this.limit.minPower && this.power < this.limit.minPower) {
116
148
  this.power = this.limit.minPower;
117
149
  this.speed = calculations_1.default.calculateSpeed(75, this.power, this.slope);
118
150
  }
119
151
  let distance = this.calculateDistance(this.speed, timespan / 1000);
120
152
  let data = { speed: this.speed, cadence: Math.round(this.cadence), power: Math.round(this.power), timespan, distance };
121
- if (this.onData) {
122
- this.onData(data);
153
+ if (this.onDataFn) {
154
+ this.onDataFn(data);
123
155
  }
124
156
  }
125
157
  calculateDistance(speedKps, timeS) {
@@ -127,7 +159,14 @@ class Simulator extends Device_1.default {
127
159
  }
128
160
  sendUpdate(request) {
129
161
  this.logger.logEvent({ message: 'bike update request', request });
130
- this.limit = request;
162
+ const r = request || { refresh: true };
163
+ if (r.refresh) {
164
+ if (Object.keys(r).length === 1)
165
+ return this.limit;
166
+ delete r.refresh;
167
+ }
168
+ this.limit = r;
169
+ return this.limit;
131
170
  }
132
171
  }
133
172
  exports.Simulator = Simulator;
@@ -137,6 +176,8 @@ class SimulatorProtocol extends DeviceProtocol_1.default {
137
176
  super();
138
177
  this.devices.push(new Simulator(this));
139
178
  }
179
+ add(settings) {
180
+ }
140
181
  getName() {
141
182
  return SimulatorProtocol.NAME;
142
183
  }
package/lib/utils.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export declare const sleep: (x: any) => Promise<unknown>;
1
+ export declare const sleep: (ms: any) => Promise<unknown>;
2
2
  export declare function runWithRetries(fn: any, maxRetries: any, timeBetween: any): Promise<unknown>;
3
+ export declare function floatVal(d?: number | string): number;
4
+ export declare function intVal(d?: number | string): number;
3
5
  export declare function hexstr(arr: any, start?: any, len?: any): string;
4
6
  export declare class Queue<T> {
5
7
  data: Array<T>;
package/lib/utils.js CHANGED
@@ -9,10 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Queue = exports.hexstr = exports.runWithRetries = exports.sleep = void 0;
13
- exports.sleep = (x) => {
14
- return new Promise(ok => { setTimeout(() => { ok(); }, x); });
12
+ exports.Queue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.sleep = void 0;
13
+ const sleep = (ms) => {
14
+ return new Promise(resolve => setTimeout(resolve, ms));
15
15
  };
16
+ exports.sleep = sleep;
16
17
  function runWithRetries(fn, maxRetries, timeBetween) {
17
18
  return new Promise((resolve, reject) => {
18
19
  let retries = 0;
@@ -32,34 +33,54 @@ function runWithRetries(fn, maxRetries, timeBetween) {
32
33
  }
33
34
  catch (err) {
34
35
  tLastFailure = Date.now();
35
- busy = false;
36
36
  retries++;
37
- if (retries > maxRetries) {
37
+ if (retries >= maxRetries) {
38
38
  clearInterval(iv);
39
+ busy = false;
39
40
  return reject(err);
40
41
  }
42
+ else {
43
+ busy = false;
44
+ }
41
45
  }
42
46
  }
43
47
  }), 50);
44
48
  });
45
49
  }
46
50
  exports.runWithRetries = runWithRetries;
51
+ function floatVal(d) {
52
+ if (d === undefined)
53
+ return;
54
+ if (typeof d === 'number')
55
+ return d;
56
+ const res = parseFloat(d);
57
+ return isNaN(res) ? undefined : res;
58
+ }
59
+ exports.floatVal = floatVal;
60
+ function intVal(d) {
61
+ if (d === undefined)
62
+ return;
63
+ if (typeof d === 'number')
64
+ return Math.floor(d);
65
+ const res = parseInt(d);
66
+ return isNaN(res) ? undefined : res;
67
+ }
68
+ exports.intVal = intVal;
47
69
  function hexstr(arr, start, len) {
48
- var str = "";
49
- if (start === undefined)
50
- start = 0;
51
- if (len === undefined) {
52
- len = arr.length;
53
- }
54
- if (len - start > arr.length) {
55
- len = arr.length - start;
70
+ let str = "";
71
+ const startIdx = start || 0;
72
+ const length = len || arr.length;
73
+ let endIdx = startIdx + length;
74
+ if (endIdx >= arr.length) {
75
+ endIdx = arr.length;
56
76
  }
57
- var j = start;
58
- for (var i = 0; i < len; i++) {
59
- var hex = Math.abs(arr[j++]).toString(16);
60
- if (i !== 0)
61
- str += " ";
77
+ let added = 0;
78
+ for (var i = startIdx; i < endIdx; i++) {
79
+ const hex = Math.abs(arr[i]).toString(16).toUpperCase();
80
+ if (added !== 0)
81
+ str += ' ';
62
82
  str += hex;
83
+ added++;
63
84
  }
64
85
  return str;
65
86
  }
package/package.json CHANGED
@@ -1,23 +1,24 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",
7
- "@types/serialport": "^8.0.1"
7
+ "@types/serialport": "^8.0.1",
8
+ "gd-ant-plus": "^0.0.33"
8
9
  },
9
10
  "peerDependencies": {
10
- "gd-eventlog": "^0.1.21"
11
+ "gd-eventlog": "^0.1.22"
11
12
  },
12
13
  "devDependencies": {
13
- "@types/jest": "^25.2.1",
14
- "@types/node": "^10.0.0",
15
- "eslint": "^6.1.0",
16
- "eslint-config-react-app": "^5.0.1",
17
- "eslint-loader": "2.2.1",
18
- "jest": "^25.2.7",
19
- "ts-jest": "^25.3.1",
20
- "typescript": "^3.8.3"
14
+ "@types/jest": "^27.0.3",
15
+ "@types/node": "^10.17.58",
16
+ "eslint": "^7.32.0",
17
+ "eslint-config-react-app": "^6.0.0",
18
+ "eslint-loader": "^4.0.2",
19
+ "jest": "^27.4.3",
20
+ "ts-jest": "^27.1.0",
21
+ "typescript": "^4.5.2"
21
22
  },
22
23
  "scripts": {
23
24
  "build": "tsc",
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const AntScanner_1 = require("./AntScanner");
4
- const TestData = [
5
- { "busNumber": 2, "deviceAddress": 3, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 512, "bDeviceClass": 0, "bDeviceSubClass": 0, "bDeviceProtocol": 0, "bMaxPacketSize0": 32, "idVendor": 4047, "idProduct": 4104, "bcdDevice": 256, "iManufacturer": 1, "iProduct": 2, "iSerialNumber": 3, "bNumConfigurations": 1 }, "portNumbers": [1, 2], "inUse": false },
6
- { "busNumber": 1, "deviceAddress": 5, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 512, "bDeviceClass": 0, "bDeviceSubClass": 0, "bDeviceProtocol": 0, "bMaxPacketSize0": 8, "idVendor": 1133, "idProduct": 49174, "bcdDevice": 832, "iManufacturer": 1, "iProduct": 2, "iSerialNumber": 0, "bNumConfigurations": 1 }, "portNumbers": [1], "inUse": false },
7
- { "busNumber": 2, "deviceAddress": 4, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 512, "bDeviceClass": 239, "bDeviceSubClass": 2, "bDeviceProtocol": 1, "bMaxPacketSize0": 64, "idVendor": 1266, "idProduct": 46094, "bcdDevice": 26937, "iManufacturer": 2, "iProduct": 1, "iSerialNumber": 0, "bNumConfigurations": 1 }, "portNumbers": [1, 3], "inUse": false },
8
- { "busNumber": 2, "deviceAddress": 5, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 528, "bDeviceClass": 224, "bDeviceSubClass": 1, "bDeviceProtocol": 1, "bMaxPacketSize0": 64, "idVendor": 3034, "idProduct": 45057, "bcdDevice": 512, "iManufacturer": 1, "iProduct": 2, "iSerialNumber": 3, "bNumConfigurations": 1 }, "portNumbers": [1, 7], "inUse": false },
9
- { "busNumber": 1, "deviceAddress": 9, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 512, "bDeviceClass": 0, "bDeviceSubClass": 0, "bDeviceProtocol": 0, "bMaxPacketSize0": 32, "idVendor": 4047, "idProduct": 4104, "bcdDevice": 256, "iManufacturer": 1, "iProduct": 2, "iSerialNumber": 3, "bNumConfigurations": 1 }, "portNumbers": [6], "inUse": false },
10
- { "busNumber": 2, "deviceAddress": 2, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 512, "bDeviceClass": 9, "bDeviceSubClass": 0, "bDeviceProtocol": 1, "bMaxPacketSize0": 64, "idVendor": 32903, "idProduct": 32768, "bcdDevice": 4, "iManufacturer": 0, "iProduct": 0, "iSerialNumber": 0, "bNumConfigurations": 1 }, "portNumbers": [1], "inUse": false },
11
- { "busNumber": 2, "deviceAddress": 1, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 0, "bDeviceClass": 9, "bDeviceSubClass": 0, "bDeviceProtocol": 0, "bMaxPacketSize0": 0, "idVendor": 32902, "idProduct": 39974, "bcdDevice": 0, "iManufacturer": 0, "iProduct": 0, "iSerialNumber": 0, "bNumConfigurations": 1 }, "inUse": false },
12
- { "busNumber": 1, "deviceAddress": 1, "deviceDescriptor": { "bLength": 18, "bDescriptorType": 1, "bcdUSB": 0, "bDeviceClass": 9, "bDeviceSubClass": 0, "bDeviceProtocol": 0, "bMaxPacketSize0": 0, "idVendor": 32902, "idProduct": 39985, "bcdDevice": 0, "iManufacturer": 0, "iProduct": 0, "iSerialNumber": 0, "bNumConfigurations": 1 }, "inUse": false }
13
- ];
14
- class MockGarminStick2 {
15
- }
16
- class MockGarminStick3 {
17
- }
18
- class MockAnt {
19
- static getSticks() { return TestData; }
20
- }
21
- describe('AntScanner', () => {
22
- const scanner = AntScanner_1.AntScanner(MockAnt);
23
- test('getSticks', () => {
24
- });
25
- });
@@ -1,40 +0,0 @@
1
- export default class AntFEProcessor {
2
- static NAME: string;
3
- static STATE: {
4
- INITIALIZED: string;
5
- STARTING: string;
6
- START_OK: string;
7
- START_FAILED: string;
8
- ERROR: string;
9
- FINISHING: string;
10
- FINISH_OK: string;
11
- FINISH_FAILED: string;
12
- };
13
- static isBike(): boolean;
14
- static isHrm(): boolean;
15
- constructor(controller: any, bikeInfo: any);
16
- bikeInfo: any;
17
- ignoreHrm: boolean;
18
- instance: any;
19
- paused: boolean;
20
- started: boolean;
21
- time: number;
22
- iv: NodeJS.Timeout;
23
- state: string;
24
- data: {};
25
- request: any;
26
- setState(newState: any): void;
27
- toggle(): void;
28
- pause(): void;
29
- setIgnoreHrm(ignore: any): void;
30
- checkBikeStatus(): Promise<any>;
31
- startTraining(): Promise<any>;
32
- getBikeData(): Promise<any>;
33
- sendBikeUpdate(request: any): Promise<any>;
34
- onStarted(): void;
35
- start(user: any): Promise<void>;
36
- stop(): void;
37
- update(): Promise<void>;
38
- sendUpdate(data: any): Promise<void>;
39
- onEvent(event: any): void | Promise<void>;
40
- }