diff options
author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-06-25 10:17:59 +0300 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-06-25 10:17:59 +0300 |
commit | 6b3026ba736d3eef4b7754dfed46e32e45c5a490 (patch) | |
tree | e5316d29beba3d8c0d1fd791e0e7bac73aa8cfb6 /src/MTS_IO_QuectelRadio.cpp | |
parent | adaca6b0fc6430f38ae3f0551f9a248563ad53b5 (diff) | |
parent | a949739583abb1fe30895edfda216e83ffdbef52 (diff) | |
download | libmts-io-6b3026ba736d3eef4b7754dfed46e32e45c5a490.tar.gz libmts-io-6b3026ba736d3eef4b7754dfed46e32e45c5a490.tar.bz2 libmts-io-6b3026ba736d3eef4b7754dfed46e32e45c5a490.zip |
[MTX-3489] mPower Oct20: Porting "LNA7 Intermediate Release" changes
Merged all the changes from the intermediate release to master.
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 5024f54..5c2c352 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -438,6 +438,98 @@ ICellularRadio::CODE QuectelRadio::setMdn(const Json::Value& jArgs) { return NOT_APPLICABLE; } +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 = 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, sOdmAbnormal }; + + CODE eCode; + + do { + + // Send command and expect "OK" in iTimeoutOk milliseconds + eCode = sendBasicCommand(sCmdOdmStart, iTimeoutOk); + if (eCode != SUCCESS) { + printError("%s| OMA DM procedure can not be started", getName().c_str()); + if (stepCb) { + stepCb(Json::Value("OMA DM Error: OMA DM can not be started")); + } + break; + } + + // Wait for the "Start" response + 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) { + stepCb(Json::Value("OMA DM Error: OMA DM failed due to timeout")); + } + eCode = FAILURE; + break; + } + + // Got "DM Started" message from the radio + printTrace("%s| OMA DM started", getName().c_str()); + if (stepCb) { + stepCb(Json::Value("OMA DM Info: OMA DM started")); + } + + // 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")); + } + 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; + } + + // Got "DM End" message from the radio + printTrace("%s| OMA DM finished", getName().c_str()); + if (stepCb) { + stepCb(Json::Value("OMA DM Info: OMA DM finished")); + } + + eCode = SUCCESS; + + } while (false); + + return eCode; +} + ICellularRadio::CODE QuectelRadio::getServiceDomain(ICellularRadio::SERVICEDOMAIN& sd) { printTrace("%s| Get Service Domain", getName().c_str()); |