From b765b775cb9b2fc45a25cfbae15abfc61745d267 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sat, 6 Oct 2018 19:51:28 +0200 Subject: [PATCH] Disconnect from scale if no GATT services are found May fix exception seen in #330 --- .../openscale/core/bluetooth/BluetoothCommunication.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java index f992f6c7..7641792e 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java @@ -667,6 +667,12 @@ public abstract class BluetoothCommunication { Timber.d("onServicesDiscovered: status=%d (%d services)", status, gatt.getServices().size()); + if (gatt.getServices().isEmpty()) { + setBtStatus(BT_STATUS_CODE.BT_UNEXPECTED_ERROR, "No services found"); + disconnect(false); + return; + } + synchronized (lock) { cmdStepNr = 0; initStepNr = 0;