tirecheck-device-sdk 0.2.33 → 0.2.35
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 +151 -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 +151 -44
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -527,27 +527,27 @@ const deviceMeta = {
|
|
|
527
527
|
},
|
|
528
528
|
getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
|
|
529
529
|
},
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
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) => {
|
|
541
|
+
const bleDevice = {
|
|
542
|
+
...device,
|
|
543
|
+
type: "flexiGauge"
|
|
544
|
+
};
|
|
545
|
+
return bleDevice;
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
548
|
flexiGaugeTpms: {
|
|
549
549
|
// after implementation of normal fg replace with /^Flexi.*TPMS.*/,
|
|
550
|
-
nameRegex: /^Flexi.*/,
|
|
550
|
+
nameRegex: /^Flexi.*TPMS.*/,
|
|
551
551
|
communication: {
|
|
552
552
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
553
553
|
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
|
|
@@ -2364,6 +2364,9 @@ async function setConfiguration(deviceId, bridgeConfiguration) {
|
|
|
2364
2364
|
if (configurationValidation.differences.includes("pressuresPerAxle")) {
|
|
2365
2365
|
await bridgeCommands.setPressuresPerAxle(deviceId, bridgeConfiguration.pressuresPerAxle);
|
|
2366
2366
|
}
|
|
2367
|
+
if (configurationValidation.differences.includes("autolearnSettings")) {
|
|
2368
|
+
await bridgeCommands.setAutoLearnSettings(deviceId, bridgeConfiguration.autolearnSettings);
|
|
2369
|
+
}
|
|
2367
2370
|
}
|
|
2368
2371
|
async function setVehicle(deviceId, tcVehicle) {
|
|
2369
2372
|
const currentTcVehicle = await getVehicle(deviceId);
|
|
@@ -2752,6 +2755,134 @@ async function disconnect(deviceId, reason) {
|
|
|
2752
2755
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2753
2756
|
}
|
|
2754
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
|
+
|
|
2755
2886
|
const devicePromiseQueue = {};
|
|
2756
2887
|
const deviceCurrentResolve = {};
|
|
2757
2888
|
const deviceCurrentReject = {};
|
|
@@ -2806,30 +2937,6 @@ const promiseQueue = {
|
|
|
2806
2937
|
}
|
|
2807
2938
|
};
|
|
2808
2939
|
|
|
2809
|
-
const callbacks = {};
|
|
2810
|
-
const simulatorSvc = {
|
|
2811
|
-
registerEvent(eventName, callback) {
|
|
2812
|
-
callbacks[eventName] = callback;
|
|
2813
|
-
},
|
|
2814
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2815
|
-
if (payload === void 0) {
|
|
2816
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2817
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2818
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2819
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2820
|
-
}
|
|
2821
|
-
const callback = callbacks[eventName];
|
|
2822
|
-
if (!callback) {
|
|
2823
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2824
|
-
} else {
|
|
2825
|
-
callback(deviceId, payload);
|
|
2826
|
-
}
|
|
2827
|
-
},
|
|
2828
|
-
merge(deviceTemplate, initialData) {
|
|
2829
|
-
return ___default.mergeWith({}, deviceTemplate, initialData, (a, b) => ___default.isArray(b) ? b : void 0);
|
|
2830
|
-
}
|
|
2831
|
-
};
|
|
2832
|
-
|
|
2833
2940
|
const flexiGaugeTpmsSecurity = {
|
|
2834
2941
|
getCommandsSignature(seed) {
|
|
2835
2942
|
const key = store.securityKeys?.flexiGaugeTpms?.signatureKeys.allLFCommands;
|
|
@@ -4092,7 +4199,7 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4092
4199
|
bridgeOta,
|
|
4093
4200
|
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
4094
4201
|
flexiGaugeTpms,
|
|
4095
|
-
|
|
4202
|
+
flexiGauge,
|
|
4096
4203
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
4097
4204
|
pressureStick,
|
|
4098
4205
|
// ateq,
|
package/dist/index.d.cts
CHANGED
|
@@ -70,6 +70,18 @@ declare const _default$1: {
|
|
|
70
70
|
};
|
|
71
71
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleDevice | undefined;
|
|
72
72
|
};
|
|
73
|
+
flexiGauge: {
|
|
74
|
+
nameRegex: RegExp;
|
|
75
|
+
communication: {
|
|
76
|
+
serviceId: string;
|
|
77
|
+
characteristicId: string;
|
|
78
|
+
};
|
|
79
|
+
battery: {
|
|
80
|
+
serviceId: string;
|
|
81
|
+
characteristicId: string;
|
|
82
|
+
};
|
|
83
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGauge;
|
|
84
|
+
};
|
|
73
85
|
flexiGaugeTpms: {
|
|
74
86
|
nameRegex: RegExp;
|
|
75
87
|
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
|
@@ -70,6 +70,18 @@ declare const _default$1: {
|
|
|
70
70
|
};
|
|
71
71
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleDevice | undefined;
|
|
72
72
|
};
|
|
73
|
+
flexiGauge: {
|
|
74
|
+
nameRegex: RegExp;
|
|
75
|
+
communication: {
|
|
76
|
+
serviceId: string;
|
|
77
|
+
characteristicId: string;
|
|
78
|
+
};
|
|
79
|
+
battery: {
|
|
80
|
+
serviceId: string;
|
|
81
|
+
characteristicId: string;
|
|
82
|
+
};
|
|
83
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGauge;
|
|
84
|
+
};
|
|
73
85
|
flexiGaugeTpms: {
|
|
74
86
|
nameRegex: RegExp;
|
|
75
87
|
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
|
@@ -70,6 +70,18 @@ declare const _default$1: {
|
|
|
70
70
|
};
|
|
71
71
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleDevice | undefined;
|
|
72
72
|
};
|
|
73
|
+
flexiGauge: {
|
|
74
|
+
nameRegex: RegExp;
|
|
75
|
+
communication: {
|
|
76
|
+
serviceId: string;
|
|
77
|
+
characteristicId: string;
|
|
78
|
+
};
|
|
79
|
+
battery: {
|
|
80
|
+
serviceId: string;
|
|
81
|
+
characteristicId: string;
|
|
82
|
+
};
|
|
83
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleFlexiGauge;
|
|
84
|
+
};
|
|
73
85
|
flexiGaugeTpms: {
|
|
74
86
|
nameRegex: RegExp;
|
|
75
87
|
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,27 @@ const deviceMeta = {
|
|
|
520
520
|
},
|
|
521
521
|
getDeviceInfoFromAdvertising: bridgeOtaAdvertisingParser.getDeviceInfoFromAdvertising
|
|
522
522
|
},
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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) => {
|
|
534
|
+
const bleDevice = {
|
|
535
|
+
...device,
|
|
536
|
+
type: "flexiGauge"
|
|
537
|
+
};
|
|
538
|
+
return bleDevice;
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
541
|
flexiGaugeTpms: {
|
|
542
542
|
// after implementation of normal fg replace with /^Flexi.*TPMS.*/,
|
|
543
|
-
nameRegex: /^Flexi.*/,
|
|
543
|
+
nameRegex: /^Flexi.*TPMS.*/,
|
|
544
544
|
communication: {
|
|
545
545
|
serviceId: "4880c12c-fdcb-4077-8920-a450d7f9b907",
|
|
546
546
|
characteristicId: "fec26ec4-6d71-4442-9f81-55bc21d658d6"
|
|
@@ -2357,6 +2357,9 @@ async function setConfiguration(deviceId, bridgeConfiguration) {
|
|
|
2357
2357
|
if (configurationValidation.differences.includes("pressuresPerAxle")) {
|
|
2358
2358
|
await bridgeCommands.setPressuresPerAxle(deviceId, bridgeConfiguration.pressuresPerAxle);
|
|
2359
2359
|
}
|
|
2360
|
+
if (configurationValidation.differences.includes("autolearnSettings")) {
|
|
2361
|
+
await bridgeCommands.setAutoLearnSettings(deviceId, bridgeConfiguration.autolearnSettings);
|
|
2362
|
+
}
|
|
2360
2363
|
}
|
|
2361
2364
|
async function setVehicle(deviceId, tcVehicle) {
|
|
2362
2365
|
const currentTcVehicle = await getVehicle(deviceId);
|
|
@@ -2745,6 +2748,134 @@ async function disconnect(deviceId, reason) {
|
|
|
2745
2748
|
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
2746
2749
|
}
|
|
2747
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
|
+
|
|
2748
2879
|
const devicePromiseQueue = {};
|
|
2749
2880
|
const deviceCurrentResolve = {};
|
|
2750
2881
|
const deviceCurrentReject = {};
|
|
@@ -2799,30 +2930,6 @@ const promiseQueue = {
|
|
|
2799
2930
|
}
|
|
2800
2931
|
};
|
|
2801
2932
|
|
|
2802
|
-
const callbacks = {};
|
|
2803
|
-
const simulatorSvc = {
|
|
2804
|
-
registerEvent(eventName, callback) {
|
|
2805
|
-
callbacks[eventName] = callback;
|
|
2806
|
-
},
|
|
2807
|
-
triggerEvent(eventName, deviceId, payload) {
|
|
2808
|
-
if (payload === void 0) {
|
|
2809
|
-
const simulatedDevice = store.simulatedDevices[deviceId];
|
|
2810
|
-
if (!simulatedDevice) throw new Error(`Device not found`);
|
|
2811
|
-
payload = simulatedDevice.simulatorData?.events?.[eventName];
|
|
2812
|
-
if (!payload) throw new Error(`Event not found`);
|
|
2813
|
-
}
|
|
2814
|
-
const callback = callbacks[eventName];
|
|
2815
|
-
if (!callback) {
|
|
2816
|
-
console.warn(`Event ${eventName} not registered`);
|
|
2817
|
-
} else {
|
|
2818
|
-
callback(deviceId, payload);
|
|
2819
|
-
}
|
|
2820
|
-
},
|
|
2821
|
-
merge(deviceTemplate, initialData) {
|
|
2822
|
-
return _.mergeWith({}, deviceTemplate, initialData, (a, b) => _.isArray(b) ? b : void 0);
|
|
2823
|
-
}
|
|
2824
|
-
};
|
|
2825
|
-
|
|
2826
2933
|
const flexiGaugeTpmsSecurity = {
|
|
2827
2934
|
getCommandsSignature(seed) {
|
|
2828
2935
|
const key = store.securityKeys?.flexiGaugeTpms?.signatureKeys.allLFCommands;
|
|
@@ -4085,7 +4192,7 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4085
4192
|
bridgeOta,
|
|
4086
4193
|
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
4087
4194
|
flexiGaugeTpms,
|
|
4088
|
-
|
|
4195
|
+
flexiGauge,
|
|
4089
4196
|
/** Methods for working with Tirecheck Pressure Stick */
|
|
4090
4197
|
pressureStick,
|
|
4091
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.35",
|
|
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",
|