tirecheck-device-sdk 0.2.71 → 0.2.72

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
@@ -179,7 +179,7 @@ const bridgeTools = {
179
179
  );
180
180
  const result = [];
181
181
  for (const key of keys) {
182
- if (!structurizedObj[key]) throw new Error(`Missing key ${key} in the structure`);
182
+ if (structurizedObj[key] == null) throw new Error(`Missing key ${key} in the structure`);
183
183
  const encoded = this.encodeData(structurizedObj[key], objStructure[key].display);
184
184
  if (encoded.length < objStructure[key].size) {
185
185
  const _padArray = Array.from({ length: objStructure[key].size - encoded.length }, () => 0);
@@ -219,7 +219,8 @@ const bridgeTools = {
219
219
  return this.asciiToDecimalArray(_data);
220
220
  }
221
221
  if (displayUnits === "decimal") {
222
- return this.hexToDecimalArray(decimalToHex(_data)).reverse();
222
+ const hex = decimalToHex(_data);
223
+ return this.hexToDecimalArray(hex.length % 2 ? `0${hex}` : hex).reverse();
223
224
  }
224
225
  if (displayUnits === "reverseHex") {
225
226
  const byteArray = _data.match(/.{1,2}/g) || [];
@@ -1852,6 +1853,109 @@ const bridgeCommandStructures = {
1852
1853
  description: "Bluetooth chip FW version: major.minor.patch + release type (e.g. 1.2.0 Release)"
1853
1854
  }
1854
1855
  }
1856
+ },
1857
+ bridgeConfiguration: {
1858
+ id: [98, 1],
1859
+ name: "bridgeConfiguration",
1860
+ structure: {
1861
+ configVersion: {
1862
+ size: 4,
1863
+ description: "Application configuration version details",
1864
+ display: "decimal"
1865
+ },
1866
+ bleTxPower: {
1867
+ size: 2,
1868
+ description: "Used BLE Tx power (16 bit signed value; LSB = 0.1)",
1869
+ display: "decimal"
1870
+ },
1871
+ bleTxChannels: {
1872
+ size: 1,
1873
+ description: "BLE channel configuration (0x07 = all channels)"
1874
+ },
1875
+ bleConnectableAdvPeriod: {
1876
+ size: 2,
1877
+ description: "BLE Connectable Advertisement Period [LSB = 0.625 ms]",
1878
+ display: "decimal"
1879
+ },
1880
+ configurationFlags: {
1881
+ size: 1,
1882
+ description: "Configuration flags (1 = Enable inactivity timeout; 4 = Disable time lockout on false PINs)"
1883
+ },
1884
+ wrongPinsUntilLockout: {
1885
+ size: 1,
1886
+ description: "Minimal number of wrong pins allowed before the lockout activates",
1887
+ display: "decimal"
1888
+ },
1889
+ maxLockoutPeriodIncreases: {
1890
+ size: 1,
1891
+ description: "How many times the lockout period may be doubled",
1892
+ display: "decimal"
1893
+ },
1894
+ wrongPinInitialLockoutTime: {
1895
+ size: 1,
1896
+ description: "Initial lockout time duration after too many wrong PINs",
1897
+ display: "decimal"
1898
+ },
1899
+ securityConfiguration: {
1900
+ size: 1,
1901
+ description: "Bluetooth security configuration (0x03 - legacy pairing enabled; 0x07 - disabled)"
1902
+ },
1903
+ canEnabled: {
1904
+ size: 1,
1905
+ description: "CAN enabled state",
1906
+ display: "decimal"
1907
+ },
1908
+ bleEnabled: {
1909
+ size: 1,
1910
+ description: "BLE Advertisement enabled state",
1911
+ display: "decimal"
1912
+ },
1913
+ canBitrate: {
1914
+ size: 2,
1915
+ description: "CAN Bitrate [kbps]",
1916
+ display: "decimal"
1917
+ },
1918
+ movementDetectionLimit: {
1919
+ size: 2,
1920
+ description: "Movement detection limit [1/256 kmph per bit]",
1921
+ display: "decimal"
1922
+ },
1923
+ sensorInactivityTimeout: {
1924
+ size: 2,
1925
+ description: "Timeout [s] after which an inactive sensor is marked erroneous (max. 512 s)",
1926
+ display: "decimal"
1927
+ },
1928
+ manufacturerCode: {
1929
+ size: 4,
1930
+ description: "Manufacturer Code as per SAE J1939",
1931
+ display: "decimal"
1932
+ },
1933
+ identityNumber: {
1934
+ size: 4,
1935
+ description: "Identity number for ECU (max. 22 bits = 0x1FFFFF)",
1936
+ display: "decimal"
1937
+ },
1938
+ manufacturerName: {
1939
+ size: 20,
1940
+ description: "Manufacturer Name (SPN 4304, max. 20 bytes)",
1941
+ display: "ascii"
1942
+ },
1943
+ ecuPartNumber: {
1944
+ size: 20,
1945
+ description: "ECU Part Number (SPN 2901, max. 20 bytes)",
1946
+ display: "ascii"
1947
+ },
1948
+ softwareVersion: {
1949
+ size: 20,
1950
+ description: "Software Version (SPN 234, max. 20 bytes)",
1951
+ display: "ascii"
1952
+ },
1953
+ reservedConfiguration: {
1954
+ size: 4,
1955
+ description: "Reserved configuration",
1956
+ display: "decimal"
1957
+ }
1958
+ }
1855
1959
  }
1856
1960
  };
1857
1961
 
@@ -1950,6 +2054,18 @@ const bridgeSecurity = {
1950
2054
  }
1951
2055
  return crc >>> 0;
1952
2056
  },
2057
+ /** CRC-16/CCITT-FALSE (poly 0x1021, init 0xFFFF). Used for the RxSWIN (0xF18F) E010/E141 checksums. */
2058
+ crc16Ccitt(msg) {
2059
+ let crc = 65535;
2060
+ const polynomial = 4129;
2061
+ for (const byte of msg) {
2062
+ crc ^= (byte & 255) << 8;
2063
+ for (let j = 0; j < 8; j++) {
2064
+ crc = crc & 32768 ? (crc << 1 ^ polynomial) & 65535 : crc << 1 & 65535;
2065
+ }
2066
+ }
2067
+ return crc & 65535;
2068
+ },
1953
2069
  getCrcArray(msg) {
1954
2070
  const crc = this.crc32mpeg2(msg);
1955
2071
  const crcHex = decimalToHex(crc).padStart(8, "0");
@@ -2355,6 +2471,21 @@ const bridgeCommands = {
2355
2471
  deviceData.advertisingData.fwVersion
2356
2472
  );
2357
2473
  },
