rusel1989 / react-native-bluetooth-serial

Port of https://github.com/don/BluetoothSerial for react native
475 stars 291 forks source link

connect() causes FATAL exception #127

Open qiray opened 3 years ago

qiray commented 3 years ago

When I call BluetoothSerial.connect inside setInterval() my app crashes.

E/AndroidRuntime: FATAL EXCEPTION: ConnectThread
    java.lang.NullPointerException: Attempt to invoke interface method 'void com.facebook.react.bridge.Callback.invoke(java.lang.Object[])' on a null object reference
        at com.facebook.react.bridge.PromiseImpl.reject(PromiseImpl.java:231)
        at com.facebook.react.bridge.PromiseImpl.reject(PromiseImpl.java:104)
        at com.rusel.RCTBluetoothSerial.RCTBluetoothSerialModule.onConnectionFailed(RCTBluetoothSerialModule.java:449)
        at com.rusel.RCTBluetoothSerial.RCTBluetoothSerialService.connectionFailed(RCTBluetoothSerialService.java:157)
        at com.rusel.RCTBluetoothSerial.RCTBluetoothSerialService.access$300(RCTBluetoothSerialService.java:23)
        at com.rusel.RCTBluetoothSerial.RCTBluetoothSerialService$ConnectThread.run(RCTBluetoothSerialService.java:245)