# react-native-rfid-connector

> This is a library for connect rfid using native module in React Native app

Latest version **2.0.2** (published 2020-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-rfid-connector
pnpm add react-native-rfid-connector
yarn add react-native-rfid-connector
bun add react-native-rfid-connector
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2020-04-24 |
| First published | 2020-02-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | KienLV |
| Maintainers | kienlv58 |
| Keywords | react-native |

## Links

- npm: https://www.npmjs.com/package/react-native-rfid-connector
- Repository: https://gitlab.nal.vn/kienlv/react-native-rfid-connector
- npm.io page: https://npm.io/package/react-native-rfid-connector

## Recent versions

- 2.0.2 (latest) — 2020-04-24
- 2.0.1 — 2020-04-24
- 2.0.0 — 2020-04-24
- 1.0.9 — 2020-04-24
- 1.0.8 — 2020-04-24
- 1.0.7 — 2020-04-23
- 1.0.6 — 2020-03-21
- 1.0.5 — 2020-03-13
- 1.0.4 — 2020-03-10
- 1.0.3 — 2020-03-04
- 1.0.2 — 2020-02-27
- 1.0.1 — 2020-02-27
- 1.0.0 — 2020-02-26

## README

# React-native-rfid-connector

This library helps us listen to the state of Bluetooth and connect it with an RFID reader device. Get data from RFID TAG

## Getting started

`$ npm install react-native-rfid-connector --save`
or
`$ yarn add react-native-rfid-connector`

### Mostly automatic installation

If using react-native  < 0.60
`$ react-native link react-native-rfid-connector`

## Usage
```javascript
import RfidConnector from 'react-native-rfid-connector';

componentDidMount() {
    RfidConnector.getCurrentState().then(this.handleConnection)
  }

  componentWillMount() {
    RfidConnector.addEventListener('change', this.handleConnection);
  }

  componentWillUnmount() {
    RfidConnector.removeEventListener('change', this.handleConnection)
  }

  handleConnection = (resp) => {
    const {type} = resp;
    switch(type){
      case 'BLT_STATE_CHANGE':
        //resp: { type:BLT_STATE_CHANGE, status:"on"}
        this.setState({connectionState:resp.status});

        break;

        case 'BLT_DISCOVERY_STARTED':
          //resp: { type:"BLT_DISCOVERY_STARTED"}
          break;
        case 'BLT_DISCOVERY_DEVICE':
          //resp: { type:"BLT_DISCOVERY_DEVICE", device_info: {device_address: "6C:40:08:AA:F2:0B", device_name: "Hangnta"}}
          const newList = [...this.state.listDevice,resp.device_info];
          this.setState({listDevice:newList})
        break;

      case 'BLT_DISCOVERY_DEVICE_FINISH':
        //resp: { type:"BLT_DISCOVERY_DEVICE_FINISH"}
        break;
        case 'DOTR_EVENT':
        //resp: { type:"DOTR_EVENT",status:"",data: any}
          break;
    }
```


### Start Scan bluetooth devices:
```javascript
RfidConnector.startScanBlueTooth().then(rsp=>{
            console.log("scan rsp",rsp);
          }).catch(err=>console.log("err",err));
```

### Stop Scan bluetooth devices:
```javascript
RfidConnector.stopScanBlueTooth().then(rsp=>{
            console.log("stop scan",rsp);
          }).catch(err=>console.log("err",err));
```

### Filter bluetooth devices with prefix name:
```javascript
RfidConnector.setListFilterBlueToothPrefix(["HQ_UHF_READER","TSS91JJ-","DOTR2100-","DOTR2200-","TSS2100","TSS2200","DOTR3100","DOTR3200","TSS3100","TSS3200"]);
```

### Connect to specific devices address to read tag:
```javascript
RfidConnector.connectToDevice("device address");
```
### Disconnect to current device:
```javascript
RfidConnector.disConnectToDevice().then(msg=>console.log(msg)).catch(err=>console.log(err));
```

## List status of ```DOTR_EVENT```:
- onConnected
- onDisconnected
- onLinkLost
- onTriggerChaned
- onInventoryEPC
- onReadTagData
- onWriteTagData
- onUploadTagData
- onTagMemoryLocked
- onScanCode
- onScanTriggerChanged

In this document we will focus on  ```onReadTagData ```. This status will receive when we found any RFIDTAG.Structure response form event listener like this:
```javascript
{
type:"DOTR_EVENT",
status:"onReadTagData",
data:{
    tagData:"000",
    epc:"100001"
    }
}
```

---
_Source: https://npm.io/package/react-native-rfid-connector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
