tirecheck-device-sdk 0.2.59 → 0.2.60
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/dist/index.cjs +10 -9
- package/dist/index.mjs +10 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -136,12 +136,7 @@ function normalizeError(error) {
|
|
|
136
136
|
|
|
137
137
|
const tyreLabels = getDefaultTyreLabels();
|
|
138
138
|
const bridgeTools = {
|
|
139
|
-
getBridgeFromStore
|
|
140
|
-
const deviceData = store.devices[deviceId];
|
|
141
|
-
if (!deviceData) throw new Error(`No device data found: ${deviceId}`);
|
|
142
|
-
if (deviceData.type !== "bridge") throw new Error("Device is not bridge");
|
|
143
|
-
return deviceData;
|
|
144
|
-
},
|
|
139
|
+
getBridgeFromStore,
|
|
145
140
|
convertBytesToStructure(objStructure, payload, fwVersion) {
|
|
146
141
|
let numArray = ___default.clone(payload);
|
|
147
142
|
const keys = Object.keys(objStructure).filter(
|
|
@@ -251,7 +246,7 @@ const bridgeTools = {
|
|
|
251
246
|
},
|
|
252
247
|
convertBarToKpaByte(deviceId, value) {
|
|
253
248
|
if (!value) return 0;
|
|
254
|
-
const deviceData =
|
|
249
|
+
const deviceData = getBridgeFromStore(deviceId);
|
|
255
250
|
if (!deviceData) throw new Error(`Cannot convert bar to kpa byte, no device data found: ${deviceId}`);
|
|
256
251
|
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
257
252
|
return ___default.round((value + 1) * 100 / bitValue);
|
|
@@ -276,7 +271,7 @@ const bridgeTools = {
|
|
|
276
271
|
if (!___default.isNumber(value)) {
|
|
277
272
|
throw new TypeError("Value has to be a number");
|
|
278
273
|
}
|
|
279
|
-
const deviceData =
|
|
274
|
+
const deviceData = getBridgeFromStore(deviceId);
|
|
280
275
|
if (!deviceData) throw new Error(`Cannot convert kpa byte to bar, no device data found: ${deviceId}`);
|
|
281
276
|
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
282
277
|
const rawBar = value * bitValue / 100;
|
|
@@ -286,7 +281,7 @@ const bridgeTools = {
|
|
|
286
281
|
if (version.length !== 5) {
|
|
287
282
|
throw new Error("Invalid version format");
|
|
288
283
|
}
|
|
289
|
-
const deviceData =
|
|
284
|
+
const deviceData = getBridgeFromStore(deviceId);
|
|
290
285
|
if (deviceData?.advertisingData?.fwVersion) {
|
|
291
286
|
return deviceData.advertisingData.fwVersion > version;
|
|
292
287
|
}
|
|
@@ -366,6 +361,12 @@ const bridgeTools = {
|
|
|
366
361
|
return bitIndex;
|
|
367
362
|
}
|
|
368
363
|
};
|
|
364
|
+
function getBridgeFromStore(deviceId) {
|
|
365
|
+
const deviceData = store.devices[deviceId];
|
|
366
|
+
if (!deviceData) throw new Error(`No device data found: ${deviceId}`);
|
|
367
|
+
if (deviceData.type !== "bridge") throw new Error("Device is not bridge");
|
|
368
|
+
return deviceData;
|
|
369
|
+
}
|
|
369
370
|
function getDefaultTyreLabels() {
|
|
370
371
|
const tyreLabelsStr = "_L;_R;_LO;_LI;_RI;_RO;_";
|
|
371
372
|
const tyreLabelsStrLoc = tyreLabelsStr;
|
package/dist/index.mjs
CHANGED
|
@@ -129,12 +129,7 @@ function normalizeError(error) {
|
|
|
129
129
|
|
|
130
130
|
const tyreLabels = getDefaultTyreLabels();
|
|
131
131
|
const bridgeTools = {
|
|
132
|
-
getBridgeFromStore
|
|
133
|
-
const deviceData = store.devices[deviceId];
|
|
134
|
-
if (!deviceData) throw new Error(`No device data found: ${deviceId}`);
|
|
135
|
-
if (deviceData.type !== "bridge") throw new Error("Device is not bridge");
|
|
136
|
-
return deviceData;
|
|
137
|
-
},
|
|
132
|
+
getBridgeFromStore,
|
|
138
133
|
convertBytesToStructure(objStructure, payload, fwVersion) {
|
|
139
134
|
let numArray = _.clone(payload);
|
|
140
135
|
const keys = Object.keys(objStructure).filter(
|
|
@@ -244,7 +239,7 @@ const bridgeTools = {
|
|
|
244
239
|
},
|
|
245
240
|
convertBarToKpaByte(deviceId, value) {
|
|
246
241
|
if (!value) return 0;
|
|
247
|
-
const deviceData =
|
|
242
|
+
const deviceData = getBridgeFromStore(deviceId);
|
|
248
243
|
if (!deviceData) throw new Error(`Cannot convert bar to kpa byte, no device data found: ${deviceId}`);
|
|
249
244
|
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
250
245
|
return _.round((value + 1) * 100 / bitValue);
|
|
@@ -269,7 +264,7 @@ const bridgeTools = {
|
|
|
269
264
|
if (!_.isNumber(value)) {
|
|
270
265
|
throw new TypeError("Value has to be a number");
|
|
271
266
|
}
|
|
272
|
-
const deviceData =
|
|
267
|
+
const deviceData = getBridgeFromStore(deviceId);
|
|
273
268
|
if (!deviceData) throw new Error(`Cannot convert kpa byte to bar, no device data found: ${deviceId}`);
|
|
274
269
|
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
275
270
|
const rawBar = value * bitValue / 100;
|
|
@@ -279,7 +274,7 @@ const bridgeTools = {
|
|
|
279
274
|
if (version.length !== 5) {
|
|
280
275
|
throw new Error("Invalid version format");
|
|
281
276
|
}
|
|
282
|
-
const deviceData =
|
|
277
|
+
const deviceData = getBridgeFromStore(deviceId);
|
|
283
278
|
if (deviceData?.advertisingData?.fwVersion) {
|
|
284
279
|
return deviceData.advertisingData.fwVersion > version;
|
|
285
280
|
}
|
|
@@ -359,6 +354,12 @@ const bridgeTools = {
|
|
|
359
354
|
return bitIndex;
|
|
360
355
|
}
|
|
361
356
|
};
|
|
357
|
+
function getBridgeFromStore(deviceId) {
|
|
358
|
+
const deviceData = store.devices[deviceId];
|
|
359
|
+
if (!deviceData) throw new Error(`No device data found: ${deviceId}`);
|
|
360
|
+
if (deviceData.type !== "bridge") throw new Error("Device is not bridge");
|
|
361
|
+
return deviceData;
|
|
362
|
+
}
|
|
362
363
|
function getDefaultTyreLabels() {
|
|
363
364
|
const tyreLabelsStr = "_L;_R;_LO;_LI;_RI;_RO;_";
|
|
364
365
|
const tyreLabelsStrLoc = tyreLabelsStr;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.60",
|
|
4
4
|
"description": "SDK for working with various devices produced by Tirecheck via Bluetooth (CAN Bridge, Routers, Sensors, FlexiGauge, PressureStick, etc)",
|
|
5
5
|
"author": "Leonid Buneev <leonid.buneev@tirecheck.com>",
|
|
6
6
|
"license": "ISC",
|