tirecheck-device-sdk 0.2.34 → 0.2.36
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 +148 -44
- package/dist/index.d.cts +24 -2
- package/dist/index.d.mts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.mjs +148 -44
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -527,27 +527,9 @@ const deviceMeta = {
|
|
|
527
527
|
},
|
|
528
528
|
getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
|
|
529
529
|
},
|
|
530
|
-
// flexiGauge: {
|
|
531
|
-
// nameRegex: /^Flexi.*v.*/,
|
|
532
|
-
// communication: {
|
|
533
|
-
// serviceId: '4880c12c-fdcb-4077-8920-a450d7f9b907',
|
|
534
|
-
// characteristicId: 'fec26ec4-6d71-4442-9f81-55bc21d658d6',
|
|
535
|
-
// },
|
|
536
|
-
// battery: {
|
|
537
|
-
// serviceId: '180f',
|
|
538
|
-
// characteristicId: '2a19',
|
|
539
|
-
// },
|
|
540
|
-
// getDeviceInfoFromAdvertising: (device: PeripheralData) => {
|
|
541
|
-
// const bleDevice: BleDevice = {
|
|
542
|
-
// ...device,
|
|
543
|
-
// type: 'flexiGauge',
|
|
544
|
-
// }
|
|
545
|
-
// return bleDevice
|
|
546
|
-
// },
|
|
547
|
-
// },
|
|
548
530
|
flexiGaugeTpms: {
|
|
549
531
|
// after implementation of normal fg replace with /^Flexi.*TPMS.*/,
|
|
550
|
-
nameRegex: /^Flexi.*/,
|
|
532
|
+
nameRegex: /^Flexi.*TPMS.*/,
|
|
551
533
|
communication: {
|
|
552
534
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
553
535
|
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
|
|
@@ -564,6 +546,24 @@ const deviceMeta = {
|
|
|
564
546
|
return bleDevice;
|
|
565
547
|
}
|
|
566
548
|
},
|
|
549
|
+
flexiGauge: {
|
|
550
|
+
nameRegex: /^Flexi.*/,
|
|
551
|
+
communication: {
|
|
552
|
+
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
553
|
+
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
|
|
554
|
+
},
|
|
555
|
+
battery: {
|
|
556
|
+
serviceId: "180f",
|
|
557
|
+
characteristicId: "2a19"
|
|
558
|
+
},
|
|
559
|
+
getDeviceInfoFromAdvertising: (device) => {
|
|
560
|
+
const bleDevice = {
|
|
561
|
+
...device,
|
|
562
|
+
type: "flexiGauge"
|
|
563
|
+
};
|
|
564
|
+
return bleDevice;
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
567
|
pressureStick: {
|
|
568
568
|
nameRegex: /Pressure Stick.*/,
|
|
569
569
|
communication: {
|
|
@@ -2755,6 +2755,134 @@ async function disconnect(deviceId, reason) {
|
|
|
2755
2755
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2756
2756
|
}
|
|
2757
2757
|
|
|
2758
|
+
const callbacks = {};
|
|
2759
|
+
const simulatorSvc = {
|
|
2760
|
+
registerEvent(eventName, callback) {
|
|
2761
|
+
callbacks[eventName] = callback;
|
|
2762
|
+
},
|
|
2763
|
+
triggerEvent(eventName, deviceId, payload) {
|
|
2764
|
+
if (payload === void 0) {
|
|
2765
|
+
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2766
|
+
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2767
|
+
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2768
|
+
if (!payload) throw new Error(`Event not found`);
|
|
2769
|
+
}
|
|
2770
|
+
const callback = callbacks[eventName];
|
|
2771
|
+
if (!callback) {
|
|
2772
|
+
console.warn(`Event ${eventName} not registered`);
|
|
2773
|
+
} else {
|
|
2774
|
+
callback(deviceId, payload);
|
|
2775
|
+
}
|
|
2776
|
+
},
|
|
2777
|
+
merge(deviceTemplate, initialData) {
|
|
2778
|
+
return ___default.mergeWith({}, deviceTemplate, initialData, (a, b) => ___default.isArray(b) ? b : void 0);
|
|
2779
|
+
}
|
|
2780
|
+
};
|
|
2781
|
+
|
|
2782
|
+
const flexiGaugeTpmsMeta$1 = deviceMeta.flexiGaugeTpms;
|
|
2783
|
+
const flexiGaugeCommands = {
|
|
2784
|
+
getBattery: getBattery$1,
|
|
2785
|
+
sendKeepAlive
|
|
2786
|
+
};
|
|
2787
|
+
async function getBattery$1(deviceId) {
|
|
2788
|
+
const batteryValue = await bluetooth.read(
|
|
2789
|
+
deviceId,
|
|
2790
|
+
flexiGaugeTpmsMeta$1.battery.serviceId,
|
|
2791
|
+
flexiGaugeTpmsMeta$1.battery.characteristicId
|
|
2792
|
+
);
|
|
2793
|
+
const battery = Array.from(new Uint8Array(batteryValue))[0];
|
|
2794
|
+
return battery;
|
|
2795
|
+
}
|
|
2796
|
+
async function sendKeepAlive(deviceId) {
|
|
2797
|
+
if (!canCommunicateWith(deviceId)) throw new Error("Flexi Gauge not connected");
|
|
2798
|
+
const scanMsg = stringToArrayBuffer("Z\r\n");
|
|
2799
|
+
return bluetooth.write(
|
|
2800
|
+
deviceId,
|
|
2801
|
+
flexiGaugeTpmsMeta$1.communication.serviceId,
|
|
2802
|
+
flexiGaugeTpmsMeta$1.communication.characteristicId,
|
|
2803
|
+
scanMsg
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
const capabilities$2 = [
|
|
2808
|
+
{
|
|
2809
|
+
id: "td",
|
|
2810
|
+
processFn: processTreadDepth$1,
|
|
2811
|
+
regex: /^\*?T.*/
|
|
2812
|
+
},
|
|
2813
|
+
{
|
|
2814
|
+
id: "button",
|
|
2815
|
+
processFn: processButtonPress$1,
|
|
2816
|
+
regex: /^[UDLRC]$/
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
id: "keepAlive",
|
|
2820
|
+
processFn: processKeepAlive,
|
|
2821
|
+
// eslint-disable-next-line no-control-regex
|
|
2822
|
+
regex: /Z\u0011/
|
|
2823
|
+
}
|
|
2824
|
+
];
|
|
2825
|
+
const flexiGaugeTpmsService$1 = {
|
|
2826
|
+
getBattery(deviceId) {
|
|
2827
|
+
return flexiGaugeCommands.getBattery(deviceId);
|
|
2828
|
+
},
|
|
2829
|
+
onTreadDepth(callback) {
|
|
2830
|
+
simulatorSvc.registerEvent("fg:treadDepth", callback);
|
|
2831
|
+
},
|
|
2832
|
+
onButton(callback) {
|
|
2833
|
+
simulatorSvc.registerEvent("fg:button", callback);
|
|
2834
|
+
},
|
|
2835
|
+
onTpms(callback) {
|
|
2836
|
+
simulatorSvc.registerEvent("fg:tpms", callback);
|
|
2837
|
+
},
|
|
2838
|
+
icon: "icon-flexigauge",
|
|
2839
|
+
processMessage(deviceId, message) {
|
|
2840
|
+
const numberArray = Array.from(new Uint8Array(message));
|
|
2841
|
+
const stringFromBytes = String.fromCharCode.apply(null, numberArray).replace("\r\n", "");
|
|
2842
|
+
for (const capability of capabilities$2) {
|
|
2843
|
+
if (capability.regex.test(stringFromBytes)) {
|
|
2844
|
+
return capability.processFn(deviceId, stringFromBytes);
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
};
|
|
2849
|
+
function processKeepAlive(deviceId) {
|
|
2850
|
+
flexiGaugeCommands.sendKeepAlive(deviceId);
|
|
2851
|
+
}
|
|
2852
|
+
function processTreadDepth$1(deviceId, value) {
|
|
2853
|
+
const treadDepth = value.match(/\d+/)?.[0];
|
|
2854
|
+
const convertedValue = Number(treadDepth) / 1e3;
|
|
2855
|
+
simulatorSvc.triggerEvent("fg:treadDepth", deviceId, convertedValue);
|
|
2856
|
+
}
|
|
2857
|
+
function processButtonPress$1(deviceId, value) {
|
|
2858
|
+
const buttonName = value.match(/\*?(.)/);
|
|
2859
|
+
if (!buttonName || !buttonName[1]) throw new Error("Unrecognized button");
|
|
2860
|
+
simulatorSvc.triggerEvent("fg:button", deviceId, buttonName[1]);
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
const flexiGauge = {
|
|
2864
|
+
async connect(deviceId) {
|
|
2865
|
+
const fgMeta = deviceMeta.flexiGaugeTpms;
|
|
2866
|
+
await bluetooth.connect(deviceId, this.disconnect);
|
|
2867
|
+
await ble.startNotification(
|
|
2868
|
+
deviceId,
|
|
2869
|
+
fgMeta.communication.serviceId,
|
|
2870
|
+
fgMeta.communication.characteristicId,
|
|
2871
|
+
(notification) => flexiGaugeTpmsService$1.processMessage(deviceId, notification),
|
|
2872
|
+
(error) => console.warn("ble.startNotification error", error)
|
|
2873
|
+
);
|
|
2874
|
+
store.setState(deviceId, "paired");
|
|
2875
|
+
},
|
|
2876
|
+
async disconnect(deviceId, reason) {
|
|
2877
|
+
store.setState(deviceId, "disconnecting");
|
|
2878
|
+
await bluetooth.disconnect(deviceId);
|
|
2879
|
+
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2880
|
+
},
|
|
2881
|
+
onTreadDepth: flexiGaugeTpmsService$1.onTreadDepth,
|
|
2882
|
+
onButtonPress: flexiGaugeTpmsService$1.onButton,
|
|
2883
|
+
getBattery: flexiGaugeTpmsService$1.getBattery
|
|
2884
|
+
};
|
|
2885
|
+
|
|
2758
2886
|
const devicePromiseQueue = {};
|
|
2759
2887
|
const deviceCurrentResolve = {};
|
|
2760
2888
|
const deviceCurrentReject = {};
|
|
@@ -2809,30 +2937,6 @@ const promiseQueue = {
|
|
|
2809
2937
|
}
|
|
2810
2938
|
};
|
|
2811
2939
|
|
|
2812
|
-
const callbacks = {};
|
|
2813
|
-
const simulatorSvc = {
|
|
2814
|
-
registerEvent(eventName, callback) {
|
|
2815
|
-
callbacks[eventName] = callback;
|
|
2816
|
-
},
|
|
2817
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2818
|
-
if (payload === void 0) {
|
|
2819
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2820
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2821
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2822
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2823
|
-
}
|
|
2824
|
-
const callback = callbacks[eventName];
|
|
2825
|
-
if (!callback) {
|
|
2826
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2827
|
-
} else {
|
|
2828
|
-
callback(deviceId, payload);
|
|
2829
|
-
}
|
|
2830
|
-
},
|
|
2831
|
-
merge(deviceTemplate, initialData) {
|
|
2832
|
-
return ___default.mergeWith({}, deviceTemplate, initialData, (a, b) => ___default.isArray(b) ? b : void 0);
|
|
2833
|
-
}
|
|
2834
|
-
};
|
|
2835
|
-
|
|
2836
2940
|
const flexiGaugeTpmsSecurity = {
|
|
2837
2941
|
getCommandsSignature(seed) {
|
|
2838
2942
|
const key = store.securityKeys?.flexiGaugeTpms?.signatureKeys.allLFCommands;
|
|
@@ -4095,7 +4199,7 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4095
4199
|
bridgeOta,
|
|
4096
4200
|
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
4097
4201
|
flexiGaugeTpms,
|
|
4098
|
-
|
|
4202
|
+
flexiGauge,
|
|
4099
4203
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
4100
4204
|
pressureStick,
|
|
4101
4205
|
// ateq,
|
package/dist/index.d.cts
CHANGED
|
@@ -82,6 +82,18 @@ declare const _default$1: {
|
|
|
82
82
|
};
|
|
83
83
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGaugeTpms;
|
|
84
84
|
};
|
|
85
|
+
flexiGauge: {
|
|
86
|
+
nameRegex: RegExp;
|
|
87
|
+
communication: {
|
|
88
|
+
serviceId: string;
|
|
89
|
+
characteristicId: string;
|
|
90
|
+
};
|
|
91
|
+
battery: {
|
|
92
|
+
serviceId: string;
|
|
93
|
+
characteristicId: string;
|
|
94
|
+
};
|
|
95
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGauge;
|
|
96
|
+
};
|
|
85
97
|
pressureStick: {
|
|
86
98
|
nameRegex: RegExp;
|
|
87
99
|
communication: {
|
|
@@ -750,7 +762,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
|
|
|
750
762
|
};
|
|
751
763
|
type BleDeviceType = keyof typeof _default$1;
|
|
752
764
|
/** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
|
|
753
|
-
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleTorqueWrench;
|
|
765
|
+
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench;
|
|
754
766
|
type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
|
|
755
767
|
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
|
|
756
768
|
interface BleDeviceBase {
|
|
@@ -774,6 +786,9 @@ interface BleBridge extends BleDeviceBase {
|
|
|
774
786
|
interface BleFlexiGaugeTpms extends BleDeviceBase {
|
|
775
787
|
type: 'flexiGaugeTpms';
|
|
776
788
|
}
|
|
789
|
+
interface BleFlexiGauge extends BleDeviceBase {
|
|
790
|
+
type: 'flexiGauge';
|
|
791
|
+
}
|
|
777
792
|
interface BleTorqueWrench extends BleDeviceBase {
|
|
778
793
|
type: 'torqueWrench';
|
|
779
794
|
}
|
|
@@ -932,6 +947,13 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
932
947
|
setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
|
|
933
948
|
resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
|
|
934
949
|
};
|
|
950
|
+
flexiGauge: {
|
|
951
|
+
connect(deviceId: string): Promise<void>;
|
|
952
|
+
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
953
|
+
onTreadDepth: (callback: (deviceId: string, value: number) => void) => void;
|
|
954
|
+
onButtonPress: (callback: (deviceId: string, value: string) => void) => void;
|
|
955
|
+
getBattery: (deviceId: string) => Promise<number>;
|
|
956
|
+
};
|
|
935
957
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
936
958
|
pressureStick: {
|
|
937
959
|
connect(deviceId: string): Promise<void>;
|
|
@@ -967,4 +989,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
967
989
|
};
|
|
968
990
|
};
|
|
969
991
|
|
|
970
|
-
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 };
|
|
992
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, 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
|
@@ -82,6 +82,18 @@ declare const _default$1: {
|
|
|
82
82
|
};
|
|
83
83
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGaugeTpms;
|
|
84
84
|
};
|
|
85
|
+
flexiGauge: {
|
|
86
|
+
nameRegex: RegExp;
|
|
87
|
+
communication: {
|
|
88
|
+
serviceId: string;
|
|
89
|
+
characteristicId: string;
|
|
90
|
+
};
|
|
91
|
+
battery: {
|
|
92
|
+
serviceId: string;
|
|
93
|
+
characteristicId: string;
|
|
94
|
+
};
|
|
95
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGauge;
|
|
96
|
+
};
|
|
85
97
|
pressureStick: {
|
|
86
98
|
nameRegex: RegExp;
|
|
87
99
|
communication: {
|
|
@@ -750,7 +762,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
|
|
|
750
762
|
};
|
|
751
763
|
type BleDeviceType = keyof typeof _default$1;
|
|
752
764
|
/** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
|
|
753
|
-
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleTorqueWrench;
|
|
765
|
+
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench;
|
|
754
766
|
type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
|
|
755
767
|
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
|
|
756
768
|
interface BleDeviceBase {
|
|
@@ -774,6 +786,9 @@ interface BleBridge extends BleDeviceBase {
|
|
|
774
786
|
interface BleFlexiGaugeTpms extends BleDeviceBase {
|
|
775
787
|
type: 'flexiGaugeTpms';
|
|
776
788
|
}
|
|
789
|
+
interface BleFlexiGauge extends BleDeviceBase {
|
|
790
|
+
type: 'flexiGauge';
|
|
791
|
+
}
|
|
777
792
|
interface BleTorqueWrench extends BleDeviceBase {
|
|
778
793
|
type: 'torqueWrench';
|
|
779
794
|
}
|
|
@@ -932,6 +947,13 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
932
947
|
setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
|
|
933
948
|
resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
|
|
934
949
|
};
|
|
950
|
+
flexiGauge: {
|
|
951
|
+
connect(deviceId: string): Promise<void>;
|
|
952
|
+
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
953
|
+
onTreadDepth: (callback: (deviceId: string, value: number) => void) => void;
|
|
954
|
+
onButtonPress: (callback: (deviceId: string, value: string) => void) => void;
|
|
955
|
+
getBattery: (deviceId: string) => Promise<number>;
|
|
956
|
+
};
|
|
935
957
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
936
958
|
pressureStick: {
|
|
937
959
|
connect(deviceId: string): Promise<void>;
|
|
@@ -967,4 +989,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
967
989
|
};
|
|
968
990
|
};
|
|
969
991
|
|
|
970
|
-
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 };
|
|
992
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, 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
|
@@ -82,6 +82,18 @@ declare const _default$1: {
|
|
|
82
82
|
};
|
|
83
83
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGaugeTpms;
|
|
84
84
|
};
|
|
85
|
+
flexiGauge: {
|
|
86
|
+
nameRegex: RegExp;
|
|
87
|
+
communication: {
|
|
88
|
+
serviceId: string;
|
|
89
|
+
characteristicId: string;
|
|
90
|
+
};
|
|
91
|
+
battery: {
|
|
92
|
+
serviceId: string;
|
|
93
|
+
characteristicId: string;
|
|
94
|
+
};
|
|
95
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGauge;
|
|
96
|
+
};
|
|
85
97
|
pressureStick: {
|
|
86
98
|
nameRegex: RegExp;
|
|
87
99
|
communication: {
|
|
@@ -750,7 +762,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
|
|
|
750
762
|
};
|
|
751
763
|
type BleDeviceType = keyof typeof _default$1;
|
|
752
764
|
/** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
|
|
753
|
-
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleTorqueWrench;
|
|
765
|
+
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench;
|
|
754
766
|
type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
|
|
755
767
|
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
|
|
756
768
|
interface BleDeviceBase {
|
|
@@ -774,6 +786,9 @@ interface BleBridge extends BleDeviceBase {
|
|
|
774
786
|
interface BleFlexiGaugeTpms extends BleDeviceBase {
|
|
775
787
|
type: 'flexiGaugeTpms';
|
|
776
788
|
}
|
|
789
|
+
interface BleFlexiGauge extends BleDeviceBase {
|
|
790
|
+
type: 'flexiGauge';
|
|
791
|
+
}
|
|
777
792
|
interface BleTorqueWrench extends BleDeviceBase {
|
|
778
793
|
type: 'torqueWrench';
|
|
779
794
|
}
|
|
@@ -932,6 +947,13 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
932
947
|
setSensorDisplayId: (deviceId: string, oldSensorId: string, newSensorId: string) => Promise<void>;
|
|
933
948
|
resetSensorDisplayId: (deviceId: string, sensorId: string) => Promise<void>;
|
|
934
949
|
};
|
|
950
|
+
flexiGauge: {
|
|
951
|
+
connect(deviceId: string): Promise<void>;
|
|
952
|
+
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
953
|
+
onTreadDepth: (callback: (deviceId: string, value: number) => void) => void;
|
|
954
|
+
onButtonPress: (callback: (deviceId: string, value: string) => void) => void;
|
|
955
|
+
getBattery: (deviceId: string) => Promise<number>;
|
|
956
|
+
};
|
|
935
957
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
936
958
|
pressureStick: {
|
|
937
959
|
connect(deviceId: string): Promise<void>;
|
|
@@ -967,4 +989,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
967
989
|
};
|
|
968
990
|
};
|
|
969
991
|
|
|
970
|
-
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 };
|
|
992
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeOta, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BleFlexiGauge, 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
|
@@ -520,27 +520,9 @@ const deviceMeta = {
|
|
|
520
520
|
},
|
|
521
521
|
getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
|
|
522
522
|
},
|
|
523
|
-
// flexiGauge: {
|
|
524
|
-
// nameRegex: /^Flexi.*v.*/,
|
|
525
|
-
// communication: {
|
|
526
|
-
// serviceId: '4880c12c-fdcb-4077-8920-a450d7f9b907',
|
|
527
|
-
// characteristicId: 'fec26ec4-6d71-4442-9f81-55bc21d658d6',
|
|
528
|
-
// },
|
|
529
|
-
// battery: {
|
|
530
|
-
// serviceId: '180f',
|
|
531
|
-
// characteristicId: '2a19',
|
|
532
|
-
// },
|
|
533
|
-
// getDeviceInfoFromAdvertising: (device: PeripheralData) => {
|
|
534
|
-
// const bleDevice: BleDevice = {
|
|
535
|
-
// ...device,
|
|
536
|
-
// type: 'flexiGauge',
|
|
537
|
-
// }
|
|
538
|
-
// return bleDevice
|
|
539
|
-
// },
|
|
540
|
-
// },
|
|
541
523
|
flexiGaugeTpms: {
|
|
542
524
|
// after implementation of normal fg replace with /^Flexi.*TPMS.*/,
|
|
543
|
-
nameRegex: /^Flexi.*/,
|
|
525
|
+
nameRegex: /^Flexi.*TPMS.*/,
|
|
544
526
|
communication: {
|
|
545
527
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
546
528
|
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
|
|
@@ -557,6 +539,24 @@ const deviceMeta = {
|
|
|
557
539
|
return bleDevice;
|
|
558
540
|
}
|
|
559
541
|
},
|
|
542
|
+
flexiGauge: {
|
|
543
|
+
nameRegex: /^Flexi.*/,
|
|
544
|
+
communication: {
|
|
545
|
+
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
546
|
+
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
|
|
547
|
+
},
|
|
548
|
+
battery: {
|
|
549
|
+
serviceId: "180f",
|
|
550
|
+
characteristicId: "2a19"
|
|
551
|
+
},
|
|
552
|
+
getDeviceInfoFromAdvertising: (device) => {
|
|
553
|
+
const bleDevice = {
|
|
554
|
+
...device,
|
|
555
|
+
type: "flexiGauge"
|
|
556
|
+
};
|
|
557
|
+
return bleDevice;
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
560
|
pressureStick: {
|
|
561
561
|
nameRegex: /Pressure Stick.*/,
|
|
562
562
|
communication: {
|
|
@@ -2748,6 +2748,134 @@ async function disconnect(deviceId, reason) {
|
|
|
2748
2748
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2749
2749
|
}
|
|
2750
2750
|
|
|
2751
|
+
const callbacks = {};
|
|
2752
|
+
const simulatorSvc = {
|
|
2753
|
+
registerEvent(eventName, callback) {
|
|
2754
|
+
callbacks[eventName] = callback;
|
|
2755
|
+
},
|
|
2756
|
+
triggerEvent(eventName, deviceId, payload) {
|
|
2757
|
+
if (payload === void 0) {
|
|
2758
|
+
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2759
|
+
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2760
|
+
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2761
|
+
if (!payload) throw new Error(`Event not found`);
|
|
2762
|
+
}
|
|
2763
|
+
const callback = callbacks[eventName];
|
|
2764
|
+
if (!callback) {
|
|
2765
|
+
console.warn(`Event ${eventName} not registered`);
|
|
2766
|
+
} else {
|
|
2767
|
+
callback(deviceId, payload);
|
|
2768
|
+
}
|
|
2769
|
+
},
|
|
2770
|
+
merge(deviceTemplate, initialData) {
|
|
2771
|
+
return _.mergeWith({}, deviceTemplate, initialData, (a, b) => _.isArray(b) ? b : void 0);
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
|
|
2775
|
+
const flexiGaugeTpmsMeta$1 = deviceMeta.flexiGaugeTpms;
|
|
2776
|
+
const flexiGaugeCommands = {
|
|
2777
|
+
getBattery: getBattery$1,
|
|
2778
|
+
sendKeepAlive
|
|
2779
|
+
};
|
|
2780
|
+
async function getBattery$1(deviceId) {
|
|
2781
|
+
const batteryValue = await bluetooth.read(
|
|
2782
|
+
deviceId,
|
|
2783
|
+
flexiGaugeTpmsMeta$1.battery.serviceId,
|
|
2784
|
+
flexiGaugeTpmsMeta$1.battery.characteristicId
|
|
2785
|
+
);
|
|
2786
|
+
const battery = Array.from(new Uint8Array(batteryValue))[0];
|
|
2787
|
+
return battery;
|
|
2788
|
+
}
|
|
2789
|
+
async function sendKeepAlive(deviceId) {
|
|
2790
|
+
if (!canCommunicateWith(deviceId)) throw new Error("Flexi Gauge not connected");
|
|
2791
|
+
const scanMsg = stringToArrayBuffer("Z\r\n");
|
|
2792
|
+
return bluetooth.write(
|
|
2793
|
+
deviceId,
|
|
2794
|
+
flexiGaugeTpmsMeta$1.communication.serviceId,
|
|
2795
|
+
flexiGaugeTpmsMeta$1.communication.characteristicId,
|
|
2796
|
+
scanMsg
|
|
2797
|
+
);
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
const capabilities$2 = [
|
|
2801
|
+
{
|
|
2802
|
+
id: "td",
|
|
2803
|
+
processFn: processTreadDepth$1,
|
|
2804
|
+
regex: /^\*?T.*/
|
|
2805
|
+
},
|
|
2806
|
+
{
|
|
2807
|
+
id: "button",
|
|
2808
|
+
processFn: processButtonPress$1,
|
|
2809
|
+
regex: /^[UDLRC]$/
|
|
2810
|
+
},
|
|
2811
|
+
{
|
|
2812
|
+
id: "keepAlive",
|
|
2813
|
+
processFn: processKeepAlive,
|
|
2814
|
+
// eslint-disable-next-line no-control-regex
|
|
2815
|
+
regex: /Z\u0011/
|
|
2816
|
+
}
|
|
2817
|
+
];
|
|
2818
|
+
const flexiGaugeTpmsService$1 = {
|
|
2819
|
+
getBattery(deviceId) {
|
|
2820
|
+
return flexiGaugeCommands.getBattery(deviceId);
|
|
2821
|
+
},
|
|
2822
|
+
onTreadDepth(callback) {
|
|
2823
|
+
simulatorSvc.registerEvent("fg:treadDepth", callback);
|
|
2824
|
+
},
|
|
2825
|
+
onButton(callback) {
|
|
2826
|
+
simulatorSvc.registerEvent("fg:button", callback);
|
|
2827
|
+
},
|
|
2828
|
+
onTpms(callback) {
|
|
2829
|
+
simulatorSvc.registerEvent("fg:tpms", callback);
|
|
2830
|
+
},
|
|
2831
|
+
icon: "icon-flexigauge",
|
|
2832
|
+
processMessage(deviceId, message) {
|
|
2833
|
+
const numberArray = Array.from(new Uint8Array(message));
|
|
2834
|
+
const stringFromBytes = String.fromCharCode.apply(null, numberArray).replace("\r\n", "");
|
|
2835
|
+
for (const capability of capabilities$2) {
|
|
2836
|
+
if (capability.regex.test(stringFromBytes)) {
|
|
2837
|
+
return capability.processFn(deviceId, stringFromBytes);
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
};
|
|
2842
|
+
function processKeepAlive(deviceId) {
|
|
2843
|
+
flexiGaugeCommands.sendKeepAlive(deviceId);
|
|
2844
|
+
}
|
|
2845
|
+
function processTreadDepth$1(deviceId, value) {
|
|
2846
|
+
const treadDepth = value.match(/\d+/)?.[0];
|
|
2847
|
+
const convertedValue = Number(treadDepth) / 1e3;
|
|
2848
|
+
simulatorSvc.triggerEvent("fg:treadDepth", deviceId, convertedValue);
|
|
2849
|
+
}
|
|
2850
|
+
function processButtonPress$1(deviceId, value) {
|
|
2851
|
+
const buttonName = value.match(/\*?(.)/);
|
|
2852
|
+
if (!buttonName || !buttonName[1]) throw new Error("Unrecognized button");
|
|
2853
|
+
simulatorSvc.triggerEvent("fg:button", deviceId, buttonName[1]);
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
const flexiGauge = {
|
|
2857
|
+
async connect(deviceId) {
|
|
2858
|
+
const fgMeta = deviceMeta.flexiGaugeTpms;
|
|
2859
|
+
await bluetooth.connect(deviceId, this.disconnect);
|
|
2860
|
+
await ble.startNotification(
|
|
2861
|
+
deviceId,
|
|
2862
|
+
fgMeta.communication.serviceId,
|
|
2863
|
+
fgMeta.communication.characteristicId,
|
|
2864
|
+
(notification) => flexiGaugeTpmsService$1.processMessage(deviceId, notification),
|
|
2865
|
+
(error) => console.warn("ble.startNotification error", error)
|
|
2866
|
+
);
|
|
2867
|
+
store.setState(deviceId, "paired");
|
|
2868
|
+
},
|
|
2869
|
+
async disconnect(deviceId, reason) {
|
|
2870
|
+
store.setState(deviceId, "disconnecting");
|
|
2871
|
+
await bluetooth.disconnect(deviceId);
|
|
2872
|
+
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2873
|
+
},
|
|
2874
|
+
onTreadDepth: flexiGaugeTpmsService$1.onTreadDepth,
|
|
2875
|
+
onButtonPress: flexiGaugeTpmsService$1.onButton,
|
|
2876
|
+
getBattery: flexiGaugeTpmsService$1.getBattery
|
|
2877
|
+
};
|
|
2878
|
+
|
|
2751
2879
|
const devicePromiseQueue = {};
|
|
2752
2880
|
const deviceCurrentResolve = {};
|
|
2753
2881
|
const deviceCurrentReject = {};
|
|
@@ -2802,30 +2930,6 @@ const promiseQueue = {
|
|
|
2802
2930
|
}
|
|
2803
2931
|
};
|
|
2804
2932
|
|
|
2805
|
-
const callbacks = {};
|
|
2806
|
-
const simulatorSvc = {
|
|
2807
|
-
registerEvent(eventName, callback) {
|
|
2808
|
-
callbacks[eventName] = callback;
|
|
2809
|
-
},
|
|
2810
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2811
|
-
if (payload === void 0) {
|
|
2812
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2813
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2814
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2815
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2816
|
-
}
|
|
2817
|
-
const callback = callbacks[eventName];
|
|
2818
|
-
if (!callback) {
|
|
2819
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2820
|
-
} else {
|
|
2821
|
-
callback(deviceId, payload);
|
|
2822
|
-
}
|
|
2823
|
-
},
|
|
2824
|
-
merge(deviceTemplate, initialData) {
|
|
2825
|
-
return _.mergeWith({}, deviceTemplate, initialData, (a, b) => _.isArray(b) ? b : void 0);
|
|
2826
|
-
}
|
|
2827
|
-
};
|
|
2828
|
-
|
|
2829
2933
|
const flexiGaugeTpmsSecurity = {
|
|
2830
2934
|
getCommandsSignature(seed) {
|
|
2831
2935
|
const key = store.securityKeys?.flexiGaugeTpms?.signatureKeys.allLFCommands;
|
|
@@ -4088,7 +4192,7 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4088
4192
|
bridgeOta,
|
|
4089
4193
|
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
4090
4194
|
flexiGaugeTpms,
|
|
4091
|
-
|
|
4195
|
+
flexiGauge,
|
|
4092
4196
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
4093
4197
|
pressureStick,
|
|
4094
4198
|
// ateq,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.36",
|
|
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",
|