diff options
author | sdesai <sdesai@multitech.com> | 2023-03-20 14:32:37 -0500 |
---|---|---|
committer | sdesai <sdesai@multitech.com> | 2023-03-20 14:32:37 -0500 |
commit | 8fce7442bbc63b744905f9febc21aad9cf5074fd (patch) | |
tree | 2e78f36932d43d1eaa2b7c3f49f9349c9573d557 | |
parent | 050834e3cdd0f5f56ba15b09ca568ac6312c7699 (diff) | |
download | libmts-io-8fce7442bbc63b744905f9febc21aad9cf5074fd.tar.gz libmts-io-8fce7442bbc63b744905f9febc21aad9cf5074fd.tar.bz2 libmts-io-8fce7442bbc63b744905f9febc21aad9cf5074fd.zip |
Support Portal Case #5086148: use Cellular Radio timeas alternative to GPS or NTP
-rw-r--r-- | include/mts/MTS_IO_CellularRadio.h | 1 | ||||
-rw-r--r-- | include/mts/MTS_IO_ICellularRadio.h | 1 | ||||
-rw-r--r-- | include/mts/MTS_IO_QuectelRadio.h | 2 | ||||
-rw-r--r-- | include/mts/MTS_IO_SequansRadio.h | 3 | ||||
-rw-r--r-- | include/mts/MTS_IO_TelitRadio.h | 3 | ||||
-rw-r--r-- | src/MTS_IO_CellularRadio.cpp | 2 | ||||
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 28 | ||||
-rw-r--r-- | src/MTS_IO_SequansRadio.cpp | 26 | ||||
-rw-r--r-- | src/MTS_IO_TelitRadio.cpp | 37 |
9 files changed, 43 insertions, 60 deletions
diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 68c1394..0af531b 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -277,6 +277,7 @@ namespace MTS { * @return the list of AT commands (strings). */ virtual const std::vector<std::string>& getDiagCommands(bool bIsSimReady = true) = 0; + virtual CODE setTimeFormat () = 0; class RadioBandMap : public MTS::NonCopyable { public: diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index da8e130..d5b5f18 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -717,7 +717,6 @@ namespace MTS { * CODE::FAILURE otherwise. */ virtual CODE getDiagnostics(std::string& sDiagReport) = 0; - virtual CODE getTimeUTC(void) = 0; }; } } diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 7015acb..a8d37f2 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -86,7 +86,7 @@ namespace MTS { CODE setRxDiversity(const Json::Value& jArgs) override; const std::vector<std::string>& getDiagCommands(bool bIsSimReady = true) override; - CODE getTimeUTC(void) override; + CODE setTimeFormat() override; private: // private variable to save old firmware versions during FOTA std::string m_sQuectelFirmware; diff --git a/include/mts/MTS_IO_SequansRadio.h b/include/mts/MTS_IO_SequansRadio.h index d61ae67..30f4875 100644 --- a/include/mts/MTS_IO_SequansRadio.h +++ b/include/mts/MTS_IO_SequansRadio.h @@ -49,7 +49,7 @@ namespace MTS { CODE setRxDiversity(const Json::Value& jArgs) override; const std::vector<std::string> getRegistrationCommands() override; - CODE getTimeUTC(void) override; + protected: SequansRadio(const std::string& sName, const std::string& sRadioPort); @@ -57,6 +57,7 @@ namespace MTS { CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; const std::vector<std::string>& getDiagCommands(bool bIsSimReady = true) override; + virtual CODE setTimeFormat() override; private: /* diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index 01897ac..7011ef3 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -51,7 +51,6 @@ namespace MTS { CODE fumoLocalApply(UpdateCb& stepCb) override; CODE getSelectedBandsRaw(std::string& sRawBands) override; - CODE getTimeUTC(void) override; protected: TelitRadio(const std::string& sName, const std::string& sRadioPort); @@ -76,7 +75,7 @@ namespace MTS { const std::vector<std::string>& getDiagCommands(bool bIsSimReady = true) override; static bool isContainsSignChar(const std::string& str); - + virtual CODE setTimeFormat() override; private: virtual CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk, const std::string& sLockStatus); ICellularRadio::CODE wdsList(std::set<int> &wds); diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 8cdaf44..0b90b55 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -580,7 +580,7 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi std::vector<std::string> vTimeParts; std::string sSign = "+"; - if(getTimeUTC() == FAILURE) { + if(setTimeFormat() == FAILURE) { printWarning("%s| Unable to set Time Parameters for radio [%s]", m_sName.c_str()); return FAILURE;; } diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 655fb38..760cf6d 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -1676,27 +1676,25 @@ const std::vector<std::string>& QuectelRadio::getDiagCommands(bool) { return vCommands; } -ICellularRadio::CODE QuectelRadio::getTimeUTC(void) { - printTrace("%s| Get Time in UTC", getName().c_str()); - +ICellularRadio::CODE QuectelRadio::setTimeFormat(void) { + printTrace("%s| Set standard time format", getName().c_str()); + ICellularRadio::CODE rc; // Set year format in YYYY first, in case it is in YY format to get accurate year std::string sCmdCSDF("AT+CSDF=1,2"); - std::string sRes = sendCommand(sCmdCSDF); - size_t endr = sRes.find(ICellularRadio::RSP_OK); + rc = sendBasicCommand(sCmdCSDF); - if (endr == std::string::npos) { - printWarning("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCSDF.c_str()); - return FAILURE; + if (rc != SUCCESS) { + printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + return rc; } - // Set command enables/disables the automatic time zone update - std::string sCmdCTZU("AT+CTZU=1"); - sRes = sendCommand(sCmdCTZU); - size_t endc = sRes.find(ICellularRadio::RSP_OK); + // Set command enables the automatic time zone update + std::string sCmdCTZU("AT+CTZU=3"); + rc = sendBasicCommand(sCmdCTZU); - if (endc == std::string::npos) { - printWarning("%s| Unable to set automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); - return FAILURE; + if (rc != SUCCESS) { + printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + return rc; } return SUCCESS; }
\ No newline at end of file diff --git a/src/MTS_IO_SequansRadio.cpp b/src/MTS_IO_SequansRadio.cpp index 33bd068..31c736f 100644 --- a/src/MTS_IO_SequansRadio.cpp +++ b/src/MTS_IO_SequansRadio.cpp @@ -569,27 +569,25 @@ const std::vector<std::string>& SequansRadio::getDiagCommands(bool) { return vCommands; } -ICellularRadio::CODE SequansRadio::getTimeUTC(void) { - printTrace("%s| Get Time in UTC", getName().c_str()); - +ICellularRadio::CODE SequansRadio::setTimeFormat() { + printTrace("%s| Set standard time format", getName().c_str()); + ICellularRadio::CODE rc; // Set year format in YYYY first, in case it is in YY format to get accurate year std::string sCmdCSDF("AT+CSDF=1,2"); - std::string sRes = sendCommand(sCmdCSDF); - size_t endr = sRes.find(ICellularRadio::RSP_OK); + rc = sendBasicCommand(sCmdCSDF); - if (endr == std::string::npos) { - printWarning("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCSDF.c_str()); - return FAILURE; + if (rc != SUCCESS) { + printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + return rc; } - // Set year format in YYYY first, in case it is in YY format to get accurate year + // Set command enables the automatic time zone update std::string sCmdCTZU("AT+CTZU=1"); - sRes = sendCommand(sCmdCTZU); - size_t endc = sRes.find(ICellularRadio::RSP_OK); + rc = sendBasicCommand(sCmdCTZU); - if (endc == std::string::npos) { - printWarning("%s| Unable to set automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); - return FAILURE; + if (rc != SUCCESS) { + printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + return rc; } return SUCCESS; }
\ No newline at end of file diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 2c50208..261fd34 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -1213,38 +1213,25 @@ const std::vector<std::string>& TelitRadio::getDiagCommands(bool) { return vCommands; } -ICellularRadio::CODE TelitRadio::getTimeUTC(void) { - printTrace("%s| Get Time in UTC", getName().c_str()); - +ICellularRadio::CODE TelitRadio::setTimeFormat(void) { + printTrace("%s| Set standard time format", getName().c_str()); + ICellularRadio::CODE rc; // Set year format in YYYY first, in case it is in YY format to get accurate year std::string sCmdCSDF("AT+CSDF=1,2"); - std::string sRes = sendCommand(sCmdCSDF); - size_t endr = sRes.find(ICellularRadio::RSP_OK); + rc = sendBasicCommand(sCmdCSDF); - if (endr == std::string::npos) { - printWarning("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCSDF.c_str()); - return FAILURE; + if (rc != SUCCESS) { + printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + return rc; } - // Set command enables/disables the automatic time zone update via NITZ. + // Set command enables the automatic time zone update std::string sCmdCTZU("AT+CTZU=1"); - sRes = sendCommand(sCmdCTZU); - size_t endc = sRes.find(ICellularRadio::RSP_OK); - - if (endc == std::string::npos) { - printWarning("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); - return FAILURE; - } - - //Enables/disables the automatic date/time updating and the - //Full Network Name applying. It enables also the #NITZ URC in the format. - std::string sCmdNITZ("AT#NITZ"); - sRes = sendCommand(sCmdNITZ); - size_t endn = sRes.find(ICellularRadio::RSP_OK); + rc = sendBasicCommand(sCmdCTZU); - if (endn == std::string::npos) { - printWarning("%s| Unable to set automatic time zone update for radio using command [%s]", getName().c_str(), sCmdNITZ.c_str()); - return FAILURE; + if (rc != SUCCESS) { + printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + return rc; } return SUCCESS; }
\ No newline at end of file |