mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-28 02:27:32 +01:00
InfiniTime: support notification for battery level
This commit is contained in:
parent
c5aaaec7e3
commit
603050b7cc
@ -108,4 +108,7 @@ public abstract class AbstractBleProfile<T extends AbstractBTLEDeviceSupport> ex
|
||||
return mSupport.getQueue();
|
||||
}
|
||||
|
||||
public void enableNotify(TransactionBuilder builder, boolean enable) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,8 +53,9 @@ public class BatteryInfoProfile<T extends AbstractBTLEDeviceSupport> 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<T extends AbstractBTLEDeviceSupport> 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);
|
||||
|
@ -453,6 +453,7 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
||||
}
|
||||
setInitialized(builder);
|
||||
batteryInfoProfile.requestBatteryInfo(builder);
|
||||
batteryInfoProfile.enableNotify(builder,true);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user