https://github.com/mapaiva/react-native-usbserial
A USB serial React Native bridge
https://github.com/mapaiva/react-native-usbserial
react react-module usbserial
Last synced: 11 months ago
JSON representation
A USB serial React Native bridge
- Host: GitHub
- URL: https://github.com/mapaiva/react-native-usbserial
- Owner: mapaiva
- License: mit
- Created: 2016-09-04T17:07:58.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-23T20:44:35.000Z (almost 9 years ago)
- Last Synced: 2025-06-13T18:48:46.476Z (about 1 year ago)
- Topics: react, react-module, usbserial
- Language: Java
- Homepage:
- Size: 23.4 KB
- Stars: 58
- Watchers: 7
- Forks: 35
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-usbserial
This wrapper implementation is totally based on [usb-serial-for-android](https://github.com/mik3y/usb-serial-for-android). Thanks [mik3y](https://github.com/mik3y) for the awesome project.
## Installation
```
npm install react-native-usbserial --save
```
## Integrate module
To integrate `react-native-usbserial` with the rest of your react app just execute:
```
react-native link react-native-usbserial
```
### Android
To integrate it with your android application you also need to add these following lines on your `android/app/build.gradle`:
```gradle
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
```
## Usage
```javascript
import { UsbSerial} from 'react-native-usbserial';
const usbs = new UsbSerial();
async function getDeviceAsync() {
try {
const deviceList = await usbs.getDeviceListAsync();
const firstDevice = deviceList[0];
console.log(firstDevice);
if (firstDevice) {
const usbSerialDevice = await usbs.openDeviceAsync(firstDevice);
console.log(usbSerialDevice);
}
} catch (err) {
console.warn(err);
}
}
getDeviceAsync();
```