This wrapper implementation is totally based on usb-serial-for-android. Thanks mik3y for the awesome project.
npm install react-native-usbserial --save
To integrate react-native-usbserial with the rest of your react app just execute:
react-native link react-native-usbserial
To integrate it with your android application you also need to add these following lines on your android/app/build.gradle:
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}import{UsbSerial}from'react-native-usbserial';constusbs=newUsbSerial();asyncfunctiongetDeviceAsync(){try{constdeviceList=awaitusbs.getDeviceListAsync();constfirstDevice=deviceList[0];console.log(firstDevice);if(firstDevice){constusbSerialDevice=awaitusbs.openDeviceAsync(firstDevice);console.log(usbSerialDevice);}}catch(err){console.warn(err);}}getDeviceAsync();