diff options
Diffstat (limited to 'src/MTS_IO_CellularRadio.cpp')
| -rw-r--r-- | src/MTS_IO_CellularRadio.cpp | 136 | 
1 files changed, 68 insertions, 68 deletions
| diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index c6ff5af..dbb64a5 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -175,10 +175,10 @@ const std::string& CellularRadio::getName() const {  CellularRadio::CODE CellularRadio::getFirmware(std::string& sFirmware) {      printTrace("%s| Get Firmware", m_sName.c_str()); -    sFirmware = VALUE_NOT_SUPPORTED; +    sFirmware = ICellularRadio::VALUE_NOT_SUPPORTED;      std::string sCmd("AT+CGMR");      std::string sResult = sendCommand(sCmd); -    size_t pos = sResult.find(RSP_OK); +    size_t pos = sResult.find(ICellularRadio::RSP_OK);      if (pos == std::string::npos) {          printWarning("%s| Unable to get firmware from radio using command [%s]", m_sName.c_str(), sCmd.c_str());          return FAILURE; @@ -196,13 +196,13 @@ CellularRadio::CODE CellularRadio::getFirmware(std::string& sFirmware) {  }  CellularRadio::CODE CellularRadio::getFirmwareBuild(std::string& sFirmwareBuild) { -    sFirmwareBuild = VALUE_NOT_SUPPORTED; +    sFirmwareBuild = ICellularRadio::VALUE_NOT_SUPPORTED;      return FAILURE;  }  CellularRadio::CODE CellularRadio::getHardware(std::string& sHardware) {      printTrace("%s| Get Hardware", m_sName.c_str()); -    sHardware = VALUE_NOT_SUPPORTED; +    sHardware = ICellularRadio::VALUE_NOT_SUPPORTED;      if(m_sFirmware.size() == 0) {          getFirmware(m_sFirmware); @@ -216,10 +216,10 @@ CellularRadio::CODE CellularRadio::getHardware(std::string& sHardware) {  CellularRadio::CODE CellularRadio::getManufacturer(std::string& sManufacturer) {      printTrace("%s| Get Manufacturer", m_sName.c_str()); -    sManufacturer = VALUE_NOT_SUPPORTED; +    sManufacturer = ICellularRadio::VALUE_NOT_SUPPORTED;      std::string sCmd("AT+GMI");      std::string sResult = sendCommand(sCmd); -    size_t pos = sResult.find(RSP_OK); +    size_t pos = sResult.find(ICellularRadio::RSP_OK);      if (pos == std::string::npos) {          printWarning("%s| Unable to get manufacturer from radio using command [%s]", m_sName.c_str(), sCmd.c_str());          return FAILURE; @@ -236,10 +236,10 @@ CellularRadio::CODE CellularRadio::getManufacturer(std::string& sManufacturer) {  CellularRadio::CODE CellularRadio::getImei(std::string& sImei) {      printTrace("%s| Get IMEI", m_sName.c_str()); -    sImei = VALUE_NOT_SUPPORTED; +    sImei = ICellularRadio::VALUE_NOT_SUPPORTED;      std::string sCmd("AT+CGSN");      std::string sResult = sendCommand(sCmd); -    size_t pos = sResult.find(RSP_OK); +    size_t pos = sResult.find(ICellularRadio::RSP_OK);      if (pos == std::string::npos) {          printWarning("%s| Unable to get IMEI from radio using command [%s]", m_sName.c_str(), sCmd.c_str());          return FAILURE; @@ -261,10 +261,10 @@ CellularRadio::CODE CellularRadio::getMeid(std::string& sMeid) {  CellularRadio::CODE CellularRadio::getImsi(std::string& sImsi) {      printTrace("%s| Get IMSI", m_sName.c_str()); -    sImsi = VALUE_NOT_SUPPORTED; +    sImsi = ICellularRadio::VALUE_NOT_SUPPORTED;      std::string sCmd("AT+CIMI");      std::string sResult = sendCommand(sCmd); -    size_t pos = sResult.find(RSP_OK); +    size_t pos = sResult.find(ICellularRadio::RSP_OK);      if (pos == std::string::npos) {          printWarning("%s| Unable to get IMSI from radio using command [%s]", m_sName.c_str(), sCmd.c_str());          return FAILURE; @@ -281,7 +281,7 @@ CellularRadio::CODE CellularRadio::getImsi(std::string& sImsi) {  CellularRadio::CODE CellularRadio::getSimStatus(std::string& sSimStatus) {      printTrace("%s| Get SIM Status", getName().c_str()); -    sSimStatus = VALUE_UNKNOWN; +    sSimStatus = ICellularRadio::VALUE_UNKNOWN;      return FAILURE;  } @@ -289,11 +289,11 @@ CellularRadio::CODE CellularRadio::getLac(std::string& sLac) {      Json::Value jData;      printTrace("%s| Get LAC", m_sName.c_str()); -    sLac = VALUE_NOT_SUPPORTED; +    sLac = ICellularRadio::VALUE_NOT_SUPPORTED;      if(getNetworkStatus(jData) == SUCCESS) { -        if(jData.isMember(KEY_LAC)) { -            sLac = jData[KEY_LAC].asString(); +        if(jData.isMember(ICellularRadio::KEY_LAC)) { +            sLac = jData[ICellularRadio::KEY_LAC].asString();              return SUCCESS;          }      } @@ -303,10 +303,10 @@ CellularRadio::CODE CellularRadio::getLac(std::string& sLac) {  CellularRadio::CODE CellularRadio::getMdn(std::string& sMdn) {      printTrace("%s| Get MDN", m_sName.c_str()); -    sMdn = VALUE_NOT_SUPPORTED; +    sMdn = ICellularRadio::VALUE_NOT_SUPPORTED;      std::string sCmd("AT+CNUM");      std::string sResult = 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 MDN from radio using command [%s]", m_sName.c_str(), sCmd.c_str());          return FAILURE; @@ -350,7 +350,7 @@ CellularRadio::CODE CellularRadio::getMsid(std::string& sMsid) {  CellularRadio::CODE CellularRadio::getType(std::string& sType) {      printTrace("%s| Get Type", m_sName.c_str()); -    sType = VALUE_NOT_SUPPORTED; +    sType = ICellularRadio::VALUE_NOT_SUPPORTED;      return FAILURE;  } @@ -359,14 +359,14 @@ CellularRadio::CODE CellularRadio::getCarrier(std::string& sCarrier) {      if(m_sCarrier == "") {          Json::Value jData;          if(getNetworkStatus(jData) == SUCCESS) { -            if(jData.isMember(KEY_MCC) && jData.isMember(KEY_MNC)) { -                std::string sMcc = jData[KEY_MCC].asString(); -                std::string sMnc = jData[KEY_MNC].asString(); +            if(jData.isMember(ICellularRadio::KEY_MCC) && jData.isMember(ICellularRadio::KEY_MNC)) { +                std::string sMcc = jData[ICellularRadio::KEY_MCC].asString(); +                std::string sMnc = jData[ICellularRadio::KEY_MNC].asString();                  Json::Value jLookup = MccMncTable::getInstance()->lookup(sMcc, sMnc);                  printTrace("%s| MCC-MNC Lookup: [%s][%s][%s]", m_sName.c_str(),                             sMcc.c_str(), sMnc.c_str(), jLookup.toStyledString().c_str()); -                if(jLookup.isMember(KEY_CARRIER)) { -                    m_sCarrier = jLookup[KEY_CARRIER].asString(); +                if(jLookup.isMember(ICellularRadio::KEY_CARRIER)) { +                    m_sCarrier = jLookup[ICellularRadio::KEY_CARRIER].asString();                  } else {                      printWarning("%s| MCC-MNC Lookup did not contain carrier", m_sName.c_str());                      return FAILURE; @@ -388,11 +388,11 @@ CellularRadio::CODE CellularRadio::getTower(std::string& sTower) {      Json::Value jData;      printTrace("%s| Get Tower", m_sName.c_str()); -    sTower = VALUE_NOT_SUPPORTED; +    sTower = ICellularRadio::VALUE_NOT_SUPPORTED;      if(getNetworkStatus(jData) == SUCCESS) { -        if(jData.isMember(KEY_CID)) { -            sTower = jData[KEY_CID].asString(); +        if(jData.isMember(ICellularRadio::KEY_CID)) { +            sTower = jData[ICellularRadio::KEY_CID].asString();              return SUCCESS;          }      } @@ -409,7 +409,7 @@ CellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTim      std::string sCmd("AT+CCLK?");      std::string sResult = 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 Time from radio using command [%s]", m_sName.c_str(), sCmd.c_str());          return FAILURE; @@ -636,7 +636,7 @@ std::string CellularRadio::queryLteLac() {      std::string result;      CGREGstring = queryCGREGstring(); -    if (CGREGstring == RSP_ERROR) { +    if (CGREGstring == ICellularRadio::RSP_ERROR) {          originalCGREG = "0";      } else {          originalCGREG = CGREGstring.at(CGREGstring.find(",") - 1); //Position right before first comma ("+CGREG: 0,1") @@ -646,13 +646,13 @@ std::string CellularRadio::queryLteLac() {      setCGREG("2");      CGREGstring = queryCGREGstring(); -    if (CGREGstring == RSP_ERROR) { -        result = VALUE_UNKNOWN; +    if (CGREGstring == ICellularRadio::RSP_ERROR) { +        result = ICellularRadio::VALUE_UNKNOWN;      } else {          size_t start = CGREGstring.find(":") + 1; //Position right after "+CGREG:"          std::vector<std::string> vParts = MTS::Text::split(MTS::Text::trim(CGREGstring.substr(start)), ",");          if(vParts.size() < 3) { -            result = VALUE_UNAVAILABLE; +            result = ICellularRadio::VALUE_UNAVAILABLE;          } else {              result = MTS::Text::strip(vParts[2], '"');          } @@ -676,7 +676,7 @@ std::string CellularRadio::queryCGREGstring() {      std::string cmdResult(sendCommand(sCmd));      if (cmdResult.find("+CGREG:") == std::string::npos) {          printDebug("%s| AT+CGREG? returned unexpected response: [%s][%s]", m_sName.c_str(), sCmd.c_str(), cmdResult.c_str()); -        return RSP_ERROR; +        return ICellularRadio::RSP_ERROR;      }      return cmdResult;  } @@ -685,48 +685,48 @@ void CellularRadio::getCommonNetworkStats(Json::Value& jData) {      bool bRoaming = false;      if(getRoaming(bRoaming) == SUCCESS) { -        jData[KEY_ROAMING] = bRoaming; +        jData[ICellularRadio::KEY_ROAMING] = bRoaming;      }      int32_t iRssi;      if(getSignalStrength(iRssi) == SUCCESS) { -        jData[KEY_RSSI] = iRssi; +        jData[ICellularRadio::KEY_RSSI] = iRssi;          int32_t dBm; -        if(!jData.isMember(KEY_RSSIDBM) && convertSignalStrengthTodBm(iRssi, dBm) == SUCCESS) { +        if(!jData.isMember(ICellularRadio::KEY_RSSIDBM) && convertSignalStrengthTodBm(iRssi, dBm) == SUCCESS) {              //Add RSSI in dBm format -            jData[KEY_RSSIDBM] = MTS::Text::format(dBm); +            jData[ICellularRadio::KEY_RSSIDBM] = MTS::Text::format(dBm);          }      }      std::string sService;      if(getService(sService) == SUCCESS) { -        jData[KEY_SERVICE] = sService; +        jData[ICellularRadio::KEY_SERVICE] = sService;      }      std::string sDate, sTime, sTimeZone;      if(getTime(sDate, sTime, sTimeZone) == SUCCESS) { -        jData[KEY_DATETIME] = sDate + " " + sTime + " GMT" + sTimeZone; +        jData[ICellularRadio::KEY_DATETIME] = sDate + " " + sTime + " GMT" + sTimeZone;      }      std::string sNetworkReg;      REGISTRATION eReg;      if (getRegistration(eReg) == SUCCESS) {          if (convertRegistrationToString(eReg, sNetworkReg) == SUCCESS) { -            jData[KEY_NETWORK_REG] = sNetworkReg; +            jData[ICellularRadio::KEY_NETWORK_REG] = sNetworkReg;          }      }  }  void CellularRadio::initMipProfile(Json::Value& jData) { -    jData[KEY_MIP_ID] = 0; -    jData[KEY_MIP_ENABLED] = false; -    jData[KEY_MIP_NAI] = VALUE_UNKNOWN; -    jData[KEY_MIP_HOMEADDRESS] = VALUE_UNKNOWN; -    jData[KEY_MIP_PRIMARYHA] = VALUE_UNKNOWN; -    jData[KEY_MIP_SECONDARYHA] = VALUE_UNKNOWN; -    jData[KEY_MIP_MNAAASPI] = VALUE_UNKNOWN; -    jData[KEY_MIP_MNHASPI] = VALUE_UNKNOWN; -    jData[KEY_MIP_MNAAASS] = false; -    jData[KEY_MIP_MNHASS] = false; +    jData[ICellularRadio::KEY_MIP_ID] = 0; +    jData[ICellularRadio::KEY_MIP_ENABLED] = false; +    jData[ICellularRadio::KEY_MIP_NAI] = ICellularRadio::VALUE_UNKNOWN; +    jData[ICellularRadio::KEY_MIP_HOMEADDRESS] = ICellularRadio::VALUE_UNKNOWN; +    jData[ICellularRadio::KEY_MIP_PRIMARYHA] = ICellularRadio::VALUE_UNKNOWN; +    jData[ICellularRadio::KEY_MIP_SECONDARYHA] = ICellularRadio::VALUE_UNKNOWN; +    jData[ICellularRadio::KEY_MIP_MNAAASPI] = ICellularRadio::VALUE_UNKNOWN; +    jData[ICellularRadio::KEY_MIP_MNHASPI] = ICellularRadio::VALUE_UNKNOWN; +    jData[ICellularRadio::KEY_MIP_MNAAASS] = false; +    jData[ICellularRadio::KEY_MIP_MNHASS] = false;  }  CellularRadio::CODE CellularRadio::getRegistration(REGISTRATION& eRegistration) { @@ -767,12 +767,12 @@ CellularRadio::CODE CellularRadio::convertRegistrationToString(REGISTRATION eReg      CODE eCode = FAILURE;      switch (eRegistration) { -        case NOT_REGISTERED: sRegistration = VALUE_NOT_REGISTERED; eCode = SUCCESS; break; -        case REGISTERED: sRegistration = VALUE_REGISTERED; eCode = SUCCESS; break; -        case SEARCHING: sRegistration = VALUE_SEARCHING; eCode = SUCCESS; break; -        case DENIED: sRegistration = VALUE_DENIED; eCode = SUCCESS; break; -        case UNKNOWN: sRegistration = VALUE_UNKNOWN; eCode = SUCCESS; break; -        case ROAMING: sRegistration = VALUE_ROAMING; eCode = SUCCESS; break; +        case NOT_REGISTERED: sRegistration = ICellularRadio::VALUE_NOT_REGISTERED; eCode = SUCCESS; break; +        case REGISTERED: sRegistration = ICellularRadio::VALUE_REGISTERED; eCode = SUCCESS; break; +        case SEARCHING: sRegistration = ICellularRadio::VALUE_SEARCHING; eCode = SUCCESS; break; +        case DENIED: sRegistration = ICellularRadio::VALUE_DENIED; eCode = SUCCESS; break; +        case UNKNOWN: sRegistration = ICellularRadio::VALUE_UNKNOWN; eCode = SUCCESS; break; +        case ROAMING: sRegistration = ICellularRadio::VALUE_ROAMING; eCode = SUCCESS; break;      }      return eCode;  } @@ -893,7 +893,7 @@ CellularRadio::CODE CellularRadio::setActiveFirmware(const Json::Value&) {  CellularRadio::CODE CellularRadio::getActiveFirmware(std::string& sFwId) {      printTrace("%s| Get Active Firmware Image Number: not applicable", m_sName.c_str()); -    sFwId = VALUE_NOT_SUPPORTED; +    sFwId = ICellularRadio::VALUE_NOT_SUPPORTED;      return NOT_APPLICABLE;  } @@ -902,9 +902,9 @@ CellularRadio::CODE CellularRadio::sendBasicCommand(const std::string& sCmd, int      std::string response = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, iTimeoutMillis, ESC);      if (response.size() == 0) {          return NO_RESPONSE; -    } else if (response.find(RSP_OK) != std::string::npos) { +    } else if (response.find(ICellularRadio::RSP_OK) != std::string::npos) {          return SUCCESS; -    } else if (response.find(RSP_ERROR) != std::string::npos) { +    } else if (response.find(ICellularRadio::RSP_ERROR) != std::string::npos) {          return ERROR;      } else {          return FAILURE; @@ -959,7 +959,7 @@ const char *CellularRadio::RadioBandMap::getLTEBand(const int32_t channel)              return EULTRAband[ii].name;          }      } -    return VALUE_UNKNOWN; +    return ICellularRadio::VALUE_UNKNOWN;  }  const char *CellularRadio::RadioBandMap::getCDMABand(const int channel) @@ -971,7 +971,7 @@ const char *CellularRadio::RadioBandMap::getCDMABand(const int channel)              return WCDMAband[ii].name;          }      } -    return VALUE_UNKNOWN; +    return ICellularRadio::VALUE_UNKNOWN;  }  const char *CellularRadio::RadioBandMap::getGSMBand(const int channel) @@ -983,22 +983,22 @@ const char *CellularRadio::RadioBandMap::getGSMBand(const int channel)              return GSMband[ii].name;          }      } -    return VALUE_UNKNOWN; +    return ICellularRadio::VALUE_UNKNOWN;  }  const char *CellularRadio::RadioBandMap::getRadioBandName()  { -    const char *band = CellularRadio::VALUE_UNKNOWN; +    const char *band = ICellularRadio::VALUE_UNKNOWN; -    if (m_sRadioType == VALUE_TYPE_LTE) +    if (m_sRadioType == ICellularRadio::VALUE_TYPE_LTE)      {          band = getLTEBand(m_iChannel);      } -    else if (m_sRadioType == VALUE_TYPE_CDMA) +    else if (m_sRadioType == ICellularRadio::VALUE_TYPE_CDMA)      {          band = getCDMABand(m_iChannel);      } -    else if (m_sRadioType == VALUE_TYPE_GSM) +    else if (m_sRadioType == ICellularRadio::VALUE_TYPE_GSM)      {          band = getGSMBand(m_iChannel);      } @@ -1008,17 +1008,17 @@ const char *CellularRadio::RadioBandMap::getRadioBandName()  const char *CellularRadio::RadioBandMap::getRadioBandName(const std::string &channel, const std::string &radioType)  { -    const char *band = VALUE_UNKNOWN; +    const char *band = ICellularRadio::VALUE_UNKNOWN;      int32_t chan = strtol(channel.c_str(), NULL, 10); -    if (radioType == VALUE_TYPE_LTE) +    if (radioType == ICellularRadio::VALUE_TYPE_LTE)      {          band = getLTEBand(chan);      } -    else if (radioType == VALUE_TYPE_CDMA) +    else if (radioType == ICellularRadio::VALUE_TYPE_CDMA)      {          band = getCDMABand(chan);      } -    else if (radioType == VALUE_TYPE_GSM) +    else if (radioType == ICellularRadio::VALUE_TYPE_GSM)      {          band = getGSMBand(chan);      } | 