2474
+ async getBridgeConfiguration(deviceId) {
2475
+ const deviceData = bridgeTools.getBridgeFromStore(deviceId);
2476
+ const result = await this.readCommand(deviceData, subCommandIds.bridgeConfiguration);
2477
+ const structurized = bridgeTools.convertBytesToStructure(
2478
+ bridgeCommandStructures.bridgeConfiguration.structure,
2479
+ result.data,
2480
+ deviceData.advertisingData.fwVersion
2481
+ );
2482
+ console.log(
2483
+ `[getBridgeConfiguration] raw payload (${result.data.length}B):`,
2484
+ result.data.map((b) => decimalToHex(b)).join(" ")
2485
+ );
2486
+ console.log("[getBridgeConfiguration] decoded structure:", structurized, `(isFactory: ${result.isFactory})`);
2487
+ return { ...structurized, isFactory: result.isFactory };
2488
+ },
2358
2489
  async getErrorHistoryCounter(deviceId) {
2359
2490
  const deviceData = bridgeTools.getBridgeFromStore(deviceId);
2360
2491
  const result = await this.readCommand(deviceData, subCommandIds.errorHistoryCounter, {
@@ -2466,6 +2597,7 @@ const bridgeService = {
2466
2597
  setVehicle,
2467
2598
  getConfiguration,
2468
2599
  setConfiguration,
2600
+ getRxSWIN,
2469
2601
  getSensorReading,
2470
2602
  getVehicleReadings,
2471
2603
  resetAutolearnStatuses,
@@ -2537,7 +2669,7 @@ async function setVehicleLayout(deviceId, tcVehicle) {
2537
2669
  }
2538
2670
  await bridgeCommands.setVehicleLayout(deviceId, result);
2539
2671
  }
2540
- async function getConfiguration(deviceId, includeVehicleData = false) {
2672
+ async function getConfiguration(deviceId) {
2541
2673
  const customerCANSettings = await bridgeCommands.getCustomerCANSettings(deviceId);
2542
2674
  const workshopCANSettings = await bridgeCommands.getWorkshopCANSettings(deviceId);
2543
2675
  const customerPressureThresholds = await bridgeCommands.getCustomerPressureThresholds(deviceId);
@@ -2545,16 +2677,23 @@ async function getConfiguration(deviceId, includeVehicleData = false) {
2545
2677
  const customerImbalanceThresholds = await bridgeCommands.getCustomerImbalanceThresholds(deviceId);
2546
2678
  const pressuresPerAxle = await bridgeCommands.getPressuresPerAxle(deviceId);
2547
2679
  let autolearnSettings;
2680
+ let autolearnIdStatus;
2681
+ let autolearnUnknownSensors;
2548
2682
  let errorHistoryCounter;
2549
2683
  let eolStatus;
2684
+ let firmwareVersion;
2550
2685
  if (bridgeTools.isVersionGreaterThan(deviceId, "0.9.7")) {
2551
2686
  autolearnSettings = await bridgeCommands.getAutolearnSettings(deviceId);
2687
+ autolearnIdStatus = await bridgeCommands.getAutolearnIdStatus(deviceId);
2688
+ autolearnUnknownSensors = await bridgeCommands.getAutolearnUnknownSensors(deviceId);
2552
2689
  }
2553
2690
  if (bridgeTools.isVersionGreaterThan(deviceId, "1.1.F")) {
2554
2691
  errorHistoryCounter = await bridgeCommands.getErrorHistoryCounter(deviceId);
2555
2692
  eolStatus = await bridgeCommands.getEolStatus(deviceId);
2693
+ firmwareVersion = await bridgeCommands.getFirmwareVersion(deviceId);
2556
2694
  }
2557
- const configuration = {
2695
+ const rxswin = await getRxSWIN(deviceId, { customerPressureThresholds, customerCANSettings });
2696
+ return {
2558
2697
  customerCANSettings,
2559
2698
  workshopCANSettings,
2560
2699
  customerPressureThresholds,
@@ -2562,27 +2701,75 @@ async function getConfiguration(deviceId, includeVehicleData = false) {
2562
2701
  customerImbalanceThresholds,
2563
2702
  pressuresPerAxle,
2564
2703
  autolearnSettings,
2704
+ autolearnIdStatus,
2705
+ autolearnUnknownSensors,
2565
2706
  errorHistoryCounter,
2566
- eolStatus
2707
+ eolStatus,
2708
+ firmwareVersion,
2709
+ rxswin
2567
2710
  };
2568
- if (includeVehicleData) {
2569
- configuration.vehicleLayout = await bridgeCommands.getVehicleLayout(deviceId);
2570
- configuration.axleInfo = [];
2571
- for (let axleIndex = 0; axleIndex < 15; axleIndex++) {
2572
- const axleBytes = await bridgeCommands.getAxleInfo(deviceId, axleIndex);
2573
- configuration.axleInfo.push(
2574
- bridgeTools.convertBytesToStructure(bridgeCommandStructures.idsPerWheel.structure, axleBytes)
2575
- );
2576
- }
2577
- if (bridgeTools.isVersionGreaterThan(deviceId, "1.1.F")) {
2578
- configuration.firmwareVersion = await bridgeCommands.getFirmwareVersion(deviceId);
2579
- }
2580
- if (bridgeTools.isVersionGreaterThan(deviceId, "0.9.7")) {
2581
- configuration.autolearnIdStatus = await bridgeCommands.getAutolearnIdStatus(deviceId);
2582
- configuration.autolearnUnknownSensors = await bridgeCommands.getAutolearnUnknownSensors(deviceId);
2583
- }
2584
- }
2585
- return configuration;
2711
+ }
2712
+ async function getRxSWIN(deviceId, configuration) {
2713
+ if (!canCommunicateWith(deviceId)) throw new Error("Bridge not connected");
2714
+ const bridgeConfiguration = bridgeTools.isVersionGreaterThan(deviceId, "1.1.F") ? await bridgeCommands.getBridgeConfiguration(deviceId) : {
2715
+ canEnabled: 1,
2716
+ movementDetectionLimit: 1280,
2717
+ // Firmware default provided as 0x01FA for pre-1.2.0 bridges where record 0x01 is unavailable.
2718
+ sensorInactivityTimeout: 506,
2719
+ bleTxPower: 60,
2720
+ bleTxChannels: "07"
2721
+ };
2722
+ const customerPressureThresholds = configuration?.customerPressureThresholds ?? await bridgeCommands.getCustomerPressureThresholds(deviceId);
2723
+ const customerCANSettings = configuration?.customerCANSettings ?? await bridgeCommands.getCustomerCANSettings(deviceId);
2724
+ const fwVersion = bridgeTools.getBridgeFromStore(deviceId).advertisingData.fwVersion;
2725
+ const bleTxChannels = bridgeTools.hexToDecimalArray(bridgeConfiguration.bleTxChannels ?? "").reverse();
2726
+ const axle01PressureThresholds = bridgeTools.hexToDecimalArray(customerPressureThresholds.axle01 ?? "");
2727
+ const canProtocol = bridgeTools.hexToDecimalArray(customerCANSettings.canProtocol ?? "").reverse();
2728
+ const transparentFilteredMode = bridgeTools.hexToDecimalArray(customerCANSettings.transparentFilteredMode ?? "").reverse();
2729
+ const fwMajor = (fwVersion || "0").split(".")[0].charCodeAt(0) & 255;
2730
+ const bleTxPower = bridgeTools.intToBytes(bridgeConfiguration.bleTxPower ?? 0, 2);
2731
+ const canEnabled = bridgeTools.intToBytes(bridgeConfiguration.canEnabled ?? 0, 1);
2732
+ const movementDetectionLimit = bridgeTools.intToBytes(bridgeConfiguration.movementDetectionLimit ?? 0, 2);
2733
+ const sensorInactivityTimeout = bridgeTools.intToBytes(bridgeConfiguration.sensorInactivityTimeout ?? 0, 2);
2734
+ const e010Input = [bleTxPower[0] ?? 0, bleTxPower[1] ?? 0, bleTxChannels[0] ?? 0];
2735
+ const e141Input = [
2736
+ canEnabled[0] ?? 0,
2737
+ movementDetectionLimit[0] ?? 0,
2738
+ movementDetectionLimit[1] ?? 0,
2739
+ sensorInactivityTimeout[0] ?? 0,
2740
+ sensorInactivityTimeout[1] ?? 0,
2741
+ axle01PressureThresholds[0] ?? 0,
2742
+ canProtocol[0] ?? 0,
2743
+ transparentFilteredMode[0] ?? 0,
2744
+ fwMajor
2745
+ ];
2746
+ console.log(`[getRxSWIN] e010: ${e010Input}`);
2747
+ console.log(`[getRxSWIN] e141: ${e141Input}`);
2748
+ const result = {
2749
+ R10SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e010Input), 4),
2750
+ R141SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e141Input), 4)
2751
+ };
2752
+ const item1Content = [
2753
+ ...bridgeTools.asciiToDecimalArray("R010"),
2754
+ 32,
2755
+ ...bridgeTools.asciiToDecimalArray(result.R10SWIN)
2756
+ ];
2757
+ const item2Content = [
2758
+ ...bridgeTools.asciiToDecimalArray("R141"),
2759
+ 32,
2760
+ ...bridgeTools.asciiToDecimalArray(result.R141SWIN)
2761
+ ];
2762
+ const item1 = [item1Content.length, ...item1Content];
2763
+ const item2 = [item2Content.length, ...item2Content];
2764
+ const payload = [...item1, ...item2];
2765
+ console.log(
2766
+ `[getRxSWIN] R010 item: "${String.fromCharCode(...item1.slice(1))}" (${item1.map((b) => decimalToHex(b)).join(" ")})`
2767
+ );
2768
+ console.log(
2769
+ `[getRxSWIN] R141 item: "${String.fromCharCode(...item2.slice(1))}" (${item2.map((b) => decimalToHex(b)).join(" ")})`
2770
+ );
2771
+ console.log(`[getRxSWIN] final payload (${payload.length}B): ${payload.map((b) => decimalToHex(b)).join(" ")}`);
2772
+ return result;
2586
2773
  }
2587
2774
  function bridgeVehiclesDifference(original, change) {
2588
2775
  const differences = [];
@@ -3161,6 +3348,7 @@ const bridge = {
3161
3348
  setVehicle: bridgeService.setVehicle,
3162
3349
  getConfiguration: bridgeService.getConfiguration,
3163
3350
  setConfiguration: bridgeService.setConfiguration,
3351
+ getRxSWIN: bridgeService.getRxSWIN,
3164
3352
  getSensorReading: bridgeService.getSensorReading,
3165
3353
  getVehicleReadings: bridgeService.getVehicleReadings,
3166
3354
  getAutolearnStatuses: bridgeService.getAutolearnStatuses,
@@ -4354,6 +4542,32 @@ const bridgeSimulator = {
4354
4542
  const bridge = getSimulatedBridge(deviceId);
4355
4543
  bridge.simulatorData.configuration = ___default.cloneDeep(config);
4356
4544
  },
4545
+ async getRxSWIN(deviceId) {
4546
+ const bridge = getSimulatedBridge(deviceId);
4547
+ const config = bridge.simulatorData.configuration;
4548
+ const axle01PressureThresholds = bridgeTools.hexToDecimalArray(config.customerPressureThresholds?.axle01 ?? "");
4549
+ const canProtocol = bridgeTools.hexToDecimalArray(config.customerCANSettings?.canProtocol ?? "");
4550
+ const transparentFilteredMode = bridgeTools.hexToDecimalArray(
4551
+ config.customerCANSettings?.transparentFilteredMode ?? ""
4552
+ );
4553
+ const fwMajor = (bridge.advertisingData.fwVersion || "0").split(".")[0].charCodeAt(0) & 255;
4554
+ const e010Input = [0, 0, 0];
4555
+ const e141Input = [
4556
+ 0,
4557
+ 0,
4558
+ 0,
4559
+ 0,
4560
+ 0,
4561
+ axle01PressureThresholds[0] ?? 0,
4562
+ canProtocol[0] ?? 0,
4563
+ transparentFilteredMode[0] ?? 0,
4564
+ fwMajor
4565
+ ];
4566
+ return {
4567
+ R10SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e010Input), 4),
4568
+ R141SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e141Input), 4)
4569
+ };
4570
+ },
4357
4571
  async getSensorReading(deviceId, positionId) {
4358
4572
  const bridge = getSimulatedBridge(deviceId);
4359
4573
  return bridge.simulatorData.sensors[positionId];
package/dist/index.d.cts CHANGED
@@ -973,6 +973,109 @@ declare const _default: {
973
973
  };
974
974
  };
975
975
  };
