From 28b673dd4db086f1957c5cdae281f54980715e36 Mon Sep 17 00:00:00 2001 From: Mykola Salomatin Date: Wed, 29 Sep 2021 16:20:21 +0300 Subject: [MTX-4206] mPower R.6.0: Making Telit and Quectel radios data-only on AT&T network. GP-1364 Add 2 functions for Telit and Quectel modems: - disableVoiceSupport: disable voice support (IMS and CSFB) and enable SMS only registration flag. - getVoiceSupport: get voice support configuration for the current radio. --- src/MTS_IO_CellularRadio.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/MTS_IO_CellularRadio.cpp') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 1850a60..6236c3f 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -1609,3 +1609,57 @@ ICellularRadio::CODE CellularRadio::getUeModeOfOperation(ICellularRadio::UE_MODE mode = ICellularRadio::UE_MODES_OF_OPERATION::UNKNOWN_MODE; return NOT_APPLICABLE; } + +ICellularRadio::CODE CellularRadio::disableVoiceSupport() { + printTrace("%s| Disable Voice Support: not applicable", m_sName.c_str()); + return NOT_APPLICABLE; +} + +ICellularRadio::CODE CellularRadio::getVoiceSupport(Json::Value& jData) { + bool bVoiceEnabled, bSmsOnly; + CODE rc; + + rc = getVoiceSupport(bVoiceEnabled, bSmsOnly); + + if (rc == SUCCESS) { + jData[KEY_VOICE_ENABLED] = bVoiceEnabled; + jData[KEY_SMS_ONLY] = bSmsOnly; + } + + return rc; +} + +ICellularRadio::CODE CellularRadio::getVoiceSupport(bool&, bool&) { + printTrace("%s| Get Voice Support: not applicable", m_sName.c_str()); + return NOT_APPLICABLE; +} + +ICellularRadio::CODE CellularRadio::sendBasicQuery(const std::string& sCmd, const std::string& sLabel, std::string& sResult, int32_t iTimeoutMillis, const char& ESC) { + sResult = sendCommand(sCmd, DEFAULT_BAIL_STRINGS, iTimeoutMillis, ESC); + printTrace("%s| Got response from the radio: [%s]", getName().c_str(), sResult.c_str()); + + if (sResult.empty()) { + return NO_RESPONSE; + } + + if (sResult.rfind(ICellularRadio::RSP_ERROR) != std::string::npos) { + return ERROR; + } + + size_t end = sResult.rfind(ICellularRadio::RSP_OK); + if (end == std::string::npos) { + printError("%s| \"OK\" not found in the response: [%s]", getName().c_str(), sResult.c_str()); + return FAILURE; + } + + size_t start = sResult.find(sLabel); + if (start == std::string::npos) { + printError("%s| Unexpected radio response: [%s]", getName().c_str(), sResult.c_str()); + return FAILURE; + } + + start += sLabel.length(); + sResult = MTS::Text::trim(sResult.substr(start, end-start)); + + return SUCCESS; +} -- cgit v1.2.3 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_CellularRadio.cpp | 122 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 107 insertions(+), 15 deletions(-) (limited to 'src/MTS_IO_CellularRadio.cpp') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 6236c3f..afdfc1e 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -147,7 +147,9 @@ bool CellularRadio::resetConnection(uint32_t iTimeoutMillis) { } else { printInfo("%s| Successfully re-opened radio port [%s]", m_sName.c_str(), m_sRadioPort.c_str()); printDebug("%s| Recovering 'echo' after connection reset", m_sName.c_str()); // see CellularRadio::initialize - setEcho(m_bEchoEnabled); + if (setEcho(m_bEchoEnabled) != SUCCESS) { + printWarning("%s| Failed to recover 'echo' after connection reset", m_sName.c_str()); + } break; } @@ -425,26 +427,110 @@ ICellularRadio::CODE CellularRadio::getType(std::string& sType) { ICellularRadio::CODE CellularRadio::getCarrier(std::string& sCarrier) { printTrace("%s| Get Carrier", m_sName.c_str()); - if (m_sCarrier == "") { - std::string sMcc; - std::string sMnc; - if (getSimMccMnc(sMcc, sMnc) == CODE::SUCCESS) { - Json::Value jLookup = MccMncTable::getInstance()->lookup(sMcc, sMnc); - printTrace("%s| MCC-MNC Lookup: [%s][%s][%s]", m_sName.c_str(), - sMcc.c_str(), sMnc.c_str(), jLookup.toStyledString().c_str()); - if (jLookup.isMember(ICellularRadio::KEY_CARRIER)) { - m_sCarrier = jLookup[ICellularRadio::KEY_CARRIER].asString(); - } else { - printWarning("%s| MCC-MNC Lookup did not contain carrier", m_sName.c_str()); - return FAILURE; + + CODE rc = SUCCESS; + std::string t_sCarrier; + + do { + if (m_sCarrier == "") { + rc = getCarrierFromSimSpn(t_sCarrier); + if (rc == SUCCESS) { + m_sCarrier = t_sCarrier; + break; + } + + rc = getCarrierFromSimMccMnc(t_sCarrier); + if (rc == SUCCESS) { + m_sCarrier = t_sCarrier; + break; } + } + } while (false); + + sCarrier = m_sCarrier; + return rc; +} + +ICellularRadio::CODE CellularRadio::getCarrierFromSimMccMnc(std::string& sCarrier) { + printTrace("%s| Get Carrier from SIM MCC/MNC", m_sName.c_str()); + + std::string sMcc; + std::string sMnc; + + CODE rc; + + rc = getSimMccMnc(sMcc, sMnc); + if (rc == SUCCESS) { + Json::Value jLookup = MccMncTable::getInstance()->lookup(sMcc, sMnc); + printTrace("%s| MCC-MNC Lookup: [%s][%s][%s]", m_sName.c_str(), + sMcc.c_str(), sMnc.c_str(), jLookup.toStyledString().c_str()); + if (jLookup.isMember(ICellularRadio::KEY_CARRIER)) { + sCarrier = jLookup[ICellularRadio::KEY_CARRIER].asString(); } else { - printWarning("%s| SIM did no contain MCC or MNC", m_sName.c_str()); + printWarning("%s| MCC-MNC Lookup does not contain the carrier", m_sName.c_str()); return FAILURE; } + } else { + printWarning("%s| SIM did no contain MCC or MNC", m_sName.c_str()); + return rc; + } + + return SUCCESS; +} + +ICellularRadio::CODE CellularRadio::getCarrierFromSimSpn(std::string& sCarrier) { + printTrace("%s| Get Carrier from SIM SPN", m_sName.c_str()); + + const int iEfspnId = 0x6F46; + const uint8_t iOffsetHigh = 1; + const uint8_t iOffsetLow = 0; + const uint8_t iNumBytes = 16; + + CODE rc; + std::string sEFspnContent; + + rc = simAccessReadBinary(iEfspnId, iOffsetLow, iOffsetHigh, iNumBytes, sEFspnContent); + if (rc != SUCCESS) { + printError("%s| Failed to determine the service provider name", m_sName.c_str()); + return rc; + } + + if (sEFspnContent.length() != 32) { + printError("%s| Invalid length of the service provider name: expected [32], actual: [%d]", m_sName.c_str(), sEFspnContent.length()); + return FAILURE; + } + + uint8_t iSpnPart; + + for (size_t i = 0; i < sEFspnContent.length(); i += 2) { + std::string sPart = sEFspnContent.substr(i, 2); + + // parse hex to unsigned byte + if (!MTS::Text::parseHex(iSpnPart, sPart)) { + printError("%s| Unexpected SIM EFspn content: [%s]", m_sName.c_str(), sEFspnContent.c_str()); + return FAILURE; + } + + // skip 0xFF bytes + if (iSpnPart == 0xFF) { + continue; + } + + sCarrier.push_back(iSpnPart); + } + + /** + * Example of radio response when SIM card does not contain the service provider name: + * Raw response from the radio: [ + * +CRSM: 144,0,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + * OK + * ] + */ + if (sCarrier.empty()) { + printError("%s| SIM EFspn does not contain the service provider name", m_sName.c_str()); + return FAILURE; } - sCarrier = m_sCarrier; return SUCCESS; } @@ -1663,3 +1749,9 @@ ICellularRadio::CODE CellularRadio::sendBasicQuery(const std::string& sCmd, cons return SUCCESS; } + +ICellularRadio::CODE CellularRadio::getSelectedBandsRaw(std::string& sRawBands) +{ + printTrace("%s| Acquiring selected bands: not applicable", m_sName.c_str()); + return NOT_APPLICABLE; +} -- cgit v1.2.3 From b8991e7f15f30ad21725b113df773db7beaa69d8 Mon Sep 17 00:00:00 2001 From: Andrii Davydenko Date: Wed, 2 Nov 2022 15:35:51 +0200 Subject: [MTX-4694][GP-1791] MTCAP3 mPower R.6.1.X: LNA7D support - APN setup behavior when provider is Verizon Implement getting the CGDCONT from the modem Implement setting the CGDCONT to the modem --- src/MTS_IO_CellularRadio.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'src/MTS_IO_CellularRadio.cpp') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index afdfc1e..3de96ce 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -1755,3 +1755,117 @@ ICellularRadio::CODE CellularRadio::getSelectedBandsRaw(std::string& sRawBands) printTrace("%s| Acquiring selected bands: not applicable", m_sName.c_str()); return NOT_APPLICABLE; } + +ICellularRadio::CODE CellularRadio::getPdpContexts(Json::Value& jData) { + printTrace("%s| Fetching the list of PDP contexts from the radio", getName().c_str()); + CODE rc; + + const std::string sCommand = "AT+CGDCONT?"; + const int dTimeout = 1000; + std::string sResult; + + rc = sendBasicQuery(sCommand, "", sResult, dTimeout); + if (rc != SUCCESS) { + return rc; + } + + std::vector vContexts = MTS::Text::split(sResult, "+CGDCONT: "); + std::vector vContextParams; + + for (size_t i = 0; i < vContexts.size(); i++) { + vContexts[i] = MTS::Text::trim(vContexts[i]); + + if (vContexts[i].empty()) { + continue; + } + + vContextParams = MTS::Text::split(vContexts[i], ",", 4); + + if (vContextParams.size() < 3) { + return FAILURE; + } + + std::string sContextId = vContextParams[0]; + std::string sIpMode = MTS::Text::trim(vContextParams[1], '"'); // Remove double quotes from the start and end of the value + std::string sApn = MTS::Text::trim(vContextParams[2], '"'); // Remove double quotes from the start and end of the value + + jData[sContextId][ICellularRadio::KEY_PDP_CONTEXT_IPMODE] = sIpMode; + jData[sContextId][ICellularRadio::KEY_PDP_CONTEXT_APN] = sApn; + } + + return SUCCESS; +} + +ICellularRadio::CODE CellularRadio::setPdpContext(const std::string& sId, const Json::Value& jConfig) { + printTrace("%s| Setting context to the radio", getName().c_str()); + CODE rc; + + if (sId.empty()) { + printError("%s| PDP Context ID is not specified", getName().c_str()); + return FAILURE; + } + + std::string sCommand = "AT+CGDCONT=" + sId; + const int dTimeout = 1000; + + Json::Value jAllContexts; + + rc = getPdpContexts(jAllContexts); + if (rc != SUCCESS) { + printError("%s| Failed to retrieve the current PDP context configuration: [%d]", getName().c_str(), rc); + return rc; + } + + // Remove the context if no parameters defined + if (!jConfig.isMember(ICellularRadio::KEY_PDP_CONTEXT_IPMODE) && !jConfig.isMember(ICellularRadio::KEY_PDP_CONTEXT_APN)) { + if (jAllContexts.isMember(sId)) { + rc = sendBasicCommand(sCommand, dTimeout); + return rc; + } else { + printError("%s| PDP Context [%s] does not exist", getName().c_str(), sId.c_str()); + return FAILURE; + } + } + + std::string sIpMode; + + if (jConfig.isMember(ICellularRadio::KEY_PDP_CONTEXT_IPMODE)) { + if (jConfig[ICellularRadio::KEY_PDP_CONTEXT_IPMODE] == "IP" || jConfig[ICellularRadio::KEY_PDP_CONTEXT_IPMODE] == "PPP" || + jConfig[ICellularRadio::KEY_PDP_CONTEXT_IPMODE] == "IPV6" || jConfig[ICellularRadio::KEY_PDP_CONTEXT_IPMODE] == "IPV4V6") { + sIpMode = jConfig[ICellularRadio::KEY_PDP_CONTEXT_IPMODE].asString(); + } else { + printError("%s| Invalid IP Mode defined: [%s]", getName().c_str(), jConfig[ICellularRadio::KEY_PDP_CONTEXT_IPMODE].asString().c_str()); + return FAILURE; + } + } else if (jAllContexts.isMember(sId)) { + printInfo("%s| Re-using IP Mode [%s] for PDP context [%s]", getName().c_str(), jAllContexts[sId][ICellularRadio::KEY_PDP_CONTEXT_IPMODE].asString().c_str(), sId.c_str()); + sIpMode = jAllContexts[sId][ICellularRadio::KEY_PDP_CONTEXT_IPMODE].asString(); + } else { + printError("%s| Failed to edit PDP context [%s] - no such context defined", getName().c_str(), sId.c_str()); + return FAILURE; + } + + sCommand += ",\""; + sCommand += sIpMode; + sCommand += "\""; + + std::string sApn; + + if (jConfig.isMember(ICellularRadio::KEY_PDP_CONTEXT_APN)) { + sApn = jConfig[ICellularRadio::KEY_PDP_CONTEXT_APN].asString(); + } else if (jAllContexts.isMember(sId)) { + printInfo("%s| Re-using APN [%s] for PDP context [%s]", getName().c_str(), jAllContexts[sId][ICellularRadio::KEY_PDP_CONTEXT_APN].asString().c_str(), sId.c_str()); + sApn = jAllContexts[sId][ICellularRadio::KEY_PDP_CONTEXT_APN].asString(); + } else { + printError("%s| Failed to edit PDP context [%s] - no such context defined", getName().c_str(), sId.c_str()); + return FAILURE; + } + + sCommand += ",\""; + sCommand += sApn; + sCommand += "\""; + + rc = sendBasicCommand(sCommand, dTimeout); + + return rc; +} \ No newline at end of file -- 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_CellularRadio.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'src/MTS_IO_CellularRadio.cpp') diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 3de96ce..069d5fa 100644 --- a/src/MTS_IO_CellularRadio.cpp +++ b/src/MTS_IO_CellularRadio.cpp @@ -1868,4 +1868,65 @@ ICellularRadio::CODE CellularRadio::setPdpContext(const std::string& sId, const rc = sendBasicCommand(sCommand, dTimeout); return rc; -} \ No newline at end of file +} + +ICellularRadio::CODE CellularRadio::getDiagnostics(std::string& sReport) { + // Clear the original content before using the string as a buffer. + sReport.clear(); + + // Determine whether the SIM card is locked to select the appropriate + // list of commands for this radio. + std::string sSimLockStatus; + CODE iSimLockRet = getSimLockStatus(sSimLockStatus); + + // Re-use the SIM status detection logic from TelitRadio::getNetworkStatus. + // The SIM should be inserted and NOT locked. + bool bIsSimReady = (iSimLockRet == CODE::SUCCESS + && sSimLockStatus != "SIM PIN" + && sSimLockStatus != "SIM PUK"); + + // Determine the list of diagnostic commands required for this radio. + const auto& vCommands = getDiagCommands(bIsSimReady); + + // For all commands - set the maximum timeout to 2 seconds. + const int iMaxTimeout = 2000; + + // Allow the radio to ignore up to 2 consecutive queries before giving up. + int iMaxNoResponseCount = 2; + int iNoResponseCount = 0; + + // Execute each of the commands, add their output to the report. + for (const auto& sCmd : vCommands) { + // First line - the command to execute. + sReport.append(sCmd); + sReport.push_back(ICellularRadio::CR); + sReport.push_back(ICellularRadio::NL); + + // Execute the command. + std::string sResult = sendCommand(sCmd, ICellularRadio::DEFAULT_BAIL_STRINGS, iMaxTimeout); + + // Count the number of commands ignored by the radio. + // Normally, the radio should not ignore any of the commands, + // but radios have their own bugs. + if (sResult.empty()) { + printWarning("%s| Failed to execute the [%s] command - no response from the radio in [%d] ms", getName().c_str(), sCmd.c_str(), iMaxTimeout); + sResult = "\r\n"; + ++iNoResponseCount; + } else { + iNoResponseCount = 0; + } + + // If the radio ignored too many commands - probably it is stuck and will not + // return to operation on its own. There is no point in waiting any longer. + if (iNoResponseCount >= iMaxNoResponseCount) { + printError("%s| Failed to execute the diagnostic commands - the radio has stopped responding", getName().c_str()); + return CODE::NO_RESPONSE; + } + + // Append the command output to the report. + sReport.append(sResult); + } + + // All commands returned a non-empty output. + return CODE::SUCCESS; +} -- cgit v1.2.3