diff options
author | andrii.davydenko <andrii.davydenko@globallogic.com> | 2021-11-16 11:51:32 +0200 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2022-04-18 13:26:27 -0500 |
commit | 1f7987d546384b6b9ef0079dac5c903148a59210 (patch) | |
tree | 6eaf7db557e91e1f6b6c29885d5fddc3c584c457 /src/MTS_IO_QuectelRadio.cpp | |
parent | 28b673dd4db086f1957c5cdae281f54980715e36 (diff) | |
download | libmts-io-1f7987d546384b6b9ef0079dac5c903148a59210.tar.gz libmts-io-1f7987d546384b6b9ef0079dac5c903148a59210.tar.bz2 libmts-io-1f7987d546384b6b9ef0079dac5c903148a59210.zip |
Update MODBUS slave feature, Rogers Certification issue
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 7a1a1a7..b1e1e59 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -1468,3 +1468,63 @@ ICellularRadio::CODE QuectelRadio::getVoiceSupport(bool& bVoiceEnabled, bool& bS return SUCCESS; } + +ICellularRadio::CODE QuectelRadio::getSelectedBandsRaw(std::string& sRawBands) { + printTrace("%s| Acquiring selected bands", getName().c_str()); + CODE rc; + + const std::string sCommand = "AT+QCFG=\"band\""; + const std::string sLabel = "+QCFG: \"band\","; + const int dTimeout = 1000; + std::string sResult; + + rc = sendBasicQuery(sCommand, sLabel, sResult, dTimeout); + if (rc != SUCCESS) { + return rc; + } + + std::vector<std::string> vParts = MTS::Text::split(sResult, ','); + uint8_t iNumBandParams = 0; + + + if (vParts.size() > 0) { + uint16_t iSelectedBands = 0; + // Duplicate the <GW_band> value to the first two fields + // <GW_band> contains information for both the GSM and WCDMA bands + if (!isContainsSignChar(vParts[0]) && MTS::Text::parseHex(iSelectedBands, MTS::Text::trim(vParts[0])) ) { + sRawBands = MTS::Text::formatHex(iSelectedBands) + "," + MTS::Text::formatHex(iSelectedBands); + iNumBandParams++; + } else { + printWarning("%s| Error during parse number from string: [%s]. Assuming that no GSM and WCDMA bands selected", getName().c_str(), vParts[0].c_str()); + sRawBands = "ffff,ffff"; + } + } else { + sRawBands = "ffff,ffff"; + } + + if (vParts.size() > 1) { + uint64_t iSelectedBands = 0; + if (!isContainsSignChar(vParts[1]) && MTS::Text::parseHex(iSelectedBands, MTS::Text::trim(vParts[1]))) { + sRawBands += "," + MTS::Text::formatHex(iSelectedBands); // LTE bands + iNumBandParams++; + } else { + printWarning("%s| Error during parse number from string: [%s]. Assuming that no LTE bands selected", getName().c_str(), vParts[0].c_str()); + sRawBands += ",ffffffffffffffff"; + } + } else { + sRawBands += ",ffffffffffffffff"; + } + + // All other fragments - ignored for now. + + // Return success if at least one band param was extracted; otherwise failure + return (iNumBandParams > 0) ? SUCCESS : FAILURE; +} + +bool MTS::IO::QuectelRadio::isContainsSignChar(const std::string& str) { + if (str.find_first_of("+-") == std::string::npos) { + return false; + } + + return true; +} |