1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-06 05:16:41 +02:00

Mi Band 2/Bip/Cor: Only enable notification on realtime hr characteristic when live activity is used

This commit is contained in:
Andreas Shimokawa 2017-11-11 23:36:38 +01:00
parent 2f443ad419
commit 82ad7abf62

View File

@ -271,10 +271,6 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
builder.notify(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION), enable);
builder.notify(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_6_BATTERY_INFO), enable);
builder.notify(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_DEVICEEVENT), enable);
BluetoothGattCharacteristic heartrateCharacteristic = getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT);
if (heartrateCharacteristic != null) {
builder.notify(heartrateCharacteristic, enable);
}
return this;
}
@ -752,11 +748,15 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
}
try {
TransactionBuilder builder = performInitialized("Enable realtime heart rate measurement");
BluetoothGattCharacteristic heartrateCharacteristic = getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT);
if (heartrateCharacteristic != null) {
builder.notify(heartrateCharacteristic, enable);
}
if (enable) {
builder.write(characteristicHRControlPoint, stopHeartMeasurementManual);
builder.write(characteristicHRControlPoint, startHeartMeasurementContinuous);
} else {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementContinuous);
builder.write(characteristicHRControlPoint, stopHeartMeasurementContinuous);
}
builder.queue(getQueue());
enableRealtimeSamplesTimer(enable);