summaryrefslogtreecommitdiff
path: root/src/MTS_IO_QuectelRadio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r--src/MTS_IO_QuectelRadio.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index c4bdc56..d0ec310 100644
--- a/src/MTS_IO_QuectelRadio.cpp
+++ b/src/MTS_IO_QuectelRadio.cpp
@@ -26,6 +26,10 @@
using namespace MTS::IO;
+// It is strongly recommended to use DOS 8.3 file name format for <filename>.
+const std::string QuectelRadio::VALUE_MTS_DELTA_NAME = "mtsdelta.zip";
+const std::string QuectelRadio::VALUE_MTS_DELTA_PATH = "/data/ufs/" + QuectelRadio::VALUE_MTS_DELTA_NAME;
+
QuectelRadio::QuectelRadio(const std::string& sName, const std::string& sRadioPort)
: CellularRadio (sName, sRadioPort)
{
@@ -436,6 +440,46 @@ ICellularRadio::CODE QuectelRadio::setMdn(const Json::Value& jArgs) {
return NOT_APPLICABLE;
}
+ICellularRadio::CODE QuectelRadio::uploadDeltaFirmwareFile(int fd, ICellularRadio::UpdateCb& stepCb) {
+ CODE rc = FAILURE;
+ bool bIsFilePresent = false;
+
+ do {
+ rc = checkFile(bIsFilePresent, VALUE_MTS_DELTA_NAME);
+ if (rc != SUCCESS) {
+ printError("Failed to check if the delta file was already uploaded.");
+ break;
+ }
+
+ if (bIsFilePresent) {
+ rc = removeDeltaFirmwareFile();
+ }
+
+ if (rc != SUCCESS) {
+ printError("Failed to remove the previous delta file.");
+ break;
+ }
+
+ rc = uploadFile(fd, VALUE_MTS_DELTA_NAME, stepCb);
+ if (rc != SUCCESS) {
+ printError("Failed to upload the delta file.");
+ break;
+ }
+
+ } while (false);
+
+ return rc;
+}
+
+ICellularRadio::CODE QuectelRadio::removeDeltaFirmwareFile() {
+ printTrace("Removing the delta upgrade file: %s", VALUE_MTS_DELTA_NAME.c_str());
+ return removeFile(VALUE_MTS_DELTA_NAME);
+}
+
+ICellularRadio::CODE QuectelRadio::applyDeltaFirmwareFile(ICellularRadio::UpdateCb& stepCb) {
+ return ERROR; // not implemented
+}
+
ICellularRadio::CODE QuectelRadio::getServiceDomain(ICellularRadio::SERVICEDOMAIN& sd) {
printTrace("%s| Get Service Domain", getName().c_str());
@@ -568,3 +612,41 @@ ICellularRadio::CODE QuectelRadio::convertToActiveBand(const std::string& sQuect
return SUCCESS;
}
+
+ICellularRadio::CODE QuectelRadio::uploadFile(int fd, const std::string& sTargetFilename, ICellularRadio::UpdateCb& stepCb) {
+ return ERROR; // not implemented
+}
+
+ICellularRadio::CODE QuectelRadio::removeFile(const std::string& sTargetFilename) {
+ printTrace("Removing file [%s] from the radio memory", sTargetFilename.c_str());
+
+ const int dTimeout = 1000; //ms
+ const std::string sCmd = "AT+QFDEL=\"" + sTargetFilename + "\"";
+
+ std::string sResult = sendCommand(sCmd, ICellularRadio::DEFAULT_BAIL_STRINGS, dTimeout);
+ if (sResult.find(ICellularRadio::RSP_OK) == std::string::npos) {
+ printError("Failed to remove file [%s]: [%s]", sTargetFilename.c_str(), sResult.c_str());
+ return FAILURE;
+ }
+
+ printTrace("File [%s] removed", sTargetFilename.c_str());
+ return SUCCESS;
+}
+
+ICellularRadio::CODE QuectelRadio::checkFile(bool& bIsFilePresent, const std::string& sTargetFilename) {
+ printTrace("Checking status of the [%s] file", sTargetFilename.c_str());
+
+ const int dTimeout = 1000; //ms
+ const std::string sCmd = "AT+QFLST"; // list all files in the UFS memory
+
+ std::string sResult = sendCommand(sCmd, ICellularRadio::DEFAULT_BAIL_STRINGS, dTimeout);
+ if (sResult.rfind(ICellularRadio::RSP_OK) == std::string::npos) {
+ printError("Unable to list files from the radio memory: [%s]", sResult.c_str());
+ return FAILURE;
+ }
+
+ const std::string sExpected = "+QFLST: \"UFS:" + sTargetFilename + "\"";
+ bIsFilePresent = (sResult.find(sExpected) != std::string::npos);
+
+ return SUCCESS;
+}