tirecheck-device-sdk 0.2.69 → 0.2.71
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 +199 -35
- package/dist/index.d.cts +104 -3
- package/dist/index.d.mts +104 -3
- package/dist/index.d.ts +104 -3
- package/dist/index.mjs +199 -35
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -134,6 +134,19 @@ function normalizeError(error) {
|
|
|
134
134
|
return error;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
const emptyBluetoothClassicSerialImplementation = {
|
|
138
|
+
list: async () => [],
|
|
139
|
+
discoverUnpaired: async () => [],
|
|
140
|
+
setDeviceDiscoveredListener: () => {
|
|
141
|
+
},
|
|
142
|
+
clearDeviceDiscoveredListener: () => {
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
let bluetoothClassicSerial = emptyBluetoothClassicSerialImplementation;
|
|
146
|
+
function setBluetoothClassicSerialImplementation(bluetoothClassicSerialImplementation) {
|
|
147
|
+
bluetoothClassicSerial = bluetoothClassicSerialImplementation ?? emptyBluetoothClassicSerialImplementation;
|
|
148
|
+
}
|
|
149
|
+
|
|
137
150
|
const tyreLabels = getDefaultTyreLabels();
|
|
138
151
|
const bridgeTools = {
|
|
139
152
|
getBridgeFromStore,
|
|
@@ -657,6 +670,17 @@ const deviceMeta = {
|
|
|
657
670
|
};
|
|
658
671
|
return bleDevice;
|
|
659
672
|
}
|
|
673
|
+
},
|
|
674
|
+
unitechRfid: {
|
|
675
|
+
nameRegex: /^RP902/i,
|
|
676
|
+
transport: "serial",
|
|
677
|
+
getDeviceInfoFromAdvertising: (device) => {
|
|
678
|
+
const bleDevice = {
|
|
679
|
+
...device,
|
|
680
|
+
type: "unitechRfid"
|
|
681
|
+
};
|
|
682
|
+
return bleDevice;
|
|
683
|
+
}
|
|
660
684
|
}
|
|
661
685
|
};
|
|
662
686
|
|
|
@@ -693,6 +717,8 @@ const bluetooth = {
|
|
|
693
717
|
deviceStateChangeCallback = callback;
|
|
694
718
|
},
|
|
695
719
|
scanDevices,
|
|
720
|
+
scanSerialDevicesPaired,
|
|
721
|
+
scanSerialDevicesUnpaired,
|
|
696
722
|
stopScan() {
|
|
697
723
|
ble.stopScan();
|
|
698
724
|
},
|
|
@@ -723,6 +749,47 @@ async function scanDevices(services = [], duration) {
|
|
|
723
749
|
(e) => console.error("ble.startScanWithOptions error:", e)
|
|
724
750
|
);
|
|
725
751
|
}
|
|
752
|
+
async function scanSerialDevicesPaired() {
|
|
753
|
+
try {
|
|
754
|
+
const pairedDevices = await bluetoothClassicSerial.list();
|
|
755
|
+
for (const device of pairedDevices ?? []) handleSerialDevice(device);
|
|
756
|
+
} catch (e) {
|
|
757
|
+
console.error("scanPairedSerialDevices error:", e);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
async function scanSerialDevicesUnpaired() {
|
|
761
|
+
bluetoothClassicSerial.setDeviceDiscoveredListener?.((device) => handleSerialDevice(device));
|
|
762
|
+
try {
|
|
763
|
+
const unpairedDevices = await bluetoothClassicSerial.discoverUnpaired();
|
|
764
|
+
for (const device of unpairedDevices ?? []) handleSerialDevice(device);
|
|
765
|
+
} catch (e) {
|
|
766
|
+
const message = (typeof e === "string" ? e : e?.message ?? "").toLowerCase();
|
|
767
|
+
const pickerDismissed = store.platform === "ios" && ["cancel", "alreadyconnected", "already connected", "notfound", "not found"].some((m) => message.includes(m));
|
|
768
|
+
if (pickerDismissed) {
|
|
769
|
+
console.log("discoverSerialDevices: accessory picker returned no unpaired device -", message);
|
|
770
|
+
} else {
|
|
771
|
+
console.error("discoverSerialDevices error:", e);
|
|
772
|
+
}
|
|
773
|
+
} finally {
|
|
774
|
+
bluetoothClassicSerial.clearDeviceDiscoveredListener?.();
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function handleSerialDevice(device) {
|
|
778
|
+
const rawId = device.id ?? device.address;
|
|
779
|
+
const id = rawId != null ? String(rawId) : void 0;
|
|
780
|
+
if (!id) {
|
|
781
|
+
console.warn("handleSerialDevice: skipped, no id/address", device);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const peripheral = { id, name: device.name, rssi: device.rssi ?? 0, advertising: {} };
|
|
785
|
+
const processedDevice = processDevice(peripheral);
|
|
786
|
+
if (!processedDevice) {
|
|
787
|
+
console.warn("handleSerialDevice: processDevice returned null (filtered out)", id, device.name);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
store.devices[processedDevice.id] = processedDevice;
|
|
791
|
+
deviceAdvertisingCallback?.(processedDevice);
|
|
792
|
+
}
|
|
726
793
|
async function connect$1(deviceId, disconnectCallback) {
|
|
727
794
|
if (toolsSvc.canCommunicateWith(deviceId)) return console.warn("Connect Warn: Already connected to device");
|
|
728
795
|
store.setState(deviceId, "connecting");
|
|
@@ -811,7 +878,8 @@ function processDevice(device) {
|
|
|
811
878
|
console.warn("Error processing advertising", e);
|
|
812
879
|
return;
|
|
813
880
|
}
|
|
814
|
-
|
|
881
|
+
const isSerial = deviceMeta[deviceType].transport === "serial";
|
|
882
|
+
if (!isSerial) unreachableSvc.refresh(processedDevice.id, deviceUnreachableCallback);
|
|
815
883
|
return processedDevice;
|
|
816
884
|
}
|
|
817
885
|
function getDeviceTypeFromName(name) {
|
|
@@ -1516,64 +1584,64 @@ const bridgeCommandStructures = {
|
|
|
1516
1584
|
name: "autolearnUnknownSensors",
|
|
1517
1585
|
structure: {
|
|
1518
1586
|
sensor01: {
|
|
1519
|
-
size:
|
|
1520
|
-
description: "Unknown sensor data"
|
|
1587
|
+
size: 13,
|
|
1588
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1521
1589
|
},
|
|
1522
1590
|
sensor02: {
|
|
1523
|
-
size:
|
|
1524
|
-
description: "Unknown sensor data"
|
|
1591
|
+
size: 13,
|
|
1592
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1525
1593
|
},
|
|
1526
1594
|
sensor03: {
|
|
1527
|
-
size:
|
|
1528
|
-
description: "Unknown sensor data"
|
|
1595
|
+
size: 13,
|
|
1596
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1529
1597
|
},
|
|
1530
1598
|
sensor04: {
|
|
1531
|
-
size:
|
|
1532
|
-
description: "Unknown sensor data"
|
|
1599
|
+
size: 13,
|
|
1600
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1533
1601
|
},
|
|
1534
1602
|
sensor05: {
|
|
1535
|
-
size:
|
|
1536
|
-
description: "Unknown sensor data"
|
|
1603
|
+
size: 13,
|
|
1604
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1537
1605
|
},
|
|
1538
1606
|
sensor06: {
|
|
1539
|
-
size:
|
|
1540
|
-
description: "Unknown sensor data"
|
|
1607
|
+
size: 13,
|
|
1608
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1541
1609
|
},
|
|
1542
1610
|
sensor07: {
|
|
1543
|
-
size:
|
|
1544
|
-
description: "Unknown sensor data"
|
|
1611
|
+
size: 13,
|
|
1612
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1545
1613
|
},
|
|
1546
1614
|
sensor08: {
|
|
1547
|
-
size:
|
|
1548
|
-
description: "Unknown sensor data"
|
|
1615
|
+
size: 13,
|
|
1616
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1549
1617
|
},
|
|
1550
1618
|
sensor09: {
|
|
1551
|
-
size:
|
|
1552
|
-
description: "Unknown sensor data"
|
|
1619
|
+
size: 13,
|
|
1620
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1553
1621
|
},
|
|
1554
1622
|
sensor10: {
|
|
1555
|
-
size:
|
|
1556
|
-
description: "Unknown sensor data"
|
|
1623
|
+
size: 13,
|
|
1624
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1557
1625
|
},
|
|
1558
1626
|
sensor11: {
|
|
1559
|
-
size:
|
|
1560
|
-
description: "Unknown sensor data"
|
|
1627
|
+
size: 13,
|
|
1628
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1561
1629
|
},
|
|
1562
1630
|
sensor12: {
|
|
1563
|
-
size:
|
|
1564
|
-
description: "Unknown sensor data"
|
|
1631
|
+
size: 13,
|
|
1632
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1565
1633
|
},
|
|
1566
1634
|
sensor13: {
|
|
1567
|
-
size:
|
|
1568
|
-
description: "Unknown sensor data"
|
|
1635
|
+
size: 13,
|
|
1636
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1569
1637
|
},
|
|
1570
1638
|
sensor14: {
|
|
1571
|
-
size:
|
|
1572
|
-
description: "Unknown sensor data"
|
|
1639
|
+
size: 13,
|
|
1640
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1573
1641
|
},
|
|
1574
1642
|
sensor15: {
|
|
1575
|
-
size:
|
|
1576
|
-
description: "Unknown sensor data"
|
|
1643
|
+
size: 13,
|
|
1644
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1577
1645
|
}
|
|
1578
1646
|
}
|
|
1579
1647
|
},
|
|
@@ -2195,7 +2263,10 @@ const bridgeCommands = {
|
|
|
2195
2263
|
},
|
|
2196
2264
|
async getAutolearnUnknownSensors(deviceId) {
|
|
2197
2265
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2198
|
-
const result = await this.readCommand(deviceData, subCommandIds.autolearnUnknownSensors
|
|
2266
|
+
const result = await this.readCommand(deviceData, subCommandIds.autolearnUnknownSensors, {
|
|
2267
|
+
headerLength: 5,
|
|
2268
|
+
footerLength: 4
|
|
2269
|
+
});
|
|
2199
2270
|
const structurized = bridgeTools.convertBytesToStructure(
|
|
2200
2271
|
bridgeCommandStructures.autolearnUnknownSensors.structure,
|
|
2201
2272
|
result.data,
|
|
@@ -2276,7 +2347,7 @@ const bridgeCommands = {
|
|
|
2276
2347
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2277
2348
|
const result = await this.readCommand(deviceData, subCommandIds.firmwareVersion, {
|
|
2278
2349
|
headerLength: 5,
|
|
2279
|
-
footerLength:
|
|
2350
|
+
footerLength: 4
|
|
2280
2351
|
});
|
|
2281
2352
|
return bridgeTools.convertBytesToStructure(
|
|
2282
2353
|
bridgeCommandStructures.firmwareVersion.structure,
|
|
@@ -2288,7 +2359,7 @@ const bridgeCommands = {
|
|
|
2288
2359
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2289
2360
|
const result = await this.readCommand(deviceData, subCommandIds.errorHistoryCounter, {
|
|
2290
2361
|
headerLength: 5,
|
|
2291
|
-
footerLength:
|
|
2362
|
+
footerLength: 4
|
|
2292
2363
|
});
|
|
2293
2364
|
return bridgeTools.convertBytesToStructure(
|
|
2294
2365
|
bridgeCommandStructures.errorHistoryCounter.structure,
|
|
@@ -4157,6 +4228,95 @@ const torqueWrench = {
|
|
|
4157
4228
|
onReading: torqueWrenchService.onReading
|
|
4158
4229
|
};
|
|
4159
4230
|
|
|
4231
|
+
let unitech;
|
|
4232
|
+
function setUnitechRfidImplementation(unitechRfidImplementation) {
|
|
4233
|
+
if (!unitechRfidImplementation)
|
|
4234
|
+
return console.warn("Unitech RFID implementation is not provided, Unitech RFID functionality will not work");
|
|
4235
|
+
unitech = unitechRfidImplementation;
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4238
|
+
const unitechRfidService = {
|
|
4239
|
+
subscribeListeners(deviceId) {
|
|
4240
|
+
unitech.addListener("readerState", (event) => {
|
|
4241
|
+
simulatorSvc.triggerEvent("unitech:readerState", deviceId, event);
|
|
4242
|
+
simulatorSvc.triggerEvent("unitech:readerStateConnect", deviceId, event);
|
|
4243
|
+
});
|
|
4244
|
+
unitech.addListener("actionState", (event) => simulatorSvc.triggerEvent("unitech:actionState", deviceId, event));
|
|
4245
|
+
unitech.addListener("trigger", (event) => simulatorSvc.triggerEvent("unitech:trigger", deviceId, event));
|
|
4246
|
+
unitech.addListener("tagRead", (event) => simulatorSvc.triggerEvent("unitech:tag", deviceId, event));
|
|
4247
|
+
unitech.addListener("battery", (event) => simulatorSvc.triggerEvent("unitech:battery", deviceId, event));
|
|
4248
|
+
unitech.addListener("temperature", (event) => simulatorSvc.triggerEvent("unitech:temperature", deviceId, event));
|
|
4249
|
+
},
|
|
4250
|
+
onReaderState(callback) {
|
|
4251
|
+
simulatorSvc.registerEvent("unitech:readerState", callback);
|
|
4252
|
+
},
|
|
4253
|
+
onActionState(callback) {
|
|
4254
|
+
simulatorSvc.registerEvent("unitech:actionState", callback);
|
|
4255
|
+
},
|
|
4256
|
+
onTrigger(callback) {
|
|
4257
|
+
simulatorSvc.registerEvent("unitech:trigger", callback);
|
|
4258
|
+
},
|
|
4259
|
+
onTagRead(callback) {
|
|
4260
|
+
simulatorSvc.registerEvent("unitech:tag", callback);
|
|
4261
|
+
},
|
|
4262
|
+
onBattery(callback) {
|
|
4263
|
+
simulatorSvc.registerEvent("unitech:battery", callback);
|
|
4264
|
+
},
|
|
4265
|
+
onTemperature(callback) {
|
|
4266
|
+
simulatorSvc.registerEvent("unitech:temperature", callback);
|
|
4267
|
+
}
|
|
4268
|
+
};
|
|
4269
|
+
|
|
4270
|
+
const unitechRfid = {
|
|
4271
|
+
async connect(deviceId) {
|
|
4272
|
+
const unitechDevices = Object.values(store.devices).filter((d) => d.type === "unitechRfid");
|
|
4273
|
+
for (const device2 of unitechDevices) {
|
|
4274
|
+
if (device2.id !== deviceId && store.deviceState[device2.id] === "paired") {
|
|
4275
|
+
await this.disconnect(device2.id, "manualDisconnection");
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
store.setState(deviceId, "connecting");
|
|
4279
|
+
await unitech.removeAllListeners();
|
|
4280
|
+
const device = store.devices[deviceId];
|
|
4281
|
+
if (store.platform === "ios") {
|
|
4282
|
+
await unitech.startDetect({ deviceName: device.name });
|
|
4283
|
+
await toolsSvc.delay(500);
|
|
4284
|
+
await unitech.stopDetect();
|
|
4285
|
+
}
|
|
4286
|
+
const { connected } = await unitech.connect({ bluetoothAddress: device.id });
|
|
4287
|
+
if (!connected) throw new Error("UnitechRfid Error: Unable to connect to the device.");
|
|
4288
|
+
await unitechRfidService.subscribeListeners(deviceId);
|
|
4289
|
+
await withTimeout(
|
|
4290
|
+
new Promise((resolve) => {
|
|
4291
|
+
simulatorSvc.registerEvent("unitech:readerStateConnect", (_deviceId, event) => {
|
|
4292
|
+
if (event.state?.toLowerCase() === "connected") resolve();
|
|
4293
|
+
});
|
|
4294
|
+
}),
|
|
4295
|
+
15e3
|
|
4296
|
+
);
|
|
4297
|
+
await unitech.initDeviceSettings();
|
|
4298
|
+
store.setState(deviceId, "paired");
|
|
4299
|
+
},
|
|
4300
|
+
async disconnect(deviceId, reason) {
|
|
4301
|
+
store.setState(deviceId, "disconnecting");
|
|
4302
|
+
await unitech.removeAllListeners();
|
|
4303
|
+
await unitech.disconnect();
|
|
4304
|
+
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
4305
|
+
},
|
|
4306
|
+
async startReading() {
|
|
4307
|
+
await unitech.startInventory();
|
|
4308
|
+
},
|
|
4309
|
+
async stopReading() {
|
|
4310
|
+
await unitech.stopInventory();
|
|
4311
|
+
},
|
|
4312
|
+
onReaderState: unitechRfidService.onReaderState,
|
|
4313
|
+
onActionState: unitechRfidService.onActionState,
|
|
4314
|
+
onTrigger: unitechRfidService.onTrigger,
|
|
4315
|
+
onTagRead: unitechRfidService.onTagRead,
|
|
4316
|
+
onBattery: unitechRfidService.onBattery,
|
|
4317
|
+
onTemperature: unitechRfidService.onTemperature
|
|
4318
|
+
};
|
|
4319
|
+
|
|
4160
4320
|
const bridgeSimulator = {
|
|
4161
4321
|
isRebootRequired(deviceId) {
|
|
4162
4322
|
return store.bridgeRebootRequired[deviceId];
|
|
@@ -4798,11 +4958,13 @@ class BridgeTcVehicleAxle {
|
|
|
4798
4958
|
minTargetPressure;
|
|
4799
4959
|
}
|
|
4800
4960
|
|
|
4801
|
-
function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
4961
|
+
function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys, unitechRfidImplementation, bluetoothClassicSerialImplementation) {
|
|
4802
4962
|
store.platform = platform;
|
|
4803
4963
|
bleImplementation = bleImplementation || emptyBleImplementation;
|
|
4804
4964
|
store.securityKeys = securityKeys || {};
|
|
4805
4965
|
setBleImplementation(bleImplementation);
|
|
4966
|
+
setUnitechRfidImplementation(unitechRfidImplementation);
|
|
4967
|
+
setBluetoothClassicSerialImplementation(bluetoothClassicSerialImplementation);
|
|
4806
4968
|
return {
|
|
4807
4969
|
/** Generic methods common for all devices */
|
|
4808
4970
|
bluetooth,
|
|
@@ -4820,6 +4982,8 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4820
4982
|
simulator,
|
|
4821
4983
|
/** Methods for working with Tirecheck Torque Wrench */
|
|
4822
4984
|
torqueWrench,
|
|
4985
|
+
/** Methods for working with Unitech RFID reader */
|
|
4986
|
+
unitechRfid,
|
|
4823
4987
|
utils: {
|
|
4824
4988
|
bridge: {
|
|
4825
4989
|
convertBarToKpaByte: bridgeTools.convertBarToKpaByte,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
interface UnitechListenerHandle {
|
|
2
|
+
remove: () => Promise<void>;
|
|
3
|
+
}
|
|
4
|
+
interface ReaderStateEvent {
|
|
5
|
+
state: string;
|
|
6
|
+
}
|
|
7
|
+
interface ActionStateEvent {
|
|
8
|
+
state: string;
|
|
9
|
+
}
|
|
10
|
+
interface TriggerEvent {
|
|
11
|
+
pressed: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface TagReadEvent {
|
|
14
|
+
epc: string;
|
|
15
|
+
rssi: number;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface BatteryEvent {
|
|
19
|
+
percent: number;
|
|
20
|
+
}
|
|
21
|
+
interface TemperatureEvent {
|
|
22
|
+
celsius: number;
|
|
23
|
+
}
|
|
24
|
+
interface UnitechRfidImplementation {
|
|
25
|
+
removeAllListeners: () => Promise<void>;
|
|
26
|
+
addListener: ((eventName: 'readerState', listener: (event: ReaderStateEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'actionState', listener: (event: ActionStateEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'trigger', listener: (event: TriggerEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'tagRead', listener: (event: TagReadEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'battery', listener: (event: BatteryEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'temperature', listener: (event: TemperatureEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>);
|
|
27
|
+
startDetect: (options: {
|
|
28
|
+
deviceName: string;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
stopDetect: () => Promise<void>;
|
|
31
|
+
connect: (options: {
|
|
32
|
+
bluetoothAddress?: string;
|
|
33
|
+
}) => Promise<{
|
|
34
|
+
connected: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
disconnect: () => Promise<void>;
|
|
37
|
+
initDeviceSettings: () => Promise<void>;
|
|
38
|
+
startInventory: () => Promise<void>;
|
|
39
|
+
stopInventory: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
1
42
|
interface BleImplementation {
|
|
2
43
|
startScanWithOptions: (services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure?: (error: string) => any) => void;
|
|
3
44
|
stopScan: () => Promise<void>;
|
|
@@ -118,6 +159,11 @@ declare const _default$1: {
|
|
|
118
159
|
};
|
|
119
160
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleTorqueWrench;
|
|
120
161
|
};
|
|
162
|
+
unitechRfid: {
|
|
163
|
+
nameRegex: RegExp;
|
|
164
|
+
transport: "serial";
|
|
165
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleUnitechRfid;
|
|
166
|
+
};
|
|
121
167
|
};
|
|
122
168
|
|
|
123
169
|
declare const _default: {
|
|
@@ -1095,7 +1141,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
|
|
|
1095
1141
|
};
|
|
1096
1142
|
type BleDeviceType = keyof typeof _default$1;
|
|
1097
1143
|
/** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
|
|
1098
|
-
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench;
|
|
1144
|
+
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench | BleUnitechRfid;
|
|
1099
1145
|
type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
|
|
1100
1146
|
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
|
|
1101
1147
|
interface BleDeviceBase {
|
|
@@ -1125,6 +1171,9 @@ interface BleFlexiGauge extends BleDeviceBase {
|
|
|
1125
1171
|
interface BleTorqueWrench extends BleDeviceBase {
|
|
1126
1172
|
type: 'torqueWrench';
|
|
1127
1173
|
}
|
|
1174
|
+
interface BleUnitechRfid extends BleDeviceBase {
|
|
1175
|
+
type: 'unitechRfid';
|
|
1176
|
+
}
|
|
1128
1177
|
interface BleBridgeOta extends BleDeviceBase {
|
|
1129
1178
|
advertisingData: {
|
|
1130
1179
|
bridgeId: string;
|
|
@@ -1200,12 +1249,25 @@ type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
|
1200
1249
|
type ReportStatusFn = (status: string, completionPercentage: number) => void;
|
|
1201
1250
|
type DeviceState = 'connected' | 'connecting' | 'disconnecting' | 'paired' | undefined;
|
|
1202
1251
|
type StateReason = 'lostConnection' | 'manualDisconnection' | 'failedConnection' | 'failedDisconnection' | 'firmwareUpdate' | string;
|
|
1252
|
+
/** A unique RFID tag aggregated across many tagRead events, keeping the strongest signal seen. */
|
|
1253
|
+
interface RfidTag {
|
|
1254
|
+
epc: string;
|
|
1255
|
+
rssi: number;
|
|
1256
|
+
}
|
|
1203
1257
|
interface EventHandlers {
|
|
1204
1258
|
'fg:treadDepth'?: (deviceId: string, value: number) => void;
|
|
1205
1259
|
'fg:button'?: (deviceId: string, value: string) => void;
|
|
1206
1260
|
'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
|
|
1207
1261
|
'ps:pressure'?: (deviceId: string, value: number) => void;
|
|
1208
1262
|
'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
|
|
1263
|
+
'unitech:readerState'?: (deviceId: string, event: ReaderStateEvent) => void;
|
|
1264
|
+
'unitech:readerStateConnect'?: (deviceId: string, event: ReaderStateEvent) => void;
|
|
1265
|
+
'unitech:actionState'?: (deviceId: string, event: ActionStateEvent) => void;
|
|
1266
|
+
'unitech:trigger'?: (deviceId: string, event: TriggerEvent) => void;
|
|
1267
|
+
'unitech:tag'?: (deviceId: string, event: TagReadEvent) => void;
|
|
1268
|
+
'unitech:tagReadMultiple'?: (deviceId: string, tags: RfidTag[]) => void;
|
|
1269
|
+
'unitech:battery'?: (deviceId: string, event: BatteryEvent) => void;
|
|
1270
|
+
'unitech:temperature'?: (deviceId: string, event: TemperatureEvent) => void;
|
|
1209
1271
|
'bridgeOta:status'?: (deviceId: string, status: string) => void;
|
|
1210
1272
|
'bridgeOta:success'?: (deviceId: string) => void;
|
|
1211
1273
|
'bridgeOta:error'?: (deviceId: string, error: string) => void;
|
|
@@ -1236,16 +1298,42 @@ interface TorqueWrenchReading {
|
|
|
1236
1298
|
}
|
|
1237
1299
|
type EventName = keyof EventHandlers;
|
|
1238
1300
|
|
|
1301
|
+
interface BluetoothClassicSerialDevice {
|
|
1302
|
+
/** Device identifier.
|
|
1303
|
+
* Android: device's MAC address (same value as `address`).
|
|
1304
|
+
* iOS: device UUID. */
|
|
1305
|
+
id: string;
|
|
1306
|
+
/** Device's MAC address (Android only). */
|
|
1307
|
+
address?: string;
|
|
1308
|
+
name: string;
|
|
1309
|
+
/** Bluetooth device class (Android only). */
|
|
1310
|
+
class?: number;
|
|
1311
|
+
rssi?: number;
|
|
1312
|
+
}
|
|
1313
|
+
interface BluetoothClassicSerialImplementation {
|
|
1314
|
+
/** Lists already paired/bonded serial devices. */
|
|
1315
|
+
list: () => Promise<BluetoothClassicSerialDevice[]>;
|
|
1316
|
+
/** Discovers nearby unpaired serial devices. Resolves with all devices found once discovery finishes.
|
|
1317
|
+
* For incremental results during discovery, also register `setDeviceDiscoveredListener`. */
|
|
1318
|
+
discoverUnpaired: () => Promise<BluetoothClassicSerialDevice[]>;
|
|
1319
|
+
/** Registers a listener fired for each device discovered during `discoverUnpaired`. */
|
|
1320
|
+
setDeviceDiscoveredListener?: (notify: (device: BluetoothClassicSerialDevice) => void) => void;
|
|
1321
|
+
/** Removes the listener registered via `setDeviceDiscoveredListener`. */
|
|
1322
|
+
clearDeviceDiscoveredListener?: () => void;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1239
1325
|
/** Creates instance of SDK.
|
|
1240
1326
|
* For real usage, `bleImplementation` argument must be provided - it's an object that follows method definitions from `cordova-plugin-bluetooth-central`.
|
|
1241
1327
|
* If `bleImplementation` is not provided, SDK will work only with the simulator. */
|
|
1242
|
-
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation, securityKeys?: BleSecurityKeys): {
|
|
1328
|
+
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation, securityKeys?: BleSecurityKeys, unitechRfidImplementation?: UnitechRfidImplementation, bluetoothClassicSerialImplementation?: BluetoothClassicSerialImplementation): {
|
|
1243
1329
|
/** Generic methods common for all devices */
|
|
1244
1330
|
bluetooth: {
|
|
1245
1331
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
1246
1332
|
onDeviceUnreachable(callback: (deviceId: string) => void): void;
|
|
1247
1333
|
onDeviceStateChange(callback: (deviceId: string, state?: DeviceState, reason?: StateReason) => void): void;
|
|
1248
1334
|
scanDevices: (services?: string[], duration?: number) => Promise<void>;
|
|
1335
|
+
scanSerialDevicesPaired: () => Promise<void>;
|
|
1336
|
+
scanSerialDevicesUnpaired: () => Promise<void>;
|
|
1249
1337
|
stopScan(): void;
|
|
1250
1338
|
connect: (deviceId: string, disconnectCallback: (deviceId: string) => void) => Promise<void | PeripheralDataExtended>;
|
|
1251
1339
|
disconnect: (deviceId: string) => Promise<void>;
|
|
@@ -1333,6 +1421,19 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1333
1421
|
getTime: (deviceId: string) => Promise<Date>;
|
|
1334
1422
|
onReading: (callback: (deviceId: string, value: TorqueWrenchReading) => void) => void;
|
|
1335
1423
|
};
|
|
1424
|
+
/** Methods for working with Unitech RFID reader */
|
|
1425
|
+
unitechRfid: {
|
|
1426
|
+
connect(deviceId: string): Promise<void>;
|
|
1427
|
+
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
1428
|
+
startReading(): Promise<void>;
|
|
1429
|
+
stopReading(): Promise<void>;
|
|
1430
|
+
onReaderState: (callback: (deviceId: string, event: ReaderStateEvent) => void) => void;
|
|
1431
|
+
onActionState: (callback: (deviceId: string, event: ActionStateEvent) => void) => void;
|
|
1432
|
+
onTrigger: (callback: (deviceId: string, event: TriggerEvent) => void) => void;
|
|
1433
|
+
onTagRead: (callback: (deviceId: string, event: TagReadEvent) => void) => void;
|
|
1434
|
+
onBattery: (callback: (deviceId: string, event: BatteryEvent) => void) => void;
|
|
1435
|
+
onTemperature: (callback: (deviceId: string, event: TemperatureEvent) => void) => void;
|
|
1436
|
+
};
|
|
1336
1437
|
utils: {
|
|
1337
1438
|
bridge: {
|
|
1338
1439
|
convertBarToKpaByte: (deviceId: string, value?: number) => number;
|
|
@@ -1342,4 +1443,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1342
1443
|
};
|
|
1343
1444
|
};
|
|
1344
1445
|
|
|
1345
|
-
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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
|
1446
|
+
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 BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
interface UnitechListenerHandle {
|
|
2
|
+
remove: () => Promise<void>;
|
|
3
|
+
}
|
|
4
|
+
interface ReaderStateEvent {
|
|
5
|
+
state: string;
|
|
6
|
+
}
|
|
7
|
+
interface ActionStateEvent {
|
|
8
|
+
state: string;
|
|
9
|
+
}
|
|
10
|
+
interface TriggerEvent {
|
|
11
|
+
pressed: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface TagReadEvent {
|
|
14
|
+
epc: string;
|
|
15
|
+
rssi: number;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface BatteryEvent {
|
|
19
|
+
percent: number;
|
|
20
|
+
}
|
|
21
|
+
interface TemperatureEvent {
|
|
22
|
+
celsius: number;
|
|
23
|
+
}
|
|
24
|
+
interface UnitechRfidImplementation {
|
|
25
|
+
removeAllListeners: () => Promise<void>;
|
|
26
|
+
addListener: ((eventName: 'readerState', listener: (event: ReaderStateEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'actionState', listener: (event: ActionStateEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'trigger', listener: (event: TriggerEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'tagRead', listener: (event: TagReadEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'battery', listener: (event: BatteryEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'temperature', listener: (event: TemperatureEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>);
|
|
27
|
+
startDetect: (options: {
|
|
28
|
+
deviceName: string;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
stopDetect: () => Promise<void>;
|
|
31
|
+
connect: (options: {
|
|
32
|
+
bluetoothAddress?: string;
|
|
33
|
+
}) => Promise<{
|
|
34
|
+
connected: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
disconnect: () => Promise<void>;
|
|
37
|
+
initDeviceSettings: () => Promise<void>;
|
|
38
|
+
startInventory: () => Promise<void>;
|
|
39
|
+
stopInventory: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
1
42
|
interface BleImplementation {
|
|
2
43
|
startScanWithOptions: (services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure?: (error: string) => any) => void;
|
|
3
44
|
stopScan: () => Promise<void>;
|
|
@@ -118,6 +159,11 @@ declare const _default$1: {
|
|
|
118
159
|
};
|
|
119
160
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleTorqueWrench;
|
|
120
161
|
};
|
|
162
|
+
unitechRfid: {
|
|
163
|
+
nameRegex: RegExp;
|
|
164
|
+
transport: "serial";
|
|
165
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleUnitechRfid;
|
|
166
|
+
};
|
|
121
167
|
};
|
|
122
168
|
|
|
123
169
|
declare const _default: {
|
|
@@ -1095,7 +1141,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
|
|
|
1095
1141
|
};
|
|
1096
1142
|
type BleDeviceType = keyof typeof _default$1;
|
|
1097
1143
|
/** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
|
|
1098
|
-
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench;
|
|
1144
|
+
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench | BleUnitechRfid;
|
|
1099
1145
|
type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
|
|
1100
1146
|
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
|
|
1101
1147
|
interface BleDeviceBase {
|
|
@@ -1125,6 +1171,9 @@ interface BleFlexiGauge extends BleDeviceBase {
|
|
|
1125
1171
|
interface BleTorqueWrench extends BleDeviceBase {
|
|
1126
1172
|
type: 'torqueWrench';
|
|
1127
1173
|
}
|
|
1174
|
+
interface BleUnitechRfid extends BleDeviceBase {
|
|
1175
|
+
type: 'unitechRfid';
|
|
1176
|
+
}
|
|
1128
1177
|
interface BleBridgeOta extends BleDeviceBase {
|
|
1129
1178
|
advertisingData: {
|
|
1130
1179
|
bridgeId: string;
|
|
@@ -1200,12 +1249,25 @@ type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
|
1200
1249
|
type ReportStatusFn = (status: string, completionPercentage: number) => void;
|
|
1201
1250
|
type DeviceState = 'connected' | 'connecting' | 'disconnecting' | 'paired' | undefined;
|
|
1202
1251
|
type StateReason = 'lostConnection' | 'manualDisconnection' | 'failedConnection' | 'failedDisconnection' | 'firmwareUpdate' | string;
|
|
1252
|
+
/** A unique RFID tag aggregated across many tagRead events, keeping the strongest signal seen. */
|
|
1253
|
+
interface RfidTag {
|
|
1254
|
+
epc: string;
|
|
1255
|
+
rssi: number;
|
|
1256
|
+
}
|
|
1203
1257
|
interface EventHandlers {
|
|
1204
1258
|
'fg:treadDepth'?: (deviceId: string, value: number) => void;
|
|
1205
1259
|
'fg:button'?: (deviceId: string, value: string) => void;
|
|
1206
1260
|
'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
|
|
1207
1261
|
'ps:pressure'?: (deviceId: string, value: number) => void;
|
|
1208
1262
|
'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
|
|
1263
|
+
'unitech:readerState'?: (deviceId: string, event: ReaderStateEvent) => void;
|
|
1264
|
+
'unitech:readerStateConnect'?: (deviceId: string, event: ReaderStateEvent) => void;
|
|
1265
|
+
'unitech:actionState'?: (deviceId: string, event: ActionStateEvent) => void;
|
|
1266
|
+
'unitech:trigger'?: (deviceId: string, event: TriggerEvent) => void;
|
|
1267
|
+
'unitech:tag'?: (deviceId: string, event: TagReadEvent) => void;
|
|
1268
|
+
'unitech:tagReadMultiple'?: (deviceId: string, tags: RfidTag[]) => void;
|
|
1269
|
+
'unitech:battery'?: (deviceId: string, event: BatteryEvent) => void;
|
|
1270
|
+
'unitech:temperature'?: (deviceId: string, event: TemperatureEvent) => void;
|
|
1209
1271
|
'bridgeOta:status'?: (deviceId: string, status: string) => void;
|
|
1210
1272
|
'bridgeOta:success'?: (deviceId: string) => void;
|
|
1211
1273
|
'bridgeOta:error'?: (deviceId: string, error: string) => void;
|
|
@@ -1236,16 +1298,42 @@ interface TorqueWrenchReading {
|
|
|
1236
1298
|
}
|
|
1237
1299
|
type EventName = keyof EventHandlers;
|
|
1238
1300
|
|
|
1301
|
+
interface BluetoothClassicSerialDevice {
|
|
1302
|
+
/** Device identifier.
|
|
1303
|
+
* Android: device's MAC address (same value as `address`).
|
|
1304
|
+
* iOS: device UUID. */
|
|
1305
|
+
id: string;
|
|
1306
|
+
/** Device's MAC address (Android only). */
|
|
1307
|
+
address?: string;
|
|
1308
|
+
name: string;
|
|
1309
|
+
/** Bluetooth device class (Android only). */
|
|
1310
|
+
class?: number;
|
|
1311
|
+
rssi?: number;
|
|
1312
|
+
}
|
|
1313
|
+
interface BluetoothClassicSerialImplementation {
|
|
1314
|
+
/** Lists already paired/bonded serial devices. */
|
|
1315
|
+
list: () => Promise<BluetoothClassicSerialDevice[]>;
|
|
1316
|
+
/** Discovers nearby unpaired serial devices. Resolves with all devices found once discovery finishes.
|
|
1317
|
+
* For incremental results during discovery, also register `setDeviceDiscoveredListener`. */
|
|
1318
|
+
discoverUnpaired: () => Promise<BluetoothClassicSerialDevice[]>;
|
|
1319
|
+
/** Registers a listener fired for each device discovered during `discoverUnpaired`. */
|
|
1320
|
+
setDeviceDiscoveredListener?: (notify: (device: BluetoothClassicSerialDevice) => void) => void;
|
|
1321
|
+
/** Removes the listener registered via `setDeviceDiscoveredListener`. */
|
|
1322
|
+
clearDeviceDiscoveredListener?: () => void;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1239
1325
|
/** Creates instance of SDK.
|
|
1240
1326
|
* For real usage, `bleImplementation` argument must be provided - it's an object that follows method definitions from `cordova-plugin-bluetooth-central`.
|
|
1241
1327
|
* If `bleImplementation` is not provided, SDK will work only with the simulator. */
|
|
1242
|
-
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation, securityKeys?: BleSecurityKeys): {
|
|
1328
|
+
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation, securityKeys?: BleSecurityKeys, unitechRfidImplementation?: UnitechRfidImplementation, bluetoothClassicSerialImplementation?: BluetoothClassicSerialImplementation): {
|
|
1243
1329
|
/** Generic methods common for all devices */
|
|
1244
1330
|
bluetooth: {
|
|
1245
1331
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
1246
1332
|
onDeviceUnreachable(callback: (deviceId: string) => void): void;
|
|
1247
1333
|
onDeviceStateChange(callback: (deviceId: string, state?: DeviceState, reason?: StateReason) => void): void;
|
|
1248
1334
|
scanDevices: (services?: string[], duration?: number) => Promise<void>;
|
|
1335
|
+
scanSerialDevicesPaired: () => Promise<void>;
|
|
1336
|
+
scanSerialDevicesUnpaired: () => Promise<void>;
|
|
1249
1337
|
stopScan(): void;
|
|
1250
1338
|
connect: (deviceId: string, disconnectCallback: (deviceId: string) => void) => Promise<void | PeripheralDataExtended>;
|
|
1251
1339
|
disconnect: (deviceId: string) => Promise<void>;
|
|
@@ -1333,6 +1421,19 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1333
1421
|
getTime: (deviceId: string) => Promise<Date>;
|
|
1334
1422
|
onReading: (callback: (deviceId: string, value: TorqueWrenchReading) => void) => void;
|
|
1335
1423
|
};
|
|
1424
|
+
/** Methods for working with Unitech RFID reader */
|
|
1425
|
+
unitechRfid: {
|
|
1426
|
+
connect(deviceId: string): Promise<void>;
|
|
1427
|
+
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
1428
|
+
startReading(): Promise<void>;
|
|
1429
|
+
stopReading(): Promise<void>;
|
|
1430
|
+
onReaderState: (callback: (deviceId: string, event: ReaderStateEvent) => void) => void;
|
|
1431
|
+
onActionState: (callback: (deviceId: string, event: ActionStateEvent) => void) => void;
|
|
1432
|
+
onTrigger: (callback: (deviceId: string, event: TriggerEvent) => void) => void;
|
|
1433
|
+
onTagRead: (callback: (deviceId: string, event: TagReadEvent) => void) => void;
|
|
1434
|
+
onBattery: (callback: (deviceId: string, event: BatteryEvent) => void) => void;
|
|
1435
|
+
onTemperature: (callback: (deviceId: string, event: TemperatureEvent) => void) => void;
|
|
1436
|
+
};
|
|
1336
1437
|
utils: {
|
|
1337
1438
|
bridge: {
|
|
1338
1439
|
convertBarToKpaByte: (deviceId: string, value?: number) => number;
|
|
@@ -1342,4 +1443,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1342
1443
|
};
|
|
1343
1444
|
};
|
|
1344
1445
|
|
|
1345
|
-
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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
|
1446
|
+
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 BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
interface UnitechListenerHandle {
|
|
2
|
+
remove: () => Promise<void>;
|
|
3
|
+
}
|
|
4
|
+
interface ReaderStateEvent {
|
|
5
|
+
state: string;
|
|
6
|
+
}
|
|
7
|
+
interface ActionStateEvent {
|
|
8
|
+
state: string;
|
|
9
|
+
}
|
|
10
|
+
interface TriggerEvent {
|
|
11
|
+
pressed: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface TagReadEvent {
|
|
14
|
+
epc: string;
|
|
15
|
+
rssi: number;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface BatteryEvent {
|
|
19
|
+
percent: number;
|
|
20
|
+
}
|
|
21
|
+
interface TemperatureEvent {
|
|
22
|
+
celsius: number;
|
|
23
|
+
}
|
|
24
|
+
interface UnitechRfidImplementation {
|
|
25
|
+
removeAllListeners: () => Promise<void>;
|
|
26
|
+
addListener: ((eventName: 'readerState', listener: (event: ReaderStateEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'actionState', listener: (event: ActionStateEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'trigger', listener: (event: TriggerEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'tagRead', listener: (event: TagReadEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'battery', listener: (event: BatteryEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>) & ((eventName: 'temperature', listener: (event: TemperatureEvent) => void | Promise<void>) => Promise<UnitechListenerHandle>);
|
|
27
|
+
startDetect: (options: {
|
|
28
|
+
deviceName: string;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
stopDetect: () => Promise<void>;
|
|
31
|
+
connect: (options: {
|
|
32
|
+
bluetoothAddress?: string;
|
|
33
|
+
}) => Promise<{
|
|
34
|
+
connected: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
disconnect: () => Promise<void>;
|
|
37
|
+
initDeviceSettings: () => Promise<void>;
|
|
38
|
+
startInventory: () => Promise<void>;
|
|
39
|
+
stopInventory: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
1
42
|
interface BleImplementation {
|
|
2
43
|
startScanWithOptions: (services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure?: (error: string) => any) => void;
|
|
3
44
|
stopScan: () => Promise<void>;
|
|
@@ -118,6 +159,11 @@ declare const _default$1: {
|
|
|
118
159
|
};
|
|
119
160
|
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleTorqueWrench;
|
|
120
161
|
};
|
|
162
|
+
unitechRfid: {
|
|
163
|
+
nameRegex: RegExp;
|
|
164
|
+
transport: "serial";
|
|
165
|
+
getDeviceInfoFromAdvertising: (device: PeripheralData) => BleUnitechRfid;
|
|
166
|
+
};
|
|
121
167
|
};
|
|
122
168
|
|
|
123
169
|
declare const _default: {
|
|
@@ -1095,7 +1141,7 @@ type BridgeCommandStructurized<T extends BridgeCommandStructureProperties> = {
|
|
|
1095
1141
|
};
|
|
1096
1142
|
type BleDeviceType = keyof typeof _default$1;
|
|
1097
1143
|
/** distinguish by type, e.g. `if (device.type === 'bridge')`, to access furhter fields */
|
|
1098
|
-
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench;
|
|
1144
|
+
type BleDevice = BleBridge | BleBridgeOta | BleFlexiGaugeTpms | BlePressureStick | BleFlexiGauge | BleTorqueWrench | BleUnitechRfid;
|
|
1099
1145
|
type BleDeviceSimulated = BleBridgeSimulated | BleFlexiGaugeTpmsSimulated;
|
|
1100
1146
|
type BleDeviceStatus = 'connected' | 'connecting' | 'disconnecting' | undefined;
|
|
1101
1147
|
interface BleDeviceBase {
|
|
@@ -1125,6 +1171,9 @@ interface BleFlexiGauge extends BleDeviceBase {
|
|
|
1125
1171
|
interface BleTorqueWrench extends BleDeviceBase {
|
|
1126
1172
|
type: 'torqueWrench';
|
|
1127
1173
|
}
|
|
1174
|
+
interface BleUnitechRfid extends BleDeviceBase {
|
|
1175
|
+
type: 'unitechRfid';
|
|
1176
|
+
}
|
|
1128
1177
|
interface BleBridgeOta extends BleDeviceBase {
|
|
1129
1178
|
advertisingData: {
|
|
1130
1179
|
bridgeId: string;
|
|
@@ -1200,12 +1249,25 @@ type Wrapper<T extends Record<string, (...args: any) => any>> = {
|
|
|
1200
1249
|
type ReportStatusFn = (status: string, completionPercentage: number) => void;
|
|
1201
1250
|
type DeviceState = 'connected' | 'connecting' | 'disconnecting' | 'paired' | undefined;
|
|
1202
1251
|
type StateReason = 'lostConnection' | 'manualDisconnection' | 'failedConnection' | 'failedDisconnection' | 'firmwareUpdate' | string;
|
|
1252
|
+
/** A unique RFID tag aggregated across many tagRead events, keeping the strongest signal seen. */
|
|
1253
|
+
interface RfidTag {
|
|
1254
|
+
epc: string;
|
|
1255
|
+
rssi: number;
|
|
1256
|
+
}
|
|
1203
1257
|
interface EventHandlers {
|
|
1204
1258
|
'fg:treadDepth'?: (deviceId: string, value: number) => void;
|
|
1205
1259
|
'fg:button'?: (deviceId: string, value: string) => void;
|
|
1206
1260
|
'fg:tpms'?: (deviceId: string, value: FgSensorReading | undefined) => void;
|
|
1207
1261
|
'ps:pressure'?: (deviceId: string, value: number) => void;
|
|
1208
1262
|
'tw:reading'?: (deviceId: string, value: TorqueWrenchReading) => void;
|
|
1263
|
+
'unitech:readerState'?: (deviceId: string, event: ReaderStateEvent) => void;
|
|
1264
|
+
'unitech:readerStateConnect'?: (deviceId: string, event: ReaderStateEvent) => void;
|
|
1265
|
+
'unitech:actionState'?: (deviceId: string, event: ActionStateEvent) => void;
|
|
1266
|
+
'unitech:trigger'?: (deviceId: string, event: TriggerEvent) => void;
|
|
1267
|
+
'unitech:tag'?: (deviceId: string, event: TagReadEvent) => void;
|
|
1268
|
+
'unitech:tagReadMultiple'?: (deviceId: string, tags: RfidTag[]) => void;
|
|
1269
|
+
'unitech:battery'?: (deviceId: string, event: BatteryEvent) => void;
|
|
1270
|
+
'unitech:temperature'?: (deviceId: string, event: TemperatureEvent) => void;
|
|
1209
1271
|
'bridgeOta:status'?: (deviceId: string, status: string) => void;
|
|
1210
1272
|
'bridgeOta:success'?: (deviceId: string) => void;
|
|
1211
1273
|
'bridgeOta:error'?: (deviceId: string, error: string) => void;
|
|
@@ -1236,16 +1298,42 @@ interface TorqueWrenchReading {
|
|
|
1236
1298
|
}
|
|
1237
1299
|
type EventName = keyof EventHandlers;
|
|
1238
1300
|
|
|
1301
|
+
interface BluetoothClassicSerialDevice {
|
|
1302
|
+
/** Device identifier.
|
|
1303
|
+
* Android: device's MAC address (same value as `address`).
|
|
1304
|
+
* iOS: device UUID. */
|
|
1305
|
+
id: string;
|
|
1306
|
+
/** Device's MAC address (Android only). */
|
|
1307
|
+
address?: string;
|
|
1308
|
+
name: string;
|
|
1309
|
+
/** Bluetooth device class (Android only). */
|
|
1310
|
+
class?: number;
|
|
1311
|
+
rssi?: number;
|
|
1312
|
+
}
|
|
1313
|
+
interface BluetoothClassicSerialImplementation {
|
|
1314
|
+
/** Lists already paired/bonded serial devices. */
|
|
1315
|
+
list: () => Promise<BluetoothClassicSerialDevice[]>;
|
|
1316
|
+
/** Discovers nearby unpaired serial devices. Resolves with all devices found once discovery finishes.
|
|
1317
|
+
* For incremental results during discovery, also register `setDeviceDiscoveredListener`. */
|
|
1318
|
+
discoverUnpaired: () => Promise<BluetoothClassicSerialDevice[]>;
|
|
1319
|
+
/** Registers a listener fired for each device discovered during `discoverUnpaired`. */
|
|
1320
|
+
setDeviceDiscoveredListener?: (notify: (device: BluetoothClassicSerialDevice) => void) => void;
|
|
1321
|
+
/** Removes the listener registered via `setDeviceDiscoveredListener`. */
|
|
1322
|
+
clearDeviceDiscoveredListener?: () => void;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1239
1325
|
/** Creates instance of SDK.
|
|
1240
1326
|
* For real usage, `bleImplementation` argument must be provided - it's an object that follows method definitions from `cordova-plugin-bluetooth-central`.
|
|
1241
1327
|
* If `bleImplementation` is not provided, SDK will work only with the simulator. */
|
|
1242
|
-
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation, securityKeys?: BleSecurityKeys): {
|
|
1328
|
+
declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplementation?: BleImplementation, securityKeys?: BleSecurityKeys, unitechRfidImplementation?: UnitechRfidImplementation, bluetoothClassicSerialImplementation?: BluetoothClassicSerialImplementation): {
|
|
1243
1329
|
/** Generic methods common for all devices */
|
|
1244
1330
|
bluetooth: {
|
|
1245
1331
|
onDeviceAdvertising(callback: (device: BleDevice) => void): void;
|
|
1246
1332
|
onDeviceUnreachable(callback: (deviceId: string) => void): void;
|
|
1247
1333
|
onDeviceStateChange(callback: (deviceId: string, state?: DeviceState, reason?: StateReason) => void): void;
|
|
1248
1334
|
scanDevices: (services?: string[], duration?: number) => Promise<void>;
|
|
1335
|
+
scanSerialDevicesPaired: () => Promise<void>;
|
|
1336
|
+
scanSerialDevicesUnpaired: () => Promise<void>;
|
|
1249
1337
|
stopScan(): void;
|
|
1250
1338
|
connect: (deviceId: string, disconnectCallback: (deviceId: string) => void) => Promise<void | PeripheralDataExtended>;
|
|
1251
1339
|
disconnect: (deviceId: string) => Promise<void>;
|
|
@@ -1333,6 +1421,19 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1333
1421
|
getTime: (deviceId: string) => Promise<Date>;
|
|
1334
1422
|
onReading: (callback: (deviceId: string, value: TorqueWrenchReading) => void) => void;
|
|
1335
1423
|
};
|
|
1424
|
+
/** Methods for working with Unitech RFID reader */
|
|
1425
|
+
unitechRfid: {
|
|
1426
|
+
connect(deviceId: string): Promise<void>;
|
|
1427
|
+
disconnect(deviceId: string, reason?: StateReason): Promise<void>;
|
|
1428
|
+
startReading(): Promise<void>;
|
|
1429
|
+
stopReading(): Promise<void>;
|
|
1430
|
+
onReaderState: (callback: (deviceId: string, event: ReaderStateEvent) => void) => void;
|
|
1431
|
+
onActionState: (callback: (deviceId: string, event: ActionStateEvent) => void) => void;
|
|
1432
|
+
onTrigger: (callback: (deviceId: string, event: TriggerEvent) => void) => void;
|
|
1433
|
+
onTagRead: (callback: (deviceId: string, event: TagReadEvent) => void) => void;
|
|
1434
|
+
onBattery: (callback: (deviceId: string, event: BatteryEvent) => void) => void;
|
|
1435
|
+
onTemperature: (callback: (deviceId: string, event: TemperatureEvent) => void) => void;
|
|
1436
|
+
};
|
|
1336
1437
|
utils: {
|
|
1337
1438
|
bridge: {
|
|
1338
1439
|
convertBarToKpaByte: (deviceId: string, value?: number) => number;
|
|
@@ -1342,4 +1443,4 @@ declare function createTirecheckDeviceSdk(platform: DevicePlatform, bleImplement
|
|
|
1342
1443
|
};
|
|
1343
1444
|
};
|
|
1344
1445
|
|
|
1345
|
-
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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
|
1446
|
+
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 BleUnitechRfid, 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 FgConfig, type FgConfigNeedleLength, type FgConfigPressureDisplay, type FgConfigPressureUnit, type FgConfigRegion, type FgConfigTdUnit, type FgConfigTemperatureUnit, type FgSensorReading, type FgTpmsConfig, type FgTpmsConfigProtocol, type FgTpmsConfigProtocolSetting, type PositionInfo, type ReportStatusFn, type RfidTag, type Simulator, type StateReason, type TorqueWrenchProperties, type TorqueWrenchReading, type TorqueWrenchStartJobParams, type Wrapper, createTirecheckDeviceSdk };
|
package/dist/index.mjs
CHANGED
|
@@ -127,6 +127,19 @@ function normalizeError(error) {
|
|
|
127
127
|
return error;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
const emptyBluetoothClassicSerialImplementation = {
|
|
131
|
+
list: async () => [],
|
|
132
|
+
discoverUnpaired: async () => [],
|
|
133
|
+
setDeviceDiscoveredListener: () => {
|
|
134
|
+
},
|
|
135
|
+
clearDeviceDiscoveredListener: () => {
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
let bluetoothClassicSerial = emptyBluetoothClassicSerialImplementation;
|
|
139
|
+
function setBluetoothClassicSerialImplementation(bluetoothClassicSerialImplementation) {
|
|
140
|
+
bluetoothClassicSerial = bluetoothClassicSerialImplementation ?? emptyBluetoothClassicSerialImplementation;
|
|
141
|
+
}
|
|
142
|
+
|
|
130
143
|
const tyreLabels = getDefaultTyreLabels();
|
|
131
144
|
const bridgeTools = {
|
|
132
145
|
getBridgeFromStore,
|
|
@@ -650,6 +663,17 @@ const deviceMeta = {
|
|
|
650
663
|
};
|
|
651
664
|
return bleDevice;
|
|
652
665
|
}
|
|
666
|
+
},
|
|
667
|
+
unitechRfid: {
|
|
668
|
+
nameRegex: /^RP902/i,
|
|
669
|
+
transport: "serial",
|
|
670
|
+
getDeviceInfoFromAdvertising: (device) => {
|
|
671
|
+
const bleDevice = {
|
|
672
|
+
...device,
|
|
673
|
+
type: "unitechRfid"
|
|
674
|
+
};
|
|
675
|
+
return bleDevice;
|
|
676
|
+
}
|
|
653
677
|
}
|
|
654
678
|
};
|
|
655
679
|
|
|
@@ -686,6 +710,8 @@ const bluetooth = {
|
|
|
686
710
|
deviceStateChangeCallback = callback;
|
|
687
711
|
},
|
|
688
712
|
scanDevices,
|
|
713
|
+
scanSerialDevicesPaired,
|
|
714
|
+
scanSerialDevicesUnpaired,
|
|
689
715
|
stopScan() {
|
|
690
716
|
ble.stopScan();
|
|
691
717
|
},
|
|
@@ -716,6 +742,47 @@ async function scanDevices(services = [], duration) {
|
|
|
716
742
|
(e) => console.error("ble.startScanWithOptions error:", e)
|
|
717
743
|
);
|
|
718
744
|
}
|
|
745
|
+
async function scanSerialDevicesPaired() {
|
|
746
|
+
try {
|
|
747
|
+
const pairedDevices = await bluetoothClassicSerial.list();
|
|
748
|
+
for (const device of pairedDevices ?? []) handleSerialDevice(device);
|
|
749
|
+
} catch (e) {
|
|
750
|
+
console.error("scanPairedSerialDevices error:", e);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
async function scanSerialDevicesUnpaired() {
|
|
754
|
+
bluetoothClassicSerial.setDeviceDiscoveredListener?.((device) => handleSerialDevice(device));
|
|
755
|
+
try {
|
|
756
|
+
const unpairedDevices = await bluetoothClassicSerial.discoverUnpaired();
|
|
757
|
+
for (const device of unpairedDevices ?? []) handleSerialDevice(device);
|
|
758
|
+
} catch (e) {
|
|
759
|
+
const message = (typeof e === "string" ? e : e?.message ?? "").toLowerCase();
|
|
760
|
+
const pickerDismissed = store.platform === "ios" && ["cancel", "alreadyconnected", "already connected", "notfound", "not found"].some((m) => message.includes(m));
|
|
761
|
+
if (pickerDismissed) {
|
|
762
|
+
console.log("discoverSerialDevices: accessory picker returned no unpaired device -", message);
|
|
763
|
+
} else {
|
|
764
|
+
console.error("discoverSerialDevices error:", e);
|
|
765
|
+
}
|
|
766
|
+
} finally {
|
|
767
|
+
bluetoothClassicSerial.clearDeviceDiscoveredListener?.();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
function handleSerialDevice(device) {
|
|
771
|
+
const rawId = device.id ?? device.address;
|
|
772
|
+
const id = rawId != null ? String(rawId) : void 0;
|
|
773
|
+
if (!id) {
|
|
774
|
+
console.warn("handleSerialDevice: skipped, no id/address", device);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const peripheral = { id, name: device.name, rssi: device.rssi ?? 0, advertising: {} };
|
|
778
|
+
const processedDevice = processDevice(peripheral);
|
|
779
|
+
if (!processedDevice) {
|
|
780
|
+
console.warn("handleSerialDevice: processDevice returned null (filtered out)", id, device.name);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
store.devices[processedDevice.id] = processedDevice;
|
|
784
|
+
deviceAdvertisingCallback?.(processedDevice);
|
|
785
|
+
}
|
|
719
786
|
async function connect$1(deviceId, disconnectCallback) {
|
|
720
787
|
if (toolsSvc.canCommunicateWith(deviceId)) return console.warn("Connect Warn: Already connected to device");
|
|
721
788
|
store.setState(deviceId, "connecting");
|
|
@@ -804,7 +871,8 @@ function processDevice(device) {
|
|
|
804
871
|
console.warn("Error processing advertising", e);
|
|
805
872
|
return;
|
|
806
873
|
}
|
|
807
|
-
|
|
874
|
+
const isSerial = deviceMeta[deviceType].transport === "serial";
|
|
875
|
+
if (!isSerial) unreachableSvc.refresh(processedDevice.id, deviceUnreachableCallback);
|
|
808
876
|
return processedDevice;
|
|
809
877
|
}
|
|
810
878
|
function getDeviceTypeFromName(name) {
|
|
@@ -1509,64 +1577,64 @@ const bridgeCommandStructures = {
|
|
|
1509
1577
|
name: "autolearnUnknownSensors",
|
|
1510
1578
|
structure: {
|
|
1511
1579
|
sensor01: {
|
|
1512
|
-
size:
|
|
1513
|
-
description: "Unknown sensor data"
|
|
1580
|
+
size: 13,
|
|
1581
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1514
1582
|
},
|
|
1515
1583
|
sensor02: {
|
|
1516
|
-
size:
|
|
1517
|
-
description: "Unknown sensor data"
|
|
1584
|
+
size: 13,
|
|
1585
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1518
1586
|
},
|
|
1519
1587
|
sensor03: {
|
|
1520
|
-
size:
|
|
1521
|
-
description: "Unknown sensor data"
|
|
1588
|
+
size: 13,
|
|
1589
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1522
1590
|
},
|
|
1523
1591
|
sensor04: {
|
|
1524
|
-
size:
|
|
1525
|
-
description: "Unknown sensor data"
|
|
1592
|
+
size: 13,
|
|
1593
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1526
1594
|
},
|
|
1527
1595
|
sensor05: {
|
|
1528
|
-
size:
|
|
1529
|
-
description: "Unknown sensor data"
|
|
1596
|
+
size: 13,
|
|
1597
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1530
1598
|
},
|
|
1531
1599
|
sensor06: {
|
|
1532
|
-
size:
|
|
1533
|
-
description: "Unknown sensor data"
|
|
1600
|
+
size: 13,
|
|
1601
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1534
1602
|
},
|
|
1535
1603
|
sensor07: {
|
|
1536
|
-
size:
|
|
1537
|
-
description: "Unknown sensor data"
|
|
1604
|
+
size: 13,
|
|
1605
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1538
1606
|
},
|
|
1539
1607
|
sensor08: {
|
|
1540
|
-
size:
|
|
1541
|
-
description: "Unknown sensor data"
|
|
1608
|
+
size: 13,
|
|
1609
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1542
1610
|
},
|
|
1543
1611
|
sensor09: {
|
|
1544
|
-
size:
|
|
1545
|
-
description: "Unknown sensor data"
|
|
1612
|
+
size: 13,
|
|
1613
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1546
1614
|
},
|
|
1547
1615
|
sensor10: {
|
|
1548
|
-
size:
|
|
1549
|
-
description: "Unknown sensor data"
|
|
1616
|
+
size: 13,
|
|
1617
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1550
1618
|
},
|
|
1551
1619
|
sensor11: {
|
|
1552
|
-
size:
|
|
1553
|
-
description: "Unknown sensor data"
|
|
1620
|
+
size: 13,
|
|
1621
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1554
1622
|
},
|
|
1555
1623
|
sensor12: {
|
|
1556
|
-
size:
|
|
1557
|
-
description: "Unknown sensor data"
|
|
1624
|
+
size: 13,
|
|
1625
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1558
1626
|
},
|
|
1559
1627
|
sensor13: {
|
|
1560
|
-
size:
|
|
1561
|
-
description: "Unknown sensor data"
|
|
1628
|
+
size: 13,
|
|
1629
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1562
1630
|
},
|
|
1563
1631
|
sensor14: {
|
|
1564
|
-
size:
|
|
1565
|
-
description: "Unknown sensor data"
|
|
1632
|
+
size: 13,
|
|
1633
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1566
1634
|
},
|
|
1567
1635
|
sensor15: {
|
|
1568
|
-
size:
|
|
1569
|
-
description: "Unknown sensor data"
|
|
1636
|
+
size: 13,
|
|
1637
|
+
description: "Unknown sensor data: timestamp; ID; pressure; temperature; status; RSSI; message counter (13-byte record)"
|
|
1570
1638
|
}
|
|
1571
1639
|
}
|
|
1572
1640
|
},
|
|
@@ -2188,7 +2256,10 @@ const bridgeCommands = {
|
|
|
2188
2256
|
},
|
|
2189
2257
|
async getAutolearnUnknownSensors(deviceId) {
|
|
2190
2258
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2191
|
-
const result = await this.readCommand(deviceData, subCommandIds.autolearnUnknownSensors
|
|
2259
|
+
const result = await this.readCommand(deviceData, subCommandIds.autolearnUnknownSensors, {
|
|
2260
|
+
headerLength: 5,
|
|
2261
|
+
footerLength: 4
|
|
2262
|
+
});
|
|
2192
2263
|
const structurized = bridgeTools.convertBytesToStructure(
|
|
2193
2264
|
bridgeCommandStructures.autolearnUnknownSensors.structure,
|
|
2194
2265
|
result.data,
|
|
@@ -2269,7 +2340,7 @@ const bridgeCommands = {
|
|
|
2269
2340
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2270
2341
|
const result = await this.readCommand(deviceData, subCommandIds.firmwareVersion, {
|
|
2271
2342
|
headerLength: 5,
|
|
2272
|
-
footerLength:
|
|
2343
|
+
footerLength: 4
|
|
2273
2344
|
});
|
|
2274
2345
|
return bridgeTools.convertBytesToStructure(
|
|
2275
2346
|
bridgeCommandStructures.firmwareVersion.structure,
|
|
@@ -2281,7 +2352,7 @@ const bridgeCommands = {
|
|
|
2281
2352
|
const deviceData = bridgeTools.getBridgeFromStore(deviceId);
|
|
2282
2353
|
const result = await this.readCommand(deviceData, subCommandIds.errorHistoryCounter, {
|
|
2283
2354
|
headerLength: 5,
|
|
2284
|
-
footerLength:
|
|
2355
|
+
footerLength: 4
|
|
2285
2356
|
});
|
|
2286
2357
|
return bridgeTools.convertBytesToStructure(
|
|
2287
2358
|
bridgeCommandStructures.errorHistoryCounter.structure,
|
|
@@ -4150,6 +4221,95 @@ const torqueWrench = {
|
|
|
4150
4221
|
onReading: torqueWrenchService.onReading
|
|
4151
4222
|
};
|
|
4152
4223
|
|
|
4224
|
+
let unitech;
|
|
4225
|
+
function setUnitechRfidImplementation(unitechRfidImplementation) {
|
|
4226
|
+
if (!unitechRfidImplementation)
|
|
4227
|
+
return console.warn("Unitech RFID implementation is not provided, Unitech RFID functionality will not work");
|
|
4228
|
+
unitech = unitechRfidImplementation;
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
const unitechRfidService = {
|
|
4232
|
+
subscribeListeners(deviceId) {
|
|
4233
|
+
unitech.addListener("readerState", (event) => {
|
|
4234
|
+
simulatorSvc.triggerEvent("unitech:readerState", deviceId, event);
|
|
4235
|
+
simulatorSvc.triggerEvent("unitech:readerStateConnect", deviceId, event);
|
|
4236
|
+
});
|
|
4237
|
+
unitech.addListener("actionState", (event) => simulatorSvc.triggerEvent("unitech:actionState", deviceId, event));
|
|
4238
|
+
unitech.addListener("trigger", (event) => simulatorSvc.triggerEvent("unitech:trigger", deviceId, event));
|
|
4239
|
+
unitech.addListener("tagRead", (event) => simulatorSvc.triggerEvent("unitech:tag", deviceId, event));
|
|
4240
|
+
unitech.addListener("battery", (event) => simulatorSvc.triggerEvent("unitech:battery", deviceId, event));
|
|
4241
|
+
unitech.addListener("temperature", (event) => simulatorSvc.triggerEvent("unitech:temperature", deviceId, event));
|
|
4242
|
+
},
|
|
4243
|
+
onReaderState(callback) {
|
|
4244
|
+
simulatorSvc.registerEvent("unitech:readerState", callback);
|
|
4245
|
+
},
|
|
4246
|
+
onActionState(callback) {
|
|
4247
|
+
simulatorSvc.registerEvent("unitech:actionState", callback);
|
|
4248
|
+
},
|
|
4249
|
+
onTrigger(callback) {
|
|
4250
|
+
simulatorSvc.registerEvent("unitech:trigger", callback);
|
|
4251
|
+
},
|
|
4252
|
+
onTagRead(callback) {
|
|
4253
|
+
simulatorSvc.registerEvent("unitech:tag", callback);
|
|
4254
|
+
},
|
|
4255
|
+
onBattery(callback) {
|
|
4256
|
+
simulatorSvc.registerEvent("unitech:battery", callback);
|
|
4257
|
+
},
|
|
4258
|
+
onTemperature(callback) {
|
|
4259
|
+
simulatorSvc.registerEvent("unitech:temperature", callback);
|
|
4260
|
+
}
|
|
4261
|
+
};
|
|
4262
|
+
|
|
4263
|
+
const unitechRfid = {
|
|
4264
|
+
async connect(deviceId) {
|
|
4265
|
+
const unitechDevices = Object.values(store.devices).filter((d) => d.type === "unitechRfid");
|
|
4266
|
+
for (const device2 of unitechDevices) {
|
|
4267
|
+
if (device2.id !== deviceId && store.deviceState[device2.id] === "paired") {
|
|
4268
|
+
await this.disconnect(device2.id, "manualDisconnection");
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
store.setState(deviceId, "connecting");
|
|
4272
|
+
await unitech.removeAllListeners();
|
|
4273
|
+
const device = store.devices[deviceId];
|
|
4274
|
+
if (store.platform === "ios") {
|
|
4275
|
+
await unitech.startDetect({ deviceName: device.name });
|
|
4276
|
+
await toolsSvc.delay(500);
|
|
4277
|
+
await unitech.stopDetect();
|
|
4278
|
+
}
|
|
4279
|
+
const { connected } = await unitech.connect({ bluetoothAddress: device.id });
|
|
4280
|
+
if (!connected) throw new Error("UnitechRfid Error: Unable to connect to the device.");
|
|
4281
|
+
await unitechRfidService.subscribeListeners(deviceId);
|
|
4282
|
+
await withTimeout(
|
|
4283
|
+
new Promise((resolve) => {
|
|
4284
|
+
simulatorSvc.registerEvent("unitech:readerStateConnect", (_deviceId, event) => {
|
|
4285
|
+
if (event.state?.toLowerCase() === "connected") resolve();
|
|
4286
|
+
});
|
|
4287
|
+
}),
|
|
4288
|
+
15e3
|
|
4289
|
+
);
|
|
4290
|
+
await unitech.initDeviceSettings();
|
|
4291
|
+
store.setState(deviceId, "paired");
|
|
4292
|
+
},
|
|
4293
|
+
async disconnect(deviceId, reason) {
|
|
4294
|
+
store.setState(deviceId, "disconnecting");
|
|
4295
|
+
await unitech.removeAllListeners();
|
|
4296
|
+
await unitech.disconnect();
|
|
4297
|
+
store.setState(deviceId, void 0, reason ?? "manualDisconnection");
|
|
4298
|
+
},
|
|
4299
|
+
async startReading() {
|
|
4300
|
+
await unitech.startInventory();
|
|
4301
|
+
},
|
|
4302
|
+
async stopReading() {
|
|
4303
|
+
await unitech.stopInventory();
|
|
4304
|
+
},
|
|
4305
|
+
onReaderState: unitechRfidService.onReaderState,
|
|
4306
|
+
onActionState: unitechRfidService.onActionState,
|
|
4307
|
+
onTrigger: unitechRfidService.onTrigger,
|
|
4308
|
+
onTagRead: unitechRfidService.onTagRead,
|
|
4309
|
+
onBattery: unitechRfidService.onBattery,
|
|
4310
|
+
onTemperature: unitechRfidService.onTemperature
|
|
4311
|
+
};
|
|
4312
|
+
|
|
4153
4313
|
const bridgeSimulator = {
|
|
4154
4314
|
isRebootRequired(deviceId) {
|
|
4155
4315
|
return store.bridgeRebootRequired[deviceId];
|
|
@@ -4791,11 +4951,13 @@ class BridgeTcVehicleAxle {
|
|
|
4791
4951
|
minTargetPressure;
|
|
4792
4952
|
}
|
|
4793
4953
|
|
|
4794
|
-
function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
4954
|
+
function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys, unitechRfidImplementation, bluetoothClassicSerialImplementation) {
|
|
4795
4955
|
store.platform = platform;
|
|
4796
4956
|
bleImplementation = bleImplementation || emptyBleImplementation;
|
|
4797
4957
|
store.securityKeys = securityKeys || {};
|
|
4798
4958
|
setBleImplementation(bleImplementation);
|
|
4959
|
+
setUnitechRfidImplementation(unitechRfidImplementation);
|
|
4960
|
+
setBluetoothClassicSerialImplementation(bluetoothClassicSerialImplementation);
|
|
4799
4961
|
return {
|
|
4800
4962
|
/** Generic methods common for all devices */
|
|
4801
4963
|
bluetooth,
|
|
@@ -4813,6 +4975,8 @@ function createTirecheckDeviceSdk(platform, bleImplementation, securityKeys) {
|
|
|
4813
4975
|
simulator,
|
|
4814
4976
|
/** Methods for working with Tirecheck Torque Wrench */
|
|
4815
4977
|
torqueWrench,
|
|
4978
|
+
/** Methods for working with Unitech RFID reader */
|
|
4979
|
+
unitechRfid,
|
|
4816
4980
|
utils: {
|
|
4817
4981
|
bridge: {
|
|
4818
4982
|
convertBarToKpaByte: bridgeTools.convertBarToKpaByte,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tirecheck-device-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.71",
|
|
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",
|