diff options
| author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2019-06-12 13:45:44 +0300 | 
|---|---|---|
| committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2019-06-12 15:43:51 +0300 | 
| commit | 6647e6fbb8f742727229309c9372d6c66291f805 (patch) | |
| tree | ecaa23ccf8acb30aa0301b0fb3961cc0a3e35392 /src | |
| parent | 2f451104dc4a5b3459ecf4ffade49efa55e2c454 (diff) | |
| download | libmts-io-6647e6fbb8f742727229309c9372d6c66291f805.tar.gz libmts-io-6647e6fbb8f742727229309c9372d6c66291f805.tar.bz2 libmts-io-6647e6fbb8f742727229309c9372d6c66291f805.zip | |
[MTS-MTQ] QuectelRadio implementation
Fixes and improvements
- Corrected the format of getNetwork output
- Fixed pasrsing for the trailing values in QuectelRadio::getNetworkStatus (removed extra characters)
- Removed empty "debug" field from QuectelRadio::getNetworkStatus output in GSM mode
- Corrected parsing in the QuectelRadio::getServiceDomain
- Corrected parsing in the QuectelRadio::getService
- Corrected target fields for Service Domain value in QuectelRadio::getNetworkStatus
Diffstat (limited to 'src')
| -rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 37 | 
1 files changed, 27 insertions, 10 deletions
| diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 414cd98..6c6ab4b 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -105,8 +105,9 @@ CellularRadio::CODE QuectelRadio::getService(std::string& sService) {      }      // +COPS: <mode>[,<format>[,<oper>][,<Act>]] +    // %*[^,] in scanf - ignore all symbols until next comma      int32_t iAccessTechnology = -1; -    sscanf(sResult.c_str(), "%*d,%*d,%*s,%d", &iAccessTechnology); +    sscanf(sResult.c_str(), "+COPS: %*d,%*d,%*[^,],%d", &iAccessTechnology);      switch(iAccessTechnology) {          case   0 : sService = "GPRS"  ; break;  // GSM @@ -156,7 +157,13 @@ CellularRadio::CODE QuectelRadio::getNetwork(std::string& sNetwork) {      std::vector<std::string> vParts = MTS::Text::split(MTS::Text::trim(sResult.substr(start)), ",");      if(vParts.size() > 3) { -        sNetwork = vParts[2]; +        const std::string sValue = vParts[2]; + +        // +COPS: 0,0,"CHN-UNICOM UNICOM",7 +        //             ^start    ^end +        size_t start = sValue.find("\"") + 1; +        size_t end = sValue.find(" ", start); +        sNetwork = sValue.substr(start, end-start);      } else {          sNetwork = "";  // Not connected to any network      } @@ -218,11 +225,6 @@ CellularRadio::CODE QuectelRadio::getNetworkStatus(Json::Value& jData) {          jData[KEY_NETWORK] = sValue;      } -    // Service Domain is not provided by AT+QENG. Fetch it separately to keep the same interface -    if (getServiceDomain(sd) == SUCCESS && convertServiceDomainToString(sd, sValue) == SUCCESS) { -        jData[KEY_SD] = sValue; -    } -      std::string sCmd;      std::string sResult; @@ -235,7 +237,8 @@ CellularRadio::CODE QuectelRadio::getNetworkStatus(Json::Value& jData) {      }      size_t start = sResult.find(":") + 1; //Position right after "+QENG:" -    std::vector<std::string> vParts = MTS::Text::split(MTS::Text::trim(sResult.substr(start)), ","); +    size_t end = sResult.rfind(RSP_OK); +    std::vector<std::string> vParts = MTS::Text::split(MTS::Text::trim(sResult.substr(start, end-start)), ",");      Json::Value jDebug;      Json::Value jQuectelDebug; @@ -288,10 +291,14 @@ CellularRadio::CODE QuectelRadio::getNetworkStatus(Json::Value& jData) {          jQuectelDebug["rxqualfull"] = vParts[25];          jQuectelDebug["voicecodec"] = vParts[26]; +        // Service Domain is not provided by AT+QENG. Fetch it separately to keep the same interface +        if (getServiceDomain(sd) == SUCCESS && convertServiceDomainToString(sd, sValue) == SUCCESS) { +            jData[KEY_SD] = sValue; +        } +          // The following fields can NOT be fetched for Quectel in GSM mode: RAC, MM, RR, NOM          jData["quectelDebug"] = jQuectelDebug; -        jData[KEY_DEBUG] = jDebug;      }      // +QENG:"servingcell",<state>,"WCDMA",<mcc>,<mnc>,<lac>,<cellid>,<uarfcn>,<psc>,<rac>,<rscp>,<ecio>,<phych>,<sf>,<slot>,<speech_code>,<comMod> @@ -317,6 +324,11 @@ CellularRadio::CODE QuectelRadio::getNetworkStatus(Json::Value& jData) {          // RSSI is not provided by AT+QENG in WCDMA mode. It was filled above by the getCommonNetworkStats +        // Service Domain is not provided by AT+QENG. Fetch it separately to keep the same interface +        if (getServiceDomain(sd) == SUCCESS && convertServiceDomainToString(sd, sValue) == SUCCESS) { +            jDebug[KEY_SD] = sValue; +        } +          // BLER is not provided by AT+QENG. Set to constant          jDebug[KEY_BLER] = "000"; @@ -352,6 +364,11 @@ CellularRadio::CODE QuectelRadio::getNetworkStatus(Json::Value& jData) {          RadioBandMap radioBandMap(vParts[8], CellularRadio::VALUE_TYPE_LTE);          jData[KEY_ABND] = radioBandMap.getRadioBandName(); +        // Service Domain is not provided by AT+QENG. Fetch it separately to keep the same interface +        if (getServiceDomain(sd) == SUCCESS && convertServiceDomainToString(sd, sValue) == SUCCESS) { +            jDebug[KEY_SD] = sValue; +        } +          // LAC is not provided by AT+QENG in WCDMA mode. Use another command instead          jData[KEY_LAC] = queryLteLac(); @@ -425,7 +442,7 @@ CellularRadio::CODE QuectelRadio::getServiceDomain(CellularRadio::SERVICEDOMAIN&      // +QCFG: "servicedomain",<service>      size_t start = sResult.find(",") + 1;  // Position right after comma -    std::string sServiceDomain = MTS::Text::trim(sResult.substr(start, end)); +    std::string sServiceDomain = MTS::Text::trim(sResult.substr(start, end-start));      int iValue = -1;      if (!MTS::Text::parse(iValue, sServiceDomain)) { | 
