tirecheck-device-sdk 0.1.993 → 0.1.994
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 +18 -110
- package/dist/index.d.cts +10 -2
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +18 -110
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ function setBleImplementation(bleImplementation) {
|
|
|
37
37
|
|
|
38
38
|
const store = {
|
|
39
39
|
platform: "android",
|
|
40
|
+
securityKeys: {},
|
|
40
41
|
/** Defines access level for each connection, should be 'driver' as default, Supported roles: ['manufacturer', 'driver'] , Example: F4B4553322: 'manufacturer' */
|
|
41
42
|
deviceAccessLevel: {},
|
|
42
43
|
devices: {},
|
|
@@ -619,7 +620,7 @@ async function connect$1(deviceId, disconnectCallback) {
|
|
|
619
620
|
if (toolsSvc.canCommunicateWith(deviceId)) return console.warn("Connect Warn: Already connected to device");
|
|
620
621
|
store.setState(deviceId, "connecting");
|
|
621
622
|
let connectedDevice;
|
|
622
|
-
for (let attempt = 1; attempt <=
|
|
623
|
+
for (let attempt = 1; attempt <= 5; attempt++) {
|
|
623
624
|
try {
|
|
624
625
|
connectedDevice = await withTimeout(connectInner(deviceId, disconnectCallback), 2e4);
|
|
625
626
|
const _deviceId = store.deviceIdMapingTable[deviceId] ?? deviceId;
|
|
@@ -631,7 +632,7 @@ async function connect$1(deviceId, disconnectCallback) {
|
|
|
631
632
|
}
|
|
632
633
|
} catch (e) {
|
|
633
634
|
console.warn(`${attempt} connect fail`, e);
|
|
634
|
-
if (attempt ===
|
|
635
|
+
if (attempt === 5) {
|
|
635
636
|
store.setState(deviceId, void 0, "failedConnection");
|
|
636
637
|
throw new Error("Connection unsuccessful");
|
|
637
638
|
}
|
|
@@ -1405,105 +1406,6 @@ const bridgeCommandStructures = {
|
|
|
1405
1406
|
}
|
|
1406
1407
|
};
|
|
1407
1408
|
|
|
1408
|
-
const signature_keys = {
|
|
1409
|
-
0: [
|
|
1410
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
1411
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31],
|
|
1412
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 47],
|
|
1413
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 63],
|
|
1414
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 79],
|
|
1415
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 95],
|
|
1416
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 111],
|
|
1417
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 127],
|
|
1418
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 143],
|
|
1419
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 159],
|
|
1420
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 175],
|
|
1421
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 191],
|
|
1422
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 207],
|
|
1423
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 223],
|
|
1424
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 239],
|
|
1425
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255]
|
|
1426
|
-
],
|
|
1427
|
-
1: [
|
|
1428
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
1429
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31],
|
|
1430
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 47],
|
|
1431
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 63],
|
|
1432
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 79],
|
|
1433
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 95],
|
|
1434
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 111],
|
|
1435
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 127],
|
|
1436
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 143],
|
|
1437
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 159],
|
|
1438
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 175],
|
|
1439
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 191],
|
|
1440
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 207],
|
|
1441
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 223],
|
|
1442
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 239],
|
|
1443
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255]
|
|
1444
|
-
],
|
|
1445
|
-
2: [
|
|
1446
|
-
[121, 114, 34, 71, 3, 133, 92, 108, 162, 173, 161, 168, 164, 148, 34, 139],
|
|
1447
|
-
[136, 120, 146, 44, 228, 28, 205, 63, 205, 120, 170, 120, 251, 245, 227, 154],
|
|
1448
|
-
[37, 22, 60, 132, 154, 66, 59, 185, 36, 142, 163, 103, 39, 121, 227, 209],
|
|
1449
|
-
[15, 30, 54, 173, 21, 127, 65, 158, 168, 84, 192, 17, 51, 3, 90, 173],
|
|
1450
|
-
[136, 165, 72, 127, 72, 38, 200, 5, 4, 187, 203, 29, 6, 82, 130, 39],
|
|
1451
|
-
[106, 95, 111, 82, 191, 213, 104, 194, 106, 30, 199, 250, 69, 223, 79, 250],
|
|
1452
|
-
[150, 63, 177, 61, 50, 182, 227, 53, 157, 168, 245, 96, 90, 212, 17, 132],
|
|
1453
|
-
[233, 159, 182, 205, 3, 216, 203, 73, 193, 142, 183, 16, 22, 208, 38, 143],
|
|
1454
|
-
[7, 45, 239, 102, 47, 8, 237, 115, 77, 232, 2, 167, 47, 65, 164, 251],
|
|
1455
|
-
[7, 159, 18, 71, 3, 132, 84, 47, 60, 167, 134, 251, 114, 207, 254, 190],
|
|
1456
|
-
[203, 129, 34, 153, 32, 169, 153, 45, 215, 172, 76, 214, 5, 21, 210, 65],
|
|
1457
|
-
[29, 194, 255, 4, 195, 144, 178, 174, 255, 66, 15, 19, 26, 212, 61, 251],
|
|
1458
|
-
[42, 13, 136, 252, 143, 234, 120, 242, 164, 36, 21, 135, 252, 145, 101, 124],
|
|
1459
|
-
[24, 24, 207, 236, 159, 24, 180, 141, 80, 119, 86, 239, 192, 32, 51, 34],
|
|
1460
|
-
[187, 89, 217, 2, 16, 125, 121, 46, 159, 66, 85, 169, 9, 155, 2, 178],
|
|
1461
|
-
[212, 230, 71, 216, 35, 20, 241, 0, 204, 163, 80, 198, 132, 210, 166, 173]
|
|
1462
|
-
],
|
|
1463
|
-
16: [
|
|
1464
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
1465
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31],
|
|
1466
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 47],
|
|
1467
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 63],
|
|
1468
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 79],
|
|
1469
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 95],
|
|
1470
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 111],
|
|
1471
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 127],
|
|
1472
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 143],
|
|
1473
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 159],
|
|
1474
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 175],
|
|
1475
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 191],
|
|
1476
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 207],
|
|
1477
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 223],
|
|
1478
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 239],
|
|
1479
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255]
|
|
1480
|
-
],
|
|
1481
|
-
17: [
|
|
1482
|
-
[75, 40, 61, 20, 254, 102, 105, 160, 44, 236, 79, 39, 84, 27, 235, 100],
|
|
1483
|
-
[185, 139, 202, 38, 158, 109, 211, 6, 38, 73, 28, 120, 208, 168, 159, 108],
|
|
1484
|
-
[252, 100, 192, 127, 135, 127, 228, 125, 190, 210, 248, 146, 45, 229, 218, 159],
|
|
1485
|
-
[217, 39, 58, 200, 22, 212, 105, 55, 15, 45, 82, 96, 216, 134, 69, 123],
|
|
1486
|
-
[192, 34, 199, 199, 200, 112, 61, 98, 174, 62, 7, 200, 149, 168, 175, 110],
|
|
1487
|
-
[60, 41, 125, 116, 134, 191, 241, 188, 171, 127, 209, 10, 114, 52, 120, 164],
|
|
1488
|
-
[255, 19, 220, 184, 141, 224, 242, 117, 230, 143, 20, 75, 44, 50, 70, 113],
|
|
1489
|
-
[55, 112, 171, 176, 239, 50, 111, 3, 175, 145, 123, 38, 12, 44, 18, 79],
|
|
1490
|
-
[211, 119, 219, 6, 27, 41, 170, 199, 206, 66, 89, 89, 154, 128, 110, 70],
|
|
1491
|
-
[187, 184, 42, 154, 108, 182, 238, 223, 192, 10, 144, 139, 130, 22, 220, 66],
|
|
1492
|
-
[91, 248, 195, 246, 212, 104, 246, 252, 231, 120, 153, 211, 39, 250, 221, 133],
|
|
1493
|
-
[184, 148, 72, 207, 106, 143, 21, 239, 133, 206, 1, 234, 1, 75, 92, 43],
|
|
1494
|
-
[46, 35, 117, 127, 103, 37, 155, 16, 177, 106, 195, 129, 168, 235, 159, 162],
|
|
1495
|
-
[0, 7, 114, 77, 77, 66, 224, 223, 92, 193, 241, 44, 242, 104, 67, 163],
|
|
1496
|
-
[116, 194, 13, 179, 75, 181, 245, 211, 19, 38, 45, 21, 36, 163, 252, 235],
|
|
1497
|
-
[6, 211, 31, 66, 81, 221, 137, 33, 23, 18, 160, 147, 159, 34, 121, 125]
|
|
1498
|
-
]
|
|
1499
|
-
};
|
|
1500
|
-
const pinKeys = {
|
|
1501
|
-
0: "00000000000000010000000000000002",
|
|
1502
|
-
1: "00000000000000010000000000000002",
|
|
1503
|
-
2: "B2D24304FC345F1418EB96835B3B7AE8",
|
|
1504
|
-
16: "00000000000000010000000000000002",
|
|
1505
|
-
17: "CB5A6AA23FD565A141C5CE5ABF209000"
|
|
1506
|
-
};
|
|
1507
1409
|
const bridgeSecurity = {
|
|
1508
1410
|
getSignedCommand(device, command) {
|
|
1509
1411
|
const { randomAdvNumber, configVersion } = device?.advertisingData || {};
|
|
@@ -1520,7 +1422,8 @@ const bridgeSecurity = {
|
|
|
1520
1422
|
const r = command.length % 16;
|
|
1521
1423
|
paddedCommand = bridgeTools.pkcs(command, r ? ++t * 16 : t * 16);
|
|
1522
1424
|
}
|
|
1523
|
-
|
|
1425
|
+
if (!store.securityKeys?.signatureKeys?.[configVersion]) throw new Error("No signature key found");
|
|
1426
|
+
const key = store.securityKeys.signatureKeys[configVersion][keyIndex];
|
|
1524
1427
|
const startArray = key.slice(keyShift);
|
|
1525
1428
|
const endArray = key.slice(0, keyShift);
|
|
1526
1429
|
const shiftedKey = startArray.concat(endArray).map((n) => bridgeTools.decimalToHex(n)).join("");
|
|
@@ -1557,13 +1460,14 @@ const bridgeSecurity = {
|
|
|
1557
1460
|
},
|
|
1558
1461
|
async getPin(deviceId) {
|
|
1559
1462
|
const deviceData = store.devices[deviceId];
|
|
1560
|
-
if (deviceData?.type !== "bridge") throw new Error("Device data missing");
|
|
1463
|
+
if (deviceData?.type !== "bridge") throw new Error("Device data missing 1 ");
|
|
1561
1464
|
const { randomAdvNumber, macAddress, configVersion } = deviceData.advertisingData || {};
|
|
1562
1465
|
if (!randomAdvNumber || !macAddress || !___default.isNumber(configVersion)) throw new Error("Cannot compute pin");
|
|
1563
1466
|
const mac = macAddress.map((n) => bridgeTools.decimalToHex(n)).join("");
|
|
1564
1467
|
const rand = randomAdvNumber.map((n) => bridgeTools.decimalToHex(n)).join("");
|
|
1565
1468
|
const message = `${mac}0000${rand}`;
|
|
1566
|
-
|
|
1469
|
+
if (!store.securityKeys?.pinKeys?.[configVersion]) throw new Error("No pin key found");
|
|
1470
|
+
const key = store.securityKeys.pinKeys[configVersion];
|
|
1567
1471
|
const res = await this.aesToCrc32(message, key);
|
|
1568
1472
|
return res;
|
|
1569
1473
|
},
|
|
@@ -2132,7 +2036,7 @@ async function updateFirmware(deviceId, bootloader, firmware, reportStatus) {
|
|
|
2132
2036
|
}
|
|
2133
2037
|
async function setVehicleLayout(deviceId, tcVehicle) {
|
|
2134
2038
|
const spareTyres = tcVehicle.tcTyres?.filter((tyre) => String(tyre.mountedOn?.positionId).endsWith("0"));
|
|
2135
|
-
let spareTyresCount = Math.min(spareTyres
|
|
2039
|
+
let spareTyresCount = Math.min(spareTyres?.length || 0, 2);
|
|
2136
2040
|
const result = {
|
|
2137
2041
|
axle01: "0000",
|
|
2138
2042
|
axle02: "0000",
|
|
@@ -2492,7 +2396,7 @@ async function getAutolearnStatuses(deviceId, tcVehicle) {
|
|
|
2492
2396
|
return autolearnedStatuses;
|
|
2493
2397
|
}
|
|
2494
2398
|
function getAutolearnStatusName(statusId) {
|
|
2495
|
-
if (["2", "A"].includes(statusId)) {
|
|
2399
|
+
if (["2", "A"].includes(statusId.toUpperCase())) {
|
|
2496
2400
|
return "error";
|
|
2497
2401
|
}
|
|
2498
2402
|
if (statusId === "4") {
|
|
@@ -2504,7 +2408,7 @@ function getAutolearnStatusName(statusId) {
|
|
|
2504
2408
|
if (statusId === "0") {
|
|
2505
2409
|
return "default";
|
|
2506
2410
|
}
|
|
2507
|
-
throw new Error(
|
|
2411
|
+
throw new Error(`Unknown autolearn status: ${statusId}`);
|
|
2508
2412
|
}
|
|
2509
2413
|
async function resetAutolearnStatuses(deviceId, positionIds) {
|
|
2510
2414
|
if (!bridgeTools.isVersionGreaterThan(deviceId, "0.9.7"))
|
|
@@ -3323,10 +3227,13 @@ function ensureSimulatorMethodsAreInjected() {
|
|
|
3323
3227
|
advertisingInterval = void 0;
|
|
3324
3228
|
}
|
|
3325
3229
|
let previousDevices = store.simulatedDevices;
|
|
3326
|
-
advertisingInterval = toolsSvc.setIntervalImmediate(() => {
|
|
3230
|
+
advertisingInterval = toolsSvc.setIntervalImmediate(async () => {
|
|
3327
3231
|
for (const key in store.simulatedDevices) {
|
|
3328
3232
|
const d = store.simulatedDevices[key];
|
|
3329
|
-
if (d.isDisabled)
|
|
3233
|
+
if (d.isDisabled) {
|
|
3234
|
+
if (store.deviceState[key] === "paired") await bridgeSimulator.disconnect(key);
|
|
3235
|
+
continue;
|
|
3236
|
+
}
|
|
3330
3237
|
unreachableSvc.refresh(d.id, deviceUnreachableCallback);
|
|
3331
3238
|
deviceAdvertisingCallback?.(store.simulatedDevices[key]);
|
|
3332
3239
|
}
|
|
@@ -3372,7 +3279,8 @@ class BridgeTcVehicleAxle {
|
|
|
3372
3279
|
minTargetPressure;
|
|
3373
3280
|
}
|
|
3374
3281
|
|
|
3375
|
-
function createTirecheckDeviceSdk(platform, bleImplementation) {
|
|
3282
|
+
function createTirecheckDeviceSdk(platform, securityKeys, bleImplementation) {
|
|
3283
|
+
store.securityKeys = securityKeys;
|
|
3376
3284
|
store.platform = platform;
|
|
3377
3285
|
bleImplementation = bleImplementation || emptyBleImplementation;
|
|
3378
3286
|
setBleImplementation(bleImplementation);
|
package/dist/index.d.cts
CHANGED
|
@@ -813,6 +813,14 @@ interface BleBridgeAdvertisingData {
|
|
|
813
813
|
configVersion: number;
|
|
814
814
|
timeFromStart?: number;
|
|
815
815
|
}
|
|
816
|
+
interface BleSecurityKeys {
|
|
817
|
+
signatureKeys: {
|
|
818
|
+
[index: number]: number[][];
|
|
819
|
+
};
|
|
820
|
+
pinKeys: {
|
|
821
|
+
[index: number]: string;
|
|
822
|
+
};
|
|
823
|
+
}
|
|
816
824
|
type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
817
825
|
[K in keyof T]: (...args: [next: (...paramsOverride: any[]) => ReturnType<T[K]>, ...Parameters<T[K]>]) => ReturnType<T[K]>;
|
|
818
826
|
};
|
|
@@ -830,7 +838,7 @@ type EventName = keyof EventHandlers;
|
|
|
830
838
|
/** Creates instance of SDK.
|
|
831
839
|
* For real usage, `bleImplementation` argument must be provided - it's an object that follows method definitions from `cordova-plugin-bluetooth-central`.
|
|
832
840
|
* If `bleImplementation` is not provided, SDK will work only with the simulator. */
|
|
833
|
-
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation): {
|
|
841
|
+
declare function createTirecheckDeviceSdk(platform: DevicePlatform, securityKeys: BleSecurityKeys, bleImplementation?: BleImplementation): {
|
|
834
842
|
/** Generic methods common for all devices */
|
|
835
843
|
bluetooth: {
|
|
836
844
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
@@ -890,4 +898,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
890
898
|
};
|
|
891
899
|
};
|
|
892
900
|
|
|
893
|
-
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
|
|
901
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.d.mts
CHANGED
|
@@ -813,6 +813,14 @@ interface BleBridgeAdvertisingData {
|
|
|
813
813
|
configVersion: number;
|
|
814
814
|
timeFromStart?: number;
|
|
815
815
|
}
|
|
816
|
+
interface BleSecurityKeys {
|
|
817
|
+
signatureKeys: {
|
|
818
|
+
[index: number]: number[][];
|
|
819
|
+
};
|
|
820
|
+
pinKeys: {
|
|
821
|
+
[index: number]: string;
|
|
822
|
+
};
|
|
823
|
+
}
|
|
816
824
|
type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
817
825
|
[K in keyof T]: (...args: [next: (...paramsOverride: any[]) => ReturnType<T[K]>, ...Parameters<T[K]>]) => ReturnType<T[K]>;
|
|
818
826
|
};
|
|
@@ -830,7 +838,7 @@ type EventName = keyof EventHandlers;
|
|
|
830
838
|
/** Creates instance of SDK.
|
|
831
839
|
* For real usage, `bleImplementation` argument must be provided - it's an object that follows method definitions from `cordova-plugin-bluetooth-central`.
|
|
832
840
|
* If `bleImplementation` is not provided, SDK will work only with the simulator. */
|
|
833
|
-
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation): {
|
|
841
|
+
declare function createTirecheckDeviceSdk(platform: DevicePlatform, securityKeys: BleSecurityKeys, bleImplementation?: BleImplementation): {
|
|
834
842
|
/** Generic methods common for all devices */
|
|
835
843
|
bluetooth: {
|
|
836
844
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
@@ -890,4 +898,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
890
898
|
};
|
|
891
899
|
};
|
|
892
900
|
|
|
893
|
-
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
|
|
901
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.d.ts
CHANGED
|
@@ -813,6 +813,14 @@ interface BleBridgeAdvertisingData {
|
|
|
813
813
|
configVersion: number;
|
|
814
814
|
timeFromStart?: number;
|
|
815
815
|
}
|
|
816
|
+
interface BleSecurityKeys {
|
|
817
|
+
signatureKeys: {
|
|
818
|
+
[index: number]: number[][];
|
|
819
|
+
};
|
|
820
|
+
pinKeys: {
|
|
821
|
+
[index: number]: string;
|
|
822
|
+
};
|
|
823
|
+
}
|
|
816
824
|
type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
817
825
|
[K in keyof T]: (...args: [next: (...paramsOverride: any[]) => ReturnType<T[K]>, ...Parameters<T[K]>]) => ReturnType<T[K]>;
|
|
818
826
|
};
|
|
@@ -830,7 +838,7 @@ type EventName = keyof EventHandlers;
|
|
|
830
838
|
/** Creates instance of SDK.
|
|
831
839
|
* For real usage, `bleImplementation` argument must be provided - it's an object that follows method definitions from `cordova-plugin-bluetooth-central`.
|
|
832
840
|
* If `bleImplementation` is not provided, SDK will work only with the simulator. */
|
|
833
|
-
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation): {
|
|
841
|
+
declare function createTirecheckDeviceSdk(platform: DevicePlatform, securityKeys: BleSecurityKeys, bleImplementation?: BleImplementation): {
|
|
834
842
|
/** Generic methods common for all devices */
|
|
835
843
|
bluetooth: {
|
|
836
844
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
@@ -890,4 +898,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
890
898
|
};
|
|
891
899
|
};
|
|
892
900
|
|
|
893
|
-
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
|
|
901
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BridgeAccessLevel, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeCommandStructurized, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type DeepPartial, type DevicePlatform, type DeviceState, type EventHandlers, type EventName, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.mjs
CHANGED
|
@@ -30,6 +30,7 @@ function setBleImplementation(bleImplementation) {
|
|
|
30
30
|
|
|
31
31
|
const store = {
|
|
32
32
|
platform: "android",
|
|
33
|
+
securityKeys: {},
|
|
33
34
|
/** Defines access level for each connection, should be 'driver' as default, Supported roles: ['manufacturer', 'driver'] , Example: F4B4553322: 'manufacturer' */
|
|
34
35
|
deviceAccessLevel: {},
|
|
35
36
|
devices: {},
|
|
@@ -612,7 +613,7 @@ async function connect$1(deviceId, disconnectCallback) {
|
|
|
612
613
|
if (toolsSvc.canCommunicateWith(deviceId)) return console.warn("Connect Warn: Already connected to device");
|
|
613
614
|
store.setState(deviceId, "connecting");
|
|
614
615
|
let connectedDevice;
|
|
615
|
-
for (let attempt = 1; attempt <=
|
|
616
|
+
for (let attempt = 1; attempt <= 5; attempt++) {
|
|
616
617
|
try {
|
|
617
618
|
connectedDevice = await withTimeout(connectInner(deviceId, disconnectCallback), 2e4);
|
|
618
619
|
const _deviceId = store.deviceIdMapingTable[deviceId] ?? deviceId;
|
|
@@ -624,7 +625,7 @@ async function connect$1(deviceId, disconnectCallback) {
|
|
|
624
625
|
}
|
|
625
626
|
} catch (e) {
|
|
626
627
|
console.warn(`${attempt} connect fail`, e);
|
|
627
|
-
if (attempt ===
|
|
628
|
+
if (attempt === 5) {
|
|
628
629
|
store.setState(deviceId, void 0, "failedConnection");
|
|
629
630
|
throw new Error("Connection unsuccessful");
|
|
630
631
|
}
|
|
@@ -1398,105 +1399,6 @@ const bridgeCommandStructures = {
|
|
|
1398
1399
|
}
|
|
1399
1400
|
};
|
|
1400
1401
|
|
|
1401
|
-
const signature_keys = {
|
|
1402
|
-
0: [
|
|
1403
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
1404
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31],
|
|
1405
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 47],
|
|
1406
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 63],
|
|
1407
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 79],
|
|
1408
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 95],
|
|
1409
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 111],
|
|
1410
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 127],
|
|
1411
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 143],
|
|
1412
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 159],
|
|
1413
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 175],
|
|
1414
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 191],
|
|
1415
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 207],
|
|
1416
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 223],
|
|
1417
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 239],
|
|
1418
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255]
|
|
1419
|
-
],
|
|
1420
|
-
1: [
|
|
1421
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
1422
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31],
|
|
1423
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 47],
|
|
1424
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 63],
|
|
1425
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 79],
|
|
1426
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 95],
|
|
1427
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 111],
|
|
1428
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 127],
|
|
1429
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 143],
|
|
1430
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 159],
|
|
1431
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 175],
|
|
1432
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 191],
|
|
1433
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 207],
|
|
1434
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 223],
|
|
1435
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 239],
|
|
1436
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255]
|
|
1437
|
-
],
|
|
1438
|
-
2: [
|
|
1439
|
-
[121, 114, 34, 71, 3, 133, 92, 108, 162, 173, 161, 168, 164, 148, 34, 139],
|
|
1440
|
-
[136, 120, 146, 44, 228, 28, 205, 63, 205, 120, 170, 120, 251, 245, 227, 154],
|
|
1441
|
-
[37, 22, 60, 132, 154, 66, 59, 185, 36, 142, 163, 103, 39, 121, 227, 209],
|
|
1442
|
-
[15, 30, 54, 173, 21, 127, 65, 158, 168, 84, 192, 17, 51, 3, 90, 173],
|
|
1443
|
-
[136, 165, 72, 127, 72, 38, 200, 5, 4, 187, 203, 29, 6, 82, 130, 39],
|
|
1444
|
-
[106, 95, 111, 82, 191, 213, 104, 194, 106, 30, 199, 250, 69, 223, 79, 250],
|
|
1445
|
-
[150, 63, 177, 61, 50, 182, 227, 53, 157, 168, 245, 96, 90, 212, 17, 132],
|
|
1446
|
-
[233, 159, 182, 205, 3, 216, 203, 73, 193, 142, 183, 16, 22, 208, 38, 143],
|
|
1447
|
-
[7, 45, 239, 102, 47, 8, 237, 115, 77, 232, 2, 167, 47, 65, 164, 251],
|
|
1448
|
-
[7, 159, 18, 71, 3, 132, 84, 47, 60, 167, 134, 251, 114, 207, 254, 190],
|
|
1449
|
-
[203, 129, 34, 153, 32, 169, 153, 45, 215, 172, 76, 214, 5, 21, 210, 65],
|
|
1450
|
-
[29, 194, 255, 4, 195, 144, 178, 174, 255, 66, 15, 19, 26, 212, 61, 251],
|
|
1451
|
-
[42, 13, 136, 252, 143, 234, 120, 242, 164, 36, 21, 135, 252, 145, 101, 124],
|
|
1452
|
-
[24, 24, 207, 236, 159, 24, 180, 141, 80, 119, 86, 239, 192, 32, 51, 34],
|
|
1453
|
-
[187, 89, 217, 2, 16, 125, 121, 46, 159, 66, 85, 169, 9, 155, 2, 178],
|
|
1454
|
-
[212, 230, 71, 216, 35, 20, 241, 0, 204, 163, 80, 198, 132, 210, 166, 173]
|
|
1455
|
-
],
|
|
1456
|
-
16: [
|
|
1457
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
1458
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31],
|
|
1459
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 47],
|
|
1460
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 63],
|
|
1461
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 79],
|
|
1462
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 95],
|
|
1463
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 111],
|
|
1464
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 127],
|
|
1465
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 143],
|
|
1466
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 159],
|
|
1467
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 175],
|
|
1468
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 191],
|
|
1469
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 207],
|
|
1470
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 223],
|
|
1471
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 239],
|
|
1472
|
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255]
|
|
1473
|
-
],
|
|
1474
|
-
17: [
|
|
1475
|
-
[75, 40, 61, 20, 254, 102, 105, 160, 44, 236, 79, 39, 84, 27, 235, 100],
|
|
1476
|
-
[185, 139, 202, 38, 158, 109, 211, 6, 38, 73, 28, 120, 208, 168, 159, 108],
|
|
1477
|
-
[252, 100, 192, 127, 135, 127, 228, 125, 190, 210, 248, 146, 45, 229, 218, 159],
|
|
1478
|
-
[217, 39, 58, 200, 22, 212, 105, 55, 15, 45, 82, 96, 216, 134, 69, 123],
|
|
1479
|
-
[192, 34, 199, 199, 200, 112, 61, 98, 174, 62, 7, 200, 149, 168, 175, 110],
|
|
1480
|
-
[60, 41, 125, 116, 134, 191, 241, 188, 171, 127, 209, 10, 114, 52, 120, 164],
|
|
1481
|
-
[255, 19, 220, 184, 141, 224, 242, 117, 230, 143, 20, 75, 44, 50, 70, 113],
|
|
1482
|
-
[55, 112, 171, 176, 239, 50, 111, 3, 175, 145, 123, 38, 12, 44, 18, 79],
|
|
1483
|
-
[211, 119, 219, 6, 27, 41, 170, 199, 206, 66, 89, 89, 154, 128, 110, 70],
|
|
1484
|
-
[187, 184, 42, 154, 108, 182, 238, 223, 192, 10, 144, 139, 130, 22, 220, 66],
|
|
1485
|
-
[91, 248, 195, 246, 212, 104, 246, 252, 231, 120, 153, 211, 39, 250, 221, 133],
|
|
1486
|
-
[184, 148, 72, 207, 106, 143, 21, 239, 133, 206, 1, 234, 1, 75, 92, 43],
|
|
1487
|
-
[46, 35, 117, 127, 103, 37, 155, 16, 177, 106, 195, 129, 168, 235, 159, 162],
|
|
1488
|
-
[0, 7, 114, 77, 77, 66, 224, 223, 92, 193, 241, 44, 242, 104, 67, 163],
|
|
1489
|
-
[116, 194, 13, 179, 75, 181, 245, 211, 19, 38, 45, 21, 36, 163, 252, 235],
|
|
1490
|
-
[6, 211, 31, 66, 81, 221, 137, 33, 23, 18, 160, 147, 159, 34, 121, 125]
|
|
1491
|
-
]
|
|
1492
|
-
};
|
|
1493
|
-
const pinKeys = {
|
|
1494
|
-
0: "00000000000000010000000000000002",
|
|
1495
|
-
1: "00000000000000010000000000000002",
|
|
1496
|
-
2: "B2D24304FC345F1418EB96835B3B7AE8",
|
|
1497
|
-
16: "00000000000000010000000000000002",
|
|
1498
|
-
17: "CB5A6AA23FD565A141C5CE5ABF209000"
|
|
1499
|
-
};
|
|
1500
1402
|
const bridgeSecurity = {
|
|
1501
1403
|
getSignedCommand(device, command) {
|
|
1502
1404
|
const { randomAdvNumber, configVersion } = device?.advertisingData || {};
|
|
@@ -1513,7 +1415,8 @@ const bridgeSecurity = {
|
|
|
1513
1415
|
const r = command.length % 16;
|
|
1514
1416
|
paddedCommand = bridgeTools.pkcs(command, r ? ++t * 16 : t * 16);
|
|
1515
1417
|
}
|
|
1516
|
-
|
|
1418
|
+
if (!store.securityKeys?.signatureKeys?.[configVersion]) throw new Error("No signature key found");
|
|
1419
|
+
const key = store.securityKeys.signatureKeys[configVersion][keyIndex];
|
|
1517
1420
|
const startArray = key.slice(keyShift);
|
|
1518
1421
|
const endArray = key.slice(0, keyShift);
|
|
1519
1422
|
const shiftedKey = startArray.concat(endArray).map((n) => bridgeTools.decimalToHex(n)).join("");
|
|
@@ -1550,13 +1453,14 @@ const bridgeSecurity = {
|
|
|
1550
1453
|
},
|
|
1551
1454
|
async getPin(deviceId) {
|
|
1552
1455
|
const deviceData = store.devices[deviceId];
|
|
1553
|
-
if (deviceData?.type !== "bridge") throw new Error("Device data missing");
|
|
1456
|
+
if (deviceData?.type !== "bridge") throw new Error("Device data missing 1 ");
|
|
1554
1457
|
const { randomAdvNumber, macAddress, configVersion } = deviceData.advertisingData || {};
|
|
1555
1458
|
if (!randomAdvNumber || !macAddress || !_.isNumber(configVersion)) throw new Error("Cannot compute pin");
|
|
1556
1459
|
const mac = macAddress.map((n) => bridgeTools.decimalToHex(n)).join("");
|
|
1557
1460
|
const rand = randomAdvNumber.map((n) => bridgeTools.decimalToHex(n)).join("");
|
|
1558
1461
|
const message = `${mac}0000${rand}`;
|
|
1559
|
-
|
|
1462
|
+
if (!store.securityKeys?.pinKeys?.[configVersion]) throw new Error("No pin key found");
|
|
1463
|
+
const key = store.securityKeys.pinKeys[configVersion];
|
|
1560
1464
|
const res = await this.aesToCrc32(message, key);
|
|
1561
1465
|
return res;
|
|
1562
1466
|
},
|
|
@@ -2125,7 +2029,7 @@ async function updateFirmware(deviceId, bootloader, firmware, reportStatus) {
|
|
|
2125
2029
|
}
|
|
2126
2030
|
async function setVehicleLayout(deviceId, tcVehicle) {
|
|
2127
2031
|
const spareTyres = tcVehicle.tcTyres?.filter((tyre) => String(tyre.mountedOn?.positionId).endsWith("0"));
|
|
2128
|
-
let spareTyresCount = Math.min(spareTyres
|
|
2032
|
+
let spareTyresCount = Math.min(spareTyres?.length || 0, 2);
|
|
2129
2033
|
const result = {
|
|
2130
2034
|
axle01: "0000",
|
|
2131
2035
|
axle02: "0000",
|
|
@@ -2485,7 +2389,7 @@ async function getAutolearnStatuses(deviceId, tcVehicle) {
|
|
|
2485
2389
|
return autolearnedStatuses;
|
|
2486
2390
|
}
|
|
2487
2391
|
function getAutolearnStatusName(statusId) {
|
|
2488
|
-
if (["2", "A"].includes(statusId)) {
|
|
2392
|
+
if (["2", "A"].includes(statusId.toUpperCase())) {
|
|
2489
2393
|
return "error";
|
|
2490
2394
|
}
|
|
2491
2395
|
if (statusId === "4") {
|
|
@@ -2497,7 +2401,7 @@ function getAutolearnStatusName(statusId) {
|
|
|
2497
2401
|
if (statusId === "0") {
|
|
2498
2402
|
return "default";
|
|
2499
2403
|
}
|
|
2500
|
-
throw new Error(
|
|
2404
|
+
throw new Error(`Unknown autolearn status: ${statusId}`);
|
|
2501
2405
|
}
|
|
2502
2406
|
async function resetAutolearnStatuses(deviceId, positionIds) {
|
|
2503
2407
|
if (!bridgeTools.isVersionGreaterThan(deviceId, "0.9.7"))
|
|
@@ -3316,10 +3220,13 @@ function ensureSimulatorMethodsAreInjected() {
|
|
|
3316
3220
|
advertisingInterval = void 0;
|
|
3317
3221
|
}
|
|
3318
3222
|
let previousDevices = store.simulatedDevices;
|
|
3319
|
-
advertisingInterval = toolsSvc.setIntervalImmediate(() => {
|
|
3223
|
+
advertisingInterval = toolsSvc.setIntervalImmediate(async () => {
|
|
3320
3224
|
for (const key in store.simulatedDevices) {
|
|
3321
3225
|
const d = store.simulatedDevices[key];
|
|
3322
|
-
if (d.isDisabled)
|
|
3226
|
+
if (d.isDisabled) {
|
|
3227
|
+
if (store.deviceState[key] === "paired") await bridgeSimulator.disconnect(key);
|
|
3228
|
+
continue;
|
|
3229
|
+
}
|
|
3323
3230
|
unreachableSvc.refresh(d.id, deviceUnreachableCallback);
|
|
3324
3231
|
deviceAdvertisingCallback?.(store.simulatedDevices[key]);
|
|
3325
3232
|
}
|
|
@@ -3365,7 +3272,8 @@ class BridgeTcVehicleAxle {
|
|
|
3365
3272
|
minTargetPressure;
|
|
3366
3273
|
}
|
|
3367
3274
|
|
|
3368
|
-
function createTirecheckDeviceSdk(platform, bleImplementation) {
|
|
3275
|
+
function createTirecheckDeviceSdk(platform, securityKeys, bleImplementation) {
|
|
3276
|
+
store.securityKeys = securityKeys;
|
|
3369
3277
|
store.platform = platform;
|
|
3370
3278
|
bleImplementation = bleImplementation || emptyBleImplementation;
|
|
3371
3279
|
setBleImplementation(bleImplementation);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.994",
|
|
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",
|