mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 01:55:50 +01:00
test if heartrate is supported before writing preferences
This commit is contained in:
parent
20aa7d9ad9
commit
f2de21a664
@ -376,20 +376,24 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
* @return
|
||||
*/
|
||||
private MiBandSupport setHeartrateSleepSupport(TransactionBuilder transaction) {
|
||||
LOG.info("Attempting to set heartrate sleep support...");
|
||||
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT);
|
||||
if (characteristic != null) {
|
||||
if(MiBandCoordinator.getHeartrateSleepSupport(getDevice().getAddress())) {
|
||||
LOG.info("Enabling heartrate sleep support...");
|
||||
transaction.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), startHeartMeasurementSleep);
|
||||
if (supportsHeartRate()) {
|
||||
LOG.info("Attempting to set heartrate sleep support...");
|
||||
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT);
|
||||
if (characteristic != null) {
|
||||
if(MiBandCoordinator.getHeartrateSleepSupport(getDevice().getAddress())) {
|
||||
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...");
|
||||
transaction.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementSleep);
|
||||
}
|
||||
} else {
|
||||
LOG.info("Unable to set Wear Location");
|
||||
}
|
||||
|
||||
} else
|
||||
GB.toast(getContext(), "Heart rate is not supported on this device", Toast.LENGTH_LONG, GB.ERROR);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user