tirecheck-device-sdk 0.1.996 → 0.1.997

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
@@ -2333,7 +2333,7 @@ async function getSensorReading(deviceId, positionId) {
2333
2333
  sensorId: correctedSensorId,
2334
2334
  sensorStatus: value[12],
2335
2335
  eceStatus: value[13],
2336
- pressureIssue: getPressureIssue(deviceId, value[13]),
2336
+ pressureIssue: getPressureIssue$1(deviceId, value[13]),
2337
2337
  ...getPressureAndTemperatureReadingObjects(value[9], value[10]),
2338
2338
  byteReading: value
2339
2339
  };
@@ -2442,7 +2442,7 @@ function getPressureAndTemperatureReadingObjects(rawPressure, rawTemperature) {
2442
2442
  temperature: { raw: rawTemperature, amb: ambientTemperature, celsius: measuredTemperature }
2443
2443
  };
2444
2444
  }
2445
- function getPressureIssue(deviceId, eceStatus) {
2445
+ function getPressureIssue$1(deviceId, eceStatus) {
2446
2446
  if (eceStatus === 254) {
2447
2447
  return {
2448
2448
  date: Date.now(),
@@ -2914,7 +2914,7 @@ const bridgeSimulator = {
2914
2914
  },
2915
2915
  async setConfiguration(deviceId, config) {
2916
2916
  const bridge = getSimulatedBridge(deviceId);
2917
- bridge.simulatorData.configuration = config;
2917
+ bridge.simulatorData.configuration = ___default.cloneDeep(config);
2918
2918
  },
2919
2919
  async getSensorReading(deviceId, positionId) {
2920
2920
  const bridge = getSimulatedBridge(deviceId);
@@ -2922,7 +2922,11 @@ const bridgeSimulator = {
2922
2922
  },
2923
2923
  async getVehicleReadings(deviceId, vehicle) {
2924
2924
  const bridge = getSimulatedBridge(deviceId);
2925
- return ___default.values(bridge.simulatorData.sensors);
2925
+ const readings = ___default.values(bridge.simulatorData.sensors);
2926
+ for (const reading of readings) {
2927
+ reading.pressureIssue = getPressureIssue(deviceId, reading.eceStatus);
2928
+ }
2929
+ return readings;
2926
2930
  },
2927
2931
  async getAutolearnStatuses(deviceId) {
2928
2932
  const bridge = getSimulatedBridge(deviceId);
@@ -2946,7 +2950,7 @@ const bridgeSimulator = {
2946
2950
  bridge.advertisingData.fwVersion = "1.9.9";
2947
2951
  },
2948
2952
  async connect(deviceId) {
2949
- if (store.simulatedDevices[deviceId].isDisabled) throw new Error(`Simulated bridge is disabled: ${deviceId}`);
2953
+ if (store.simulatedDevices[deviceId].isDisabled) return;
2950
2954
  store.setState(deviceId, "connecting");
2951
2955
  await toolsSvc.delay(100);
2952
2956
  store.setState(deviceId, "connected");
@@ -2962,6 +2966,60 @@ const bridgeSimulator = {
2962
2966
  return simulatorSvc.merge(getSimulatedBridgeTemplate(), initialData);
2963
2967
  }
2964
2968
  };
2969
+ function getPressureIssue(deviceId, eceStatus) {
2970
+ if (eceStatus === 254) {
2971
+ return {
2972
+ date: Date.now(),
2973
+ tcIssue: {
2974
+ id: "outdatedCritical"
2975
+ },
2976
+ type: "outdated",
2977
+ severity: "critical"
2978
+ };
2979
+ }
2980
+ const bridge = getSimulatedBridge(deviceId);
2981
+ const usesNewValues = (bridge.advertisingData.fwVersion || "") > "0.8.F";
2982
+ if (eceStatus === (usesNewValues ? 3 : 4)) {
2983
+ return {
2984
+ date: Date.now(),
2985
+ tcIssue: {
2986
+ id: "overinflationCritical"
2987
+ },
2988
+ type: "over_inflated",
2989
+ severity: "critical"
2990
+ };
2991
+ }
2992
+ if (eceStatus === (usesNewValues ? 1 : 3)) {
2993
+ return {
2994
+ date: Date.now(),
2995
+ tcIssue: {
2996
+ id: "overinflationWarning"
2997
+ },
2998
+ severity: "warning",
2999
+ type: "over_inflated"
3000
+ };
3001
+ }
3002
+ if (eceStatus === (usesNewValues ? 4 : 2)) {
3003
+ return {
3004
+ date: Date.now(),
3005
+ tcIssue: {
3006
+ id: "underinflationCritical"
3007
+ },
3008
+ severity: "critical",
3009
+ type: "under_inflated"
3010
+ };
3011
+ }
3012
+ if (eceStatus === (usesNewValues ? 2 : 1)) {
3013
+ return {
3014
+ date: Date.now(),
3015
+ tcIssue: {
3016
+ id: "underinflationWarning"
3017
+ },
3018
+ severity: "warning",
3019
+ type: "under_inflated"
3020
+ };
3021
+ }
3022
+ }
2965
3023
  function getSimulatedBridge(deviceId) {
2966
3024
  const simulatedDevice = store.simulatedDevices[deviceId];
2967
3025
  if (!simulatedDevice) throw new Error(`Simulated bridge was not found: ${deviceId}`);
@@ -2973,7 +3031,7 @@ function getSimulatedBridgeTemplate() {
2973
3031
  type: "bridge",
2974
3032
  id: "bridge1",
2975
3033
  rssi: -50,
2976
- bridgeId: "FFFFAABB",
3034
+ bridgeId: "FFFAABB",
2977
3035
  vin: "VIN1",
2978
3036
  name: "Bridge1",
2979
3037
  simulatorData: {
@@ -2982,7 +3040,7 @@ function getSimulatedBridgeTemplate() {
2982
3040
  registrationNumber: "",
2983
3041
  vin: "VIN1",
2984
3042
  tcTyres: [
2985
- { mountedOn: { positionId: 112 }, serialNumber: "TYRE-112", tcTpmsSensor: { id: "FFFFAABB" } },
3043
+ { mountedOn: { positionId: 112 }, serialNumber: "TYRE-112", tcTpmsSensor: { id: "A0FFAABB" } },
2986
3044
  { mountedOn: { positionId: 122 }, serialNumber: "TYRE-122" }
2987
3045
  ]
2988
3046
  },
@@ -2990,18 +3048,18 @@ function getSimulatedBridgeTemplate() {
2990
3048
  112: {
2991
3049
  autolearnedStatus: "default",
2992
3050
  positionId: 112,
2993
- autolearnedSensorId: "FFFFAABB"
3051
+ autolearnedSensorId: "A0FFAABB"
2994
3052
  }
2995
3053
  },
2996
3054
  sensors: {
2997
3055
  112: {
2998
3056
  date: Date.now(),
2999
- eceStatus: 0,
3000
- sensorId: "FFFFAABB",
3057
+ eceStatus: 2,
3058
+ sensorId: "A0FFAABB",
3001
3059
  sensorStatus: 0,
3002
- pressure: { bar: 0, meas: 0, raw: 0 },
3060
+ pressure: { bar: 1, meas: 1, raw: 19 },
3003
3061
  pressureIssue: void 0,
3004
- temperature: { amb: 0, celsius: 0, raw: 0 },
3062
+ temperature: { amb: 20, celsius: 24, raw: 64 },
3005
3063
  byteReading: [0, 0, 0, 0, 0, 0, 0, 0]
3006
3064
  }
3007
3065
  },
@@ -3179,10 +3237,51 @@ const simulator = {
3179
3237
  return simulatedDevices;
3180
3238
  },
3181
3239
  putSimulatedDevice(device) {
3240
+ ensureSimulatorMethodsAreInjected();
3241
+ const normalizedDevice = this.createSimulatedDevice(device);
3242
+ store.simulatedDevices[normalizedDevice.id] = normalizedDevice;
3243
+ return normalizedDevice;
3244
+ },
3245
+ putSimulatedNormalizedDevice(normalizedDevice) {
3246
+ store.simulatedDevices[normalizedDevice.id] = normalizedDevice;
3247
+ },
3248
+ createSimulatedDevice(device) {
3182
3249
  ensureSimulatorMethodsAreInjected();
3183
3250
  const normalizedDevice = normalizeSimulatedDevice(device);
3184
3251
  if (normalizedDevice) {
3185
- store.simulatedDevices[normalizedDevice.id] = normalizedDevice;
3252
+ if (normalizedDevice?.type === "bridge" && normalizedDevice?.simulatorData?.sensors) {
3253
+ const keys = Object.keys(normalizedDevice.simulatorData.sensors);
3254
+ for (const key of keys) {
3255
+ const sensor = normalizedDevice.simulatorData.sensors[key];
3256
+ const sensorIdInBinary = bridgeTools.hexToDecimalArray(sensor.sensorId).reverse();
3257
+ const pressureTemperature = getRawPressureandTemperatureValue(
3258
+ sensor.pressure.bar,
3259
+ sensor.pressure.meas,
3260
+ sensor.temperature.celsius
3261
+ );
3262
+ const responseHeader = [16, 1, 12, 253];
3263
+ const rssiByte = 255;
3264
+ const sensorStatus = sensor.sensorStatus;
3265
+ const eceStatusByte = calculateEceStatusByte(
3266
+ key,
3267
+ normalizedDevice.simulatorData,
3268
+ normalizedDevice.advertisingData
3269
+ );
3270
+ const signatureBytes = [255, 255, 255, 255];
3271
+ sensor.byteReading = [
3272
+ ...responseHeader,
3273
+ 25,
3274
+ ...sensorIdInBinary,
3275
+ ...pressureTemperature,
3276
+ rssiByte,
3277
+ sensorStatus,
3278
+ eceStatusByte,
3279
+ 40,
3280
+ ...signatureBytes
3281
+ ];
3282
+ sensor.eceStatus = eceStatusByte;
3283
+ }
3284
+ }
3186
3285
  }
3187
3286
  return normalizedDevice;
3188
3287
  },
@@ -3204,6 +3303,49 @@ function normalizeSimulatedDevice(device) {
3204
3303
  }
3205
3304
  throw new Error(`Simulator is not supported for device type: ${device.type}`);
3206
3305
  }
3306
+ function calculateEceStatusByte(positionId, simulatorData, advertisingData) {
3307
+ const customerPressureThresholdsDecimal = bridgeTools.hexToDecimalArray(
3308
+ simulatorData.configuration.customerPressureThresholds.axle01
3309
+ );
3310
+ const pressureThresholds = {
3311
+ overinflationCritical: customerPressureThresholdsDecimal[0],
3312
+ overinflationWarning: customerPressureThresholdsDecimal[1],
3313
+ underinflationWarning: customerPressureThresholdsDecimal[2],
3314
+ underinflationCritical: customerPressureThresholdsDecimal[3]
3315
+ };
3316
+ const sensor = simulatorData.sensors[positionId];
3317
+ const axleIndex = Math.floor(positionId / 100) - 1;
3318
+ const axle = simulatorData.vehicle.axles[axleIndex];
3319
+ if (!axle || axle.targetPressure === void 0) return 0;
3320
+ if (!sensor.pressure) return 0;
3321
+ const sensorPressure = sensor.pressure.meas ?? sensor.pressure.bar;
3322
+ const percentageDifference = (sensorPressure - axle.targetPressure) / axle.targetPressure * 100;
3323
+ const usesNewValues = (advertisingData.fwVersion || "") > "0.8.F";
3324
+ if (percentageDifference >= pressureThresholds.overinflationCritical) {
3325
+ return usesNewValues ? 3 : 4;
3326
+ }
3327
+ if (percentageDifference >= pressureThresholds.overinflationWarning) {
3328
+ return usesNewValues ? 1 : 3;
3329
+ }
3330
+ if (percentageDifference <= -pressureThresholds.underinflationCritical) {
3331
+ return usesNewValues ? 4 : 2;
3332
+ }
3333
+ if (percentageDifference <= -pressureThresholds.underinflationWarning) {
3334
+ return usesNewValues ? 2 : 1;
3335
+ }
3336
+ return 0;
3337
+ }
3338
+ function getRawPressureandTemperatureValue(barPressure, measPressure, measuredTemperature) {
3339
+ const ambientTemperature = 20;
3340
+ const rawTemperature = 40 + measuredTemperature;
3341
+ if (measPressure !== null) {
3342
+ return [Math.round((measPressure + 1) * 19.753086), rawTemperature];
3343
+ }
3344
+ const rawPressure = Math.round(
3345
+ (barPressure + 1) * (273 + measuredTemperature) / (273 + ambientTemperature) * 19.753086
3346
+ );
3347
+ return [rawPressure, rawTemperature];
3348
+ }
3207
3349
  function ensureSimulatorMethodsAreInjected() {
3208
3350
  if (areSimulatorMethodsInjected) return;
3209
3351
  areSimulatorMethodsInjected = true;
package/dist/index.d.cts CHANGED
@@ -894,6 +894,8 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
894
894
  simulator: {
895
895
  putSimulatedDevices(devices: Record<string, DeepPartial<BleDeviceSimulated>>): Record<string, BleDeviceSimulated>;
896
896
  putSimulatedDevice(device: DeepPartial<BleDeviceSimulated>): BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
897
+ putSimulatedNormalizedDevice(normalizedDevice: BleBridgeSimulated | BleFlexiGaugeTpmsSimulated): void;
898
+ createSimulatedDevice(device: DeepPartial<BleDeviceSimulated>): BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
897
899
  deleteSimulatedDevice(deviceId: string): void;
898
900
  getSimulatedDevices(): Record<string, BleDeviceSimulated>;
899
901
  triggerEvent: (eventName: EventName, deviceId: string, payload?: any) => void;
package/dist/index.d.mts CHANGED
@@ -894,6 +894,8 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
894
894
  simulator: {
895
895
  putSimulatedDevices(devices: Record<string, DeepPartial<BleDeviceSimulated>>): Record<string, BleDeviceSimulated>;
896
896
  putSimulatedDevice(device: DeepPartial<BleDeviceSimulated>): BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
897
+ putSimulatedNormalizedDevice(normalizedDevice: BleBridgeSimulated | BleFlexiGaugeTpmsSimulated): void;
898
+ createSimulatedDevice(device: DeepPartial<BleDeviceSimulated>): BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
897
899
  deleteSimulatedDevice(deviceId: string): void;
898
900
  getSimulatedDevices(): Record<string, BleDeviceSimulated>;
899
901
  triggerEvent: (eventName: EventName, deviceId: string, payload?: any) => void;
package/dist/index.d.ts CHANGED
@@ -894,6 +894,8 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
894
894
  simulator: {
895
895
  putSimulatedDevices(devices: Record<string, DeepPartial<BleDeviceSimulated>>): Record<string, BleDeviceSimulated>;
896
896
  putSimulatedDevice(device: DeepPartial<BleDeviceSimulated>): BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
897
+ putSimulatedNormalizedDevice(normalizedDevice: BleBridgeSimulated | BleFlexiGaugeTpmsSimulated): void;
898
+ createSimulatedDevice(device: DeepPartial<BleDeviceSimulated>): BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
897
899
  deleteSimulatedDevice(deviceId: string): void;
898
900
  getSimulatedDevices(): Record<string, BleDeviceSimulated>;
899
901
  triggerEvent: (eventName: EventName, deviceId: string, payload?: any) => void;
package/dist/index.mjs CHANGED
@@ -2326,7 +2326,7 @@ async function getSensorReading(deviceId, positionId) {
2326
2326
  sensorId: correctedSensorId,
2327
2327
  sensorStatus: value[12],
2328
2328
  eceStatus: value[13],
2329
- pressureIssue: getPressureIssue(deviceId, value[13]),
2329
+ pressureIssue: getPressureIssue$1(deviceId, value[13]),
2330
2330
  ...getPressureAndTemperatureReadingObjects(value[9], value[10]),
2331
2331
  byteReading: value
2332
2332
  };
@@ -2435,7 +2435,7 @@ function getPressureAndTemperatureReadingObjects(rawPressure, rawTemperature) {
2435
2435
  temperature: { raw: rawTemperature, amb: ambientTemperature, celsius: measuredTemperature }
2436
2436
  };
2437
2437
  }
2438
- function getPressureIssue(deviceId, eceStatus) {
2438
+ function getPressureIssue$1(deviceId, eceStatus) {
2439
2439
  if (eceStatus === 254) {
2440
2440
  return {
2441
2441
  date: Date.now(),
@@ -2907,7 +2907,7 @@ const bridgeSimulator = {
2907
2907
  },
2908
2908
  async setConfiguration(deviceId, config) {
2909
2909
  const bridge = getSimulatedBridge(deviceId);
2910
- bridge.simulatorData.configuration = config;
2910
+ bridge.simulatorData.configuration = _.cloneDeep(config);
2911
2911
  },
2912
2912
  async getSensorReading(deviceId, positionId) {
2913
2913
  const bridge = getSimulatedBridge(deviceId);
@@ -2915,7 +2915,11 @@ const bridgeSimulator = {
2915
2915
  },
2916
2916
  async getVehicleReadings(deviceId, vehicle) {
2917
2917
  const bridge = getSimulatedBridge(deviceId);
2918
- return _.values(bridge.simulatorData.sensors);
2918
+ const readings = _.values(bridge.simulatorData.sensors);
2919
+ for (const reading of readings) {
2920
+ reading.pressureIssue = getPressureIssue(deviceId, reading.eceStatus);
2921
+ }
2922
+ return readings;
2919
2923
  },
2920
2924
  async getAutolearnStatuses(deviceId) {
2921
2925
  const bridge = getSimulatedBridge(deviceId);
@@ -2939,7 +2943,7 @@ const bridgeSimulator = {
2939
2943
  bridge.advertisingData.fwVersion = "1.9.9";
2940
2944
  },
2941
2945
  async connect(deviceId) {
2942
- if (store.simulatedDevices[deviceId].isDisabled) throw new Error(`Simulated bridge is disabled: ${deviceId}`);
2946
+ if (store.simulatedDevices[deviceId].isDisabled) return;
2943
2947
  store.setState(deviceId, "connecting");
2944
2948
  await toolsSvc.delay(100);
2945
2949
  store.setState(deviceId, "connected");
@@ -2955,6 +2959,60 @@ const bridgeSimulator = {
2955
2959
  return simulatorSvc.merge(getSimulatedBridgeTemplate(), initialData);
2956
2960
  }
2957
2961
  };
2962
+ function getPressureIssue(deviceId, eceStatus) {
2963
+ if (eceStatus === 254) {
2964
+ return {
2965
+ date: Date.now(),
2966
+ tcIssue: {
2967
+ id: "outdatedCritical"
2968
+ },
2969
+ type: "outdated",
2970
+ severity: "critical"
2971
+ };
2972
+ }
2973
+ const bridge = getSimulatedBridge(deviceId);
2974
+ const usesNewValues = (bridge.advertisingData.fwVersion || "") > "0.8.F";
2975
+ if (eceStatus === (usesNewValues ? 3 : 4)) {
2976
+ return {
2977
+ date: Date.now(),
2978
+ tcIssue: {
2979
+ id: "overinflationCritical"
2980
+ },
2981
+ type: "over_inflated",
2982
+ severity: "critical"
2983
+ };
2984
+ }
2985
+ if (eceStatus === (usesNewValues ? 1 : 3)) {
2986
+ return {
2987
+ date: Date.now(),
2988
+ tcIssue: {
2989
+ id: "overinflationWarning"
2990
+ },
2991
+ severity: "warning",
2992
+ type: "over_inflated"
2993
+ };
2994
+ }
2995
+ if (eceStatus === (usesNewValues ? 4 : 2)) {
2996
+ return {
2997
+ date: Date.now(),
2998
+ tcIssue: {
2999
+ id: "underinflationCritical"
3000
+ },
3001
+ severity: "critical",
3002
+ type: "under_inflated"
3003
+ };
3004
+ }
3005
+ if (eceStatus === (usesNewValues ? 2 : 1)) {
3006
+ return {
3007
+ date: Date.now(),
3008
+ tcIssue: {
3009
+ id: "underinflationWarning"
3010
+ },
3011
+ severity: "warning",
3012
+ type: "under_inflated"
3013
+ };
3014
+ }
3015
+ }
2958
3016
  function getSimulatedBridge(deviceId) {
2959
3017
  const simulatedDevice = store.simulatedDevices[deviceId];
2960
3018
  if (!simulatedDevice) throw new Error(`Simulated bridge was not found: ${deviceId}`);
@@ -2966,7 +3024,7 @@ function getSimulatedBridgeTemplate() {
2966
3024
  type: "bridge",
2967
3025
  id: "bridge1",
2968
3026
  rssi: -50,
2969
- bridgeId: "FFFFAABB",
3027
+ bridgeId: "FFFAABB",
2970
3028
  vin: "VIN1",
2971
3029
  name: "Bridge1",
2972
3030
  simulatorData: {
@@ -2975,7 +3033,7 @@ function getSimulatedBridgeTemplate() {
2975
3033
  registrationNumber: "",
2976
3034
  vin: "VIN1",
2977
3035
  tcTyres: [
2978
- { mountedOn: { positionId: 112 }, serialNumber: "TYRE-112", tcTpmsSensor: { id: "FFFFAABB" } },
3036
+ { mountedOn: { positionId: 112 }, serialNumber: "TYRE-112", tcTpmsSensor: { id: "A0FFAABB" } },
2979
3037
  { mountedOn: { positionId: 122 }, serialNumber: "TYRE-122" }
2980
3038
  ]
2981
3039
  },
@@ -2983,18 +3041,18 @@ function getSimulatedBridgeTemplate() {
2983
3041
  112: {
2984
3042
  autolearnedStatus: "default",
2985
3043
  positionId: 112,
2986
- autolearnedSensorId: "FFFFAABB"
3044
+ autolearnedSensorId: "A0FFAABB"
2987
3045
  }
2988
3046
  },
2989
3047
  sensors: {
2990
3048
  112: {
2991
3049
  date: Date.now(),
2992
- eceStatus: 0,
2993
- sensorId: "FFFFAABB",
3050
+ eceStatus: 2,
3051
+ sensorId: "A0FFAABB",
2994
3052
  sensorStatus: 0,
2995
- pressure: { bar: 0, meas: 0, raw: 0 },
3053
+ pressure: { bar: 1, meas: 1, raw: 19 },
2996
3054
  pressureIssue: void 0,
2997
- temperature: { amb: 0, celsius: 0, raw: 0 },
3055
+ temperature: { amb: 20, celsius: 24, raw: 64 },
2998
3056
  byteReading: [0, 0, 0, 0, 0, 0, 0, 0]
2999
3057
  }
3000
3058
  },
@@ -3172,10 +3230,51 @@ const simulator = {
3172
3230
  return simulatedDevices;
3173
3231
  },
3174
3232
  putSimulatedDevice(device) {
3233
+ ensureSimulatorMethodsAreInjected();
3234
+ const normalizedDevice = this.createSimulatedDevice(device);
3235
+ store.simulatedDevices[normalizedDevice.id] = normalizedDevice;
3236
+ return normalizedDevice;
3237
+ },
3238
+ putSimulatedNormalizedDevice(normalizedDevice) {
3239
+ store.simulatedDevices[normalizedDevice.id] = normalizedDevice;
3240
+ },
3241
+ createSimulatedDevice(device) {
3175
3242
  ensureSimulatorMethodsAreInjected();
3176
3243
  const normalizedDevice = normalizeSimulatedDevice(device);
3177
3244
  if (normalizedDevice) {
3178
- store.simulatedDevices[normalizedDevice.id] = normalizedDevice;
3245
+ if (normalizedDevice?.type === "bridge" && normalizedDevice?.simulatorData?.sensors) {
3246
+ const keys = Object.keys(normalizedDevice.simulatorData.sensors);
3247
+ for (const key of keys) {
3248
+ const sensor = normalizedDevice.simulatorData.sensors[key];
3249
+ const sensorIdInBinary = bridgeTools.hexToDecimalArray(sensor.sensorId).reverse();
3250
+ const pressureTemperature = getRawPressureandTemperatureValue(
3251
+ sensor.pressure.bar,
3252
+ sensor.pressure.meas,
3253
+ sensor.temperature.celsius
3254
+ );
3255
+ const responseHeader = [16, 1, 12, 253];
3256
+ const rssiByte = 255;
3257
+ const sensorStatus = sensor.sensorStatus;
3258
+ const eceStatusByte = calculateEceStatusByte(
3259
+ key,
3260
+ normalizedDevice.simulatorData,
3261
+ normalizedDevice.advertisingData
3262
+ );
3263
+ const signatureBytes = [255, 255, 255, 255];
3264
+ sensor.byteReading = [
3265
+ ...responseHeader,
3266
+ 25,
3267
+ ...sensorIdInBinary,
3268
+ ...pressureTemperature,
3269
+ rssiByte,
3270
+ sensorStatus,
3271
+ eceStatusByte,
3272
+ 40,
3273
+ ...signatureBytes
3274
+ ];
3275
+ sensor.eceStatus = eceStatusByte;
3276
+ }
3277
+ }
3179
3278
  }
3180
3279
  return normalizedDevice;
3181
3280
  },
@@ -3197,6 +3296,49 @@ function normalizeSimulatedDevice(device) {
3197
3296
  }
3198
3297
  throw new Error(`Simulator is not supported for device type: ${device.type}`);
3199
3298
  }
3299
+ function calculateEceStatusByte(positionId, simulatorData, advertisingData) {
3300
+ const customerPressureThresholdsDecimal = bridgeTools.hexToDecimalArray(
3301
+ simulatorData.configuration.customerPressureThresholds.axle01
3302
+ );
3303
+ const pressureThresholds = {
3304
+ overinflationCritical: customerPressureThresholdsDecimal[0],
3305
+ overinflationWarning: customerPressureThresholdsDecimal[1],
3306
+ underinflationWarning: customerPressureThresholdsDecimal[2],
3307
+ underinflationCritical: customerPressureThresholdsDecimal[3]
3308
+ };
3309
+ const sensor = simulatorData.sensors[positionId];
3310
+ const axleIndex = Math.floor(positionId / 100) - 1;
3311
+ const axle = simulatorData.vehicle.axles[axleIndex];
3312
+ if (!axle || axle.targetPressure === void 0) return 0;
3313
+ if (!sensor.pressure) return 0;
3314
+ const sensorPressure = sensor.pressure.meas ?? sensor.pressure.bar;
3315
+ const percentageDifference = (sensorPressure - axle.targetPressure) / axle.targetPressure * 100;
3316
+ const usesNewValues = (advertisingData.fwVersion || "") > "0.8.F";
3317
+ if (percentageDifference >= pressureThresholds.overinflationCritical) {
3318
+ return usesNewValues ? 3 : 4;
3319
+ }
3320
+ if (percentageDifference >= pressureThresholds.overinflationWarning) {
3321
+ return usesNewValues ? 1 : 3;
3322
+ }
3323
+ if (percentageDifference <= -pressureThresholds.underinflationCritical) {
3324
+ return usesNewValues ? 4 : 2;
3325
+ }
3326
+ if (percentageDifference <= -pressureThresholds.underinflationWarning) {
3327
+ return usesNewValues ? 2 : 1;
3328
+ }
3329
+ return 0;
3330
+ }
3331
+ function getRawPressureandTemperatureValue(barPressure, measPressure, measuredTemperature) {
3332
+ const ambientTemperature = 20;
3333
+ const rawTemperature = 40 + measuredTemperature;
3334
+ if (measPressure !== null) {
3335
+ return [Math.round((measPressure + 1) * 19.753086), rawTemperature];
3336
+ }
3337
+ const rawPressure = Math.round(
3338
+ (barPressure + 1) * (273 + measuredTemperature) / (273 + ambientTemperature) * 19.753086
3339
+ );
3340
+ return [rawPressure, rawTemperature];
3341
+ }
3200
3342
  function ensureSimulatorMethodsAreInjected() {
3201
3343
  if (areSimulatorMethodsInjected) return;
3202
3344
  areSimulatorMethodsInjected = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirecheck-device-sdk",
3
- "version": "0.1.996",
3
+ "version": "0.1.997",
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",