976
+ bridgeConfiguration: {
977
+ id: number[];
978
+ name: string;
979
+ structure: {
980
+ configVersion: {
981
+ size: number;
982
+ description: string;
983
+ display: "decimal";
984
+ };
985
+ bleTxPower: {
986
+ size: number;
987
+ description: string;
988
+ display: "decimal";
989
+ };
990
+ bleTxChannels: {
991
+ size: number;
992
+ description: string;
993
+ };
994
+ bleConnectableAdvPeriod: {
995
+ size: number;
996
+ description: string;
997
+ display: "decimal";
998
+ };
999
+ configurationFlags: {
1000
+ size: number;
1001
+ description: string;
1002
+ };
1003
+ wrongPinsUntilLockout: {
1004
+ size: number;
1005
+ description: string;
1006
+ display: "decimal";
1007
+ };
1008
+ maxLockoutPeriodIncreases: {
1009
+ size: number;
1010
+ description: string;
1011
+ display: "decimal";
1012
+ };
1013
+ wrongPinInitialLockoutTime: {
1014
+ size: number;
1015
+ description: string;
1016
+ display: "decimal";
1017
+ };
1018
+ securityConfiguration: {
1019
+ size: number;
1020
+ description: string;
1021
+ };
1022
+ canEnabled: {
1023
+ size: number;
1024
+ description: string;
1025
+ display: "decimal";
1026
+ };
1027
+ bleEnabled: {
1028
+ size: number;
1029
+ description: string;
1030
+ display: "decimal";
1031
+ };
1032
+ canBitrate: {
1033
+ size: number;
1034
+ description: string;
1035
+ display: "decimal";
1036
+ };
1037
+ movementDetectionLimit: {
1038
+ size: number;
1039
+ description: string;
1040
+ display: "decimal";
1041
+ };
1042
+ sensorInactivityTimeout: {
1043
+ size: number;
1044
+ description: string;
1045
+ display: "decimal";
1046
+ };
1047
+ manufacturerCode: {
1048
+ size: number;
1049
+ description: string;
1050
+ display: "decimal";
1051
+ };
1052
+ identityNumber: {
1053
+ size: number;
1054
+ description: string;
1055
+ display: "decimal";
1056
+ };
1057
+ manufacturerName: {
1058
+ size: number;
1059
+ description: string;
1060
+ display: "ascii";
1061
+ };
1062
+ ecuPartNumber: {
1063
+ size: number;
1064
+ description: string;
1065
+ display: "ascii";
1066
+ };
1067
+ softwareVersion: {
1068
+ size: number;
1069
+ description: string;
1070
+ display: "ascii";
1071
+ };
1072
+ reservedConfiguration: {
1073
+ size: number;
1074
+ description: string;
1075
+ display: "decimal";
1076
+ };
1077
+ };
1078
+ };
976
1079
  };
