summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2019-07-15 17:10:08 +0300
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2019-07-15 17:25:14 +0300
commit6042426e8d21b9b92f7078f64f4b50c2f1b8bc8d (patch)
tree557a133740c1dfb34bfd52da0048096f457d1c58 /src
parent0de89b68bd4471df424eca976d60ae98dea309df (diff)
downloadlibmts-io-6042426e8d21b9b92f7078f64f4b50c2f1b8bc8d.tar.gz
libmts-io-6042426e8d21b9b92f7078f64f4b50c2f1b8bc8d.tar.bz2
libmts-io-6042426e8d21b9b92f7078f64f4b50c2f1b8bc8d.zip
[MTX-2886] MTR_MTQ - radio-cmd shows invalid message on valid SIM PIN
Fixed the timeouts for several AT commands, including SIM-related commands
Diffstat (limited to 'src')
-rw-r--r--src/MTS_IO_CellularRadio.cpp24
-rw-r--r--src/MTS_IO_QuectelRadio.cpp22
-rw-r--r--src/MTS_IO_TelitRadio.cpp2
3 files changed, 37 insertions, 11 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index 500f352..195ba4f 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -237,8 +237,11 @@ CellularRadio::CODE CellularRadio::getManufacturer(std::string& sManufacturer) {
CellularRadio::CODE CellularRadio::getImei(std::string& sImei) {
printTrace("%s| Get IMEI", m_sName.c_str());
sImei = ICellularRadio::VALUE_NOT_SUPPORTED;
+
+ // AT+CGSN execution can take up to 300ms according to the Quectel datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+CGSN");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
+
size_t pos = sResult.find(ICellularRadio::RSP_OK);
if (pos == std::string::npos) {
printWarning("%s| Unable to get IMEI from radio using command [%s]", m_sName.c_str(), sCmd.c_str());
@@ -262,8 +265,11 @@ CellularRadio::CODE CellularRadio::getMeid(std::string& sMeid) {
CellularRadio::CODE CellularRadio::getImsi(std::string& sImsi) {
printTrace("%s| Get IMSI", m_sName.c_str());
sImsi = ICellularRadio::VALUE_NOT_SUPPORTED;
+
+ // AT+CIMI execution can take up to 300ms according to the Quectel datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+CIMI");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
+
size_t pos = sResult.find(ICellularRadio::RSP_OK);
if (pos == std::string::npos) {
printWarning("%s| Unable to get IMSI from radio using command [%s]", m_sName.c_str(), sCmd.c_str());
@@ -348,8 +354,11 @@ CellularRadio::CODE CellularRadio::getLac(std::string& sLac) {
CellularRadio::CODE CellularRadio::getMdn(std::string& sMdn) {
printTrace("%s| Get MDN", m_sName.c_str());
sMdn = ICellularRadio::VALUE_NOT_SUPPORTED;
+
+ // AT+CNUM execution can take up to 300ms according to the Quectel datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+CNUM");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
+
size_t end = sResult.find(ICellularRadio::RSP_OK);
if (end == std::string::npos) {
printWarning("%s| Unable to get MDN from radio using command [%s]", m_sName.c_str(), sCmd.c_str());
@@ -534,8 +543,11 @@ CellularRadio::CODE CellularRadio::getRoaming(bool& bRoaming) {
CellularRadio::CODE CellularRadio::getSignalStrength(int32_t& rssi) {
printTrace("%s| Get Signal Strength", m_sName.c_str());
+
+ // AT+CSQ execution can take up to 300ms according to the Quectel datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+CSQ");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
+
if (sResult.find("+CSQ: ") == std::string::npos) {
printDebug("%s| Signal Strength command returned unexpected response: [%s]", m_sName.c_str(), sResult.c_str());
return FAILURE;
@@ -763,8 +775,10 @@ void CellularRadio::getCommonNetworkStats(Json::Value& jData) {
CellularRadio::CODE CellularRadio::getSimLockStatus(std::string& sData)
{
printTrace("%s| Get SIM lock status", m_sName.c_str());
+
+ // SIM card may introduce a delay to AT+CPIN? execution. Setting timeout to 1s as set in PPP chat patches.
std::string sCmd("AT+CPIN?");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 1000);
const std::string sPrefix = "+CPIN: ";
size_t start = sResult.find(sPrefix);
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index 6f97989..b8c781f 100644
--- a/src/MTS_IO_QuectelRadio.cpp
+++ b/src/MTS_IO_QuectelRadio.cpp
@@ -73,8 +73,11 @@ CellularRadio::CODE QuectelRadio::getModel(std::string& sModel) {
CellularRadio::CODE QuectelRadio::getIccid(std::string& sIccid) {
printTrace("%s| Get ICCID", getName().c_str());
sIccid = ICellularRadio::VALUE_NOT_SUPPORTED;
+
+ // AT+QCCID execution can take up to 300ms according to the datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+QCCID");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
+
size_t end = sResult.find(ICellularRadio::RSP_OK);
if (end == std::string::npos) {
printWarning("%s| Unable to get ICCID from radio using command [%s]", getName().c_str(), sCmd.c_str());
@@ -482,8 +485,10 @@ bool QuectelRadio::getHardwareVersionFromFirmware(const std::string& sFirmware,
CellularRadio::CODE QuectelRadio::getIsSimInserted(bool& bData) {
printTrace("%s| Get SIM insertion status", getName().c_str());
+
+ // AT+QSIMSTAT? execution can take up to 300ms according to the datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+QSIMSTAT?");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
const std::string sPrefix = "+QSIMSTAT: ";
size_t start = sResult.find(sPrefix);
@@ -519,8 +524,10 @@ CellularRadio::CODE QuectelRadio::getIsSimInserted(bool& bData) {
CellularRadio::CODE QuectelRadio::getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) {
printTrace("%s| Get SIM unlock attempts left", getName().c_str());
+
+ // AT+QPINC execution can take up to 300ms according to the datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+QPINC=\"SC\"");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
const std::string sPrefix = "+QPINC: \"SC\",";
size_t start = sResult.find(sPrefix);
@@ -578,8 +585,10 @@ CellularRadio::CODE QuectelRadio::convertToActiveBand(const std::string& sQuecte
ICellularRadio::CODE QuectelRadio::getRadioNetworkMode(RADIO_NETWORK_MODE &mode)
{
+ // AT+QCFG="nwscanmode" execution can take up to 300ms according to the datasheet. Setting timeout to 500ms just for sure.
std::string sCmd("AT+QCFG=\"nwscanmode\"");
- std::string cmdResult = sendCommand(sCmd);
+ std::string cmdResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
+
if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) {
printDebug("%s| AT+QCFG? returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str());
return FAILURE;
@@ -604,7 +613,10 @@ ICellularRadio::CODE QuectelRadio::setRadioNetworkMode(RADIO_NETWORK_MODE mode)
}
std::string sCmd("AT+QCFG=\"nwscanmode\",");
sCmd += value;
- std::string cmdResult = sendCommand(sCmd);
+
+ // AT+QCFG="nwscanmode" execution can take up to 300ms according to the datasheet. Setting timeout to 500ms just for sure.
+ std::string cmdResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
+
if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) {
printDebug("%s| AT+QCFG? returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str());
return FAILURE;
diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp
index bafbd35..c8448e2 100644
--- a/src/MTS_IO_TelitRadio.cpp
+++ b/src/MTS_IO_TelitRadio.cpp
@@ -627,7 +627,7 @@ CellularRadio::CODE TelitRadio::getSimLockAttempts(int& iAttemptsPin, int& iAtte
CellularRadio::CODE TelitRadio::getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk, const std::string& sLockStatus) {
printTrace("%s| Get SIM unlock attempts left", getName().c_str());
std::string sCmd("AT#PCT");
- std::string sResult = sendCommand(sCmd);
+ std::string sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, 500);
std::string sValue;
int iValue;