I am working on implementing an Android app that connects to BLE devices but the lack of proper documentation is killing me. Nothing seems to be working the same way twice if I run the app once it might work but the next time stops somewhere(no idea where) but I kinda came to a conclusion that I might have not been using disconnect()
and close()
in the right order.
After let's say an error I call disconnect() first:
public void disconnect() {
mScanning = true;
mConnected = false;
startedConnect = false;
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
scanLeDevice(true);
return;
}
mBluetoothGatt.disconnect();
scanLeDevice(true);
}
then I call close():
public void close() {
if (mBluetoothGatt == null) {
return;
}
mBluetoothGatt.close();
mBluetoothGatt = null;
}
Is this the correct way of doing it or wrong? Please be aware that I am calling scanLeDevice(true);
right after disconnecting but then close()
is called which I think is just "finishing" everything and stops the scanning right?