summaryrefslogtreecommitdiff
path: root/src/MTS_IO_CellularRadio.cpp
diff options
context:
space:
mode:
authorSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2019-06-22 10:57:44 +0300
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2019-06-22 13:53:16 +0300
commita7673be0a434243c2011d809cc0a3a01441470fb (patch)
tree85eb8c58490c643aa706cc32cea564c728fa978e /src/MTS_IO_CellularRadio.cpp
parentda53c2f6955e748862066f727997965f7b9c6849 (diff)
downloadlibmts-io-a7673be0a434243c2011d809cc0a3a01441470fb.tar.gz
libmts-io-a7673be0a434243c2011d809cc0a3a01441470fb.tar.bz2
libmts-io-a7673be0a434243c2011d809cc0a3a01441470fb.zip
[MTS-MTQ] SIM status and PIN unlock procedures
Added a common implementation for the CellularRadio::getSimStatusSummary method
Diffstat (limited to 'src/MTS_IO_CellularRadio.cpp')
-rw-r--r--src/MTS_IO_CellularRadio.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index dbb64a5..8c4c75b 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -285,6 +285,50 @@ CellularRadio::CODE CellularRadio::getSimStatus(std::string& sSimStatus) {
return FAILURE;
}
+CellularRadio::CODE CellularRadio::getSimStatusSummary(Json::Value& jData) {
+ bool bIsSimInserted = false;
+ bool bIsSimLocked = true;
+ int iAttemptsPin = 0;
+ int iAttemptsPuk = 0;
+ std::string sSimLockStatus;
+ CODE retCode;
+
+ do {
+ retCode = getIsSimInserted(bIsSimInserted);
+ if (retCode != SUCCESS) {
+ break;
+ }
+
+ if (!bIsSimInserted) {
+ // There is no left much to do. Return one field only.
+ jData[KEY_IS_SIM_INSERTED] = bIsSimInserted;
+ break;
+ }
+
+ // The following code assumes that the SIM card is inserted
+ retCode = getSimLockStatus(sSimLockStatus);
+ if (retCode != SUCCESS) {
+ break;
+ }
+
+ bIsSimLocked = (sSimLockStatus != "READY"); // SIM PIN, SIM PUK or other values
+
+ retCode = getSimLockAttempts(iAttemptsPin, iAttemptsPuk);
+ if (retCode != SUCCESS) {
+ break;
+ }
+
+ // Everything fetched successfully. Populate the jData object
+ jData[KEY_IS_SIM_INSERTED] = bIsSimInserted;
+ jData[KEY_IS_SIM_LOCKED] = bIsSimLocked;
+ jData[KEY_SIM_LOCK_STATUS] = sSimLockStatus;
+ jData[KEY_ATTEMPTS_PIN] = iAttemptsPin;
+ jData[KEY_ATTEMPTS_PUK] = iAttemptsPuk;
+ } while (false);
+
+ return retCode;
+}
+
CellularRadio::CODE CellularRadio::getLac(std::string& sLac) {
Json::Value jData;