tirecheck-device-sdk 0.2.66 → 0.2.67
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 +109 -22
- package/dist/index.d.cts +72 -0
- package/dist/index.d.mts +72 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.mjs +109 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -228,6 +228,14 @@ const bridgeTools = {
|
|
|
228
228
|
hexToDecimalArray(hex) {
|
|
229
229
|
return hex.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || [];
|
|
230
230
|
},
|
|
231
|
+
/** Combine little-endian bytes (low byte first) into a single integer. */
|
|
232
|
+
bytesToInt(bytes) {
|
|
233
|
+
return bytes.reduce((acc, byte, index) => acc + ((byte || 0) << 8 * index), 0);
|
|
234
|
+
},
|
|
235
|
+
/** Split an integer into `byteCount` little-endian bytes (low byte first). */
|
|
236
|
+
intToBytes(value, byteCount) {
|
|
237
|
+
return Array.from({ length: byteCount }, (_unused, index) => value >> 8 * index & 255);
|
|
238
|
+
},
|
|
231
239
|
getFwVersion(payload) {
|
|
232
240
|
if (payload?.length !== 3) {
|
|
233
241
|
console.warn("Could not process FwVersion ", payload);
|
|
@@ -246,9 +254,7 @@ const bridgeTools = {
|
|
|
246
254
|
},
|
|
247
255
|
convertBarToKpaByte(deviceId, value) {
|
|
248
256
|
if (!value) return 0;
|
|
249
|
-
const
|
|
250
|
-
if (!deviceData) throw new Error(`Cannot convert bar to kpa byte, no device data found: ${deviceId}`);
|
|
251
|
-
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
257
|
+
const bitValue = this.usesKpaPressure(deviceId) ? 1 : 5.0625;
|
|
252
258
|
return ___default.round((value + 1) * 100 / bitValue);
|
|
253
259
|
},
|
|
254
260
|
convertSensorIdForBridge(sensorId) {
|
|
@@ -271,9 +277,7 @@ const bridgeTools = {
|
|
|
271
277
|
if (!___default.isNumber(value)) {
|
|
272
278
|
throw new TypeError("Value has to be a number");
|
|
273
279
|
}
|
|
274
|
-
const
|
|
275
|
-
if (!deviceData) throw new Error(`Cannot convert kpa byte to bar, no device data found: ${deviceId}`);
|
|
276
|
-
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
280
|
+
const bitValue = this.usesKpaPressure(deviceId) ? 1 : 5.0625;
|
|
277
281
|
const rawBar = value * bitValue / 100;
|
|
278
282
|
return ___default.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
279
283
|
},
|
|
@@ -287,6 +291,9 @@ const bridgeTools = {
|
|
|
287
291
|
}
|
|
288
292
|
return false;
|
|
289
293
|
},
|
|
294
|
+
usesKpaPressure(deviceId) {
|
|
295
|
+
return this.isVersionGreaterThan(deviceId, "1.1.F");
|
|
296
|
+
},
|
|
290
297
|
convertSensorIdFromBridge(sensorId) {
|
|
291
298
|
if (sensorId.startsWith("B")) {
|
|
292
299
|
return Number.parseInt(sensorId, 16).toString();
|
|
@@ -1266,6 +1273,78 @@ const bridgeCommandStructures = {
|
|
|
1266
1273
|
}
|
|
1267
1274
|
}
|
|
1268
1275
|
},
|
|
1276
|
+
/**
|
|
1277
|
+
* kPa per-axle pressure layout used from FW 1.2.0 onwards (same sub-command 0x30 as `pressuresPerAxle`).
|
|
1278
|
+
* Each axle packs the same three values (set; min; max) but every value is a 2-byte little-endian raw kPa
|
|
1279
|
+
* uint16 (no 5.0625 bit scaling), so each axle is 6 bytes instead of 3. Selected at runtime via
|
|
1280
|
+
* `bridgeTools.usesKpaPressure(deviceId)`.
|
|
1281
|
+
*/
|
|
1282
|
+
pressuresPerAxleKpa: {
|
|
1283
|
+
id: [98, 48],
|
|
1284
|
+
name: "pressuresPerAxleKpa",
|
|
1285
|
+
structure: {
|
|
1286
|
+
axle01: {
|
|
1287
|
+
size: 6,
|
|
1288
|
+
description: "Axle 01 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1289
|
+
},
|
|
1290
|
+
axle02: {
|
|
1291
|
+
size: 6,
|
|
1292
|
+
description: "Axle 02 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1293
|
+
},
|
|
1294
|
+
axle03: {
|
|
1295
|
+
size: 6,
|
|
1296
|
+
description: "Axle 03 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1297
|
+
},
|
|
1298
|
+
axle04: {
|
|
1299
|
+
size: 6,
|
|
1300
|
+
description: "Axle 04 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1301
|
+
},
|
|
1302
|
+
axle05: {
|
|
1303
|
+
size: 6,
|
|
1304
|
+
description: "Axle 05 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1305
|
+
},
|
|
1306
|
+
axle06: {
|
|
1307
|
+
size: 6,
|
|
1308
|
+
description: "Axle 06 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1309
|
+
},
|
|
1310
|
+
axle07: {
|
|
1311
|
+
size: 6,
|
|
1312
|
+
description: "Axle 07 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1313
|
+
},
|
|
1314
|
+
axle08: {
|
|
1315
|
+
size: 6,
|
|
1316
|
+
description: "Axle 08 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1317
|
+
},
|
|
1318
|
+
axle09: {
|
|
1319
|
+
size: 6,
|
|
1320
|
+
description: "Axle 09 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1321
|
+
},
|
|
1322
|
+
axle10: {
|
|
1323
|
+
size: 6,
|
|
1324
|
+
description: "Axle 10 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1325
|
+
},
|
|
1326
|
+
axle11: {
|
|
1327
|
+
size: 6,
|
|
1328
|
+
description: "Axle 11 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1329
|
+
},
|
|
1330
|
+
axle12: {
|
|
1331
|
+
size: 6,
|
|
1332
|
+
description: "Axle 12 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1333
|
+
},
|
|
1334
|
+
axle13: {
|
|
1335
|
+
size: 6,
|
|
1336
|
+
description: "Axle 13 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1337
|
+
},
|
|
1338
|
+
axle14: {
|
|
1339
|
+
size: 6,
|
|
1340
|
+
description: "Axle 14 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1341
|
+
},
|
|
1342
|
+
axle15: {
|
|
1343
|
+
size: 6,
|
|
1344
|
+
description: "Axle 15 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
},
|
|
1269
1348
|
autolearnSettings: {
|
|
1270
1349
|
id: [98, 160],
|
|
1271
1350
|
name: "autolearnSettings",
|
|
@@ -2099,8 +2178,9 @@ const bridgeCommands = {
|
|
|
2099
2178
|
async getPressuresPerAxle(deviceId) {
|
|
2100
2179
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2101
2180
|
const result = await this.readCommand(deviceData, subCommandIds.pressurePerAxle);
|
|
2181
|
+
const structure = bridgeTools.usesKpaPressure(deviceId) ? bridgeCommandStructures.pressuresPerAxleKpa.structure : bridgeCommandStructures.pressuresPerAxle.structure;
|
|
2102
2182
|
const structurizedData = bridgeTools.convertBytesToStructure(
|
|
2103
|
-
|
|
2183
|
+
structure,
|
|
2104
2184
|
result.data,
|
|
2105
2185
|
deviceData.advertisingData.fwVersion
|
|
2106
2186
|
);
|
|
@@ -2108,8 +2188,9 @@ const bridgeCommands = {
|
|
|
2108
2188
|
},
|
|
2109
2189
|
async setPressuresPerAxle(deviceId, structurizedPayload) {
|
|
2110
2190
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2191
|
+
const structure = bridgeTools.usesKpaPressure(deviceId) ? bridgeCommandStructures.pressuresPerAxleKpa.structure : bridgeCommandStructures.pressuresPerAxle.structure;
|
|
2111
2192
|
const payload = bridgeTools.convertStructureToBytes(
|
|
2112
|
-
|
|
2193
|
+
structure,
|
|
2113
2194
|
structurizedPayload,
|
|
2114
2195
|
deviceData.advertisingData.fwVersion
|
|
2115
2196
|
);
|
|
@@ -2524,6 +2605,8 @@ async function setAxleInfo(deviceId, tcVehicle) {
|
|
|
2524
2605
|
async function setAxlesPressure(deviceId, axles) {
|
|
2525
2606
|
let data = [];
|
|
2526
2607
|
let bridgeAxlesPressureData;
|
|
2608
|
+
const width = bridgeTools.usesKpaPressure(deviceId) ? 2 : 1;
|
|
2609
|
+
const maxFallback = width === 2 ? 65535 : 255;
|
|
2527
2610
|
for (let index = 0; index < 15; index++) {
|
|
2528
2611
|
let { targetPressure, maxTargetPressure, minTargetPressure, isSpare } = axles[index] || {};
|
|
2529
2612
|
maxTargetPressure = bridgeTools.convertBarToKpaByte(deviceId, maxTargetPressure);
|
|
@@ -2537,14 +2620,19 @@ async function setAxlesPressure(deviceId, axles) {
|
|
|
2537
2620
|
if (!bridgeAxlesPressureData) {
|
|
2538
2621
|
bridgeAxlesPressureData = await bridgeCommands.getAxlesPressure(deviceId);
|
|
2539
2622
|
}
|
|
2540
|
-
|
|
2623
|
+
const base = index * width * 3;
|
|
2624
|
+
maxTargetPressure = bridgeTools.bytesToInt(bridgeAxlesPressureData.data.slice(base, base + width)) || maxFallback;
|
|
2541
2625
|
}
|
|
2542
2626
|
if (targetPressure > maxTargetPressure) {
|
|
2543
2627
|
targetPressure = maxTargetPressure;
|
|
2544
2628
|
} else if (targetPressure < minTargetPressure) {
|
|
2545
2629
|
targetPressure = minTargetPressure;
|
|
2546
2630
|
}
|
|
2547
|
-
data = data.concat([
|
|
2631
|
+
data = data.concat([
|
|
2632
|
+
...bridgeTools.intToBytes(maxTargetPressure, width),
|
|
2633
|
+
...bridgeTools.intToBytes(minTargetPressure, width),
|
|
2634
|
+
...bridgeTools.intToBytes(targetPressure, width)
|
|
2635
|
+
]);
|
|
2548
2636
|
}
|
|
2549
2637
|
await bridgeCommands.setAxlesPressure(deviceId, data);
|
|
2550
2638
|
}
|
|
@@ -2891,21 +2979,20 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2891
2979
|
}
|
|
2892
2980
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2893
2981
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2982
|
+
const width = bridgeTools.usesKpaPressure(deviceId) ? 2 : 1;
|
|
2983
|
+
const base = axleIndex * width * 3;
|
|
2984
|
+
const maxRaw = bridgeTools.bytesToInt(axlesPressureData.slice(base, base + width));
|
|
2985
|
+
const minRaw = bridgeTools.bytesToInt(axlesPressureData.slice(base + width, base + width * 2));
|
|
2986
|
+
const setRaw = bridgeTools.bytesToInt(axlesPressureData.slice(base + width * 2, base + width * 3));
|
|
2987
|
+
if (maxRaw) {
|
|
2988
|
+
tcVehicleAxle.maxTargetPressure = ___default.floor(bridgeTools.convertKpaByteToBar(deviceId, maxRaw), 1);
|
|
2899
2989
|
}
|
|
2900
|
-
if (
|
|
2901
|
-
tcVehicleAxle.minTargetPressure = ___default.ceil(
|
|
2902
|
-
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3 + 1]),
|
|
2903
|
-
1
|
|
2904
|
-
);
|
|
2990
|
+
if (minRaw) {
|
|
2991
|
+
tcVehicleAxle.minTargetPressure = ___default.ceil(bridgeTools.convertKpaByteToBar(deviceId, minRaw), 1);
|
|
2905
2992
|
}
|
|
2906
|
-
if (
|
|
2993
|
+
if (setRaw) {
|
|
2907
2994
|
tcVehicleAxle.targetPressure = ___default.round(
|
|
2908
|
-
bridgeTools.convertKpaByteToBar(deviceId,
|
|
2995
|
+
bridgeTools.convertKpaByteToBar(deviceId, setRaw, void 0),
|
|
2909
2996
|
1
|
|
2910
2997
|
);
|
|
2911
2998
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -419,6 +419,78 @@ declare const _default: {
|
|
|
419
419
|
};
|
|
420
420
|
};
|
|
421
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* kPa per-axle pressure layout used from FW 1.2.0 onwards (same sub-command 0x30 as `pressuresPerAxle`).
|
|
424
|
+
* Each axle packs the same three values (set; min; max) but every value is a 2-byte little-endian raw kPa
|
|
425
|
+
* uint16 (no 5.0625 bit scaling), so each axle is 6 bytes instead of 3. Selected at runtime via
|
|
426
|
+
* `bridgeTools.usesKpaPressure(deviceId)`.
|
|
427
|
+
*/
|
|
428
|
+
pressuresPerAxleKpa: {
|
|
429
|
+
id: number[];
|
|
430
|
+
name: string;
|
|
431
|
+
structure: {
|
|
432
|
+
axle01: {
|
|
433
|
+
size: number;
|
|
434
|
+
description: string;
|
|
435
|
+
};
|
|
436
|
+
axle02: {
|
|
437
|
+
size: number;
|
|
438
|
+
description: string;
|
|
439
|
+
};
|
|
440
|
+
axle03: {
|
|
441
|
+
size: number;
|
|
442
|
+
description: string;
|
|
443
|
+
};
|
|
444
|
+
axle04: {
|
|
445
|
+
size: number;
|
|
446
|
+
description: string;
|
|
447
|
+
};
|
|
448
|
+
axle05: {
|
|
449
|
+
size: number;
|
|
450
|
+
description: string;
|
|
451
|
+
};
|
|
452
|
+
axle06: {
|
|
453
|
+
size: number;
|
|
454
|
+
description: string;
|
|
455
|
+
};
|
|
456
|
+
axle07: {
|
|
457
|
+
size: number;
|
|
458
|
+
description: string;
|
|
459
|
+
};
|
|
460
|
+
axle08: {
|
|
461
|
+
size: number;
|
|
462
|
+
description: string;
|
|
463
|
+
};
|
|
464
|
+
axle09: {
|
|
465
|
+
size: number;
|
|
466
|
+
description: string;
|
|
467
|
+
};
|
|
468
|
+
axle10: {
|
|
469
|
+
size: number;
|
|
470
|
+
description: string;
|
|
471
|
+
};
|
|
472
|
+
axle11: {
|
|
473
|
+
size: number;
|
|
474
|
+
description: string;
|
|
475
|
+
};
|
|
476
|
+
axle12: {
|
|
477
|
+
size: number;
|
|
478
|
+
description: string;
|
|
479
|
+
};
|
|
480
|
+
axle13: {
|
|
481
|
+
size: number;
|
|
482
|
+
description: string;
|
|
483
|
+
};
|
|
484
|
+
axle14: {
|
|
485
|
+
size: number;
|
|
486
|
+
description: string;
|
|
487
|
+
};
|
|
488
|
+
axle15: {
|
|
489
|
+
size: number;
|
|
490
|
+
description: string;
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
};
|
|
422
494
|
autolearnSettings: {
|
|
423
495
|
id: number[];
|
|
424
496
|
name: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -419,6 +419,78 @@ declare const _default: {
|
|
|
419
419
|
};
|
|
420
420
|
};
|
|
421
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* kPa per-axle pressure layout used from FW 1.2.0 onwards (same sub-command 0x30 as `pressuresPerAxle`).
|
|
424
|
+
* Each axle packs the same three values (set; min; max) but every value is a 2-byte little-endian raw kPa
|
|
425
|
+
* uint16 (no 5.0625 bit scaling), so each axle is 6 bytes instead of 3. Selected at runtime via
|
|
426
|
+
* `bridgeTools.usesKpaPressure(deviceId)`.
|
|
427
|
+
*/
|
|
428
|
+
pressuresPerAxleKpa: {
|
|
429
|
+
id: number[];
|
|
430
|
+
name: string;
|
|
431
|
+
structure: {
|
|
432
|
+
axle01: {
|
|
433
|
+
size: number;
|
|
434
|
+
description: string;
|
|
435
|
+
};
|
|
436
|
+
axle02: {
|
|
437
|
+
size: number;
|
|
438
|
+
description: string;
|
|
439
|
+
};
|
|
440
|
+
axle03: {
|
|
441
|
+
size: number;
|
|
442
|
+
description: string;
|
|
443
|
+
};
|
|
444
|
+
axle04: {
|
|
445
|
+
size: number;
|
|
446
|
+
description: string;
|
|
447
|
+
};
|
|
448
|
+
axle05: {
|
|
449
|
+
size: number;
|
|
450
|
+
description: string;
|
|
451
|
+
};
|
|
452
|
+
axle06: {
|
|
453
|
+
size: number;
|
|
454
|
+
description: string;
|
|
455
|
+
};
|
|
456
|
+
axle07: {
|
|
457
|
+
size: number;
|
|
458
|
+
description: string;
|
|
459
|
+
};
|
|
460
|
+
axle08: {
|
|
461
|
+
size: number;
|
|
462
|
+
description: string;
|
|
463
|
+
};
|
|
464
|
+
axle09: {
|
|
465
|
+
size: number;
|
|
466
|
+
description: string;
|
|
467
|
+
};
|
|
468
|
+
axle10: {
|
|
469
|
+
size: number;
|
|
470
|
+
description: string;
|
|
471
|
+
};
|
|
472
|
+
axle11: {
|
|
473
|
+
size: number;
|
|
474
|
+
description: string;
|
|
475
|
+
};
|
|
476
|
+
axle12: {
|
|
477
|
+
size: number;
|
|
478
|
+
description: string;
|
|
479
|
+
};
|
|
480
|
+
axle13: {
|
|
481
|
+
size: number;
|
|
482
|
+
description: string;
|
|
483
|
+
};
|
|
484
|
+
axle14: {
|
|
485
|
+
size: number;
|
|
486
|
+
description: string;
|
|
487
|
+
};
|
|
488
|
+
axle15: {
|
|
489
|
+
size: number;
|
|
490
|
+
description: string;
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
};
|
|
422
494
|
autolearnSettings: {
|
|
423
495
|
id: number[];
|
|
424
496
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -419,6 +419,78 @@ declare const _default: {
|
|
|
419
419
|
};
|
|
420
420
|
};
|
|
421
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* kPa per-axle pressure layout used from FW 1.2.0 onwards (same sub-command 0x30 as `pressuresPerAxle`).
|
|
424
|
+
* Each axle packs the same three values (set; min; max) but every value is a 2-byte little-endian raw kPa
|
|
425
|
+
* uint16 (no 5.0625 bit scaling), so each axle is 6 bytes instead of 3. Selected at runtime via
|
|
426
|
+
* `bridgeTools.usesKpaPressure(deviceId)`.
|
|
427
|
+
*/
|
|
428
|
+
pressuresPerAxleKpa: {
|
|
429
|
+
id: number[];
|
|
430
|
+
name: string;
|
|
431
|
+
structure: {
|
|
432
|
+
axle01: {
|
|
433
|
+
size: number;
|
|
434
|
+
description: string;
|
|
435
|
+
};
|
|
436
|
+
axle02: {
|
|
437
|
+
size: number;
|
|
438
|
+
description: string;
|
|
439
|
+
};
|
|
440
|
+
axle03: {
|
|
441
|
+
size: number;
|
|
442
|
+
description: string;
|
|
443
|
+
};
|
|
444
|
+
axle04: {
|
|
445
|
+
size: number;
|
|
446
|
+
description: string;
|
|
447
|
+
};
|
|
448
|
+
axle05: {
|
|
449
|
+
size: number;
|
|
450
|
+
description: string;
|
|
451
|
+
};
|
|
452
|
+
axle06: {
|
|
453
|
+
size: number;
|
|
454
|
+
description: string;
|
|
455
|
+
};
|
|
456
|
+
axle07: {
|
|
457
|
+
size: number;
|
|
458
|
+
description: string;
|
|
459
|
+
};
|
|
460
|
+
axle08: {
|
|
461
|
+
size: number;
|
|
462
|
+
description: string;
|
|
463
|
+
};
|
|
464
|
+
axle09: {
|
|
465
|
+
size: number;
|
|
466
|
+
description: string;
|
|
467
|
+
};
|
|
468
|
+
axle10: {
|
|
469
|
+
size: number;
|
|
470
|
+
description: string;
|
|
471
|
+
};
|
|
472
|
+
axle11: {
|
|
473
|
+
size: number;
|
|
474
|
+
description: string;
|
|
475
|
+
};
|
|
476
|
+
axle12: {
|
|
477
|
+
size: number;
|
|
478
|
+
description: string;
|
|
479
|
+
};
|
|
480
|
+
axle13: {
|
|
481
|
+
size: number;
|
|
482
|
+
description: string;
|
|
483
|
+
};
|
|
484
|
+
axle14: {
|
|
485
|
+
size: number;
|
|
486
|
+
description: string;
|
|
487
|
+
};
|
|
488
|
+
axle15: {
|
|
489
|
+
size: number;
|
|
490
|
+
description: string;
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
};
|
|
422
494
|
autolearnSettings: {
|
|
423
495
|
id: number[];
|
|
424
496
|
name: string;
|
package/dist/index.mjs
CHANGED
|
@@ -221,6 +221,14 @@ const bridgeTools = {
|
|
|
221
221
|
hexToDecimalArray(hex) {
|
|
222
222
|
return hex.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || [];
|
|
223
223
|
},
|
|
224
|
+
/** Combine little-endian bytes (low byte first) into a single integer. */
|
|
225
|
+
bytesToInt(bytes) {
|
|
226
|
+
return bytes.reduce((acc, byte, index) => acc + ((byte || 0) << 8 * index), 0);
|
|
227
|
+
},
|
|
228
|
+
/** Split an integer into `byteCount` little-endian bytes (low byte first). */
|
|
229
|
+
intToBytes(value, byteCount) {
|
|
230
|
+
return Array.from({ length: byteCount }, (_unused, index) => value >> 8 * index & 255);
|
|
231
|
+
},
|
|
224
232
|
getFwVersion(payload) {
|
|
225
233
|
if (payload?.length !== 3) {
|
|
226
234
|
console.warn("Could not process FwVersion ", payload);
|
|
@@ -239,9 +247,7 @@ const bridgeTools = {
|
|
|
239
247
|
},
|
|
240
248
|
convertBarToKpaByte(deviceId, value) {
|
|
241
249
|
if (!value) return 0;
|
|
242
|
-
const
|
|
243
|
-
if (!deviceData) throw new Error(`Cannot convert bar to kpa byte, no device data found: ${deviceId}`);
|
|
244
|
-
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
250
|
+
const bitValue = this.usesKpaPressure(deviceId) ? 1 : 5.0625;
|
|
245
251
|
return _.round((value + 1) * 100 / bitValue);
|
|
246
252
|
},
|
|
247
253
|
convertSensorIdForBridge(sensorId) {
|
|
@@ -264,9 +270,7 @@ const bridgeTools = {
|
|
|
264
270
|
if (!_.isNumber(value)) {
|
|
265
271
|
throw new TypeError("Value has to be a number");
|
|
266
272
|
}
|
|
267
|
-
const
|
|
268
|
-
if (!deviceData) throw new Error(`Cannot convert kpa byte to bar, no device data found: ${deviceId}`);
|
|
269
|
-
const bitValue = deviceData.name.includes("030717") ? 6.7 : 5.0625;
|
|
273
|
+
const bitValue = this.usesKpaPressure(deviceId) ? 1 : 5.0625;
|
|
270
274
|
const rawBar = value * bitValue / 100;
|
|
271
275
|
return _.round(Math.max(rawBar - decrementValue, 0), 1);
|
|
272
276
|
},
|
|
@@ -280,6 +284,9 @@ const bridgeTools = {
|
|
|
280
284
|
}
|
|
281
285
|
return false;
|
|
282
286
|
},
|
|
287
|
+
usesKpaPressure(deviceId) {
|
|
288
|
+
return this.isVersionGreaterThan(deviceId, "1.1.F");
|
|
289
|
+
},
|
|
283
290
|
convertSensorIdFromBridge(sensorId) {
|
|
284
291
|
if (sensorId.startsWith("B")) {
|
|
285
292
|
return Number.parseInt(sensorId, 16).toString();
|
|
@@ -1259,6 +1266,78 @@ const bridgeCommandStructures = {
|
|
|
1259
1266
|
}
|
|
1260
1267
|
}
|
|
1261
1268
|
},
|
|
1269
|
+
/**
|
|
1270
|
+
* kPa per-axle pressure layout used from FW 1.2.0 onwards (same sub-command 0x30 as `pressuresPerAxle`).
|
|
1271
|
+
* Each axle packs the same three values (set; min; max) but every value is a 2-byte little-endian raw kPa
|
|
1272
|
+
* uint16 (no 5.0625 bit scaling), so each axle is 6 bytes instead of 3. Selected at runtime via
|
|
1273
|
+
* `bridgeTools.usesKpaPressure(deviceId)`.
|
|
1274
|
+
*/
|
|
1275
|
+
pressuresPerAxleKpa: {
|
|
1276
|
+
id: [98, 48],
|
|
1277
|
+
name: "pressuresPerAxleKpa",
|
|
1278
|
+
structure: {
|
|
1279
|
+
axle01: {
|
|
1280
|
+
size: 6,
|
|
1281
|
+
description: "Axle 01 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1282
|
+
},
|
|
1283
|
+
axle02: {
|
|
1284
|
+
size: 6,
|
|
1285
|
+
description: "Axle 02 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1286
|
+
},
|
|
1287
|
+
axle03: {
|
|
1288
|
+
size: 6,
|
|
1289
|
+
description: "Axle 03 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1290
|
+
},
|
|
1291
|
+
axle04: {
|
|
1292
|
+
size: 6,
|
|
1293
|
+
description: "Axle 04 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1294
|
+
},
|
|
1295
|
+
axle05: {
|
|
1296
|
+
size: 6,
|
|
1297
|
+
description: "Axle 05 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1298
|
+
},
|
|
1299
|
+
axle06: {
|
|
1300
|
+
size: 6,
|
|
1301
|
+
description: "Axle 06 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1302
|
+
},
|
|
1303
|
+
axle07: {
|
|
1304
|
+
size: 6,
|
|
1305
|
+
description: "Axle 07 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1306
|
+
},
|
|
1307
|
+
axle08: {
|
|
1308
|
+
size: 6,
|
|
1309
|
+
description: "Axle 08 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1310
|
+
},
|
|
1311
|
+
axle09: {
|
|
1312
|
+
size: 6,
|
|
1313
|
+
description: "Axle 09 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1314
|
+
},
|
|
1315
|
+
axle10: {
|
|
1316
|
+
size: 6,
|
|
1317
|
+
description: "Axle 10 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1318
|
+
},
|
|
1319
|
+
axle11: {
|
|
1320
|
+
size: 6,
|
|
1321
|
+
description: "Axle 11 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1322
|
+
},
|
|
1323
|
+
axle12: {
|
|
1324
|
+
size: 6,
|
|
1325
|
+
description: "Axle 12 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1326
|
+
},
|
|
1327
|
+
axle13: {
|
|
1328
|
+
size: 6,
|
|
1329
|
+
description: "Axle 13 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1330
|
+
},
|
|
1331
|
+
axle14: {
|
|
1332
|
+
size: 6,
|
|
1333
|
+
description: "Axle 14 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1334
|
+
},
|
|
1335
|
+
axle15: {
|
|
1336
|
+
size: 6,
|
|
1337
|
+
description: "Axle 15 set pressure; min pressure; max pressure (2-byte little-endian kPa values)"
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1262
1341
|
autolearnSettings: {
|
|
1263
1342
|
id: [98, 160],
|
|
1264
1343
|
name: "autolearnSettings",
|
|
@@ -2092,8 +2171,9 @@ const bridgeCommands = {
|
|
|
2092
2171
|
async getPressuresPerAxle(deviceId) {
|
|
2093
2172
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2094
2173
|
const result = await this.readCommand(deviceData, subCommandIds.pressurePerAxle);
|
|
2174
|
+
const structure = bridgeTools.usesKpaPressure(deviceId) ? bridgeCommandStructures.pressuresPerAxleKpa.structure : bridgeCommandStructures.pressuresPerAxle.structure;
|
|
2095
2175
|
const structurizedData = bridgeTools.convertBytesToStructure(
|
|
2096
|
-
|
|
2176
|
+
structure,
|
|
2097
2177
|
result.data,
|
|
2098
2178
|
deviceData.advertisingData.fwVersion
|
|
2099
2179
|
);
|
|
@@ -2101,8 +2181,9 @@ const bridgeCommands = {
|
|
|
2101
2181
|
},
|
|
2102
2182
|
async setPressuresPerAxle(deviceId, structurizedPayload) {
|
|
2103
2183
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2184
|
+
const structure = bridgeTools.usesKpaPressure(deviceId) ? bridgeCommandStructures.pressuresPerAxleKpa.structure : bridgeCommandStructures.pressuresPerAxle.structure;
|
|
2104
2185
|
const payload = bridgeTools.convertStructureToBytes(
|
|
2105
|
-
|
|
2186
|
+
structure,
|
|
2106
2187
|
structurizedPayload,
|
|
2107
2188
|
deviceData.advertisingData.fwVersion
|
|
2108
2189
|
);
|
|
@@ -2517,6 +2598,8 @@ async function setAxleInfo(deviceId, tcVehicle) {
|
|
|
2517
2598
|
async function setAxlesPressure(deviceId, axles) {
|
|
2518
2599
|
let data = [];
|
|
2519
2600
|
let bridgeAxlesPressureData;
|
|
2601
|
+
const width = bridgeTools.usesKpaPressure(deviceId) ? 2 : 1;
|
|
2602
|
+
const maxFallback = width === 2 ? 65535 : 255;
|
|
2520
2603
|
for (let index = 0; index < 15; index++) {
|
|
2521
2604
|
let { targetPressure, maxTargetPressure, minTargetPressure, isSpare } = axles[index] || {};
|
|
2522
2605
|
maxTargetPressure = bridgeTools.convertBarToKpaByte(deviceId, maxTargetPressure);
|
|
@@ -2530,14 +2613,19 @@ async function setAxlesPressure(deviceId, axles) {
|
|
|
2530
2613
|
if (!bridgeAxlesPressureData) {
|
|
2531
2614
|
bridgeAxlesPressureData = await bridgeCommands.getAxlesPressure(deviceId);
|
|
2532
2615
|
}
|
|
2533
|
-
|
|
2616
|
+
const base = index * width * 3;
|
|
2617
|
+
maxTargetPressure = bridgeTools.bytesToInt(bridgeAxlesPressureData.data.slice(base, base + width)) || maxFallback;
|
|
2534
2618
|
}
|
|
2535
2619
|
if (targetPressure > maxTargetPressure) {
|
|
2536
2620
|
targetPressure = maxTargetPressure;
|
|
2537
2621
|
} else if (targetPressure < minTargetPressure) {
|
|
2538
2622
|
targetPressure = minTargetPressure;
|
|
2539
2623
|
}
|
|
2540
|
-
data = data.concat([
|
|
2624
|
+
data = data.concat([
|
|
2625
|
+
...bridgeTools.intToBytes(maxTargetPressure, width),
|
|
2626
|
+
...bridgeTools.intToBytes(minTargetPressure, width),
|
|
2627
|
+
...bridgeTools.intToBytes(targetPressure, width)
|
|
2628
|
+
]);
|
|
2541
2629
|
}
|
|
2542
2630
|
await bridgeCommands.setAxlesPressure(deviceId, data);
|
|
2543
2631
|
}
|
|
@@ -2884,21 +2972,20 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2884
2972
|
}
|
|
2885
2973
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2886
2974
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2975
|
+
const width = bridgeTools.usesKpaPressure(deviceId) ? 2 : 1;
|
|
2976
|
+
const base = axleIndex * width * 3;
|
|
2977
|
+
const maxRaw = bridgeTools.bytesToInt(axlesPressureData.slice(base, base + width));
|
|
2978
|
+
const minRaw = bridgeTools.bytesToInt(axlesPressureData.slice(base + width, base + width * 2));
|
|
2979
|
+
const setRaw = bridgeTools.bytesToInt(axlesPressureData.slice(base + width * 2, base + width * 3));
|
|
2980
|
+
if (maxRaw) {
|
|
2981
|
+
tcVehicleAxle.maxTargetPressure = _.floor(bridgeTools.convertKpaByteToBar(deviceId, maxRaw), 1);
|
|
2892
2982
|
}
|
|
2893
|
-
if (
|
|
2894
|
-
tcVehicleAxle.minTargetPressure = _.ceil(
|
|
2895
|
-
bridgeTools.convertKpaByteToBar(deviceId, axlesPressureData[axleIndex * 3 + 1]),
|
|
2896
|
-
1
|
|
2897
|
-
);
|
|
2983
|
+
if (minRaw) {
|
|
2984
|
+
tcVehicleAxle.minTargetPressure = _.ceil(bridgeTools.convertKpaByteToBar(deviceId, minRaw), 1);
|
|
2898
2985
|
}
|
|
2899
|
-
if (
|
|
2986
|
+
if (setRaw) {
|
|
2900
2987
|
tcVehicleAxle.targetPressure = _.round(
|
|
2901
|
-
bridgeTools.convertKpaByteToBar(deviceId,
|
|
2988
|
+
bridgeTools.convertKpaByteToBar(deviceId, setRaw, void 0),
|
|
2902
2989
|
1
|
|
2903
2990
|
);
|
|
2904
2991
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.67",
|
|
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",
|