Cleaner device reattachment after firmware update

This commit is contained in:
Jan Käberich 2020-10-07 20:04:45 +02:00
parent 394facf2ed
commit 707975b037
2 changed files with 16 additions and 5 deletions

View File

@ -90,18 +90,28 @@ void FirmwareUpdateDialog::abortWithError(QString error)
void FirmwareUpdateDialog::timerCallback() void FirmwareUpdateDialog::timerCallback()
{ {
if(state != State::WaitingForReboot) { switch(state) {
abortWithError("Response timed out"); case State::WaitingForReboot: {
} else {
// Currently waiting for the reboot, check device list // Currently waiting for the reboot, check device list
auto devices = Device::GetDevices(); auto devices = Device::GetDevices();
if(devices.find(serialnumber) != devices.end()) { if(devices.find(serialnumber) != devices.end()) {
// the device rebooted and is available again // the device rebooted and is available again
addStatus("...device enumerated, update complete"); addStatus("...device enumerated, update complete");
timer.stop(); state = State::WaitBeforeInitializing;
emit DeviceRebooted(serialnumber); timer.start(3000);
} }
} }
break;
case State::WaitBeforeInitializing:
// Device had enough time to initialize, indicate that rebooted device is ready
timer.stop();
emit DeviceRebooted(serialnumber);
delete this;
break;
default:
abortWithError("Response timed out");
break;
}
} }
void FirmwareUpdateDialog::receivedAck() void FirmwareUpdateDialog::receivedAck()

View File

@ -51,6 +51,7 @@ private:
TransferringData, TransferringData,
TriggeringUpdate, TriggeringUpdate,
WaitingForReboot, WaitingForReboot,
WaitBeforeInitializing,
}; };
State state; State state;
unsigned int transferredBytes; unsigned int transferredBytes;