tirecheck-device-sdk 0.2.53 → 0.2.55
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 +110 -50
- package/dist/index.d.cts +11 -1
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.mjs +110 -50
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -521,7 +521,7 @@ const bridgeOtaAdvertisingParser = {
|
|
|
521
521
|
|
|
522
522
|
const deviceMeta = {
|
|
523
523
|
bridge: {
|
|
524
|
-
nameRegex: /^(030303|030321|030632)$/,
|
|
524
|
+
nameRegex: /^(030303|030321|030632|KSC-B3)$/,
|
|
525
525
|
communication: {
|
|
526
526
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
527
527
|
// message from device
|
|
@@ -533,9 +533,13 @@ const deviceMeta = {
|
|
|
533
533
|
bridgeOta: {
|
|
534
534
|
nameRegex: /(CAN BLE BRDG OTA.*|0303.{2}_B|030632_B)/,
|
|
535
535
|
mtu: 180,
|
|
536
|
-
|
|
537
|
-
serviceId: "
|
|
538
|
-
characteristicId: "
|
|
536
|
+
control: {
|
|
537
|
+
serviceId: "1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0",
|
|
538
|
+
characteristicId: "f7bf3564-fb6d-4e53-88a4-5e37e0326063"
|
|
539
|
+
},
|
|
540
|
+
data: {
|
|
541
|
+
serviceId: "1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0",
|
|
542
|
+
characteristicId: "984227f3-34fc-4045-a5d0-2c581f81a153"
|
|
539
543
|
},
|
|
540
544
|
getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
|
|
541
545
|
},
|
|
@@ -809,18 +813,51 @@ function getDeviceNameFromAdvertising(advertising) {
|
|
|
809
813
|
return deviceName;
|
|
810
814
|
}
|
|
811
815
|
|
|
812
|
-
const
|
|
813
|
-
const
|
|
814
|
-
|
|
816
|
+
const callbacks = {};
|
|
817
|
+
const simulatorSvc = {
|
|
818
|
+
registerEvent(eventName, callback) {
|
|
819
|
+
callbacks[eventName] = callback;
|
|
820
|
+
},
|
|
821
|
+
triggerEvent(eventName, deviceId, payload) {
|
|
822
|
+
if (payload && store.simulatedDevices[deviceId]) {
|
|
823
|
+
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
824
|
+
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
825
|
+
if (!payload) throw new Error(`Event not found`);
|
|
826
|
+
}
|
|
827
|
+
const callback = callbacks[eventName];
|
|
828
|
+
if (!callback) {
|
|
829
|
+
console.warn(`Event ${eventName} not registered`);
|
|
830
|
+
} else {
|
|
831
|
+
callback(deviceId, payload);
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
merge(deviceTemplate, initialData) {
|
|
835
|
+
return ___default.mergeWith({}, deviceTemplate, initialData, (a, b) => ___default.isArray(b) ? b : void 0);
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
const bridgeOtaMeta = deviceMeta.bridgeOta;
|
|
815
840
|
const bridgeOtaCommands = {
|
|
816
841
|
async beginOta(deviceId) {
|
|
817
|
-
await bluetooth.write(
|
|
842
|
+
await bluetooth.write(
|
|
843
|
+
deviceId,
|
|
844
|
+
bridgeOtaMeta.control.serviceId,
|
|
845
|
+
bridgeOtaMeta.control.characteristicId,
|
|
846
|
+
new Uint8Array([0]).buffer,
|
|
847
|
+
true
|
|
848
|
+
);
|
|
818
849
|
},
|
|
819
850
|
async uploadOtaChunk(deviceId, data) {
|
|
820
|
-
await bluetooth.write(deviceId,
|
|
851
|
+
await bluetooth.write(deviceId, bridgeOtaMeta.data.serviceId, bridgeOtaMeta.data.characteristicId, data, true);
|
|
821
852
|
},
|
|
822
853
|
async endOta(deviceId) {
|
|
823
|
-
await bluetooth.write(
|
|
854
|
+
await bluetooth.write(
|
|
855
|
+
deviceId,
|
|
856
|
+
bridgeOtaMeta.control.serviceId,
|
|
857
|
+
bridgeOtaMeta.control.characteristicId,
|
|
858
|
+
new Uint8Array([3]).buffer,
|
|
859
|
+
true
|
|
860
|
+
);
|
|
824
861
|
}
|
|
825
862
|
};
|
|
826
863
|
|
|
@@ -829,17 +866,39 @@ const bridgeOtaService = {
|
|
|
829
866
|
await delay(2e3);
|
|
830
867
|
progressCallback("Connecting to the bridge...", 0.1);
|
|
831
868
|
await bridgeOta.connect(deviceId);
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
869
|
+
try {
|
|
870
|
+
progressCallback("Uploading bootloader...", 0.12);
|
|
871
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "bootloaderUploadBegin");
|
|
872
|
+
await bridgeOtaCommands.beginOta(deviceId);
|
|
873
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "bootloaderUpload");
|
|
874
|
+
await uploadOta(deviceId, bootloader, (str, percents) => progressCallback(str, 0.12 + percents * 0.2));
|
|
875
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "bootloaderUploadEnd");
|
|
876
|
+
await bridgeOtaCommands.endOta(deviceId);
|
|
877
|
+
progressCallback("Uploading application...", 0.32);
|
|
878
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "applicationUploadBegin");
|
|
879
|
+
await bridgeOtaCommands.beginOta(deviceId);
|
|
880
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "applicationUpload");
|
|
881
|
+
await uploadOta(deviceId, firmware, (str, percents) => progressCallback(str, 0.32 + percents * 0.5));
|
|
882
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "applicationUploadEnd");
|
|
883
|
+
await bridgeOtaCommands.endOta(deviceId);
|
|
884
|
+
simulatorSvc.triggerEvent("bridgeOta:success", deviceId);
|
|
885
|
+
progressCallback("Upload completed, disconnecting...", 0.81);
|
|
886
|
+
} catch (error) {
|
|
887
|
+
simulatorSvc.triggerEvent("bridgeOta:error", deviceId);
|
|
888
|
+
throw error;
|
|
889
|
+
} finally {
|
|
890
|
+
await bridgeOta.disconnect(deviceId);
|
|
891
|
+
progressCallback("Disconnected...", 1);
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
async onUpdateFirmwareStatus(callback) {
|
|
895
|
+
simulatorSvc.registerEvent("bridgeOta:status", callback);
|
|
896
|
+
},
|
|
897
|
+
async onUpdateFirmwareSuccess(callback) {
|
|
898
|
+
simulatorSvc.registerEvent("bridgeOta:success", callback);
|
|
899
|
+
},
|
|
900
|
+
async onUpdateFirmwareError(callback) {
|
|
901
|
+
simulatorSvc.registerEvent("bridgeOta:error", callback);
|
|
843
902
|
}
|
|
844
903
|
};
|
|
845
904
|
async function uploadOta(deviceId, firmwareBinary, reportStatus) {
|
|
@@ -878,6 +937,15 @@ const bridgeOta = {
|
|
|
878
937
|
},
|
|
879
938
|
async updateFirmware(deviceId, bootloader, firmware, progressCallback) {
|
|
880
939
|
return bridgeOtaService.updateFirmware(deviceId, bootloader, firmware, progressCallback);
|
|
940
|
+
},
|
|
941
|
+
async onUpdateFirmwareStatus(callback) {
|
|
942
|
+
return bridgeOtaService.onUpdateFirmwareStatus(callback);
|
|
943
|
+
},
|
|
944
|
+
async onUpdateFirmwareSuccess(callback) {
|
|
945
|
+
return bridgeOtaService.onUpdateFirmwareSuccess(callback);
|
|
946
|
+
},
|
|
947
|
+
async onUpdateFirmwareError(callback) {
|
|
948
|
+
return bridgeOtaService.onUpdateFirmwareError(callback);
|
|
881
949
|
}
|
|
882
950
|
};
|
|
883
951
|
|
|
@@ -2155,10 +2223,16 @@ function bridgeVehiclesDifference(original, change) {
|
|
|
2155
2223
|
const differences = [];
|
|
2156
2224
|
if (original.vin !== change.vin || original.vinExtension !== change.vinExtension) differences.push("vin");
|
|
2157
2225
|
const originalTyres = original.tcTyres.map((t) => {
|
|
2158
|
-
return {
|
|
2226
|
+
return {
|
|
2227
|
+
positionId: t.mountedOn?.positionId,
|
|
2228
|
+
sensorId: t.tcTpmsSensor?.id || null
|
|
2229
|
+
};
|
|
2159
2230
|
});
|
|
2160
2231
|
const changeTyres = change.tcTyres?.map((t) => {
|
|
2161
|
-
return {
|
|
2232
|
+
return {
|
|
2233
|
+
positionId: t.mountedOn?.positionId,
|
|
2234
|
+
sensorId: t.tcTpmsSensor?.id || null
|
|
2235
|
+
};
|
|
2162
2236
|
});
|
|
2163
2237
|
if (!___default.isEqual(___default.sortBy(changeTyres, "positionId"), ___default.sortBy(originalTyres, "positionId")))
|
|
2164
2238
|
differences.push("sensorPosition");
|
|
@@ -2213,7 +2287,8 @@ async function bridgeConfigurationDifference(original, change) {
|
|
|
2213
2287
|
for (const prop of propertiesToCheck) {
|
|
2214
2288
|
if (!originalAny[prop] || !changeAny[prop]) continue;
|
|
2215
2289
|
for (const key in changeAny[prop]) {
|
|
2216
|
-
if (
|
|
2290
|
+
if (key === "isFactory") continue;
|
|
2291
|
+
if (originalAny[prop][key] !== changeAny[prop][key]) {
|
|
2217
2292
|
differentProps.push(prop);
|
|
2218
2293
|
break;
|
|
2219
2294
|
}
|
|
@@ -2489,7 +2564,11 @@ function getPressureAndTemperatureReadingObjects(rawPressure, rawTemperature) {
|
|
|
2489
2564
|
meas: Math.max(0, measuredPressureAbsolute - 1),
|
|
2490
2565
|
bar: Math.max(0, compensatedPressureAbsolute - 1)
|
|
2491
2566
|
},
|
|
2492
|
-
temperature: {
|
|
2567
|
+
temperature: {
|
|
2568
|
+
raw: rawTemperature,
|
|
2569
|
+
amb: ambientTemperature,
|
|
2570
|
+
celsius: measuredTemperature
|
|
2571
|
+
}
|
|
2493
2572
|
};
|
|
2494
2573
|
}
|
|
2495
2574
|
function getPressureIssue$1(deviceId, eceStatus) {
|
|
@@ -2612,7 +2691,12 @@ async function assignAxles(deviceId, tcVehicle) {
|
|
|
2612
2691
|
const tyreCount = Number.parseInt(activeAxles[index], 16).toString(2).split("").filter((x) => x === "1").length;
|
|
2613
2692
|
if (!tyreCount) continue;
|
|
2614
2693
|
const hasSpareTyre = tyreCount % 2 === 1;
|
|
2615
|
-
const axle = {
|
|
2694
|
+
const axle = {
|
|
2695
|
+
tyresCount: hasSpareTyre ? tyreCount - 1 : tyreCount,
|
|
2696
|
+
isSteer,
|
|
2697
|
+
isDrive,
|
|
2698
|
+
isLift
|
|
2699
|
+
};
|
|
2616
2700
|
const axleWithLimits = await assignAxlePressureLimits(deviceId, tcVehicle, axle, index, axlesPressureData);
|
|
2617
2701
|
tcVehicle.axles.push(axleWithLimits);
|
|
2618
2702
|
if (hasSpareTyre) {
|
|
@@ -2736,30 +2820,6 @@ async function disconnect(deviceId, reason) {
|
|
|
2736
2820
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2737
2821
|
}
|
|
2738
2822
|
|
|
2739
|
-
const callbacks = {};
|
|
2740
|
-
const simulatorSvc = {
|
|
2741
|
-
registerEvent(eventName, callback) {
|
|
2742
|
-
callbacks[eventName] = callback;
|
|
2743
|
-
},
|
|
2744
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2745
|
-
if (payload === void 0) {
|
|
2746
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2747
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2748
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2749
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2750
|
-
}
|
|
2751
|
-
const callback = callbacks[eventName];
|
|
2752
|
-
if (!callback) {
|
|
2753
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2754
|
-
} else {
|
|
2755
|
-
callback(deviceId, payload);
|
|
2756
|
-
}
|
|
2757
|
-
},
|
|
2758
|
-
merge(deviceTemplate, initialData) {
|
|
2759
|
-
return ___default.mergeWith({}, deviceTemplate, initialData, (a, b) => ___default.isArray(b) ? b : void 0);
|
|
2760
|
-
}
|
|
2761
|
-
};
|
|
2762
|
-
|
|
2763
2823
|
const flexiGaugeTpmsMeta$1 = deviceMeta.flexiGaugeTpms;
|
|
2764
2824
|
const flexiGaugeCommands = {
|
|
2765
2825
|
getBattery: getBattery$1,
|
package/dist/index.d.cts
CHANGED
|
@@ -64,7 +64,11 @@ declare const _default$1: {
|
|
|
64
64
|
bridgeOta: {
|
|
65
65
|
nameRegex: RegExp;
|
|
66
66
|
mtu: number;
|
|
67
|
-
|
|
67
|
+
control: {
|
|
68
|
+
serviceId: string;
|
|
69
|
+
characteristicId: string;
|
|
70
|
+
};
|
|
71
|
+
data: {
|
|
68
72
|
serviceId: string;
|
|
69
73
|
characteristicId: string;
|
|
70
74
|
};
|
|
@@ -906,6 +910,9 @@ interface EventHandlers {
|
|
|
906
910
|
'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
|
|
907
911
|
'ps:pressure'?: (deviceId: string, value: number) => void;
|
|
908
912
|
'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
|
|
913
|
+
'bridgeOta:status'?: (deviceId: string, status: string) => void;
|
|
914
|
+
'bridgeOta:success'?: (deviceId: string) => void;
|
|
915
|
+
'bridgeOta:error'?: (deviceId: string, error: string) => void;
|
|
909
916
|
}
|
|
910
917
|
interface TorqueWrenchStartJobParams {
|
|
911
918
|
nuts: number;
|
|
@@ -969,6 +976,9 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
969
976
|
connect(deviceId: string): Promise<void>;
|
|
970
977
|
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
971
978
|
updateFirmware(deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, progressCallback: ReportStatusFn): Promise<void>;
|
|
979
|
+
onUpdateFirmwareStatus(callback: (deviceId: string, status: string) => void): Promise<void>;
|
|
980
|
+
onUpdateFirmwareSuccess(callback: (deviceId: string) => void): Promise<void>;
|
|
981
|
+
onUpdateFirmwareError(callback: (deviceId: string) => void): Promise<void>;
|
|
972
982
|
};
|
|
973
983
|
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
974
984
|
flexiGaugeTpms: {
|
package/dist/index.d.mts
CHANGED
|
@@ -64,7 +64,11 @@ declare const _default$1: {
|
|
|
64
64
|
bridgeOta: {
|
|
65
65
|
nameRegex: RegExp;
|
|
66
66
|
mtu: number;
|
|
67
|
-
|
|
67
|
+
control: {
|
|
68
|
+
serviceId: string;
|
|
69
|
+
characteristicId: string;
|
|
70
|
+
};
|
|
71
|
+
data: {
|
|
68
72
|
serviceId: string;
|
|
69
73
|
characteristicId: string;
|
|
70
74
|
};
|
|
@@ -906,6 +910,9 @@ interface EventHandlers {
|
|
|
906
910
|
'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
|
|
907
911
|
'ps:pressure'?: (deviceId: string, value: number) => void;
|
|
908
912
|
'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
|
|
913
|
+
'bridgeOta:status'?: (deviceId: string, status: string) => void;
|
|
914
|
+
'bridgeOta:success'?: (deviceId: string) => void;
|
|
915
|
+
'bridgeOta:error'?: (deviceId: string, error: string) => void;
|
|
909
916
|
}
|
|
910
917
|
interface TorqueWrenchStartJobParams {
|
|
911
918
|
nuts: number;
|
|
@@ -969,6 +976,9 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
969
976
|
connect(deviceId: string): Promise<void>;
|
|
970
977
|
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
971
978
|
updateFirmware(deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, progressCallback: ReportStatusFn): Promise<void>;
|
|
979
|
+
onUpdateFirmwareStatus(callback: (deviceId: string, status: string) => void): Promise<void>;
|
|
980
|
+
onUpdateFirmwareSuccess(callback: (deviceId: string) => void): Promise<void>;
|
|
981
|
+
onUpdateFirmwareError(callback: (deviceId: string) => void): Promise<void>;
|
|
972
982
|
};
|
|
973
983
|
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
974
984
|
flexiGaugeTpms: {
|
package/dist/index.d.ts
CHANGED
|
@@ -64,7 +64,11 @@ declare const _default$1: {
|
|
|
64
64
|
bridgeOta: {
|
|
65
65
|
nameRegex: RegExp;
|
|
66
66
|
mtu: number;
|
|
67
|
-
|
|
67
|
+
control: {
|
|
68
|
+
serviceId: string;
|
|
69
|
+
characteristicId: string;
|
|
70
|
+
};
|
|
71
|
+
data: {
|
|
68
72
|
serviceId: string;
|
|
69
73
|
characteristicId: string;
|
|
70
74
|
};
|
|
@@ -906,6 +910,9 @@ interface EventHandlers {
|
|
|
906
910
|
'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
|
|
907
911
|
'ps:pressure'?: (deviceId: string, value: number) => void;
|
|
908
912
|
'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
|
|
913
|
+
'bridgeOta:status'?: (deviceId: string, status: string) => void;
|
|
914
|
+
'bridgeOta:success'?: (deviceId: string) => void;
|
|
915
|
+
'bridgeOta:error'?: (deviceId: string, error: string) => void;
|
|
909
916
|
}
|
|
910
917
|
interface TorqueWrenchStartJobParams {
|
|
911
918
|
nuts: number;
|
|
@@ -969,6 +976,9 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
969
976
|
connect(deviceId: string): Promise<void>;
|
|
970
977
|
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
971
978
|
updateFirmware(deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, progressCallback: ReportStatusFn): Promise<void>;
|
|
979
|
+
onUpdateFirmwareStatus(callback: (deviceId: string, status: string) => void): Promise<void>;
|
|
980
|
+
onUpdateFirmwareSuccess(callback: (deviceId: string) => void): Promise<void>;
|
|
981
|
+
onUpdateFirmwareError(callback: (deviceId: string) => void): Promise<void>;
|
|
972
982
|
};
|
|
973
983
|
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
974
984
|
flexiGaugeTpms: {
|
package/dist/index.mjs
CHANGED
|
@@ -514,7 +514,7 @@ const bridgeOtaAdvertisingParser = {
|
|
|
514
514
|
|
|
515
515
|
const deviceMeta = {
|
|
516
516
|
bridge: {
|
|
517
|
-
nameRegex: /^(030303|030321|030632)$/,
|
|
517
|
+
nameRegex: /^(030303|030321|030632|KSC-B3)$/,
|
|
518
518
|
communication: {
|
|
519
519
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
520
520
|
// message from device
|
|
@@ -526,9 +526,13 @@ const deviceMeta = {
|
|
|
526
526
|
bridgeOta: {
|
|
527
527
|
nameRegex: /(CAN BLE BRDG OTA.*|0303.{2}_B|030632_B)/,
|
|
528
528
|
mtu: 180,
|
|
529
|
-
|
|
530
|
-
serviceId: "
|
|
531
|
-
characteristicId: "
|
|
529
|
+
control: {
|
|
530
|
+
serviceId: "1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0",
|
|
531
|
+
characteristicId: "f7bf3564-fb6d-4e53-88a4-5e37e0326063"
|
|
532
|
+
},
|
|
533
|
+
data: {
|
|
534
|
+
serviceId: "1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0",
|
|
535
|
+
characteristicId: "984227f3-34fc-4045-a5d0-2c581f81a153"
|
|
532
536
|
},
|
|
533
537
|
getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
|
|
534
538
|
},
|
|
@@ -802,18 +806,51 @@ function getDeviceNameFromAdvertising(advertising) {
|
|
|
802
806
|
return deviceName;
|
|
803
807
|
}
|
|
804
808
|
|
|
805
|
-
const
|
|
806
|
-
const
|
|
807
|
-
|
|
809
|
+
const callbacks = {};
|
|
810
|
+
const simulatorSvc = {
|
|
811
|
+
registerEvent(eventName, callback) {
|
|
812
|
+
callbacks[eventName] = callback;
|
|
813
|
+
},
|
|
814
|
+
triggerEvent(eventName, deviceId, payload) {
|
|
815
|
+
if (payload && store.simulatedDevices[deviceId]) {
|
|
816
|
+
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
817
|
+
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
818
|
+
if (!payload) throw new Error(`Event not found`);
|
|
819
|
+
}
|
|
820
|
+
const callback = callbacks[eventName];
|
|
821
|
+
if (!callback) {
|
|
822
|
+
console.warn(`Event ${eventName} not registered`);
|
|
823
|
+
} else {
|
|
824
|
+
callback(deviceId, payload);
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
merge(deviceTemplate, initialData) {
|
|
828
|
+
return _.mergeWith({}, deviceTemplate, initialData, (a, b) => _.isArray(b) ? b : void 0);
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
const bridgeOtaMeta = deviceMeta.bridgeOta;
|
|
808
833
|
const bridgeOtaCommands = {
|
|
809
834
|
async beginOta(deviceId) {
|
|
810
|
-
await bluetooth.write(
|
|
835
|
+
await bluetooth.write(
|
|
836
|
+
deviceId,
|
|
837
|
+
bridgeOtaMeta.control.serviceId,
|
|
838
|
+
bridgeOtaMeta.control.characteristicId,
|
|
839
|
+
new Uint8Array([0]).buffer,
|
|
840
|
+
true
|
|
841
|
+
);
|
|
811
842
|
},
|
|
812
843
|
async uploadOtaChunk(deviceId, data) {
|
|
813
|
-
await bluetooth.write(deviceId,
|
|
844
|
+
await bluetooth.write(deviceId, bridgeOtaMeta.data.serviceId, bridgeOtaMeta.data.characteristicId, data, true);
|
|
814
845
|
},
|
|
815
846
|
async endOta(deviceId) {
|
|
816
|
-
await bluetooth.write(
|
|
847
|
+
await bluetooth.write(
|
|
848
|
+
deviceId,
|
|
849
|
+
bridgeOtaMeta.control.serviceId,
|
|
850
|
+
bridgeOtaMeta.control.characteristicId,
|
|
851
|
+
new Uint8Array([3]).buffer,
|
|
852
|
+
true
|
|
853
|
+
);
|
|
817
854
|
}
|
|
818
855
|
};
|
|
819
856
|
|
|
@@ -822,17 +859,39 @@ const bridgeOtaService = {
|
|
|
822
859
|
await delay(2e3);
|
|
823
860
|
progressCallback("Connecting to the bridge...", 0.1);
|
|
824
861
|
await bridgeOta.connect(deviceId);
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
862
|
+
try {
|
|
863
|
+
progressCallback("Uploading bootloader...", 0.12);
|
|
864
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "bootloaderUploadBegin");
|
|
865
|
+
await bridgeOtaCommands.beginOta(deviceId);
|
|
866
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "bootloaderUpload");
|
|
867
|
+
await uploadOta(deviceId, bootloader, (str, percents) => progressCallback(str, 0.12 + percents * 0.2));
|
|
868
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "bootloaderUploadEnd");
|
|
869
|
+
await bridgeOtaCommands.endOta(deviceId);
|
|
870
|
+
progressCallback("Uploading application...", 0.32);
|
|
871
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "applicationUploadBegin");
|
|
872
|
+
await bridgeOtaCommands.beginOta(deviceId);
|
|
873
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "applicationUpload");
|
|
874
|
+
await uploadOta(deviceId, firmware, (str, percents) => progressCallback(str, 0.32 + percents * 0.5));
|
|
875
|
+
simulatorSvc.triggerEvent("bridgeOta:status", deviceId, "applicationUploadEnd");
|
|
876
|
+
await bridgeOtaCommands.endOta(deviceId);
|
|
877
|
+
simulatorSvc.triggerEvent("bridgeOta:success", deviceId);
|
|
878
|
+
progressCallback("Upload completed, disconnecting...", 0.81);
|
|
879
|
+
} catch (error) {
|
|
880
|
+
simulatorSvc.triggerEvent("bridgeOta:error", deviceId);
|
|
881
|
+
throw error;
|
|
882
|
+
} finally {
|
|
883
|
+
await bridgeOta.disconnect(deviceId);
|
|
884
|
+
progressCallback("Disconnected...", 1);
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
async onUpdateFirmwareStatus(callback) {
|
|
888
|
+
simulatorSvc.registerEvent("bridgeOta:status", callback);
|
|
889
|
+
},
|
|
890
|
+
async onUpdateFirmwareSuccess(callback) {
|
|
891
|
+
simulatorSvc.registerEvent("bridgeOta:success", callback);
|
|
892
|
+
},
|
|
893
|
+
async onUpdateFirmwareError(callback) {
|
|
894
|
+
simulatorSvc.registerEvent("bridgeOta:error", callback);
|
|
836
895
|
}
|
|
837
896
|
};
|
|
838
897
|
async function uploadOta(deviceId, firmwareBinary, reportStatus) {
|
|
@@ -871,6 +930,15 @@ const bridgeOta = {
|
|
|
871
930
|
},
|
|
872
931
|
async updateFirmware(deviceId, bootloader, firmware, progressCallback) {
|
|
873
932
|
return bridgeOtaService.updateFirmware(deviceId, bootloader, firmware, progressCallback);
|
|
933
|
+
},
|
|
934
|
+
async onUpdateFirmwareStatus(callback) {
|
|
935
|
+
return bridgeOtaService.onUpdateFirmwareStatus(callback);
|
|
936
|
+
},
|
|
937
|
+
async onUpdateFirmwareSuccess(callback) {
|
|
938
|
+
return bridgeOtaService.onUpdateFirmwareSuccess(callback);
|
|
939
|
+
},
|
|
940
|
+
async onUpdateFirmwareError(callback) {
|
|
941
|
+
return bridgeOtaService.onUpdateFirmwareError(callback);
|
|
874
942
|
}
|
|
875
943
|
};
|
|
876
944
|
|
|
@@ -2148,10 +2216,16 @@ function bridgeVehiclesDifference(original, change) {
|
|
|
2148
2216
|
const differences = [];
|
|
2149
2217
|
if (original.vin !== change.vin || original.vinExtension !== change.vinExtension) differences.push("vin");
|
|
2150
2218
|
const originalTyres = original.tcTyres.map((t) => {
|
|
2151
|
-
return {
|
|
2219
|
+
return {
|
|
2220
|
+
positionId: t.mountedOn?.positionId,
|
|
2221
|
+
sensorId: t.tcTpmsSensor?.id || null
|
|
2222
|
+
};
|
|
2152
2223
|
});
|
|
2153
2224
|
const changeTyres = change.tcTyres?.map((t) => {
|
|
2154
|
-
return {
|
|
2225
|
+
return {
|
|
2226
|
+
positionId: t.mountedOn?.positionId,
|
|
2227
|
+
sensorId: t.tcTpmsSensor?.id || null
|
|
2228
|
+
};
|
|
2155
2229
|
});
|
|
2156
2230
|
if (!_.isEqual(_.sortBy(changeTyres, "positionId"), _.sortBy(originalTyres, "positionId")))
|
|
2157
2231
|
differences.push("sensorPosition");
|
|
@@ -2206,7 +2280,8 @@ async function bridgeConfigurationDifference(original, change) {
|
|
|
2206
2280
|
for (const prop of propertiesToCheck) {
|
|
2207
2281
|
if (!originalAny[prop] || !changeAny[prop]) continue;
|
|
2208
2282
|
for (const key in changeAny[prop]) {
|
|
2209
|
-
if (
|
|
2283
|
+
if (key === "isFactory") continue;
|
|
2284
|
+
if (originalAny[prop][key] !== changeAny[prop][key]) {
|
|
2210
2285
|
differentProps.push(prop);
|
|
2211
2286
|
break;
|
|
2212
2287
|
}
|
|
@@ -2482,7 +2557,11 @@ function getPressureAndTemperatureReadingObjects(rawPressure, rawTemperature) {
|
|
|
2482
2557
|
meas: Math.max(0, measuredPressureAbsolute - 1),
|
|
2483
2558
|
bar: Math.max(0, compensatedPressureAbsolute - 1)
|
|
2484
2559
|
},
|
|
2485
|
-
temperature: {
|
|
2560
|
+
temperature: {
|
|
2561
|
+
raw: rawTemperature,
|
|
2562
|
+
amb: ambientTemperature,
|
|
2563
|
+
celsius: measuredTemperature
|
|
2564
|
+
}
|
|
2486
2565
|
};
|
|
2487
2566
|
}
|
|
2488
2567
|
function getPressureIssue$1(deviceId, eceStatus) {
|
|
@@ -2605,7 +2684,12 @@ async function assignAxles(deviceId, tcVehicle) {
|
|
|
2605
2684
|
const tyreCount = Number.parseInt(activeAxles[index], 16).toString(2).split("").filter((x) => x === "1").length;
|
|
2606
2685
|
if (!tyreCount) continue;
|
|
2607
2686
|
const hasSpareTyre = tyreCount % 2 === 1;
|
|
2608
|
-
const axle = {
|
|
2687
|
+
const axle = {
|
|
2688
|
+
tyresCount: hasSpareTyre ? tyreCount - 1 : tyreCount,
|
|
2689
|
+
isSteer,
|
|
2690
|
+
isDrive,
|
|
2691
|
+
isLift
|
|
2692
|
+
};
|
|
2609
2693
|
const axleWithLimits = await assignAxlePressureLimits(deviceId, tcVehicle, axle, index, axlesPressureData);
|
|
2610
2694
|
tcVehicle.axles.push(axleWithLimits);
|
|
2611
2695
|
if (hasSpareTyre) {
|
|
@@ -2729,30 +2813,6 @@ async function disconnect(deviceId, reason) {
|
|
|
2729
2813
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2730
2814
|
}
|
|
2731
2815
|
|
|
2732
|
-
const callbacks = {};
|
|
2733
|
-
const simulatorSvc = {
|
|
2734
|
-
registerEvent(eventName, callback) {
|
|
2735
|
-
callbacks[eventName] = callback;
|
|
2736
|
-
},
|
|
2737
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2738
|
-
if (payload === void 0) {
|
|
2739
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2740
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2741
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2742
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2743
|
-
}
|
|
2744
|
-
const callback = callbacks[eventName];
|
|
2745
|
-
if (!callback) {
|
|
2746
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2747
|
-
} else {
|
|
2748
|
-
callback(deviceId, payload);
|
|
2749
|
-
}
|
|
2750
|
-
},
|
|
2751
|
-
merge(deviceTemplate, initialData) {
|
|
2752
|
-
return _.mergeWith({}, deviceTemplate, initialData, (a, b) => _.isArray(b) ? b : void 0);
|
|
2753
|
-
}
|
|
2754
|
-
};
|
|
2755
|
-
|
|
2756
2816
|
const flexiGaugeTpmsMeta$1 = deviceMeta.flexiGaugeTpms;
|
|
2757
2817
|
const flexiGaugeCommands = {
|
|
2758
2818
|
getBattery: getBattery$1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.55",
|
|
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",
|