incyclist-devices 2.1.0 → 2.1.2

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 (161) hide show
  1. package/lib/adapters.d.ts +1 -1
  2. package/lib/antv2/adapter-factory.d.ts +4 -15
  3. package/lib/antv2/adapter.d.ts +15 -15
  4. package/lib/antv2/adapter.js +67 -21
  5. package/lib/antv2/ant-interface.d.ts +3 -11
  6. package/lib/antv2/ant-interface.js +1 -1
  7. package/lib/antv2/base/adapter.d.ts +69 -0
  8. package/lib/antv2/base/adapter.js +439 -0
  9. package/lib/antv2/base/ant-interface.d.ts +35 -0
  10. package/lib/antv2/base/ant-interface.js +285 -0
  11. package/lib/antv2/base/binding.d.ts +13 -0
  12. package/lib/antv2/base/binding.js +27 -0
  13. package/lib/antv2/base/interface.d.ts +46 -0
  14. package/lib/antv2/base/interface.js +337 -0
  15. package/lib/antv2/cad/adapter.d.ts +10 -0
  16. package/lib/antv2/cad/adapter.js +25 -0
  17. package/lib/antv2/cad/index.d.ts +2 -0
  18. package/lib/antv2/cad/index.js +7 -0
  19. package/lib/antv2/consts.d.ts +2 -0
  20. package/lib/antv2/consts.js +5 -0
  21. package/lib/antv2/factories/adapter-factory.d.ts +14 -0
  22. package/lib/antv2/factories/adapter-factory.js +73 -0
  23. package/lib/antv2/factories/sensor-factory.d.ts +5 -0
  24. package/lib/antv2/factories/sensor-factory.js +22 -0
  25. package/lib/antv2/fe/adapter.d.ts +21 -30
  26. package/lib/antv2/fe/adapter.js +139 -251
  27. package/lib/antv2/hr/adapter.d.ts +6 -15
  28. package/lib/antv2/hr/adapter.js +7 -55
  29. package/lib/antv2/hr copy/adapter.d.ts +11 -0
  30. package/lib/antv2/hr copy/adapter.js +30 -0
  31. package/lib/antv2/hr copy/index.d.ts +2 -0
  32. package/lib/antv2/hr copy/index.js +7 -0
  33. package/lib/antv2/index.d.ts +5 -4
  34. package/lib/antv2/index.js +5 -3
  35. package/lib/antv2/pwr/adapter.d.ts +9 -33
  36. package/lib/antv2/pwr/adapter.js +19 -140
  37. package/lib/antv2/types.d.ts +32 -4
  38. package/lib/base/adpater.d.ts +39 -60
  39. package/lib/base/adpater.js +139 -161
  40. package/lib/base/consts.d.ts +4 -0
  41. package/lib/base/consts.js +9 -0
  42. package/lib/ble/adapter-factory.d.ts +10 -11
  43. package/lib/ble/base/adapter.d.ts +7 -14
  44. package/lib/ble/base/adapter.js +2 -36
  45. package/lib/ble/ble-interface.d.ts +5 -7
  46. package/lib/ble/cp/adapter.d.ts +6 -8
  47. package/lib/ble/cp/adapter.js +8 -27
  48. package/lib/ble/elite/adapter.d.ts +7 -8
  49. package/lib/ble/elite/adapter.js +5 -25
  50. package/lib/ble/fm/adapter.d.ts +6 -7
  51. package/lib/ble/fm/adapter.js +13 -34
  52. package/lib/ble/hr/adapter.d.ts +5 -8
  53. package/lib/ble/hr/adapter.js +2 -2
  54. package/lib/ble/peripheral-cache.d.ts +2 -3
  55. package/lib/ble/tacx/adapter.d.ts +2 -3
  56. package/lib/ble/tacx/adapter.js +8 -8
  57. package/lib/ble/types.d.ts +1 -2
  58. package/lib/ble/wahoo/adapter.d.ts +2 -2
  59. package/lib/ble/wahoo/adapter.js +6 -6
  60. package/lib/ble/wahoo/comms.js +16 -16
  61. package/lib/factories/adapters.d.ts +7 -0
  62. package/lib/factories/adapters.js +49 -0
  63. package/lib/factories/index.d.ts +3 -0
  64. package/lib/factories/index.js +10 -0
  65. package/lib/factories/interfaces.d.ts +7 -0
  66. package/lib/factories/interfaces.js +27 -0
  67. package/lib/index.d.ts +5 -6
  68. package/lib/index.js +4 -9
  69. package/lib/interfaces.d.ts +1 -1
  70. package/lib/modes/ant-fe-adv-st-mode.d.ts +1 -1
  71. package/lib/modes/antble-erg.d.ts +1 -1
  72. package/lib/modes/antble-smarttrainer.d.ts +2 -2
  73. package/lib/modes/base.d.ts +5 -5
  74. package/lib/modes/daum-classic-standard.d.ts +3 -2
  75. package/lib/modes/daum-erg.d.ts +3 -3
  76. package/lib/modes/daum-premium-standard.d.ts +3 -2
  77. package/lib/modes/daum-smarttrainer.d.ts +3 -2
  78. package/lib/modes/kettler-erg.d.ts +3 -3
  79. package/lib/modes/power-base.d.ts +3 -3
  80. package/lib/modes/power-base.js +2 -2
  81. package/lib/modes/power-meter.d.ts +3 -2
  82. package/lib/modes/simulator.d.ts +2 -1
  83. package/lib/modes/types.d.ts +2 -13
  84. package/lib/serial/SinglePathScanner.d.ts +17 -0
  85. package/lib/serial/SinglePathScanner.js +87 -0
  86. package/lib/serial/adapter-factory.d.ts +6 -6
  87. package/lib/serial/adapter.d.ts +6 -11
  88. package/lib/serial/base/adapter.d.ts +17 -0
  89. package/lib/serial/base/adapter.js +67 -0
  90. package/lib/serial/base/comms.d.ts +62 -0
  91. package/lib/serial/base/comms.js +280 -0
  92. package/lib/serial/base/serial-interface.d.ts +36 -0
  93. package/lib/serial/base/serial-interface.js +288 -0
  94. package/lib/serial/base/serial-scanner.d.ts +16 -0
  95. package/lib/serial/base/serial-scanner.js +87 -0
  96. package/lib/serial/base/serialport.d.ts +17 -0
  97. package/lib/serial/base/serialport.js +87 -0
  98. package/lib/serial/comms.d.ts +2 -2
  99. package/lib/serial/daum/DaumAdapter.d.ts +12 -24
  100. package/lib/serial/daum/DaumAdapter.js +40 -59
  101. package/lib/serial/daum/classic/PROTOCOL_NAME.d.ts +2 -0
  102. package/lib/serial/daum/classic/PROTOCOL_NAME.js +5 -0
  103. package/lib/serial/daum/classic/adapter.d.ts +8 -20
  104. package/lib/serial/daum/classic/adapter.js +28 -58
  105. package/lib/serial/daum/classic/comms.d.ts +4 -6
  106. package/lib/serial/daum/classic/comms.js +2 -2
  107. package/lib/serial/daum/classic/consts.d.ts +2 -0
  108. package/lib/serial/daum/classic/consts.js +5 -0
  109. package/lib/serial/daum/classic/mock.js +5 -4
  110. package/lib/serial/daum/classic/types.d.ts +8 -10
  111. package/lib/serial/daum/classic/utils.d.ts +1 -2
  112. package/lib/serial/daum/consts.d.ts +0 -19
  113. package/lib/serial/daum/consts.js +0 -22
  114. package/lib/serial/daum/premium/adapter.d.ts +8 -11
  115. package/lib/serial/daum/premium/adapter.js +27 -53
  116. package/lib/serial/daum/premium/comms.d.ts +4 -7
  117. package/lib/serial/daum/premium/comms.js +23 -22
  118. package/lib/serial/daum/premium/mock.d.ts +1 -1
  119. package/lib/serial/daum/premium/mock.js +2 -2
  120. package/lib/serial/daum/premium/types.d.ts +32 -17
  121. package/lib/serial/daum/premium/types.js +8 -8
  122. package/lib/serial/daum/premium/utils.d.ts +2 -3
  123. package/lib/serial/daum/premium/utils.js +3 -3
  124. package/lib/serial/daum/types.d.ts +4 -1
  125. package/lib/serial/daum/types.js +9 -1
  126. package/lib/serial/factories/adapter-factory.d.ts +14 -0
  127. package/lib/serial/factories/adapter-factory.js +30 -0
  128. package/lib/serial/index.d.ts +8 -5
  129. package/lib/serial/index.js +15 -15
  130. package/lib/serial/kettler/comms.d.ts +1 -1
  131. package/lib/serial/kettler/ergo-racer/adapter.d.ts +11 -18
  132. package/lib/serial/kettler/ergo-racer/adapter.js +9 -21
  133. package/lib/serial/kettler/types.d.ts +8 -0
  134. package/lib/serial/kettler/types.js +2 -0
  135. package/lib/serial/serial-interface.d.ts +2 -32
  136. package/lib/serial/serial-interface.js +3 -76
  137. package/lib/serial/serial-scanner.d.ts +16 -0
  138. package/lib/serial/serial-scanner.js +87 -0
  139. package/lib/serial/serialport.d.ts +1 -13
  140. package/lib/serial/types.d.ts +45 -0
  141. package/lib/serial/types.js +9 -0
  142. package/lib/simulator/Simulator.d.ts +10 -13
  143. package/lib/simulator/Simulator.js +11 -23
  144. package/lib/types/Command.d.ts +8 -0
  145. package/lib/types/Command.js +2 -0
  146. package/lib/types/adapter.d.ts +22 -33
  147. package/lib/types/adapter.js +0 -68
  148. package/lib/types/command.d.ts +0 -8
  149. package/lib/types/command.js +0 -2
  150. package/lib/types/data.d.ts +12 -1
  151. package/lib/types/device.d.ts +8 -23
  152. package/lib/types/device.js +9 -8
  153. package/lib/types/index.d.ts +6 -0
  154. package/lib/types/index.js +22 -0
  155. package/lib/types/route.d.ts +0 -19
  156. package/lib/types/route.js +0 -2
  157. package/lib/types/types.d.ts +8 -0
  158. package/lib/types/types.js +2 -0
  159. package/lib/utils/utils.d.ts +2 -0
  160. package/lib/utils/utils.js +39 -4
  161. package/package.json +1 -1
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./adapter"), exports);
18
+ __exportStar(require("./capabilities"), exports);
19
+ __exportStar(require("./data"), exports);
20
+ __exportStar(require("./device"), exports);
21
+ __exportStar(require("./interface"), exports);
22
+ __exportStar(require("./user"), exports);
@@ -1,19 +0,0 @@
1
- export type Point = {
2
- lat?: number;
3
- lng?: number;
4
- elevation?: number;
5
- distance: number;
6
- slope?: number;
7
- };
8
- export type Route = {
9
- programId: number;
10
- points: Point[];
11
- type: string;
12
- name?: string;
13
- description?: string;
14
- lapMode: boolean;
15
- totalDistance: number;
16
- minElevation?: number;
17
- maxElevation?: number;
18
- sampleRate?: number;
19
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" />
2
+ export interface Command {
3
+ logStr?: string;
4
+ message: string | Buffer;
5
+ timeout?: number;
6
+ onError: (err: Error) => void;
7
+ onResponse: (response: string | Buffer) => void;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,6 +4,7 @@ export declare function runWithRetries(fn: any, maxRetries: any, timeBetween: an
4
4
  export declare function floatVal(d?: number | string): number;
5
5
  export declare function intVal(d?: number | string): number;
6
6
  export declare function hexstr(arr: any, start?: any, len?: any): string;
7
+ export declare function isTrue(value: any): boolean;
7
8
  export declare class Queue<T> {
8
9
  protected data: Array<T>;
9
10
  constructor(values?: Array<T>);
@@ -13,4 +14,5 @@ export declare class Queue<T> {
13
14
  dequeue(): T;
14
15
  enqueue(value: T): void;
15
16
  }
17
+ export declare function runWithTimeout(promise: Promise<any>, timeout: number): Promise<any>;
16
18
  export declare function waitWithTimeout(promise: Promise<any>, timeout: number, onTimeout?: () => void): Promise<any>;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.waitWithTimeout = exports.Queue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.resolveNextTick = exports.sleep = void 0;
12
+ exports.waitWithTimeout = exports.runWithTimeout = exports.Queue = exports.isTrue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.resolveNextTick = exports.sleep = void 0;
13
13
  const sleep = (ms) => {
14
14
  return new Promise(resolve => setTimeout(resolve, ms));
15
15
  };
@@ -92,6 +92,23 @@ function hexstr(arr, start, len) {
92
92
  return str;
93
93
  }
94
94
  exports.hexstr = hexstr;
95
+ function isTrue(value) {
96
+ if (typeof (value) === 'string') {
97
+ value = value.trim().toLowerCase();
98
+ }
99
+ switch (value) {
100
+ case true:
101
+ case "true":
102
+ case 1:
103
+ case "1":
104
+ case "on":
105
+ case "yes":
106
+ return true;
107
+ default:
108
+ return false;
109
+ }
110
+ }
111
+ exports.isTrue = isTrue;
95
112
  class Queue {
96
113
  constructor(values) {
97
114
  this.data = [];
@@ -116,7 +133,19 @@ class Queue {
116
133
  }
117
134
  }
118
135
  exports.Queue = Queue;
136
+ function runWithTimeout(promise, timeout) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ return yield doWaitWithTimeout(promise, timeout, true);
139
+ });
140
+ }
141
+ exports.runWithTimeout = runWithTimeout;
119
142
  function waitWithTimeout(promise, timeout, onTimeout) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ return yield doWaitWithTimeout(promise, timeout, false, onTimeout);
145
+ });
146
+ }
147
+ exports.waitWithTimeout = waitWithTimeout;
148
+ function doWaitWithTimeout(promise, timeout, throwError, onTimeout) {
120
149
  return __awaiter(this, void 0, void 0, function* () {
121
150
  let to;
122
151
  let hasTimedOut = false;
@@ -124,7 +153,7 @@ function waitWithTimeout(promise, timeout, onTimeout) {
124
153
  return new Promise((resolve, reject) => {
125
154
  to = setTimeout(() => {
126
155
  hasTimedOut = true;
127
- if (!onTimeout) {
156
+ if (!onTimeout || throwError) {
128
157
  reject(new Error('Timeout'));
129
158
  }
130
159
  else {
@@ -144,11 +173,17 @@ function waitWithTimeout(promise, timeout, onTimeout) {
144
173
  res = yield Promise.race([promise, toPromise(timeout)]);
145
174
  }
146
175
  catch (err) {
147
- if (err.message === 'Timeout' && hasTimedOut)
176
+ if (err.message === 'Timeout' && hasTimedOut) {
148
177
  throw err;
178
+ }
179
+ else {
180
+ if (throwError) {
181
+ clearTimeout(to);
182
+ throw err;
183
+ }
184
+ }
149
185
  }
150
186
  clearTimeout(to);
151
187
  return res;
152
188
  });
153
189
  }
154
- exports.waitWithTimeout = waitWithTimeout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",