diff --git a/Software/PC_Application/Device/firmwareupdatedialog.cpp b/Software/PC_Application/Device/firmwareupdatedialog.cpp index 8784abb..867ef07 100644 --- a/Software/PC_Application/Device/firmwareupdatedialog.cpp +++ b/Software/PC_Application/Device/firmwareupdatedialog.cpp @@ -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() diff --git a/Software/PC_Application/Device/firmwareupdatedialog.h b/Software/PC_Application/Device/firmwareupdatedialog.h index 2a59e01..194fe57 100644 --- a/Software/PC_Application/Device/firmwareupdatedialog.h +++ b/Software/PC_Application/Device/firmwareupdatedialog.h @@ -51,6 +51,7 @@ private: TransferringData, TriggeringUpdate, WaitingForReboot, + WaitBeforeInitializing, }; State state; unsigned int transferredBytes;