977
1080
 
978
1081
  type DeepPartial<T> = T extends object ? {
@@ -1064,15 +1167,14 @@ interface BridgeConfiguration {
1064
1167
  eolStatus?: BridgeCommandStructurized<typeof _default.eolStatus.structure>;
1065
1168
  /** only available after 0.9.8 fw */
1066
1169
  autolearnSettings?: BridgeCommandStructurized<typeof _default.autolearnSettings.structure>;
1067
- vehicleLayout?: BridgeCommandStructurized<typeof _default.vehicleLayout.structure>;
1068
- /** Per-axle wheel sensor IDs, indexed by axle (0-14). Each entry holds the 15 wheel slots of one axle. */
1069
- axleInfo?: BridgeCommandStructurized<typeof _default.idsPerWheel.structure>[];
1070
1170
  /** Parsed 0x90 SW Version DID (BT stack, config data version, BLE chip compilation date, BT chip FW version). */
1071
1171
  firmwareVersion?: BridgeCommandStructurized<typeof _default.firmwareVersion.structure>;
1072
1172
  /** only available after 0.9.7 fw */
1073
1173
  autolearnIdStatus?: BridgeCommandStructurized<typeof _default.autolearnIdStatus.structure>;
1074
1174
  /** only available after 0.9.7 fw */
1075
1175
  autolearnUnknownSensors?: BridgeCommandStructurized<typeof _default.autolearnUnknownSensors.structure>;
1176
+ /** R10/R141 software identification numbers, computed app-side from config records. */
1177
+ rxswin?: RxSwinResult;
1076
1178
  }
1077
1179
  interface BridgeReading {
1078
1180
  date: number;
@@ -1296,6 +1398,17 @@ interface TorqueWrenchReading {
1296
1398
  angle: number;
1297
1399
  duration: number;
1298
1400
  }
1401
+ interface RxSwinBridgeConfiguration {
1402
+ bleTxPower?: number;
1403
+ bleTxChannels?: string;
1404
+ canEnabled?: number;
1405
+ movementDetectionLimit?: number;
1406
+ sensorInactivityTimeout?: number;
1407
+ }
1408
+ interface RxSwinResult {
1409
+ R10SWIN: string;
1410
+ R141SWIN: string;
1411
+ }
1299
1412
  type EventName = keyof EventHandlers;
1300
1413
 
1301
1414
  interface BluetoothClassicSerialDevice {
@@ -1346,8 +1459,9 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
1346
1459
  connect: (deviceId: string, accessLevel: BridgeAccessLevel) => Promise<void>;
1347
1460
  getVehicle: (deviceId: string) => Promise<BridgeTcVehicle>;
1348
1461
  setVehicle: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<void>;
1349
- getConfiguration: (deviceId: string, includeVehicleData?: boolean) => Promise<BridgeConfiguration>;
1462
+ getConfiguration: (deviceId: string) => Promise<BridgeConfiguration>;
1350
1463
  setConfiguration: (deviceId: string, bridgeConfiguration: BridgeConfiguration) => Promise<void>;
1464
+ getRxSWIN: (deviceId: string, configuration?: Partial<BridgeConfiguration>) => Promise<RxSwinResult>;
1351
1465
  getSensorReading: (deviceId: string, positionId: number) => Promise<BridgeReading>;
1352
1466
  getVehicleReadings: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeReading[]>;
1353
1467
  getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
@@ -1443,4 +1557,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
1443
1557
  };
1444
1558
  };
1445
1559
 
1446
- export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
1560
+ export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type RxSwinBridgeConfiguration, type RxSwinResult, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
package/dist/index.d.mts CHANGED
@@ -973,6 +973,109 @@ declare const _default: {
973
973
  };
974
974
  };
975
975
  };
976
+ bridgeConfiguration: {
977
+ id: number[];
978
+ name: string;
979
+ structure: {
980
+ configVersion: {
981
+ size: number;
982
+ description: string;
983
+ display: "decimal";
984
+ };
985
+ bleTxPower: {
986
+ size: number;
987
+ description: string;
988
+ display: "decimal";
989
+ };
990
+ bleTxChannels: {
991
+ size: number;
992
+ description: string;
993
+ };
994
+ bleConnectableAdvPeriod: {
995
+ size: number;
996
+ description: string;
997
+ display: "decimal";
998
+ };
999
+ configurationFlags: {
1000
+ size: number;
1001
+ description: string;
1002
+ };
1003
+ wrongPinsUntilLockout: {
1004
+ size: number;
1005
+ description: string;
1006
+ display: "decimal";
1007
+ };
1008
+ maxLockoutPeriodIncreases: {
1009
+ size: number;
1010
+ description: string;
1011
+ display: "decimal";
1012
+ };
1013
+ wrongPinInitialLockoutTime: {
1014
+ size: number;
1015
+ description: string;
1016
+ display: "decimal";
1017
+ };
1018
+ securityConfiguration: {
1019
+ size: number;
1020
+ description: string;
1021
+ };
1022
+ canEnabled: {
1023
+ size: number;
1024
+ description: string;
1025
+ display: "decimal";
1026
+ };
1027
+ bleEnabled: {
1028
+ size: number;
1029
+ description: string;
1030
+ display: "decimal";
1031
+ };
1032
+ canBitrate: {
1033
+ size: number;
1034
+ description: string;
1035
+ display: "decimal";
1036
+ };
1037
+ movementDetectionLimit: {
1038
+ size: number;
1039
+ description: string;
1040
+ display: "decimal";
1041
+ };
1042
+ sensorInactivityTimeout: {
1043
+ size: number;
1044
+ description: string;
1045
+ display: "decimal";
1046
+ };
1047
+ manufacturerCode: {
1048
+ size: number;
1049
+ description: string;
1050
+ display: "decimal";
1051
+ };
1052
+ identityNumber: {
1053
+ size: number;
1054
+ description: string;
1055
+ display: "decimal";
1056
+ };
1057
+ manufacturerName: {
1058
+ size: number;
1059
+ description: string;
1060
+ display: "ascii";
1061
+ };
1062
+ ecuPartNumber: {
1063
+ size: number;
1064
+ description: string;
1065
+ display: "ascii";
1066
+ };
1067
+ softwareVersion: {
1068
+ size: number;
1069
+ description: string;
1070
+ display: "ascii";
1071
+ };
1072
+ reservedConfiguration: {
1073
+ size: number;
1074
+ description: string;
1075
+ display: "decimal";
1076
+ };
1077
+ };
1078
+ };
976
1079
  };
977
1080
 
