Bluetooth-Library icon indicating copy to clipboard operation
Bluetooth-Library copied to clipboard

startDiscovery impossible

Open openmotion opened this issue 3 years ago • 7 comments

Hello

i try to use your library with a simple code bluetooth = new Bluetooth(this);

    bluetooth.setBluetoothCallback(bluetoothCallback);
    bluetooth.setDiscoveryCallback(discoveryCallback);

    if(bluetooth != null) {
        try {
            bluetooth.startScanning();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

but i have this error

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothAdapter.startDiscovery()' on a null object reference

openmotion avatar Aug 20 '20 15:08 openmotion

It's because you haven't called bluetooth.onStart(). Take a look at the README.

omaraflak avatar Aug 20 '20 16:08 omaraflak

hello it's ok but now i have this error when i try to connect : Could not connect, next try in 3 sec... : read failed, socket might closed or timeout, read ret: -1 i have the same error in your demo app :p

openmotion avatar Aug 20 '20 16:08 openmotion

Is the device you are trying to connect to a BLE device ?

omaraflak avatar Aug 20 '20 17:08 omaraflak

Is the device you are trying to connect to a BLE device ?

Yes it's possible I can connect to the device with the default tchat app from Google. I am searching for a library able to manage jpg file transfer

openmotion avatar Aug 20 '20 18:08 openmotion

Is the device you are trying to connect to a BLE device ?

Yes it's possible I can connect to the device with the default tchat app from Google. I am searching for a library able to manage jpg file transfer

The device must be BLE compatible yes but i don't want to connect it in BLE

openmotion avatar Aug 21 '20 05:08 openmotion

The library does not support BLE. Of you run the app in the repo does it connect without problem ? Socket timeout might happen few times before connecting successfully..

omaraflak avatar Aug 21 '20 05:08 omaraflak

The library does not support BLE. Of you run the app in the repo does it connect without problem ? Socket timeout might happen few times before connecting successfully..

the app in the repo does not connect :p

openmotion avatar Aug 21 '20 06:08 openmotion