summaryrefslogtreecommitdiff
path: root/src/MTS_IO_QuectelRadio.cpp
diff options
context:
space:
mode:
authorSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-05-28 15:55:00 +0300
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-05-30 11:39:58 +0300
commit9f5a4f138b56a0a1b4e5764a69261aa4a4edaa71 (patch)
tree458ac922e7cc2d3ff7cdaf975b742d69a6a2c5a6 /src/MTS_IO_QuectelRadio.cpp
parent26f6e69e9d5c7049d42559259933482b35559889 (diff)
downloadlibmts-io-9f5a4f138b56a0a1b4e5764a69261aa4a4edaa71.tar.gz
libmts-io-9f5a4f138b56a0a1b4e5764a69261aa4a4edaa71.tar.bz2
libmts-io-9f5a4f138b56a0a1b4e5764a69261aa4a4edaa71.zip
Quectel Delta Radio Firmware Upgrade support - libmts-io implementation
Declared base interface and added started implementation for the QuectelRadio class. Implemented file listing (file status check) and file removal logic.
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;
+}