summaryrefslogtreecommitdiff
path: root/src/MTS_IO_QuectelRadio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r--src/MTS_IO_QuectelRadio.cpp60
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;
+}