summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMykola Salomatin <mykola.salomatin@globallogic.com>2022-05-04 12:40:15 +0300
committerJohn Klug <john.klug@multitech.com>2022-06-17 10:26:56 -0500
commitdc05152d236dd42dd31206cf2d3f439491b73300 (patch)
tree7ab78bc6273ffa42305c342f1fe71d1ffa1d6779
parent117b5c87afafb24500f820942f5f6724c426ad11 (diff)
downloadlibmts-io-dc05152d236dd42dd31206cf2d3f439491b73300.tar.gz
libmts-io-dc05152d236dd42dd31206cf2d3f439491b73300.tar.bz2
libmts-io-dc05152d236dd42dd31206cf2d3f439491b73300.zip
[MTX-4445] mPower R.6.0.X: MTCAP3: LNA7D - cellular radio support GP-15481.0.29
setRxDiversity command moved to common class for Quectel radios - QuectelRadio.cpp. Add LNA7D radio support. LNA7D radio supports only 3g and 4g network modes. Add new command for enabling/disabling diversity. Retained backward compatibility with the old diversity command.
-rw-r--r--include/mts/MTS_IO_EG25Radio.h1
-rw-r--r--include/mts/MTS_IO_EG95Radio.h1
-rw-r--r--include/mts/MTS_IO_QuectelRadio.h4
-rw-r--r--src/MTS_IO_EG25Radio.cpp11
-rw-r--r--src/MTS_IO_EG95Radio.cpp24
-rw-r--r--src/MTS_IO_ICellularRadio.cpp3
-rw-r--r--src/MTS_IO_QuectelRadio.cpp87
7 files changed, 108 insertions, 23 deletions
diff --git a/include/mts/MTS_IO_EG25Radio.h b/include/mts/MTS_IO_EG25Radio.h
index 46bff20..e05fa7d 100644
--- a/include/mts/MTS_IO_EG25Radio.h
+++ b/include/mts/MTS_IO_EG25Radio.h
@@ -34,7 +34,6 @@ namespace MTS {
EG25Radio(const std::string& sPort);
virtual ~EG25Radio();
- CODE setRxDiversity(const Json::Value& jArgs) override;
protected:
diff --git a/include/mts/MTS_IO_EG95Radio.h b/include/mts/MTS_IO_EG95Radio.h
index 17c413e..6fb47c8 100644
--- a/include/mts/MTS_IO_EG95Radio.h
+++ b/include/mts/MTS_IO_EG95Radio.h
@@ -34,7 +34,6 @@ namespace MTS {
EG95Radio(const std::string& sPort);
virtual ~EG95Radio();
- CODE setRxDiversity(const Json::Value& jArgs) override;
protected:
diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h
index c54e560..bd312b8 100644
--- a/include/mts/MTS_IO_QuectelRadio.h
+++ b/include/mts/MTS_IO_QuectelRadio.h
@@ -83,6 +83,8 @@ namespace MTS {
static bool isContainsSignChar(const std::string& str);
+ CODE setRxDiversity(const Json::Value& jArgs) override;
+
private:
// private variable to save old firmware versions during FOTA
std::string m_sQuectelFirmware;
@@ -117,6 +119,8 @@ namespace MTS {
return vector[index];
}
}
+
+ CODE isDivctlSupported(bool& bSupported);
};
}
}
diff --git a/src/MTS_IO_EG25Radio.cpp b/src/MTS_IO_EG25Radio.cpp
index aa5d453..c6d1c34 100644
--- a/src/MTS_IO_EG25Radio.cpp
+++ b/src/MTS_IO_EG25Radio.cpp
@@ -35,17 +35,6 @@ EG25Radio::~EG25Radio() {
}
-ICellularRadio::CODE EG25Radio::setRxDiversity(const Json::Value& jArgs) {
- /* Command string for EG25 radios: AT+QCFG="diversity",(0-1) */
- if (jArgs["enabled"].asString() != "1" && jArgs["enabled"].asString() != "0") {
- return FAILURE;
- }
- std::string sCmd = "AT+QCFG=\"diversity\",";
- sCmd += jArgs["enabled"].asString();
-
- return sendBasicCommand(sCmd);
-}
-
ICellularRadio::CODE EG25Radio::getSupportedCellularModes(CELLULAR_MODES &networks) {
networks = static_cast<CELLULAR_MODES>(CELLULAR_MODE_2G | CELLULAR_MODE_3G | CELLULAR_MODE_4G);
return SUCCESS;
diff --git a/src/MTS_IO_EG95Radio.cpp b/src/MTS_IO_EG95Radio.cpp
index 296f183..83d6489 100644
--- a/src/MTS_IO_EG95Radio.cpp
+++ b/src/MTS_IO_EG95Radio.cpp
@@ -19,6 +19,7 @@
*/
#include <mts/MTS_IO_EG95Radio.h>
+#include <mts/MTS_Logger.h>
using namespace MTS::IO;
@@ -34,18 +35,21 @@ EG95Radio::~EG95Radio() {
}
-ICellularRadio::CODE EG95Radio::setRxDiversity(const Json::Value& jArgs) {
- /* Command string for EG95 radios: AT+QCFG="diversity",(0-1) */
- if (jArgs["enabled"].asString() != "1" && jArgs["enabled"].asString() != "0") {
- return FAILURE;
+ICellularRadio::CODE EG95Radio::getSupportedCellularModes(CELLULAR_MODES &networks) {
+ std::string sRadioCode;
+ ICellularRadio::CODE iCode;
+
+ iCode = convertModelToMtsShortCode(MODEL_NAME, sRadioCode, this);
+ if (iCode != SUCCESS) {
+ printError("%s| Failed to obtain radio code: [%d]", getName().c_str(), iCode);
+ return iCode;
}
- std::string sCmd = "AT+QCFG=\"diversity\",";
- sCmd += jArgs["enabled"].asString();
- return sendBasicCommand(sCmd);
-}
+ if (sRadioCode == "LNA7D") {
+ networks = static_cast<CELLULAR_MODES>(CELLULAR_MODE_3G | CELLULAR_MODE_4G);
+ } else {
+ networks = static_cast<CELLULAR_MODES>(CELLULAR_MODE_2G | CELLULAR_MODE_3G | CELLULAR_MODE_4G);
+ }
-ICellularRadio::CODE EG95Radio::getSupportedCellularModes(CELLULAR_MODES &networks) {
- networks = static_cast<CELLULAR_MODES>(CELLULAR_MODE_2G | CELLULAR_MODE_3G | CELLULAR_MODE_4G);
return SUCCESS;
} \ No newline at end of file
diff --git a/src/MTS_IO_ICellularRadio.cpp b/src/MTS_IO_ICellularRadio.cpp
index cfb6811..7453662 100644
--- a/src/MTS_IO_ICellularRadio.cpp
+++ b/src/MTS_IO_ICellularRadio.cpp
@@ -207,6 +207,9 @@ MTS::IO::ICellularRadio::CODE MTS::IO::ICellularRadio::convertModelToMtsShortCod
} else if (sValue.find("EG95E") != std::string::npos) {
sCode = "LEU7";
eCode = SUCCESS;
+ } else if (sValue.find("EG95NAXD") != std::string::npos) {
+ sCode = "LNA7D";
+ eCode = SUCCESS;
} else if (sValue.find("EG95NA") != std::string::npos) {
sCode = "LNA7";
eCode = SUCCESS;
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index 9c5b3d5..ae6200e 100644
--- a/src/MTS_IO_QuectelRadio.cpp
+++ b/src/MTS_IO_QuectelRadio.cpp
@@ -1541,3 +1541,90 @@ bool MTS::IO::QuectelRadio::isContainsSignChar(const std::string& str) {
return true;
}
+
+ICellularRadio::CODE QuectelRadio::isDivctlSupported(bool& bSupported) {
+ const std::string sCommand = "AT+QCFG=\"divctl\"";
+ const std::string sLabel = "+QCFG: \"divctl\",";
+ const int dTimeout = 1000; // ms
+ std::string sResult;
+
+ CODE rc;
+
+ rc = sendBasicQuery(sCommand, sLabel, sResult, dTimeout);
+ if (rc == ERROR) {
+ bSupported = false;
+ return SUCCESS;
+ } else if (rc == SUCCESS) {
+ if (sResult.find("(\"lte\",\"wcdma\")") != std::string::npos) {
+ bSupported = true;
+ } else {
+ bSupported = false;
+ }
+ return rc;
+ } else {
+ return rc;
+ }
+}
+
+ICellularRadio::CODE QuectelRadio::setRxDiversity(const Json::Value& jArgs) {
+ if (jArgs["enabled"].asString() != "1" && jArgs["enabled"].asString() != "0") {
+ return FAILURE;
+ }
+
+ ICellularRadio::CODE rc;
+ std::string sCmd;
+ bool bSupported;
+
+ rc = isDivctlSupported(bSupported);
+ if (rc != SUCCESS) {
+ printError("%s| Failed to determine the AT+QCFG=\"divctl\" support: [%d]", getName().c_str(), rc);
+ return rc;
+ }
+
+ if (!bSupported) {
+ /* Old command string for EG95 radios: AT+QCFG="diversity",(0-1) */
+ sCmd = "AT+QCFG=\"diversity\",";
+ sCmd += jArgs["enabled"].asString();
+
+ return sendBasicCommand(sCmd);
+ }
+
+ std::string sValue;
+
+ /* Reverse obtained value because the new command string works in the following way:
+ 0 - enable,
+ 1 - disable, use the main antenna as the only antenna.
+ 2 - disable, use the diversity antenna as the only antenna.
+ */
+ if (jArgs["enabled"].asString() == "1") {
+ sValue = "0";
+ } else {
+ sValue = "1";
+ }
+
+ /* New command string for EG95 radios:
+ AT+QCFG=\"divctl\",\"lte\",(0-2)
+ AT+QCFG=\"divctl\",\"wcdma\",(0-2)
+ */
+ const int dTimeout = 1000; // ms
+
+ sCmd = "AT+QCFG=\"divctl\",\"lte\",";
+ sCmd += sValue;
+
+ rc = sendBasicCommand(sCmd, dTimeout);
+ if (rc != SUCCESS) {
+ printError("%s| Failed to set diversity for LTE network mode: [%d]", getName().c_str(), rc);
+ return rc;
+ }
+
+ sCmd = "AT+QCFG=\"divctl\",\"wcdma\",";
+ sCmd += sValue;
+
+ rc = sendBasicCommand(sCmd, dTimeout);
+ if (rc != SUCCESS) {
+ printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc);
+ return rc;
+ }
+
+ return SUCCESS;
+} \ No newline at end of file