tirecheck-device-sdk 0.2.29 → 0.2.31

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
@@ -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;
@@ -3026,7 +3026,7 @@ const flexiGaugeTpmsService = {
3026
3026
  }
3027
3027
  flexiGaugeTpmsCommands.processMessage(deviceId, message);
3028
3028
  },
3029
- programSensor,
3029
+ setSensorDisplayId,
3030
3030
  getFirmwareVersion
3031
3031
  };
3032
3032
  function processTreadDepth(deviceId, value) {
@@ -3066,7 +3066,7 @@ function processTpms(deviceId, value) {
3066
3066
  simulatorSvc.triggerEvent("fg:tpms", deviceId, strongestReading);
3067
3067
  }
3068
3068
  }
3069
- async function programSensor(deviceId, oldSensorId, newSensorId) {
3069
+ async function setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
3070
3070
  const fw = await getFirmwareVersion(deviceId);
3071
3071
  if (fw < "1.4.4") throw new Error("Programming sensors is not supported on this firmware version");
3072
3072
  await findSensor(deviceId, oldSensorId);
@@ -3078,7 +3078,9 @@ async function programSensor(deviceId, oldSensorId, newSensorId) {
3078
3078
  const config = await getSensorConfiguration(deviceId);
3079
3079
  const newConfig = config.replace(/^.{8}/, newSensorId);
3080
3080
  await flexiGaugeTpmsCommands.vdaSendConfiguration(deviceId, newConfig);
3081
- await findSensor(deviceId, newSensorId);
3081
+ if (newSensorId !== "00000000") {
3082
+ await findSensor(deviceId, newSensorId);
3083
+ }
3082
3084
  }
3083
3085
  async function getSeed(deviceId, sensorId) {
3084
3086
  try {
@@ -3127,6 +3129,7 @@ const flexiGaugeTpms = {
3127
3129
  async connect(deviceId) {
3128
3130
  const fgMeta = deviceMeta.flexiGaugeTpms;
3129
3131
  await bluetooth.connect(deviceId, this.disconnect);
3132
+ await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3130
3133
  await ble.startNotification(
3131
3134
  deviceId,
3132
3135
  fgMeta.communication.serviceId,
@@ -3138,6 +3141,7 @@ const flexiGaugeTpms = {
3138
3141
  },
3139
3142
  async disconnect(deviceId, reason) {
3140
3143
  store.setState(deviceId, "disconnecting");
3144
+ await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3141
3145
  await bluetooth.disconnect(deviceId);
3142
3146
  store.setState(deviceId, void 0, reason ?? "manualDisconnection");
3143
3147
  },
@@ -3147,7 +3151,8 @@ const flexiGaugeTpms = {
3147
3151
  getBattery: flexiGaugeTpmsService.getBattery,
3148
3152
  getFirmwareVersion: flexiGaugeTpmsService.getFirmwareVersion,
3149
3153
  startTpmsScan: flexiGaugeTpmsService.startTpmsScan,
3150
- programSensor: flexiGaugeTpmsService.programSensor
3154
+ setSensorDisplayId: flexiGaugeTpmsService.setSensorDisplayId,
3155
+ resetSensorDisplayId: (deviceId, sensorId) => flexiGaugeTpmsService.setSensorDisplayId(deviceId, sensorId, "00000000")
3151
3156
  };
3152
3157
 
3153
3158
  const capabilities = [
@@ -3821,13 +3826,16 @@ const flexiGaugeTpmsSimulator = {
3821
3826
  await toolsSvc.delay(200);
3822
3827
  return fg.simulatorData.battery;
3823
3828
  },
3829
+ setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
3830
+ return new Promise((resolve) => resolve());
3831
+ },
3832
+ resetSensorDisplayId(deviceId, sensorId) {
3833
+ return new Promise((resolve) => resolve());
3834
+ },
3824
3835
  async getFirmwareVersion(deviceId) {
3825
3836
  await toolsSvc.delay(100);
3826
3837
  return "9.9.9";
3827
3838
  },
3828
- programSensor(deviceId, oldSensorId, newSensorId) {
3829
- return new Promise((resolve) => resolve());
3830
- },
3831
3839
  onButtonPress(callback) {
3832
3840
  },
3833
3841
  onTpms(callback) {
package/dist/index.d.cts CHANGED
@@ -929,7 +929,8 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
929
929
  getBattery: (deviceId: string) => Promise<number>;
930
930
  getFirmwareVersion: (deviceId: string) => Promise<string>;
931
931
  startTpmsScan: (deviceId: string) => void;
932
- programSensor: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
932
+ setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
933
+ resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
933
934
  };
934
935
  /** Methods for working with Tirecheck Pressure Stick */
935
936
  pressureStick: {
package/dist/index.d.mts CHANGED
@@ -929,7 +929,8 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
929
929
  getBattery: (deviceId: string) => Promise<number>;
930
930
  getFirmwareVersion: (deviceId: string) => Promise<string>;
931
931
  startTpmsScan: (deviceId: string) => void;
932
- programSensor: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
932
+ setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
933
+ resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
933
934
  };
934
935
  /** Methods for working with Tirecheck Pressure Stick */
935
936
  pressureStick: {
package/dist/index.d.ts CHANGED
@@ -929,7 +929,8 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
929
929
  getBattery: (deviceId: string) => Promise<number>;
930
930
  getFirmwareVersion: (deviceId: string) => Promise<string>;
931
931
  startTpmsScan: (deviceId: string) => void;
932
- programSensor: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
932
+ setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
933
+ resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
933
934
  };
934
935
  /** Methods for working with Tirecheck Pressure Stick */
935
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;
@@ -3019,7 +3019,7 @@ const flexiGaugeTpmsService = {
3019
3019
  }
3020
3020
  flexiGaugeTpmsCommands.processMessage(deviceId, message);
3021
3021
  },
3022
- programSensor,
3022
+ setSensorDisplayId,
3023
3023
  getFirmwareVersion
3024
3024
  };
3025
3025
  function processTreadDepth(deviceId, value) {
@@ -3059,7 +3059,7 @@ function processTpms(deviceId, value) {
3059
3059
  simulatorSvc.triggerEvent("fg:tpms", deviceId, strongestReading);
3060
3060
  }
3061
3061
  }
3062
- async function programSensor(deviceId, oldSensorId, newSensorId) {
3062
+ async function setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
3063
3063
  const fw = await getFirmwareVersion(deviceId);
3064
3064
  if (fw < "1.4.4") throw new Error("Programming sensors is not supported on this firmware version");
3065
3065
  await findSensor(deviceId, oldSensorId);
@@ -3071,7 +3071,9 @@ async function programSensor(deviceId, oldSensorId, newSensorId) {
3071
3071
  const config = await getSensorConfiguration(deviceId);
3072
3072
  const newConfig = config.replace(/^.{8}/, newSensorId);
3073
3073
  await flexiGaugeTpmsCommands.vdaSendConfiguration(deviceId, newConfig);
3074
- await findSensor(deviceId, newSensorId);
3074
+ if (newSensorId !== "00000000") {
3075
+ await findSensor(deviceId, newSensorId);
3076
+ }
3075
3077
  }
3076
3078
  async function getSeed(deviceId, sensorId) {
3077
3079
  try {
@@ -3120,6 +3122,7 @@ const flexiGaugeTpms = {
3120
3122
  async connect(deviceId) {
3121
3123
  const fgMeta = deviceMeta.flexiGaugeTpms;
3122
3124
  await bluetooth.connect(deviceId, this.disconnect);
3125
+ await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3123
3126
  await ble.startNotification(
3124
3127
  deviceId,
3125
3128
  fgMeta.communication.serviceId,
@@ -3131,6 +3134,7 @@ const flexiGaugeTpms = {
3131
3134
  },
3132
3135
  async disconnect(deviceId, reason) {
3133
3136
  store.setState(deviceId, "disconnecting");
3137
+ await promiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3134
3138
  await bluetooth.disconnect(deviceId);
3135
3139
  store.setState(deviceId, void 0, reason ?? "manualDisconnection");
3136
3140
  },
@@ -3140,7 +3144,8 @@ const flexiGaugeTpms = {
3140
3144
  getBattery: flexiGaugeTpmsService.getBattery,
3141
3145
  getFirmwareVersion: flexiGaugeTpmsService.getFirmwareVersion,
3142
3146
  startTpmsScan: flexiGaugeTpmsService.startTpmsScan,
3143
- programSensor: flexiGaugeTpmsService.programSensor
3147
+ setSensorDisplayId: flexiGaugeTpmsService.setSensorDisplayId,
3148
+ resetSensorDisplayId: (deviceId, sensorId) => flexiGaugeTpmsService.setSensorDisplayId(deviceId, sensorId, "00000000")
3144
3149
  };
3145
3150
 
3146
3151
  const capabilities = [
@@ -3814,13 +3819,16 @@ const flexiGaugeTpmsSimulator = {
3814
3819
  await toolsSvc.delay(200);
3815
3820
  return fg.simulatorData.battery;
3816
3821
  },
3822
+ setSensorDisplayId(deviceId, oldSensorId, newSensorId) {
3823
+ return new Promise((resolve) => resolve());
3824
+ },
3825
+ resetSensorDisplayId(deviceId, sensorId) {
3826
+ return new Promise((resolve) => resolve());
3827
+ },
3817
3828
  async getFirmwareVersion(deviceId) {
3818
3829
  await toolsSvc.delay(100);
3819
3830
  return "9.9.9";
3820
3831
  },
3821
- programSensor(deviceId, oldSensorId, newSensorId) {
3822
- return new Promise((resolve) => resolve());
3823
- },
3824
3832
  onButtonPress(callback) {
3825
3833
  },
3826
3834
  onTpms(callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirecheck-device-sdk",
3
- "version": "0.2.29",
3
+ "version": "0.2.31",
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",