summaryrefslogtreecommitdiff
path: root/src/MTS_IO_CellularRadio.cpp
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/MTS_IO_CellularRadio.cpp
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/MTS_IO_CellularRadio.cpp')
-rw-r--r--src/MTS_IO_CellularRadio.cpp24
1 files changed, 19 insertions, 5 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);