Search in sources :

Example 1 with WriteAction

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

the class MiBandSupport method sendUserInfo.

/**
     * Part of device initialization process. Do not call manually.
     *
     * @param builder
     * @return
     */
private MiBandSupport sendUserInfo(TransactionBuilder builder) {
    LOG.debug("Writing User Info!");
    // Use a custom action instead of just builder.write() because mDeviceInfo
    // is set by handleDeviceInfo *after* this action is created.
    builder.add(new BtLEAction(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_USER_INFO)) {

        @Override
        public boolean expectsResult() {
            return true;
        }

        @Override
        public boolean run(BluetoothGatt gatt) {
            // at this point, mDeviceInfo should be set
            return new WriteAction(getCharacteristic(), MiBandCoordinator.getAnyUserInfo(getDevice().getAddress()).getData(mDeviceInfo)).run(gatt);
        }
    });
    return this;
}
Also used : ConditionalWriteAction(nodomain.freeyourgadget.gadgetbridge.service.btle.actions.ConditionalWriteAction) WriteAction(nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction) BluetoothGatt(android.bluetooth.BluetoothGatt) BtLEAction(nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction)

Aggregations

BluetoothGatt (android.bluetooth.BluetoothGatt)1 BtLEAction (nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction)1 ConditionalWriteAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.ConditionalWriteAction)1 WriteAction (nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction)1