use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class MiBand2Support method onSetTime.
@Override
public void onSetTime() {
try {
TransactionBuilder builder = performInitialized("Set date and time");
setCurrentTimeWithService(builder);
//TODO: once we have a common strategy for sending events (e.g. EventHandler), remove this call from here. Meanwhile it does no harm.
sendCalendarEvents(builder);
builder.queue(getQueue());
} catch (IOException ex) {
LOG.error("Unable to set time on MI device", ex);
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class MiBand2Support method stopCurrentNotification.
private void stopCurrentNotification() {
try {
TransactionBuilder builder = performInitialized("stop notification");
getNotificationStrategy().stopCurrentNotification(builder);
builder.queue(getQueue());
} catch (IOException e) {
LOG.error("Error stopping notification");
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class MiBand2Support method onEnableRealtimeHeartRateMeasurement.
@Override
public void onEnableRealtimeHeartRateMeasurement(boolean enable) {
try {
TransactionBuilder builder = performInitialized("Enable realtime heart rateM measurement");
if (enable) {
builder.write(getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementManual);
builder.write(getCharacteristic(GattCharacteristic.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 MiBand2Support method performPreferredNotification.
private void performPreferredNotification(String task, String notificationOrigin, SimpleNotification simpleNotification, int alertLevel, 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);
profile.setAlertLevel(alertLevel);
int flashTimes = getPreferredFlashCount(notificationOrigin, prefs);
int flashColour = getPreferredFlashColour(notificationOrigin, prefs);
int originalColour = getPreferredOriginalColour(notificationOrigin, prefs);
int flashDuration = getPreferredFlashDuration(notificationOrigin, prefs);
sendCustomNotification(profile, simpleNotification, flashTimes, flashColour, originalColour, flashDuration, extraAction, 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 MiBand2Support method onTestNewFunction.
@Override
public void onTestNewFunction() {
try {
TransactionBuilder builder = performInitialized("incoming call from peter");
NewAlert alert = new NewAlert(AlertCategory.Custom, 1, new String(new byte[] { 0x19 }));
AlertNotificationProfile<MiBand2Support> profile = new AlertNotificationProfile<>(this);
profile.newAlert(builder, alert, OverflowStrategy.MAKE_MULTIPLE);
builder.queue(getQueue());
} catch (IOException e) {
}
}
Aggregations