From 55f036c104a37d4a1ad8bc7db27e1c392181c848 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Fri, 4 Nov 2016 22:11:07 +0100 Subject: [PATCH] Move heart rate notification enamblement to after authentication Might fix #408 and #425 --- .../service/devices/miband/MiBand2Support.java | 11 +++++------ .../devices/miband2/operations/InitOperation.java | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java index 937780ca..dae5952a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java @@ -233,15 +233,14 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport { builder.notify(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_AUTH), enable); builder.notify(getCharacteristic(MiBand2Service.UUID_UNKNOWN_CHARACTERISTIC3), enable); builder.notify(getCharacteristic(MiBand2Service.UUID_UNKNOWN_CHARACTERISTIC4), enable); - builder.notify(getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT), enable); return this; } - private MiBand2Support enableFurtherNotifications(TransactionBuilder builder, boolean enable) { - builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS), enable) - .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_ACTIVITY_DATA), enable) - .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_BATTERY), enable) - .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_SENSOR_DATA), enable); + public MiBand2Support enableFurtherNotifications(TransactionBuilder builder, boolean enable) { +// builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS), enable) +// .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_ACTIVITY_DATA), enable) +// .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_BATTERY), enable) +// .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_SENSOR_DATA), enable); // cannot use supportsHeartrate() here because we don't have that information yet BluetoothGattCharacteristic heartrateCharacteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT); if (heartrateCharacteristic != null) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/operations/InitOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/operations/InitOperation.java index 7e8335db..ab5f73e9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/operations/InitOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/operations/InitOperation.java @@ -101,6 +101,7 @@ public class InitOperation extends AbstractBTLEOperation { TransactionBuilder builder = createTransactionBuilder("Sending the encrypted random key to the band"); builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext())); getSupport().requestDeviceInfo(builder); + getSupport().enableFurtherNotifications(builder, true); getSupport().setInitialized(builder); getSupport().performImmediately(builder); } else {