From 289c724a4706e6f5ec2e73353502384671940c1c Mon Sep 17 00:00:00 2001 From: sdesai Date: Thu, 2 Mar 2023 14:20:52 -0600 Subject: Support Portal Case #5086148: use Cellular Radio timeas alternative to GPS or NTP --- src/MTS_IO_CellularRadio.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 3ce97ec..1c385ae 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -581,6 +581,7 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi std::string sCmd("AT+CCLK?"); std::string sResult = sendCommand(sCmd); size_t end = sResult.find(ICellularRadio::RSP_OK); + if (end == std::string::npos) { printWarning("%s| Unable to get Time from radio using command [%s]", m_sName.c_str(), sCmd.c_str()); return FAILURE; @@ -605,37 +606,15 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi return FAILURE; } - //The Date format is YY/MM/DD -> Change to MM/DD/YY - sDate = vDateParts[1] + "/" + vDateParts[2] + "/" + vDateParts[0]; + // Append "20" to the year. format is YYYY-MM-DD + sDate = "20" + vDateParts[0] + "-" + vDateParts[1] + "-" + vDateParts[2]; vParts = MTS::Text::split(vParts[1], '-'); - if(vParts.size() != 2) { + if(vParts.size() != 1) { printWarning("%s| Unable to parse Time from response [%s]", m_sName.c_str(), sResult.c_str()); return FAILURE; } sTime = vParts[0]; - - int32_t iZoneUnits; //the difference, expressed in quarters of an hour, between the local time and GMT - if(!MTS::Text::parse(iZoneUnits, MTS::Text::strip(vParts[1], '+'))) { - printWarning("%s| Unable to parse Time Zone from response [%s]", m_sName.c_str(), sResult.c_str()); - return FAILURE; - } - - int32_t iZone = iZoneUnits/4; //Divide by 4 to get hours difference - int32_t iZonePartial = (iZoneUnits % 4) * 15; //Remainder in minutes - std::string sPlusSign = "+"; - if(iZonePartial < 0) { - //Remove negative sign from partial and clear plus sign component - iZonePartial *= -1; - sPlusSign = ""; - } - std::stringstream ss; - ss << sPlusSign << iZone; - if(iZonePartial != 0) { - ss << ":" << iZonePartial; - } - - sTimeZone = ss.str(); return SUCCESS; } else { -- cgit v1.2.3 From 2e2359fd17c4d1fb7e7ef37aceccf766dd262d0b Mon Sep 17 00:00:00 2001 From: Mykola Salomatin Date: Wed, 15 Mar 2023 10:46:04 +0200 Subject: Fixed use of uninitialized variable --- src/MTS_IO_SequansRadio.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_SequansRadio.cpp b/src/MTS_IO_SequansRadio.cpp index 8133bbf..380dd80 100644 --- a/src/MTS_IO_SequansRadio.cpp +++ b/src/MTS_IO_SequansRadio.cpp @@ -282,7 +282,6 @@ ICellularRadio::CODE SequansRadio::getNetworkStatusTxPower(Json::Value& jData, J std::string sResult; std::string sPrefix; std::vector vParts; - int iValue; CODE rc; sCmd = "AT+SQNQRUP?"; @@ -312,7 +311,7 @@ ICellularRadio::CODE SequansRadio::getNetworkStatusTxPower(Json::Value& jData, J break; // invalid, not known or not detectable } if (fTxPow < -255 || fTxPow > 99) { - printDebug("%s| Network Status command returned unexpected value of txPower: [%s][%d]", getName().c_str(), sCmd.c_str(), iValue); + printDebug("%s| Network Status command returned unexpected value of txPower: [%s][%f]", getName().c_str(), sCmd.c_str(), fTxPow); break; } jDebug[ICellularRadio::KEY_TXPWR] = vParts[0]; -- cgit v1.2.3 From 050834e3cdd0f5f56ba15b09ca568ac6312c7699 Mon Sep 17 00:00:00 2001 From: sdesai Date: Wed, 15 Mar 2023 15:22:04 -0500 Subject: GP-139:Support Portal Case #5086148: use Cellular Radio timeas alternative to GPS or NTP --- src/MTS_IO_CellularRadio.cpp | 57 ++++++++++++++++++++++++++++++++++++-------- src/MTS_IO_QuectelRadio.cpp | 25 +++++++++++++++++++ src/MTS_IO_SequansRadio.cpp | 25 +++++++++++++++++++ src/MTS_IO_TelitRadio.cpp | 36 ++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 1c385ae..8cdaf44 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -577,6 +577,13 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi sDate = ""; sTime = ""; sTimeZone = ""; + std::vector vTimeParts; + std::string sSign = "+"; + + if(getTimeUTC() == FAILURE) { + printWarning("%s| Unable to set Time Parameters for radio [%s]", m_sName.c_str()); + return FAILURE;; + } std::string sCmd("AT+CCLK?"); std::string sResult = sendCommand(sCmd); @@ -588,7 +595,7 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi } size_t start = sResult.find("CCLK: "); - if(start != std::string::npos) { + if (start != std::string::npos) { start += sizeof("CCLK: "); std::string sValue = MTS::Text::trim(sResult.substr(start, end - start)); sValue = MTS::Text::strip(sValue, '"'); @@ -599,26 +606,56 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi return FAILURE; } - std::vector vDateParts = MTS::Text::split(vParts[0], '/'); if(vDateParts.size() != 3) { - printWarning("%s| Unable to parse Date from response [%s]", m_sName.c_str(), sResult.c_str()); + printWarning("%s| Unable to parse Date parts from response [%s]", m_sName.c_str(), sResult.c_str()); return FAILURE; } - // Append "20" to the year. format is YYYY-MM-DD - sDate = "20" + vDateParts[0] + "-" + vDateParts[1] + "-" + vDateParts[2]; + // The format is YYYY-MM-DD + sDate = vDateParts[0] + "-" + vDateParts[1] + "-" + vDateParts[2]; + + sTime = (vParts[1]); + + //E.g. 20:39:34-16. Split time and zone with + or - sign. + size_t psign = sTime.find("+"); + size_t nsign = sTime.find("-"); + + if (psign != std::string::npos) { + vTimeParts = MTS::Text::split(vParts[1], '+'); + } else if (nsign != std::string::npos) { + vTimeParts = MTS::Text::split(vParts[1], '-'); + sSign = "-"; + } - vParts = MTS::Text::split(vParts[1], '-'); - if(vParts.size() != 1) { - printWarning("%s| Unable to parse Time from response [%s]", m_sName.c_str(), sResult.c_str()); + if(vTimeParts.size() != 2) { + printWarning("%s| Unable to parse Time Zone from response [%s], size %d", m_sName.c_str(), sResult.c_str(),vTimeParts.size()); return FAILURE; } - sTime = vParts[0]; + + //Get just the UTC time without zone info + sTime = (vTimeParts[0]); + + int32_t iZoneUnits = stoi(vTimeParts[1]); //the difference, expressed in quarters of an hour, between the local time and GMT + int32_t iZone = iZoneUnits/4; //Divide by 4 to get hours difference + int32_t iZonePartial = (iZoneUnits % 4) * 15; //Remainder in minutes + + if (iZonePartial < 0) { + //Remove negative sign from partial and clear sign component + iZonePartial *= -1; + sSign = ""; + } + std::stringstream ss; + ss << sSign << iZone; + if(iZonePartial != 0) { + ss << ":" << iZonePartial; + } + + sTimeZone = ss.str(); return SUCCESS; } else { - printWarning("%s| Unable to get Time from radio using command [%s]", m_sName.c_str(), sCmd.c_str()); + printWarning("%s| Unable to parse Time from radio using command [%s]", m_sName.c_str(), sCmd.c_str()); } return FAILURE; diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 0c0c8ab..655fb38 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -1675,3 +1675,28 @@ const std::vector& QuectelRadio::getDiagCommands(bool) { return vCommands; } + +ICellularRadio::CODE QuectelRadio::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 + 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 automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); + return FAILURE; + } + return SUCCESS; +} \ No newline at end of file diff --git a/src/MTS_IO_SequansRadio.cpp b/src/MTS_IO_SequansRadio.cpp index a48a309..33bd068 100644 --- a/src/MTS_IO_SequansRadio.cpp +++ b/src/MTS_IO_SequansRadio.cpp @@ -568,3 +568,28 @@ const std::vector& SequansRadio::getDiagCommands(bool) { return vCommands; } + +ICellularRadio::CODE SequansRadio::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 year format in YYYY first, in case it is in YY format to get accurate year + 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 automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); + return FAILURE; + } + return SUCCESS; +} \ No newline at end of file diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 21af65d..2c50208 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -1212,3 +1212,39 @@ const std::vector& 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 -- cgit v1.2.3 From 8fce7442bbc63b744905f9febc21aad9cf5074fd Mon Sep 17 00:00:00 2001 From: sdesai Date: Mon, 20 Mar 2023 14:32:37 -0500 Subject: Support Portal Case #5086148: use Cellular Radio timeas alternative to GPS or NTP --- src/MTS_IO_CellularRadio.cpp | 2 +- src/MTS_IO_QuectelRadio.cpp | 28 +++++++++++++--------------- src/MTS_IO_SequansRadio.cpp | 26 ++++++++++++-------------- src/MTS_IO_TelitRadio.cpp | 37 ++++++++++++------------------------- 4 files changed, 38 insertions(+), 55 deletions(-) (limited to 'src') 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 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& 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& 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& 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 -- cgit v1.2.3 From 96a6958ec2242d1ff7bc0afa83e25044e61800e1 Mon Sep 17 00:00:00 2001 From: sdesai Date: Mon, 20 Mar 2023 15:19:05 -0500 Subject: Support Portal Case #5086148: use Cellular Radio timeas alternative to GPS or NTP --- src/MTS_IO_QuectelRadio.cpp | 4 ++-- src/MTS_IO_SequansRadio.cpp | 4 ++-- src/MTS_IO_TelitRadio.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 760cf6d..2bc4fb6 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -1684,7 +1684,7 @@ ICellularRadio::CODE QuectelRadio::setTimeFormat(void) { rc = sendBasicCommand(sCmdCSDF); if (rc != SUCCESS) { - printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + printError("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCSDF.c_str()); return rc; } @@ -1693,7 +1693,7 @@ ICellularRadio::CODE QuectelRadio::setTimeFormat(void) { rc = sendBasicCommand(sCmdCTZU); if (rc != SUCCESS) { - printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + printError("%s| Unable to set automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); return rc; } return SUCCESS; diff --git a/src/MTS_IO_SequansRadio.cpp b/src/MTS_IO_SequansRadio.cpp index 31c736f..d2a2efb 100644 --- a/src/MTS_IO_SequansRadio.cpp +++ b/src/MTS_IO_SequansRadio.cpp @@ -577,7 +577,7 @@ ICellularRadio::CODE SequansRadio::setTimeFormat() { rc = sendBasicCommand(sCmdCSDF); if (rc != SUCCESS) { - printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + printError("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCSDF.c_str()); return rc; } @@ -586,7 +586,7 @@ ICellularRadio::CODE SequansRadio::setTimeFormat() { rc = sendBasicCommand(sCmdCTZU); if (rc != SUCCESS) { - printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + printError("%s| Unable to set automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); return rc; } return SUCCESS; diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 261fd34..d73dc0a 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -1221,7 +1221,7 @@ ICellularRadio::CODE TelitRadio::setTimeFormat(void) { rc = sendBasicCommand(sCmdCSDF); if (rc != SUCCESS) { - printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + printError("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCSDF.c_str()); return rc; } @@ -1230,7 +1230,7 @@ ICellularRadio::CODE TelitRadio::setTimeFormat(void) { rc = sendBasicCommand(sCmdCTZU); if (rc != SUCCESS) { - printError("%s| Failed to set diversity for WCDMA network mode: [%d]", getName().c_str(), rc); + printError("%s| Unable to set automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); return rc; } return SUCCESS; -- cgit v1.2.3 From 91c623896442013d82f59e6e06e70523e9046b8c Mon Sep 17 00:00:00 2001 From: sdesai Date: Thu, 23 Mar 2023 16:37:24 -0500 Subject: Support Portal Case #5086148: use Cellular Radio time as alternative to GPS or NTP --- src/MTS_IO_CellularRadio.cpp | 29 +++++++++++++++-------------- src/MTS_IO_QuectelRadio.cpp | 4 ++-- 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 0b90b55..bc1fee1 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -580,9 +580,9 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi std::vector vTimeParts; std::string sSign = "+"; - if(setTimeFormat() == FAILURE) { + if (setTimeFormat() == FAILURE) { printWarning("%s| Unable to set Time Parameters for radio [%s]", m_sName.c_str()); - return FAILURE;; + return FAILURE; } std::string sCmd("AT+CCLK?"); @@ -601,13 +601,13 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi sValue = MTS::Text::strip(sValue, '"'); std::vector vParts = MTS::Text::split(sValue, ','); - if(vParts.size() != 2) { + if (vParts.size() != 2) { printWarning("%s| Unable to parse Date from response [%s]", m_sName.c_str(), sResult.c_str()); return FAILURE; } std::vector vDateParts = MTS::Text::split(vParts[0], '/'); - if(vDateParts.size() != 3) { + if (vDateParts.size() != 3) { printWarning("%s| Unable to parse Date parts from response [%s]", m_sName.c_str(), sResult.c_str()); return FAILURE; } @@ -622,32 +622,33 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi size_t nsign = sTime.find("-"); if (psign != std::string::npos) { - vTimeParts = MTS::Text::split(vParts[1], '+'); + vTimeParts = MTS::Text::split(vParts[1], '+'); } else if (nsign != std::string::npos) { vTimeParts = MTS::Text::split(vParts[1], '-'); sSign = "-"; + } else { + sSign = ""; } - if(vTimeParts.size() != 2) { + if (vTimeParts.size() != 2) { printWarning("%s| Unable to parse Time Zone from response [%s], size %d", m_sName.c_str(), sResult.c_str(),vTimeParts.size()); return FAILURE; } - //Get just the UTC time without zone info + //Get local time sTime = (vTimeParts[0]); - int32_t iZoneUnits = stoi(vTimeParts[1]); //the difference, expressed in quarters of an hour, between the local time and GMT + int32_t iZoneUnits = 0; //the difference, expressed in quarters of an hour, between the local time and GMT + if (!MTS::Text::parse(iZoneUnits, vTimeParts[1])) { + printWarning("%s| Unable to parse Time Zone units from response [%s], size %d", m_sName.c_str(), sResult.c_str(),vTimeParts.size()); + return FAILURE; + } int32_t iZone = iZoneUnits/4; //Divide by 4 to get hours difference int32_t iZonePartial = (iZoneUnits % 4) * 15; //Remainder in minutes - if (iZonePartial < 0) { - //Remove negative sign from partial and clear sign component - iZonePartial *= -1; - sSign = ""; - } std::stringstream ss; ss << sSign << iZone; - if(iZonePartial != 0) { + if (iZonePartial != 0) { ss << ":" << iZonePartial; } diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 2bc4fb6..defe863 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -1676,7 +1676,7 @@ const std::vector& QuectelRadio::getDiagCommands(bool) { return vCommands; } -ICellularRadio::CODE QuectelRadio::setTimeFormat(void) { +ICellularRadio::CODE QuectelRadio::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 @@ -1689,7 +1689,7 @@ ICellularRadio::CODE QuectelRadio::setTimeFormat(void) { } // Set command enables the automatic time zone update - std::string sCmdCTZU("AT+CTZU=3"); + std::string sCmdCTZU("AT+CTZU=1"); rc = sendBasicCommand(sCmdCTZU); if (rc != SUCCESS) { -- cgit v1.2.3 From 23f75ed608922db0c22a01d74f1b38f0bfed43dd Mon Sep 17 00:00:00 2001 From: sdesai Date: Fri, 24 Mar 2023 17:40:31 -0500 Subject: Support Portal Case #5086148: use Cellular Radio time as alternative to GPS or NTP --- src/MTS_IO_SequansRadio.cpp | 24 +++--------------------- src/MTS_IO_TelitRadio.cpp | 4 ++-- 2 files changed, 5 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_SequansRadio.cpp b/src/MTS_IO_SequansRadio.cpp index d2a2efb..5f85b58 100644 --- a/src/MTS_IO_SequansRadio.cpp +++ b/src/MTS_IO_SequansRadio.cpp @@ -570,24 +570,6 @@ const std::vector& SequansRadio::getDiagCommands(bool) { } 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"); - rc = sendBasicCommand(sCmdCSDF); - - if (rc != SUCCESS) { - printError("%s| Unable to set year format for radio using command [%s]", getName().c_str(), sCmdCSDF.c_str()); - return rc; - } - - // Set command enables the automatic time zone update - std::string sCmdCTZU("AT+CTZU=1"); - rc = sendBasicCommand(sCmdCTZU); - - if (rc != SUCCESS) { - printError("%s| Unable to set automatic time zone update for radio using command [%s]", getName().c_str(), sCmdCTZU.c_str()); - return rc; - } - return SUCCESS; -} \ No newline at end of file + // AT+CSDF does not work on CB610L. Also, since CB610L does not return the correct time anyway. + return NOT_APPLICABLE; +} diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index d73dc0a..be307e6 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -1213,7 +1213,7 @@ const std::vector& TelitRadio::getDiagCommands(bool) { return vCommands; } -ICellularRadio::CODE TelitRadio::setTimeFormat(void) { +ICellularRadio::CODE TelitRadio::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 @@ -1234,4 +1234,4 @@ ICellularRadio::CODE TelitRadio::setTimeFormat(void) { return rc; } return SUCCESS; -} \ No newline at end of file +} -- cgit v1.2.3 From 5a0bc9dda829197048155380c3e344e28365aebc Mon Sep 17 00:00:00 2001 From: sdesai Date: Mon, 27 Mar 2023 09:00:20 -0500 Subject: Support Portal Case #5086148: use Cellular Radio time as alternative to GPS or NTP --- src/MTS_IO_QuectelRadio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index defe863..c4b6ac4 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -1689,7 +1689,7 @@ ICellularRadio::CODE QuectelRadio::setTimeFormat() { } // Set command enables the automatic time zone update - std::string sCmdCTZU("AT+CTZU=1"); + std::string sCmdCTZU("AT+CTZU=3"); rc = sendBasicCommand(sCmdCTZU); if (rc != SUCCESS) { -- cgit v1.2.3 From 582634c91a778dba7047a69b5559f849d03be112 Mon Sep 17 00:00:00 2001 From: sdesai Date: Mon, 27 Mar 2023 11:53:13 -0500 Subject: Support Portal Case #5086148: use Cellular Radio time as alternative to GPS or NTP --- src/MTS_IO_CellularRadio.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index bc1fee1..f0df7fd 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -577,12 +577,14 @@ ICellularRadio::CODE CellularRadio::getTime(std::string& sDate, std::string& sTi sDate = ""; sTime = ""; sTimeZone = ""; + CODE rc; std::vector vTimeParts; std::string sSign = "+"; - if (setTimeFormat() == FAILURE) { + rc = setTimeFormat(); + if (rc != SUCCESS) { printWarning("%s| Unable to set Time Parameters for radio [%s]", m_sName.c_str()); - return FAILURE; + return rc; } std::string sCmd("AT+CCLK?"); -- cgit v1.2.3