omaraflak / Bluetooth-Library

Bluetooth client library for Android.
198 stars 62 forks source link

connection error #39

Open sontqq opened 5 years ago

sontqq commented 5 years ago

Everytime I try to connect to a device i get:

error_read failed, socket might closed or timeout, read ret: -1

Any idea?

omaraflak commented 5 years ago

What kind of the device are you trying to connect to ?

Take a look at this README section : https://github.com/OmarAflak/Bluetooth-Library/blob/master/README.md#connect-to-device-using-port-trick

sontqq commented 5 years ago

I'm trying to connect from an Android 9.0 Samsung device to a Windows 10 PC with a bluetooth dongle.

I have also tried to connect with the port tricking but no success.

sontqq commented 5 years ago

I get this error:

W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothSocket android.bluetooth.BluetoothDevice.createRfcommSocketToServiceRecord(java.util.UUID)' on a null object reference
        at me.aflak.bluetooth.Bluetooth.connect(Bluetooth.java:462)
W/System.err:     at me.aflak.bluetooth.Bluetooth.connectToDevice(Bluetooth.java:271)
        at me.aflak.bluetooth.Bluetooth.connectToDevice(Bluetooth.java:279)
W/System.err:     at com.sontme.esp.getlocation.activities.MainActivity$3$2.onDiscoveryFinished(MainActivity.java:363)
        at me.aflak.bluetooth.Bluetooth$7$3.run(Bluetooth.java:597)
        at me.aflak.bluetooth.utils.ThreadHelper.run(ThreadHelper.java:15)
W/System.err:     at me.aflak.bluetooth.Bluetooth$7.onReceive(Bluetooth.java:594)
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1486)
        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:873)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7073)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
jpeiter commented 4 years ago

I'm having the same error, using either connectToDevice and connectToDeviceWithPortTrick, but fails every time. I downloaded the Bluetooth Terminal app and it logs the same error on the screen. I tried to connect from a Pixel 3 (Android 10) to a Galaxy J5 Pro (Android 9).

glebkravchenko commented 4 years ago

yep, same for me, trying to connect to medical device, but it is saying same, error_read failed, socket might closed or timeout, read ret: -1

omaraflak commented 4 years ago

Please make sure you are using a regular Bluetooth dongle, not BLE. BLE is not supported.

charlieporth1 commented 2 years ago

I'm getting this msg too. Is there any solution? Is there any way to disable BLE @OmarAflak?

ibrahim-iqbal commented 2 years ago

This issue is still persistent, is there a workaround for this, none of the other libraries are also able to tackle this.

skillhubz commented 1 year ago

Everytime I try to connect to a device i get:

error_read failed, socket might closed or timeout, read ret: -1

Any idea?

no

skillhubz commented 1 year ago

Please make sure you are using a regular Bluetooth dongle, not BLE. BLE is not supported.

gotcha