Skip to content

eleroy/react-native-usb-serialport-for-android

 
 

Repository files navigation

react-native-usb-serialport-for-android

React Native USB serialport module for Android platform based on mik3y/usb-serial-for-android

Installation

npm install react-native-usb-serialport-for-android --save

Usage

import { UsbSerialManager, Parity, Codes } from "react-native-usb-serialport-for-android";

// ...
const devices = await UsbSerialManager.list();

try {
  await UsbSerialManager.tryRequestPermission(2004);
  const usbSerialport = await UsbSerialManager.open(2004, { baudRate: 38400, parity: Parity.None, dataBits: 8, stopBits: 1 });

  const sub = usbSerialport.onReceived((event) => {
    console.log(event.deviceId, event.data);
  });
  // unsubscribe
  // sub.remove();

  await usbSerialport.send('00FF');
  
  usbSerialport.close();
} catch(err) {
  console.log(err);
  if (err.code === Codes.DEVICE_NOT_FOND) {
    // ...
  }
}

See documentation for details.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 60.4%
  • TypeScript 23.2%
  • Objective-C 9.3%
  • JavaScript 4.3%
  • Ruby 1.9%
  • Shell 0.4%
  • Other 0.5%