tirecheck-device-sdk 0.2.46 → 0.2.48
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 +20 -34
- package/dist/index.mjs +20 -34
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2075,7 +2075,8 @@ const bridgeService = {
|
|
|
2075
2075
|
getAutolearnStatuses,
|
|
2076
2076
|
isRebootRequired,
|
|
2077
2077
|
sendPinCommand,
|
|
2078
|
-
setVehicleLayout
|
|
2078
|
+
setVehicleLayout,
|
|
2079
|
+
setAxleInfo
|
|
2079
2080
|
};
|
|
2080
2081
|
async function sendPinCommand(deviceId) {
|
|
2081
2082
|
if (!canCommunicateWith(deviceId)) throw new Error("Bridge not connected");
|
|
@@ -2276,8 +2277,13 @@ async function getAxlesWithAutolearnSettings(deviceId) {
|
|
|
2276
2277
|
}
|
|
2277
2278
|
async function setAxleInfo(deviceId, tcVehicle) {
|
|
2278
2279
|
if (!tcVehicle.axles?.length) throw new Error("Vehicle has no axles");
|
|
2279
|
-
const
|
|
2280
|
-
|
|
2280
|
+
const tyresWithInfo = tcVehicle.tcTyres.map((tyre) => ({
|
|
2281
|
+
tcTpmsSensor: tyre.tcTpmsSensor,
|
|
2282
|
+
...bridgeTools.getPositionInfo(tyre.mountedOn?.positionId || 0)
|
|
2283
|
+
}));
|
|
2284
|
+
const tyresWithSensors = tyresWithInfo.filter((tyre) => tyre.tcTpmsSensor && !tyre.isSpareTyre);
|
|
2285
|
+
const spareTyres = tyresWithInfo.filter((tyre) => tyre.isSpareTyre);
|
|
2286
|
+
for (let axleIndex = 0; axleIndex < 16; axleIndex++) {
|
|
2281
2287
|
const tyres = [
|
|
2282
2288
|
"00000000",
|
|
2283
2289
|
"00000000",
|
|
@@ -2300,30 +2306,14 @@ async function setAxleInfo(deviceId, tcVehicle) {
|
|
|
2300
2306
|
"00000000",
|
|
2301
2307
|
"00000000"
|
|
2302
2308
|
];
|
|
2303
|
-
const
|
|
2309
|
+
const axleTyres = tyresWithSensors.filter((tyre) => tyre.axlePosition === axleIndex + 1);
|
|
2304
2310
|
const spareTyre = spareTyres[axleIndex];
|
|
2305
|
-
if (
|
|
2306
|
-
|
|
2311
|
+
if (!axleTyres.length && !spareTyre) continue;
|
|
2312
|
+
for (const tyre of axleTyres) {
|
|
2313
|
+
const bridgeIndex = getBridgeIndexFromPositionId(tyre.positionId, 7);
|
|
2314
|
+
tyres[bridgeIndex] = tyre.tcTpmsSensor.id;
|
|
2307
2315
|
}
|
|
2308
|
-
|
|
2309
|
-
(t) => t.mountedOn?.positionId ? bridgeTools.getPositionInfo(t.mountedOn?.positionId).axlePosition === axleIndex + 1 && spareTyre?.mountedOn?.positionId !== t.mountedOn?.positionId : false
|
|
2310
|
-
) || [];
|
|
2311
|
-
axleTyres = axleTyres.sort((a, b) => (a.mountedOn?.positionId || 0) - (b.mountedOn?.positionId || 0));
|
|
2312
|
-
for (const [tyreIndex, tyre] of axleTyres.entries()) {
|
|
2313
|
-
const tyrePosition = tyre.mountedOn && bridgeTools.getPositionInfo(tyre.mountedOn.positionId).tyrePosition;
|
|
2314
|
-
const realTyreIndex = tyrePosition ? tyrePosition - 1 : tyreIndex;
|
|
2315
|
-
const sensorId = tyre.tcTpmsSensor?.id;
|
|
2316
|
-
if (!sensorId) continue;
|
|
2317
|
-
if (axle.isSpare) continue;
|
|
2318
|
-
const isTwinTyre = axle.tyresCount === 4;
|
|
2319
|
-
let bridgeTyreIndex = 0;
|
|
2320
|
-
if (isTwinTyre && realTyreIndex === 0) bridgeTyreIndex = 5;
|
|
2321
|
-
if (isTwinTyre && realTyreIndex === 1 || !isTwinTyre && realTyreIndex === 0) bridgeTyreIndex = 6;
|
|
2322
|
-
if (isTwinTyre && realTyreIndex === 3) bridgeTyreIndex = 9;
|
|
2323
|
-
if (isTwinTyre && realTyreIndex === 2 || !isTwinTyre && realTyreIndex === 1) bridgeTyreIndex = 8;
|
|
2324
|
-
tyres[bridgeTyreIndex] = bridgeTools.convertSensorIdForBridge(sensorId);
|
|
2325
|
-
}
|
|
2326
|
-
if (!___default.inRange(axleIndex, 0, 16)) return;
|
|
2316
|
+
if (spareTyre && spareTyre.tcTpmsSensor) tyres[7] = spareTyre.tcTpmsSensor.id;
|
|
2327
2317
|
const numberArray = tyres.map((x) => x.match(/.{2}/g)?.reverse()).flat().map((n) => n ? Number.parseInt(n, 16) : 0);
|
|
2328
2318
|
await bridgeCommands.setAxleInfo(deviceId, axleIndex, numberArray);
|
|
2329
2319
|
}
|
|
@@ -2672,17 +2662,13 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2672
2662
|
tcVehicle.tcTyres.push(spareTyre);
|
|
2673
2663
|
continue;
|
|
2674
2664
|
}
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
if (hasTwoTyres) sensorIndexes = [6, 8];
|
|
2679
|
-
if (hasFourTyres) sensorIndexes = [5, 6, 8, 9];
|
|
2680
|
-
for (let tyreIndex = 0; tyreIndex < sensorIndexes.length; tyreIndex++) {
|
|
2681
|
-
const tyrePositionId = getPositionId(index + 1, tyreIndex + 1, axle.tyresCount);
|
|
2665
|
+
for (let tyreIndex = 1; tyreIndex <= axle.tyresCount; tyreIndex++) {
|
|
2666
|
+
const tyrePositionId = getPositionId(index + 1, tyreIndex, axle.tyresCount);
|
|
2667
|
+
const sensorIndex = getBridgeIndexFromPositionId(tyrePositionId, 7);
|
|
2682
2668
|
const tyre = createNewTyre(tyrePositionId);
|
|
2683
|
-
if (Number.parseInt(joinedAxleData[
|
|
2669
|
+
if (Number.parseInt(joinedAxleData[sensorIndex], 16)) {
|
|
2684
2670
|
tyre.tcTpmsSensor = {
|
|
2685
|
-
id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[
|
|
2671
|
+
id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[sensorIndex])
|
|
2686
2672
|
};
|
|
2687
2673
|
}
|
|
2688
2674
|
tcVehicle.tcTyres.push(tyre);
|
package/dist/index.mjs
CHANGED
|
@@ -2068,7 +2068,8 @@ const bridgeService = {
|
|
|
2068
2068
|
getAutolearnStatuses,
|
|
2069
2069
|
isRebootRequired,
|
|
2070
2070
|
sendPinCommand,
|
|
2071
|
-
setVehicleLayout
|
|
2071
|
+
setVehicleLayout,
|
|
2072
|
+
setAxleInfo
|
|
2072
2073
|
};
|
|
2073
2074
|
async function sendPinCommand(deviceId) {
|
|
2074
2075
|
if (!canCommunicateWith(deviceId)) throw new Error("Bridge not connected");
|
|
@@ -2269,8 +2270,13 @@ async function getAxlesWithAutolearnSettings(deviceId) {
|
|
|
2269
2270
|
}
|
|
2270
2271
|
async function setAxleInfo(deviceId, tcVehicle) {
|
|
2271
2272
|
if (!tcVehicle.axles?.length) throw new Error("Vehicle has no axles");
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2273
|
+
const tyresWithInfo = tcVehicle.tcTyres.map((tyre) => ({
|
|
2274
|
+
tcTpmsSensor: tyre.tcTpmsSensor,
|
|
2275
|
+
...bridgeTools.getPositionInfo(tyre.mountedOn?.positionId || 0)
|
|
2276
|
+
}));
|
|
2277
|
+
const tyresWithSensors = tyresWithInfo.filter((tyre) => tyre.tcTpmsSensor && !tyre.isSpareTyre);
|
|
2278
|
+
const spareTyres = tyresWithInfo.filter((tyre) => tyre.isSpareTyre);
|
|
2279
|
+
for (let axleIndex = 0; axleIndex < 16; axleIndex++) {
|
|
2274
2280
|
const tyres = [
|
|
2275
2281
|
"00000000",
|
|
2276
2282
|
"00000000",
|
|
@@ -2293,30 +2299,14 @@ async function setAxleInfo(deviceId, tcVehicle) {
|
|
|
2293
2299
|
"00000000",
|
|
2294
2300
|
"00000000"
|
|
2295
2301
|
];
|
|
2296
|
-
const
|
|
2302
|
+
const axleTyres = tyresWithSensors.filter((tyre) => tyre.axlePosition === axleIndex + 1);
|
|
2297
2303
|
const spareTyre = spareTyres[axleIndex];
|
|
2298
|
-
if (
|
|
2299
|
-
|
|
2304
|
+
if (!axleTyres.length && !spareTyre) continue;
|
|
2305
|
+
for (const tyre of axleTyres) {
|
|
2306
|
+
const bridgeIndex = getBridgeIndexFromPositionId(tyre.positionId, 7);
|
|
2307
|
+
tyres[bridgeIndex] = tyre.tcTpmsSensor.id;
|
|
2300
2308
|
}
|
|
2301
|
-
|
|
2302
|
-
(t) => t.mountedOn?.positionId ? bridgeTools.getPositionInfo(t.mountedOn?.positionId).axlePosition === axleIndex + 1 && spareTyre?.mountedOn?.positionId !== t.mountedOn?.positionId : false
|
|
2303
|
-
) || [];
|
|
2304
|
-
axleTyres = axleTyres.sort((a, b) => (a.mountedOn?.positionId || 0) - (b.mountedOn?.positionId || 0));
|
|
2305
|
-
for (const [tyreIndex, tyre] of axleTyres.entries()) {
|
|
2306
|
-
const tyrePosition = tyre.mountedOn && bridgeTools.getPositionInfo(tyre.mountedOn.positionId).tyrePosition;
|
|
2307
|
-
const realTyreIndex = tyrePosition ? tyrePosition - 1 : tyreIndex;
|
|
2308
|
-
const sensorId = tyre.tcTpmsSensor?.id;
|
|
2309
|
-
if (!sensorId) continue;
|
|
2310
|
-
if (axle.isSpare) continue;
|
|
2311
|
-
const isTwinTyre = axle.tyresCount === 4;
|
|
2312
|
-
let bridgeTyreIndex = 0;
|
|
2313
|
-
if (isTwinTyre && realTyreIndex === 0) bridgeTyreIndex = 5;
|
|
2314
|
-
if (isTwinTyre && realTyreIndex === 1 || !isTwinTyre && realTyreIndex === 0) bridgeTyreIndex = 6;
|
|
2315
|
-
if (isTwinTyre && realTyreIndex === 3) bridgeTyreIndex = 9;
|
|
2316
|
-
if (isTwinTyre && realTyreIndex === 2 || !isTwinTyre && realTyreIndex === 1) bridgeTyreIndex = 8;
|
|
2317
|
-
tyres[bridgeTyreIndex] = bridgeTools.convertSensorIdForBridge(sensorId);
|
|
2318
|
-
}
|
|
2319
|
-
if (!_.inRange(axleIndex, 0, 16)) return;
|
|
2309
|
+
if (spareTyre && spareTyre.tcTpmsSensor) tyres[7] = spareTyre.tcTpmsSensor.id;
|
|
2320
2310
|
const numberArray = tyres.map((x) => x.match(/.{2}/g)?.reverse()).flat().map((n) => n ? Number.parseInt(n, 16) : 0);
|
|
2321
2311
|
await bridgeCommands.setAxleInfo(deviceId, axleIndex, numberArray);
|
|
2322
2312
|
}
|
|
@@ -2665,17 +2655,13 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2665
2655
|
tcVehicle.tcTyres.push(spareTyre);
|
|
2666
2656
|
continue;
|
|
2667
2657
|
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
if (hasTwoTyres) sensorIndexes = [6, 8];
|
|
2672
|
-
if (hasFourTyres) sensorIndexes = [5, 6, 8, 9];
|
|
2673
|
-
for (let tyreIndex = 0; tyreIndex < sensorIndexes.length; tyreIndex++) {
|
|
2674
|
-
const tyrePositionId = getPositionId(index + 1, tyreIndex + 1, axle.tyresCount);
|
|
2658
|
+
for (let tyreIndex = 1; tyreIndex <= axle.tyresCount; tyreIndex++) {
|
|
2659
|
+
const tyrePositionId = getPositionId(index + 1, tyreIndex, axle.tyresCount);
|
|
2660
|
+
const sensorIndex = getBridgeIndexFromPositionId(tyrePositionId, 7);
|
|
2675
2661
|
const tyre = createNewTyre(tyrePositionId);
|
|
2676
|
-
if (Number.parseInt(joinedAxleData[
|
|
2662
|
+
if (Number.parseInt(joinedAxleData[sensorIndex], 16)) {
|
|
2677
2663
|
tyre.tcTpmsSensor = {
|
|
2678
|
-
id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[
|
|
2664
|
+
id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[sensorIndex])
|
|
2679
2665
|
};
|
|
2680
2666
|
}
|
|
2681
2667
|
tcVehicle.tcTyres.push(tyre);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.48",
|
|
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",
|