summaryrefslogtreecommitdiff
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
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
-rw-r--r--include/mts/MTS_IO_CellularRadio.h87
-rw-r--r--src/MTS_IO_CellularRadio.cpp106
2 files changed, 188 insertions, 5 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h
index 07daf19..71190c5 100644
--- a/include/mts/MTS_IO_CellularRadio.h
+++ b/include/mts/MTS_IO_CellularRadio.h
@@ -39,6 +39,61 @@
#include <vector>
#include <functional>
+typedef struct
+{
+ const char *name;
+ int32_t low;
+ int32_t high;
+} *pNameRangeMap, nameRangeMap;
+
+static const unsigned int NUM_GSM_BANDS = 7;
+static const unsigned int NUM_WCDMA_BANDS = 6;
+static const unsigned int NUM_LTE_BANDS = 42;
+
+// http://niviuk.free.fr/gsm_band.php
+static const nameRangeMap GSMband[] =
+{
+ {"GSM 450", 259, 293}, {"GSM 480", 306, 340},
+ {"GSM 750", 438, 511}, {"GSM 850", 128, 251},
+ {"GSM 900 P", 1, 124}, {"GSM 900 E/R", 955, 1023},
+ {"GSM DCS 1800/1900", 512, 885},
+
+};
+
+// http://niviuk.free.fr/umts_band.php
+static const nameRangeMap WCDMAband[] =
+{
+ {"BAND I", 10592, 10838}, {"BAND II", 9662, 9938},
+ {"BAND III", 1162, 1513}, {"BAND IV", 1537, 1738},
+ {"BAND V", 4357, 4458}, {"BAND VI", 4387, 4413}
+};
+
+// http://niviuk.free.fr/lte_band.php
+static const nameRangeMap EULTRAband[] =
+{
+ {"EUTRAN BAND1", 0, 599}, {"EUTRAN BAND2", 600, 1199},
+ {"EUTRAN BAND3", 1200, 1949}, {"EUTRAN BAND4", 1950, 2399},
+ {"EUTRAN BAND5", 2400, 2649}, {"EUTRAN BAND6", 2650, 2749},
+ {"EUTRAN BAND7", 2750, 3449}, {"EUTRAN BAND8", 3450, 3799},
+ {"EUTRAN BAND9", 3800, 4149}, {"EUTRAN BAND10", 4150, 4749},
+ {"EUTRAN BAND11", 4750, 4999}, {"EUTRAN BAND12", 5000, 5179},
+ {"EUTRAN BAND13", 5180, 5279}, {"EUTRAN BAND14", 5280, 5379},
+ {"EUTRAN BAND17", 5730, 5849}, {"EUTRAN BAND18", 5850, 5999},
+ {"EUTRAN BAND19", 6000, 6149}, {"EUTRAN BAND20", 6150, 6449},
+ {"EUTRAN BAND21", 6450, 6525}, {"EUTRAN BAND22", 6600, 7399},
+ {"EUTRAN BAND23", 7500, 7699}, {"EUTRAN BAND24", 7700, 8039},
+ {"EUTRAN BAND25", 8040, 8689}, {"EUTRAN BAND26", 8690, 9039},
+ {"EUTRAN BAND27", 9040, 9209}, {"EUTRAN BAND28", 9210, 9659},
+ {"EUTRAN BAND29", 9660, 9769}, {"EUTRAN BAND30", 9770, 9869},
+ {"EUTRAN BAND31", 9870, 9919}, {"EUTRAN BAND32", 9920, 10359},
+ {"EUTRAN BAND33", 36000, 36199}, {"EUTRAN BAND34", 36200, 36349},
+ {"EUTRAN BAND35", 36350, 36949}, {"EUTRAN BAND36", 36950, 37549},
+ {"EUTRAN BAND37", 37550, 37749}, {"EUTRAN BAND38", 37750, 38249},
+ {"EUTRAN BAND39", 38250, 38649}, {"EUTRAN BAND40", 38650, 39649},
+ {"EUTRAN BAND41", 39650, 41589}, {"EUTRAN BAND42", 41590, 43589},
+ {"EUTRAN BAND43", 43590, 45589}, {"EUTRAN BAND44", 45590, 46589}
+};
+
namespace MTS {
namespace IO {
@@ -415,6 +470,38 @@ namespace MTS {
private:
+ class RadioBandMap : NonCopyable {
+ public:
+ RadioBandMap()
+ {
+ m_sChannel = CellularRadio::VALUE_UNKNOWN;
+ m_iChannel = 0;
+ m_sRadioType = CellularRadio::VALUE_UNKNOWN;
+ }
+
+ RadioBandMap(const std::string &channel, const std::string &radioType) :
+ m_sChannel(channel),
+ m_sRadioType(radioType)
+ {
+ m_iChannel = strtol(m_sChannel.c_str(), NULL, 10);
+ }
+
+ virtual ~RadioBandMap() {}
+
+ const char *getRadioBandName();
+ const char *getRadioBandName(const std::string &channel, const std::string &radioType);
+
+ private:
+
+ const char *getLTEBand(const int channel);
+ const char *getCDMABand(const int channel);
+ const char *getGSMBand(const int channel);
+
+ std::string m_sChannel;
+ int m_iChannel;
+ std::string m_sRadioType;
+ };
+
std::string m_sName;
std::string m_sRadioPort;
std::string m_sFirmware;
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;
+}