use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class UpdateFirmwareOperation2020 method sendFwInfo.
public boolean sendFwInfo() {
try {
TransactionBuilder builder = performInitialized("send firmware info");
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.updating_firmware), getContext()));
int fwSize = getFirmwareInfo().getSize();
byte[] sizeBytes = BLETypeConversions.fromUint32(fwSize);
int crc32 = firmwareInfo.getCrc32();
byte[] chunkSizeBytes = BLETypeConversions.fromUint16(mChunkLength);
byte[] crcBytes = BLETypeConversions.fromUint32(crc32);
byte[] bytes = new byte[] { COMMAND_SEND_FIRMWARE_INFO, getFirmwareInfo().getFirmwareType().getValue(), sizeBytes[0], sizeBytes[1], sizeBytes[2], sizeBytes[3], crcBytes[0], crcBytes[1], crcBytes[2], crcBytes[3], chunkSizeBytes[0], chunkSizeBytes[1], // ??
0, // index
0, // count
1, // total size? right now it is equal to the size above
sizeBytes[0], sizeBytes[1], sizeBytes[2], sizeBytes[3] };
if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.WATCHFACE) {
byte[] fwBytes = firmwareInfo.getBytes();
if (ArrayUtils.startsWith(fwBytes, UIHH_HEADER)) {
getSupport().writeToConfiguration(builder, new byte[] { 0x39, 0x00, sizeBytes[0], sizeBytes[1], sizeBytes[2], sizeBytes[3], fwBytes[18], fwBytes[19], fwBytes[20], fwBytes[21] });
}
}
builder.write(fwCControlChar, bytes);
builder.queue(getQueue());
return true;
} catch (IOException e) {
LOG.error("Error sending firmware info: " + e.getLocalizedMessage(), e);
return false;
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class UpdateFirmwareOperation2020 method sendTransferComplete.
protected void sendTransferComplete() throws IOException {
TransactionBuilder builder = performInitialized("trasfer complete");
builder.write(fwCControlChar, new byte[] { COMMAND_COMPLETE_TRANSFER });
builder.queue(getQueue());
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class AbstractID115Operation method operationFinished.
@Override
protected void operationFinished() {
operationStatus = OperationStatus.FINISHED;
if (getDevice() != null && getDevice().isConnected()) {
unsetBusy();
try {
TransactionBuilder builder = performInitialized("reenabling disabled notifications");
enableNotifications(builder, false);
// unset ourselves from being the queue's gatt callback
builder.setGattCallback(null);
builder.queue(getQueue());
} catch (IOException ex) {
GB.toast(getContext(), "Error enabling ID115 notifications, you may need to connect and disconnect", Toast.LENGTH_LONG, GB.ERROR, ex);
}
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class ID115Support method onSetTime.
@Override
public void onSetTime() {
try {
TransactionBuilder builder = performInitialized("time");
setTime(builder);
builder.queue(getQueue());
} catch (IOException e) {
LOG.warn("Unable to send current time", e);
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class ID115Support method onReset.
@Override
public void onReset(int flags) {
try {
getQueue().clear();
TransactionBuilder builder = performInitialized("reboot");
builder.write(normalWriteCharacteristic, new byte[] { ID115Constants.CMD_ID_DEVICE_RESTART, ID115Constants.CMD_KEY_REBOOT });
builder.queue(getQueue());
} catch (Exception e) {
}
}
Aggregations