tirecheck-device-sdk 0.2.47 → 0.2.49

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 CHANGED
@@ -2283,7 +2283,7 @@ async function setAxleInfo(deviceId, tcVehicle) {
2283
2283
  }));
2284
2284
  const tyresWithSensors = tyresWithInfo.filter((tyre) => tyre.tcTpmsSensor && !tyre.isSpareTyre);
2285
2285
  const spareTyres = tyresWithInfo.filter((tyre) => tyre.isSpareTyre);
2286
- for (let axleIndex = 1; axleIndex <= 16; axleIndex++) {
2286
+ for (let axleIndex = 0; axleIndex < 16; axleIndex++) {
2287
2287
  const tyres = [
2288
2288
  "00000000",
2289
2289
  "00000000",
@@ -2306,9 +2306,9 @@ async function setAxleInfo(deviceId, tcVehicle) {
2306
2306
  "00000000",
2307
2307
  "00000000"
2308
2308
  ];
2309
- const axleTyres = tyresWithSensors.filter((tyre) => tyre.axlePosition === axleIndex);
2310
- const spareTyre = spareTyres[axleIndex - 1];
2311
- if (!axleTyres.length && !spareTyre) continue;
2309
+ const axleTyres = tyresWithSensors.filter((tyre) => tyre.axlePosition === axleIndex + 1);
2310
+ const spareTyre = spareTyres[axleIndex];
2311
+ if (!axleTyres.length && !spareTyre && axleIndex >= tcVehicle.axles.length) continue;
2312
2312
  for (const tyre of axleTyres) {
2313
2313
  const bridgeIndex = getBridgeIndexFromPositionId(tyre.positionId, 7);
2314
2314
  tyres[bridgeIndex] = tyre.tcTpmsSensor.id;
@@ -2662,17 +2662,13 @@ async function assignTyres(deviceId, tcVehicle) {
2662
2662
  tcVehicle.tcTyres.push(spareTyre);
2663
2663
  continue;
2664
2664
  }
2665
- const hasTwoTyres = ___default.inRange(axle.tyresCount, 2, 4);
2666
- const hasFourTyres = ___default.inRange(axle.tyresCount, 4, 6);
2667
- let sensorIndexes = [];
2668
- if (hasTwoTyres) sensorIndexes = [6, 8];
2669
- if (hasFourTyres) sensorIndexes = [5, 6, 8, 9];
2670
- for (let tyreIndex = 0; tyreIndex < sensorIndexes.length; tyreIndex++) {
2671
- 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);
2672
2668
  const tyre = createNewTyre(tyrePositionId);
2673
- if (Number.parseInt(joinedAxleData[sensorIndexes[tyreIndex]], 16)) {
2669
+ if (Number.parseInt(joinedAxleData[sensorIndex], 16)) {
2674
2670
  tyre.tcTpmsSensor = {
2675
- id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[sensorIndexes[tyreIndex]])
2671
+ id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[sensorIndex])
2676
2672
  };
2677
2673
  }
2678
2674
  tcVehicle.tcTyres.push(tyre);
package/dist/index.mjs CHANGED
@@ -2276,7 +2276,7 @@ async function setAxleInfo(deviceId, tcVehicle) {
2276
2276
  }));
2277
2277
  const tyresWithSensors = tyresWithInfo.filter((tyre) => tyre.tcTpmsSensor && !tyre.isSpareTyre);
2278
2278
  const spareTyres = tyresWithInfo.filter((tyre) => tyre.isSpareTyre);
2279
- for (let axleIndex = 1; axleIndex <= 16; axleIndex++) {
2279
+ for (let axleIndex = 0; axleIndex < 16; axleIndex++) {
2280
2280
  const tyres = [
2281
2281
  "00000000",
2282
2282
  "00000000",
@@ -2299,9 +2299,9 @@ async function setAxleInfo(deviceId, tcVehicle) {
2299
2299
  "00000000",
2300
2300
  "00000000"
2301
2301
  ];
2302
- const axleTyres = tyresWithSensors.filter((tyre) => tyre.axlePosition === axleIndex);
2303
- const spareTyre = spareTyres[axleIndex - 1];
2304
- if (!axleTyres.length && !spareTyre) continue;
2302
+ const axleTyres = tyresWithSensors.filter((tyre) => tyre.axlePosition === axleIndex + 1);
2303
+ const spareTyre = spareTyres[axleIndex];
2304
+ if (!axleTyres.length && !spareTyre && axleIndex >= tcVehicle.axles.length) continue;
2305
2305
  for (const tyre of axleTyres) {
2306
2306
  const bridgeIndex = getBridgeIndexFromPositionId(tyre.positionId, 7);
2307
2307
  tyres[bridgeIndex] = tyre.tcTpmsSensor.id;
@@ -2655,17 +2655,13 @@ async function assignTyres(deviceId, tcVehicle) {
2655
2655
  tcVehicle.tcTyres.push(spareTyre);
2656
2656
  continue;
2657
2657
  }
2658
- const hasTwoTyres = _.inRange(axle.tyresCount, 2, 4);
2659
- const hasFourTyres = _.inRange(axle.tyresCount, 4, 6);
2660
- let sensorIndexes = [];
2661
- if (hasTwoTyres) sensorIndexes = [6, 8];
2662
- if (hasFourTyres) sensorIndexes = [5, 6, 8, 9];
2663
- for (let tyreIndex = 0; tyreIndex < sensorIndexes.length; tyreIndex++) {
2664
- 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);
2665
2661
  const tyre = createNewTyre(tyrePositionId);
2666
- if (Number.parseInt(joinedAxleData[sensorIndexes[tyreIndex]], 16)) {
2662
+ if (Number.parseInt(joinedAxleData[sensorIndex], 16)) {
2667
2663
  tyre.tcTpmsSensor = {
2668
- id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[sensorIndexes[tyreIndex]])
2664
+ id: bridgeTools.convertSensorIdFromBridge(joinedAxleData[sensorIndex])
2669
2665
  };
2670
2666
  }
2671
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.47",
3
+ "version": "0.2.49",
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",