diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/AbstractBleProfile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/AbstractBleProfile.java index 1580cd4cf..346586cf2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/AbstractBleProfile.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/AbstractBleProfile.java @@ -108,4 +108,7 @@ public abstract class AbstractBleProfile ex return mSupport.getQueue(); } + public void enableNotify(TransactionBuilder builder, boolean enable) { + } + } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java index dfda3ca1a..eef85c6ba 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java @@ -53,8 +53,9 @@ public class BatteryInfoProfile extends Abs builder.read(getCharacteristic(UUID_CHARACTERISTIC_BATTERY_LEVEL)); } - public void enableNotifiy() { - // TODO: notification + @Override + public void enableNotify(TransactionBuilder builder, boolean enable) { + builder.notify(getCharacteristic(BatteryInfoProfile.UUID_CHARACTERISTIC_BATTERY_LEVEL), enable); } @Override @@ -73,6 +74,11 @@ public class BatteryInfoProfile extends Abs return false; } + @Override + public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { + return onCharacteristicRead(gatt, characteristic, BluetoothGatt.GATT_SUCCESS); + } + private void handleBatteryLevel(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { int percent = ValueDecoder.decodePercent(characteristic); batteryInfo.setPercentCharged(percent); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java index 622e21c4b..136e286c1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java @@ -453,6 +453,7 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL } setInitialized(builder); batteryInfoProfile.requestBatteryInfo(builder); + batteryInfoProfile.enableNotify(builder,true); return builder; }