tirecheck-device-sdk 0.2.58 → 0.2.59

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
@@ -2475,15 +2475,23 @@ async function setVehicle(deviceId, tcVehicle) {
2475
2475
  }
2476
2476
  async function getSensorReading(deviceId, positionId) {
2477
2477
  const value = await bridgeCommands.getSensorMeasurement(deviceId, positionId);
2478
+ const messageLength = value[2];
2479
+ const payloadStartIndex = 9;
2480
+ const payloadLength = messageLength - 6;
2481
+ const payload = value.slice(payloadStartIndex, payloadStartIndex + payloadLength);
2482
+ if (payload.length < 6) {
2483
+ throw new Error(`Invalid sensor measurement payload length: ${payload.length}`);
2484
+ }
2478
2485
  const sensorId = value.slice(5, 9).reverse().map((s) => decimalToHex(s).toUpperCase()).join("");
2479
2486
  const correctedSensorId = bridgeTools.convertSensorIdFromBridge(sensorId);
2480
2487
  return {
2481
- date: Date.now() - value[14] * 2e3,
2488
+ date: Date.now() - payload[5] * 2e3,
2482
2489
  sensorId: correctedSensorId,
2483
- sensorStatus: value[12],
2484
- eceStatus: value[13],
2485
- pressureIssue: getPressureIssue$1(deviceId, value[13]),
2486
- ...getPressureAndTemperatureReadingObjects(value[9], value[10]),
2490
+ sensorType: payload[6],
2491
+ sensorStatus: payload[3],
2492
+ eceStatus: payload[4],
2493
+ pressureIssue: getPressureIssue$1(deviceId, payload[4]),
2494
+ ...getPressureAndTemperatureReadingObjects(payload[0], payload[1]),
2487
2495
  byteReading: value
2488
2496
  };
2489
2497
  }
package/dist/index.d.cts CHANGED
@@ -736,6 +736,7 @@ interface BridgeConfiguration {
736
736
  interface BridgeReading {
737
737
  date: number;
738
738
  sensorId: string;
739
+ sensorType?: number;
739
740
  sensorStatus: number;
740
741
  eceStatus: number;
741
742
  pressureIssue?: BridgeTcIssue;
package/dist/index.d.mts CHANGED
@@ -736,6 +736,7 @@ interface BridgeConfiguration {
736
736
  interface BridgeReading {
737
737
  date: number;
738
738
  sensorId: string;
739
+ sensorType?: number;
739
740
  sensorStatus: number;
740
741
  eceStatus: number;
741
742
  pressureIssue?: BridgeTcIssue;
package/dist/index.d.ts CHANGED
@@ -736,6 +736,7 @@ interface BridgeConfiguration {
736
736
  interface BridgeReading {
737
737
  date: number;
738
738
  sensorId: string;
739
+ sensorType?: number;
739
740
  sensorStatus: number;
740
741
  eceStatus: number;
741
742
  pressureIssue?: BridgeTcIssue;
package/dist/index.mjs CHANGED
@@ -2468,15 +2468,23 @@ async function setVehicle(deviceId, tcVehicle) {
2468
2468
  }
2469
2469
  async function getSensorReading(deviceId, positionId) {
2470
2470
  const value = await bridgeCommands.getSensorMeasurement(deviceId, positionId);
2471
+ const messageLength = value[2];
2472
+ const payloadStartIndex = 9;
2473
+ const payloadLength = messageLength - 6;
2474
+ const payload = value.slice(payloadStartIndex, payloadStartIndex + payloadLength);
2475
+ if (payload.length < 6) {
2476
+ throw new Error(`Invalid sensor measurement payload length: ${payload.length}`);
2477
+ }
2471
2478
  const sensorId = value.slice(5, 9).reverse().map((s) => decimalToHex(s).toUpperCase()).join("");
2472
2479
  const correctedSensorId = bridgeTools.convertSensorIdFromBridge(sensorId);
2473
2480
  return {
2474
- date: Date.now() - value[14] * 2e3,
2481
+ date: Date.now() - payload[5] * 2e3,
2475
2482
  sensorId: correctedSensorId,
2476
- sensorStatus: value[12],
2477
- eceStatus: value[13],
2478
- pressureIssue: getPressureIssue$1(deviceId, value[13]),
2479
- ...getPressureAndTemperatureReadingObjects(value[9], value[10]),
2483
+ sensorType: payload[6],
2484
+ sensorStatus: payload[3],
2485
+ eceStatus: payload[4],
2486
+ pressureIssue: getPressureIssue$1(deviceId, payload[4]),
2487
+ ...getPressureAndTemperatureReadingObjects(payload[0], payload[1]),
2480
2488
  byteReading: value
2481
2489
  };
2482
2490
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirecheck-device-sdk",
3
- "version": "0.2.58",
3
+ "version": "0.2.59",
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",