ignore connection state changes with status != GATT_SUCCESS

And add logging. Maybe this helps with #57
live-sensor-data
cpfeiffer 2015-05-24 23:12:54 +02:00
parent 228e922ce7
commit 75b9fe4c4d
1 changed files with 7 additions and 0 deletions

View File

@ -237,10 +237,17 @@ public final class BtLEQueue {
private final BluetoothGattCallback internalGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
LOG.debug("connection state change: status: " + status + ", newState: " + newState);
if (!checkCorrectGattInstance(gatt, "connection state event")) {
return;
}
if (status != BluetoothGatt.GATT_SUCCESS) {
LOG.warn("ignoring connection state event with status " + status);
return;
}
switch (newState) {
case BluetoothProfile.STATE_CONNECTED:
LOG.info("Connected to GATT server.");