tirecheck-device-sdk 0.1.91 → 0.1.92
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 +22 -12
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +22 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,8 @@ const store = {
|
|
|
22
22
|
/** undefined - no information but since we get advertisings it is most likely disconnected, connecting - trying to connect via bluetooth, connected - connected via bluetooth (can send write and read), paired - all additional connection steps completed (setMtu, sendPin, etc) */
|
|
23
23
|
deviceState: {},
|
|
24
24
|
// undefined => connecting => connected => paired => disconnecting => undefined
|
|
25
|
-
|
|
25
|
+
/** some bridge commands require bridge reboot to be completed */
|
|
26
|
+
bridgeRebootRequired: {},
|
|
26
27
|
//** Ios uses generated device Id, bridges send mac address in advertising so internaly we always use mac address but when real device id is needed we check mapping table for it */
|
|
27
28
|
deviceIdMapingTable: {},
|
|
28
29
|
/** Used to change device state in store, also notifies app via calback. Every undefined state should have its reason so that app can handle it accordingly */
|
|
@@ -471,7 +472,7 @@ const deviceMeta = {
|
|
|
471
472
|
},
|
|
472
473
|
bridgeOta: {
|
|
473
474
|
nameRegex: /(CAN BLE BRDG OTA.*|0303.{2}_B)/,
|
|
474
|
-
mtu:
|
|
475
|
+
mtu: 180,
|
|
475
476
|
characteristic: {
|
|
476
477
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
477
478
|
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d7"
|
|
@@ -1669,7 +1670,7 @@ const promiseQueue$1 = {
|
|
|
1669
1670
|
return currentReject(new Error(`Command not succesful: ${numberArray[4]}`));
|
|
1670
1671
|
}
|
|
1671
1672
|
if ([226, 81].includes(numberArray[3]) && numberArray[4] && toolsSvc.canCommunicateWith(deviceId)) {
|
|
1672
|
-
store.
|
|
1673
|
+
store.bridgeRebootRequired[deviceId] = true;
|
|
1673
1674
|
}
|
|
1674
1675
|
if ((!responseIdentifier[0] || numberArray[3] === responseIdentifier[0]) && (!responseIdentifier[1] || numberArray[4] === responseIdentifier[1])) {
|
|
1675
1676
|
return currentResolve(numberArray);
|
|
@@ -2113,6 +2114,7 @@ const bridgeOtaService = {
|
|
|
2113
2114
|
async function uploadOta(deviceId, firmwareBinary, reportStatus) {
|
|
2114
2115
|
let uploadedBytes = 0;
|
|
2115
2116
|
let chunkIndex = 0;
|
|
2117
|
+
const mtu = store.platform === "android" ? 512 : deviceMeta.bridgeOta.mtu;
|
|
2116
2118
|
while (uploadedBytes < firmwareBinary.byteLength) {
|
|
2117
2119
|
if (chunkIndex % 100 === 0)
|
|
2118
2120
|
reportStatus(
|
|
@@ -2121,7 +2123,7 @@ async function uploadOta(deviceId, firmwareBinary, reportStatus) {
|
|
|
2121
2123
|
)} KB)`,
|
|
2122
2124
|
uploadedBytes / firmwareBinary.byteLength
|
|
2123
2125
|
);
|
|
2124
|
-
const chunkSize = Math.min(
|
|
2126
|
+
const chunkSize = Math.min(mtu - 3, firmwareBinary.byteLength - uploadedBytes);
|
|
2125
2127
|
const chunk = firmwareBinary.slice(uploadedBytes, uploadedBytes + chunkSize);
|
|
2126
2128
|
await bridgeOtaCommands.uploadOtaChunk(deviceId, chunk);
|
|
2127
2129
|
uploadedBytes += chunkSize;
|
|
@@ -2133,7 +2135,9 @@ const bridgeOta = {
|
|
|
2133
2135
|
async connect(deviceId) {
|
|
2134
2136
|
await bluetooth.connect(deviceId, this.disconnect);
|
|
2135
2137
|
const _deviceId = store.deviceIdMapingTable[deviceId] ?? deviceId;
|
|
2136
|
-
|
|
2138
|
+
if (store.platform !== "ios") {
|
|
2139
|
+
await ble.requestMtu(_deviceId, 512);
|
|
2140
|
+
}
|
|
2137
2141
|
store.setState(deviceId, "paired");
|
|
2138
2142
|
},
|
|
2139
2143
|
async disconnect(deviceId, reason) {
|
|
@@ -2163,7 +2167,8 @@ const bridgeService = {
|
|
|
2163
2167
|
getSensorReading,
|
|
2164
2168
|
getVehicleReadings,
|
|
2165
2169
|
resetAutolearnStatuses,
|
|
2166
|
-
getAutolearnStatuses
|
|
2170
|
+
getAutolearnStatuses,
|
|
2171
|
+
isRebootRequired
|
|
2167
2172
|
};
|
|
2168
2173
|
async function updateFirmware(deviceId, bootloader, firmware, reportStatus) {
|
|
2169
2174
|
reportStatus("Sending OTA Request...", 0.02);
|
|
@@ -2761,15 +2766,15 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2761
2766
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2762
2767
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2763
2768
|
if (axlesPressureData[axleIndex * 3]) {
|
|
2764
|
-
tcVehicleAxle.maxTargetPressure = bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]);
|
|
2769
|
+
tcVehicleAxle.maxTargetPressure = ___default.round(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]), 1);
|
|
2765
2770
|
}
|
|
2766
2771
|
if (axlesPressureData[axleIndex * 3 + 1]) {
|
|
2767
|
-
tcVehicleAxle.minTargetPressure = bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]);
|
|
2772
|
+
tcVehicleAxle.minTargetPressure = ___default.round(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]), 1);
|
|
2768
2773
|
}
|
|
2769
2774
|
if (axlesPressureData[axleIndex * 3 + 2]) {
|
|
2770
|
-
tcVehicleAxle.targetPressure =
|
|
2771
|
-
axlesPressureData[axleIndex * 3 + 2],
|
|
2772
|
-
|
|
2775
|
+
tcVehicleAxle.targetPressure = ___default.round(
|
|
2776
|
+
bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 2], void 0),
|
|
2777
|
+
1
|
|
2773
2778
|
);
|
|
2774
2779
|
}
|
|
2775
2780
|
return tcVehicleAxle;
|
|
@@ -2780,6 +2785,9 @@ function createNewTyre(positionId) {
|
|
|
2780
2785
|
serialNumber: `TYRE-${positionId}`
|
|
2781
2786
|
};
|
|
2782
2787
|
}
|
|
2788
|
+
function isRebootRequired(deviceId) {
|
|
2789
|
+
return store.bridgeRebootRequired[deviceId];
|
|
2790
|
+
}
|
|
2783
2791
|
|
|
2784
2792
|
const bridge = {
|
|
2785
2793
|
async connect(deviceId, accessLevel) {
|
|
@@ -2799,6 +2807,7 @@ const bridge = {
|
|
|
2799
2807
|
(error) => console.error("startNotification Error", error)
|
|
2800
2808
|
);
|
|
2801
2809
|
store.deviceAccessLevel[deviceId] = accessLevel ?? "driver";
|
|
2810
|
+
store.bridgeRebootRequired[deviceId] = false;
|
|
2802
2811
|
await bridgeCommands.sendPinCommand(deviceId);
|
|
2803
2812
|
store.setState(deviceId, "paired");
|
|
2804
2813
|
},
|
|
@@ -2818,7 +2827,8 @@ const bridge = {
|
|
|
2818
2827
|
getVehicleReadings: bridgeService.getVehicleReadings,
|
|
2819
2828
|
getAutolearnStatuses: bridgeService.getAutolearnStatuses,
|
|
2820
2829
|
resetAutolearnStatuses: bridgeService.resetAutolearnStatuses,
|
|
2821
|
-
updateFirmware: bridgeService.updateFirmware
|
|
2830
|
+
updateFirmware: bridgeService.updateFirmware,
|
|
2831
|
+
isRebootRequired: bridgeService.isRebootRequired
|
|
2822
2832
|
};
|
|
2823
2833
|
|
|
2824
2834
|
const flexiGaugeTpmsMeta = deviceMeta.flexiGaugeTpms;
|
package/dist/index.d.cts
CHANGED
|
@@ -919,6 +919,7 @@ declare function createTirecheckDeviceSdk(bleImplementation: BleImplementation,
|
|
|
919
919
|
getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
|
|
920
920
|
resetAutolearnStatuses: (deviceId: string, positionIds: number[]) => Promise<void>;
|
|
921
921
|
updateFirmware: (deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, reportStatus: ReportStatusFn) => Promise<void>;
|
|
922
|
+
isRebootRequired: (deviceId: string) => boolean;
|
|
922
923
|
};
|
|
923
924
|
/** Methods for working with Tirecheck CAN Bridge in OTA mode */
|
|
924
925
|
bridgeOta: {
|
package/dist/index.d.mts
CHANGED
|
@@ -919,6 +919,7 @@ declare function createTirecheckDeviceSdk(bleImplementation: BleImplementation,
|
|
|
919
919
|
getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
|
|
920
920
|
resetAutolearnStatuses: (deviceId: string, positionIds: number[]) => Promise<void>;
|
|
921
921
|
updateFirmware: (deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, reportStatus: ReportStatusFn) => Promise<void>;
|
|
922
|
+
isRebootRequired: (deviceId: string) => boolean;
|
|
922
923
|
};
|
|
923
924
|
/** Methods for working with Tirecheck CAN Bridge in OTA mode */
|
|
924
925
|
bridgeOta: {
|
package/dist/index.d.ts
CHANGED
|
@@ -919,6 +919,7 @@ declare function createTirecheckDeviceSdk(bleImplementation: BleImplementation,
|
|
|
919
919
|
getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
|
|
920
920
|
resetAutolearnStatuses: (deviceId: string, positionIds: number[]) => Promise<void>;
|
|
921
921
|
updateFirmware: (deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, reportStatus: ReportStatusFn) => Promise<void>;
|
|
922
|
+
isRebootRequired: (deviceId: string) => boolean;
|
|
922
923
|
};
|
|
923
924
|
/** Methods for working with Tirecheck CAN Bridge in OTA mode */
|
|
924
925
|
bridgeOta: {
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,8 @@ const store = {
|
|
|
15
15
|
/** undefined - no information but since we get advertisings it is most likely disconnected, connecting - trying to connect via bluetooth, connected - connected via bluetooth (can send write and read), paired - all additional connection steps completed (setMtu, sendPin, etc) */
|
|
16
16
|
deviceState: {},
|
|
17
17
|
// undefined => connecting => connected => paired => disconnecting => undefined
|
|
18
|
-
|
|
18
|
+
/** some bridge commands require bridge reboot to be completed */
|
|
19
|
+
bridgeRebootRequired: {},
|
|
19
20
|
//** Ios uses generated device Id, bridges send mac address in advertising so internaly we always use mac address but when real device id is needed we check mapping table for it */
|
|
20
21
|
deviceIdMapingTable: {},
|
|
21
22
|
/** Used to change device state in store, also notifies app via calback. Every undefined state should have its reason so that app can handle it accordingly */
|
|
@@ -464,7 +465,7 @@ const deviceMeta = {
|
|
|
464
465
|
},
|
|
465
466
|
bridgeOta: {
|
|
466
467
|
nameRegex: /(CAN BLE BRDG OTA.*|0303.{2}_B)/,
|
|
467
|
-
mtu:
|
|
468
|
+
mtu: 180,
|
|
468
469
|
characteristic: {
|
|
469
470
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
470
471
|
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d7"
|
|
@@ -1662,7 +1663,7 @@ const promiseQueue$1 = {
|
|
|
1662
1663
|
return currentReject(new Error(`Command not succesful: ${numberArray[4]}`));
|
|
1663
1664
|
}
|
|
1664
1665
|
if ([226, 81].includes(numberArray[3]) && numberArray[4] && toolsSvc.canCommunicateWith(deviceId)) {
|
|
1665
|
-
store.
|
|
1666
|
+
store.bridgeRebootRequired[deviceId] = true;
|
|
1666
1667
|
}
|
|
1667
1668
|
if ((!responseIdentifier[0] || numberArray[3] === responseIdentifier[0]) && (!responseIdentifier[1] || numberArray[4] === responseIdentifier[1])) {
|
|
1668
1669
|
return currentResolve(numberArray);
|
|
@@ -2106,6 +2107,7 @@ const bridgeOtaService = {
|
|
|
2106
2107
|
async function uploadOta(deviceId, firmwareBinary, reportStatus) {
|
|
2107
2108
|
let uploadedBytes = 0;
|
|
2108
2109
|
let chunkIndex = 0;
|
|
2110
|
+
const mtu = store.platform === "android" ? 512 : deviceMeta.bridgeOta.mtu;
|
|
2109
2111
|
while (uploadedBytes < firmwareBinary.byteLength) {
|
|
2110
2112
|
if (chunkIndex % 100 === 0)
|
|
2111
2113
|
reportStatus(
|
|
@@ -2114,7 +2116,7 @@ async function uploadOta(deviceId, firmwareBinary, reportStatus) {
|
|
|
2114
2116
|
)} KB)`,
|
|
2115
2117
|
uploadedBytes / firmwareBinary.byteLength
|
|
2116
2118
|
);
|
|
2117
|
-
const chunkSize = Math.min(
|
|
2119
|
+
const chunkSize = Math.min(mtu - 3, firmwareBinary.byteLength - uploadedBytes);
|
|
2118
2120
|
const chunk = firmwareBinary.slice(uploadedBytes, uploadedBytes + chunkSize);
|
|
2119
2121
|
await bridgeOtaCommands.uploadOtaChunk(deviceId, chunk);
|
|
2120
2122
|
uploadedBytes += chunkSize;
|
|
@@ -2126,7 +2128,9 @@ const bridgeOta = {
|
|
|
2126
2128
|
async connect(deviceId) {
|
|
2127
2129
|
await bluetooth.connect(deviceId, this.disconnect);
|
|
2128
2130
|
const _deviceId = store.deviceIdMapingTable[deviceId] ?? deviceId;
|
|
2129
|
-
|
|
2131
|
+
if (store.platform !== "ios") {
|
|
2132
|
+
await ble.requestMtu(_deviceId, 512);
|
|
2133
|
+
}
|
|
2130
2134
|
store.setState(deviceId, "paired");
|
|
2131
2135
|
},
|
|
2132
2136
|
async disconnect(deviceId, reason) {
|
|
@@ -2156,7 +2160,8 @@ const bridgeService = {
|
|
|
2156
2160
|
getSensorReading,
|
|
2157
2161
|
getVehicleReadings,
|
|
2158
2162
|
resetAutolearnStatuses,
|
|
2159
|
-
getAutolearnStatuses
|
|
2163
|
+
getAutolearnStatuses,
|
|
2164
|
+
isRebootRequired
|
|
2160
2165
|
};
|
|
2161
2166
|
async function updateFirmware(deviceId, bootloader, firmware, reportStatus) {
|
|
2162
2167
|
reportStatus("Sending OTA Request...", 0.02);
|
|
@@ -2754,15 +2759,15 @@ async function assignTyres(deviceId, tcVehicle) {
|
|
|
2754
2759
|
async function assignAxlePressureLimits(deviceId, tcVehicle, tcVehicleAxle, axleIndex, bridgeAxlesPressureData) {
|
|
2755
2760
|
const axlesPressureData = bridgeAxlesPressureData ?? (await bridgeCommands.getAxlesPressure(deviceId)).data;
|
|
2756
2761
|
if (axlesPressureData[axleIndex * 3]) {
|
|
2757
|
-
tcVehicleAxle.maxTargetPressure = bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]);
|
|
2762
|
+
tcVehicleAxle.maxTargetPressure = _.round(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3]), 1);
|
|
2758
2763
|
}
|
|
2759
2764
|
if (axlesPressureData[axleIndex * 3 + 1]) {
|
|
2760
|
-
tcVehicleAxle.minTargetPressure = bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]);
|
|
2765
|
+
tcVehicleAxle.minTargetPressure = _.round(bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 1]), 1);
|
|
2761
2766
|
}
|
|
2762
2767
|
if (axlesPressureData[axleIndex * 3 + 2]) {
|
|
2763
|
-
tcVehicleAxle.targetPressure =
|
|
2764
|
-
axlesPressureData[axleIndex * 3 + 2],
|
|
2765
|
-
|
|
2768
|
+
tcVehicleAxle.targetPressure = _.round(
|
|
2769
|
+
bridgeTools.kpaByteToBar(axlesPressureData[axleIndex * 3 + 2], void 0),
|
|
2770
|
+
1
|
|
2766
2771
|
);
|
|
2767
2772
|
}
|
|
2768
2773
|
return tcVehicleAxle;
|
|
@@ -2773,6 +2778,9 @@ function createNewTyre(positionId) {
|
|
|
2773
2778
|
serialNumber: `TYRE-${positionId}`
|
|
2774
2779
|
};
|
|
2775
2780
|
}
|
|
2781
|
+
function isRebootRequired(deviceId) {
|
|
2782
|
+
return store.bridgeRebootRequired[deviceId];
|
|
2783
|
+
}
|
|
2776
2784
|
|
|
2777
2785
|
const bridge = {
|
|
2778
2786
|
async connect(deviceId, accessLevel) {
|
|
@@ -2792,6 +2800,7 @@ const bridge = {
|
|
|
2792
2800
|
(error) => console.error("startNotification Error", error)
|
|
2793
2801
|
);
|
|
2794
2802
|
store.deviceAccessLevel[deviceId] = accessLevel ?? "driver";
|
|
2803
|
+
store.bridgeRebootRequired[deviceId] = false;
|
|
2795
2804
|
await bridgeCommands.sendPinCommand(deviceId);
|
|
2796
2805
|
store.setState(deviceId, "paired");
|
|
2797
2806
|
},
|
|
@@ -2811,7 +2820,8 @@ const bridge = {
|
|
|
2811
2820
|
getVehicleReadings: bridgeService.getVehicleReadings,
|
|
2812
2821
|
getAutolearnStatuses: bridgeService.getAutolearnStatuses,
|
|
2813
2822
|
resetAutolearnStatuses: bridgeService.resetAutolearnStatuses,
|
|
2814
|
-
updateFirmware: bridgeService.updateFirmware
|
|
2823
|
+
updateFirmware: bridgeService.updateFirmware,
|
|
2824
|
+
isRebootRequired: bridgeService.isRebootRequired
|
|
2815
2825
|
};
|
|
2816
2826
|
|
|
2817
2827
|
const flexiGaugeTpmsMeta = deviceMeta.flexiGaugeTpms;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.92",
|
|
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",
|