1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 11:35:48 +01:00

Live Activity: don't enable notifications every second

This caused the BLE queue to fill up more and more.
This commit is contained in:
cpfeiffer 2018-09-17 23:01:01 +02:00
parent d3fd203c6c
commit 6d4d92fd88

View File

@ -179,6 +179,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
private boolean isMusicAppStarted = false;
private MusicSpec bufferMusicSpec = null;
private MusicStateSpec bufferMusicStateSpec = null;
private boolean heartRateNotifyEnabled;
public HuamiSupport() {
this(LOG);
@ -207,6 +208,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
@Override
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
try {
heartRateNotifyEnabled = false;
boolean authenticate = needsAuth;
needsAuth = false;
byte authFlags = HuamiService.AUTH_BYTE;
@ -871,9 +873,12 @@ public class HuamiSupport 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 (heartRateNotifyEnabled != enable) {
BluetoothGattCharacteristic heartrateCharacteristic = getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT);
if (heartrateCharacteristic != null) {
builder.notify(heartrateCharacteristic, enable);
heartRateNotifyEnabled = enable;
}
}
if (enable) {
builder.write(characteristicHRControlPoint, stopHeartMeasurementManual);