From dc05152d236dd42dd31206cf2d3f439491b73300 Mon Sep 17 00:00:00 2001 From: Mykola Salomatin Date: Wed, 4 May 2022 12:40:15 +0300 Subject: [MTX-4445] mPower R.6.0.X: MTCAP3: LNA7D - cellular radio support GP-1548 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. --- src/MTS_IO_QuectelRadio.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'src/MTS_IO_QuectelRadio.cpp') 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 -- cgit v1.2.3