From 1f7987d546384b6b9ef0079dac5c903148a59210 Mon Sep 17 00:00:00 2001 From: "andrii.davydenko" Date: Tue, 16 Nov 2021 11:51:32 +0200 Subject: Update MODBUS slave feature, Rogers Certification issue --- src/MTS_IO_TelitRadio.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 6 deletions(-) (limited to 'src/MTS_IO_TelitRadio.cpp') diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 1f5f4cf..5db2ddf 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -1013,8 +1014,11 @@ ICellularRadio::CODE TelitRadio::abortFotaWriteABD() { } ICellularRadio::CODE TelitRadio::fumoWaitUpgradeFinished(ICellularRadio::UpdateCb& stepCb) { - const uint32_t duAttachTimeout = 6 * 60 * 1000;// wait for 6 minutes for the radio to attach - const uint32_t duUrcTimeout = 60 * 1000; // wait for 1 minutes for the next URC message + const uint32_t duFirstAttachTimeout = 6 * 60 * 1000; // wait for 6 minutes for the radio to attach + const uint32_t duSecondAttachTimeout = 60 * 1000; // wait for 1 minute for the radio to attach + const uint32_t duThirdAttachTimeout = 5 * 1000; // wait for 5 seconds for the radio to attach + const uint32_t duUrcTimeout = 60 * 1000; // wait for 1 minutes for the next URC message + const uint32_t timeoutMillis = 30 * 60 * 1000; // wait for 30 minutes in case if radio will send invalid message (garbage) const std::string sFotaUrcPrefix = "#OTAEV:"; // prefix for the URC notification messages const std::string sFotaUrcEndSuccess = "Module Upgraded To New Fw"; const std::string sFotaUrcEndFailed = "OTA Fw Upgrade Failed"; @@ -1024,17 +1028,32 @@ ICellularRadio::CODE TelitRadio::fumoWaitUpgradeFinished(ICellularRadio::UpdateC std::string sResponse; // It's now detached. Try to reconnect - if (!resetConnection(duAttachTimeout)) { - printError("Can't connect to the radio in %d ms", (duAttachTimeout)); + if (!resetConnection(duFirstAttachTimeout)) { + printError("Can't connect to the radio in %d ms", (duFirstAttachTimeout)); callNextStep(stepCb, "FUMO Error: unable to obtain radio after reset"); return ERROR; } - while (true) { + Timer timer; + timer.start(); - sResponse = sendCommand("", vFotaBailStrings, duUrcTimeout, 0x00); + while (timer.getMillis() <= (uint64_t)timeoutMillis) { + + sResponse = waitResponse(vFotaBailStrings, duUrcTimeout); printTrace("Radio response: [%s]", sResponse.c_str()); + if (sResponse.empty()) { + // Radio detached again. Try to reconnect + if (!resetConnection(duSecondAttachTimeout)) { + printError("Can't connect to the radio in %d ms", (duSecondAttachTimeout)); + callNextStep(stepCb, "FUMO Error: unable to obtain radio after second reset"); + return ERROR; + } + + sResponse = waitResponse(vFotaBailStrings, duUrcTimeout); + printTrace("Radio response: [%s]", sResponse.c_str()); + } + if (sResponse.find(sFotaUrcPrefix) == std::string::npos) { printError("No URC messages from the radio in %d ms", duUrcTimeout); callNextStep(stepCb, "FUMO Error: timeout, radio is not responding"); @@ -1058,6 +1077,13 @@ ICellularRadio::CODE TelitRadio::fumoWaitUpgradeFinished(ICellularRadio::UpdateC } + // Required to set echo to disable, so we performed resetConnection again. + if (!resetConnection(duThirdAttachTimeout)) { + printError("Can't connect to the radio in %d ms", (duThirdAttachTimeout)); + callNextStep(stepCb, "FUMO Error: unable to reset connection to radio"); + return ERROR; + } + return rc; } @@ -1083,3 +1109,73 @@ ICellularRadio::CODE TelitRadio::fumoCheckNewFirmware(ICellularRadio::UpdateCb& return rc; } + +ICellularRadio::CODE TelitRadio::getSelectedBandsRaw(std::string& sRawBands) { + printTrace("%s| Acquiring selected bands", getName().c_str()); + CODE rc; + + const std::string sCommand = "AT#BND?"; + const std::string sLabel = "#BND: "; + const int dTimeout = 1000; + std::string sResult; + + rc = sendBasicQuery(sCommand, sLabel, sResult, dTimeout); + if (rc != SUCCESS) { + return rc; + } + + std::vector vParts = MTS::Text::split(sResult, ','); + uint8_t iNumBandParams = 0; + + if (vParts.size() > 0) { + uint16_t iSelectedBands = 0; + if (!isContainsSignChar(vParts[0]) && MTS::Text::parse(iSelectedBands, MTS::Text::trim(vParts[0]))) { + sRawBands = MTS::Text::formatHex(iSelectedBands); // GSM bands + iNumBandParams++; + } else { + printWarning("%s| Error during parse number from string: [%s]. Assuming that no GSM bands selected", getName().c_str(), vParts[0].c_str()); + sRawBands = "ffff"; + } + } else { + sRawBands = "ffff"; + } + + if (vParts.size() > 1) { + uint16_t iSelectedBands = 0; + if (!isContainsSignChar(vParts[1]) && MTS::Text::parse(iSelectedBands, MTS::Text::trim(vParts[1]))) { + sRawBands += "," + MTS::Text::formatHex(iSelectedBands); // WCDMA bands + iNumBandParams++; + } else { + printWarning("%s| Error during parse number from string: [%s]. Assuming that no WCDMA bands selected", getName().c_str(), vParts[0].c_str()); + sRawBands += ",ffff"; + } + } else { + sRawBands += ",ffff"; + } + + if (vParts.size() > 2) { + uint64_t iSelectedBands = 0; + if (!isContainsSignChar(vParts[2]) && MTS::Text::parseHex(iSelectedBands, MTS::Text::trim(vParts[2]))) { + sRawBands += "," + MTS::Text::formatHex(iSelectedBands); // LTE bands + iNumBandParams++; + } else { + printWarning("%s| Error during parse number from string: [%s]. Assuming that no LTE bands selected", getName().c_str(), vParts[0].c_str()); + sRawBands += ",ffffffffffffffff"; + } + } else { + sRawBands += ",ffffffffffffffff"; + } + + // All other fragments - ignored for now. + + // Return success if at least one band param was extracted; otherwise failure + return (iNumBandParams > 0) ? SUCCESS : FAILURE; +} + +bool MTS::IO::TelitRadio::isContainsSignChar(const std::string& str) { + if (str.find_first_of("+-") == std::string::npos) { + return false; + } + + return true; +} -- cgit v1.2.3 From c04f0c7224311c2b9828e653ed4014e1ccf7a82f Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 16 Dec 2022 16:45:19 +0200 Subject: LE910: Do not exetute #RFSTS if the SIM card is PUK-locked Executing AT#RFSTS while the SIM card is locked by PIN or PUK causes a deadlock in the legacy LE910 (LAT1, LEU1, LVW2) firmware. Avoid executing AT#RFSTS if the SIM card is locked by PUK. --- src/MTS_IO_TelitRadio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/MTS_IO_TelitRadio.cpp') diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 5db2ddf..2a07939 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -325,7 +325,7 @@ ICellularRadio::CODE TelitRadio::getNetworkStatus(Json::Value& jData) { printTrace("%s| Network Status:\n%s\n", getName().c_str(), jData.toStyledString().c_str()); return SUCCESS; //return SUCCESS because getCommonNetworkStats() succeeded at top of this function } - if (sResult.find("SIM PIN") != std::string::npos) { + if (sResult.find("SIM PIN") != std::string::npos || sResult.find("SIM PUK") != std::string::npos) { printError("%s| The SIM is locked and must first be unlocked", getName().c_str()); printTrace("%s| Network Status:\n%s\n", getName().c_str(), jData.toStyledString().c_str()); return SUCCESS; //return SUCCESS because getCommonNetworkStats() succeeded at top of this function -- cgit v1.2.3 From 4b448e3c5daf34062861d0261c5a2253638b8100 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 16 Dec 2022 17:04:08 +0200 Subject: [GP-1195] Cellular debugging - add a query Define the set of debugging AT commands and a function to execute such commands. The function executes the commands one-by-one end returns raw command outputs. To be used by radio-query --diagnostics. --- src/MTS_IO_TelitRadio.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/MTS_IO_TelitRadio.cpp') diff --git a/src/MTS_IO_TelitRadio.cpp b/src/MTS_IO_TelitRadio.cpp index 2a07939..4a0a8b2 100644 --- a/src/MTS_IO_TelitRadio.cpp +++ b/src/MTS_IO_TelitRadio.cpp @@ -1179,3 +1179,35 @@ bool MTS::IO::TelitRadio::isContainsSignChar(const std::string& str) { return true; } + +const std::vector& TelitRadio::getDiagCommands(bool) { + // Declare as static to initialize only when used, but cache the results. + const static std::vector vCommands { + // Radio model and firmware: + "AT+CGMI", "AT+CGMM", "AT+CGMR", "AT#SWPKGV", "AT#CFVR", + + // Current operator profile on the radio side: + "AT#FWSWITCH?", "AT+CGSN", + + // SIM card information: + "AT#SIMDET?", "AT#CCID", "AT+CPIN?", "AT#PCT", + + // Operating mode of the radio: + "AT+CFUN?", + + // Low-level network settings: + "AT+WS46?", "AT#RXDIV", "AT#CALLDISA?", "AT+CEMODE?", + + // Data connection configuration: + "AT+CGDCONT?", "AT#PDPAUTH?", + + // Registration and connection to the tower: + "AT+CIND?", "AT+CSQ", "AT+COPS?", "AT+CREG?", "AT+CGREG?", "AT+CEREG?", + "AT#RFSTS", "AT#PSNT?", "AT#MONI", + + // Data connection status: + "AT+CGACT?", "AT+CGCONTRDP=1", "AT+CGCONTRDP=2", "AT+CGCONTRDP=3" + }; + + return vCommands; +} -- cgit v1.2.3