Android Bluetooth LE: Not discovering services after connection
android, android-bluetooth, bluetooth, bluetooth-lowenergy
Solution
I seem to have found the solution: you need to call both `BluetoothGatt.disconnect()` AND `BluetoothGatt.close()`.
Problem
I'm trying to use Android's Bluetooth Low Energy to communicate with a BLE device. The first time I connect, everything works fine (connecting to GATT server works, all services and characteristics are discovered, etc.) But, if I disconnect and try to re-connect, it will connect to the GATT server, but will not be able to discover the services. I have to kill the app and restart it, and sometimes even that doesn't work. This is the code I'm using to disconnect from the device: ``` public void close(View view) { if (mBluetoothGatt == null) { return; } mBluetoothGatt.close(); mBluetoothGatt = null; } ``` Is there anything else that I need to do when disconnecting? There seems to be some resource that is still connected that prevents discovery of services when I try and reconnect.