-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.ts
60 lines (40 loc) · 1.51 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { NativeEventEmitter, NativeModules } from "react-native";
const { C72RfidScanner } = NativeModules;
const eventEmitter = new NativeEventEmitter(C72RfidScanner);
type initializeReader = () => void;
type deInitializeReader = () => void;
type readSingleTag = () => Promise<any>;
type readPower = () => Promise<any>;
type changePower = (powerValue: any) => Promise<any>;
type AddListener = (cb: (args: any[]) => void) => void;
type clearTags = () => void;
const initializeReader: initializeReader = () =>
C72RfidScanner.initializeReader();
const deInitializeReader: deInitializeReader = () =>
C72RfidScanner.deInitializeReader();
const readSingleTag: readSingleTag = () =>
C72RfidScanner.readSingleTag();
const startReadingTags = (callback: (args: any[]) => any) =>
C72RfidScanner.startReadingTags(callback);
const stopReadingTags = (callback: (args: any[]) => any) =>
C72RfidScanner.stopReadingTags(callback);
const readPower = () => C72RfidScanner.readPower();
const changePower: changePower = (powerValue: any) =>
C72RfidScanner.changePower(powerValue);
const powerListener: AddListener = (listener) =>
eventEmitter.addListener("UHF_POWER", listener);
const tagListener: AddListener = (listener) =>
eventEmitter.addListener("UHF_TAG", listener);
const clearTags: clearTags = () => C72RfidScanner.clearAllTags();
export default {
powerListener,
tagListener,
initializeReader,
readSingleTag,
startReadingTags,
stopReadingTags,
readPower,
changePower,
deInitializeReader,
clearTags
};