diff options
author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-07-17 02:51:22 -0500 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-07-17 02:51:22 -0500 |
commit | d520358b3e88ae80af968254b42645c4d9eae604 (patch) | |
tree | d6c9c3f1f23de7e215fca1dbbe4f38b3c4a09815 /src/MTS_IO_TelitRadio.cpp | |
parent | f0be0e4a343f9a600fe8c9fc34fa580c548a4e9e (diff) | |
parent | 298efe4e17d3665f9ddbb9298a37b563c60de735 (diff) | |
download | libmts-io-d520358b3e88ae80af968254b42645c4d9eae604.tar.gz libmts-io-d520358b3e88ae80af968254b42645c4d9eae604.tar.bz2 libmts-io-d520358b3e88ae80af968254b42645c4d9eae604.zip |
Merge branch 'ap/vendor_firmware' into 'delta-radio-fwu'
Add vendor firmware version
See merge request !29
Diffstat (limited to 'src/MTS_IO_TelitRadio.cpp')
-rw-r--r-- | src/MTS_IO_TelitRadio.cpp | 113 |
1 files changed, 76 insertions, 37 deletions
diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 52b5664..a82004c 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -51,6 +51,80 @@ 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::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()); @@ -789,7 +863,7 @@ ICellularRadio::CODE TelitRadio::fumoLocalApply(ICellularRadio::UpdateCb& stepCb std::string sCmd; FOTA_GROUP group = getFotaGroup(); - rc = getTelitFirmware(m_sTelitFirmware); + rc = getVendorFirmware(m_sTelitFirmware); if (rc != SUCCESS) { callNextStep(stepCb, "FUMO Error: Failed to obtain current firmware version"); return rc; @@ -938,41 +1012,6 @@ ICellularRadio::CODE TelitRadio::abortWrite() { return sendBasicCommand(CMD_ABORT_UPLOAD, 2000, 0x00); } -ICellularRadio::CODE TelitRadio::getTelitFirmware(std::string& sFirmware) { - /* - * Currently, AT+CGMR command is used to determine the radio firmware version. - * - * AT+CGMR - * M0F.670006 - * - * Perhaps in the future we will use AT#SWPKGV command. - * - * AT#SWPKGV - * 25.20.676-P0F.670690 - * M0F.670006 - * P0F.670690 - * A0F.670006 - */ - - printTrace("%s| Get Telit-specific firmware version", getName().c_str()); - sFirmware = ICellularRadio::VALUE_NOT_SUPPORTED; - std::string sCmd("AT+CGMR"); - 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; - } - - sFirmware = MTS::Text::trim(sResult.substr(0, pos)); - if(sFirmware.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 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 @@ -1026,7 +1065,7 @@ ICellularRadio::CODE TelitRadio::fumoCheckNewFirmware(ICellularRadio::UpdateCb& CODE rc = SUCCESS; std::string sTelitFirmware; - rc = getTelitFirmware(sTelitFirmware); + rc = getVendorFirmware(sTelitFirmware); if (rc != SUCCESS) { callNextStep(stepCb, "FUMO Error: Failed to obtain current firmware version"); |