tirecheck-device-sdk 0.2.41 → 0.2.43

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
@@ -509,7 +509,7 @@ const bridgeOtaAdvertisingParser = {
509
509
 
510
510
  const deviceMeta = {
511
511
  bridge: {
512
- nameRegex: /(030303|030321)/,
512
+ nameRegex: /^(030303|030321)$/,
513
513
  communication: {
514
514
  serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
515
515
  // message from device
@@ -2302,16 +2302,18 @@ async function setAxleInfo(deviceId, tcVehicle) {
2302
2302
  (t) => t.mountedOn?.positionId ? bridgeTools.getPositionInfo(t.mountedOn?.positionId).axlePosition === axleIndex + 1 && spareTyre?.mountedOn?.positionId !== t.mountedOn?.positionId : false
2303
2303
  ) || [];
2304
2304
  axleTyres = axleTyres.sort((a, b) => (a.mountedOn?.positionId || 0) - (b.mountedOn?.positionId || 0));
2305
- for (let tyreIndex = 0; tyreIndex < axleTyres.length; tyreIndex++) {
2306
- const sensorId = axleTyres[tyreIndex].tcTpmsSensor?.id;
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;
2307
2309
  if (!sensorId) continue;
2308
2310
  if (axle.isSpare) continue;
2309
2311
  const isTwinTyre = axle.tyresCount === 4;
2310
2312
  let bridgeTyreIndex = 0;
2311
- if (isTwinTyre && tyreIndex === 0) bridgeTyreIndex = 5;
2312
- if (isTwinTyre && tyreIndex === 1 || !isTwinTyre && tyreIndex === 0) bridgeTyreIndex = 6;
2313
- if (isTwinTyre && tyreIndex === 3) bridgeTyreIndex = 9;
2314
- if (isTwinTyre && tyreIndex === 2 || !isTwinTyre && tyreIndex === 1) bridgeTyreIndex = 8;
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;
2315
2317
  tyres[bridgeTyreIndex] = bridgeTools.convertSensorIdForBridge(sensorId);
2316
2318
  }
2317
2319
  if (!___default.inRange(axleIndex, 0, 16)) return;
package/dist/index.mjs CHANGED
@@ -502,7 +502,7 @@ const bridgeOtaAdvertisingParser = {
502
502
 
503
503
  const deviceMeta = {
504
504
  bridge: {
505
- nameRegex: /(030303|030321)/,
505
+ nameRegex: /^(030303|030321)$/,
506
506
  communication: {
507
507
  serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
508
508
  // message from device
@@ -2295,16 +2295,18 @@ async function setAxleInfo(deviceId, tcVehicle) {
2295
2295
  (t) => t.mountedOn?.positionId ? bridgeTools.getPositionInfo(t.mountedOn?.positionId).axlePosition === axleIndex + 1 && spareTyre?.mountedOn?.positionId !== t.mountedOn?.positionId : false
2296
2296
  ) || [];
2297
2297
  axleTyres = axleTyres.sort((a, b) => (a.mountedOn?.positionId || 0) - (b.mountedOn?.positionId || 0));
2298
- for (let tyreIndex = 0; tyreIndex < axleTyres.length; tyreIndex++) {
2299
- const sensorId = axleTyres[tyreIndex].tcTpmsSensor?.id;
2298
+ for (const [tyreIndex, tyre] of axleTyres.entries()) {
2299
+ const tyrePosition = tyre.mountedOn && bridgeTools.getPositionInfo(tyre.mountedOn.positionId).tyrePosition;
2300
+ const realTyreIndex = tyrePosition ? tyrePosition - 1 : tyreIndex;
2301
+ const sensorId = tyre.tcTpmsSensor?.id;
2300
2302
  if (!sensorId) continue;
2301
2303
  if (axle.isSpare) continue;
2302
2304
  const isTwinTyre = axle.tyresCount === 4;
2303
2305
  let bridgeTyreIndex = 0;
2304
- if (isTwinTyre && tyreIndex === 0) bridgeTyreIndex = 5;
2305
- if (isTwinTyre && tyreIndex === 1 || !isTwinTyre && tyreIndex === 0) bridgeTyreIndex = 6;
2306
- if (isTwinTyre && tyreIndex === 3) bridgeTyreIndex = 9;
2307
- if (isTwinTyre && tyreIndex === 2 || !isTwinTyre && tyreIndex === 1) bridgeTyreIndex = 8;
2306
+ if (isTwinTyre && realTyreIndex === 0) bridgeTyreIndex = 5;
2307
+ if (isTwinTyre && realTyreIndex === 1 || !isTwinTyre && realTyreIndex === 0) bridgeTyreIndex = 6;
2308
+ if (isTwinTyre && realTyreIndex === 3) bridgeTyreIndex = 9;
2309
+ if (isTwinTyre && realTyreIndex === 2 || !isTwinTyre && realTyreIndex === 1) bridgeTyreIndex = 8;
2308
2310
  tyres[bridgeTyreIndex] = bridgeTools.convertSensorIdForBridge(sensorId);
2309
2311
  }
2310
2312
  if (!_.inRange(axleIndex, 0, 16)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirecheck-device-sdk",
3
- "version": "0.2.41",
3
+ "version": "0.2.43",
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",