summaryrefslogtreecommitdiff
path: root/src/MTS_IO_QuectelRadio.cpp
diff options
context:
space:
mode:
authormykola.salomatin <mykola.salomatin@globallogic.com>2020-05-29 11:44:57 +0300
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-05-29 11:49:24 +0300
commit04b90430c91f4257ebeff3bcccbe8c5d7413e7ae (patch)
tree64f6423de18f09e5791d9c5da216a5cfe4bc4fd0 /src/MTS_IO_QuectelRadio.cpp
parentb3a9a71afdb0d6f4f104543cedba89d011ca68df (diff)
downloadlibmts-io-04b90430c91f4257ebeff3bcccbe8c5d7413e7ae.tar.gz
libmts-io-04b90430c91f4257ebeff3bcccbe8c5d7413e7ae.tar.bz2
libmts-io-04b90430c91f4257ebeff3bcccbe8c5d7413e7ae.zip
mPower Oct20: L4G1 libmts-io support
Diffstat (limited to 'src/MTS_IO_QuectelRadio.cpp')
-rw-r--r--src/MTS_IO_QuectelRadio.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp
index c4bdc56..5024f54 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>
@@ -568,3 +570,35 @@ 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;
+}