summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Pientsov <andrii.pientsov@globallogic.com>2020-07-17 10:42:16 +0300
committerAndrii Pientsov <andrii.pientsov@globallogic.com>2020-07-17 10:42:16 +0300
commit298efe4e17d3665f9ddbb9298a37b563c60de735 (patch)
treed6c9c3f1f23de7e215fca1dbbe4f38b3c4a09815
parenta05854f5d389f67001b7ecc4cda62c7320433349 (diff)
downloadlibmts-io-298efe4e17d3665f9ddbb9298a37b563c60de735.tar.gz
libmts-io-298efe4e17d3665f9ddbb9298a37b563c60de735.tar.bz2
libmts-io-298efe4e17d3665f9ddbb9298a37b563c60de735.zip
Code review
-rw-r--r--include/mts/MTS_IO_QuectelRadio.h3
-rw-r--r--include/mts/MTS_IO_TelitRadio.h3
-rw-r--r--src/MTS_IO_QuectelRadio.cpp40
-rw-r--r--src/MTS_IO_TelitRadio.cpp88
4 files changed, 66 insertions, 68 deletions
diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h
index b49004d..41c89dc 100644
--- a/include/mts/MTS_IO_QuectelRadio.h
+++ b/include/mts/MTS_IO_QuectelRadio.h
@@ -31,6 +31,7 @@ namespace MTS {
public:
bool resetRadio(uint32_t iTimeoutMillis = 5000) override;
+ CODE getVendorFirmware(std::string& sVendorFirmware) override;
CODE getModel(std::string& sModel) override;
CODE getIccid(std::string& sIccid) override;
CODE getService(std::string& sService) override;
@@ -72,8 +73,6 @@ namespace MTS {
static const std::string VALUE_MTS_DELTA_NAME;
static const std::string VALUE_MTS_DELTA_PATH;
- CODE getVendorFirmware(std::string& sVendorFirmware);
-
CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes);
CODE abortFileUpload();
diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h
index d0a70ed..c3ba764 100644
--- a/include/mts/MTS_IO_TelitRadio.h
+++ b/include/mts/MTS_IO_TelitRadio.h
@@ -31,6 +31,7 @@ namespace MTS {
bool resetRadio(uint32_t iTimeoutMillis = 5000) override;
CODE getFirmwareBuild(std::string& sFirmwareBuild) override;
+ CODE getVendorFirmware(std::string& sVendorFirmware) override;
CODE getModel(std::string& sModel) override;
CODE getIccid(std::string& sIccid) override;
CODE getService(std::string& sService) override;
@@ -80,8 +81,6 @@ namespace MTS {
static const size_t FILE_CHUNK_SIZE;
static const std::string CMD_ABORT_UPLOAD;
- CODE getVendorFirmware(std::string& sVendorFirmware);
-
CODE startWrite();
CODE abortWrite();
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index e32d6e8..22fa92f 100644
--- a/src/MTS_IO_QuectelRadio.cpp
+++ b/src/MTS_IO_QuectelRadio.cpp
@@ -56,6 +56,26 @@ bool QuectelRadio::resetRadio(uint32_t iTimeoutMillis) {
return false;
}
+ICellularRadio::CODE QuectelRadio::getVendorFirmware(std::string& sVendorFirmware) {
+ printTrace("%s| Get Quectel-specific firmware version", getName().c_str());
+ sVendorFirmware = ICellularRadio::VALUE_NOT_SUPPORTED;
+ std::string sCmd("AT+QGMR");
+ std::string sResult = sendCommand(sCmd);
+ size_t pos = sResult.find(ICellularRadio::RSP_OK);
+ if (pos == std::string::npos) {
+ printWarning("%s| Unable to get firmware from radio using command [%s]", getName().c_str(), sCmd.c_str());
+ return FAILURE;
+ }
+
+ sVendorFirmware = MTS::Text::trim(sResult.substr(0, pos));
+ if(sVendorFirmware.size() == 0) {
+ printWarning("%s| Unable to get firmware from radio using command [%s]", getName().c_str(), sCmd.c_str());
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
ICellularRadio::CODE QuectelRadio::getModel(std::string& sModel) {
printTrace("%s| Get Model", getName().c_str());
//Always returns SUCCESS because the model should be m_sName
@@ -954,26 +974,6 @@ ICellularRadio::CODE QuectelRadio::checkFile(bool& bIsFilePresent, const std::st
return SUCCESS;
}
-ICellularRadio::CODE QuectelRadio::getVendorFirmware(std::string& sVendorFirmware) {
- printTrace("%s| Get Quectel-specific firmware version", getName().c_str());
- sVendorFirmware = ICellularRadio::VALUE_NOT_SUPPORTED;
- std::string sCmd("AT+QGMR");
- std::string sResult = sendCommand(sCmd);
- size_t pos = sResult.find(ICellularRadio::RSP_OK);
- if (pos == std::string::npos) {
- printWarning("%s| Unable to get firmware from radio using command [%s]", getName().c_str(), sCmd.c_str());
- return FAILURE;
- }
-
- sVendorFirmware = MTS::Text::trim(sResult.substr(0, pos));
- if(sVendorFirmware.size() == 0) {
- printWarning("%s| Unable to get firmware from radio using command [%s]", getName().c_str(), sCmd.c_str());
- return FAILURE;
- }
-
- return SUCCESS;
-}
-
uint16_t QuectelRadio::getQuectelChecksum(const void* data, size_t nBytes) {
auto castData = static_cast<const uint8_t*>(data);
uint16_t iChecksum = 0;
diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp
index 599c71e..a82004c 100644
--- a/src/MTS_IO_TelitRadio.cpp
+++ b/src/MTS_IO_TelitRadio.cpp
@@ -82,6 +82,50 @@ ICellularRadio::CODE TelitRadio::getFirmwareBuild(std::string& sFirmwareBuild) {
return SUCCESS;
}
+ICellularRadio::CODE TelitRadio::getVendorFirmware(std::string& sVendorFirmware) {
+ printTrace("%s| Get Telit-specific firmware version", getName().c_str());
+ ICellularRadio::CODE rc = FAILURE;
+ sVendorFirmware = ICellularRadio::VALUE_NOT_SUPPORTED;
+ std::string sFirmware;
+ std::string sFirmwareBuild;
+ std::string sCmd("AT#SWPKGV");
+ std::string sResult = sendCommand(sCmd);
+ size_t pos = sResult.find(ICellularRadio::RSP_OK);
+
+ do {
+
+ if (pos != std::string::npos) {
+ // Found
+ std::vector<std::string> vLine = MTS::Text::split(sResult, "\r");
+ sVendorFirmware = MTS::Text::trim(vLine[1]);
+ if(sVendorFirmware.size() == 0) {
+ printWarning("%s| Unable to get firmware from radio using command [%s]", getName().c_str(), sCmd.c_str());
+ rc = FAILURE;
+ } else {
+ rc = SUCCESS;
+ }
+ break;
+ }
+
+ // Not Found. Then we will use "AT+CGMR" + "AT#CFVR"
+ rc = getFirmware(sFirmware);
+ if (rc != SUCCESS){
+ break;
+ }
+
+ rc = getFirmwareBuild(sFirmwareBuild);
+ if (rc != SUCCESS){
+ break;
+ }
+
+ sVendorFirmware = sFirmware + "," + sFirmwareBuild;
+
+ } while (false);
+
+
+ return rc;
+}
+
ICellularRadio::CODE TelitRadio::getModel(std::string& sModel) {
printTrace("%s| Get Model", getName().c_str());
//Always returns SUCCESS because the model should be m_sName
@@ -968,50 +1012,6 @@ ICellularRadio::CODE TelitRadio::abortWrite() {
return sendBasicCommand(CMD_ABORT_UPLOAD, 2000, 0x00);
}
-ICellularRadio::CODE TelitRadio::getVendorFirmware(std::string& sVendorFirmware) {
- printTrace("%s| Get Telit-specific firmware version", getName().c_str());
- ICellularRadio::CODE rc = FAILURE;
- sVendorFirmware = ICellularRadio::VALUE_NOT_SUPPORTED;
- std::string sFirmware;
- std::string sFirmwareBuild;
- std::string sCmd("AT#SWPKGV");
- std::string sResult = sendCommand(sCmd);
- size_t pos = sResult.find(ICellularRadio::RSP_OK);
-
- do {
-
- if (pos != std::string::npos) {
- // Found
- std::vector<std::string> vLine = MTS::Text::split(sResult, "\r");
- sVendorFirmware = MTS::Text::trim(vLine[1]);
- if(sVendorFirmware.size() == 0) {
- printWarning("%s| Unable to get firmware from radio using command [%s]", getName().c_str(), sCmd.c_str());
- rc = FAILURE;
- } else {
- rc = SUCCESS;
- }
- break;
- }
-
- // Not Found. Then we will use "AT+CGMR" + "AT#CFVR"
- rc = getFirmware(sFirmware);
- if (rc != SUCCESS){
- break;
- }
-
- rc = getFirmwareBuild(sFirmwareBuild);
- if (rc != SUCCESS){
- break;
- }
-
- sVendorFirmware = sFirmware + "," + sFirmwareBuild;
-
- } while (false);
-
-
- return rc;
-}
-
ICellularRadio::CODE TelitRadio::fumoWaitUpgradeFinished(ICellularRadio::UpdateCb& stepCb) {
const uint32_t duAttachTimeout = 300000; // wait for 300 seconds for the radio to attach
const uint32_t duUrcTimeout = 60 * 1000; // wait for 1 minutes for the next URC message