douglasjunior / react-native-easybluetooth-classic

⚛ A Library for easy implementation of Serial Bluetooth Classic on React Native (Android Only).
https://www.npmjs.com/package/easy-bluetooth-classic
MIT License
43 stars 7 forks source link

Error When Writing: bt socket closed, read return: -1 #27

Open jamesnogra opened 5 years ago

jamesnogra commented 5 years ago

I am getting this error when I writeLn to a connected device.

EasyBluetooth.writeln("Test 123")
        .then(() => {
          console.log("Writing " + "Test 123")
        })
        .catch((ex) => {
          console.warn(ex);
        })

In the log, it says I am connected, I just see this error when writing string using the EasyBluetooth.writeln method.

2018-12-26 22:18:10.635 23150-23266/com.bluetoothtest E/BluetoothClassicService: disconnected
   java.io.IOException: bt socket closed, read return: -1
       at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:740)
       at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:60)
       at com.github.douglasjunior.bluetoothclassiclibrary.BluetoothClassicService$ConnectedThread.run(BluetoothClassicService.java:326)