summaryrefslogtreecommitdiff
path: root/src/MTS_IO_CellularRadio.cpp
diff options
context:
space:
mode:
authorJeff Hatch <jhatch@multitech.com>2015-11-02 15:49:27 -0600
committerJeff Hatch <jhatch@multitech.com>2015-11-02 15:49:27 -0600
commit88d22d0cb8f7a3d23472d13f17221176d3a43057 (patch)
treeb62c89899fb411dfe836b18f10742615b317c301 /src/MTS_IO_CellularRadio.cpp
parentab4c686299497450542adac99d2355cf5967e18f (diff)
downloadlibmts-io-88d22d0cb8f7a3d23472d13f17221176d3a43057.tar.gz
libmts-io-88d22d0cb8f7a3d23472d13f17221176d3a43057.tar.bz2
libmts-io-88d22d0cb8f7a3d23472d13f17221176d3a43057.zip
Add retreival of radio band for (GSM,CDMA,LTE) and fix retrieval of LAC for LTE
Diffstat (limited to 'src/MTS_IO_CellularRadio.cpp')
-rw-r--r--src/MTS_IO_CellularRadio.cpp106
1 files changed, 101 insertions, 5 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index 2a92e15..b9f437b 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -1007,6 +1007,10 @@ CellularRadio::CODE CellularRadio::getNetworkStatus(Json::Value& jData) {
jData[KEY_IMSI] = MTS::Text::strip(vParts[15], '"');
jData[KEY_NETWORK] = MTS::Text::strip(vParts[16], '"');
+ // Get the radio band given the channel (UARFCN)
+ RadioBandMap radioBandMap(vParts[1], CellularRadio::VALUE_TYPE_LTE);
+ jData[KEY_ABND] = radioBandMap.getRadioBandName();
+
if(MTS::Text::parse(iValue, vParts[17]) && convertServiceDomainToString((SERVICEDOMAIN)iValue, sValue) == SUCCESS) {
jDebug[KEY_SD] = sValue;
}
@@ -1038,14 +1042,30 @@ CellularRadio::CODE CellularRadio::getNetworkStatus(Json::Value& jData) {
jData[KEY_IMSI] = MTS::Text::strip(vParts[12], '"');
jData[KEY_NETWORK] = MTS::Text::strip(vParts[13], '"');
+ // Get the radio band given the channel (EARFCN)
+ RadioBandMap radioBandMap(vParts[1], CellularRadio::VALUE_TYPE_LTE);
+ jData[KEY_ABND] = radioBandMap.getRadioBandName();
+
+ // Get the LAC for the LTE radio that's not in the #RFSTS response
+ sCmd = "AT+CGREG=2";
+ sResult = sendCommand(sCmd);
+ if (sResult.find("OK") == std::string::npos) {
+ printDebug("%s| AT#CGREG=2 returned unexpected response: [%s][%s]", m_sName.c_str(), sCmd.c_str(), sResult.c_str());
+ }
+ sCmd = "AT+CGREG?";
+ sResult = sendCommand(sCmd);
+ if (sResult.find("+CGREG:") == std::string::npos) {
+ printDebug("%s| AT#CGREG? returned unexpected response: [%s][%s]", m_sName.c_str(), sCmd.c_str(), sResult.c_str());
+ jData[KEY_LAC] = CellularRadio::VALUE_UNKNOWN;
+ } else {
+ size_t start = sResult.find(":") + 1; //Position right after "#RFSTS:"
+ std::vector<std::string> vParts = MTS::Text::split(MTS::Text::trim(sResult.substr(start)), ",");
+ jData[KEY_LAC] = MTS::Text::strip(vParts[2], '"');
+ }
+
if(MTS::Text::parse(iValue, vParts[14]) && convertServiceDomainToString((SERVICEDOMAIN)iValue, sValue) == SUCCESS) {
jDebug[KEY_SD] = sValue;
}
- //Ignoring Active Set Values
- // <nAST> - Number of Active Set (Maximum 6)
- // <nUARFCN> - UARFCN of n th active set
- // <nPSC> - PSC of n th active set
- // <nEc/Io > - Ec/Io of n th active Set
jData[KEY_DEBUG] = jDebug;
}
@@ -1534,3 +1554,79 @@ bool CellularRadio::getHardwareVersionFromFirmware(const std::string& sFirmware,
return bResult;
}
+
+const char *CellularRadio::RadioBandMap::getLTEBand(const int32_t channel)
+{
+ for (unsigned int ii = 0; ii < NUM_LTE_BANDS; ii++)
+ {
+ if (EULTRAband[ii].low <= channel && EULTRAband[ii].high >= channel)
+ {
+ return EULTRAband[ii].name;
+ }
+ }
+ return VALUE_UNKNOWN.c_str();
+}
+
+const char *CellularRadio::RadioBandMap::getCDMABand(const int channel)
+{
+ for (unsigned int ii = 0; ii < NUM_WCDMA_BANDS; ii++)
+ {
+ if (WCDMAband[ii].low <= channel && WCDMAband[ii].high >= channel)
+ {
+ return WCDMAband[ii].name;
+ }
+ }
+ return VALUE_UNKNOWN.c_str();
+}
+
+const char *CellularRadio::RadioBandMap::getGSMBand(const int channel)
+{
+ for (unsigned int ii = 0; ii < NUM_GSM_BANDS; ii++)
+ {
+ if (GSMband[ii].low <= channel && GSMband[ii].high >= channel)
+ {
+ return GSMband[ii].name;
+ }
+ }
+ return VALUE_UNKNOWN.c_str();
+}
+
+const char *CellularRadio::RadioBandMap::getRadioBandName()
+{
+ const char *band = CellularRadio::VALUE_UNKNOWN.c_str();
+
+ if (m_sRadioType == CellularRadio::VALUE_TYPE_LTE)
+ {
+ band = getLTEBand(m_iChannel);
+ }
+ else if (m_sRadioType == CellularRadio::VALUE_TYPE_CDMA)
+ {
+ band = getCDMABand(m_iChannel);
+ }
+ else if (m_sRadioType == CellularRadio::VALUE_TYPE_GSM)
+ {
+ band = getGSMBand(m_iChannel);
+ }
+
+ return band;
+}
+
+const char *CellularRadio::RadioBandMap::getRadioBandName(const std::string &channel, const std::string &radioType)
+{
+ const char *band = CellularRadio::VALUE_UNKNOWN.c_str();
+ int32_t chan = strtol(channel.c_str(), NULL, 10);
+ if (radioType == CellularRadio::VALUE_TYPE_LTE)
+ {
+ band = getLTEBand(chan);
+ }
+ else if (radioType == CellularRadio::VALUE_TYPE_CDMA)
+ {
+ band = getCDMABand(chan);
+ }
+ else if (radioType == CellularRadio::VALUE_TYPE_GSM)
+ {
+ band = getGSMBand(chan);
+ }
+
+ return band;
+}