My app talks to a BLE peripheral. Sometimes the app is started with that peripheral already connected. I can retrieve the device by calling:
BluetoothManager manager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
List<BluetoothDevice> connectedDevices = manager.getConnectedDevices(BluetoothProfile.GATT);
I can then filter connectedDevices based on address or UUID. However, BluetoothDevice has no disconnect method. To disconnect, I need a BluetoothGATT instance. But the only way I can see to get a BluetoothGATT instance is to call
connectedDevice.connectGatt(Context, boolean, BluetoothGattCallback)
Which takes a very long time. On top of this, the BluetoothGatt instance I get back after calling connectGatt doesn't seem to actually disconnect the peripheral when I call disconnect().
So my questions are:
- Is there a way to disconnect a connected BluetoothDevice without calling connectGatt?
- Why does connectGatt take so long for a device that's already connected?
- Is it even valid to call connectGatt on a connected BluetoothDevice?
Thank you