diff options
Diffstat (limited to 'src/MTS_IO_TelitRadio.cpp')
| -rw-r--r-- | src/MTS_IO_TelitRadio.cpp | 108 | 
1 files changed, 102 insertions, 6 deletions
| 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 <mts/MTS_Logger.h>  #include <mts/MTS_Thread.h>  #include <mts/MTS_Text.h> +#include <mts/MTS_Timer.h>  #include <unistd.h> @@ -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<std::string> 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; +} | 
