1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-17 02:44:04 +02:00

Better check for heartrate support on non-heartrate devices

This commit is contained in:
cpfeiffer 2016-03-07 21:36:31 +01:00
parent f1ba50b62a
commit 50dd7f5eba

View File

@ -137,12 +137,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_ACTIVITY_DATA), enable) .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_ACTIVITY_DATA), enable)
.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_BATTERY), enable) .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_BATTERY), enable)
.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_SENSOR_DATA), enable); .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_SENSOR_DATA), enable);
// unconditionally try to get notifications for HR -- will silently fail when characteristic // cannot use supportsHeartrate() here because we don't have that information yet
// is not available. And at this point, we don't even know whether we support it, because BluetoothGattCharacteristic heartrateCharacteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT);
// no device info is available yet. We would have to do the check in a custom NotifyAction. if (heartrateCharacteristic != null) {
// if (supportsHeartRate()) { builder.notify(heartrateCharacteristic, enable);
builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT), enable); }
// }
return this; return this;
} }