tirecheck-device-sdk 0.2.22 → 0.2.24

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
@@ -47,6 +47,8 @@ const store = {
47
47
  // undefined => connecting => connected => paired => disconnecting => undefined
48
48
  /** some bridge commands require bridge reboot to be completed */
49
49
  bridgeRebootRequired: {},
50
+ /** Torque wrench properties, about device settings, mainly used for unit conversion */
51
+ torqueWrenchProperties: {},
50
52
  //** 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 */
51
53
  deviceIdMapingTable: {},
52
54
  /** 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 */
@@ -522,8 +524,26 @@ const deviceMeta = {
522
524
  },
523
525
  getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
524
526
  },
527
+ // flexiGauge: {
528
+ // nameRegex: /^Flexi.*v.*/,
529
+ // communication: {
530
+ // serviceId: '4880c12c-fdcb-4077-8920-a450d7f9b907',
531
+ // characteristicId: 'fec26ec4-6d71-4442-9f81-55bc21d658d6',
532
+ // },
533
+ // battery: {
534
+ // serviceId: '180f',
535
+ // characteristicId: '2a19',
536
+ // },
537
+ // getDeviceInfoFromAdvertising: (device: PeripheralData) => {
538
+ // const bleDevice: BleDevice = {
539
+ // ...device,
540
+ // type: 'flexiGauge',
541
+ // }
542
+ // return bleDevice
543
+ // },
544
+ // },
525
545
  flexiGaugeTpms: {
526
- nameRegex: /^Flexi.*/,
546
+ nameRegex: /^Flexi.*TPMS.*/,
527
547
  communication: {
528
548
  serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
529
549
  characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
@@ -538,9 +558,7 @@ const deviceMeta = {
538
558
  type: "flexiGaugeTpms"
539
559
  };
540
560
  return bleDevice;
541
- },
542
- reconnect: true
543
- // Do we need it here?
561
+ }
544
562
  },
545
563
  pressureStick: {
546
564
  nameRegex: /Pressure Stick.*/,
@@ -555,6 +573,42 @@ const deviceMeta = {
555
573
  };
556
574
  return bleDevice;
557
575
  }
576
+ },
577
+ // ateq: {
578
+ // nameRegex: /ATEQ.*/,
579
+ // communication: {
580
+ // serviceId: 'a002',
581
+ // characteristicId: 'c305',
582
+ // },
583
+ // indicate: {
584
+ // serviceId: 'a002',
585
+ // characteristicId: 'c306',
586
+ // },
587
+ // getDeviceInfoFromAdvertising: (device: PeripheralData) => {
588
+ // const bleDevice: BleDevice = {
589
+ // ...device,
590
+ // type: 'ateq',
591
+ // }
592
+ // return bleDevice
593
+ // },
594
+ // },
595
+ torqueWrench: {
596
+ nameRegex: /^\d+(lbft|NM)-\d+$/i,
597
+ communication: {
598
+ serviceId: "49535343-fe7d-4ae5-8fa9-9fafd205e455",
599
+ characteristicId: "49535343-1e4d-4bd9-ba61-23c647249616"
600
+ },
601
+ battery: {
602
+ serviceId: "180f",
603
+ characteristicId: "2a19"
604
+ },
605
+ getDeviceInfoFromAdvertising: (device) => {
606
+ const bleDevice = {
607
+ ...device,
608
+ type: "torqueWrench"
609
+ };
610
+ return bleDevice;
611
+ }
558
612
  }
559
613
  };
560
614
 
@@ -3016,6 +3070,7 @@ const torqueWrenchCommands = {
3016
3070
  result = await torqueWrenchPromiseQueue.enqueue(deviceId, twMeta.communication, decimalArray, commandIds[command]);
3017
3071
  } catch (error) {
3018
3072
  const formattedError = formatError(error);
3073
+ torqueWrench.disconnect(deviceId, "lostConnection");
3019
3074
  throw new Error(formattedError);
3020
3075
  }
3021
3076
  return result.map((num) => String.fromCharCode(num)).join("");