978
1081
  type DeepPartial<T> = T extends object ? {
@@ -1064,15 +1167,14 @@ interface BridgeConfiguration {
1064
1167
  eolStatus?: BridgeCommandStructurized<typeof _default.eolStatus.structure>;
1065
1168
  /** only available after 0.9.8 fw */
1066
1169
  autolearnSettings?: BridgeCommandStructurized<typeof _default.autolearnSettings.structure>;
1067
- vehicleLayout?: BridgeCommandStructurized<typeof _default.vehicleLayout.structure>;
1068
- /** Per-axle wheel sensor IDs, indexed by axle (0-14). Each entry holds the 15 wheel slots of one axle. */
1069
- axleInfo?: BridgeCommandStructurized<typeof _default.idsPerWheel.structure>[];
1070
1170
  /** Parsed 0x90 SW Version DID (BT stack, config data version, BLE chip compilation date, BT chip FW version). */
1071
1171
  firmwareVersion?: BridgeCommandStructurized<typeof _default.firmwareVersion.structure>;
1072
1172
  /** only available after 0.9.7 fw */
1073
1173
  autolearnIdStatus?: BridgeCommandStructurized<typeof _default.autolearnIdStatus.structure>;
1074
1174
  /** only available after 0.9.7 fw */
1075
1175
  autolearnUnknownSensors?: BridgeCommandStructurized<typeof _default.autolearnUnknownSensors.structure>;
1176
+ /** R10/R141 software identification numbers, computed app-side from config records. */
1177
+ rxswin?: RxSwinResult;
1076
1178
  }
1077
1179
  interface BridgeReading {
1078
1180
  date: number;
@@ -1296,6 +1398,17 @@ interface TorqueWrenchReading {
1296
1398
  angle: number;
1297
1399
  duration: number;
1298
1400
  }
1401
+ interface RxSwinBridgeConfiguration {
1402
+ bleTxPower?: number;
1403
+ bleTxChannels?: string;
1404
+ canEnabled?: number;
1405
+ movementDetectionLimit?: number;
1406
+ sensorInactivityTimeout?: number;
1407
+ }
1408
+ interface RxSwinResult {
1409
+ R10SWIN: string;
1410
+ R141SWIN: string;
1411
+ }
1299
1412
  type EventName = keyof EventHandlers;
1300
1413
 
1301
1414
  interface BluetoothClassicSerialDevice {
@@ -1346,8 +1459,9 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
1346
1459
  connect: (deviceId: string, accessLevel: BridgeAccessLevel) => Promise<void>;
1347
1460
  getVehicle: (deviceId: string) => Promise<BridgeTcVehicle>;
1348
1461
  setVehicle: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<void>;
1349
- getConfiguration: (deviceId: string, includeVehicleData?: boolean) => Promise<BridgeConfiguration>;
1462
+ getConfiguration: (deviceId: string) => Promise<BridgeConfiguration>;
1350
1463
  setConfiguration: (deviceId: string, bridgeConfiguration: BridgeConfiguration) => Promise<void>;
1464
+ getRxSWIN: (deviceId: string, configuration?: Partial<BridgeConfiguration>) => Promise<RxSwinResult>;
1351
1465
  getSensorReading: (deviceId: string, positionId: number) => Promise<BridgeReading>;
1352
1466
  getVehicleReadings: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeReading[]>;
1353
1467
  getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
@@ -1443,4 +1557,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
1443
1557
  };
1444
1558
  };
1445
1559
 
1446
- export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
1560
+ export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type RxSwinBridgeConfiguration, type RxSwinResult, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
package/dist/index.d.ts CHANGED
@@ -973,6 +973,109 @@ declare const _default: {
973
973
  };
974
974
  };
975
975
  };
976
+ bridgeConfiguration: {
977
+ id: number[];
978
+ name: string;
979
+ structure: {
980
+ configVersion: {
981
+ size: number;
982
+ description: string;
983
+ display: "decimal";
984
+ };
985
+ bleTxPower: {
986
+ size: number;
987
+ description: string;
988
+ display: "decimal";
989
+ };
990
+ bleTxChannels: {
991
+ size: number;
992
+ description: string;
993
+ };
994
+ bleConnectableAdvPeriod: {
995
+ size: number;
996
+ description: string;
997
+ display: "decimal";
998
+ };
999
+ configurationFlags: {
1000
+ size: number;
1001
+ description: string;
1002
+ };
1003
+ wrongPinsUntilLockout: {
1004
+ size: number;
1005
+ description: string;
1006
+ display: "decimal";
1007
+ };
1008
+ maxLockoutPeriodIncreases: {
1009
+ size: number;
1010
+ description: string;
1011
+ display: "decimal";
1012
+ };
1013
+ wrongPinInitialLockoutTime: {
1014
+ size: number;
1015
+ description: string;
1016
+ display: "decimal";
1017
+ };
1018
+ securityConfiguration: {
1019
+ size: number;
1020
+ description: string;
1021
+ };
1022
+ canEnabled: {
1023
+ size: number;
1024
+ description: string;
1025
+ display: "decimal";
1026
+ };
1027
+ bleEnabled: {
1028
+ size: number;
1029
+ description: string;
1030
+ display: "decimal";
1031
+ };
1032
+ canBitrate: {
1033
+ size: number;
1034
+ description: string;
1035
+ display: "decimal";
1036
+ };
1037
+ movementDetectionLimit: {
1038
+ size: number;
1039
+ description: string;
1040
+ display: "decimal";
1041
+ };
1042
+ sensorInactivityTimeout: {
1043
+ size: number;
1044
+ description: string;
1045
+ display: "decimal";
1046
+ };
1047
+ manufacturerCode: {
1048
+ size: number;
1049
+ description: string;
1050
+ display: "decimal";
1051
+ };
1052
+ identityNumber: {
1053
+ size: number;
1054
+ description: string;
1055
+ display: "decimal";
1056
+ };
1057
+ manufacturerName: {
1058
+ size: number;
1059
+ description: string;
1060
+ display: "ascii";
1061
+ };
1062
+ ecuPartNumber: {
1063
+ size: number;
1064
+ description: string;
1065
+ display: "ascii";
1066
+ };
1067
+ softwareVersion: {
1068
+ size: number;
1069
+ description: string;
1070
+ display: "ascii";
1071
+ };
1072
+ reservedConfiguration: {
1073
+ size: number;
1074
+ description: string;
1075
+ display: "decimal";
1076
+ };
1077
+ };
1078
+ };
976
1079
  };
977
1080
 
