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.cpp87
1 files changed, 87 insertions, 0 deletions
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