diff options
author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-06-05 12:18:58 +0300 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-06-05 12:18:58 +0300 |
commit | 73a5dc4711da4d21a7f650aec4534ecb3691ca15 (patch) | |
tree | ceda2ed1aad58335721b403f161cf7f315e8d04c /src/MTS_IO_QuectelRadio.cpp | |
parent | 406cce9d517465698bd6f60c788b01c0e9f8e32e (diff) | |
download | libmts-io-73a5dc4711da4d21a7f650aec4534ecb3691ca15.tar.gz libmts-io-73a5dc4711da4d21a7f650aec4534ecb3691ca15.tar.bz2 libmts-io-73a5dc4711da4d21a7f650aec4534ecb3691ca15.zip |
[GP-651] LNA7: Allow to start the OMA DM procedure when it is required
Fixes after a code review:
- increased timeout from 60 to 160 seconds for "Abnormal" cases;
- added hanlding for the "DME Abnormal" URC;
- added "kill OMA DM" logic for the timeout case.
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 5d29be7..360d988 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -439,22 +439,29 @@ ICellularRadio::CODE QuectelRadio::setMdn(const Json::Value& jArgs) { ICellularRadio::CODE QuectelRadio::startOmaDm(ICellularRadio::UpdateCb& stepCb) { printTrace("%s| Start OMA DM procedure", getName().c_str()); + // TODO: All the timeout values below are empirically defined. + // Feel free to update them if you get any verified information. const int32_t iTimeoutOk = 3 * 1000; // 3 seconds const int32_t iTimeoutStart = 5 * 1000; // 5 seconds - const int32_t iTimeoutEnd = 1 * 60 * 1000; // 1 minute + const int32_t iTimeoutEnd = 160 * 1000; // 2 minutes 40 seconds + const int32_t iTimeoutAbort = 3 * 1000; // 3 seconds + + const std::string sCmdOdmStart = "AT+QODM=\"dme\",2,\"ui\""; + const std::string sCmdOdmAbort = "AT+QODM=\"dme\",2,\"kill\""; const std::string sOdmStarted = "DM Start"; const std::string sOdmFinished = "DM End"; + const std::string sOdmAbnormal = "DME Abnormal"; const std::vector<std::string> vOdmStartedStrings{ sOdmStarted }; - const std::vector<std::string> vOdmFinishedStrings{ sOdmFinished }; + const std::vector<std::string> vOdmFinishedStrings{ sOdmFinished, sOdmAbnormal }; CODE eCode; do { // Send command and expect "OK" in iTimeoutOk milliseconds - eCode = sendBasicCommand("AT+QODM=\"dme\",2,\"ui\"", iTimeoutOk); + eCode = sendBasicCommand(sCmdOdmStart, iTimeoutOk); if (eCode != SUCCESS) { printError("%s| OMA DM procedure can not be started", getName().c_str()); if (stepCb) { @@ -467,6 +474,7 @@ ICellularRadio::CODE QuectelRadio::startOmaDm(ICellularRadio::UpdateCb& stepCb) std::string sResponse = sendCommand("", vOdmStartedStrings, iTimeoutStart, 0x00); printDebug("%s| Radio returned: [%s]", getName().c_str(), sResponse.c_str()); + // Received something unexpected or nothing at all? if (sResponse.find(sOdmStarted) == std::string::npos) { printError("%s| OMA DM procedure failed due to timeout", getName().c_str()); if (stepCb) { @@ -482,15 +490,27 @@ ICellularRadio::CODE QuectelRadio::startOmaDm(ICellularRadio::UpdateCb& stepCb) stepCb(Json::Value("OMA DM Info: OMA DM started")); } - // Wait for the "End" response + // Wait for the "End" or "Abnormal" response sResponse = sendCommand("", vOdmFinishedStrings, iTimeoutEnd, 0x00); printDebug("%s| Radio returned: [%s]", getName().c_str(), sResponse.c_str()); + // Received "Abnormal"? + if (sResponse.find(sOdmAbnormal) != std::string::npos) { + printError("%s| OMA DM procedure failed due to internal error: [%s]", getName().c_str(), sResponse.c_str()); + if (stepCb) { + stepCb(Json::Value("OMA DM Error: OMA DM failed due to internal error: [%s]", sOdmAbnormal.c_str())); + } + eCode = FAILURE; + break; + } + + // Received something unexpected or nothing at all? if (sResponse.find(sOdmFinished) == std::string::npos) { printError("%s| OMA DM procedure failed due to timeout", getName().c_str()); if (stepCb) { stepCb(Json::Value("OMA DM Error: OMA DM failed due to timeout")); } + sendBasicCommand(sCmdOdmAbort, iTimeoutAbort); // abort the procedure eCode = FAILURE; break; } |