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()
{
if(state != State::WaitingForReboot) {
abortWithError("Response timed out");
} else {
switch(state) {
case State::WaitingForReboot: {
// Currently waiting for the reboot, check device list
auto devices = Device::GetDevices();
if(devices.find(serialnumber) != devices.end()) {
// the device rebooted and is available again
addStatus("...device enumerated, update complete");
timer.stop();
emit DeviceRebooted(serialnumber);
state = State::WaitBeforeInitializing;
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()

View File

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