1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

test if heartrate is supported before writing preferences

This commit is contained in:
Christian Fischer 2016-04-02 16:11:51 +02:00
parent 20aa7d9ad9
commit f2de21a664

View File

@ -376,20 +376,24 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
* @return * @return
*/ */
private MiBandSupport setHeartrateSleepSupport(TransactionBuilder transaction) { private MiBandSupport setHeartrateSleepSupport(TransactionBuilder transaction) {
LOG.info("Attempting to set heartrate sleep support..."); if (supportsHeartRate()) {
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT); LOG.info("Attempting to set heartrate sleep support...");
if (characteristic != null) { BluetoothGattCharacteristic characteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT);
if(MiBandCoordinator.getHeartrateSleepSupport(getDevice().getAddress())) { if (characteristic != null) {
LOG.info("Enabling heartrate sleep support..."); if(MiBandCoordinator.getHeartrateSleepSupport(getDevice().getAddress())) {
transaction.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), startHeartMeasurementSleep); LOG.info("Enabling heartrate sleep support...");
transaction.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), startHeartMeasurementSleep);
}
else {
LOG.info("Disabling heartrate sleep support...");
transaction.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementSleep);
}
} else {
LOG.info("Unable to set Heartrate sleep support");
} }
else {
LOG.info("Disabling heartrate sleep support..."); } else
transaction.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementSleep); GB.toast(getContext(), "Heart rate is not supported on this device", Toast.LENGTH_LONG, GB.ERROR);
}
} else {
LOG.info("Unable to set Wear Location");
}
return this; return this;
} }