omaraflak / Bluetooth-Library

Bluetooth client library for Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

startDiscovery impossible

openmotion opened this issue · 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

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

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

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

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

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

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 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