diff options
author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2021-05-29 12:22:30 +0300 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2021-05-29 12:51:23 +0300 |
commit | 10633362bed1a888168f17fa1edf639990c15c50 (patch) | |
tree | 660d74a3ddeceab7f872cc8e85b1f59be663c0f9 /src/MTS_IO_CellularRadio.cpp | |
parent | e5e131de3faf1530cc977edc643e886a640d3bde (diff) | |
download | libmts-io-10633362bed1a888168f17fa1edf639990c15c50.tar.gz libmts-io-10633362bed1a888168f17fa1edf639990c15c50.tar.bz2 libmts-io-10633362bed1a888168f17fa1edf639990c15c50.zip |
[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.
Diffstat (limited to 'src/MTS_IO_CellularRadio.cpp')
-rw-r--r-- | src/MTS_IO_CellularRadio.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
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; } } |