From 75b9fe4c4d2c53e0b40c8b01b15c786e3b6c0ea9 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 24 May 2015 23:12:54 +0200 Subject: [PATCH] ignore connection state changes with status != GATT_SUCCESS And add logging. Maybe this helps with #57 --- .../freeyourgadget/gadgetbridge/btle/BtLEQueue.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/btle/BtLEQueue.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/btle/BtLEQueue.java index eba0cbf9..703346e8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/btle/BtLEQueue.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/btle/BtLEQueue.java @@ -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.");