Cleaner device reattachment after firmware update
This commit is contained in:
parent
394facf2ed
commit
707975b037
@ -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()
|
||||
|
@ -51,6 +51,7 @@ private:
|
||||
TransferringData,
|
||||
TriggeringUpdate,
|
||||
WaitingForReboot,
|
||||
WaitBeforeInitializing,
|
||||
};
|
||||
State state;
|
||||
unsigned int transferredBytes;
|
||||
|
Loading…
Reference in New Issue
Block a user