summaryrefslogtreecommitdiff
path: root/src/MTS_IO_EG95Radio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTS_IO_EG95Radio.cpp')
-rw-r--r--src/MTS_IO_EG95Radio.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/MTS_IO_EG95Radio.cpp b/src/MTS_IO_EG95Radio.cpp
index 88f5724..501a164 100644
--- a/src/MTS_IO_EG95Radio.cpp
+++ b/src/MTS_IO_EG95Radio.cpp
@@ -21,6 +21,10 @@
#include <mts/MTS_IO_EG95Radio.h>
+#include <climits>
+
+#include <mts/MTS_Logger.h>
+
using namespace MTS::IO;
const std::string EG95Radio::MODEL_NAME("EG95");
@@ -51,10 +55,27 @@ ICellularRadio::CODE EG95Radio::getSupportedCellularModes(CELLULAR_MODES &networ
return SUCCESS;
}
-ICellularRadio::CODE EG95Radio::getCellularMode(CELLULAR_MODES &networks) {
+ICellularRadio::CODE EG95Radio::getCellularMode(CELLULAR_MODES&) {
return FAILURE;
}
ICellularRadio::CODE EG95Radio::setCellularMode(CELLULAR_MODES networks) {
+ std::string prefNet;
+ 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;
+ default: printError("Unhandled preferred network flag.");
+ }
+ }
+ std::string sCmd("AT+QCFG=\"nwscanseq\",");
+ sCmd += 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;
}