978
1081
  type DeepPartial<T> = T extends object ? {
@@ -1064,15 +1167,14 @@ interface BridgeConfiguration {
1064
1167
  eolStatus?: BridgeCommandStructurized<typeof _default.eolStatus.structure>;
1065
1168
  /** only available after 0.9.8 fw */
1066
1169
  autolearnSettings?: BridgeCommandStructurized<typeof _default.autolearnSettings.structure>;
1067
- vehicleLayout?: BridgeCommandStructurized<typeof _default.vehicleLayout.structure>;
1068
- /** Per-axle wheel sensor IDs, indexed by axle (0-14). Each entry holds the 15 wheel slots of one axle. */
1069
- axleInfo?: BridgeCommandStructurized<typeof _default.idsPerWheel.structure>[];
1070
1170
  /** Parsed 0x90 SW Version DID (BT stack, config data version, BLE chip compilation date, BT chip FW version). */
1071
1171
  firmwareVersion?: BridgeCommandStructurized<typeof _default.firmwareVersion.structure>;
1072
1172
  /** only available after 0.9.7 fw */
1073
1173
  autolearnIdStatus?: BridgeCommandStructurized<typeof _default.autolearnIdStatus.structure>;
1074
1174
  /** only available after 0.9.7 fw */
1075
1175
  autolearnUnknownSensors?: BridgeCommandStructurized<typeof _default.autolearnUnknownSensors.structure>;
1176
+ /** R10/R141 software identification numbers, computed app-side from config records. */
1177
+ rxswin?: RxSwinResult;
1076
1178
  }
1077
1179
  interface BridgeReading {
1078
1180
  date: number;
@@ -1296,6 +1398,17 @@ interface TorqueWrenchReading {
1296
1398
  angle: number;
1297
1399
  duration: number;
1298
1400
  }
1401
+ interface RxSwinBridgeConfiguration {
1402
+ bleTxPower?: number;
1403
+ bleTxChannels?: string;
1404
+ canEnabled?: number;
1405
+ movementDetectionLimit?: number;
1406
+ sensorInactivityTimeout?: number;
1407
+ }
1408
+ interface RxSwinResult {
1409
+ R10SWIN: string;
1410
+ R141SWIN: string;
1411
+ }
1299
1412
  type EventName = keyof EventHandlers;
1300
1413
 
1301
1414
  interface BluetoothClassicSerialDevice {
@@ -1346,8 +1459,9 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
1346
1459
  connect: (deviceId: string, accessLevel: BridgeAccessLevel) => Promise<void>;
1347
1460
  getVehicle: (deviceId: string) => Promise<BridgeTcVehicle>;
1348
1461
  setVehicle: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<void>;
1349
- getConfiguration: (deviceId: string, includeVehicleData?: boolean) => Promise<BridgeConfiguration>;
1462
+ getConfiguration: (deviceId: string) => Promise<BridgeConfiguration>;
1350
1463
  setConfiguration: (deviceId: string, bridgeConfiguration: BridgeConfiguration) => Promise<void>;
1464
+ getRxSWIN: (deviceId: string, configuration?: Partial<BridgeConfiguration>) => Promise<RxSwinResult>;
1351
1465
  getSensorReading: (deviceId: string, positionId: number) => Promise<BridgeReading>;
1352
1466
  getVehicleReadings: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeReading[]>;
1353
1467
  getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
@@ -1443,4 +1557,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
1443
1557
  };
1444
1558
  };
1445
1559
 
1446
- export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
1560
+ export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, type BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type RxSwinBridgeConfiguration, type RxSwinResult, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
package/dist/index.mjs CHANGED
@@ -172,7 +172,7 @@ const bridgeTools = {
172
172
  );
173
173
  const result = [];
174
174
  for (const key of keys) {
175
- if (!structurizedObj[key]) throw new Error(`Missing key ${key} in the structure`);
175
+ if (structurizedObj[key] == null) throw new Error(`Missing key ${key} in the structure`);
176
176
  const encoded = this.encodeData(structurizedObj[key], objStructure[key].display);
177
177
  if (encoded.length < objStructure[key].size) {
178
178
  const _padArray = Array.from({ length: objStructure[key].size - encoded.length }, () => 0);
@@ -212,7 +212,8 @@ const bridgeTools = {
212
212
  return this.asciiToDecimalArray(_data);
213
213
  }
214
214
  if (displayUnits === "decimal") {
215
- return this.hexToDecimalArray(decimalToHex(_data)).reverse();
215
+ const hex = decimalToHex(_data);
216
+ return this.hexToDecimalArray(hex.length % 2 ? `0${hex}` : hex).reverse();
216
217
  }
217
218
  if (displayUnits === "reverseHex") {
218
219
  const byteArray = _data.match(/.{1,2}/g) || [];
@@ -1845,6 +1846,109 @@ const bridgeCommandStructures = {
1845
1846
  description: "Bluetooth chip FW version: major.minor.patch + release type (e.g. 1.2.0 Release)"
1846
1847
  }
1847
1848
  }
1849
+ },
1850
+ bridgeConfiguration: {
1851
+ id: [98, 1],
1852
+ name: "bridgeConfiguration",
1853
+ structure: {
1854
+ configVersion: {
1855
+ size: 4,
1856
+ description: "Application configuration version details",
1857
+ display: "decimal"
1858
+ },
1859
+ bleTxPower: {
1860
+ size: 2,
1861
+ description: "Used BLE Tx power (16 bit signed value; LSB = 0.1)",
1862
+ display: "decimal"
1863
+ },
1864
+ bleTxChannels: {
1865
+ size: 1,
1866
+ description: "BLE channel configuration (0x07 = all channels)"
1867
+ },
1868
+ bleConnectableAdvPeriod: {
1869
+ size: 2,
1870
+ description: "BLE Connectable Advertisement Period [LSB = 0.625 ms]",
1871
+ display: "decimal"
1872
+ },
1873
+ configurationFlags: {
1874
+ size: 1,
1875
+ description: "Configuration flags (1 = Enable inactivity timeout; 4 = Disable time lockout on false PINs)"
1876
+ },
1877
+ wrongPinsUntilLockout: {
1878
+ size: 1,
1879
+ description: "Minimal number of wrong pins allowed before the lockout activates",
1880
+ display: "decimal"
1881
+ },
1882
+ maxLockoutPeriodIncreases: {
1883
+ size: 1,
1884
+ description: "How many times the lockout period may be doubled",
1885
+ display: "decimal"
1886
+ },
1887
+ wrongPinInitialLockoutTime: {
1888
+ size: 1,
1889
+ description: "Initial lockout time duration after too many wrong PINs",
1890
+ display: "decimal"
1891
+ },
1892
+ securityConfiguration: {
1893
+ size: 1,
1894
+ description: "Bluetooth security configuration (0x03 - legacy pairing enabled; 0x07 - disabled)"
1895
+ },
1896
+ canEnabled: {
1897
+ size: 1,
1898
+ description: "CAN enabled state",
1899
+ display: "decimal"
1900
+ },
1901
+ bleEnabled: {
1902
+ size: 1,
1903
+ description: "BLE Advertisement enabled state",
1904
+ display: "decimal"
1905
+ },
1906
+ canBitrate: {
1907
+ size: 2,
1908
+ description: "CAN Bitrate [kbps]",
1909
+ display: "decimal"
1910
+ },
1911
+ movementDetectionLimit: {
1912
+ size: 2,
1913
+ description: "Movement detection limit [1/256 kmph per bit]",
1914
+ display: "decimal"
1915
+ },
1916
+ sensorInactivityTimeout: {
1917
+ size: 2,
1918
+ description: "Timeout [s] after which an inactive sensor is marked erroneous (max. 512 s)",
1919
+ display: "decimal"
1920
+ },
1921
+ manufacturerCode: {
1922
+ size: 4,
1923
+ description: "Manufacturer Code as per SAE J1939",
1924
+ display: "decimal"
1925
+ },
1926
+ identityNumber: {
1927
+ size: 4,
1928
+ description: "Identity number for ECU (max. 22 bits = 0x1FFFFF)",
1929
+ display: "decimal"
1930
+ },
1931
+ manufacturerName: {
1932
+ size: 20,
1933
+ description: "Manufacturer Name (SPN 4304, max. 20 bytes)",
1934
+ display: "ascii"
1935
+ },
1936
+ ecuPartNumber: {
1937
+ size: 20,
1938
+ description: "ECU Part Number (SPN 2901, max. 20 bytes)",
1939
+ display: "ascii"
1940
+ },
1941
+ softwareVersion: {
1942
+ size: 20,
1943
+ description: "Software Version (SPN 234, max. 20 bytes)",
1944
+ display: "ascii"
1945
+ },
1946
+ reservedConfiguration: {
1947
+ size: 4,
1948
+ description: "Reserved configuration",
1949
+ display: "decimal"
1950
+ }
1951
+ }
1848
1952
  }
1849
1953
  };
1850
1954
 
@@ -1943,6 +2047,18 @@ const bridgeSecurity = {
1943
2047
  }
1944
2048
  return crc >>> 0;
1945
2049
  },
