diff options
| author | Jeff Hatch <jhatch@multitech.com> | 2022-05-04 16:09:39 -0500 | 
|---|---|---|
| committer | Jeff Hatch <jhatch@multitech.com> | 2022-05-04 16:09:39 -0500 | 
| commit | 9436716e2fbb28938dba10e13bc84c60105cf907 (patch) | |
| tree | 7ab78bc6273ffa42305c342f1fe71d1ffa1d6779 /src | |
| parent | 1f7987d546384b6b9ef0079dac5c903148a59210 (diff) | |
| parent | 47997c0e5aa7d32ddbba22ceead2ff553881c47c (diff) | |
| download | libmts-io-9436716e2fbb28938dba10e13bc84c60105cf907.tar.gz libmts-io-9436716e2fbb28938dba10e13bc84c60105cf907.tar.bz2 libmts-io-9436716e2fbb28938dba10e13bc84c60105cf907.zip | |
Merge branch 'ms/MTX-4445_LNA7D_Cellular_radio_support' into 'master'
[MTX-4445] mPower R.6.0.X: MTCAP3: LNA7D - cellular radio support GP-1548
See merge request !48
Diffstat (limited to 'src')
| -rw-r--r-- | src/MTS_IO_EG25Radio.cpp | 11 | ||||
| -rw-r--r-- | src/MTS_IO_EG95Radio.cpp | 24 | ||||
| -rw-r--r-- | src/MTS_IO_ICellularRadio.cpp | 3 | ||||
| -rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 100 | 
4 files changed, 117 insertions, 21 deletions
| 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 b1e1e59..ae6200e 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -1044,6 +1044,7 @@ uint16_t QuectelRadio::getQuectelChecksum(const void* data, size_t nBytes) {  ICellularRadio::CODE QuectelRadio::fumoWaitUpgradeFinished(ICellularRadio::UpdateCb& stepCb) {      const uint32_t duUrcTimeout = 4 * 60 * 1000;  // wait for 4 minutes for the next URC message +    const uint32_t duAttachTimeout = 30 * 1000;  // wait up to 30 seconds for the radio to attach      const std::string sFotaUrcPrefix = "+QIND: \"FOTA\"";  // prefix for the URC notification messages      const std::string sFotaUrcStart = "\"START\"";      const std::string sFotaUrcProgress = "\"UPDATING\""; @@ -1058,6 +1059,18 @@ ICellularRadio::CODE QuectelRadio::fumoWaitUpgradeFinished(ICellularRadio::Updat          sResponse = waitResponse(vFotaBailStrings, duUrcTimeout);          printTrace("Radio response: [%s]", sResponse.c_str()); +        if (sResponse.empty()) { +            // Radio detached again. Try to reconnect +            if (!resetConnection(duAttachTimeout)) { +                printError("Can't connect to the radio in %d ms", (duAttachTimeout)); +                callNextStep(stepCb, "FUMO Error: unable to obtain radio after second reset"); +                return ERROR; +            } + +            sResponse = waitResponse(vFotaBailStrings, duUrcTimeout); +            printTrace("Radio response: [%s]", sResponse.c_str()); +        } +          if (sResponse.find(sFotaUrcPrefix) == std::string::npos) {              printError("No URC messages from the radio in %d ms", duUrcTimeout);              callNextStep(stepCb, "FUMO Error: timeout, radio is not responding"); @@ -1528,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 | 
