diff options
author | Andrii Pientsov <andrii.pientsov@globallogic.com> | 2020-07-17 10:03:48 +0300 |
---|---|---|
committer | Andrii Pientsov <andrii.pientsov@globallogic.com> | 2020-07-17 10:03:48 +0300 |
commit | a05854f5d389f67001b7ecc4cda62c7320433349 (patch) | |
tree | cc8db0cad51bf284d708d2cd24dbe07eff2ef60c | |
parent | 1986b67d54e8e6a3f8176f5b4cb78786ac3ee496 (diff) | |
download | libmts-io-a05854f5d389f67001b7ecc4cda62c7320433349.tar.gz libmts-io-a05854f5d389f67001b7ecc4cda62c7320433349.tar.bz2 libmts-io-a05854f5d389f67001b7ecc4cda62c7320433349.zip |
Code review
-rw-r--r-- | include/mts/MTS_IO_ME910Radio.h | 2 | ||||
-rw-r--r-- | include/mts/MTS_IO_TelitRadio.h | 1 | ||||
-rw-r--r-- | src/MTS_IO_ME910Radio.cpp | 32 | ||||
-rw-r--r-- | src/MTS_IO_TelitRadio.cpp | 34 |
4 files changed, 33 insertions, 36 deletions
diff --git a/include/mts/MTS_IO_ME910Radio.h b/include/mts/MTS_IO_ME910Radio.h index 09e8ede..93af86f 100644 --- a/include/mts/MTS_IO_ME910Radio.h +++ b/include/mts/MTS_IO_ME910Radio.h @@ -36,8 +36,6 @@ namespace MTS { virtual CODE setRxDiversity(const Json::Value& jArgs); - virtual CODE getFirmwareBuild(std::string& sFirmware); - protected: private: diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 2f20996..d0a70ed 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -30,6 +30,7 @@ namespace MTS { public: bool resetRadio(uint32_t iTimeoutMillis = 5000) override; + CODE getFirmwareBuild(std::string& sFirmwareBuild) override; CODE getModel(std::string& sModel) override; CODE getIccid(std::string& sIccid) override; CODE getService(std::string& sService) override; diff --git a/src/MTS_IO_ME910Radio.cpp b/src/MTS_IO_ME910Radio.cpp index 2b181d2..ad3e7ec 100644 --- a/src/MTS_IO_ME910Radio.cpp +++ b/src/MTS_IO_ME910Radio.cpp @@ -33,35 +33,3 @@ ME910Radio::ME910Radio(const std::string& sME910Model, const std::string& sPort) ICellularRadio::CODE ME910Radio::setRxDiversity(const Json::Value& jArgs) { return FAILURE; } - - -ICellularRadio::CODE ME910Radio::getFirmwareBuild(std::string& sFirmwareBuild) { - std::string sCmd("AT#CFVR"); - - std::string sResult = sendCommand(sCmd); - - size_t end = sResult.find(ICellularRadio::RSP_OK); - if (end == std::string::npos) { - printWarning("%s| Unable to get firmware build number [%s]", - getName().c_str(), - sCmd.c_str()); - return FAILURE; - } - - size_t start = sResult.find("#CFVR:"); - if (start == std::string::npos) { - printWarning("%s| Command returned unexpected response [%s]", - getName().c_str(), - sCmd.c_str()); - return FAILURE; - } - - start += sizeof("#CFVR:"); - - sFirmwareBuild = MTS::Text::trim(sResult.substr(start, end-start)); - if(sFirmwareBuild.size() == 0) { - printWarning("%s| Firmware Build Version is empty", getName().c_str()); - return FAILURE; - } - return SUCCESS; -} diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 8d762be..599c71e 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -51,6 +51,36 @@ bool TelitRadio::resetRadio(uint32_t iTimeoutMillis) { return false; } +ICellularRadio::CODE TelitRadio::getFirmwareBuild(std::string& sFirmwareBuild) { + std::string sCmd("AT#CFVR"); + + std::string sResult = sendCommand(sCmd); + + size_t end = sResult.find(ICellularRadio::RSP_OK); + if (end == std::string::npos) { + printWarning("%s| Unable to get firmware build number [%s]", + getName().c_str(), + sCmd.c_str()); + return FAILURE; + } + + size_t start = sResult.find("#CFVR:"); + if (start == std::string::npos) { + printWarning("%s| Command returned unexpected response [%s]", + getName().c_str(), + sCmd.c_str()); + return FAILURE; + } + + start += sizeof("#CFVR:"); + + sFirmwareBuild = MTS::Text::trim(sResult.substr(start, end-start)); + if(sFirmwareBuild.size() == 0) { + printWarning("%s| Firmware Build Version is empty", getName().c_str()); + return FAILURE; + } + return SUCCESS; +} ICellularRadio::CODE TelitRadio::getModel(std::string& sModel) { printTrace("%s| Get Model", getName().c_str()); @@ -953,11 +983,11 @@ ICellularRadio::CODE TelitRadio::getVendorFirmware(std::string& sVendorFirmware) if (pos != std::string::npos) { // Found std::vector<std::string> vLine = MTS::Text::split(sResult, "\r"); - if(vLine[1].size() == 0) { + 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 { - sVendorFirmware = MTS::Text::trim(vLine[1]); rc = SUCCESS; } break; |