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;
|
return operationStatus == OperationStatus.RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOperationFinished() {
|
||||||
|
return operationStatus == OperationStatus.FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
public T getSupport() {
|
public T getSupport() {
|
||||||
return mSupport;
|
return mSupport;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void done() {
|
private void done() {
|
||||||
|
LOG.info("Operation done.");
|
||||||
updateCoordinator = null;
|
updateCoordinator = null;
|
||||||
operationFinished();
|
operationFinished();
|
||||||
unsetBusy();
|
unsetBusy();
|
||||||
|
@ -273,6 +274,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("send firmware packet");
|
TransactionBuilder builder = performInitialized("send firmware packet");
|
||||||
|
getSupport().setLowLatency(builder);
|
||||||
for (int i = 0; i < packets; i++) {
|
for (int i = 0; i < packets; i++) {
|
||||||
byte[] fwChunk = Arrays.copyOfRange(fwbytes, i * packetLength, i * packetLength + packetLength);
|
byte[] fwChunk = Arrays.copyOfRange(fwbytes, i * packetLength, i * packetLength + packetLength);
|
||||||
|
|
||||||
|
@ -319,6 +321,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
||||||
public boolean sendFwInfo() {
|
public boolean sendFwInfo() {
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("send firmware info");
|
TransactionBuilder builder = performInitialized("send firmware info");
|
||||||
|
getSupport().setLowLatency(builder);
|
||||||
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.updating_firmware), getContext()));
|
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.updating_firmware), getContext()));
|
||||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), getFirmwareInfo());
|
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), getFirmwareInfo());
|
||||||
builder.add(new FirmwareInfoSucceededAction());
|
builder.add(new FirmwareInfoSucceededAction());
|
||||||
|
@ -440,7 +443,9 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
||||||
private class FirmwareInfoSucceededAction extends PlainAction {
|
private class FirmwareInfoSucceededAction extends PlainAction {
|
||||||
@Override
|
@Override
|
||||||
public boolean run(BluetoothGatt gatt) {
|
public boolean run(BluetoothGatt gatt) {
|
||||||
|
if (isOperationRunning()) {
|
||||||
firmwareInfoSent = true;
|
firmwareInfoSent = true;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue