diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/MTS_IO_CellularRadio.cpp | 145 | ||||
-rw-r--r-- | src/MTS_IO_TelitRadio.cpp | 85 |
2 files changed, 48 insertions, 182 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 66d44a0..c6ff5af 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -488,21 +488,6 @@ CellularRadio::CODE CellularRadio::getRoaming(bool& bRoaming) { return FAILURE; } -CellularRadio::CODE CellularRadio::getNetwork(std::string& sNetwork) { - Json::Value jData; - - printTrace("%s| Get Network", m_sName.c_str()); - sNetwork = VALUE_NOT_SUPPORTED; - - if(getNetworkStatus(jData) == SUCCESS) { - if(jData.isMember(KEY_NETWORK)) { - sNetwork = jData[KEY_NETWORK].asString(); - return SUCCESS; - } - } - return FAILURE; -} - CellularRadio::CODE CellularRadio::getSignalStrength(int32_t& rssi) { printTrace("%s| Get Signal Strength", m_sName.c_str()); std::string sCmd("AT+CSQ"); @@ -531,47 +516,6 @@ CellularRadio::CODE CellularRadio::getModemLocation(std::string&) { return FAILURE; } -CellularRadio::CODE CellularRadio::convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& iDbm) { - - //Telit Conversion - if(iRssi < 0 || iRssi == 99) { - return FAILURE; - } - - if(iRssi == 0) { - iDbm = -113; - } else if(iRssi == 1) { - iDbm = -111; - } else if(iRssi <= 30) { - //28 steps between 2 and 30 - //54 dbm between 53 and 109 - float stepSize = 54.0 / 28.0; - iDbm = -109 + (int)(stepSize * (iRssi-2)); - } else { - iDbm = -51; - } - - return SUCCESS; -} - -CellularRadio::CODE CellularRadio::convertdBmToSignalStrength(const int32_t& iDBm, int32_t& iRssi) { - //Telit Conversion - if(iDBm <= -113) { - iRssi = 0; - } else if(iDBm <= -111) { - iRssi = 1; - } else if(iDBm <= -53) { - //54 dbm between -109 and -53 - //28 steps between 2 and 30 - float stepSize = 28.0/54.0; - iRssi = ((iDBm + 109)*stepSize) + 2; - } else { - iRssi = 31; - } - - return SUCCESS; -} - CellularRadio::CODE CellularRadio::getEcho(bool& bEnabled) { printTrace("%s| Echo Test", m_sName.c_str()); std::string sResult = sendCommand("AT"); @@ -685,7 +629,7 @@ CellularRadio::CODE CellularRadio::getStaticInformation(Json::Value& jData) { <ABND> - */ -// Get the LAC for the LTE radio that's not in the #RFSTS response +// Get the LAC for the LTE radio that's not in the #RFSTS or +QENG response std::string CellularRadio::queryLteLac() { std::string CGREGstring; std::string originalCGREG; @@ -705,7 +649,7 @@ std::string CellularRadio::queryLteLac() { if (CGREGstring == RSP_ERROR) { result = VALUE_UNKNOWN; } else { - size_t start = CGREGstring.find(":") + 1; //Position right after "#RFSTS:" + 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; @@ -723,7 +667,7 @@ void CellularRadio::setCGREG(std::string value) { std::string sCmd("AT+CGREG=" + value); std::string cmdResult(sendCommand(sCmd)); if (cmdResult.find("OK") == std::string::npos) { - printDebug("%s| AT#CGREG=%s returned unexpected response: [%s][%s]", m_sName.c_str(), value.c_str(), sCmd.c_str(), cmdResult.c_str()); + printDebug("%s| AT+CGREG=%s returned unexpected response: [%s][%s]", m_sName.c_str(), value.c_str(), sCmd.c_str(), cmdResult.c_str()); } } @@ -731,7 +675,7 @@ std::string CellularRadio::queryCGREGstring() { std::string sCmd("AT+CGREG?"); 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()); + printDebug("%s| AT+CGREG? returned unexpected response: [%s][%s]", m_sName.c_str(), sCmd.c_str(), cmdResult.c_str()); return RSP_ERROR; } return cmdResult; @@ -1006,87 +950,6 @@ bool CellularRadio::splitAndAssign(const std::string& sLine, const std::string& return true; } -bool CellularRadio::getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) { - // Telit Radios - // H.ab.zyx => 3 Main Components - // "H" = Hardware -> 15 = DE910 family, 18 = CE910 family, 12 = HE910 family - // "a" = Hardware version - // "b" = Software Major Version - // "z" = is the product type, i.e. DUAL or SC - // "y" = is the carrier variant - // "x" = is the firmware version - // Telit will do their best to keep the carrier variant as "0" for Sprint, "1" for Aeris, "2" for Verizon, and "3" for U.S. Cellular. - - const uint32_t CARRIER_INDEX = 1; //y in [zyx] - - bool bResult = false; - std::vector<std::string> vParts = MTS::Text::split(sFirmware, '.'); - - if(vParts.size() == 3) { - //CDMA firmware version notation - if(vParts[0] == "15" || vParts[0] == "18") { - //DE910 or CE910 -> Good good - std::string sID = vParts[2]; - if(sID.size() == 3) { - char cId = sID[CARRIER_INDEX]; - - //Good good - if(cId == '0') { - sCarrier = VALUE_CARRIER_SPRINT; - bResult = true; - } else - if(cId == '1') { - sCarrier = VALUE_CARRIER_AERIS; - bResult = true; - } else - if(cId == '2') { - sCarrier = VALUE_CARRIER_VERIZON; - bResult = true; - } else - if(cId == '3') { - sCarrier = VALUE_CARRIER_USCELLULAR; - bResult = true; - } - } - } - } - - return bResult; -} - -bool CellularRadio::getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) { - // Telit Radios - // H.ab.zyx => 3 Main Components - // "H" = Hardware -> 15 = DE910 family, 18 = CE910 family, 12 = HE910 family - // "a" = Hardware version - // "b" = Software Major Version - // "z" = is the product type, i.e. DUAL or SC - // "y" = is the carrier variant - // "x" = is the firmware version - // Telit will do their best to keep the carrier variant as "0" for Sprint, "1" for Aeris, and "2" for Verizon. - - const uint32_t HARDWARE_INDEX = 0; //a in [ab] - - bool bResult = false; - std::vector<std::string> vParts = MTS::Text::split(sFirmware, '.'); - - if(vParts.size() == 3) { - //GSM Hardware Version - if(!(vParts[0] == "15" || vParts[0] == "18")) { - //Not DE910 or CE910 -> Good good - std::string sVersion = vParts[1]; - if(sVersion.size() == 2) { - sHardware = "1."; - sHardware += sVersion[HARDWARE_INDEX]; - bResult = true; - } - } - } - - return bResult; - -} - const char *CellularRadio::RadioBandMap::getLTEBand(const int32_t channel) { for (unsigned int ii = 0; ii < NUM_LTE_BANDS; ii++) diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index ee96ff2..ecd4f36 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -127,6 +127,21 @@ CellularRadio::CODE TelitRadio::getService(std::string& sService) { return SUCCESS; } +CellularRadio::CODE TelitRadio::getNetwork(std::string& sNetwork) { + Json::Value jData; + + printTrace("%s| Get Network", getName().c_str()); + sNetwork = VALUE_NOT_SUPPORTED; + + if(getNetworkStatus(jData) == SUCCESS) { + if(jData.isMember(KEY_NETWORK)) { + sNetwork = jData[KEY_NETWORK].asString(); + return SUCCESS; + } + } + return FAILURE; +} + /* AT#RFSTS - NETWORK STATUS (GSM network) @@ -381,57 +396,45 @@ CellularRadio::CODE TelitRadio::getNetworkStatus(Json::Value& jData) { return SUCCESS; } +CellularRadio::CODE TelitRadio::convertSignalStrengthTodBm(const int32_t& iRssi, int32_t& iDbm) { -// Get the LAC for the LTE radio that's not in the #RFSTS response -std::string TelitRadio::queryLteLac() { - std::string CGREGstring; - std::string originalCGREG; - std::string result; - - CGREGstring = queryCGREGstring(); - if (CGREGstring == RSP_ERROR) { - originalCGREG = "0"; - } else { - originalCGREG = CGREGstring.at(CGREGstring.find(",") - 1); //Position right before first comma ("+CGREG: 0,1") + //Telit Conversion + if(iRssi < 0 || iRssi == 99) { + return FAILURE; } - // Temporarily set CGREG=2 to get more info - setCGREG("2"); - - CGREGstring = queryCGREGstring(); - if (CGREGstring == RSP_ERROR) { - result = CellularRadio::VALUE_UNKNOWN; + if(iRssi == 0) { + iDbm = -113; + } else if(iRssi == 1) { + iDbm = -111; + } else if(iRssi <= 30) { + //28 steps between 2 and 30 + //54 dbm between 53 and 109 + float stepSize = 54.0 / 28.0; + iDbm = -109 + (int)(stepSize * (iRssi-2)); } else { - size_t start = CGREGstring.find(":") + 1; //Position right after "#RFSTS:" - std::vector<std::string> vParts = MTS::Text::split(MTS::Text::trim(CGREGstring.substr(start)), ","); - if(vParts.size() < 3) { - result = CellularRadio::VALUE_UNAVAILABLE; - } else { - result = MTS::Text::strip(vParts[2], '"'); - } + iDbm = -51; } - setCGREG(originalCGREG); - - return result; + return SUCCESS; } -void TelitRadio::setCGREG(std::string value) { - std::string sCmd("AT+CGREG=" + value); - std::string cmdResult(sendCommand(sCmd)); - if (cmdResult.find("OK") == std::string::npos) { - printDebug("%s| AT#CGREG=%s returned unexpected response: [%s][%s]", getName().c_str(), value.c_str(), sCmd.c_str(), cmdResult.c_str()); +CellularRadio::CODE TelitRadio::convertdBmToSignalStrength(const int32_t& iDBm, int32_t& iRssi) { + //Telit Conversion + if(iDBm <= -113) { + iRssi = 0; + } else if(iDBm <= -111) { + iRssi = 1; + } else if(iDBm <= -53) { + //54 dbm between -109 and -53 + //28 steps between 2 and 30 + float stepSize = 28.0/54.0; + iRssi = ((iDBm + 109)*stepSize) + 2; + } else { + iRssi = 31; } -} -std::string TelitRadio::queryCGREGstring() { - std::string sCmd("AT+CGREG?"); - std::string cmdResult(sendCommand(sCmd)); - if (cmdResult.find("+CGREG:") == std::string::npos) { - printDebug("%s| AT#CGREG? returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); - return RSP_ERROR; - } - return cmdResult; + return SUCCESS; } CellularRadio::CODE TelitRadio::setMdn(const Json::Value& jArgs) { |