Search in sources :

Example 81 with TransactionBuilder

use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.

the class LefunDeviceSupport method onSetCallState.

@Override
public void onSetCallState(CallSpec callSpec) {
    switch(callSpec.command) {
        case CallSpec.CALL_INCOMING:
            try {
                TransactionBuilder builder = performInitialized(SetTimeRequest.class.getSimpleName());
                SendCallNotificationRequest request = new SendCallNotificationRequest(this, builder);
                request.setCallNotification(callSpec);
                request.perform();
                performConnected(builder.getTransaction());
            } catch (IOException e) {
                GB.toast(getContext(), "Failed to send call notification", Toast.LENGTH_SHORT, GB.ERROR, e);
            }
            break;
    }
}
Also used : SetTimeRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetTimeRequest) TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException) SendCallNotificationRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SendCallNotificationRequest)

Example 82 with TransactionBuilder

use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.

the class LefunDeviceSupport method sendHydrationReminderIntervalSetting.

/**
 * Sends the hydration reminder interval setting to the device
 *
 * @param period the reminder interval
 */
private void sendHydrationReminderIntervalSetting(int period) {
    try {
        TransactionBuilder builder = performInitialized(SetHydrationReminderIntervalRequest.class.getSimpleName());
        SetHydrationReminderIntervalRequest request = new SetHydrationReminderIntervalRequest(this, builder);
        request.setInterval(period);
        request.perform();
        inProgressRequests.add(request);
        performConnected(builder.getTransaction());
    } catch (IOException e) {
        GB.toast(getContext(), "Failed to set hydration reminder interval", Toast.LENGTH_SHORT, GB.ERROR, e);
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException) SetHydrationReminderIntervalRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetHydrationReminderIntervalRequest)

Example 83 with TransactionBuilder

use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.

the class Y5Support method onHeartRateTest.

@Override
public void onHeartRateTest() {
    try {
        TransactionBuilder builder = performInitialized("HeartRateTest");
        builder.write(ctrlCharacteristic, commandWithChecksum(JYouConstants.CMD_SET_HEARTRATE_AUTO, 0, 0));
        performConnected(builder.getTransaction());
    } catch (Exception e) {
        LOG.warn(e.getMessage());
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)

Example 84 with TransactionBuilder

use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.

the class BFH16DeviceSupport method onHeartRateTest.

// TODO: check
@Override
public void onHeartRateTest() {
    try {
        TransactionBuilder builder = performInitialized("HeartRateTest");
        builder.write(ctrlCharacteristic, commandWithChecksum(BFH16Constants.CMD_MEASURE_HEART, 0, 1));
        builder.queue(getQueue());
    } catch (Exception e) {
        LOG.warn(e.getMessage());
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 85 with TransactionBuilder

use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.

the class BFH16DeviceSupport method onSetTime.

// working
@Override
public void onSetTime() {
    try {
        TransactionBuilder builder = performInitialized("SetTime");
        syncDateAndTime(builder);
        builder.queue(getQueue());
    } catch (IOException e) {
        LOG.warn(e.getMessage());
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException)

Aggregations

TransactionBuilder (nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)279 IOException (java.io.IOException)218 BluetoothGattCharacteristic (android.bluetooth.BluetoothGattCharacteristic)17 Alarm (nodomain.freeyourgadget.gadgetbridge.model.Alarm)16 UnsupportedEncodingException (java.io.UnsupportedEncodingException)12 GregorianCalendar (java.util.GregorianCalendar)11 UUID (java.util.UUID)11 Calendar (java.util.Calendar)10 SetDeviceBusyAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction)10 ByteBuffer (java.nio.ByteBuffer)8 Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)8 ServerTransactionBuilder (nodomain.freeyourgadget.gadgetbridge.service.btle.ServerTransactionBuilder)7 SetDeviceStateAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction)7 GBException (nodomain.freeyourgadget.gadgetbridge.GBException)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 SetProgressAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetProgressAction)4 AlertNotificationProfile (nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertNotificationProfile)4 NewAlert (nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.NewAlert)4 GBPrefs (nodomain.freeyourgadget.gadgetbridge.util.GBPrefs)4 InvalidKeyException (java.security.InvalidKeyException)3