From 10633362bed1a888168f17fa1edf639990c15c50 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 29 May 2021 12:22:30 +0300 Subject: [GP-1111] mPower R. Apr 2021: +CEMODE shall be set to CEMODE=2 Fixed the `CellularRadio::getCarrier` implementation to use MCC/MNC combination from the SIM intead of the serving cell. Historically the implementation used MCC/MNC data from the cell that is currently serving the device and provides the registration. This MCC/MNC code is different from those of the home network in case of a roaming - the network/carrier that provided the SIM is different from the one who serves the device at the moment. The more correct way to determine home carrier for GSM/UMTS/LTE devices is to read first 5 or 6 digits of the SIM IMSI than encode the carrier. This commit updates the implementation to use SIM IMSI as a source of truth for the home network/carrier code. --- src/MTS_IO_CellularRadio.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 03baf48..1850a60 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -425,26 +425,21 @@ ICellularRadio::CODE CellularRadio::getType(std::string& sType) { ICellularRadio::CODE CellularRadio::getCarrier(std::string& sCarrier) { printTrace("%s| Get Carrier", m_sName.c_str()); - if(m_sCarrier == "") { - Json::Value jData; - if(getNetworkStatus(jData) == SUCCESS) { - if(jData.isMember(ICellularRadio::KEY_MCC) && jData.isMember(ICellularRadio::KEY_MNC)) { - std::string sMcc = jData[ICellularRadio::KEY_MCC].asString(); - std::string sMnc = jData[ICellularRadio::KEY_MNC].asString(); - Json::Value jLookup = MccMncTable::getInstance()->lookup(sMcc, sMnc); - printTrace("%s| MCC-MNC Lookup: [%s][%s][%s]", m_sName.c_str(), - sMcc.c_str(), sMnc.c_str(), jLookup.toStyledString().c_str()); - if(jLookup.isMember(ICellularRadio::KEY_CARRIER)) { - m_sCarrier = jLookup[ICellularRadio::KEY_CARRIER].asString(); - } else { - printWarning("%s| MCC-MNC Lookup did not contain carrier", m_sName.c_str()); - return FAILURE; - } + if (m_sCarrier == "") { + std::string sMcc; + std::string sMnc; + if (getSimMccMnc(sMcc, sMnc) == CODE::SUCCESS) { + Json::Value jLookup = MccMncTable::getInstance()->lookup(sMcc, sMnc); + printTrace("%s| MCC-MNC Lookup: [%s][%s][%s]", m_sName.c_str(), + sMcc.c_str(), sMnc.c_str(), jLookup.toStyledString().c_str()); + if (jLookup.isMember(ICellularRadio::KEY_CARRIER)) { + m_sCarrier = jLookup[ICellularRadio::KEY_CARRIER].asString(); } else { - printWarning("%s| Network Status did no contain MCC or MNC", m_sName.c_str()); + printWarning("%s| MCC-MNC Lookup did not contain carrier", m_sName.c_str()); return FAILURE; } } else { + printWarning("%s| SIM did no contain MCC or MNC", m_sName.c_str()); return FAILURE; } } -- cgit v1.2.3