Search in sources :

Example 46 with TransactionBuilder

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);
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException)

Example 47 with TransactionBuilder

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");
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException)

Example 48 with TransactionBuilder

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);
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException)

Example 49 with TransactionBuilder

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);
    }
}
Also used : VibrationProfile(nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile) TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException) Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs)

Example 50 with TransactionBuilder

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) {
    }
}
Also used : AlertNotificationProfile(nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertNotificationProfile) NewAlert(nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.NewAlert) TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException)

Aggregations

TransactionBuilder (nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)50 IOException (java.io.IOException)34 BluetoothGattCharacteristic (android.bluetooth.BluetoothGattCharacteristic)7 GregorianCalendar (java.util.GregorianCalendar)4 Alarm (nodomain.freeyourgadget.gadgetbridge.model.Alarm)4 Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)4 Calendar (java.util.Calendar)3 GBAlarm (nodomain.freeyourgadget.gadgetbridge.impl.GBAlarm)3 SetDeviceBusyAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction)3 VibrationProfile (nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile)2 SetProgressAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetProgressAction)2 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 UUID (java.util.UUID)1 BadPaddingException (javax.crypto.BadPaddingException)1 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)1 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)1 CalendarEvents (nodomain.freeyourgadget.gadgetbridge.model.CalendarEvents)1 SetDeviceStateAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction)1 WaitAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WaitAction)1