summaryrefslogtreecommitdiff
path: root/src/MTS_IO_TelitRadio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTS_IO_TelitRadio.cpp')
-rw-r--r--src/MTS_IO_TelitRadio.cpp85
1 files changed, 44 insertions, 41 deletions
diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp
index a2ade7c..4fcf836 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 = ICellularRadio::VALUE_NOT_SUPPORTED;
+
+ if(getNetworkStatus(jData) == SUCCESS) {
+ if(jData.isMember(ICellularRadio::KEY_NETWORK)) {
+ sNetwork = jData[ICellularRadio::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 == ICellularRadio::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 == ICellularRadio::RSP_ERROR) {
- result = ICellularRadio::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 = ICellularRadio::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 ICellularRadio::RSP_ERROR;
- }
- return cmdResult;
+ return SUCCESS;
}
CellularRadio::CODE TelitRadio::setMdn(const Json::Value& jArgs) {