summaryrefslogtreecommitdiff
path: root/src/MTS_IO_CellularRadio.cpp
diff options
context:
space:
mode:
authorSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-06-16 11:50:20 +0300
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-06-16 12:57:08 +0300
commit7634bcfed0ea186175e9f59672a38d2a86fbf025 (patch)
tree291b10f75b01b0d49073e7f8c2b7902c74ba0e8a /src/MTS_IO_CellularRadio.cpp
parentc34ebcd0df9c5bdbeb5638e9a5498cbee6bab628 (diff)
downloadlibmts-io-7634bcfed0ea186175e9f59672a38d2a86fbf025.tar.gz
libmts-io-7634bcfed0ea186175e9f59672a38d2a86fbf025.tar.bz2
libmts-io-7634bcfed0ea186175e9f59672a38d2a86fbf025.zip
GP-654: Add SIM card-based carrier detection
This commit adds implementation of the SIM-based carrier detection. The goal for this implementation is to replace various places in the firmware that previously relied on the ICCID-based carrier detection, provide some layer of abstraction and forward compatibility for such places. It is particularly useful for fwSwitch radios with AUTO firmware selection capability.
Diffstat (limited to 'src/MTS_IO_CellularRadio.cpp')
-rw-r--r--src/MTS_IO_CellularRadio.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index 648894f..bef15e9 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -912,6 +912,49 @@ ICellularRadio::CODE CellularRadio::unlockSimCard(const Json::Value& jArgs) {
return SUCCESS;
}
+ICellularRadio::CODE CellularRadio::getMtsSimCarrierCode(std::string& sCarrierCode) {
+ std::string sIccid;
+ CODE rc;
+
+ printTrace("%s| Get MTS carrier code from the SIM card installed", m_sName.c_str());
+
+ rc = getIccid(sIccid);
+ if (rc != SUCCESS) {
+ printError("%s| Unable to determine SIM carrier: Failed to fetch SIM identifier", m_sName.c_str());
+ return rc;
+ }
+
+ printTrace("%s| Fetched ICCID: [%s]", m_sName.c_str(), sIccid.c_str());
+
+ rc = getMtsSimCarrierCode(sIccid, sCarrierCode);
+ if (rc != SUCCESS) {
+ printError("%s| Unable to determine SIM carrier: Unable to extract carrier from the SIM identifier", m_sName.c_str());
+ return rc;
+ }
+
+ printTrace("%s| Detected MTS carrier code: [%s]", m_sName.c_str(), sCarrierCode.c_str());
+ return rc;
+}
+
+ICellularRadio::CODE CellularRadio::getMtsSimCarrierCode(const std::string& sIccid, std::string& sCarrierCode) {
+ const char* ICCID_PREFIX_VZW = "891480";
+ const char* ICCID_PREFIX_ATT = "8901410";
+
+ if (sIccid.find(ICCID_PREFIX_VZW) == 0) {
+ printTrace("%s| Verizon SIM detected", m_sName.c_str());
+ sCarrierCode = VALUE_MTS_CARRIER_CODE_VERIZON;
+ } else if (sIccid.find(ICCID_PREFIX_ATT) == 0) {
+ printTrace("%s| AT&T SIM detected", m_sName.c_str());
+ sCarrierCode = VALUE_MTS_CARRIER_CODE_ATT;
+ } else {
+ // All other carriers for which ICCID prefixes are not defined
+ printWarning("%s| Carrier is unknown for this SIM ID: [%s]", m_sName.c_str(), sIccid.c_str());
+ sCarrierCode = VALUE_UNKNOWN;
+ }
+
+ return SUCCESS; // no error cases for now
+}
+
ICellularRadio::CODE CellularRadio::validateMsl(const Json::Value&) {
printTrace("%s| Validate MSL", m_sName.c_str());