incyclist-devices 2.0.35 → 2.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +2 -2
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +2 -2
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +2 -2
- package/lib/base/adpater.d.ts +2 -1
- package/lib/base/adpater.js +7 -6
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ble-erg-mode.d.ts +2 -2
- package/lib/modes/ble-st-mode.d.ts +2 -2
- package/lib/modes/cycling-mode.d.ts +7 -7
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +3 -2
- package/lib/modes/power-meter.d.ts +2 -2
- package/lib/serial/comms.d.ts +62 -0
- package/lib/serial/comms.js +280 -0
- package/lib/serial/daum/DaumAdapter.d.ts +13 -8
- package/lib/serial/daum/DaumAdapter.js +49 -12
- package/lib/serial/daum/ERGCyclingMode.d.ts +2 -2
- package/lib/serial/daum/ERGCyclingMode.js +1 -1
- package/lib/serial/daum/SmartTrainerCyclingMode.d.ts +3 -2
- package/lib/serial/daum/SmartTrainerCyclingMode.js +10 -5
- package/lib/serial/daum/classic/adapter.d.ts +4 -6
- package/lib/serial/daum/classic/adapter.js +5 -23
- package/lib/serial/daum/classic/comms.d.ts +33 -65
- package/lib/serial/daum/classic/comms.js +148 -332
- package/lib/serial/daum/classic/mock.js +5 -3
- package/lib/serial/daum/classic/modes/daum-classic.d.ts +2 -2
- package/lib/serial/daum/classic/modes/daum-classic.js +1 -1
- package/lib/serial/daum/classic/types.d.ts +59 -0
- package/lib/serial/daum/classic/types.js +2 -0
- package/lib/serial/daum/classic/utils.d.ts +11 -10
- package/lib/serial/daum/classic/utils.js +33 -68
- package/lib/serial/daum/premium/adapter.d.ts +4 -7
- package/lib/serial/daum/premium/adapter.js +7 -30
- package/lib/serial/daum/premium/comms.d.ts +28 -105
- package/lib/serial/daum/premium/comms.js +262 -466
- package/lib/serial/daum/premium/consts.d.ts +6 -0
- package/lib/serial/daum/premium/consts.js +9 -0
- package/lib/serial/daum/premium/mock.d.ts +32 -1
- package/lib/serial/daum/premium/mock.js +131 -8
- package/lib/serial/daum/premium/modes/daum-classic.d.ts +2 -2
- package/lib/serial/daum/premium/modes/daum-classic.js +1 -1
- package/lib/serial/daum/premium/types.d.ts +35 -1
- package/lib/serial/daum/premium/types.js +29 -0
- package/lib/serial/daum/premium/utils.d.ts +12 -18
- package/lib/serial/daum/premium/utils.js +34 -19
- package/lib/serial/serial-interface.js +3 -2
- package/lib/types/adapter.d.ts +2 -0
- package/lib/types/device.d.ts +11 -0
- package/lib/types/route.d.ts +0 -5
- package/lib/types/route.js +0 -7
- package/lib/utils/calculations.js +1 -5
- package/lib/utils/utils.d.ts +2 -1
- package/lib/utils/utils.js +39 -3
- package/package.json +3 -2
package/lib/utils/utils.js
CHANGED
|
@@ -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.Queue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.resolveNextTick = exports.sleep = void 0;
|
|
12
|
+
exports.waitWithTimeout = exports.Queue = 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
|
};
|
|
@@ -99,13 +99,13 @@ class Queue {
|
|
|
99
99
|
this.data = values;
|
|
100
100
|
}
|
|
101
101
|
size() {
|
|
102
|
-
return this.data
|
|
102
|
+
return this.data.length;
|
|
103
103
|
}
|
|
104
104
|
clear() {
|
|
105
105
|
this.data = [];
|
|
106
106
|
}
|
|
107
107
|
isEmpty() {
|
|
108
|
-
return this.
|
|
108
|
+
return this.size() === 0;
|
|
109
109
|
}
|
|
110
110
|
dequeue() {
|
|
111
111
|
const removed = this.data.splice(0, 1);
|
|
@@ -116,3 +116,39 @@ class Queue {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
exports.Queue = Queue;
|
|
119
|
+
function waitWithTimeout(promise, timeout, onTimeout) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
let to;
|
|
122
|
+
let hasTimedOut = false;
|
|
123
|
+
const toPromise = (ms) => {
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
to = setTimeout(() => {
|
|
126
|
+
hasTimedOut = true;
|
|
127
|
+
if (!onTimeout) {
|
|
128
|
+
reject(new Error('Timeout'));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
try {
|
|
132
|
+
onTimeout();
|
|
133
|
+
resolve();
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
reject(err);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}, ms);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
let res;
|
|
143
|
+
try {
|
|
144
|
+
res = yield Promise.race([promise, toPromise(timeout)]);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
if (err.message === 'Timeout' && hasTimedOut)
|
|
148
|
+
throw err;
|
|
149
|
+
}
|
|
150
|
+
clearTimeout(to);
|
|
151
|
+
return res;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
exports.waitWithTimeout = waitWithTimeout;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-devices",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.37",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@serialport/bindings-interface": "^1.2.2",
|
|
6
6
|
"@serialport/parser-byte-length": "^9.0.1",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"build": "tsc",
|
|
30
30
|
"test": "jest --coverage",
|
|
31
31
|
"test:ci": "jest --coverage --forceExit",
|
|
32
|
-
"dev": "tsc --watch"
|
|
32
|
+
"dev": "tsc --watch",
|
|
33
|
+
"postversion": "git push && git push --tags"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"lib/"
|