tirecheck-device-sdk 0.1.998 → 0.2.1
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 +60 -8
- package/dist/index.mjs +60 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -235,7 +235,7 @@ const bridgeTools = {
|
|
|
235
235
|
},
|
|
236
236
|
barToKpaByte(value) {
|
|
237
237
|
if (!value) return 0;
|
|
238
|
-
return ___default.round(value * 100 / 5.0625);
|
|
238
|
+
return ___default.round((value + 1) * 100 / 5.0625);
|
|
239
239
|
},
|
|
240
240
|
convertSensorIdForBridge(sensorId) {
|
|
241
241
|
if (sensorId.startsWith("2") && sensorId.length === 10) {
|
|
@@ -243,12 +243,12 @@ const bridgeTools = {
|
|
|
243
243
|
}
|
|
244
244
|
return sensorId;
|
|
245
245
|
},
|
|
246
|
-
kpaByteToBar(value) {
|
|
246
|
+
kpaByteToBar(value, decrementValue = 1) {
|
|
247
247
|
if (!___default.isNumber(value)) {
|
|
248
248
|
throw new TypeError("Value has to be a number");
|
|
249
249
|
}
|
|
250
250
|
const rawBar = value * 5.0625 / 100;
|
|
251
|
-
return ___default.round(Math.max(rawBar, 0), 1);
|
|
251
|
+
return ___default.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
252
252
|
},
|
|
253
253
|
isVersionGreaterThan(deviceId, version) {
|
|
254
254
|
if (version.length !== 5) {
|
|
@@ -2436,8 +2436,8 @@ function getPressureAndTemperatureReadingObjects(rawPressure, rawTemperature) {
|
|
|
2436
2436
|
return {
|
|
2437
2437
|
pressure: {
|
|
2438
2438
|
raw: rawPressure,
|
|
2439
|
-
meas: Math.max(0, measuredPressureAbsolute),
|
|
2440
|
-
bar: Math.max(0, compensatedPressureAbsolute)
|
|
2439
|
+
meas: Math.max(0, measuredPressureAbsolute - 1),
|
|
2440
|
+
bar: Math.max(0, compensatedPressureAbsolute - 1)
|
|
2441
2441
|
},
|
|
2442
2442
|
temperature: { raw: rawTemperature, amb: ambientTemperature, celsius: measuredTemperature }
|
|
2443
2443
|
};
|
|
@@ -2615,13 +2615,16 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2615
2615
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2616
2616
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2617
2617
|
if (axlesPressureData[axleIndex * 3]) {
|
|
2618
|
-
tcVehicleAxle.maxTargetPressure = ___default.floor(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]));
|
|
2618
|
+
tcVehicleAxle.maxTargetPressure = ___default.floor(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]), 1);
|
|
2619
2619
|
}
|
|
2620
2620
|
if (axlesPressureData[axleIndex * 3 + 1]) {
|
|
2621
|
-
tcVehicleAxle.minTargetPressure = ___default.ceil(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]));
|
|
2621
|
+
tcVehicleAxle.minTargetPressure = ___default.ceil(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]), 1);
|
|
2622
2622
|
}
|
|
2623
2623
|
if (axlesPressureData[axleIndex * 3 + 2]) {
|
|
2624
|
-
tcVehicleAxle.targetPressure = ___default.round(
|
|
2624
|
+
tcVehicleAxle.targetPressure = ___default.round(
|
|
2625
|
+
bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 2], void 0),
|
|
2626
|
+
1
|
|
2627
|
+
);
|
|
2625
2628
|
}
|
|
2626
2629
|
return tcVehicleAxle;
|
|
2627
2630
|
}
|
|
@@ -2904,6 +2907,22 @@ const bridgeSimulator = {
|
|
|
2904
2907
|
async setVehicle(deviceId, vehicle) {
|
|
2905
2908
|
const bridge = getSimulatedBridge(deviceId);
|
|
2906
2909
|
bridge.vin = vehicle.vin ?? bridge.vin;
|
|
2910
|
+
for (const tcTyre of vehicle.tcTyres) {
|
|
2911
|
+
if (tcTyre.tcTpmsSensor?.id && tcTyre.mountedOn?.positionId) {
|
|
2912
|
+
const currentSensor = bridge.simulatorData.sensors[tcTyre.mountedOn.positionId];
|
|
2913
|
+
if (currentSensor?.sensorId === tcTyre.tcTpmsSensor.id) {
|
|
2914
|
+
continue;
|
|
2915
|
+
}
|
|
2916
|
+
const tyreAxle = bridge.simulatorData.vehicle.axles[Math.floor(tcTyre.mountedOn.positionId / 100) - 1];
|
|
2917
|
+
if (!tyreAxle) continue;
|
|
2918
|
+
const sensorIdInBinary = bridgeTools.hexToDecimalArray(tcTyre.tcTpmsSensor.id).reverse();
|
|
2919
|
+
bridge.simulatorData.sensors[tcTyre.mountedOn.positionId] = createSensorData(
|
|
2920
|
+
tyreAxle,
|
|
2921
|
+
tcTyre.tcTpmsSensor.id,
|
|
2922
|
+
sensorIdInBinary
|
|
2923
|
+
);
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2907
2926
|
bridge.simulatorData.vehicle = vehicle;
|
|
2908
2927
|
},
|
|
2909
2928
|
async getConfiguration(deviceId) {
|
|
@@ -3159,6 +3178,39 @@ function getSimulatedBridgeTemplate() {
|
|
|
3159
3178
|
}
|
|
3160
3179
|
};
|
|
3161
3180
|
}
|
|
3181
|
+
function createSensorData(tyreAxle, sensorId, sensorIdInBinary) {
|
|
3182
|
+
return {
|
|
3183
|
+
date: Date.now(),
|
|
3184
|
+
eceStatus: 0,
|
|
3185
|
+
sensorId,
|
|
3186
|
+
sensorStatus: 0,
|
|
3187
|
+
pressure: {
|
|
3188
|
+
bar: tyreAxle.targetPressure ?? 0,
|
|
3189
|
+
meas: tyreAxle.targetPressure ?? 0,
|
|
3190
|
+
raw: (tyreAxle.targetPressure ?? 0) * 19.753086
|
|
3191
|
+
},
|
|
3192
|
+
pressureIssue: void 0,
|
|
3193
|
+
temperature: { amb: 20, celsius: 24, raw: 64 },
|
|
3194
|
+
byteReading: [
|
|
3195
|
+
16,
|
|
3196
|
+
1,
|
|
3197
|
+
12,
|
|
3198
|
+
253,
|
|
3199
|
+
25,
|
|
3200
|
+
...sensorIdInBinary,
|
|
3201
|
+
tyreAxle.targetPressure ? tyreAxle.targetPressure * 19.753086 : 0,
|
|
3202
|
+
64,
|
|
3203
|
+
255,
|
|
3204
|
+
0,
|
|
3205
|
+
0,
|
|
3206
|
+
40,
|
|
3207
|
+
255,
|
|
3208
|
+
255,
|
|
3209
|
+
255,
|
|
3210
|
+
255
|
|
3211
|
+
]
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3162
3214
|
|
|
3163
3215
|
const flexiGaugeTpmsSimulator = {
|
|
3164
3216
|
createSimulatedDevice(initialData) {
|
package/dist/index.mjs
CHANGED
|
@@ -228,7 +228,7 @@ const bridgeTools = {
|
|
|
228
228
|
},
|
|
229
229
|
barToKpaByte(value) {
|
|
230
230
|
if (!value) return 0;
|
|
231
|
-
return _.round(value * 100 / 5.0625);
|
|
231
|
+
return _.round((value + 1) * 100 / 5.0625);
|
|
232
232
|
},
|
|
233
233
|
convertSensorIdForBridge(sensorId) {
|
|
234
234
|
if (sensorId.startsWith("2") && sensorId.length === 10) {
|
|
@@ -236,12 +236,12 @@ const bridgeTools = {
|
|
|
236
236
|
}
|
|
237
237
|
return sensorId;
|
|
238
238
|
},
|
|
239
|
-
kpaByteToBar(value) {
|
|
239
|
+
kpaByteToBar(value, decrementValue = 1) {
|
|
240
240
|
if (!_.isNumber(value)) {
|
|
241
241
|
throw new TypeError("Value has to be a number");
|
|
242
242
|
}
|
|
243
243
|
const rawBar = value * 5.0625 / 100;
|
|
244
|
-
return _.round(Math.max(rawBar, 0), 1);
|
|
244
|
+
return _.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
245
245
|
},
|
|
246
246
|
isVersionGreaterThan(deviceId, version) {
|
|
247
247
|
if (version.length !== 5) {
|
|
@@ -2429,8 +2429,8 @@ function getPressureAndTemperatureReadingObjects(rawPressure, rawTemperature) {
|
|
|
2429
2429
|
return {
|
|
2430
2430
|
pressure: {
|
|
2431
2431
|
raw: rawPressure,
|
|
2432
|
-
meas: Math.max(0, measuredPressureAbsolute),
|
|
2433
|
-
bar: Math.max(0, compensatedPressureAbsolute)
|
|
2432
|
+
meas: Math.max(0, measuredPressureAbsolute - 1),
|
|
2433
|
+
bar: Math.max(0, compensatedPressureAbsolute - 1)
|
|
2434
2434
|
},
|
|
2435
2435
|
temperature: { raw: rawTemperature, amb: ambientTemperature, celsius: measuredTemperature }
|
|
2436
2436
|
};
|
|
@@ -2608,13 +2608,16 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2608
2608
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2609
2609
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2610
2610
|
if (axlesPressureData[axleIndex * 3]) {
|
|
2611
|
-
tcVehicleAxle.maxTargetPressure = _.floor(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]));
|
|
2611
|
+
tcVehicleAxle.maxTargetPressure = _.floor(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]), 1);
|
|
2612
2612
|
}
|
|
2613
2613
|
if (axlesPressureData[axleIndex * 3 + 1]) {
|
|
2614
|
-
tcVehicleAxle.minTargetPressure = _.ceil(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]));
|
|
2614
|
+
tcVehicleAxle.minTargetPressure = _.ceil(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]), 1);
|
|
2615
2615
|
}
|
|
2616
2616
|
if (axlesPressureData[axleIndex * 3 + 2]) {
|
|
2617
|
-
tcVehicleAxle.targetPressure = _.round(
|
|
2617
|
+
tcVehicleAxle.targetPressure = _.round(
|
|
2618
|
+
bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 2], void 0),
|
|
2619
|
+
1
|
|
2620
|
+
);
|
|
2618
2621
|
}
|
|
2619
2622
|
return tcVehicleAxle;
|
|
2620
2623
|
}
|
|
@@ -2897,6 +2900,22 @@ const bridgeSimulator = {
|
|
|
2897
2900
|
async setVehicle(deviceId, vehicle) {
|
|
2898
2901
|
const bridge = getSimulatedBridge(deviceId);
|
|
2899
2902
|
bridge.vin = vehicle.vin ?? bridge.vin;
|
|
2903
|
+
for (const tcTyre of vehicle.tcTyres) {
|
|
2904
|
+
if (tcTyre.tcTpmsSensor?.id && tcTyre.mountedOn?.positionId) {
|
|
2905
|
+
const currentSensor = bridge.simulatorData.sensors[tcTyre.mountedOn.positionId];
|
|
2906
|
+
if (currentSensor?.sensorId === tcTyre.tcTpmsSensor.id) {
|
|
2907
|
+
continue;
|
|
2908
|
+
}
|
|
2909
|
+
const tyreAxle = bridge.simulatorData.vehicle.axles[Math.floor(tcTyre.mountedOn.positionId / 100) - 1];
|
|
2910
|
+
if (!tyreAxle) continue;
|
|
2911
|
+
const sensorIdInBinary = bridgeTools.hexToDecimalArray(tcTyre.tcTpmsSensor.id).reverse();
|
|
2912
|
+
bridge.simulatorData.sensors[tcTyre.mountedOn.positionId] = createSensorData(
|
|
2913
|
+
tyreAxle,
|
|
2914
|
+
tcTyre.tcTpmsSensor.id,
|
|
2915
|
+
sensorIdInBinary
|
|
2916
|
+
);
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2900
2919
|
bridge.simulatorData.vehicle = vehicle;
|
|
2901
2920
|
},
|
|
2902
2921
|
async getConfiguration(deviceId) {
|
|
@@ -3152,6 +3171,39 @@ function getSimulatedBridgeTemplate() {
|
|
|
3152
3171
|
}
|
|
3153
3172
|
};
|
|
3154
3173
|
}
|
|
3174
|
+
function createSensorData(tyreAxle, sensorId, sensorIdInBinary) {
|
|
3175
|
+
return {
|
|
3176
|
+
date: Date.now(),
|
|
3177
|
+
eceStatus: 0,
|
|
3178
|
+
sensorId,
|
|
3179
|
+
sensorStatus: 0,
|
|
3180
|
+
pressure: {
|
|
3181
|
+
bar: tyreAxle.targetPressure ?? 0,
|
|
3182
|
+
meas: tyreAxle.targetPressure ?? 0,
|
|
3183
|
+
raw: (tyreAxle.targetPressure ?? 0) * 19.753086
|
|
3184
|
+
},
|
|
3185
|
+
pressureIssue: void 0,
|
|
3186
|
+
temperature: { amb: 20, celsius: 24, raw: 64 },
|
|
3187
|
+
byteReading: [
|
|
3188
|
+
16,
|
|
3189
|
+
1,
|
|
3190
|
+
12,
|
|
3191
|
+
253,
|
|
3192
|
+
25,
|
|
3193
|
+
...sensorIdInBinary,
|
|
3194
|
+
tyreAxle.targetPressure ? tyreAxle.targetPressure * 19.753086 : 0,
|
|
3195
|
+
64,
|
|
3196
|
+
255,
|
|
3197
|
+
0,
|
|
3198
|
+
0,
|
|
3199
|
+
40,
|
|
3200
|
+
255,
|
|
3201
|
+
255,
|
|
3202
|
+
255,
|
|
3203
|
+
255
|
|
3204
|
+
]
|
|
3205
|
+
};
|
|
3206
|
+
}
|
|
3155
3207
|
|
|
3156
3208
|
const flexiGaugeTpmsSimulator = {
|
|
3157
3209
|
createSimulatedDevice(initialData) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.01",
|
|
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",
|