summaryrefslogtreecommitdiff
path: root/src/MTS_IO_TelitRadio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTS_IO_TelitRadio.cpp')
-rw-r--r--src/MTS_IO_TelitRadio.cpp139
1 files changed, 36 insertions, 103 deletions
diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp
index 00c1686..2c50208 100644
--- a/src/MTS_IO_TelitRadio.cpp
+++ b/src/MTS_IO_TelitRadio.cpp
@@ -1178,109 +1178,6 @@ bool MTS::IO::TelitRadio::isContainsSignChar(const std::string& str) {
return true;
}
-std::vector<std::string> TelitRadio::getSupportedPdpContextAuthTypes() const {
- return {
- VALUE_PDP_CONTEXT_AUTH_TYPE_NONE,
- VALUE_PDP_CONTEXT_AUTH_TYPE_PAP,
- VALUE_PDP_CONTEXT_AUTH_TYPE_CHAP
- };
-}
-
-ICellularRadio::CODE TelitRadio::isPdpContextAuthSupported(bool& isSupported) {
- std::string sCmd("AT#PDPAUTH=?");
- return isCommandSupported(sCmd, isSupported);
-}
-
-ICellularRadio::CODE TelitRadio::fillPdpContextAuthFields(Json::Value& jData) {
- CODE rc;
- std::string sCmd("AT#PDPAUTH?");
- std::string sResult;
-
- // #PDPAUTH: 1,0
- // #PDPAUTH: 2,0
- // #PDPAUTH: 3,0
- // #PDPAUTH: 4,1,"admin"
- rc = sendBasicQuery(sCmd, "", sResult, 300);
-
- if (SUCCESS != rc) {
- return rc;
- }
-
- std::vector<std::string> vContexts = MTS::Text::split(sResult, "#PDPAUTH:");
- std::string sContextId;
-
- for (std::string& sLine : vContexts) {
- sLine = MTS::Text::trim(sLine);
-
- if (sLine.empty()) {
- continue;
- }
-
- // 4,1,"admin"
- // [0][1] [2]
- auto vAuthParams = MTS::Text::split(sLine, ",");
-
- // Contains 2 elements when the authentication type is NONE, contains 3 elements in other cases
- if (vAuthParams.size() < 2) {
- printError("%s| Failed to parse PDP context authentication string [%s]", getName().c_str(), sLine.c_str());
- return FAILURE;
- }
-
- sContextId = vAuthParams[0];
-
- uint8_t iValue;
- if (! MTS::Text::parse(iValue, vAuthParams[1])) {
- printError("%s| Failed to parse PDP context authentication type [%s]", getName().c_str(), vAuthParams[1].c_str());
- return FAILURE;
- }
-
- rc = convertPdpContextAuthTypeToString(static_cast<PDP_CONTEXT_AUTH_TYPE>(iValue), sResult);
- if (SUCCESS != rc) {
- printError("%s| Failed to convert PDP context authentication type to string [%d]", getName().c_str(), iValue);
- return rc;
- }
-
- jData[sContextId][KEY_PDP_CONTEXT_AUTH_TYPE] = sResult;
-
- if (iValue == PDP_CONTEXT_AUTH_TYPE::NONE) {
- continue;
- }
-
- if (vAuthParams.size() < 3) {
- printError("%s| Failed to parse PDP context authentication string [%s]", getName().c_str(), sLine.c_str());
- return FAILURE;
- }
-
- jData[sContextId][KEY_PDP_CONTEXT_AUTH_USERNAME] = MTS::Text::trim(vAuthParams[2], '"');
- }
-
- return SUCCESS;
-}
-
-ICellularRadio::CODE TelitRadio::setPdpContextAuth(const PdpContextInfo& pdpContext) {
- printTrace("%s| Setting PDP context authentication to the radio", getName().c_str());
-
- CODE rc;
- std::string sCmd = "AT#PDPAUTH=";
- PDP_CONTEXT_AUTH_TYPE eAuthType;
-
- sCmd += pdpContext.sId + ",";
-
- rc = convertStringToPdpContextAuthType(pdpContext.sAuthType, eAuthType);
-
- if (SUCCESS != rc) {
- return rc;
- }
-
- sCmd += std::to_string(eAuthType);
-
- if (PDP_CONTEXT_AUTH_TYPE::NONE != eAuthType) {
- sCmd += "," + pdpContext.sUsername + "," + pdpContext.sPassword;
- }
-
- return sendBasicCommand(sCmd);
-}
-
const std::vector<std::string>& TelitRadio::getDiagCommands(bool) {
// Declare as static to initialize only when used, but cache the results.
const static std::vector<std::string> vCommands {
@@ -1315,3 +1212,39 @@ const std::vector<std::string>& TelitRadio::getDiagCommands(bool) {
return vCommands;
}
+
+ICellularRadio::CODE TelitRadio::getTimeUTC(void) {
+ printTrace("%s| Get Time in UTC", getName().c_str());
+
+ // 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);
+
+ 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;
+ }
+
+ // Set command enables/disables the automatic time zone update via NITZ.
+ 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);
+
+ 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;
+ }
+ return SUCCESS;
+} \ No newline at end of file