tirecheck-device-sdk 0.2.28 → 0.2.30
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 +81 -46
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +81 -46
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2750,30 +2750,6 @@ async function disconnect(deviceId, reason) {
|
|
|
2750
2750
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2751
2751
|
}
|
|
2752
2752
|
|
|
2753
|
-
const callbacks = {};
|
|
2754
|
-
const simulatorSvc = {
|
|
2755
|
-
registerEvent(eventName, callback) {
|
|
2756
|
-
callbacks[eventName] = callback;
|
|
2757
|
-
},
|
|
2758
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2759
|
-
if (payload === void 0) {
|
|
2760
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2761
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2762
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2763
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2764
|
-
}
|
|
2765
|
-
const callback = callbacks[eventName];
|
|
2766
|
-
if (!callback) {
|
|
2767
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2768
|
-
} else {
|
|
2769
|
-
callback(deviceId, payload);
|
|
2770
|
-
}
|
|
2771
|
-
},
|
|
2772
|
-
merge(deviceTemplate, initialData) {
|
|
2773
|
-
return ___default.mergeWith({}, deviceTemplate, initialData, (a, b) => ___default.isArray(b) ? b : void 0);
|
|
2774
|
-
}
|
|
2775
|
-
};
|
|
2776
|
-
|
|
2777
2753
|
const devicePromiseQueue = {};
|
|
2778
2754
|
const deviceCurrentResolve = {};
|
|
2779
2755
|
const deviceCurrentReject = {};
|
|
@@ -2828,6 +2804,30 @@ const promiseQueue = {
|
|
|
2828
2804
|
}
|
|
2829
2805
|
};
|
|
2830
2806
|
|
|
2807
|
+
const callbacks = {};
|
|
2808
|
+
const simulatorSvc = {
|
|
2809
|
+
registerEvent(eventName, callback) {
|
|
2810
|
+
callbacks[eventName] = callback;
|
|
2811
|
+
},
|
|
2812
|
+
triggerEvent(eventName, deviceId, payload) {
|
|
2813
|
+
if (payload === void 0) {
|
|
2814
|
+
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2815
|
+
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2816
|
+
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2817
|
+
if (!payload) throw new Error(`Event not found`);
|
|
2818
|
+
}
|
|
2819
|
+
const callback = callbacks[eventName];
|
|
2820
|
+
if (!callback) {
|
|
2821
|
+
console.warn(`Event ${eventName} not registered`);
|
|
2822
|
+
} else {
|
|
2823
|
+
callback(deviceId, payload);
|
|
2824
|
+
}
|
|
2825
|
+
},
|
|
2826
|
+
merge(deviceTemplate, initialData) {
|
|
2827
|
+
return ___default.mergeWith({}, deviceTemplate, initialData, (a, b) => ___default.isArray(b) ? b : void 0);
|
|
2828
|
+
}
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2831
2831
|
const flexiGaugeTpmsSecurity = {
|
|
2832
2832
|
getCommandsSignature(seed) {
|
|
2833
2833
|
const key = store.securityKeys?.flexiGaugeTpms?.signatureKeys.allLFCommands;
|
|
@@ -2885,7 +2885,8 @@ const flexiGaugeTpmsCommands = {
|
|
|
2885
2885
|
vdaSendConfiguration,
|
|
2886
2886
|
vdaRequestCommandsAccess,
|
|
2887
2887
|
vdaRequestWriteAccess,
|
|
2888
|
-
processMessage
|
|
2888
|
+
processMessage,
|
|
2889
|
+
getFirmwareVersion: getFirmwareVersion$1
|
|
2889
2890
|
};
|
|
2890
2891
|
async function startTpmsScan(deviceId) {
|
|
2891
2892
|
if (!canCommunicateWith(deviceId)) throw new Error("Flexi Gauge not connected");
|
|
@@ -2906,24 +2907,28 @@ async function getBattery(deviceId) {
|
|
|
2906
2907
|
const battery = Array.from(new Uint8Array(batteryValue))[0];
|
|
2907
2908
|
return battery;
|
|
2908
2909
|
}
|
|
2910
|
+
async function getFirmwareVersion$1(deviceId) {
|
|
2911
|
+
const msg = "*FWVER?";
|
|
2912
|
+
return sendCommand(deviceId, msg, "FWV");
|
|
2913
|
+
}
|
|
2909
2914
|
async function vdaRequestSensor(deviceId) {
|
|
2910
2915
|
const scanMsg = "*VDA_LF_SEND SID=A0 LID=1A";
|
|
2911
|
-
return
|
|
2916
|
+
return sendCommand(deviceId, scanMsg);
|
|
2912
2917
|
}
|
|
2913
2918
|
async function vdaRequestSeed(deviceId, sensorId) {
|
|
2914
2919
|
const sensorIdReversed = getReversedSensorId(sensorId);
|
|
2915
2920
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=AA PAR=04 DATA=${sensorIdReversed}CE9A5713`;
|
|
2916
|
-
return
|
|
2921
|
+
return sendCommand(deviceId, scanMsg);
|
|
2917
2922
|
}
|
|
2918
2923
|
async function vdaRequestCommandsAccess(deviceId, sensorId, signature) {
|
|
2919
2924
|
const sensorIdReversed = getReversedSensorId(sensorId);
|
|
2920
2925
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=AA PAR=00 DATA=${sensorIdReversed}${signature}`;
|
|
2921
|
-
return
|
|
2926
|
+
return sendCommand(deviceId, scanMsg);
|
|
2922
2927
|
}
|
|
2923
2928
|
async function vdaRequestWriteAccess(deviceId, sensorId, signature) {
|
|
2924
2929
|
const sensorIdReversed = getReversedSensorId(sensorId);
|
|
2925
2930
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=AA PAR=02 DATA=${sensorIdReversed}${signature}`;
|
|
2926
|
-
return
|
|
2931
|
+
return sendCommand(deviceId, scanMsg);
|
|
2927
2932
|
}
|
|
2928
2933
|
async function vdaSendWriteModePin(deviceId) {
|
|
2929
2934
|
const scanMsg = stringToArrayBuffer("*VDA_LF_SEND SID=A0 LID=AA PAR=00 DATA=FCCC71F6\r\n");
|
|
@@ -2936,21 +2941,21 @@ async function vdaSendWriteModePin(deviceId) {
|
|
|
2936
2941
|
}
|
|
2937
2942
|
async function vdaReadConfiguration(deviceId) {
|
|
2938
2943
|
const scanMsg = "*VDA_LF_SEND SID=A0 LID=DA PAR=17";
|
|
2939
|
-
return
|
|
2944
|
+
return sendCommand(deviceId, scanMsg);
|
|
2940
2945
|
}
|
|
2941
2946
|
async function vdaSendConfiguration(deviceId, configuration) {
|
|
2942
2947
|
if (configuration.length !== 60) throw new Error("Invalid sensor configuration");
|
|
2943
2948
|
const crc = flexiGaugeTpmsSecurity.getCrc(configuration);
|
|
2944
2949
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=EA PAR=17 DATA=${configuration}${crc}`;
|
|
2945
|
-
return
|
|
2950
|
+
return sendCommand(deviceId, scanMsg);
|
|
2946
2951
|
}
|
|
2947
|
-
async function sendCommand(deviceId, command) {
|
|
2952
|
+
async function sendCommand(deviceId, command, identifier = "VDA") {
|
|
2948
2953
|
const message = `${command}\r
|
|
2949
2954
|
`;
|
|
2950
2955
|
const decimalArray = stringToDecimalArray(message);
|
|
2951
2956
|
let result;
|
|
2952
2957
|
try {
|
|
2953
|
-
result = await promiseQueue.enqueue(deviceId, flexiGaugeTpmsMeta.communication, decimalArray,
|
|
2958
|
+
result = await promiseQueue.enqueue(deviceId, flexiGaugeTpmsMeta.communication, decimalArray, identifier);
|
|
2954
2959
|
} catch (error) {
|
|
2955
2960
|
flexiGaugeTpms.disconnect(deviceId, "lostConnection");
|
|
2956
2961
|
throw error;
|
|
@@ -3021,7 +3026,8 @@ const flexiGaugeTpmsService = {
|
|
|
3021
3026
|
}
|
|
3022
3027
|
flexiGaugeTpmsCommands.processMessage(deviceId, message);
|
|
3023
3028
|
},
|
|
3024
|
-
|
|
3029
|
+
setSensorDisplayId,
|
|
3030
|
+
getFirmwareVersion
|
|
3025
3031
|
};
|
|
3026
3032
|
function processTreadDepth(deviceId, value) {
|
|
3027
3033
|
const treadDepth = value.match(/\d+/)?.[0];
|
|
@@ -3060,7 +3066,9 @@ function processTpms(deviceId, value) {
|
|
|
3060
3066
|
simulatorSvc.triggerEvent("fg:tpms", deviceId, strongestReading);
|
|
3061
3067
|
}
|
|
3062
3068
|
}
|
|
3063
|
-
async function
|
|
3069
|
+
async function setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
|
|
3070
|
+
const fw = await getFirmwareVersion(deviceId);
|
|
3071
|
+
if (fw < "1.4.4") throw new Error("Programming sensors is not supported on this firmware version");
|
|
3064
3072
|
await findSensor(deviceId, oldSensorId);
|
|
3065
3073
|
const seed = await getSeed(deviceId, oldSensorId);
|
|
3066
3074
|
const commandsSignature = await flexiGaugeTpmsSecurity.getCommandsSignature(seed);
|
|
@@ -3073,36 +3081,53 @@ async function programSensor(deviceId, oldSensorId, newSensorId) {
|
|
|
3073
3081
|
await findSensor(deviceId, newSensorId);
|
|
3074
3082
|
}
|
|
3075
3083
|
async function getSeed(deviceId, sensorId) {
|
|
3076
|
-
|
|
3077
|
-
|
|
3084
|
+
try {
|
|
3085
|
+
const response = await vdaRepeat(() => flexiGaugeTpmsCommands.vdaRequestSeed(deviceId, sensorId));
|
|
3086
|
+
return response[3];
|
|
3087
|
+
} catch {
|
|
3088
|
+
throw new Error("Failed to get signature seed");
|
|
3089
|
+
}
|
|
3078
3090
|
}
|
|
3079
3091
|
async function findSensor(deviceId, sensorId) {
|
|
3080
3092
|
let seen = 0;
|
|
3081
|
-
for (let i = 0; i <
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3093
|
+
for (let i = 0; i < 6; i++) {
|
|
3094
|
+
try {
|
|
3095
|
+
const response = await vdaRepeat(() => flexiGaugeTpmsCommands.vdaRequestSensor(deviceId));
|
|
3096
|
+
if (response[2] === sensorId) seen++;
|
|
3097
|
+
if (seen === 3) return;
|
|
3098
|
+
} catch {
|
|
3099
|
+
}
|
|
3085
3100
|
}
|
|
3086
3101
|
throw new Error(`Sensor ${sensorId} not found`);
|
|
3087
3102
|
}
|
|
3088
3103
|
async function getSensorConfiguration(deviceId) {
|
|
3089
|
-
|
|
3090
|
-
|
|
3104
|
+
try {
|
|
3105
|
+
const response = await vdaRepeat(() => flexiGaugeTpmsCommands.vdaReadConfiguration(deviceId));
|
|
3106
|
+
return response[3].slice(2, -4);
|
|
3107
|
+
} catch {
|
|
3108
|
+
throw new Error("Failed to get sensor configuration");
|
|
3109
|
+
}
|
|
3091
3110
|
}
|
|
3092
3111
|
async function vdaRepeat(fn) {
|
|
3093
3112
|
for (let i = 0; i < 5; i++) {
|
|
3094
|
-
const response = await fn;
|
|
3113
|
+
const response = await fn();
|
|
3095
3114
|
const groupedValue = response.split(" ");
|
|
3096
3115
|
if (groupedValue[1].includes("TIMEOUT")) continue;
|
|
3097
3116
|
if (response) return groupedValue;
|
|
3098
3117
|
}
|
|
3099
3118
|
throw new Error("VDA Timeout");
|
|
3100
3119
|
}
|
|
3120
|
+
async function getFirmwareVersion(deviceId) {
|
|
3121
|
+
const response = await flexiGaugeTpmsCommands.getFirmwareVersion(deviceId);
|
|
3122
|
+
const groupedValue = response.split(" ");
|
|
3123
|
+
return groupedValue[1];
|
|
3124
|
+
}
|
|
3101
3125
|
|
|
3102
3126
|
const flexiGaugeTpms = {
|
|
3103
3127
|
async connect(deviceId) {
|
|
3104
3128
|
const fgMeta = deviceMeta.flexiGaugeTpms;
|
|
3105
3129
|
await bluetooth.connect(deviceId, this.disconnect);
|
|
3130
|
+
await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
|
|
3106
3131
|
await ble.startNotification(
|
|
3107
3132
|
deviceId,
|
|
3108
3133
|
fgMeta.communication.serviceId,
|
|
@@ -3114,6 +3139,7 @@ const flexiGaugeTpms = {
|
|
|
3114
3139
|
},
|
|
3115
3140
|
async disconnect(deviceId, reason) {
|
|
3116
3141
|
store.setState(deviceId, "disconnecting");
|
|
3142
|
+
await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
|
|
3117
3143
|
await bluetooth.disconnect(deviceId);
|
|
3118
3144
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
3119
3145
|
},
|
|
@@ -3121,8 +3147,10 @@ const flexiGaugeTpms = {
|
|
|
3121
3147
|
onButtonPress: flexiGaugeTpmsService.onButton,
|
|
3122
3148
|
onTpms: flexiGaugeTpmsService.onTpms,
|
|
3123
3149
|
getBattery: flexiGaugeTpmsService.getBattery,
|
|
3150
|
+
getFirmwareVersion: flexiGaugeTpmsService.getFirmwareVersion,
|
|
3124
3151
|
startTpmsScan: flexiGaugeTpmsService.startTpmsScan,
|
|
3125
|
-
|
|
3152
|
+
setSensorDisplayId: flexiGaugeTpmsService.setSensorDisplayId,
|
|
3153
|
+
resetSensorDisplayId: (deviceId, sensorId) => flexiGaugeTpmsService.setSensorDisplayId(deviceId, sensorId, "00000000")
|
|
3126
3154
|
};
|
|
3127
3155
|
|
|
3128
3156
|
const capabilities = [
|
|
@@ -3796,9 +3824,16 @@ const flexiGaugeTpmsSimulator = {
|
|
|
3796
3824
|
await toolsSvc.delay(200);
|
|
3797
3825
|
return fg.simulatorData.battery;
|
|
3798
3826
|
},
|
|
3799
|
-
|
|
3827
|
+
setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
|
|
3800
3828
|
return new Promise((resolve) => resolve());
|
|
3801
3829
|
},
|
|
3830
|
+
resetSensorDisplayId(deviceId, sensorId) {
|
|
3831
|
+
return new Promise((resolve) => resolve());
|
|
3832
|
+
},
|
|
3833
|
+
async getFirmwareVersion(deviceId) {
|
|
3834
|
+
await toolsSvc.delay(100);
|
|
3835
|
+
return "9.9.9";
|
|
3836
|
+
},
|
|
3802
3837
|
onButtonPress(callback) {
|
|
3803
3838
|
},
|
|
3804
3839
|
onTpms(callback) {
|
package/dist/index.d.cts
CHANGED
|
@@ -927,8 +927,10 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
927
927
|
onButtonPress: (callback: (deviceId: string, value: string) => void) => void;
|
|
928
928
|
onTpms: (callback: (deviceId: string, value: FgSensorReading | undefined) => void) => void;
|
|
929
929
|
getBattery: (deviceId: string) => Promise<number>;
|
|
930
|
+
getFirmwareVersion: (deviceId: string) => Promise<string>;
|
|
930
931
|
startTpmsScan: (deviceId: string) => void;
|
|
931
|
-
|
|
932
|
+
setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
|
|
933
|
+
resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
|
|
932
934
|
};
|
|
933
935
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
934
936
|
pressureStick: {
|
package/dist/index.d.mts
CHANGED
|
@@ -927,8 +927,10 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
927
927
|
onButtonPress: (callback: (deviceId: string, value: string) => void) => void;
|
|
928
928
|
onTpms: (callback: (deviceId: string, value: FgSensorReading | undefined) => void) => void;
|
|
929
929
|
getBattery: (deviceId: string) => Promise<number>;
|
|
930
|
+
getFirmwareVersion: (deviceId: string) => Promise<string>;
|
|
930
931
|
startTpmsScan: (deviceId: string) => void;
|
|
931
|
-
|
|
932
|
+
setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
|
|
933
|
+
resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
|
|
932
934
|
};
|
|
933
935
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
934
936
|
pressureStick: {
|
package/dist/index.d.ts
CHANGED
|
@@ -927,8 +927,10 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
927
927
|
onButtonPress: (callback: (deviceId: string, value: string) => void) => void;
|
|
928
928
|
onTpms: (callback: (deviceId: string, value: FgSensorReading | undefined) => void) => void;
|
|
929
929
|
getBattery: (deviceId: string) => Promise<number>;
|
|
930
|
+
getFirmwareVersion: (deviceId: string) => Promise<string>;
|
|
930
931
|
startTpmsScan: (deviceId: string) => void;
|
|
931
|
-
|
|
932
|
+
setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
|
|
933
|
+
resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
|
|
932
934
|
};
|
|
933
935
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
934
936
|
pressureStick: {
|
package/dist/index.mjs
CHANGED
|
@@ -2743,30 +2743,6 @@ async function disconnect(deviceId, reason) {
|
|
|
2743
2743
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2744
2744
|
}
|
|
2745
2745
|
|
|
2746
|
-
const callbacks = {};
|
|
2747
|
-
const simulatorSvc = {
|
|
2748
|
-
registerEvent(eventName, callback) {
|
|
2749
|
-
callbacks[eventName] = callback;
|
|
2750
|
-
},
|
|
2751
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2752
|
-
if (payload === void 0) {
|
|
2753
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2754
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2755
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2756
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2757
|
-
}
|
|
2758
|
-
const callback = callbacks[eventName];
|
|
2759
|
-
if (!callback) {
|
|
2760
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2761
|
-
} else {
|
|
2762
|
-
callback(deviceId, payload);
|
|
2763
|
-
}
|
|
2764
|
-
},
|
|
2765
|
-
merge(deviceTemplate, initialData) {
|
|
2766
|
-
return _.mergeWith({}, deviceTemplate, initialData, (a, b) => _.isArray(b) ? b : void 0);
|
|
2767
|
-
}
|
|
2768
|
-
};
|
|
2769
|
-
|
|
2770
2746
|
const devicePromiseQueue = {};
|
|
2771
2747
|
const deviceCurrentResolve = {};
|
|
2772
2748
|
const deviceCurrentReject = {};
|
|
@@ -2821,6 +2797,30 @@ const promiseQueue = {
|
|
|
2821
2797
|
}
|
|
2822
2798
|
};
|
|
2823
2799
|
|
|
2800
|
+
const callbacks = {};
|
|
2801
|
+
const simulatorSvc = {
|
|
2802
|
+
registerEvent(eventName, callback) {
|
|
2803
|
+
callbacks[eventName] = callback;
|
|
2804
|
+
},
|
|
2805
|
+
triggerEvent(eventName, deviceId, payload) {
|
|
2806
|
+
if (payload === void 0) {
|
|
2807
|
+
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2808
|
+
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2809
|
+
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2810
|
+
if (!payload) throw new Error(`Event not found`);
|
|
2811
|
+
}
|
|
2812
|
+
const callback = callbacks[eventName];
|
|
2813
|
+
if (!callback) {
|
|
2814
|
+
console.warn(`Event ${eventName} not registered`);
|
|
2815
|
+
} else {
|
|
2816
|
+
callback(deviceId, payload);
|
|
2817
|
+
}
|
|
2818
|
+
},
|
|
2819
|
+
merge(deviceTemplate, initialData) {
|
|
2820
|
+
return _.mergeWith({}, deviceTemplate, initialData, (a, b) => _.isArray(b) ? b : void 0);
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2823
|
+
|
|
2824
2824
|
const flexiGaugeTpmsSecurity = {
|
|
2825
2825
|
getCommandsSignature(seed) {
|
|
2826
2826
|
const key = store.securityKeys?.flexiGaugeTpms?.signatureKeys.allLFCommands;
|
|
@@ -2878,7 +2878,8 @@ const flexiGaugeTpmsCommands = {
|
|
|
2878
2878
|
vdaSendConfiguration,
|
|
2879
2879
|
vdaRequestCommandsAccess,
|
|
2880
2880
|
vdaRequestWriteAccess,
|
|
2881
|
-
processMessage
|
|
2881
|
+
processMessage,
|
|
2882
|
+
getFirmwareVersion: getFirmwareVersion$1
|
|
2882
2883
|
};
|
|
2883
2884
|
async function startTpmsScan(deviceId) {
|
|
2884
2885
|
if (!canCommunicateWith(deviceId)) throw new Error("Flexi Gauge not connected");
|
|
@@ -2899,24 +2900,28 @@ async function getBattery(deviceId) {
|
|
|
2899
2900
|
const battery = Array.from(new Uint8Array(batteryValue))[0];
|
|
2900
2901
|
return battery;
|
|
2901
2902
|
}
|
|
2903
|
+
async function getFirmwareVersion$1(deviceId) {
|
|
2904
|
+
const msg = "*FWVER?";
|
|
2905
|
+
return sendCommand(deviceId, msg, "FWV");
|
|
2906
|
+
}
|
|
2902
2907
|
async function vdaRequestSensor(deviceId) {
|
|
2903
2908
|
const scanMsg = "*VDA_LF_SEND SID=A0 LID=1A";
|
|
2904
|
-
return
|
|
2909
|
+
return sendCommand(deviceId, scanMsg);
|
|
2905
2910
|
}
|
|
2906
2911
|
async function vdaRequestSeed(deviceId, sensorId) {
|
|
2907
2912
|
const sensorIdReversed = getReversedSensorId(sensorId);
|
|
2908
2913
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=AA PAR=04 DATA=${sensorIdReversed}CE9A5713`;
|
|
2909
|
-
return
|
|
2914
|
+
return sendCommand(deviceId, scanMsg);
|
|
2910
2915
|
}
|
|
2911
2916
|
async function vdaRequestCommandsAccess(deviceId, sensorId, signature) {
|
|
2912
2917
|
const sensorIdReversed = getReversedSensorId(sensorId);
|
|
2913
2918
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=AA PAR=00 DATA=${sensorIdReversed}${signature}`;
|
|
2914
|
-
return
|
|
2919
|
+
return sendCommand(deviceId, scanMsg);
|
|
2915
2920
|
}
|
|
2916
2921
|
async function vdaRequestWriteAccess(deviceId, sensorId, signature) {
|
|
2917
2922
|
const sensorIdReversed = getReversedSensorId(sensorId);
|
|
2918
2923
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=AA PAR=02 DATA=${sensorIdReversed}${signature}`;
|
|
2919
|
-
return
|
|
2924
|
+
return sendCommand(deviceId, scanMsg);
|
|
2920
2925
|
}
|
|
2921
2926
|
async function vdaSendWriteModePin(deviceId) {
|
|
2922
2927
|
const scanMsg = stringToArrayBuffer("*VDA_LF_SEND SID=A0 LID=AA PAR=00 DATA=FCCC71F6\r\n");
|
|
@@ -2929,21 +2934,21 @@ async function vdaSendWriteModePin(deviceId) {
|
|
|
2929
2934
|
}
|
|
2930
2935
|
async function vdaReadConfiguration(deviceId) {
|
|
2931
2936
|
const scanMsg = "*VDA_LF_SEND SID=A0 LID=DA PAR=17";
|
|
2932
|
-
return
|
|
2937
|
+
return sendCommand(deviceId, scanMsg);
|
|
2933
2938
|
}
|
|
2934
2939
|
async function vdaSendConfiguration(deviceId, configuration) {
|
|
2935
2940
|
if (configuration.length !== 60) throw new Error("Invalid sensor configuration");
|
|
2936
2941
|
const crc = flexiGaugeTpmsSecurity.getCrc(configuration);
|
|
2937
2942
|
const scanMsg = `*VDA_LF_SEND SID=A0 LID=EA PAR=17 DATA=${configuration}${crc}`;
|
|
2938
|
-
return
|
|
2943
|
+
return sendCommand(deviceId, scanMsg);
|
|
2939
2944
|
}
|
|
2940
|
-
async function sendCommand(deviceId, command) {
|
|
2945
|
+
async function sendCommand(deviceId, command, identifier = "VDA") {
|
|
2941
2946
|
const message = `${command}\r
|
|
2942
2947
|
`;
|
|
2943
2948
|
const decimalArray = stringToDecimalArray(message);
|
|
2944
2949
|
let result;
|
|
2945
2950
|
try {
|
|
2946
|
-
result = await promiseQueue.enqueue(deviceId, flexiGaugeTpmsMeta.communication, decimalArray,
|
|
2951
|
+
result = await promiseQueue.enqueue(deviceId, flexiGaugeTpmsMeta.communication, decimalArray, identifier);
|
|
2947
2952
|
} catch (error) {
|
|
2948
2953
|
flexiGaugeTpms.disconnect(deviceId, "lostConnection");
|
|
2949
2954
|
throw error;
|
|
@@ -3014,7 +3019,8 @@ const flexiGaugeTpmsService = {
|
|
|
3014
3019
|
}
|
|
3015
3020
|
flexiGaugeTpmsCommands.processMessage(deviceId, message);
|
|
3016
3021
|
},
|
|
3017
|
-
|
|
3022
|
+
setSensorDisplayId,
|
|
3023
|
+
getFirmwareVersion
|
|
3018
3024
|
};
|
|
3019
3025
|
function processTreadDepth(deviceId, value) {
|
|
3020
3026
|
const treadDepth = value.match(/\d+/)?.[0];
|
|
@@ -3053,7 +3059,9 @@ function processTpms(deviceId, value) {
|
|
|
3053
3059
|
simulatorSvc.triggerEvent("fg:tpms", deviceId, strongestReading);
|
|
3054
3060
|
}
|
|
3055
3061
|
}
|
|
3056
|
-
async function
|
|
3062
|
+
async function setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
|
|
3063
|
+
const fw = await getFirmwareVersion(deviceId);
|
|
3064
|
+
if (fw < "1.4.4") throw new Error("Programming sensors is not supported on this firmware version");
|
|
3057
3065
|
await findSensor(deviceId, oldSensorId);
|
|
3058
3066
|
const seed = await getSeed(deviceId, oldSensorId);
|
|
3059
3067
|
const commandsSignature = await flexiGaugeTpmsSecurity.getCommandsSignature(seed);
|
|
@@ -3066,36 +3074,53 @@ async function programSensor(deviceId, oldSensorId, newSensorId) {
|
|
|
3066
3074
|
await findSensor(deviceId, newSensorId);
|
|
3067
3075
|
}
|
|
3068
3076
|
async function getSeed(deviceId, sensorId) {
|
|
3069
|
-
|
|
3070
|
-
|
|
3077
|
+
try {
|
|
3078
|
+
const response = await vdaRepeat(() => flexiGaugeTpmsCommands.vdaRequestSeed(deviceId, sensorId));
|
|
3079
|
+
return response[3];
|
|
3080
|
+
} catch {
|
|
3081
|
+
throw new Error("Failed to get signature seed");
|
|
3082
|
+
}
|
|
3071
3083
|
}
|
|
3072
3084
|
async function findSensor(deviceId, sensorId) {
|
|
3073
3085
|
let seen = 0;
|
|
3074
|
-
for (let i = 0; i <
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3086
|
+
for (let i = 0; i < 6; i++) {
|
|
3087
|
+
try {
|
|
3088
|
+
const response = await vdaRepeat(() => flexiGaugeTpmsCommands.vdaRequestSensor(deviceId));
|
|
3089
|
+
if (response[2] === sensorId) seen++;
|
|
3090
|
+
if (seen === 3) return;
|
|
3091
|
+
} catch {
|
|
3092
|
+
}
|
|
3078
3093
|
}
|
|
3079
3094
|
throw new Error(`Sensor ${sensorId} not found`);
|
|
3080
3095
|
}
|
|
3081
3096
|
async function getSensorConfiguration(deviceId) {
|
|
3082
|
-
|
|
3083
|
-
|
|
3097
|
+
try {
|
|
3098
|
+
const response = await vdaRepeat(() => flexiGaugeTpmsCommands.vdaReadConfiguration(deviceId));
|
|
3099
|
+
return response[3].slice(2, -4);
|
|
3100
|
+
} catch {
|
|
3101
|
+
throw new Error("Failed to get sensor configuration");
|
|
3102
|
+
}
|
|
3084
3103
|
}
|
|
3085
3104
|
async function vdaRepeat(fn) {
|
|
3086
3105
|
for (let i = 0; i < 5; i++) {
|
|
3087
|
-
const response = await fn;
|
|
3106
|
+
const response = await fn();
|
|
3088
3107
|
const groupedValue = response.split(" ");
|
|
3089
3108
|
if (groupedValue[1].includes("TIMEOUT")) continue;
|
|
3090
3109
|
if (response) return groupedValue;
|
|
3091
3110
|
}
|
|
3092
3111
|
throw new Error("VDA Timeout");
|
|
3093
3112
|
}
|
|
3113
|
+
async function getFirmwareVersion(deviceId) {
|
|
3114
|
+
const response = await flexiGaugeTpmsCommands.getFirmwareVersion(deviceId);
|
|
3115
|
+
const groupedValue = response.split(" ");
|
|
3116
|
+
return groupedValue[1];
|
|
3117
|
+
}
|
|
3094
3118
|
|
|
3095
3119
|
const flexiGaugeTpms = {
|
|
3096
3120
|
async connect(deviceId) {
|
|
3097
3121
|
const fgMeta = deviceMeta.flexiGaugeTpms;
|
|
3098
3122
|
await bluetooth.connect(deviceId, this.disconnect);
|
|
3123
|
+
await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
|
|
3099
3124
|
await ble.startNotification(
|
|
3100
3125
|
deviceId,
|
|
3101
3126
|
fgMeta.communication.serviceId,
|
|
@@ -3107,6 +3132,7 @@ const flexiGaugeTpms = {
|
|
|
3107
3132
|
},
|
|
3108
3133
|
async disconnect(deviceId, reason) {
|
|
3109
3134
|
store.setState(deviceId, "disconnecting");
|
|
3135
|
+
await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
|
|
3110
3136
|
await bluetooth.disconnect(deviceId);
|
|
3111
3137
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
3112
3138
|
},
|
|
@@ -3114,8 +3140,10 @@ const flexiGaugeTpms = {
|
|
|
3114
3140
|
onButtonPress: flexiGaugeTpmsService.onButton,
|
|
3115
3141
|
onTpms: flexiGaugeTpmsService.onTpms,
|
|
3116
3142
|
getBattery: flexiGaugeTpmsService.getBattery,
|
|
3143
|
+
getFirmwareVersion: flexiGaugeTpmsService.getFirmwareVersion,
|
|
3117
3144
|
startTpmsScan: flexiGaugeTpmsService.startTpmsScan,
|
|
3118
|
-
|
|
3145
|
+
setSensorDisplayId: flexiGaugeTpmsService.setSensorDisplayId,
|
|
3146
|
+
resetSensorDisplayId: (deviceId, sensorId) => flexiGaugeTpmsService.setSensorDisplayId(deviceId, sensorId, "00000000")
|
|
3119
3147
|
};
|
|
3120
3148
|
|
|
3121
3149
|
const capabilities = [
|
|
@@ -3789,9 +3817,16 @@ const flexiGaugeTpmsSimulator = {
|
|
|
3789
3817
|
await toolsSvc.delay(200);
|
|
3790
3818
|
return fg.simulatorData.battery;
|
|
3791
3819
|
},
|
|
3792
|
-
|
|
3820
|
+
setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
|
|
3793
3821
|
return new Promise((resolve) => resolve());
|
|
3794
3822
|
},
|
|
3823
|
+
resetSensorDisplayId(deviceId, sensorId) {
|
|
3824
|
+
return new Promise((resolve) => resolve());
|
|
3825
|
+
},
|
|
3826
|
+
async getFirmwareVersion(deviceId) {
|
|
3827
|
+
await toolsSvc.delay(100);
|
|
3828
|
+
return "9.9.9";
|
|
3829
|
+
},
|
|
3795
3830
|
onButtonPress(callback) {
|
|
3796
3831
|
},
|
|
3797
3832
|
onTpms(callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.30",
|
|
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",
|