tirecheck-device-sdk 0.2.56 → 0.2.58
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 +41 -12
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +41 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -155,10 +155,8 @@ const bridgeTools = {
|
|
|
155
155
|
console.warn("missing bytes filled with empty values");
|
|
156
156
|
numArray = numArray.concat(Array.from({ length: sumWithInitial - numArray.length }, () => 0));
|
|
157
157
|
}
|
|
158
|
-
if (numArray.length
|
|
159
|
-
|
|
160
|
-
`Cannot convert bytes to object: bytes received ${numArray.length}, expected ${sumWithInitial}, fw version ${fwVersion}`
|
|
161
|
-
);
|
|
158
|
+
if (numArray.length > sumWithInitial) {
|
|
159
|
+
console.warn("extra bytes will be ignored");
|
|
162
160
|
}
|
|
163
161
|
const result = {};
|
|
164
162
|
for (const key of keys) {
|
|
@@ -247,9 +245,17 @@ const bridgeTools = {
|
|
|
247
245
|
}, []).join(".");
|
|
248
246
|
},
|
|
249
247
|
barToKpaByte(value) {
|
|
248
|
+
console.warn("barToKpaByte is deprecated, please use convertBarToKpaByte instead");
|
|
250
249
|
if (!value) return 0;
|
|
251
250
|
return ___default.round((value + 1) * 100 / 5.0625);
|
|
252
251
|
},
|
|
252
|
+
convertBarToKpaByte(deviceId, value) {
|
|
253
|
+
if (!value) return 0;
|
|
254
|
+
const deviceData = this.getBridgeFromStore(deviceId);
|
|
255
|
+
if (!deviceData) throw new Error(`Cannot convert bar to kpa byte, no device data found: ${deviceId}`);
|
|
256
|
+
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
257
|
+
return ___default.round((value + 1) * 100 / bitValue);
|
|
258
|
+
},
|
|
253
259
|
convertSensorIdForBridge(sensorId) {
|
|
254
260
|
let bridgeSensorId = sensorId;
|
|
255
261
|
if (/\d{10}/.test(sensorId)) {
|
|
@@ -259,12 +265,23 @@ const bridgeTools = {
|
|
|
259
265
|
return bridgeSensorId;
|
|
260
266
|
},
|
|
261
267
|
kpaByteToBar(value, decrementValue = 1) {
|
|
268
|
+
console.warn("kpaByteToBar is deprecated, please use convertKpaByteToBar instead");
|
|
262
269
|
if (!___default.isNumber(value)) {
|
|
263
270
|
throw new TypeError("Value has to be a number");
|
|
264
271
|
}
|
|
265
272
|
const rawBar = value * 5.0625 / 100;
|
|
266
273
|
return ___default.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
267
274
|
},
|
|
275
|
+
convertKpaByteToBar(deviceId, value, decrementValue = 1) {
|
|
276
|
+
if (!___default.isNumber(value)) {
|
|
277
|
+
throw new TypeError("Value has to be a number");
|
|
278
|
+
}
|
|
279
|
+
const deviceData = this.getBridgeFromStore(deviceId);
|
|
280
|
+
if (!deviceData) throw new Error(`Cannot convert kpa byte to bar, no device data found: ${deviceId}`);
|
|
281
|
+
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
282
|
+
const rawBar = value * bitValue / 100;
|
|
283
|
+
return ___default.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
284
|
+
},
|
|
268
285
|
isVersionGreaterThan(deviceId, version) {
|
|
269
286
|
if (version.length !== 5) {
|
|
270
287
|
throw new Error("Invalid version format");
|
|
@@ -2388,12 +2405,12 @@ async function setAxlesPressure(deviceId, axles) {
|
|
|
2388
2405
|
let bridgeAxlesPressureData;
|
|
2389
2406
|
for (let index = 0; index < 15; index++) {
|
|
2390
2407
|
let { targetPressure, maxTargetPressure, minTargetPressure, isSpare } = axles[index] || {};
|
|
2391
|
-
maxTargetPressure = bridgeTools.
|
|
2392
|
-
minTargetPressure = bridgeTools.
|
|
2408
|
+
maxTargetPressure = bridgeTools.convertBarToKpaByte(deviceId, maxTargetPressure);
|
|
2409
|
+
minTargetPressure = bridgeTools.convertBarToKpaByte(deviceId, minTargetPressure);
|
|
2393
2410
|
if (isSpare && axles[0]) {
|
|
2394
|
-
targetPressure = bridgeTools.
|
|
2411
|
+
targetPressure = bridgeTools.convertBarToKpaByte(deviceId, axles[0].targetPressure);
|
|
2395
2412
|
} else {
|
|
2396
|
-
targetPressure = bridgeTools.
|
|
2413
|
+
targetPressure = bridgeTools.convertBarToKpaByte(deviceId, targetPressure);
|
|
2397
2414
|
}
|
|
2398
2415
|
if (!maxTargetPressure) {
|
|
2399
2416
|
if (!bridgeAxlesPressureData) {
|
|
@@ -2745,14 +2762,20 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2745
2762
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2746
2763
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2747
2764
|
if (axlesPressureData[axleIndex * 3]) {
|
|
2748
|
-
tcVehicleAxle.maxTargetPressure = ___default.floor(
|
|
2765
|
+
tcVehicleAxle.maxTargetPressure = ___default.floor(
|
|
2766
|
+
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3]),
|
|
2767
|
+
1
|
|
2768
|
+
);
|
|
2749
2769
|
}
|
|
2750
2770
|
if (axlesPressureData[axleIndex * 3 + 1]) {
|
|
2751
|
-
tcVehicleAxle.minTargetPressure = ___default.ceil(
|
|
2771
|
+
tcVehicleAxle.minTargetPressure = ___default.ceil(
|
|
2772
|
+
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3 + 1]),
|
|
2773
|
+
1
|
|
2774
|
+
);
|
|
2752
2775
|
}
|
|
2753
2776
|
if (axlesPressureData[axleIndex * 3 + 2]) {
|
|
2754
2777
|
tcVehicleAxle.targetPressure = ___default.round(
|
|
2755
|
-
bridgeTools.
|
|
2778
|
+
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3 + 2], void 0),
|
|
2756
2779
|
1
|
|
2757
2780
|
);
|
|
2758
2781
|
}
|
|
@@ -4504,7 +4527,13 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4504
4527
|
/** Allows simulating devices without actually using bluetooth */
|
|
4505
4528
|
simulator,
|
|
4506
4529
|
/** Methods for working with Tirecheck Torque Wrench */
|
|
4507
|
-
torqueWrench
|
|
4530
|
+
torqueWrench,
|
|
4531
|
+
utils: {
|
|
4532
|
+
bridge: {
|
|
4533
|
+
convertBarToKpaByte: bridgeTools.convertBarToKpaByte,
|
|
4534
|
+
convertKpaByteToBar: bridgeTools.convertKpaByteToBar
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4508
4537
|
};
|
|
4509
4538
|
}
|
|
4510
4539
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1037,6 +1037,12 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1037
1037
|
getTime: (deviceId: string) => Promise<Date>;
|
|
1038
1038
|
onReading: (callback: (deviceId: string, value: TorqueWrenchReading) => void) => void;
|
|
1039
1039
|
};
|
|
1040
|
+
utils: {
|
|
1041
|
+
bridge: {
|
|
1042
|
+
convertBarToKpaByte: (deviceId: string, value?: number) => number;
|
|
1043
|
+
convertKpaByteToBar: (deviceId: string, value?: number, decrementValue?: number) => number;
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1040
1046
|
};
|
|
1041
1047
|
|
|
1042
1048
|
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.d.mts
CHANGED
|
@@ -1037,6 +1037,12 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1037
1037
|
getTime: (deviceId: string) => Promise<Date>;
|
|
1038
1038
|
onReading: (callback: (deviceId: string, value: TorqueWrenchReading) => void) => void;
|
|
1039
1039
|
};
|
|
1040
|
+
utils: {
|
|
1041
|
+
bridge: {
|
|
1042
|
+
convertBarToKpaByte: (deviceId: string, value?: number) => number;
|
|
1043
|
+
convertKpaByteToBar: (deviceId: string, value?: number, decrementValue?: number) => number;
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1040
1046
|
};
|
|
1041
1047
|
|
|
1042
1048
|
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.d.ts
CHANGED
|
@@ -1037,6 +1037,12 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1037
1037
|
getTime: (deviceId: string) => Promise<Date>;
|
|
1038
1038
|
onReading: (callback: (deviceId: string, value: TorqueWrenchReading) => void) => void;
|
|
1039
1039
|
};
|
|
1040
|
+
utils: {
|
|
1041
|
+
bridge: {
|
|
1042
|
+
convertBarToKpaByte: (deviceId: string, value?: number) => number;
|
|
1043
|
+
convertKpaByteToBar: (deviceId: string, value?: number, decrementValue?: number) => number;
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1040
1046
|
};
|
|
1041
1047
|
|
|
1042
1048
|
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.mjs
CHANGED
|
@@ -148,10 +148,8 @@ const bridgeTools = {
|
|
|
148
148
|
console.warn("missing bytes filled with empty values");
|
|
149
149
|
numArray = numArray.concat(Array.from({ length: sumWithInitial - numArray.length }, () => 0));
|
|
150
150
|
}
|
|
151
|
-
if (numArray.length
|
|
152
|
-
|
|
153
|
-
`Cannot convert bytes to object: bytes received ${numArray.length}, expected ${sumWithInitial}, fw version ${fwVersion}`
|
|
154
|
-
);
|
|
151
|
+
if (numArray.length > sumWithInitial) {
|
|
152
|
+
console.warn("extra bytes will be ignored");
|
|
155
153
|
}
|
|
156
154
|
const result = {};
|
|
157
155
|
for (const key of keys) {
|
|
@@ -240,9 +238,17 @@ const bridgeTools = {
|
|
|
240
238
|
}, []).join(".");
|
|
241
239
|
},
|
|
242
240
|
barToKpaByte(value) {
|
|
241
|
+
console.warn("barToKpaByte is deprecated, please use convertBarToKpaByte instead");
|
|
243
242
|
if (!value) return 0;
|
|
244
243
|
return _.round((value + 1) * 100 / 5.0625);
|
|
245
244
|
},
|
|
245
|
+
convertBarToKpaByte(deviceId, value) {
|
|
246
|
+
if (!value) return 0;
|
|
247
|
+
const deviceData = this.getBridgeFromStore(deviceId);
|
|
248
|
+
if (!deviceData) throw new Error(`Cannot convert bar to kpa byte, no device data found: ${deviceId}`);
|
|
249
|
+
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
250
|
+
return _.round((value + 1) * 100 / bitValue);
|
|
251
|
+
},
|
|
246
252
|
convertSensorIdForBridge(sensorId) {
|
|
247
253
|
let bridgeSensorId = sensorId;
|
|
248
254
|
if (/\d{10}/.test(sensorId)) {
|
|
@@ -252,12 +258,23 @@ const bridgeTools = {
|
|
|
252
258
|
return bridgeSensorId;
|
|
253
259
|
},
|
|
254
260
|
kpaByteToBar(value, decrementValue = 1) {
|
|
261
|
+
console.warn("kpaByteToBar is deprecated, please use convertKpaByteToBar instead");
|
|
255
262
|
if (!_.isNumber(value)) {
|
|
256
263
|
throw new TypeError("Value has to be a number");
|
|
257
264
|
}
|
|
258
265
|
const rawBar = value * 5.0625 / 100;
|
|
259
266
|
return _.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
260
267
|
},
|
|
268
|
+
convertKpaByteToBar(deviceId, value, decrementValue = 1) {
|
|
269
|
+
if (!_.isNumber(value)) {
|
|
270
|
+
throw new TypeError("Value has to be a number");
|
|
271
|
+
}
|
|
272
|
+
const deviceData = this.getBridgeFromStore(deviceId);
|
|
273
|
+
if (!deviceData) throw new Error(`Cannot convert kpa byte to bar, no device data found: ${deviceId}`);
|
|
274
|
+
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
275
|
+
const rawBar = value * bitValue / 100;
|
|
276
|
+
return _.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
277
|
+
},
|
|
261
278
|
isVersionGreaterThan(deviceId, version) {
|
|
262
279
|
if (version.length !== 5) {
|
|
263
280
|
throw new Error("Invalid version format");
|
|
@@ -2381,12 +2398,12 @@ async function setAxlesPressure(deviceId, axles) {
|
|
|
2381
2398
|
let bridgeAxlesPressureData;
|
|
2382
2399
|
for (let index = 0; index < 15; index++) {
|
|
2383
2400
|
let { targetPressure, maxTargetPressure, minTargetPressure, isSpare } = axles[index] || {};
|
|
2384
|
-
maxTargetPressure = bridgeTools.
|
|
2385
|
-
minTargetPressure = bridgeTools.
|
|
2401
|
+
maxTargetPressure = bridgeTools.convertBarToKpaByte(deviceId, maxTargetPressure);
|
|
2402
|
+
minTargetPressure = bridgeTools.convertBarToKpaByte(deviceId, minTargetPressure);
|
|
2386
2403
|
if (isSpare && axles[0]) {
|
|
2387
|
-
targetPressure = bridgeTools.
|
|
2404
|
+
targetPressure = bridgeTools.convertBarToKpaByte(deviceId, axles[0].targetPressure);
|
|
2388
2405
|
} else {
|
|
2389
|
-
targetPressure = bridgeTools.
|
|
2406
|
+
targetPressure = bridgeTools.convertBarToKpaByte(deviceId, targetPressure);
|
|
2390
2407
|
}
|
|
2391
2408
|
if (!maxTargetPressure) {
|
|
2392
2409
|
if (!bridgeAxlesPressureData) {
|
|
@@ -2738,14 +2755,20 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2738
2755
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2739
2756
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2740
2757
|
if (axlesPressureData[axleIndex * 3]) {
|
|
2741
|
-
tcVehicleAxle.maxTargetPressure = _.floor(
|
|
2758
|
+
tcVehicleAxle.maxTargetPressure = _.floor(
|
|
2759
|
+
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3]),
|
|
2760
|
+
1
|
|
2761
|
+
);
|
|
2742
2762
|
}
|
|
2743
2763
|
if (axlesPressureData[axleIndex * 3 + 1]) {
|
|
2744
|
-
tcVehicleAxle.minTargetPressure = _.ceil(
|
|
2764
|
+
tcVehicleAxle.minTargetPressure = _.ceil(
|
|
2765
|
+
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3 + 1]),
|
|
2766
|
+
1
|
|
2767
|
+
);
|
|
2745
2768
|
}
|
|
2746
2769
|
if (axlesPressureData[axleIndex * 3 + 2]) {
|
|
2747
2770
|
tcVehicleAxle.targetPressure = _.round(
|
|
2748
|
-
bridgeTools.
|
|
2771
|
+
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3 + 2], void 0),
|
|
2749
2772
|
1
|
|
2750
2773
|
);
|
|
2751
2774
|
}
|
|
@@ -4497,7 +4520,13 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4497
4520
|
/** Allows simulating devices without actually using bluetooth */
|
|
4498
4521
|
simulator,
|
|
4499
4522
|
/** Methods for working with Tirecheck Torque Wrench */
|
|
4500
|
-
torqueWrench
|
|
4523
|
+
torqueWrench,
|
|
4524
|
+
utils: {
|
|
4525
|
+
bridge: {
|
|
4526
|
+
convertBarToKpaByte: bridgeTools.convertBarToKpaByte,
|
|
4527
|
+
convertKpaByteToBar: bridgeTools.convertKpaByteToBar
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4501
4530
|
};
|
|
4502
4531
|
}
|
|
4503
4532
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.58",
|
|
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",
|