diff options
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
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; |