react-native-serialport icon indicating copy to clipboard operation
react-native-serialport copied to clipboard

Can not connect to attached device

Open sharqawiDev opened this issue 4 years ago • 1 comments

I'm using the manual connection example, and I've Arduino Uno attached to my mobile (Galaxy S8+), but I can not connect to the attached device!

photo_2020-11-18_01-46-48

React Native version: 0.63.3

Arduino Code:

image

Please help me

sharqawiDev avatar Nov 17 '20 22:11 sharqawiDev

I had make some modifications to get the library to work in my project, I only need to connect to the first device that is already connected so I use my fork and I hard-code the connection like so:

fillDeviceList() {
  RNSerialport.getDeviceList().then((response => {
    if (response[0].status) {
      this.setState({ deviceList: response, selectedDevice: response[0]}, ()=>{
        this.connectDevice().then(()=>{console.log("CONNECTED");});
      });
    }
  }));
}

See this commit for the modification that I make to the library, I only had to change one line within the library itself. https://github.com/sessionm21/react-native-serialport/commit/baf59359d73aa2daabf5e6871b103f9d129ad985

You can also install directly from git

npm i git+https://github.com/sessionm21/react-native-serialport.git

sessions-matthew avatar Dec 13 '20 07:12 sessions-matthew