Search in sources :

Example 16 with TransactionBuilder

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

the class MiBand2Support method onEnableHeartRateSleepSupport.

@Override
public void onEnableHeartRateSleepSupport(boolean enable) {
    try {
        TransactionBuilder builder = performInitialized("enable heart rate sleep support: " + enable);
        setHeartrateSleepSupport(builder);
        builder.queue(getQueue());
    } catch (IOException e) {
        GB.toast(getContext(), "Error toggling heart rate sleep support: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException)

Example 17 with TransactionBuilder

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

the class MiBand2Support method performDefaultNotification.

private void performDefaultNotification(String task, SimpleNotification simpleNotification, short repeat, BtLEAction extraAction) {
    try {
        TransactionBuilder builder = performInitialized(task);
        sendDefaultNotification(builder, simpleNotification, repeat, extraAction);
        builder.queue(getQueue());
    } catch (IOException ex) {
        LOG.error("Unable to send notification to MI device", ex);
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException)

Example 18 with TransactionBuilder

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

the class AbstractBleProfile method performInitialized.

/**
     * Delegates to the DeviceSupport instance and additionally sets this instance as the Gatt
     * callback for the transaction.
     *
     * @param taskName
     * @return
     * @throws IOException
     */
public TransactionBuilder performInitialized(String taskName) throws IOException {
    TransactionBuilder builder = mSupport.performInitialized(taskName);
    builder.setGattCallback(this);
    return builder;
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)

Example 19 with TransactionBuilder

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

the class HPlusHandlerThread method requestNextSleepData.

/**
     * Issue a message requesting the next batch of sleep data
     */
private void requestNextSleepData() {
    TransactionBuilder builder = new TransactionBuilder("requestSleepStats");
    builder.write(mHPlusSupport.ctrlCharacteristic, new byte[] { HPlusConstants.CMD_GET_SLEEP });
    builder.queue(mHPlusSupport.getQueue());
    mGetSleepTime = GregorianCalendar.getInstance();
    mGetSleepTime.add(GregorianCalendar.SECOND, SLEEP_SYNC_RETRY_PERIOD);
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)

Example 20 with TransactionBuilder

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

the class MiBandSupport method onEnableRealtimeSteps.

@Override
public void onEnableRealtimeSteps(boolean enable) {
    try {
        BluetoothGattCharacteristic controlPoint = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT);
        if (enable) {
            TransactionBuilder builder = performInitialized("Read realtime steps");
            builder.read(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS)).queue(getQueue());
        }
        performInitialized(enable ? "Enabling realtime steps notifications" : "Disabling realtime steps notifications").write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_LE_PARAMS), enable ? getLowLatency() : getHighLatency()).write(controlPoint, enable ? startRealTimeStepsNotifications : stopRealTimeStepsNotifications).queue(getQueue());
        enableRealtimeSamplesTimer(enable);
    } catch (IOException e) {
        LOG.error("Unable to change realtime steps notification to: " + enable, e);
    }
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic)

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