Fix fw update notification being stuck at the end

Fixes #821
This commit is contained in:
cpfeiffer 2017-09-25 00:03:40 +02:00
parent e28085e6af
commit 3c9fab0471
2 changed files with 11 additions and 2 deletions

View File

@ -687,13 +687,18 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
public void onReboot() {
try {
TransactionBuilder builder = performInitialized("Reboot");
builder.write(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_FIRMWARE), new byte[] { MiBand2Service.COMMAND_FIRMWARE_REBOOT});
sendReboot(builder);
builder.queue(getQueue());
} catch (IOException ex) {
LOG.error("Unable to reboot MI", ex);
}
}
public MiBand2Support sendReboot(TransactionBuilder builder) {
builder.write(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_FIRMWARE), new byte[] { MiBand2Service.COMMAND_FIRMWARE_REBOOT});
return this;
}
@Override
public void onHeartRateTest() {
try {

View File

@ -97,6 +97,7 @@ public class UpdateFirmwareOperation extends AbstractMiBand2Operation {
UUID characteristicUUID = characteristic.getUuid();
if (fwCControlChar.getUuid().equals(characteristicUUID)) {
handleNotificationNotif(characteristic.getValue());
return true; // don't let anyone else handle it
} else {
super.onCharacteristicChanged(gatt, characteristic);
}
@ -134,7 +135,9 @@ public class UpdateFirmwareOperation extends AbstractMiBand2Operation {
}
case MiBand2Service.COMMAND_FIRMWARE_CHECKSUM: {
if (getFirmwareInfo().getFirmwareType() == FirmwareType.FIRMWARE) {
getSupport().onReboot();
TransactionBuilder builder = performInitialized("reboot");
getSupport().sendReboot(builder);
builder.queue(getQueue());
} else {
GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_update_complete), false, 100, getContext());
done();
@ -142,6 +145,7 @@ public class UpdateFirmwareOperation extends AbstractMiBand2Operation {
break;
}
case MiBand2Service.COMMAND_FIRMWARE_REBOOT: {
LOG.info("Reboot command successfully sent.");
GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_update_complete), false, 100, getContext());
// getSupport().onReboot();
done();