diff options
| author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2019-06-13 10:32:08 +0300 | 
|---|---|---|
| committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2019-06-13 10:32:08 +0300 | 
| commit | c0e937f5a2a31b09f2736f1aeda782ba4ad121e2 (patch) | |
| tree | d1218d23cd3eab04c10bac711fe312ff650566a0 /src/MTS_IO_TelitRadio.cpp | |
| parent | acb40ca0033a48cedfeb118dcc216f60e4dd8c45 (diff) | |
| parent | 123aed7c4be0b88a4726cae5d722d74ebdf93782 (diff) | |
| download | libmts-io-c0e937f5a2a31b09f2736f1aeda782ba4ad121e2.tar.gz libmts-io-c0e937f5a2a31b09f2736f1aeda782ba4ad121e2.tar.bz2 libmts-io-c0e937f5a2a31b09f2736f1aeda782ba4ad121e2.zip | |
Merge branch 'quectel-radio' into quectel-specific
Ported the recent changes made by Maksym
Diffstat (limited to 'src/MTS_IO_TelitRadio.cpp')
| -rw-r--r-- | src/MTS_IO_TelitRadio.cpp | 122 | 
1 files changed, 61 insertions, 61 deletions
| diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index ecd4f36..4fcf836 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -74,10 +74,10 @@ CellularRadio::CODE TelitRadio::getModel(std::string& sModel) {  CellularRadio::CODE TelitRadio::getIccid(std::string& sIccid) {      printTrace("%s| Get ICCID", getName().c_str()); -    sIccid = VALUE_NOT_SUPPORTED; +    sIccid = ICellularRadio::VALUE_NOT_SUPPORTED;      std::string sCmd("AT#CCID");      std::string sResult = CellularRadio::sendCommand(sCmd); -    size_t end = sResult.find(RSP_OK); +    size_t end = sResult.find(ICellularRadio::RSP_OK);      if (end == std::string::npos) {          printWarning("%s| Unable to get ICCID from radio using command [%s]", getName().c_str(), sCmd.c_str());          return FAILURE; @@ -97,10 +97,10 @@ CellularRadio::CODE TelitRadio::getIccid(std::string& sIccid) {  CellularRadio::CODE TelitRadio::getService(std::string& sService) {      printTrace("%s| Get Service", getName().c_str()); -    sService = VALUE_NOT_SUPPORTED; +    sService = ICellularRadio::VALUE_NOT_SUPPORTED;      std::string sCmd("AT#PSNT?");      std::string sResult = CellularRadio::sendCommand(sCmd); -    size_t end = sResult.find(RSP_OK); +    size_t end = sResult.find(ICellularRadio::RSP_OK);      if (end == std::string::npos) {          printWarning("%s| Unable to get Service from radio using command [%s]", getName().c_str(), sCmd.c_str());          return FAILURE; @@ -119,7 +119,7 @@ CellularRadio::CODE TelitRadio::getService(std::string& sService) {              case 2: sService = "WCDMA"; break;              case 3: sService = "HSDPA"; break;              case 4: sService = "LTE"; break; -            default: sService = VALUE_UNKNOWN; break; +            default: sService = ICellularRadio::VALUE_UNKNOWN; break;          }          printDebug("%s| Service ID: [%d][%s]", getName().c_str(), iService, sService.c_str()); @@ -131,11 +131,11 @@ CellularRadio::CODE TelitRadio::getNetwork(std::string& sNetwork) {      Json::Value jData;      printTrace("%s| Get Network", getName().c_str()); -    sNetwork = VALUE_NOT_SUPPORTED; +    sNetwork = ICellularRadio::VALUE_NOT_SUPPORTED;      if(getNetworkStatus(jData) == SUCCESS) { -        if(jData.isMember(KEY_NETWORK)) { -            sNetwork = jData[KEY_NETWORK].asString(); +        if(jData.isMember(ICellularRadio::KEY_NETWORK)) { +            sNetwork = jData[ICellularRadio::KEY_NETWORK].asString();              return SUCCESS;          }      } @@ -271,30 +271,30 @@ CellularRadio::CODE TelitRadio::getNetworkStatus(Json::Value& jData) {          //Country Code and Operator Code          std::vector<std::string> vPLMN = MTS::Text::split(vParts[0], ' ');          if(vPLMN.size() == 2) { -            jData[KEY_MCC] = MTS::Text::strip(vPLMN[0], '"'); -            jData[KEY_MNC] = MTS::Text::strip(vPLMN[1], '"'); +            jData[ICellularRadio::KEY_MCC] = MTS::Text::strip(vPLMN[0], '"'); +            jData[ICellularRadio::KEY_MNC] = MTS::Text::strip(vPLMN[1], '"');          } -        jData[KEY_CHANNEL] = vParts[1]; +        jData[ICellularRadio::KEY_CHANNEL] = vParts[1];      }      if (vParts.size() == GSM_NETWORK_FORMAT ) {          //Parse as GSM Network Format -        jData[KEY_RSSIDBM] = vParts[2]; -        jData[KEY_LAC] =  vParts[3]; -        jData[KEY_RAC] = vParts[4]; -        jData[KEY_TXPWR] = vParts[5]; -        jData[KEY_MM] = vParts[6]; -        jData[KEY_RR] = vParts[7]; -        jData[KEY_NOM] = vParts[8]; -        jData[KEY_CID] = vParts[9]; -        jData[KEY_IMSI] = MTS::Text::strip(vParts[10], '"'); -        jData[KEY_NETWORK] = MTS::Text::strip(vParts[11], '"'); +        jData[ICellularRadio::KEY_RSSIDBM] = vParts[2]; +        jData[ICellularRadio::KEY_LAC] =  vParts[3]; +        jData[ICellularRadio::KEY_RAC] = vParts[4]; +        jData[ICellularRadio::KEY_TXPWR] = vParts[5]; +        jData[ICellularRadio::KEY_MM] = vParts[6]; +        jData[ICellularRadio::KEY_RR] = vParts[7]; +        jData[ICellularRadio::KEY_NOM] = vParts[8]; +        jData[ICellularRadio::KEY_CID] = vParts[9]; +        jData[ICellularRadio::KEY_IMSI] = MTS::Text::strip(vParts[10], '"'); +        jData[ICellularRadio::KEY_NETWORK] = MTS::Text::strip(vParts[11], '"');          if(MTS::Text::parse(iValue, vParts[12]) && convertServiceDomainToString((SERVICEDOMAIN)iValue, sValue) == SUCCESS) { -            jData[KEY_SD] = sValue; +            jData[ICellularRadio::KEY_SD] = sValue;          }          if(MTS::Text::parse(iValue, vParts[13]) && convertActiveBandToString((ACTIVEBAND)iValue, sValue) == SUCCESS) { -            jData[KEY_ABND] = sValue; +            jData[ICellularRadio::KEY_ABND] = sValue;          }        // IN003567 ME910C1 radios have some odd behavior with regards to WCDMA.  The ordering of the fields from #RFSTS are        // the same as LTE up to the 16th field (for ME901C1-WW anyway).  Drop into LTE parsing for ME910C1-WW. @@ -303,36 +303,36 @@ CellularRadio::CODE TelitRadio::getNetworkStatus(Json::Value& jData) {          //Parse as WCDMA Network Format -        jDebug[KEY_PSC] = vParts[2]; -        jDebug[KEY_ECIO] = vParts[3]; -        jDebug[KEY_RSCP] = vParts[4]; +        jDebug[ICellularRadio::KEY_PSC] = vParts[2]; +        jDebug[ICellularRadio::KEY_ECIO] = vParts[3]; +        jDebug[ICellularRadio::KEY_RSCP] = vParts[4]; -        jData[KEY_RSSIDBM] = vParts[5]; -        jData[KEY_LAC] = vParts[6]; -        jData[KEY_RAC] = vParts[7]; +        jData[ICellularRadio::KEY_RSSIDBM] = vParts[5]; +        jData[ICellularRadio::KEY_LAC] = vParts[6]; +        jData[ICellularRadio::KEY_RAC] = vParts[7]; -        jDebug[KEY_TXPWR] = vParts[8]; -        jDebug[KEY_DRX] = vParts[9]; -        jDebug[KEY_MM] = vParts[10]; -        jDebug[KEY_RR] = vParts[11]; -        jDebug[KEY_NOM] = vParts[12]; +        jDebug[ICellularRadio::KEY_TXPWR] = vParts[8]; +        jDebug[ICellularRadio::KEY_DRX] = vParts[9]; +        jDebug[ICellularRadio::KEY_MM] = vParts[10]; +        jDebug[ICellularRadio::KEY_RR] = vParts[11]; +        jDebug[ICellularRadio::KEY_NOM] = vParts[12];          if(vParts[13].size() != 0) { -            jDebug[KEY_BLER] = vParts[13]; +            jDebug[ICellularRadio::KEY_BLER] = vParts[13];          } else { -            jDebug[KEY_BLER] = "000"; +            jDebug[ICellularRadio::KEY_BLER] = "000";          } -        jData[KEY_CID] = vParts[14]; -        jData[KEY_IMSI] = MTS::Text::strip(vParts[15], '"'); -        jData[KEY_NETWORK] = MTS::Text::strip(vParts[16], '"'); +        jData[ICellularRadio::KEY_CID] = vParts[14]; +        jData[ICellularRadio::KEY_IMSI] = MTS::Text::strip(vParts[15], '"'); +        jData[ICellularRadio::KEY_NETWORK] = MTS::Text::strip(vParts[16], '"');          // Get the radio band given the channel (UARFCN) -        RadioBandMap radioBandMap(vParts[1], CellularRadio::VALUE_TYPE_CDMA); -        jData[KEY_ABND] = radioBandMap.getRadioBandName(); +        RadioBandMap radioBandMap(vParts[1], CellularRadio::ICellularRadio::VALUE_TYPE_CDMA); +        jData[ICellularRadio::KEY_ABND] = radioBandMap.getRadioBandName();          if(MTS::Text::parse(iValue, vParts[17]) && convertServiceDomainToString((SERVICEDOMAIN)iValue, sValue) == SUCCESS) { -            jDebug[KEY_SD] = sValue; +            jDebug[ICellularRadio::KEY_SD] = sValue;          }          //Ignoring Active Set Values          //  <nAST> - Number of Active Set (Maximum 6) @@ -340,7 +340,7 @@ CellularRadio::CODE TelitRadio::getNetworkStatus(Json::Value& jData) {          //  <nPSC> - PSC of n th active set          //  <nEc/Io > - Ec/Io of n th active Set -        jData[KEY_DEBUG] = jDebug; +        jData[ICellularRadio::KEY_DEBUG] = jDebug;      } else if(vParts.size() >= LTE_NETWORK_FORMAT) {          Json::Value jDebug; @@ -362,34 +362,34 @@ CellularRadio::CODE TelitRadio::getNetworkStatus(Json::Value& jData) {          //          if (vParts[13].find("\"") != std::string::npos) {              // parse the RAC and then remove it from the vector -            jData[KEY_RAC] = vParts[6]; +            jData[ICellularRadio::KEY_RAC] = vParts[6];              vParts.erase(vParts.begin() + 6);          }          jDebug["rsrp"] = vParts[2]; -        jDebug[KEY_RSSIDBM] = vParts[3]; +        jDebug[ICellularRadio::KEY_RSSIDBM] = vParts[3];          jDebug["rsrq"] = vParts[4];          jData["tac"] = vParts[5]; -        jDebug[KEY_TXPWR] = vParts[6]; -        jData[KEY_DRX] = vParts[7]; -        jDebug[KEY_MM] = vParts[8]; +        jDebug[ICellularRadio::KEY_TXPWR] = vParts[6]; +        jData[ICellularRadio::KEY_DRX] = vParts[7]; +        jDebug[ICellularRadio::KEY_MM] = vParts[8];          jDebug["rrc"] = vParts[9]; -        jData[KEY_CID] = MTS::Text::strip(vParts[10], '"'); -        jData[KEY_IMSI] = MTS::Text::strip(vParts[11], '"'); -        jData[KEY_NETWORK] = MTS::Text::strip(vParts[12], '"'); +        jData[ICellularRadio::KEY_CID] = MTS::Text::strip(vParts[10], '"'); +        jData[ICellularRadio::KEY_IMSI] = MTS::Text::strip(vParts[11], '"'); +        jData[ICellularRadio::KEY_NETWORK] = MTS::Text::strip(vParts[12], '"');          // Get the radio band given the channel (EARFCN) -        RadioBandMap radioBandMap(vParts[1], CellularRadio::VALUE_TYPE_LTE); -        jData[KEY_ABND] = radioBandMap.getRadioBandName(); +        RadioBandMap radioBandMap(vParts[1], ICellularRadio::VALUE_TYPE_LTE); +        jData[ICellularRadio::KEY_ABND] = radioBandMap.getRadioBandName(); -        jData[KEY_LAC] = queryLteLac(); +        jData[ICellularRadio::KEY_LAC] = queryLteLac();          if(MTS::Text::parse(iValue, vParts[13]) && convertServiceDomainToString((SERVICEDOMAIN)iValue, sValue) == SUCCESS) { -            jDebug[KEY_SD] = sValue; +            jDebug[ICellularRadio::KEY_SD] = sValue;          } -        jData[KEY_DEBUG] = jDebug; +        jData[ICellularRadio::KEY_DEBUG] = jDebug;      }      printTrace("%s| Network Status:\n%s\n", getName().c_str(), jData.toStyledString().c_str()); @@ -448,7 +448,7 @@ CellularRadio::CODE TelitRadio::setMdn(const Json::Value& jArgs) {      sCmd += jArgs["mdn"].asString() + "\"";      std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 1000); -    size_t end = sResult.find(RSP_OK); +    size_t end = sResult.find(ICellularRadio::RSP_OK);      if (end == std::string::npos) {          printWarning("%s| Unable to set MDN for radio using command [%s]", getName().c_str(), sCmd.c_str());          return FAILURE; @@ -483,19 +483,19 @@ bool TelitRadio::getCarrierFromFirmware(const std::string& sFirmware, std::strin                  //Good good                  if(cId == '0') { -                    sCarrier = VALUE_CARRIER_SPRINT; +                    sCarrier = ICellularRadio::VALUE_CARRIER_SPRINT;                      bResult = true;                  } else                  if(cId == '1') { -                    sCarrier = VALUE_CARRIER_AERIS; +                    sCarrier = ICellularRadio::VALUE_CARRIER_AERIS;                      bResult = true;                  } else                  if(cId == '2') { -                    sCarrier = VALUE_CARRIER_VERIZON; +                    sCarrier = ICellularRadio::VALUE_CARRIER_VERIZON;                      bResult = true;                  } else                  if(cId == '3') { -                    sCarrier = VALUE_CARRIER_USCELLULAR; +                    sCarrier = ICellularRadio::VALUE_CARRIER_USCELLULAR;                      bResult = true;                  }              } | 
