summaryrefslogtreecommitdiff
path: root/src/MTS_IO_TelitRadio.cpp
diff options
context:
space:
mode:
authorMaksym Telychko <maksym.telychko@globallogic.com>2019-06-12 15:22:41 +0300
committerMaksym Telychko <maksym.telychko@globallogic.com>2019-06-12 15:22:41 +0300
commit123aed7c4be0b88a4726cae5d722d74ebdf93782 (patch)
tree7923c2bd930ebd879e6d8e6f43dc988a409320c4 /src/MTS_IO_TelitRadio.cpp
parent5c8318bea803966f5b883c986919787e77e514a5 (diff)
downloadlibmts-io-123aed7c4be0b88a4726cae5d722d74ebdf93782.tar.gz
libmts-io-123aed7c4be0b88a4726cae5d722d74ebdf93782.tar.bz2
libmts-io-123aed7c4be0b88a4726cae5d722d74ebdf93782.zip
[MTS-MTQ] refactoring: using full qualified names for consts
Diffstat (limited to 'src/MTS_IO_TelitRadio.cpp')
-rw-r--r--src/MTS_IO_TelitRadio.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp
index ee96ff2..a2ade7c 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());
@@ -256,30 +256,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.
@@ -288,36 +288,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)
@@ -325,7 +325,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;
@@ -347,34 +347,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());
@@ -389,7 +389,7 @@ std::string TelitRadio::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")
@@ -399,13 +399,13 @@ std::string TelitRadio::queryLteLac() {
setCGREG("2");
CGREGstring = queryCGREGstring();
- if (CGREGstring == RSP_ERROR) {
- result = CellularRadio::VALUE_UNKNOWN;
+ if (CGREGstring == ICellularRadio::RSP_ERROR) {
+ result = ICellularRadio::VALUE_UNKNOWN;
} 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;
+ result = ICellularRadio::VALUE_UNAVAILABLE;
} else {
result = MTS::Text::strip(vParts[2], '"');
}
@@ -429,7 +429,7 @@ std::string TelitRadio::queryCGREGstring() {
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 ICellularRadio::RSP_ERROR;
}
return cmdResult;
}
@@ -445,7 +445,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;
@@ -480,19 +480,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;
}
}