diff options
author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-06-30 12:49:56 +0300 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-06-30 12:49:56 +0300 |
commit | 24ed390ceb584fadfd428a6e9019371550931094 (patch) | |
tree | bf9d7b72303a8cd9026e625a4cd2812cab708d5c /src/MTS_IO_QuectelRadio.cpp | |
parent | 6e9ce61addd97809d5ea7b912332dd11a4bf7cee (diff) | |
parent | adaca6b0fc6430f38ae3f0551f9a248563ad53b5 (diff) | |
download | libmts-io-24ed390ceb584fadfd428a6e9019371550931094.tar.gz libmts-io-24ed390ceb584fadfd428a6e9019371550931094.tar.bz2 libmts-io-24ed390ceb584fadfd428a6e9019371550931094.zip |
Merge remote-tracking branch 'origin/master' into sk/quectel-delta-fwu
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 8cd7194..a8986f4 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -20,6 +20,8 @@ #include "mts/MTS_IO_QuectelRadio.h" +#include <climits> + #include <mts/MTS_Logger.h> #include <mts/MTS_Thread.h> #include <mts/MTS_Text.h> @@ -618,6 +620,38 @@ ICellularRadio::CODE QuectelRadio::convertToActiveBand(const std::string& sQuect return SUCCESS; } +ICellularRadio::CODE QuectelRadio::setCellularMode(CELLULAR_MODES networks) { + std::string prefNet; + unsigned int prefOnly = 0, prefCount = 0; + for (int i = sizeof(networks)*CHAR_BIT-1; i>=0; --i){ + switch (1<<i & networks) { + case ICellularRadio::CELLULAR_MODE_2G: prefNet += "01" ; prefOnly = 1; prefCount++; break; + case ICellularRadio::CELLULAR_MODE_3G: prefNet += "0302"; prefOnly = 2; prefCount++; break; + case ICellularRadio::CELLULAR_MODE_4G: prefNet += "04" ; prefOnly = 3; prefCount++; break; + } + } + + std::string sCmd; + if (prefCount == 1) { // *g-only + sCmd = "AT+QCFG=\"nwscanmode\"," + std::to_string(prefOnly); + } else { // preferred + sCmd = "AT+QCFG=\"nwscanmode\",0"; + } + std::string cmdResult = sendCommand(sCmd); + if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) { + printError("%s| AT+QCFG=\"nwscanmode\" returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); + return FAILURE; + } + + sCmd = "AT+QCFG=\"nwscanseq\"," + prefNet; + cmdResult = sendCommand(sCmd); + if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) { + printError("%s| AT+QCFG=\"nwscanseq\" returned unexpected response: [%s][%s]", getName().c_str(), sCmd.c_str(), cmdResult.c_str()); + return FAILURE; + } + return SUCCESS; +} + ICellularRadio::CODE QuectelRadio::uploadFile(int fd, const std::string& sTargetFilename, ICellularRadio::UpdateCb& stepCb) { size_t dPayloadLenght; size_t nChunks; |