I want to track connection with BLE device even when phone goes sleep - there's a callback to track connect/disconnect BluetoothGattCallback.
So going along the tutorial from above there's a Service
public class BluetoothLeService extends Service {
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
//...
}
//...
}
//...
}
To connect I call
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
As you can see I do not acquire the wake lock anywhere.
- So what happens with the callback if device goes sleep?
- Will it be called? Or I need to explicitly acquire the wake lock.
- Or maybe the BluetoothDevice takes care about waking the device up when callback will be called? (however I see that it's not documented anywhere)