From 482f5c42c4e0a03b7474d369250121005bc94f3f Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 21 Jun 2019 18:11:11 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Declared the interface for SIM status and PIN-related methods --- include/mts/MTS_IO_ICellularRadio.h | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include/mts') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index d74ad15..5d2295b 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -205,6 +205,29 @@ namespace MTS { virtual CODE getMeid(std::string& sMeid) = 0; virtual CODE getImsi(std::string& sImsi) = 0; virtual CODE getSimStatus(std::string& sSimStatus) = 0; + + /** + * @brief getSimStatusSummary - get summary on the SIM card status + * (if there is a SIM card inserted, is it locked, etc). + * See below for the full list of returned fields. + * + * - `isSimInserted` - bool, is the SIM card installed or not; + * - `isSimLocked` - bool, is the SIM card blocked with PIN/PUK or not (or is READY); + * - `lockStatus` - string, either "READY", "SIM PUK", "SIM PIN" or other status as + * returned by "AT+CPIN?" AT command; + * - `attemptsPin` - integer, the number of attempts lef to enter a PIN code; + * - `attemptsPuk` - integer, the number of attempts lef to enter a PUK code. + * + * **Only `isSimInserted` is always present.** All other fields are omitted if + * the SIM card is removed. + * + * @param jData - an object to be filled with data + * @return CODE::SUCCESS on success, + * CODE::NOT_APPLICABLE if not supported by this radio + * and CODE::ERROR otherwise + */ + virtual CODE getSimStatusSummary(Json::Value& jData) = 0; + virtual CODE getIccid(std::string& sIccid) = 0; virtual CODE getService(std::string& sService) = 0; virtual CODE getLac(std::string& sLac) = 0; @@ -225,6 +248,26 @@ namespace MTS { virtual CODE getRegistration(REGISTRATION& eRegistration) = 0; virtual CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) = 0; + /** + * @brief unlockSimCard - unlock the SIM card using PIN code provided + * + * This command does not peform any checks on the number of attempts left. + * Use with caution, verify the SIM status manually before execution. + * + * @param jArgs - a JSON object with the following format: + * + * jArgs = { + * "pin" : "A correct PIN code to unlock the SIM card: STRING" + * } + * + * @return CODE::SUCCESS when SIM card was succeffully unlocked, + * CODE::INVALID_ARGS when passed arguments are invalid, + * CODE::ERROR otherwise (i.e. when modem is not responding, + * when SIM card is removed, when PIN code is not correct + * or on any other error). + */ + virtual CODE unlockSimCard(const Json::Value& jArgs) = 0; + //! Gather details of the radio's Mobile IP Profile /*! \param Json::Value object that will be populated with MIP data -- cgit v1.2.3 From 07d0ee6ea892dea71911478fad2c530de41e059b Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 10:17:30 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Defined common protected utility methods for the CellularRadio class: - getIsSimInserted - getSimLockStatus - getSimLockAttempts --- include/mts/MTS_IO_CellularRadio.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include/mts') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 899ceeb..e23cbc9 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -122,6 +122,40 @@ namespace MTS { virtual void getCommonNetworkStats(Json::Value& jData); + /** + * @brief getIsSimInserted - returns if the SIM card is inserted / installed or not. + * + * @param bData - an object to be filled with the SIM card insertion status. + * `true` when SIM card is inserted / installed / present, + * `false` otherwise. + * @return CODE::SUCCESS when SIM insertion status is fetched successfully, + * CODE::NOT_APPLICABLE when the modem doesn't support this feature, + * CODE::ERROR otherwise (when modem is inaccessible or in other cases). + */ + virtual CODE getIsSimInserted(bool& bData) = 0; + + /** + * @brief getSimLockStatus - return the SIM lock status as defined by AT+CPIN? command. + * Returns "READY", "SIM PIN", "SIM PUK" or other SIM status. + * + * @param sData - an object to be filled with the SIM lock status + * @return CODE::SUCCESS when SIM status is fetched successfully, + * CODE::NOT_APPLICABLE when the modem doesn't support this feature, + * CODE::ERROR otherwise (SIM card removed, modem is inaccessible, etc). + */ + virtual CODE getSimLockStatus(std::string& sData) = 0; + + /** + * @brief getSimLockAttempts - get the number of SIM unlock attempts left. + * + * @param iAttemptsPin - the number of attempts left to enter a PIN code. + * @param iAttemptsPuk - the number of attempts left to enter a PUK code. + * @return CODE::SUCCESS when both numbers are fetched successfully, + * CODE::NOT_APPLICABLE when the modem doesn't support this feature, + * CODE::ERROR otherwise (SIM card removed, modem is inaccessible, etc). + */ + virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) = 0; + void initMipProfile(Json::Value& jData); bool splitAndAssign(const std::string& sLine, const std::string& sKey, Json::Value& jParent, const std::string& sJsonKey, Json::ValueType eType = Json::ValueType::stringValue); -- cgit v1.2.3 From da53c2f6955e748862066f727997965f7b9c6849 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 10:51:06 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Defined the JSON object fields for SIM Status Summary data --- include/mts/MTS_IO_ICellularRadio.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/mts') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 5d2295b..531e0e0 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -160,6 +160,12 @@ namespace MTS { static const char *KEY_MIP_MNAAASS; //!< Mobile Node Authentication, Authorization, and Accounting Server Shared Secret static const char *KEY_MIP_MNHASS; //!< Mobile Node Home Agent Shared Secret + //SIM Status Summary data + static const char *KEY_IS_SIM_INSERTED; //!< SIM card insertion indicator. True when a SIM card is inserted + static const char *KEY_IS_SIM_LOCKED; //!< SIM card lock status indicator. True when a SIM card is locked by PIN / PUK / other code + static const char *KEY_SIM_LOCK_STATUS; //!< SIM card lock status string. Either "READY", "SIM PIN", "SIM PUK" or other state + static const char *KEY_ATTEMPTS_PIN; //!< The number of attempts left to unlock the SIM card using PIN code + static const char *KEY_ATTEMPTS_PUK; //!< The number of attempts left to unlock the SIM card using PUK code //Values - Type static const char *VALUE_TYPE_LTE; -- cgit v1.2.3 From a7673be0a434243c2011d809cc0a3a01441470fb Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 10:57:44 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added a common implementation for the CellularRadio::getSimStatusSummary method --- include/mts/MTS_IO_CellularRadio.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/mts') 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; -- cgit v1.2.3 From d9024556c684f2c157d472eee814e01ff2496ff9 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 11:24:51 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added common implementations for CellularRadio::unlockSimCard and CellularRadio::getSimLockStatus --- include/mts/MTS_IO_CellularRadio.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/mts') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 5ca9f9a..9866d73 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -76,6 +76,9 @@ namespace MTS { CODE getRegistration(REGISTRATION& eRegistration) override; CODE convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) override; + + CODE unlockSimCard(const Json::Value& jArgs) override; + CODE getMipProfile(Json::Value& jMipProfile) override; CODE validateMsl(const Json::Value& jArgs) override; CODE setMsid(const Json::Value& jArgs) override; @@ -144,7 +147,7 @@ namespace MTS { * CODE::NOT_APPLICABLE when the modem doesn't support this feature, * CODE::ERROR otherwise (SIM card removed, modem is inaccessible, etc). */ - virtual CODE getSimLockStatus(std::string& sData) = 0; + virtual CODE getSimLockStatus(std::string& sData); /** * @brief getSimLockAttempts - get the number of SIM unlock attempts left. -- cgit v1.2.3 From 25bbcb7482dbbb93c9edfc3e1de415cfa4c260d0 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 12:03:17 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added Telit-specific implementation of the CellularRadio::getIsSimInserted and CellularRadio::getSimLockAttempts utility methods --- include/mts/MTS_IO_TelitRadio.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/mts') diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 70ff8a9..65ca56e 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -46,7 +46,11 @@ namespace MTS { bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) override; bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; + CODE getIsSimInserted(bool& bData) override; + CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; + private: + virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk, const std::string& sLockStatus); }; } -- cgit v1.2.3 From 1cb0265df2b2e2171a874a52a782de3ecc6620fa Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Sat, 22 Jun 2019 12:03:17 +0300 Subject: [MTS-MTQ] SIM status and PIN unlock procedures Added Quectel-specific implementation of the CellularRadio::getIsSimInserted and CellularRadio::getSimLockAttempts utility methods --- include/mts/MTS_IO_QuectelRadio.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/mts') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index b486323..81da1ce 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -48,6 +48,9 @@ namespace MTS { bool getCarrierFromFirmware(const std::string& sFirmware, std::string& sCarrier) override; bool getHardwareVersionFromFirmware(const std::string& sFirmware, std::string& sHardware) override; + CODE getIsSimInserted(bool& bData) override; + CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; + virtual CODE getServiceDomain(SERVICEDOMAIN& sd); virtual CODE convertToActiveBand(const std::string& sQuectelBand, ACTIVEBAND& band); -- cgit v1.2.3