@@ -3078,7 +3133,6 @@ const torqueWrenchService = {
3078
3133
  async startJob(deviceId, params) {
3079
3134
  await this.stopJob(deviceId);
3080
3135
  const { units, span, ppr, threshold } = store.torqueWrenchProperties[deviceId];
3081
- console.log("\u{1F680} ~ startJob ~ units:", units);
3082
3136
  const { torqueMin, torqueMax, angleMin, angleMax, direction, jobTimeout } = params;
3083
3137
  const msgParams = {
3084
3138
  id: "01",
@@ -3103,14 +3157,11 @@ const torqueWrenchService = {
3103
3157
  await torqueWrenchCommands.sendCommand(deviceId, "startJob", paramsString);
3104
3158
  jobInterval = setInterval(async () => {
3105
3159
  const numberOfReading = await this.getNumberOfReadings(deviceId);
3106
- console.log("\u{1F680} ~ jobInterval=setInterval ~ numberOfReading:", numberOfReading);
3107
3160
  if (numberOfReading.count > 0) this.getReading(deviceId);
3108
- }, 1e3);
3161
+ }, 2e3);
3109
3162
  if (jobTimeout) {
3110
3163
  await new Promise(
3111
3164
  (resolve) => setTimeout(() => {
3112
- console.log("job terminated");
3113
- clearInterval(jobInterval);
3114
3165
  this.stopJob(deviceId);
3115
3166
  resolve("");
3116
3167
  }, jobTimeout * 1e3)
@@ -3118,6 +3169,7 @@ const torqueWrenchService = {
3118
3169
  }
3119
3170
  },
3120
3171
  async stopJob(deviceId) {
3172
+ clearInterval(jobInterval);
3121
3173
  return torqueWrenchCommands.sendCommand(deviceId, "stopJob");
3122
3174
  },
3123
3175
  async getNumberOfReadings(deviceId) {
@@ -3209,6 +3261,7 @@ const torqueWrench = {
3209
3261
  async connect(deviceId) {
3210
3262
  const twMeta = deviceMeta.torqueWrench;
3211
3263
  await bluetooth.connect(deviceId, this.disconnect);
3264
+ await torqueWrenchPromiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3212
3265
  await ble.startNotification(
3213
3266
  deviceId,
3214
3267
  twMeta.communication.serviceId,
@@ -3224,6 +3277,8 @@ const torqueWrench = {
3224
3277
  },
3225
3278
  async disconnect(deviceId, reason) {
3226
3279
  store.setState(deviceId, "disconnecting");
3280
+ await torqueWrenchService.stopJob(deviceId);
3281
+ await torqueWrenchPromiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3227
3282
  await bluetooth.disconnect(deviceId);
3228
3283
  store.setState(deviceId, void 0, reason ?? "manualDisconnection");
3229
3284
  },
package/dist/index.d.cts CHANGED
@@ -81,7 +81,6 @@ declare const _default$1: {
81
81
  characteristicId: string;
82
82
  };
83
83
  getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGaugeTpms;
84
- reconnect: boolean;
85
84
  };
86
85
  pressureStick: {
87
86
  nameRegex: RegExp;
@@ -91,6 +90,18 @@ declare const _default$1: {
91
90
  };
92
91
  getDeviceInfoFromAdvertising: (device: PeripheralData) => BlePressureStick;
93
92
  };
93
+ torqueWrench: {
94
+ nameRegex: RegExp;
95
+ communication: {
96
+ serviceId: string;
97
+ characteristicId: string;
98
+ };
99
+ battery: {
100
+ serviceId: string;
101
+ characteristicId: string;
102
+ };
103
+ getDeviceInfoFromAdvertising: (device: PeripheralData) => BleTorqueWrench;
104
+ };
94
105
  };
95
106
 
96
107
  declare const _default: {
@@ -739,7 +750,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
739
750
  };
740
751
  type BleDeviceType = keyof typeof _default$1;
741
752
  /** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
742
- type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick;
753
+ type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleTorqueWrench;
743
754
  type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
744
755
  type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
745
756
  interface BleDeviceBase {
@@ -763,6 +774,9 @@ interface BleBridge extends BleDeviceBase {
763
774
  interface BleFlexiGaugeTpms extends BleDeviceBase {
764
775
  type: 'flexiGaugeTpms';
765
776
  }
777
+ interface BleTorqueWrench extends BleDeviceBase {
778
+ type: 'torqueWrench';
779
+ }
766
780
  interface BleBridgeOta extends BleDeviceBase {
767
781
  advertisingData: {
768
782
  bridgeId: string;
@@ -834,6 +848,31 @@ interface EventHandlers {
834
848
  'fg:button'?: (deviceId: string, value: string) => void;
835
849
  'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
836
850
  'ps:pressure'?: (deviceId: string, value: number) => void;
851
+ 'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
852
+ }
853
+ interface TorqueWrenchStartJobParams {
854
+ nuts: number;
855
+ direction: 'clockwise' | 'counter-clockwise';
856
+ torqueMin?: number;
857
+ torqueMax?: number;
858
+ angleMin?: number;
859
+ angleMax?: number;
860
+ jobTimeout: number;
861
+ }
862
+ interface TorqueWrenchProperties {
863
+ serialNumber: string;
864
+ calibrationDate: string;
865
+ units: 'Nm' | 'lb-ft';
866
+ span: number;
867
+ ppr: number;
868
+ threshold: number;
869
+ }
870
+ interface TorqueWrenchReading {
871
+ jobId: number;
872
+ nut: number;
873
+ torque: number;
874
+ angle: number;
875
+ duration: number;
837
876
  }
838
877
  type EventName = keyof EventHandlers;
839
878
 
@@ -919,4 +958,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
919
958
  };
920
959
  };
921
960
 
922
- export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, 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 FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
961
+ export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, 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 FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
package/dist/index.d.mts CHANGED
@@ -81,7 +81,6 @@ declare const _default$1: {
81
81
  characteristicId: string;
82
82
  };
83
83
  getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGaugeTpms;
84
- reconnect: boolean;
85
84
  };
86
85
  pressureStick: {
87
86
  nameRegex: RegExp;
@@ -91,6 +90,18 @@ declare const _default$1: {
91
90
  };
92
91
  getDeviceInfoFromAdvertising: (device: PeripheralData) => BlePressureStick;
93
92
  };
93
+ torqueWrench: {
94
+ nameRegex: RegExp;
95
+ communication: {
96
+ serviceId: string;
97
+ characteristicId: string;
98
+ };
99
+ battery: {
100
+ serviceId: string;
101
+ characteristicId: string;
102
+ };
103
+ getDeviceInfoFromAdvertising: (device: PeripheralData) => BleTorqueWrench;
104
+ };
94
105
  };
95
106
 
96
107
  declare const _default: {
@@ -739,7 +750,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
739
750
  };
740
751
  type BleDeviceType = keyof typeof _default$1;
741
752
  /** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
742
- type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick;
753
+ type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleTorqueWrench;
743
754
  type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
744
755
  type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
745
756
  interface BleDeviceBase {
@@ -763,6 +774,9 @@ interface BleBridge extends BleDeviceBase {
763
774
  interface BleFlexiGaugeTpms extends BleDeviceBase {
764
775
  type: 'flexiGaugeTpms';
765
776
  }
777
+ interface BleTorqueWrench extends BleDeviceBase {
778
+ type: 'torqueWrench';
779
+ }
766
780
  interface BleBridgeOta extends BleDeviceBase {
767
781
  advertisingData: {
768
782
  bridgeId: string;
@@ -834,6 +848,31 @@ interface EventHandlers {
834
848
  'fg:button'?: (deviceId: string, value: string) => void;
835
849
  'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
836
850
  'ps:pressure'?: (deviceId: string, value: number) => void;
851
+ 'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
852
+ }
853
+ interface TorqueWrenchStartJobParams {
854
+ nuts: number;
855
+ direction: 'clockwise' | 'counter-clockwise';
856
+ torqueMin?: number;
857
+ torqueMax?: number;
858
+ angleMin?: number;
859
+ angleMax?: number;
860
+ jobTimeout: number;
861
+ }
862
+ interface TorqueWrenchProperties {
863
+ serialNumber: string;
864
+ calibrationDate: string;
865
+ units: 'Nm' | 'lb-ft';
866
+ span: number;
867
+ ppr: number;
868
+ threshold: number;
869
+ }
870
+ interface TorqueWrenchReading {
871
+ jobId: number;
872
+ nut: number;
873
+ torque: number;
874
+ angle: number;
875
+ duration: number;
837
876
  }
838
877
  type EventName = keyof EventHandlers;
839
878
 
@@ -919,4 +958,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
919
958
  };
920
959
  };
921
960
 
922
- export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, 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 FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
961
+ export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, 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 FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
package/dist/index.d.ts CHANGED
@@ -81,7 +81,6 @@ declare const _default$1: {
81
81
  characteristicId: string;
82
82
  };
83
83
  getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGaugeTpms;
84
- reconnect: boolean;
85
84
  };
86
85
  pressureStick: {
87
86
  nameRegex: RegExp;
@@ -91,6 +90,18 @@ declare const _default$1: {
91
90
  };
92
91
  getDeviceInfoFromAdvertising: (device: PeripheralData) => BlePressureStick;
93
92
  };
93
+ torqueWrench: {
94
+ nameRegex: RegExp;
95
+ communication: {
96
+ serviceId: string;
97
+ characteristicId: string;
98
+ };
99
+ battery: {
100
+ serviceId: string;
101
+ characteristicId: string;
102
+ };
103
+ getDeviceInfoFromAdvertising: (device: PeripheralData) => BleTorqueWrench;
104
+ };
94
105
  };
95
106
 
96
107
  declare const _default: {
@@ -739,7 +750,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
739
750
  };
740
751
  type BleDeviceType = keyof typeof _default$1;
741
752
  /** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
742
- type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick;
753
+ type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleTorqueWrench;
743
754
  type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
744
755
  type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
745
756
  interface BleDeviceBase {
@@ -763,6 +774,9 @@ interface BleBridge extends BleDeviceBase {
763
774
  interface BleFlexiGaugeTpms extends BleDeviceBase {
764
775
  type: 'flexiGaugeTpms';
765
776
  }
777
+ interface BleTorqueWrench extends BleDeviceBase {
778
+ type: 'torqueWrench';
779
+ }
766
780
  interface BleBridgeOta extends BleDeviceBase {
767
781
  advertisingData: {
768
782
  bridgeId: string;
@@ -834,6 +848,31 @@ interface EventHandlers {
834
848
  'fg:button'?: (deviceId: string, value: string) => void;
835
849
  'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
836
850
  'ps:pressure'?: (deviceId: string, value: number) => void;
851
+ 'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
852
+ }
853
+ interface TorqueWrenchStartJobParams {
854
+ nuts: number;
855
+ direction: 'clockwise' | 'counter-clockwise';
856
+ torqueMin?: number;
857
+ torqueMax?: number;
858
+ angleMin?: number;
859
+ angleMax?: number;
860
+ jobTimeout: number;
861
+ }
862
+ interface TorqueWrenchProperties {
863
+ serialNumber: string;
864
+ calibrationDate: string;
865
+ units: 'Nm' | 'lb-ft';
866
+ span: number;
867
+ ppr: number;
868
+ threshold: number;
869
+ }
870
+ interface TorqueWrenchReading {
871
+ jobId: number;
872
+ nut: number;
873
+ torque: number;
874
+ angle: number;
875
+ duration: number;
837
876
  }
838
877
  type EventName = keyof EventHandlers;
839
878
 
@@ -919,4 +958,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
919
958
  };
920
959
  };
921
960
 
922
- export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, 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 FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type Wrapper, createTirecheckDeviceSdk };
961
+ export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGaugeTpms, type BleFlexiGaugeTpmsSimulated, type BlePressureStick, type BleSecurityKeys, type BleTorqueWrench, 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 FgSensorReading, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
package/dist/index.mjs CHANGED
@@ -40,6 +40,8 @@ const store = {
40
40
  // undefined => connecting => connected => paired => disconnecting => undefined
41
41
  /** some bridge commands require bridge reboot to be completed */
42
42
  bridgeRebootRequired: {},
43
+ /** Torque wrench properties, about device settings, mainly used for unit conversion */
44
+ torqueWrenchProperties: {},
43
45
  //** 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 */
44
46
  deviceIdMapingTable: {},
45
47
  /** 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 */
@@ -515,8 +517,26 @@ const deviceMeta = {
515
517
  },
516
518
  getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
517
519
  },
520
+ // flexiGauge: {
521
+ // nameRegex: /^Flexi.*v.*/,
522
+ // communication: {
523
+ // serviceId: '4880c12c-fdcb-4077-8920-a450d7f9b907',
524
+ // characteristicId: 'fec26ec4-6d71-4442-9f81-55bc21d658d6',
525
+ // },
526
+ // battery: {
527
+ // serviceId: '180f',
528
+ // characteristicId: '2a19',
529
+ // },
530
+ // getDeviceInfoFromAdvertising: (device: PeripheralData) => {
531
+ // const bleDevice: BleDevice = {
532
+ // ...device,
533
+ // type: 'flexiGauge',
534
+ // }
535
+ // return bleDevice
536
+ // },
537
+ // },
518
538
  flexiGaugeTpms: {
519
- nameRegex: /^Flexi.*/,
539
+ nameRegex: /^Flexi.*TPMS.*/,
520
540
  communication: {
521
541
  serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
522
542
  characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
@@ -531,9 +551,7 @@ const deviceMeta = {
531
551
  type: "flexiGaugeTpms"
532
552
  };
533
553
  return bleDevice;
534
- },
535
- reconnect: true
536
- // Do we need it here?
554
+ }
537
555
  },
538
556
  pressureStick: {
539
557
  nameRegex: /Pressure Stick.*/,
@@ -548,6 +566,42 @@ const deviceMeta = {
548
566
  };
549
567
  return bleDevice;
550
568
  }
569
+ },
570
+ // ateq: {
571
+ // nameRegex: /ATEQ.*/,
572
+ // communication: {
573
+ // serviceId: 'a002',
574
+ // characteristicId: 'c305',
575
+ // },
576
+ // indicate: {
577
+ // serviceId: 'a002',
578
+ // characteristicId: 'c306',
579
+ // },
580
+ // getDeviceInfoFromAdvertising: (device: PeripheralData) => {
581
+ // const bleDevice: BleDevice = {
582
+ // ...device,
583
+ // type: 'ateq',
584
+ // }
585
+ // return bleDevice
586
+ // },
587
+ // },
588
+ torqueWrench: {
589
+ nameRegex: /^\d+(lbft|NM)-\d+$/i,
590
+ communication: {
591
+ serviceId: "49535343-fe7d-4ae5-8fa9-9fafd205e455",
592
+ characteristicId: "49535343-1e4d-4bd9-ba61-23c647249616"
593
+ },
594
+ battery: {
595
+ serviceId: "180f",
596
+ characteristicId: "2a19"
597
+ },
598
+ getDeviceInfoFromAdvertising: (device) => {
599
+ const bleDevice = {
600
+ ...device,
601
+ type: "torqueWrench"
602
+ };
603
+ return bleDevice;
604
+ }
551
605
  }
552
606
  };
553
607
 
@@ -3009,6 +3063,7 @@ const torqueWrenchCommands = {
3009
3063
  result = await torqueWrenchPromiseQueue.enqueue(deviceId, twMeta.communication, decimalArray, commandIds[command]);
3010
3064
  } catch (error) {
3011
3065
  const formattedError = formatError(error);
3066
+ torqueWrench.disconnect(deviceId, "lostConnection");
3012
3067
  throw new Error(formattedError);
3013
3068
  }
3014
3069
  return result.map((num) => String.fromCharCode(num)).join("");
@@ -3071,7 +3126,6 @@ const torqueWrenchService = {
3071
3126
  async startJob(deviceId, params) {
3072
3127
  await this.stopJob(deviceId);
3073
3128
  const { units, span, ppr, threshold } = store.torqueWrenchProperties[deviceId];
3074
- console.log("\u{1F680} ~ startJob ~ units:", units);
3075
3129
  const { torqueMin, torqueMax, angleMin, angleMax, direction, jobTimeout } = params;
3076
3130
  const msgParams = {
3077
3131
  id: "01",
@@ -3096,14 +3150,11 @@ const torqueWrenchService = {
3096
3150
  await torqueWrenchCommands.sendCommand(deviceId, "startJob", paramsString);
3097
3151
  jobInterval = setInterval(async () => {
3098
3152
  const numberOfReading = await this.getNumberOfReadings(deviceId);
3099
- console.log("\u{1F680} ~ jobInterval=setInterval ~ numberOfReading:", numberOfReading);
3100
3153
  if (numberOfReading.count > 0) this.getReading(deviceId);
3101
- }, 1e3);
3154
+ }, 2e3);
3102
3155
  if (jobTimeout) {
3103
3156
  await new Promise(
3104
3157
  (resolve) => setTimeout(() => {
3105
- console.log("job terminated");
3106
- clearInterval(jobInterval);
3107
3158
  this.stopJob(deviceId);
3108
3159
  resolve("");
3109
3160
  }, jobTimeout * 1e3)
@@ -3111,6 +3162,7 @@ const torqueWrenchService = {
3111
3162
  }
3112
3163
  },
3113
3164
  async stopJob(deviceId) {
3165
+ clearInterval(jobInterval);
3114
3166
  return torqueWrenchCommands.sendCommand(deviceId, "stopJob");
3115
3167
  },
3116
3168
  async getNumberOfReadings(deviceId) {
@@ -3202,6 +3254,7 @@ const torqueWrench = {
3202
3254
  async connect(deviceId) {
3203
3255
  const twMeta = deviceMeta.torqueWrench;
3204
3256
  await bluetooth.connect(deviceId, this.disconnect);
3257
+ await torqueWrenchPromiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3205
3258
  await ble.startNotification(
3206
3259
  deviceId,
3207
3260
  twMeta.communication.serviceId,
@@ -3217,6 +3270,8 @@ const torqueWrench = {
3217
3270
  },
3218
3271
  async disconnect(deviceId, reason) {
3219
3272
  store.setState(deviceId, "disconnecting");
3273
+ await torqueWrenchService.stopJob(deviceId);
3274
+ await torqueWrenchPromiseQueue.clearQueue(deviceId, "Previous pending commands aborted");
3220
3275
  await bluetooth.disconnect(deviceId);
3221
3276
  store.setState(deviceId, void 0, reason ?? "manualDisconnection");
3222
3277
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirecheck-device-sdk",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
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",