2050
+ /** CRC-16/CCITT-FALSE (poly 0x1021, init 0xFFFF). Used for the RxSWIN (0xF18F) E010/E141 checksums. */
2051
+ crc16Ccitt(msg) {
2052
+ let crc = 65535;
2053
+ const polynomial = 4129;
2054
+ for (const byte of msg) {
2055
+ crc ^= (byte & 255) << 8;
2056
+ for (let j = 0; j < 8; j++) {
2057
+ crc = crc & 32768 ? (crc << 1 ^ polynomial) & 65535 : crc << 1 & 65535;
2058
+ }
2059
+ }
2060
+ return crc & 65535;
2061
+ },
1946
2062
  getCrcArray(msg) {
1947
2063
  const crc = this.crc32mpeg2(msg);
1948
2064
  const crcHex = decimalToHex(crc).padStart(8, "0");
@@ -2348,6 +2464,21 @@ const bridgeCommands = {
2348
2464
  deviceData.advertisingData.fwVersion
2349
2465
  );
2350
2466
  },
2467
+ async getBridgeConfiguration(deviceId) {
2468
+ const deviceData = bridgeTools.getBridgeFromStore(deviceId);
2469
+ const result = await this.readCommand(deviceData, subCommandIds.bridgeConfiguration);
2470
+ const structurized = bridgeTools.convertBytesToStructure(
2471
+ bridgeCommandStructures.bridgeConfiguration.structure,
2472
+ result.data,
2473
+ deviceData.advertisingData.fwVersion
2474
+ );
2475
+ console.log(
2476
+ `[getBridgeConfiguration] raw payload (${result.data.length}B):`,
2477
+ result.data.map((b) => decimalToHex(b)).join(" ")
2478
+ );
2479
+ console.log("[getBridgeConfiguration] decoded structure:", structurized, `(isFactory: ${result.isFactory})`);
2480
+ return { ...structurized, isFactory: result.isFactory };
2481
+ },
2351
2482
  async getErrorHistoryCounter(deviceId) {
2352
2483
  const deviceData = bridgeTools.getBridgeFromStore(deviceId);
2353
2484
  const result = await this.readCommand(deviceData, subCommandIds.errorHistoryCounter, {
@@ -2459,6 +2590,7 @@ const bridgeService = {
2459
2590
  setVehicle,
2460
2591
  getConfiguration,
2461
2592
  setConfiguration,
2593
+ getRxSWIN,
2462
2594
  getSensorReading,
2463
2595
  getVehicleReadings,
2464
2596
  resetAutolearnStatuses,
@@ -2530,7 +2662,7 @@ async function setVehicleLayout(deviceId, tcVehicle) {
2530
2662
  }
2531
2663
  await bridgeCommands.setVehicleLayout(deviceId, result);
2532
2664
  }
2533
- async function getConfiguration(deviceId, includeVehicleData = false) {
2665
+ async function getConfiguration(deviceId) {
2534
2666
  const customerCANSettings = await bridgeCommands.getCustomerCANSettings(deviceId);
2535
2667
  const workshopCANSettings = await bridgeCommands.getWorkshopCANSettings(deviceId);
2536
2668
  const customerPressureThresholds = await bridgeCommands.getCustomerPressureThresholds(deviceId);
@@ -2538,16 +2670,23 @@ async function getConfiguration(deviceId, includeVehicleData = false) {
2538
2670
  const customerImbalanceThresholds = await bridgeCommands.getCustomerImbalanceThresholds(deviceId);
2539
2671
  const pressuresPerAxle = await bridgeCommands.getPressuresPerAxle(deviceId);
2540
2672
  let autolearnSettings;
2673
+ let autolearnIdStatus;
2674
+ let autolearnUnknownSensors;
2541
2675
  let errorHistoryCounter;
2542
2676
  let eolStatus;
2677
+ let firmwareVersion;
2543
2678
  if (bridgeTools.isVersionGreaterThan(deviceId, "0.9.7")) {
2544
2679
  autolearnSettings = await bridgeCommands.getAutolearnSettings(deviceId);
2680
+ autolearnIdStatus = await bridgeCommands.getAutolearnIdStatus(deviceId);
2681
+ autolearnUnknownSensors = await bridgeCommands.getAutolearnUnknownSensors(deviceId);
2545
2682
  }
2546
2683
  if (bridgeTools.isVersionGreaterThan(deviceId, "1.1.F")) {
2547
2684
  errorHistoryCounter = await bridgeCommands.getErrorHistoryCounter(deviceId);
2548
2685
  eolStatus = await bridgeCommands.getEolStatus(deviceId);
2686
+ firmwareVersion = await bridgeCommands.getFirmwareVersion(deviceId);
2549
2687
  }
2550
- const configuration = {
2688
+ const rxswin = await getRxSWIN(deviceId, { customerPressureThresholds, customerCANSettings });
2689
+ return {
2551
2690
  customerCANSettings,
2552
2691
  workshopCANSettings,
2553
2692
  customerPressureThresholds,
@@ -2555,27 +2694,75 @@ async function getConfiguration(deviceId, includeVehicleData = false) {
2555
2694
  customerImbalanceThresholds,
2556
2695
  pressuresPerAxle,
2557
2696
  autolearnSettings,
2697
+ autolearnIdStatus,
2698
+ autolearnUnknownSensors,
2558
2699
  errorHistoryCounter,
2559
- eolStatus
2700
+ eolStatus,
2701
+ firmwareVersion,
2702
+ rxswin
2560
2703
  };
2561
- if (includeVehicleData) {
2562
- configuration.vehicleLayout = await bridgeCommands.getVehicleLayout(deviceId);
2563
- configuration.axleInfo = [];
2564
- for (let axleIndex = 0; axleIndex < 15; axleIndex++) {
2565
- const axleBytes = await bridgeCommands.getAxleInfo(deviceId, axleIndex);
2566
- configuration.axleInfo.push(
2567
- bridgeTools.convertBytesToStructure(bridgeCommandStructures.idsPerWheel.structure, axleBytes)
2568
- );
2569
- }
2570
- if (bridgeTools.isVersionGreaterThan(deviceId, "1.1.F")) {
2571
- configuration.firmwareVersion = await bridgeCommands.getFirmwareVersion(deviceId);
2572
- }
2573
- if (bridgeTools.isVersionGreaterThan(deviceId, "0.9.7")) {
2574
- configuration.autolearnIdStatus = await bridgeCommands.getAutolearnIdStatus(deviceId);
2575
- configuration.autolearnUnknownSensors = await bridgeCommands.getAutolearnUnknownSensors(deviceId);
2576
- }
2577
- }
2578
- return configuration;
2704
+ }
2705
+ async function getRxSWIN(deviceId, configuration) {
2706
+ if (!canCommunicateWith(deviceId)) throw new Error("Bridge not connected");
2707
+ const bridgeConfiguration = bridgeTools.isVersionGreaterThan(deviceId, "1.1.F") ? await bridgeCommands.getBridgeConfiguration(deviceId) : {
2708
+ canEnabled: 1,
2709
+ movementDetectionLimit: 1280,
2710
+ // Firmware default provided as 0x01FA for pre-1.2.0 bridges where record 0x01 is unavailable.
2711
+ sensorInactivityTimeout: 506,
2712
+ bleTxPower: 60,
2713
+ bleTxChannels: "07"
2714
+ };
2715
+ const customerPressureThresholds = configuration?.customerPressureThresholds ?? await bridgeCommands.getCustomerPressureThresholds(deviceId);
2716
+ const customerCANSettings = configuration?.customerCANSettings ?? await bridgeCommands.getCustomerCANSettings(deviceId);
2717
+ const fwVersion = bridgeTools.getBridgeFromStore(deviceId).advertisingData.fwVersion;
2718
+ const bleTxChannels = bridgeTools.hexToDecimalArray(bridgeConfiguration.bleTxChannels ?? "").reverse();
2719
+ const axle01PressureThresholds = bridgeTools.hexToDecimalArray(customerPressureThresholds.axle01 ?? "");
2720
+ const canProtocol = bridgeTools.hexToDecimalArray(customerCANSettings.canProtocol ?? "").reverse();
2721
+ const transparentFilteredMode = bridgeTools.hexToDecimalArray(customerCANSettings.transparentFilteredMode ?? "").reverse();
2722
+ const fwMajor = (fwVersion || "0").split(".")[0].charCodeAt(0) & 255;
2723
+ const bleTxPower = bridgeTools.intToBytes(bridgeConfiguration.bleTxPower ?? 0, 2);
2724
+ const canEnabled = bridgeTools.intToBytes(bridgeConfiguration.canEnabled ?? 0, 1);
2725
+ const movementDetectionLimit = bridgeTools.intToBytes(bridgeConfiguration.movementDetectionLimit ?? 0, 2);
2726
+ const sensorInactivityTimeout = bridgeTools.intToBytes(bridgeConfiguration.sensorInactivityTimeout ?? 0, 2);
2727
+ const e010Input = [bleTxPower[0] ?? 0, bleTxPower[1] ?? 0, bleTxChannels[0] ?? 0];
2728
+ const e141Input = [
2729
+ canEnabled[0] ?? 0,
2730
+ movementDetectionLimit[0] ?? 0,
2731
+ movementDetectionLimit[1] ?? 0,
2732
+ sensorInactivityTimeout[0] ?? 0,
2733
+ sensorInactivityTimeout[1] ?? 0,
2734
+ axle01PressureThresholds[0] ?? 0,
2735
+ canProtocol[0] ?? 0,
2736
+ transparentFilteredMode[0] ?? 0,
2737
+ fwMajor
2738
+ ];
2739
+ console.log(`[getRxSWIN] e010: ${e010Input}`);
2740
+ console.log(`[getRxSWIN] e141: ${e141Input}`);
2741
+ const result = {
2742
+ R10SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e010Input), 4),
2743
+ R141SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e141Input), 4)
2744
+ };
2745
+ const item1Content = [
2746
+ ...bridgeTools.asciiToDecimalArray("R010"),
2747
+ 32,
2748
+ ...bridgeTools.asciiToDecimalArray(result.R10SWIN)
2749
+ ];
2750
+ const item2Content = [
2751
+ ...bridgeTools.asciiToDecimalArray("R141"),
2752
+ 32,
2753
+ ...bridgeTools.asciiToDecimalArray(result.R141SWIN)
2754
+ ];
2755
+ const item1 = [item1Content.length, ...item1Content];
2756
+ const item2 = [item2Content.length, ...item2Content];
2757
+ const payload = [...item1, ...item2];
2758
+ console.log(
2759
+ `[getRxSWIN] R010 item: "${String.fromCharCode(...item1.slice(1))}" (${item1.map((b) => decimalToHex(b)).join(" ")})`
2760
+ );
2761
+ console.log(
2762
+ `[getRxSWIN] R141 item: "${String.fromCharCode(...item2.slice(1))}" (${item2.map((b) => decimalToHex(b)).join(" ")})`
2763
+ );
2764
+ console.log(`[getRxSWIN] final payload (${payload.length}B): ${payload.map((b) => decimalToHex(b)).join(" ")}`);
2765
+ return result;
2579
2766
  }
2580
2767
  function bridgeVehiclesDifference(original, change) {
2581
2768
  const differences = [];
@@ -3154,6 +3341,7 @@ const bridge = {
3154
3341
  setVehicle: bridgeService.setVehicle,
3155
3342
  getConfiguration: bridgeService.getConfiguration,
3156
3343
  setConfiguration: bridgeService.setConfiguration,
3344
+ getRxSWIN: bridgeService.getRxSWIN,
3157
3345
  getSensorReading: bridgeService.getSensorReading,
3158
3346
  getVehicleReadings: bridgeService.getVehicleReadings,
3159
3347
  getAutolearnStatuses: bridgeService.getAutolearnStatuses,
@@ -4347,6 +4535,32 @@ const bridgeSimulator = {
4347
4535
  const bridge = getSimulatedBridge(deviceId);
4348
4536
  bridge.simulatorData.configuration = _.cloneDeep(config);
4349
4537
  },
4538
+ async getRxSWIN(deviceId) {
4539
+ const bridge = getSimulatedBridge(deviceId);
4540
+ const config = bridge.simulatorData.configuration;
4541
+ const axle01PressureThresholds = bridgeTools.hexToDecimalArray(config.customerPressureThresholds?.axle01 ?? "");
4542
+ const canProtocol = bridgeTools.hexToDecimalArray(config.customerCANSettings?.canProtocol ?? "");
4543
+ const transparentFilteredMode = bridgeTools.hexToDecimalArray(
4544
+ config.customerCANSettings?.transparentFilteredMode ?? ""
4545
+ );
4546
+ const fwMajor = (bridge.advertisingData.fwVersion || "0").split(".")[0].charCodeAt(0) & 255;
4547
+ const e010Input = [0, 0, 0];
4548
+ const e141Input = [
4549
+ 0,
4550
+ 0,
4551
+ 0,
4552
+ 0,
4553
+ 0,
4554
+ axle01PressureThresholds[0] ?? 0,
4555
+ canProtocol[0] ?? 0,
4556
+ transparentFilteredMode[0] ?? 0,
4557
+ fwMajor
4558
+ ];
4559
+ return {
4560
+ R10SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e010Input), 4),
4561
+ R141SWIN: decimalToHex(bridgeSecurity.crc16Ccitt(e141Input), 4)
4562
+ };
4563
+ },
4350
4564
  async getSensorReading(deviceId, positionId) {
4351
4565
  const bridge = getSimulatedBridge(deviceId);
4352
4566
  return bridge.simulatorData.sensors[positionId];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirecheck-device-sdk",
3
- "version": "0.2.71",
3
+ "version": "0.2.72",
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",