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
1 changed files with 8 additions and 3 deletions

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);