use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class MiBandSupport method onEnableRealtimeHeartRateMeasurement.
@Override
public void onEnableRealtimeHeartRateMeasurement(boolean enable) {
if (supportsHeartRate()) {
try {
TransactionBuilder builder = performInitialized("EnableRealtimeHeartRateMeasurement");
if (enable) {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementManual);
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), startHeartMeasurementContinuous);
} else {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementContinuous);
}
builder.queue(getQueue());
enableRealtimeSamplesTimer(enable);
} catch (IOException ex) {
LOG.error("Unable to enable realtime heart rate measurement in MI1S", ex);
}
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class MiBandSupport method onSetTime.
@Override
public void onSetTime() {
try {
TransactionBuilder builder = performInitialized("Set date and time");
setCurrentTime(builder);
builder.queue(getQueue());
} catch (IOException ex) {
LOG.error("Unable to set time on MI device", ex);
}
// TODO: once we have a common strategy for sending events (e.g. EventHandler), remove this call from here. Meanwhile it does no harm.
sendCalendarEvents();
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class MiBandSupport method onReset.
@Override
public void onReset(int flags) {
try {
TransactionBuilder builder = performInitialized("reset");
if ((flags & GBDeviceProtocol.RESET_FLAGS_FACTORY_RESET) != 0) {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), factoryReset);
} else {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), reboot);
}
builder.queue(getQueue());
} catch (IOException ex) {
LOG.error("Unable to reset", ex);
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class MiBandSupport method performPreferredNotification.
private void performPreferredNotification(String task, @Nullable SimpleNotification simpleNotification, String notificationOrigin, BtLEAction extraAction) {
try {
TransactionBuilder builder = performInitialized(task);
Prefs prefs = GBApplication.getPrefs();
int vibrateDuration = getPreferredVibrateDuration(notificationOrigin, prefs);
int vibratePause = getPreferredVibratePause(notificationOrigin, prefs);
short vibrateTimes = getPreferredVibrateCount(notificationOrigin, prefs);
VibrationProfile profile = getPreferredVibrateProfile(notificationOrigin, prefs, vibrateTimes);
int flashTimes = getPreferredFlashCount(notificationOrigin, prefs);
int flashColour = getPreferredFlashColour(notificationOrigin, prefs);
int originalColour = getPreferredOriginalColour(notificationOrigin, prefs);
int flashDuration = getPreferredFlashDuration(notificationOrigin, prefs);
// setLowLatency(builder);
sendCustomNotification(profile, simpleNotification, flashTimes, flashColour, originalColour, flashDuration, extraAction, builder);
// setHighLatency(builder);
// sendCustomNotification(vibrateDuration, vibrateTimes, vibratePause, flashTimes, flashColour, originalColour, flashDuration, builder);
builder.queue(getQueue());
} catch (IOException ex) {
LOG.error("Unable to send notification to MI device", ex);
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class WatchXPlusDeviceSupport method getTime.
private void getTime() {
try {
TransactionBuilder builder = performInitialized("getTime");
builder.write(getCharacteristic(WatchXPlusConstants.UUID_CHARACTERISTIC_WRITE), buildCommand(WatchXPlusConstants.CMD_TIME_SETTINGS, WatchXPlusConstants.READ_VALUE));
builder.queue(getQueue());
} catch (IOException e) {
LOG.warn(" Unable to get device time ", e);
}
}
Aggregations