diff options
author | Maksym Telychko <maksym.telychko@globallogic.com> | 2019-08-05 19:05:47 +0300 |
---|---|---|
committer | Maksym Telychko <maksym.telychko@globallogic.com> | 2019-08-05 19:05:47 +0300 |
commit | dde61cb74828054f00518ca3b931f0b20009cc79 (patch) | |
tree | 90074e1ac63ac355a34ed4b007f4df5adef8d00f /src/MTS_IO_EG95Radio.cpp | |
parent | e8412ebb27c8ff995795951d609377b003c8d6b1 (diff) | |
download | libmts-io-dde61cb74828054f00518ca3b931f0b20009cc79.tar.gz libmts-io-dde61cb74828054f00518ca3b931f0b20009cc79.tar.bz2 libmts-io-dde61cb74828054f00518ca3b931f0b20009cc79.zip |
MTX-2898 mpower 2-3-4g: quectel methods for set-cellular-mode and common methods for get-cellular-mode
Diffstat (limited to 'src/MTS_IO_EG95Radio.cpp')
-rw-r--r-- | src/MTS_IO_EG95Radio.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/MTS_IO_EG95Radio.cpp b/src/MTS_IO_EG95Radio.cpp index 501a164..f934e50 100644 --- a/src/MTS_IO_EG95Radio.cpp +++ b/src/MTS_IO_EG95Radio.cpp @@ -24,6 +24,7 @@ #include <climits> #include <mts/MTS_Logger.h> +#include <mts/MTS_Text.h> using namespace MTS::IO; @@ -55,27 +56,27 @@ ICellularRadio::CODE EG95Radio::getSupportedCellularModes(CELLULAR_MODES &networ return SUCCESS; } -ICellularRadio::CODE EG95Radio::getCellularMode(CELLULAR_MODES&) { - return FAILURE; -} - ICellularRadio::CODE EG95Radio::setCellularMode(CELLULAR_MODES networks) { std::string prefNet; + unsigned int prefOnly = 0; for (int i = sizeof(networks)*CHAR_BIT-1; i>=0; --i){ switch (1<<i & networks) { - case ICellularRadio::CELLULAR_MODE_2G: prefNet += "01"; break; - case ICellularRadio::CELLULAR_MODE_3G: prefNet += "0302"; break; - case ICellularRadio::CELLULAR_MODE_4G: prefNet += "04"; break; + case ICellularRadio::CELLULAR_MODE_2G: prefNet += "01" ; prefOnly = 1; break; + case ICellularRadio::CELLULAR_MODE_3G: prefNet += "0302"; prefOnly = 2; break; + case ICellularRadio::CELLULAR_MODE_4G: prefNet += "04" ; prefOnly = 3; break; default: printError("Unhandled preferred network flag."); } } - std::string sCmd("AT+QCFG=\"nwscanseq\","); - sCmd += prefNet; + std::string sCmd; + if (prefNet.size() == 2) { // *g-only + sCmd = "AT+QCFG=\"nwscanmode\"," + std::to_string(prefOnly); + } else { // preferred + sCmd = "AT+QCFG=\"nwscanseq\"," + prefNet; + } std::string cmdResult = sendCommand(sCmd); if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) { printDebug("%s| AT+QCFG returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); return FAILURE; } - return SUCCESS; } |