diff options
-rw-r--r-- | include/mts/MTS_IO_CellularRadio.h | 1 | ||||
-rw-r--r-- | include/mts/MTS_IO_ICellularRadio.h | 3 | ||||
-rw-r--r-- | include/mts/MTS_IO_QuectelRadio.h | 1 | ||||
-rw-r--r-- | src/MTS_IO_CellularRadio.cpp | 6 | ||||
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 72 |
5 files changed, 83 insertions, 0 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 56506af..7f4ed2b 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -100,6 +100,7 @@ namespace MTS { CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb) override; CODE resetHfa(const Json::Value& jArgs, UpdateCb& stepCb) override; CODE activate(const Json::Value& jArgs, UpdateCb& stepCb) override; + CODE startOmaDm(UpdateCb& stepCb) override; CODE setActiveFirmware(const Json::Value& jArgs) override; CODE getActiveFirmware(std::string& sFwId) override; CODE getEcho(bool& bEnabled) override; diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 58d5076..c301191 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -431,6 +431,9 @@ namespace MTS { * "fwid" : "Firmware Image To Be Enabled: STRING" * } */ + + virtual CODE startOmaDm(UpdateCb& stepCb) = 0; + virtual CODE setActiveFirmware(const Json::Value& jArgs) = 0; virtual CODE getActiveFirmware(std::string& sFwId) = 0; diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index df3b5b5..1dc45cd 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -41,6 +41,7 @@ namespace MTS { CODE convertdBmToSignalStrength(const int32_t& dBm, int32_t& iRssi) override; CODE setMdn(const Json::Value& jArgs) override; + CODE startOmaDm(ICellularRadio::UpdateCb& stepCb) override; protected: QuectelRadio(const std::string& sName, const std::string& sRadioPort); diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 50fdf5c..648894f 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -1020,6 +1020,12 @@ ICellularRadio::CODE CellularRadio::activate(const Json::Value&, UpdateCb&) { return NOT_APPLICABLE; } +ICellularRadio::CODE CellularRadio::startOmaDm(ICellularRadio::UpdateCb&) { + printTrace("%s| Start OMA DM procedure: not applicable", m_sName.c_str()); + + return NOT_APPLICABLE; +} + ICellularRadio::CODE CellularRadio::setActiveFirmware(const Json::Value&) { printTrace("%s| Set Active Firmware Image Number: not applicable", m_sName.c_str()); diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index c4bdc56..b750bd6 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -436,6 +436,78 @@ 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()); + + 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 std::string sOdmStarted = "DM Start"; + const std::string sOdmFinished = "DM End"; + + const std::vector<std::string> vOdmStartedStrings{ sOdmStarted }; + const std::vector<std::string> vOdmFinishedStrings{ sOdmFinished }; + + CODE eCode; + + do { + + // Send command and expect "OK" in iTimeoutOk milliseconds + eCode = sendBasicCommand("AT+QODM=\"DME\",2,\"UI\"", 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()); + + 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" response + sResponse = sendCommand("", vOdmFinishedStrings, iTimeoutEnd, 0x00); + printDebug("%s| Radio returned: [%s]", getName().c_str(), sResponse.c_str()); + + 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")); + } + 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()); |