summaryrefslogtreecommitdiff
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
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
-rw-r--r--include/mts/MTS_IO_CellularRadio.h1
-rw-r--r--src/MTS_IO_CellularRadio.cpp44
2 files changed, 45 insertions, 0 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h
index e23cbc9..5ca9f9a 100644
--- a/include/mts/MTS_IO_CellularRadio.h
+++ b/include/mts/MTS_IO_CellularRadio.h
@@ -61,6 +61,7 @@ namespace MTS {
CODE getMeid(std::string& sMeid) override;
CODE getImsi(std::string& sImsi) override;
CODE getSimStatus(std::string& sSimStatus) override;
+ CODE getSimStatusSummary(Json::Value& jData) override;
CODE getLac(std::string& sLac) override;
CODE getMdn(std::string& sMdn) override;
CODE getMsid(std::string& sMsid) override;
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;