0.5.0 • Published 3 months ago

react-native-usb-serialport-for-android v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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

0.5.0

3 months ago

0.5.1

3 months ago

0.4.1

1 year ago

0.3.0

2 years ago

0.2.0

2 years ago

0.4.0

2 years ago

0.1.0

2 years ago