use of nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction in project Gadgetbridge by Freeyourgadget.
the class FetchActivityOperation method doPerform.
@Override
protected void doPerform() throws IOException {
TransactionBuilder builder = performInitialized("fetching activity data");
getSupport().setLowLatency(builder);
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.busy_task_fetch_activity_data), getContext()));
BluetoothGattCharacteristic characteristicFetch = getCharacteristic(MiBand2Service.UUID_UNKNOWN_CHARACTERISTIC4);
builder.notify(characteristicFetch, true);
BluetoothGattCharacteristic characteristicActivityData = getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_5_ACTIVITY_DATA);
GregorianCalendar sinceWhen = getLastSuccessfulSyncTime();
builder.write(characteristicFetch, BLETypeConversions.join(new byte[] { MiBand2Service.COMMAND_ACTIVITY_DATA_START_DATE, 0x01 }, getSupport().getTimeBytes(sinceWhen, TimeUnit.MINUTES)));
// TODO: actually wait for the success-reply
builder.add(new WaitAction(1000));
builder.notify(characteristicActivityData, true);
builder.write(characteristicFetch, new byte[] { MiBand2Service.COMMAND_FETCH_ACTIVITY_DATA });
builder.queue(getQueue());
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction in project Gadgetbridge by Freeyourgadget.
the class FetchActivityOperation method doPerform.
@Override
protected void doPerform() throws IOException {
// scheduleTaskExecutor = Executors.newScheduledThreadPool(1);
TransactionBuilder builder = performInitialized("fetch activity data");
getSupport().setLowLatency(builder);
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.busy_task_fetch_activity_data), getContext()));
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), fetch);
builder.queue(getQueue());
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction in project Gadgetbridge by Freeyourgadget.
the class UpdateFirmwareOperation method sendFwInfo.
public boolean sendFwInfo() {
try {
TransactionBuilder builder = performInitialized("send firmware info");
// getSupport().setLowLatency(builder);
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.updating_firmware), getContext()));
int fwSize = getFirmwareInfo().getSize();
byte[] sizeBytes = BLETypeConversions.fromUint24(fwSize);
int arraySize = 4;
boolean isFirmwareCode = getFirmwareInfo().getFirmwareType() == FirmwareType.FIRMWARE;
if (!isFirmwareCode) {
arraySize++;
}
byte[] bytes = new byte[arraySize];
int i = 0;
bytes[i++] = MiBand2Service.COMMAND_FIRMWARE_INIT;
bytes[i++] = sizeBytes[0];
bytes[i++] = sizeBytes[1];
bytes[i++] = sizeBytes[2];
if (!isFirmwareCode) {
bytes[i++] = getFirmwareInfo().getFirmwareType().getValue();
}
builder.write(fwCControlChar, bytes);
builder.queue(getQueue());
return true;
} catch (IOException e) {
LOG.error("Error sending firmware info: " + e.getLocalizedMessage(), e);
return false;
}
}
Aggregations