summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/MTS_IO_QuectelRadio.cpp52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index cbc2cfb..03593a7 100644
--- a/src/MTS_IO_QuectelRadio.cpp
+++ b/src/MTS_IO_QuectelRadio.cpp
@@ -549,9 +549,12 @@ ICellularRadio::CODE QuectelRadio::fumoLocalInject(int fd, ICellularRadio::Updat
bool bIsFilePresent = false;
do {
+ callNextStep(stepCb, "FUMO Info: downloading the firmware");
+
rc = checkFile(bIsFilePresent, VALUE_MTS_DELTA_NAME);
if (rc != SUCCESS) {
- printError("Failed to check if the delta file was already uploaded.");
+ printError("Failed to check if the delta file was already download.");
+ callNextStep(stepCb, "FUMO Error: failed to download the firmware file");
break;
}
@@ -561,15 +564,19 @@ ICellularRadio::CODE QuectelRadio::fumoLocalInject(int fd, ICellularRadio::Updat
if (rc != SUCCESS) {
printError("Failed to remove the previous delta file.");
+ callNextStep(stepCb, "FUMO Error: failed to download the firmware file");
break;
}
rc = uploadFile(fd, VALUE_MTS_DELTA_NAME, stepCb);
if (rc != SUCCESS) {
- printError("Failed to upload the delta file.");
+ printError("Failed to inject the delta file.");
+ callNextStep(stepCb, "FUMO Error: failed to download the firmware file");
break;
}
+ callNextStep(stepCb, "FUMO Info: firmware downloaded successfully");
+
} while (false);
return rc;
@@ -592,6 +599,7 @@ ICellularRadio::CODE QuectelRadio::fumoLocalApply(ICellularRadio::UpdateCb& step
rc = sendBasicCommand(sCmd, 1000);
if (rc != SUCCESS) {
+ printError("FUMO failed, OK not received from the radio");
callNextStep(stepCb, "FUMO Error: failed to apply the firmware");
return rc;
}
@@ -611,29 +619,44 @@ ICellularRadio::CODE QuectelRadio::fumoLocalApply(ICellularRadio::UpdateCb& step
// It's now detached. Try to reconnect
if (!resetConnection(duAttachTimeout)) {
printError("Can't connect to the radio in %d ms", (duAttachTimeout));
-
- callNextStep(stepCb, "FUMO error: failed to connect to the radio in recovery mode");
+ callNextStep(stepCb, "FUMO Error: unable to obtain radio after reset");
break;
}
// It's now back on the bus. Wait for the URC messages.
+ printInfo("Applying the radio firmware");
+ callNextStep(stepCb, "FUMO Info: applying the radio firmware");
rc = fumoWaitUpgradeFinished(stepCb);
+
if (rc == ERROR) {
// unrecoverable error
+ callNextStep(stepCb, "FUMO Error: failed to apply the firmware, consider radio reset");
break;
}
if (rc != SUCCESS) {
// attempt failed, radio reboots and starts its next attempt
+ printError("Failed to apply the firmware, attempts left: %d", (dMaxAttempts - i - 1));
+ callNextStep(stepCb, "FUMO Error: failed to apply the firmware");
continue;
}
- // attempt finished
+ // Wait for the radio to finish update and reboot
+ printTrace("Waiting for the radio to come up");
+ callNextStep(stepCb, "FUMO Info: waiting for the radio to enter normal mode");
+
+ rc = fumoWaitNewFirmware(stepCb);
break;
}
- // Wait for the radio to finish update and reboot
- rc = fumoWaitNewFirmware(stepCb);
+ if (rc == SUCCESS) {
+ printInfo("Radio firmware applied successfully");
+ callNextStep(stepCb, "FUMO done: radio firmware applied successfully");
+ } else {
+ printError("Radio firmware has not been updated");
+ callNextStep(stepCb, "FUMO error: radio firmware has not been updated");
+ }
+
return rc;
}
@@ -1015,7 +1038,7 @@ ICellularRadio::CODE QuectelRadio::fumoWaitUpgradeFinished(ICellularRadio::Updat
const std::string sFotaUrcEnd = "\"END\"";
const std::vector<std::string> vFotaBailStrings{ sFotaUrcPrefix };
- CODE rc = ERROR;
+ CODE rc = FAILURE;
std::string sResponse;
while (true) { // breaks on "FOTA","END"
@@ -1025,6 +1048,7 @@ ICellularRadio::CODE QuectelRadio::fumoWaitUpgradeFinished(ICellularRadio::Updat
if (sResponse.find(sFotaUrcPrefix) == std::string::npos) {
printError("No URC messages from the radio in %d ms", duUrcTimeout);
callNextStep(stepCb, "FUMO error: timeout, radio is not responding");
+ rc = ERROR;
break;
}
@@ -1041,7 +1065,7 @@ ICellularRadio::CODE QuectelRadio::fumoWaitUpgradeFinished(ICellularRadio::Updat
break;
}
// attempt failed, the radio attempts to recover
- rc = FAILURE;
+ callNextStep(stepCb, "FUMO Error: radio returned error code " + sCode);
break;
} else if (sStage == sFotaUrcStart) {
printTrace("Got FOTA START message");
@@ -1049,6 +1073,7 @@ ICellularRadio::CODE QuectelRadio::fumoWaitUpgradeFinished(ICellularRadio::Updat
printTrace("Got FOTA progress message");
const std::string& sPercents = vParts[2];
printInfo("FOTA progress: [%s]", sPercents.c_str());
+ callNextStep(stepCb, "FUMO Info: firmware apply progress " + sPercents);
} else {
printInfo("FOTA unexpected URC code: [%s]", sStage.c_str());
}
@@ -1074,6 +1099,7 @@ ICellularRadio::CODE QuectelRadio::fumoWaitNewFirmware(ICellularRadio::UpdateCb&
}
#if 0
+ // TODO: Implement the version check
if (sFirmware == m_sFw && sFirmwareBuild == m_sFwBuild) {
// Have the same firmware. The radio resets several time
// before the firmware is actually get upgraded. So keep polling.
@@ -1089,11 +1115,9 @@ ICellularRadio::CODE QuectelRadio::fumoWaitNewFirmware(ICellularRadio::UpdateCb&
}
oTimer.stop();
- if (rc == SUCCESS) {
- callNextStep(stepCb, "FUMO done: radio firmware applied successfully");
- }
- else {
- callNextStep(stepCb, "FUMO error: radio firmware has not been updated");
+ if (rc != SUCCESS) {
+ printError("Radio is not responding");
+ callNextStep(stepCb, "FUMO Error: unable to obtain radio after reset");
}
return rc;