react-native-serial-ports

1.3.4 • Public • Published

react-native-serial-port

Only for android platform based on Android-SerialPort-API.

It is available in AndroidX

Getting started

$ npm install react-native-serial-port --save

Mostly automatic installation

$ npx react-native link react-native-serial-port

Usage

import SerialPortAPI from 'react-native-serial-port';

async function example() {
  const serialPort = await SerialPortAPI.open("/dev/ttyS4", { baudRate: 38400 });

  // subscribe received data
  const sub = serialPort.onReceived(buff => {
    console.log(buff.toString('hex').toUpperCase());
  })

  // unsubscribe
  // sub.remove();

  // send data with hex format
  await serialPort.send('00FF');

  // close
  serialPort.close();
}

Package Sidebar

Install

npm i react-native-serial-ports

Weekly Downloads

93

Version

1.3.4

License

MIT

Unpacked Size

25 kB

Total Files

13

Last publish

Collaborators

  • xiezaishubenshang