capacitor-rfid-plugin-ox 0.3.5 → 0.5.0
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/README.md +206 -0
- package/dist/docs.json +277 -2
- package/dist/esm/definitions.d.ts +141 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/electron-bridge.d.ts +30 -0
- package/dist/esm/electron-bridge.js +55 -0
- package/dist/esm/electron-bridge.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +33 -23
- package/dist/esm/web.js +65 -35
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +128 -35
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +128 -35
- package/dist/plugin.js.map +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -13,6 +13,10 @@ npx cap sync
|
|
|
13
13
|
|
|
14
14
|
<docgen-index>
|
|
15
15
|
|
|
16
|
+
* [`getCapabilities()`](#getcapabilities)
|
|
17
|
+
* [`getConnectionState()`](#getconnectionstate)
|
|
18
|
+
* [`listReaderPorts()`](#listreaderports)
|
|
19
|
+
* [`selectReaderPort(...)`](#selectreaderport)
|
|
16
20
|
* [`isConnected()`](#isconnected)
|
|
17
21
|
* [`startScan()`](#startscan)
|
|
18
22
|
* [`stopScan()`](#stopscan)
|
|
@@ -30,12 +34,97 @@ npx cap sync
|
|
|
30
34
|
* [`writeEpcString(...)`](#writeepcstring)
|
|
31
35
|
* [`startSearch(...)`](#startsearch)
|
|
32
36
|
* [`stopSearch()`](#stopsearch)
|
|
37
|
+
* [`addListener('onConnectionState', ...)`](#addlisteneronconnectionstate-)
|
|
38
|
+
* [`addListener(string, ...)`](#addlistenerstring-)
|
|
39
|
+
* [Interfaces](#interfaces)
|
|
40
|
+
* [Type Aliases](#type-aliases)
|
|
33
41
|
|
|
34
42
|
</docgen-index>
|
|
35
43
|
|
|
36
44
|
<docgen-api>
|
|
37
45
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
38
46
|
|
|
47
|
+
### getCapabilities()
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
getCapabilities() => Promise<ReaderCapabilities>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Capabilities of the connected Reader.
|
|
54
|
+
|
|
55
|
+
Implementations that predate this method reject. That is a signal, not a
|
|
56
|
+
failure: the caller treats a rejection as a handheld Mobile Reader.
|
|
57
|
+
|
|
58
|
+
**Returns:** <code>Promise<<a href="#readercapabilities">ReaderCapabilities</a>></code>
|
|
59
|
+
|
|
60
|
+
--------------------
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### getConnectionState()
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
getConnectionState() => Promise<ReaderConnectionState>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Connection state for the first render. The stream of later changes comes
|
|
70
|
+
from the `onConnectionState` listener — "not responding" is only found out
|
|
71
|
+
after a timeout, so it cannot be a return value.
|
|
72
|
+
|
|
73
|
+
A reader is an exclusive resource, so its state is only knowable while it
|
|
74
|
+
is held: an implementation that is not connected may start an attempt here
|
|
75
|
+
and answer `connecting`, with the outcome arriving on the listener.
|
|
76
|
+
|
|
77
|
+
Implementations that predate this method reject. The caller then hides the
|
|
78
|
+
indicator instead of guessing.
|
|
79
|
+
|
|
80
|
+
**Returns:** <code>Promise<<a href="#readerconnectionstate">ReaderConnectionState</a>></code>
|
|
81
|
+
|
|
82
|
+
--------------------
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### listReaderPorts()
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
listReaderPorts() => Promise<{ ports: ReaderPort[]; }>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The readers plugged in right now, newest listing every call — a port that
|
|
92
|
+
was there a minute ago may be gone.
|
|
93
|
+
|
|
94
|
+
Only readers, not every serial port: what the caller does with this list
|
|
95
|
+
is offer it as a choice, and a Bluetooth port is not a choice.
|
|
96
|
+
|
|
97
|
+
Implementations that predate this method reject. The caller then keeps
|
|
98
|
+
whatever the driver picks on its own.
|
|
99
|
+
|
|
100
|
+
**Returns:** <code>Promise<{ ports: ReaderPort[]; }></code>
|
|
101
|
+
|
|
102
|
+
--------------------
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### selectReaderPort(...)
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
selectReaderPort(options: { path: string; }) => Promise<void>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Use this reader from now on. Reconnects when another port is open.
|
|
112
|
+
|
|
113
|
+
The choice itself is not stored here: the driver is restarted with the
|
|
114
|
+
app, and where a choice belongs is the caller's question. The caller
|
|
115
|
+
remembers the path and says it again on the next start.
|
|
116
|
+
|
|
117
|
+
Rejects when the path is not in the current `listReaderPorts()` — a
|
|
118
|
+
remembered reader that was unplugged has to be chosen again, not opened
|
|
119
|
+
blindly.
|
|
120
|
+
|
|
121
|
+
| Param | Type |
|
|
122
|
+
| ------------- | ------------------------------ |
|
|
123
|
+
| **`options`** | <code>{ path: string; }</code> |
|
|
124
|
+
|
|
125
|
+
--------------------
|
|
126
|
+
|
|
127
|
+
|
|
39
128
|
### isConnected()
|
|
40
129
|
|
|
41
130
|
```typescript
|
|
@@ -236,4 +325,121 @@ stopSearch() => Promise<void>
|
|
|
236
325
|
|
|
237
326
|
--------------------
|
|
238
327
|
|
|
328
|
+
|
|
329
|
+
### addListener('onConnectionState', ...)
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
addListener(eventName: 'onConnectionState', listener: (state: ReaderConnectionState) => void) => Promise<PluginListenerHandle>
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Every connection state change. Fires only on a change, not on a poll.
|
|
336
|
+
|
|
337
|
+
| Param | Type |
|
|
338
|
+
| --------------- | ------------------------------------------------------------------------------------------- |
|
|
339
|
+
| **`eventName`** | <code>'onConnectionState'</code> |
|
|
340
|
+
| **`listener`** | <code>(state: <a href="#readerconnectionstate">ReaderConnectionState</a>) => void</code> |
|
|
341
|
+
|
|
342
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
343
|
+
|
|
344
|
+
--------------------
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
### addListener(string, ...)
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
addListener(eventName: string, listenerFunc: (...args: any[]) => any) => Promise<PluginListenerHandle>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
| Param | Type |
|
|
354
|
+
| ------------------ | --------------------------------------- |
|
|
355
|
+
| **`eventName`** | <code>string</code> |
|
|
356
|
+
| **`listenerFunc`** | <code>(...args: any[]) => any</code> |
|
|
357
|
+
|
|
358
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
359
|
+
|
|
360
|
+
--------------------
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
### Interfaces
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
#### ReaderCapabilities
|
|
367
|
+
|
|
368
|
+
What the connected Reader can do. Mode gating comes from here, not from the
|
|
369
|
+
reader type — a desktop reader that can write must not be gated like one
|
|
370
|
+
that cannot.
|
|
371
|
+
|
|
372
|
+
| Prop | Type | Description |
|
|
373
|
+
| ---------------- | ----------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
374
|
+
| **`canWrite`** | <code>boolean</code> | Reader can write an EPC to a tag (Generate & Set mode depends on it). |
|
|
375
|
+
| **`hasRssi`** | <code>boolean</code> | Reader reports RSSI (Find mode depends on it). |
|
|
376
|
+
| **`isHandheld`** | <code>boolean</code> | Reader is a handheld terminal rather than a desk device. |
|
|
377
|
+
| **`power`** | <code>{ min: number; max: number; default: number; }</code> | Output power range in dBm. The power slider renders this range. |
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
#### ReaderConnectionState
|
|
381
|
+
|
|
382
|
+
| Prop | Type | Description |
|
|
383
|
+
| ------------ | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
384
|
+
| **`status`** | <code><a href="#readerconnectionstatus">ReaderConnectionStatus</a></code> | |
|
|
385
|
+
| **`reason`** | <code><a href="#readerconnectionreason">ReaderConnectionReason</a></code> | |
|
|
386
|
+
| **`detail`** | <code>string</code> | Driver text: the port list, the command code, the OS error. This is the one field allowed to talk about the wiring, because nothing branches on it — it is shown as-is for support, not translated. |
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
#### ReaderPort
|
|
390
|
+
|
|
391
|
+
One reader the driver could talk to.
|
|
392
|
+
|
|
393
|
+
`path` is the identity — `COM3` on Windows, `/dev/cu.usbserial-110`
|
|
394
|
+
elsewhere. Two identical CH340 adapters carry no serial number of their own,
|
|
395
|
+
so the path is all that separates them.
|
|
396
|
+
|
|
397
|
+
The caller treats it as **opaque**: it compares, stores and hands it back,
|
|
398
|
+
and never reads meaning out of it. A driver for a device that is not a
|
|
399
|
+
serial port puts its own identity here.
|
|
400
|
+
|
|
401
|
+
| Prop | Type | Description |
|
|
402
|
+
| --------------- | ------------------- | ------------------------------------------------------------------------ |
|
|
403
|
+
| **`path`** | <code>string</code> | |
|
|
404
|
+
| **`label`** | <code>string</code> | What the OS calls the device. For the operator to read, not to match on. |
|
|
405
|
+
| **`vendorId`** | <code>string</code> | |
|
|
406
|
+
| **`productId`** | <code>string</code> | |
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
#### PluginListenerHandle
|
|
410
|
+
|
|
411
|
+
| Prop | Type |
|
|
412
|
+
| ------------ | ----------------------------------------- |
|
|
413
|
+
| **`remove`** | <code>() => Promise<void></code> |
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
### Type Aliases
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
#### ReaderConnectionStatus
|
|
420
|
+
|
|
421
|
+
The four states an operator can act on.
|
|
422
|
+
|
|
423
|
+
`isConnected()` is too coarse for this: a reader that is plugged in but
|
|
424
|
+
silent answers `false` the same way a missing one does, and the operator
|
|
425
|
+
needs a different move in each case. `isConnected()` stays as it is.
|
|
426
|
+
|
|
427
|
+
<code>'connecting' | 'connected' | 'not-found' | 'not-responding'</code>
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
#### ReaderConnectionReason
|
|
431
|
+
|
|
432
|
+
Why the reader is unusable. The status alone does not say what to do next:
|
|
433
|
+
a busy reader needs another program closed, a missing one needs the
|
|
434
|
+
connection checked. The UI picks its message from the reason when there is
|
|
435
|
+
one.
|
|
436
|
+
|
|
437
|
+
These name what happened to the *reader*, never how it is wired. A driver
|
|
438
|
+
for a device with no serial port has to be able to answer in this
|
|
439
|
+
vocabulary too, and the operator has to be told the truth either way —
|
|
440
|
+
so nothing here says "COM port" or "USB". The device-specific sentence
|
|
441
|
+
belongs in `detail`.
|
|
442
|
+
|
|
443
|
+
<code>'busy' | 'not-detected' | 'disconnected' | 'no-answer' | 'not-chosen'</code>
|
|
444
|
+
|
|
239
445
|
</docgen-api>
|
package/dist/docs.json
CHANGED
|
@@ -5,6 +5,58 @@
|
|
|
5
5
|
"docs": "",
|
|
6
6
|
"tags": [],
|
|
7
7
|
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "getCapabilities",
|
|
10
|
+
"signature": "() => Promise<ReaderCapabilities>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<ReaderCapabilities>",
|
|
13
|
+
"tags": [],
|
|
14
|
+
"docs": "Capabilities of the connected Reader.\n\nImplementations that predate this method reject. That is a signal, not a\nfailure: the caller treats a rejection as a handheld Mobile Reader.",
|
|
15
|
+
"complexTypes": [
|
|
16
|
+
"ReaderCapabilities"
|
|
17
|
+
],
|
|
18
|
+
"slug": "getcapabilities"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "getConnectionState",
|
|
22
|
+
"signature": "() => Promise<ReaderConnectionState>",
|
|
23
|
+
"parameters": [],
|
|
24
|
+
"returns": "Promise<ReaderConnectionState>",
|
|
25
|
+
"tags": [],
|
|
26
|
+
"docs": "Connection state for the first render. The stream of later changes comes\nfrom the `onConnectionState` listener — \"not responding\" is only found out\nafter a timeout, so it cannot be a return value.\n\nA reader is an exclusive resource, so its state is only knowable while it\nis held: an implementation that is not connected may start an attempt here\nand answer `connecting`, with the outcome arriving on the listener.\n\nImplementations that predate this method reject. The caller then hides the\nindicator instead of guessing.",
|
|
27
|
+
"complexTypes": [
|
|
28
|
+
"ReaderConnectionState"
|
|
29
|
+
],
|
|
30
|
+
"slug": "getconnectionstate"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "listReaderPorts",
|
|
34
|
+
"signature": "() => Promise<{ ports: ReaderPort[]; }>",
|
|
35
|
+
"parameters": [],
|
|
36
|
+
"returns": "Promise<{ ports: ReaderPort[]; }>",
|
|
37
|
+
"tags": [],
|
|
38
|
+
"docs": "The readers plugged in right now, newest listing every call — a port that\nwas there a minute ago may be gone.\n\nOnly readers, not every serial port: what the caller does with this list\nis offer it as a choice, and a Bluetooth port is not a choice.\n\nImplementations that predate this method reject. The caller then keeps\nwhatever the driver picks on its own.",
|
|
39
|
+
"complexTypes": [
|
|
40
|
+
"ReaderPort"
|
|
41
|
+
],
|
|
42
|
+
"slug": "listreaderports"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "selectReaderPort",
|
|
46
|
+
"signature": "(options: { path: string; }) => Promise<void>",
|
|
47
|
+
"parameters": [
|
|
48
|
+
{
|
|
49
|
+
"name": "options",
|
|
50
|
+
"docs": "",
|
|
51
|
+
"type": "{ path: string; }"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"returns": "Promise<void>",
|
|
55
|
+
"tags": [],
|
|
56
|
+
"docs": "Use this reader from now on. Reconnects when another port is open.\n\nThe choice itself is not stored here: the driver is restarted with the\napp, and where a choice belongs is the caller's question. The caller\nremembers the path and says it again on the next start.\n\nRejects when the path is not in the current `listReaderPorts()` — a\nremembered reader that was unplugged has to be chosen again, not opened\nblindly.",
|
|
57
|
+
"complexTypes": [],
|
|
58
|
+
"slug": "selectreaderport"
|
|
59
|
+
},
|
|
8
60
|
{
|
|
9
61
|
"name": "isConnected",
|
|
10
62
|
"signature": "() => Promise<{ connected: boolean; }>",
|
|
@@ -210,12 +262,235 @@
|
|
|
210
262
|
"docs": "",
|
|
211
263
|
"complexTypes": [],
|
|
212
264
|
"slug": "stopsearch"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"name": "addListener",
|
|
268
|
+
"signature": "(eventName: 'onConnectionState', listener: (state: ReaderConnectionState) => void) => Promise<PluginListenerHandle>",
|
|
269
|
+
"parameters": [
|
|
270
|
+
{
|
|
271
|
+
"name": "eventName",
|
|
272
|
+
"docs": "",
|
|
273
|
+
"type": "'onConnectionState'"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "listener",
|
|
277
|
+
"docs": "",
|
|
278
|
+
"type": "(state: ReaderConnectionState) => void"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
282
|
+
"tags": [],
|
|
283
|
+
"docs": "Every connection state change. Fires only on a change, not on a poll.",
|
|
284
|
+
"complexTypes": [
|
|
285
|
+
"PluginListenerHandle",
|
|
286
|
+
"ReaderConnectionState"
|
|
287
|
+
],
|
|
288
|
+
"slug": "addlisteneronconnectionstate-"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"name": "addListener",
|
|
292
|
+
"signature": "(eventName: string, listenerFunc: (...args: any[]) => any) => Promise<PluginListenerHandle>",
|
|
293
|
+
"parameters": [
|
|
294
|
+
{
|
|
295
|
+
"name": "eventName",
|
|
296
|
+
"docs": "",
|
|
297
|
+
"type": "string"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"name": "listenerFunc",
|
|
301
|
+
"docs": "",
|
|
302
|
+
"type": "(...args: any[]) => any"
|
|
303
|
+
}
|
|
304
|
+
],
|
|
305
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
306
|
+
"tags": [],
|
|
307
|
+
"docs": "",
|
|
308
|
+
"complexTypes": [
|
|
309
|
+
"PluginListenerHandle"
|
|
310
|
+
],
|
|
311
|
+
"slug": "addlistenerstring-"
|
|
213
312
|
}
|
|
214
313
|
],
|
|
215
314
|
"properties": []
|
|
216
315
|
},
|
|
217
|
-
"interfaces": [
|
|
316
|
+
"interfaces": [
|
|
317
|
+
{
|
|
318
|
+
"name": "ReaderCapabilities",
|
|
319
|
+
"slug": "readercapabilities",
|
|
320
|
+
"docs": "What the connected Reader can do. Mode gating comes from here, not from the\nreader type — a desktop reader that can write must not be gated like one\nthat cannot.",
|
|
321
|
+
"tags": [],
|
|
322
|
+
"methods": [],
|
|
323
|
+
"properties": [
|
|
324
|
+
{
|
|
325
|
+
"name": "canWrite",
|
|
326
|
+
"tags": [],
|
|
327
|
+
"docs": "Reader can write an EPC to a tag (Generate & Set mode depends on it).",
|
|
328
|
+
"complexTypes": [],
|
|
329
|
+
"type": "boolean"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"name": "hasRssi",
|
|
333
|
+
"tags": [],
|
|
334
|
+
"docs": "Reader reports RSSI (Find mode depends on it).",
|
|
335
|
+
"complexTypes": [],
|
|
336
|
+
"type": "boolean"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"name": "isHandheld",
|
|
340
|
+
"tags": [],
|
|
341
|
+
"docs": "Reader is a handheld terminal rather than a desk device.",
|
|
342
|
+
"complexTypes": [],
|
|
343
|
+
"type": "boolean"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"name": "power",
|
|
347
|
+
"tags": [],
|
|
348
|
+
"docs": "Output power range in dBm. The power slider renders this range.",
|
|
349
|
+
"complexTypes": [],
|
|
350
|
+
"type": "{ min: number; max: number; default: number; }"
|
|
351
|
+
}
|
|
352
|
+
]
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"name": "ReaderConnectionState",
|
|
356
|
+
"slug": "readerconnectionstate",
|
|
357
|
+
"docs": "",
|
|
358
|
+
"tags": [],
|
|
359
|
+
"methods": [],
|
|
360
|
+
"properties": [
|
|
361
|
+
{
|
|
362
|
+
"name": "status",
|
|
363
|
+
"tags": [],
|
|
364
|
+
"docs": "",
|
|
365
|
+
"complexTypes": [
|
|
366
|
+
"ReaderConnectionStatus"
|
|
367
|
+
],
|
|
368
|
+
"type": "ReaderConnectionStatus"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"name": "reason",
|
|
372
|
+
"tags": [],
|
|
373
|
+
"docs": "",
|
|
374
|
+
"complexTypes": [
|
|
375
|
+
"ReaderConnectionReason"
|
|
376
|
+
],
|
|
377
|
+
"type": "ReaderConnectionReason"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"name": "detail",
|
|
381
|
+
"tags": [],
|
|
382
|
+
"docs": "Driver text: the port list, the command code, the OS error. This is the\none field allowed to talk about the wiring, because nothing branches on\nit — it is shown as-is for support, not translated.",
|
|
383
|
+
"complexTypes": [],
|
|
384
|
+
"type": "string | undefined"
|
|
385
|
+
}
|
|
386
|
+
]
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"name": "ReaderPort",
|
|
390
|
+
"slug": "readerport",
|
|
391
|
+
"docs": "One reader the driver could talk to.\n\n`path` is the identity — `COM3` on Windows, `/dev/cu.usbserial-110`\nelsewhere. Two identical CH340 adapters carry no serial number of their own,\nso the path is all that separates them.\n\nThe caller treats it as **opaque**: it compares, stores and hands it back,\nand never reads meaning out of it. A driver for a device that is not a\nserial port puts its own identity here.",
|
|
392
|
+
"tags": [],
|
|
393
|
+
"methods": [],
|
|
394
|
+
"properties": [
|
|
395
|
+
{
|
|
396
|
+
"name": "path",
|
|
397
|
+
"tags": [],
|
|
398
|
+
"docs": "",
|
|
399
|
+
"complexTypes": [],
|
|
400
|
+
"type": "string"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"name": "label",
|
|
404
|
+
"tags": [],
|
|
405
|
+
"docs": "What the OS calls the device. For the operator to read, not to match on.",
|
|
406
|
+
"complexTypes": [],
|
|
407
|
+
"type": "string | undefined"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"name": "vendorId",
|
|
411
|
+
"tags": [],
|
|
412
|
+
"docs": "",
|
|
413
|
+
"complexTypes": [],
|
|
414
|
+
"type": "string | undefined"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"name": "productId",
|
|
418
|
+
"tags": [],
|
|
419
|
+
"docs": "",
|
|
420
|
+
"complexTypes": [],
|
|
421
|
+
"type": "string | undefined"
|
|
422
|
+
}
|
|
423
|
+
]
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"name": "PluginListenerHandle",
|
|
427
|
+
"slug": "pluginlistenerhandle",
|
|
428
|
+
"docs": "",
|
|
429
|
+
"tags": [],
|
|
430
|
+
"methods": [],
|
|
431
|
+
"properties": [
|
|
432
|
+
{
|
|
433
|
+
"name": "remove",
|
|
434
|
+
"tags": [],
|
|
435
|
+
"docs": "",
|
|
436
|
+
"complexTypes": [],
|
|
437
|
+
"type": "() => Promise<void>"
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
],
|
|
218
442
|
"enums": [],
|
|
219
|
-
"typeAliases": [
|
|
443
|
+
"typeAliases": [
|
|
444
|
+
{
|
|
445
|
+
"name": "ReaderConnectionStatus",
|
|
446
|
+
"slug": "readerconnectionstatus",
|
|
447
|
+
"docs": "The four states an operator can act on.\n\n`isConnected()` is too coarse for this: a reader that is plugged in but\nsilent answers `false` the same way a missing one does, and the operator\nneeds a different move in each case. `isConnected()` stays as it is.",
|
|
448
|
+
"types": [
|
|
449
|
+
{
|
|
450
|
+
"text": "'connecting'",
|
|
451
|
+
"complexTypes": []
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"text": "'connected'",
|
|
455
|
+
"complexTypes": []
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
"text": "'not-found'",
|
|
459
|
+
"complexTypes": []
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"text": "'not-responding'",
|
|
463
|
+
"complexTypes": []
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"name": "ReaderConnectionReason",
|
|
469
|
+
"slug": "readerconnectionreason",
|
|
470
|
+
"docs": "Why the reader is unusable. The status alone does not say what to do next:\na busy reader needs another program closed, a missing one needs the\nconnection checked. The UI picks its message from the reason when there is\none.\n\nThese name what happened to the *reader*, never how it is wired. A driver\nfor a device with no serial port has to be able to answer in this\nvocabulary too, and the operator has to be told the truth either way —\nso nothing here says \"COM port\" or \"USB\". The device-specific sentence\nbelongs in `detail`.",
|
|
471
|
+
"types": [
|
|
472
|
+
{
|
|
473
|
+
"text": "'busy'",
|
|
474
|
+
"complexTypes": []
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"text": "'not-detected'",
|
|
478
|
+
"complexTypes": []
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
"text": "'disconnected'",
|
|
482
|
+
"complexTypes": []
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"text": "'no-answer'",
|
|
486
|
+
"complexTypes": []
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"text": "'not-chosen'",
|
|
490
|
+
"complexTypes": []
|
|
491
|
+
}
|
|
492
|
+
]
|
|
493
|
+
}
|
|
494
|
+
],
|
|
220
495
|
"pluginConfigs": []
|
|
221
496
|
}
|
|
@@ -1,5 +1,142 @@
|
|
|
1
|
-
import type { Plugin } from '@capacitor/core';
|
|
1
|
+
import type { Plugin, PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* What the connected Reader can do. Mode gating comes from here, not from the
|
|
4
|
+
* reader type — a desktop reader that can write must not be gated like one
|
|
5
|
+
* that cannot.
|
|
6
|
+
*/
|
|
7
|
+
export interface ReaderCapabilities {
|
|
8
|
+
/** Reader can write an EPC to a tag (Generate & Set mode depends on it). */
|
|
9
|
+
canWrite: boolean;
|
|
10
|
+
/** Reader reports RSSI (Find mode depends on it). */
|
|
11
|
+
hasRssi: boolean;
|
|
12
|
+
/** Reader is a handheld terminal rather than a desk device. */
|
|
13
|
+
isHandheld: boolean;
|
|
14
|
+
/** Output power range in dBm. The power slider renders this range. */
|
|
15
|
+
power: {
|
|
16
|
+
min: number;
|
|
17
|
+
max: number;
|
|
18
|
+
default: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The four states an operator can act on.
|
|
23
|
+
*
|
|
24
|
+
* `isConnected()` is too coarse for this: a reader that is plugged in but
|
|
25
|
+
* silent answers `false` the same way a missing one does, and the operator
|
|
26
|
+
* needs a different move in each case. `isConnected()` stays as it is.
|
|
27
|
+
*/
|
|
28
|
+
export declare type ReaderConnectionStatus =
|
|
29
|
+
/** An attempt is running. */
|
|
30
|
+
'connecting'
|
|
31
|
+
/** The reader is open and answering. */
|
|
32
|
+
| 'connected'
|
|
33
|
+
/** No reader to talk to — nothing found, or found but not openable. */
|
|
34
|
+
| 'not-found'
|
|
35
|
+
/** The port opened but the reader did not answer a command. */
|
|
36
|
+
| 'not-responding';
|
|
37
|
+
/**
|
|
38
|
+
* Why the reader is unusable. The status alone does not say what to do next:
|
|
39
|
+
* a busy reader needs another program closed, a missing one needs the
|
|
40
|
+
* connection checked. The UI picks its message from the reason when there is
|
|
41
|
+
* one.
|
|
42
|
+
*
|
|
43
|
+
* These name what happened to the *reader*, never how it is wired. A driver
|
|
44
|
+
* for a device with no serial port has to be able to answer in this
|
|
45
|
+
* vocabulary too, and the operator has to be told the truth either way —
|
|
46
|
+
* so nothing here says "COM port" or "USB". The device-specific sentence
|
|
47
|
+
* belongs in `detail`.
|
|
48
|
+
*/
|
|
49
|
+
export declare type ReaderConnectionReason =
|
|
50
|
+
/** Another program holds the reader. Only one may have it at a time. */
|
|
51
|
+
'busy'
|
|
52
|
+
/** No reader in sight — nothing connected, or nothing that is a reader. */
|
|
53
|
+
| 'not-detected'
|
|
54
|
+
/** The reader was there and then went away. */
|
|
55
|
+
| 'disconnected'
|
|
56
|
+
/** The reader is reachable but did not answer. */
|
|
57
|
+
| 'no-answer'
|
|
58
|
+
/**
|
|
59
|
+
* Several readers are connected and none was picked. Guessing here would
|
|
60
|
+
* attach tags read by the wrong device, so nothing is opened until
|
|
61
|
+
* `selectReaderPort` says which one.
|
|
62
|
+
*/
|
|
63
|
+
| 'not-chosen';
|
|
64
|
+
export interface ReaderConnectionState {
|
|
65
|
+
status: ReaderConnectionStatus;
|
|
66
|
+
reason?: ReaderConnectionReason;
|
|
67
|
+
/**
|
|
68
|
+
* Driver text: the port list, the command code, the OS error. This is the
|
|
69
|
+
* one field allowed to talk about the wiring, because nothing branches on
|
|
70
|
+
* it — it is shown as-is for support, not translated.
|
|
71
|
+
*/
|
|
72
|
+
detail?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* One reader the driver could talk to.
|
|
76
|
+
*
|
|
77
|
+
* `path` is the identity — `COM3` on Windows, `/dev/cu.usbserial-110`
|
|
78
|
+
* elsewhere. Two identical CH340 adapters carry no serial number of their own,
|
|
79
|
+
* so the path is all that separates them.
|
|
80
|
+
*
|
|
81
|
+
* The caller treats it as **opaque**: it compares, stores and hands it back,
|
|
82
|
+
* and never reads meaning out of it. A driver for a device that is not a
|
|
83
|
+
* serial port puts its own identity here.
|
|
84
|
+
*/
|
|
85
|
+
export interface ReaderPort {
|
|
86
|
+
path: string;
|
|
87
|
+
/** What the OS calls the device. For the operator to read, not to match on. */
|
|
88
|
+
label?: string;
|
|
89
|
+
vendorId?: string;
|
|
90
|
+
productId?: string;
|
|
91
|
+
}
|
|
2
92
|
export interface RFIDPlugin extends Plugin {
|
|
93
|
+
/**
|
|
94
|
+
* Capabilities of the connected Reader.
|
|
95
|
+
*
|
|
96
|
+
* Implementations that predate this method reject. That is a signal, not a
|
|
97
|
+
* failure: the caller treats a rejection as a handheld Mobile Reader.
|
|
98
|
+
*/
|
|
99
|
+
getCapabilities(): Promise<ReaderCapabilities>;
|
|
100
|
+
/**
|
|
101
|
+
* Connection state for the first render. The stream of later changes comes
|
|
102
|
+
* from the `onConnectionState` listener — "not responding" is only found out
|
|
103
|
+
* after a timeout, so it cannot be a return value.
|
|
104
|
+
*
|
|
105
|
+
* A reader is an exclusive resource, so its state is only knowable while it
|
|
106
|
+
* is held: an implementation that is not connected may start an attempt here
|
|
107
|
+
* and answer `connecting`, with the outcome arriving on the listener.
|
|
108
|
+
*
|
|
109
|
+
* Implementations that predate this method reject. The caller then hides the
|
|
110
|
+
* indicator instead of guessing.
|
|
111
|
+
*/
|
|
112
|
+
getConnectionState(): Promise<ReaderConnectionState>;
|
|
113
|
+
/**
|
|
114
|
+
* The readers plugged in right now, newest listing every call — a port that
|
|
115
|
+
* was there a minute ago may be gone.
|
|
116
|
+
*
|
|
117
|
+
* Only readers, not every serial port: what the caller does with this list
|
|
118
|
+
* is offer it as a choice, and a Bluetooth port is not a choice.
|
|
119
|
+
*
|
|
120
|
+
* Implementations that predate this method reject. The caller then keeps
|
|
121
|
+
* whatever the driver picks on its own.
|
|
122
|
+
*/
|
|
123
|
+
listReaderPorts(): Promise<{
|
|
124
|
+
ports: ReaderPort[];
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Use this reader from now on. Reconnects when another port is open.
|
|
128
|
+
*
|
|
129
|
+
* The choice itself is not stored here: the driver is restarted with the
|
|
130
|
+
* app, and where a choice belongs is the caller's question. The caller
|
|
131
|
+
* remembers the path and says it again on the next start.
|
|
132
|
+
*
|
|
133
|
+
* Rejects when the path is not in the current `listReaderPorts()` — a
|
|
134
|
+
* remembered reader that was unplugged has to be chosen again, not opened
|
|
135
|
+
* blindly.
|
|
136
|
+
*/
|
|
137
|
+
selectReaderPort(options: {
|
|
138
|
+
path: string;
|
|
139
|
+
}): Promise<void>;
|
|
3
140
|
isConnected(): Promise<{
|
|
4
141
|
connected: boolean;
|
|
5
142
|
}>;
|
|
@@ -54,4 +191,7 @@ export interface RFIDPlugin extends Plugin {
|
|
|
54
191
|
playSound: boolean;
|
|
55
192
|
}): Promise<void>;
|
|
56
193
|
stopSearch(): Promise<void>;
|
|
194
|
+
/** Every connection state change. Fires only on a change, not on a poll. */
|
|
195
|
+
addListener(eventName: 'onConnectionState', listener: (state: ReaderConnectionState) => void): Promise<PluginListenerHandle>;
|
|
196
|
+
addListener(eventName: string, listenerFunc: (...args: any[]) => any): Promise<PluginListenerHandle>;
|
|
57
197
|
}
|