tirecheck-device-sdk 0.1.2 → 0.1.4
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 +2758 -221
- package/dist/index.d.cts +201 -31
- package/dist/index.d.mts +201 -31
- package/dist/index.d.ts +201 -31
- package/dist/index.mjs +2757 -222
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,14 @@ interface BleImplementation {
|
|
|
3
3
|
stopScan: () => Promise<void>;
|
|
4
4
|
/** Returns a resolved promise if the device is connected,
|
|
5
5
|
otherwise returns rejected promise if the device is not connected */
|
|
6
|
-
isConnected: (
|
|
6
|
+
isConnected: (deviceId: string) => Promise<boolean>;
|
|
7
|
+
connect: (device_id: string, connectCallback: (data: PeripheralDataExtended) => any, disconnectCallback: (error: string | BLEError) => any) => void;
|
|
8
|
+
disconnect: (deviceId: string) => Promise<void>;
|
|
9
|
+
read: (deviceId: string, serviceUuid: string, characteristicUuid: string) => Promise<ArrayBuffer>;
|
|
10
|
+
writeWithoutResponse: (deviceId: string, serviceUuid: string, characteristicUuid: string, value: ArrayBuffer) => void;
|
|
11
|
+
startNotification: (deviceId: string, serviceUuid: string, characteristicUuid: string, success: (rawData: ArrayBuffer) => any, failure?: (error: string | BLEError) => any) => Promise<void>;
|
|
12
|
+
isEnabled: () => Promise<void>;
|
|
13
|
+
requestMtu: (deviceId: string, mtu: number) => Promise<number>;
|
|
7
14
|
}
|
|
8
15
|
interface StartScanOptions {
|
|
9
16
|
scanMode?: 'lowPower' | 'balanced' | 'lowLatency' | 'opportunistic';
|
|
@@ -18,6 +25,11 @@ interface StartScanOptions {
|
|
|
18
25
|
/** Scanning duration in seconds */
|
|
19
26
|
duration?: number;
|
|
20
27
|
}
|
|
28
|
+
interface BLEError {
|
|
29
|
+
name: string;
|
|
30
|
+
id: string;
|
|
31
|
+
errorMessage: string;
|
|
32
|
+
}
|
|
21
33
|
interface PeripheralData {
|
|
22
34
|
name: string;
|
|
23
35
|
id: string;
|
|
@@ -26,17 +38,25 @@ interface PeripheralData {
|
|
|
26
38
|
connectable?: boolean;
|
|
27
39
|
state: PeripheralState;
|
|
28
40
|
}
|
|
41
|
+
interface PeripheralDataExtended extends PeripheralData {
|
|
42
|
+
services: string[];
|
|
43
|
+
characteristics: PeripheralCharacteristic[];
|
|
44
|
+
}
|
|
45
|
+
interface PeripheralCharacteristic {
|
|
46
|
+
service: string;
|
|
47
|
+
characteristic: string;
|
|
48
|
+
properties: string[];
|
|
49
|
+
descriptors?: any[];
|
|
50
|
+
}
|
|
29
51
|
type PeripheralState = 'disconnected' | 'disconnecting' | 'connecting' | 'connected';
|
|
30
52
|
|
|
31
53
|
declare const _default: {
|
|
32
54
|
bridge: {
|
|
33
55
|
nameRegex: RegExp;
|
|
34
|
-
|
|
56
|
+
communication: {
|
|
35
57
|
serviceId: string;
|
|
36
58
|
characteristicId: string;
|
|
37
59
|
};
|
|
38
|
-
capabilities: never[];
|
|
39
|
-
manufacturerId: number;
|
|
40
60
|
mtu: number;
|
|
41
61
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleBridge | undefined;
|
|
42
62
|
};
|
|
@@ -46,36 +66,121 @@ declare const _default: {
|
|
|
46
66
|
serviceId: string;
|
|
47
67
|
characteristicId: string;
|
|
48
68
|
};
|
|
49
|
-
|
|
50
|
-
getDeviceInfoFromAdvertising: () => void;
|
|
69
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleDeviceBase;
|
|
51
70
|
};
|
|
52
71
|
flexiGaugeTpms: {
|
|
53
72
|
nameRegex: RegExp;
|
|
54
|
-
|
|
73
|
+
communication: {
|
|
55
74
|
serviceId: string;
|
|
56
75
|
characteristicId: string;
|
|
57
76
|
};
|
|
58
|
-
|
|
59
|
-
capabilities: {
|
|
60
|
-
id: string;
|
|
61
|
-
regex: RegExp;
|
|
62
|
-
}[];
|
|
63
|
-
reconnect: boolean;
|
|
64
|
-
};
|
|
65
|
-
pressureStick: {
|
|
66
|
-
nameRegex: RegExp;
|
|
67
|
-
characteristic: {
|
|
77
|
+
battery: {
|
|
68
78
|
serviceId: string;
|
|
69
79
|
characteristicId: string;
|
|
70
80
|
};
|
|
71
|
-
getDeviceInfoFromAdvertising: () =>
|
|
72
|
-
|
|
73
|
-
id: string;
|
|
74
|
-
regex: RegExp;
|
|
75
|
-
}[];
|
|
81
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleDeviceBase;
|
|
82
|
+
reconnect: boolean;
|
|
76
83
|
};
|
|
77
84
|
};
|
|
78
85
|
|
|
86
|
+
interface BridgeTcVehicle {
|
|
87
|
+
registrationNumber?: string;
|
|
88
|
+
vin?: string;
|
|
89
|
+
axles: BridgeTcVehicleAxle[];
|
|
90
|
+
tcTyres: BridgeTcTyre[];
|
|
91
|
+
tcBridge: {
|
|
92
|
+
id: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface BridgeTcTyre {
|
|
96
|
+
mountedOn?: TcTyreMountedOn;
|
|
97
|
+
serialNumber?: string;
|
|
98
|
+
temperature?: number;
|
|
99
|
+
tcTpmsSensor?: {
|
|
100
|
+
id: string;
|
|
101
|
+
};
|
|
102
|
+
pressure?: number;
|
|
103
|
+
}
|
|
104
|
+
declare class TcTyreMountedOn {
|
|
105
|
+
positionId: number;
|
|
106
|
+
}
|
|
107
|
+
interface FgSensorReading {
|
|
108
|
+
Alg?: string;
|
|
109
|
+
Rssi: string;
|
|
110
|
+
ID: string;
|
|
111
|
+
PA?: number;
|
|
112
|
+
PC: number;
|
|
113
|
+
T: number;
|
|
114
|
+
S?: string;
|
|
115
|
+
}
|
|
116
|
+
declare class BridgeTcVehicleAxle {
|
|
117
|
+
targetPressure?: number;
|
|
118
|
+
tyresCount: number;
|
|
119
|
+
isSteer?: boolean;
|
|
120
|
+
isSpare?: boolean;
|
|
121
|
+
isDrive?: boolean;
|
|
122
|
+
isLift?: boolean;
|
|
123
|
+
spacesBelow?: number;
|
|
124
|
+
maxTargetPressure?: number;
|
|
125
|
+
minTargetPressure?: number;
|
|
126
|
+
}
|
|
127
|
+
interface BridgeConfiguration {
|
|
128
|
+
customerCANSettings: any;
|
|
129
|
+
workshopCANSettings: any;
|
|
130
|
+
bridgeConfiguration: any;
|
|
131
|
+
customerPressureThresholds: any;
|
|
132
|
+
customerTemperatureThresholds: any;
|
|
133
|
+
customerImbalanceThresholds: any;
|
|
134
|
+
pressuresPerAxle: any;
|
|
135
|
+
/** only available after 0.9.8 fw */
|
|
136
|
+
autolearnSettings?: any;
|
|
137
|
+
}
|
|
138
|
+
interface BridgeReading {
|
|
139
|
+
date: number;
|
|
140
|
+
sensorId: string;
|
|
141
|
+
sensorStatus: number;
|
|
142
|
+
eceStatus: number;
|
|
143
|
+
pressureIssue?: BridgeTcIssue;
|
|
144
|
+
pressure?: {
|
|
145
|
+
raw: number;
|
|
146
|
+
meas: number;
|
|
147
|
+
bar: number;
|
|
148
|
+
};
|
|
149
|
+
temperature?: {
|
|
150
|
+
raw: number;
|
|
151
|
+
amb: number;
|
|
152
|
+
celsius: number;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
interface BridgeAutolearnStatus {
|
|
156
|
+
positionId: number;
|
|
157
|
+
/** Only populated for 'known' and 'unknown' statuses */
|
|
158
|
+
autolearnedSensorId?: string;
|
|
159
|
+
autolearnedStatus: 'default' | 'known' | 'unknown' | 'error';
|
|
160
|
+
}
|
|
161
|
+
interface BridgeTcIssue {
|
|
162
|
+
date: number;
|
|
163
|
+
tcIssue: {
|
|
164
|
+
id: string;
|
|
165
|
+
};
|
|
166
|
+
type: string;
|
|
167
|
+
severity: string;
|
|
168
|
+
}
|
|
169
|
+
interface PositionInfo {
|
|
170
|
+
positionId?: number;
|
|
171
|
+
axlePosition: number | null;
|
|
172
|
+
tyrePosition: number | null | undefined;
|
|
173
|
+
axleTyresCount?: number;
|
|
174
|
+
name: string;
|
|
175
|
+
description?: string;
|
|
176
|
+
isSpareTyre?: boolean;
|
|
177
|
+
isLeftTyre?: boolean;
|
|
178
|
+
isRightTyre?: boolean;
|
|
179
|
+
isCenterTyre?: boolean;
|
|
180
|
+
isTwinTyre?: boolean;
|
|
181
|
+
isOuterTwinTyre?: boolean;
|
|
182
|
+
isInnerTwinTyre?: boolean;
|
|
183
|
+
}
|
|
79
184
|
interface BluetoothDeviceCharacteristic {
|
|
80
185
|
serviceId: string;
|
|
81
186
|
characteristicId: string;
|
|
@@ -85,6 +190,18 @@ interface BluetoothDeviceCapability {
|
|
|
85
190
|
processFn: Function;
|
|
86
191
|
regex: RegExp;
|
|
87
192
|
}
|
|
193
|
+
interface BridgeCommandStructure {
|
|
194
|
+
id: number[];
|
|
195
|
+
name: string;
|
|
196
|
+
structure: BridgeCommandStructureProperties;
|
|
197
|
+
}
|
|
198
|
+
interface BridgeCommandStructureProperties {
|
|
199
|
+
[propName: string]: {
|
|
200
|
+
size: number;
|
|
201
|
+
display?: 'decimal' | 'ascii';
|
|
202
|
+
description: string;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
88
205
|
interface BluetoothDeviceHandler {
|
|
89
206
|
/** Characteristic on which device sends messages, will be subscribed by connect function */
|
|
90
207
|
characteristic: BluetoothDeviceCharacteristic;
|
|
@@ -111,14 +228,24 @@ interface BluetoothDeviceHandler {
|
|
|
111
228
|
onDisconnected?: Function;
|
|
112
229
|
}
|
|
113
230
|
type BleDeviceType = keyof typeof _default;
|
|
114
|
-
type BleDevice = BleBridge;
|
|
115
|
-
|
|
231
|
+
type BleDevice = BleBridge | BleDeviceBase;
|
|
232
|
+
type BleDeviceSimulated = BleBridgeSimulated;
|
|
233
|
+
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | 'disconnected' | undefined;
|
|
234
|
+
interface BleDeviceBase {
|
|
116
235
|
id: string;
|
|
117
236
|
name: string;
|
|
237
|
+
type: BleDeviceType;
|
|
238
|
+
rssi: number;
|
|
239
|
+
status?: BleDeviceStatus;
|
|
240
|
+
}
|
|
241
|
+
interface BleBridge extends BleDeviceBase {
|
|
242
|
+
type: 'bridge';
|
|
118
243
|
bridgeId: string;
|
|
119
244
|
vin: string;
|
|
120
245
|
advertisingData: BleBridgeAdvertisingData;
|
|
121
|
-
|
|
246
|
+
}
|
|
247
|
+
interface BleBridgeSimulated extends BleBridge {
|
|
248
|
+
simulatorData: Record<string, any>;
|
|
122
249
|
}
|
|
123
250
|
interface BleBridgeAdvertisingData {
|
|
124
251
|
randomAdvNumber: number[];
|
|
@@ -135,17 +262,60 @@ interface BleBridgeAdvertisingData {
|
|
|
135
262
|
configVersion: number;
|
|
136
263
|
timeFromStart?: number;
|
|
137
264
|
}
|
|
265
|
+
type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
266
|
+
[K in keyof T]: (...args: [next: (...paramsOverride: any[]) => ReturnType<T[K]>, ...Parameters<T[K]>]) => ReturnType<T[K]>;
|
|
267
|
+
};
|
|
268
|
+
type ReportStatusFn = (status: string, completionPercentage: number) => void;
|
|
138
269
|
|
|
139
270
|
declare function createTirecheckDeviceSdk(bleImplementation: BleImplementation): {
|
|
271
|
+
/** Generic methods common for all devices */
|
|
140
272
|
bluetooth: {
|
|
141
273
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
142
|
-
onDeviceUpdate(callback: (update: {
|
|
143
|
-
deviceId: string;
|
|
144
|
-
isConnected: boolean;
|
|
145
|
-
}) => void): void;
|
|
146
274
|
onDeviceUnreachable(callback: (deviceId: string) => void): void;
|
|
147
|
-
|
|
275
|
+
onDeviceLostConnection(callback: (deviceId: string) => void): void;
|
|
276
|
+
scanDevices: (services?: string[], duration?: number) => Promise<void>;
|
|
277
|
+
stopScan(): void;
|
|
278
|
+
connect: (deviceId: string, disconnectCallback: (deviceId: string) => void) => Promise<PeripheralDataExtended | undefined>;
|
|
279
|
+
disconnect: (deviceId: string) => Promise<void>;
|
|
280
|
+
write: (deviceId: string, serviceUuid: string, characteristicUuid: string, value: ArrayBuffer) => Promise<void>;
|
|
281
|
+
read: (deviceId: string, serviceUuid: string, characteristicUuid: string) => Promise<number[]>;
|
|
282
|
+
};
|
|
283
|
+
/** Methods for working with Tirecheck CAN Bridge */
|
|
284
|
+
bridge: {
|
|
285
|
+
connect(deviceId: string): Promise<void>;
|
|
286
|
+
disconnect(deviceId: string): Promise<void>;
|
|
287
|
+
getVehicle: (deviceId: string) => Promise<BridgeTcVehicle>;
|
|
288
|
+
setVehicle: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<void>;
|
|
289
|
+
getConfiguration: (deviceId: string) => Promise<BridgeConfiguration>;
|
|
290
|
+
setConfiguration: (deviceId: string, bridgeConfiguration: BridgeConfiguration) => Promise<void>;
|
|
291
|
+
getSensorReading: (deviceId: string, positionId: number) => Promise<BridgeReading>;
|
|
292
|
+
getVehicleReadings: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeReading[] | undefined>;
|
|
293
|
+
getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
|
|
294
|
+
resetAutolearnStatuses: (deviceId: string, positionIds: number[]) => Promise<void>;
|
|
295
|
+
updateFirmware: (deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, reportStatus: ReportStatusFn) => Promise<void>;
|
|
296
|
+
};
|
|
297
|
+
/** Methods for working with Tirecheck CAN Bridge in OTA mode */
|
|
298
|
+
bridgeOta: {
|
|
299
|
+
connect(deviceId: string): Promise<void>;
|
|
300
|
+
disconnect(deviceId: string): Promise<void>;
|
|
301
|
+
updateFirmware(deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, progressCallback: ReportStatusFn): Promise<void>;
|
|
302
|
+
};
|
|
303
|
+
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
304
|
+
flexiGaugeTpms: {
|
|
305
|
+
connect(deviceId: string): Promise<void>;
|
|
306
|
+
disconnect(deviceId: string): Promise<void>;
|
|
307
|
+
onTreadDepth(callback: (value: number) => void): void;
|
|
308
|
+
onButtonPress(callback: (buttonName: string) => void): void;
|
|
309
|
+
onTpms(callback: (tpms: FgSensorReading) => void): void;
|
|
310
|
+
getBattery: (deviceId: string) => Promise<number>;
|
|
311
|
+
startTpmsScan: (deviceId: string) => void;
|
|
312
|
+
};
|
|
313
|
+
/** Allows simulating devices without actually using bluetooth */
|
|
314
|
+
simulator: {
|
|
315
|
+
setSimulatedDevices(devices: Record<string, BleDeviceSimulated>): void;
|
|
316
|
+
addSimulatedDevice(device: BleDeviceSimulated): void;
|
|
317
|
+
getSimulatedDevices(): Record<string, BleBridgeSimulated>;
|
|
148
318
|
};
|
|
149
319
|
};
|
|
150
320
|
|
|
151
|
-
export { type BleBridge, type BleBridgeAdvertisingData, type BleDevice, type BleDeviceType, type BluetoothDeviceCapability, type BluetoothDeviceCharacteristic, type BluetoothDeviceHandler, createTirecheckDeviceSdk };
|
|
321
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BluetoothDeviceCapability, type BluetoothDeviceCharacteristic, type BluetoothDeviceHandler, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,14 @@ interface BleImplementation {
|
|
|
3
3
|
stopScan: () => Promise<void>;
|
|
4
4
|
/** Returns a resolved promise if the device is connected,
|
|
5
5
|
otherwise returns rejected promise if the device is not connected */
|
|
6
|
-
isConnected: (
|
|
6
|
+
isConnected: (deviceId: string) => Promise<boolean>;
|
|
7
|
+
connect: (device_id: string, connectCallback: (data: PeripheralDataExtended) => any, disconnectCallback: (error: string | BLEError) => any) => void;
|
|
8
|
+
disconnect: (deviceId: string) => Promise<void>;
|
|
9
|
+
read: (deviceId: string, serviceUuid: string, characteristicUuid: string) => Promise<ArrayBuffer>;
|
|
10
|
+
writeWithoutResponse: (deviceId: string, serviceUuid: string, characteristicUuid: string, value: ArrayBuffer) => void;
|
|
11
|
+
startNotification: (deviceId: string, serviceUuid: string, characteristicUuid: string, success: (rawData: ArrayBuffer) => any, failure?: (error: string | BLEError) => any) => Promise<void>;
|
|
12
|
+
isEnabled: () => Promise<void>;
|
|
13
|
+
requestMtu: (deviceId: string, mtu: number) => Promise<number>;
|
|
7
14
|
}
|
|
8
15
|
interface StartScanOptions {
|
|
9
16
|
scanMode?: 'lowPower' | 'balanced' | 'lowLatency' | 'opportunistic';
|
|
@@ -18,6 +25,11 @@ interface StartScanOptions {
|
|
|
18
25
|
/** Scanning duration in seconds */
|
|
19
26
|
duration?: number;
|
|
20
27
|
}
|
|
28
|
+
interface BLEError {
|
|
29
|
+
name: string;
|
|
30
|
+
id: string;
|
|
31
|
+
errorMessage: string;
|
|
32
|
+
}
|
|
21
33
|
interface PeripheralData {
|
|
22
34
|
name: string;
|
|
23
35
|
id: string;
|
|
@@ -26,17 +38,25 @@ interface PeripheralData {
|
|
|
26
38
|
connectable?: boolean;
|
|
27
39
|
state: PeripheralState;
|
|
28
40
|
}
|
|
41
|
+
interface PeripheralDataExtended extends PeripheralData {
|
|
42
|
+
services: string[];
|
|
43
|
+
characteristics: PeripheralCharacteristic[];
|
|
44
|
+
}
|
|
45
|
+
interface PeripheralCharacteristic {
|
|
46
|
+
service: string;
|
|
47
|
+
characteristic: string;
|
|
48
|
+
properties: string[];
|
|
49
|
+
descriptors?: any[];
|
|
50
|
+
}
|
|
29
51
|
type PeripheralState = 'disconnected' | 'disconnecting' | 'connecting' | 'connected';
|
|
30
52
|
|
|
31
53
|
declare const _default: {
|
|
32
54
|
bridge: {
|
|
33
55
|
nameRegex: RegExp;
|
|
34
|
-
|
|
56
|
+
communication: {
|
|
35
57
|
serviceId: string;
|
|
36
58
|
characteristicId: string;
|
|
37
59
|
};
|
|
38
|
-
capabilities: never[];
|
|
39
|
-
manufacturerId: number;
|
|
40
60
|
mtu: number;
|
|
41
61
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleBridge | undefined;
|
|
42
62
|
};
|
|
@@ -46,36 +66,121 @@ declare const _default: {
|
|
|
46
66
|
serviceId: string;
|
|
47
67
|
characteristicId: string;
|
|
48
68
|
};
|
|
49
|
-
|
|
50
|
-
getDeviceInfoFromAdvertising: () => void;
|
|
69
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleDeviceBase;
|
|
51
70
|
};
|
|
52
71
|
flexiGaugeTpms: {
|
|
53
72
|
nameRegex: RegExp;
|
|
54
|
-
|
|
73
|
+
communication: {
|
|
55
74
|
serviceId: string;
|
|
56
75
|
characteristicId: string;
|
|
57
76
|
};
|
|
58
|
-
|
|
59
|
-
capabilities: {
|
|
60
|
-
id: string;
|
|
61
|
-
regex: RegExp;
|
|
62
|
-
}[];
|
|
63
|
-
reconnect: boolean;
|
|
64
|
-
};
|
|
65
|
-
pressureStick: {
|
|
66
|
-
nameRegex: RegExp;
|
|
67
|
-
characteristic: {
|
|
77
|
+
battery: {
|
|
68
78
|
serviceId: string;
|
|
69
79
|
characteristicId: string;
|
|
70
80
|
};
|
|
71
|
-
getDeviceInfoFromAdvertising: () =>
|
|
72
|
-
|
|
73
|
-
id: string;
|
|
74
|
-
regex: RegExp;
|
|
75
|
-
}[];
|
|
81
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleDeviceBase;
|
|
82
|
+
reconnect: boolean;
|
|
76
83
|
};
|
|
77
84
|
};
|
|
78
85
|
|
|
86
|
+
interface BridgeTcVehicle {
|
|
87
|
+
registrationNumber?: string;
|
|
88
|
+
vin?: string;
|
|
89
|
+
axles: BridgeTcVehicleAxle[];
|
|
90
|
+
tcTyres: BridgeTcTyre[];
|
|
91
|
+
tcBridge: {
|
|
92
|
+
id: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface BridgeTcTyre {
|
|
96
|
+
mountedOn?: TcTyreMountedOn;
|
|
97
|
+
serialNumber?: string;
|
|
98
|
+
temperature?: number;
|
|
99
|
+
tcTpmsSensor?: {
|
|
100
|
+
id: string;
|
|
101
|
+
};
|
|
102
|
+
pressure?: number;
|
|
103
|
+
}
|
|
104
|
+
declare class TcTyreMountedOn {
|
|
105
|
+
positionId: number;
|
|
106
|
+
}
|
|
107
|
+
interface FgSensorReading {
|
|
108
|
+
Alg?: string;
|
|
109
|
+
Rssi: string;
|
|
110
|
+
ID: string;
|
|
111
|
+
PA?: number;
|
|
112
|
+
PC: number;
|
|
113
|
+
T: number;
|
|
114
|
+
S?: string;
|
|
115
|
+
}
|
|
116
|
+
declare class BridgeTcVehicleAxle {
|
|
117
|
+
targetPressure?: number;
|
|
118
|
+
tyresCount: number;
|
|
119
|
+
isSteer?: boolean;
|
|
120
|
+
isSpare?: boolean;
|
|
121
|
+
isDrive?: boolean;
|
|
122
|
+
isLift?: boolean;
|
|
123
|
+
spacesBelow?: number;
|
|
124
|
+
maxTargetPressure?: number;
|
|
125
|
+
minTargetPressure?: number;
|
|
126
|
+
}
|
|
127
|
+
interface BridgeConfiguration {
|
|
128
|
+
customerCANSettings: any;
|
|
129
|
+
workshopCANSettings: any;
|
|
130
|
+
bridgeConfiguration: any;
|
|
131
|
+
customerPressureThresholds: any;
|
|
132
|
+
customerTemperatureThresholds: any;
|
|
133
|
+
customerImbalanceThresholds: any;
|
|
134
|
+
pressuresPerAxle: any;
|
|
135
|
+
/** only available after 0.9.8 fw */
|
|
136
|
+
autolearnSettings?: any;
|
|
137
|
+
}
|
|
138
|
+
interface BridgeReading {
|
|
139
|
+
date: number;
|
|
140
|
+
sensorId: string;
|
|
141
|
+
sensorStatus: number;
|
|
142
|
+
eceStatus: number;
|
|
143
|
+
pressureIssue?: BridgeTcIssue;
|
|
144
|
+
pressure?: {
|
|
145
|
+
raw: number;
|
|
146
|
+
meas: number;
|
|
147
|
+
bar: number;
|
|
148
|
+
};
|
|
149
|
+
temperature?: {
|
|
150
|
+
raw: number;
|
|
151
|
+
amb: number;
|
|
152
|
+
celsius: number;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
interface BridgeAutolearnStatus {
|
|
156
|
+
positionId: number;
|
|
157
|
+
/** Only populated for 'known' and 'unknown' statuses */
|
|
158
|
+
autolearnedSensorId?: string;
|
|
159
|
+
autolearnedStatus: 'default' | 'known' | 'unknown' | 'error';
|
|
160
|
+
}
|
|
161
|
+
interface BridgeTcIssue {
|
|
162
|
+
date: number;
|
|
163
|
+
tcIssue: {
|
|
164
|
+
id: string;
|
|
165
|
+
};
|
|
166
|
+
type: string;
|
|
167
|
+
severity: string;
|
|
168
|
+
}
|
|
169
|
+
interface PositionInfo {
|
|
170
|
+
positionId?: number;
|
|
171
|
+
axlePosition: number | null;
|
|
172
|
+
tyrePosition: number | null | undefined;
|
|
173
|
+
axleTyresCount?: number;
|
|
174
|
+
name: string;
|
|
175
|
+
description?: string;
|
|
176
|
+
isSpareTyre?: boolean;
|
|
177
|
+
isLeftTyre?: boolean;
|
|
178
|
+
isRightTyre?: boolean;
|
|
179
|
+
isCenterTyre?: boolean;
|
|
180
|
+
isTwinTyre?: boolean;
|
|
181
|
+
isOuterTwinTyre?: boolean;
|
|
182
|
+
isInnerTwinTyre?: boolean;
|
|
183
|
+
}
|
|
79
184
|
interface BluetoothDeviceCharacteristic {
|
|
80
185
|
serviceId: string;
|
|
81
186
|
characteristicId: string;
|
|
@@ -85,6 +190,18 @@ interface BluetoothDeviceCapability {
|
|
|
85
190
|
processFn: Function;
|
|
86
191
|
regex: RegExp;
|
|
87
192
|
}
|
|
193
|
+
interface BridgeCommandStructure {
|
|
194
|
+
id: number[];
|
|
195
|
+
name: string;
|
|
196
|
+
structure: BridgeCommandStructureProperties;
|
|
197
|
+
}
|
|
198
|
+
interface BridgeCommandStructureProperties {
|
|
199
|
+
[propName: string]: {
|
|
200
|
+
size: number;
|
|
201
|
+
display?: 'decimal' | 'ascii';
|
|
202
|
+
description: string;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
88
205
|
interface BluetoothDeviceHandler {
|
|
89
206
|
/** Characteristic on which device sends messages, will be subscribed by connect function */
|
|
90
207
|
characteristic: BluetoothDeviceCharacteristic;
|
|
@@ -111,14 +228,24 @@ interface BluetoothDeviceHandler {
|
|
|
111
228
|
onDisconnected?: Function;
|
|
112
229
|
}
|
|
113
230
|
type BleDeviceType = keyof typeof _default;
|
|
114
|
-
type BleDevice = BleBridge;
|
|
115
|
-
|
|
231
|
+
type BleDevice = BleBridge | BleDeviceBase;
|
|
232
|
+
type BleDeviceSimulated = BleBridgeSimulated;
|
|
233
|
+
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | 'disconnected' | undefined;
|
|
234
|
+
interface BleDeviceBase {
|
|
116
235
|
id: string;
|
|
117
236
|
name: string;
|
|
237
|
+
type: BleDeviceType;
|
|
238
|
+
rssi: number;
|
|
239
|
+
status?: BleDeviceStatus;
|
|
240
|
+
}
|
|
241
|
+
interface BleBridge extends BleDeviceBase {
|
|
242
|
+
type: 'bridge';
|
|
118
243
|
bridgeId: string;
|
|
119
244
|
vin: string;
|
|
120
245
|
advertisingData: BleBridgeAdvertisingData;
|
|
121
|
-
|
|
246
|
+
}
|
|
247
|
+
interface BleBridgeSimulated extends BleBridge {
|
|
248
|
+
simulatorData: Record<string, any>;
|
|
122
249
|
}
|
|
123
250
|
interface BleBridgeAdvertisingData {
|
|
124
251
|
randomAdvNumber: number[];
|
|
@@ -135,17 +262,60 @@ interface BleBridgeAdvertisingData {
|
|
|
135
262
|
configVersion: number;
|
|
136
263
|
timeFromStart?: number;
|
|
137
264
|
}
|
|
265
|
+
type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
266
|
+
[K in keyof T]: (...args: [next: (...paramsOverride: any[]) => ReturnType<T[K]>, ...Parameters<T[K]>]) => ReturnType<T[K]>;
|
|
267
|
+
};
|
|
268
|
+
type ReportStatusFn = (status: string, completionPercentage: number) => void;
|
|
138
269
|
|
|
139
270
|
declare function createTirecheckDeviceSdk(bleImplementation: BleImplementation): {
|
|
271
|
+
/** Generic methods common for all devices */
|
|
140
272
|
bluetooth: {
|
|
141
273
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
142
|
-
onDeviceUpdate(callback: (update: {
|
|
143
|
-
deviceId: string;
|
|
144
|
-
isConnected: boolean;
|
|
145
|
-
}) => void): void;
|
|
146
274
|
onDeviceUnreachable(callback: (deviceId: string) => void): void;
|
|
147
|
-
|
|
275
|
+
onDeviceLostConnection(callback: (deviceId: string) => void): void;
|
|
276
|
+
scanDevices: (services?: string[], duration?: number) => Promise<void>;
|
|
277
|
+
stopScan(): void;
|
|
278
|
+
connect: (deviceId: string, disconnectCallback: (deviceId: string) => void) => Promise<PeripheralDataExtended | undefined>;
|
|
279
|
+
disconnect: (deviceId: string) => Promise<void>;
|
|
280
|
+
write: (deviceId: string, serviceUuid: string, characteristicUuid: string, value: ArrayBuffer) => Promise<void>;
|
|
281
|
+
read: (deviceId: string, serviceUuid: string, characteristicUuid: string) => Promise<number[]>;
|
|
282
|
+
};
|
|
283
|
+
/** Methods for working with Tirecheck CAN Bridge */
|
|
284
|
+
bridge: {
|
|
285
|
+
connect(deviceId: string): Promise<void>;
|
|
286
|
+
disconnect(deviceId: string): Promise<void>;
|
|
287
|
+
getVehicle: (deviceId: string) => Promise<BridgeTcVehicle>;
|
|
288
|
+
setVehicle: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<void>;
|
|
289
|
+
getConfiguration: (deviceId: string) => Promise<BridgeConfiguration>;
|
|
290
|
+
setConfiguration: (deviceId: string, bridgeConfiguration: BridgeConfiguration) => Promise<void>;
|
|
291
|
+
getSensorReading: (deviceId: string, positionId: number) => Promise<BridgeReading>;
|
|
292
|
+
getVehicleReadings: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeReading[] | undefined>;
|
|
293
|
+
getAutolearnStatuses: (deviceId: string, tcVehicle: BridgeTcVehicle) => Promise<BridgeAutolearnStatus[]>;
|
|
294
|
+
resetAutolearnStatuses: (deviceId: string, positionIds: number[]) => Promise<void>;
|
|
295
|
+
updateFirmware: (deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, reportStatus: ReportStatusFn) => Promise<void>;
|
|
296
|
+
};
|
|
297
|
+
/** Methods for working with Tirecheck CAN Bridge in OTA mode */
|
|
298
|
+
bridgeOta: {
|
|
299
|
+
connect(deviceId: string): Promise<void>;
|
|
300
|
+
disconnect(deviceId: string): Promise<void>;
|
|
301
|
+
updateFirmware(deviceId: string, bootloader: ArrayBuffer, firmware: ArrayBuffer, progressCallback: ReportStatusFn): Promise<void>;
|
|
302
|
+
};
|
|
303
|
+
/** Methods for working with Tirecheck TPMS FlexiGauge */
|
|
304
|
+
flexiGaugeTpms: {
|
|
305
|
+
connect(deviceId: string): Promise<void>;
|
|
306
|
+
disconnect(deviceId: string): Promise<void>;
|
|
307
|
+
onTreadDepth(callback: (value: number) => void): void;
|
|
308
|
+
onButtonPress(callback: (buttonName: string) => void): void;
|
|
309
|
+
onTpms(callback: (tpms: FgSensorReading) => void): void;
|
|
310
|
+
getBattery: (deviceId: string) => Promise<number>;
|
|
311
|
+
startTpmsScan: (deviceId: string) => void;
|
|
312
|
+
};
|
|
313
|
+
/** Allows simulating devices without actually using bluetooth */
|
|
314
|
+
simulator: {
|
|
315
|
+
setSimulatedDevices(devices: Record<string, BleDeviceSimulated>): void;
|
|
316
|
+
addSimulatedDevice(device: BleDeviceSimulated): void;
|
|
317
|
+
getSimulatedDevices(): Record<string, BleBridgeSimulated>;
|
|
148
318
|
};
|
|
149
319
|
};
|
|
150
320
|
|
|
151
|
-
export { type BleBridge, type BleBridgeAdvertisingData, type BleDevice, type BleDeviceType, type BluetoothDeviceCapability, type BluetoothDeviceCharacteristic, type BluetoothDeviceHandler, createTirecheckDeviceSdk };
|
|
321
|
+
export { type BleBridge, type BleBridgeAdvertisingData, type BleBridgeSimulated, type BleDevice, type BleDeviceBase, type BleDeviceSimulated, type BleDeviceStatus, type BleDeviceType, type BluetoothDeviceCapability, type BluetoothDeviceCharacteristic, type BluetoothDeviceHandler, type BridgeAutolearnStatus, type BridgeCommandStructure, type BridgeCommandStructureProperties, type BridgeConfiguration, type BridgeReading, type BridgeTcIssue, type BridgeTcTyre, type BridgeTcVehicle, BridgeTcVehicleAxle, type FgSensorReading, type PositionInfo, type ReportStatusFn, type Wrapper, createTirecheckDeviceSdk };
|