Use low latency transfer mode for fw update #234
This commit is contained in:
parent
5f72daa43a
commit
cc7f5406ef
|
@ -113,6 +113,10 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
|
|||
return operationStatus == OperationStatus.RUNNING;
|
||||
}
|
||||
|
||||
public boolean isOperationFinished() {
|
||||
return operationStatus == OperationStatus.FINISHED;
|
||||
}
|
||||
|
||||
public T getSupport() {
|
||||
return mSupport;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
|||
}
|
||||
|
||||
private void done() {
|
||||
LOG.info("Operation done.");
|
||||
updateCoordinator = null;
|
||||
operationFinished();
|
||||
unsetBusy();
|
||||
|
@ -273,6 +274,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
|||
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("send firmware packet");
|
||||
getSupport().setLowLatency(builder);
|
||||
for (int i = 0; i < packets; i++) {
|
||||
byte[] fwChunk = Arrays.copyOfRange(fwbytes, i * packetLength, i * packetLength + packetLength);
|
||||
|
||||
|
@ -319,6 +321,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
|||
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()));
|
||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), getFirmwareInfo());
|
||||
builder.add(new FirmwareInfoSucceededAction());
|
||||
|
@ -440,7 +443,9 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
|||
private class FirmwareInfoSucceededAction extends PlainAction {
|
||||
@Override
|
||||
public boolean run(BluetoothGatt gatt) {
|
||||
if (isOperationRunning()) {
|
||||
firmwareInfoSent = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue