summaryrefslogtreecommitdiff
path: root/src/MTS_IO_CellularRadio.cpp
diff options
context:
space:
mode:
authorMaksym Telychko <maksym.telychko@globallogic.com>2019-08-05 19:05:47 +0300
committerMaksym Telychko <maksym.telychko@globallogic.com>2019-08-05 19:05:47 +0300
commitdde61cb74828054f00518ca3b931f0b20009cc79 (patch)
tree90074e1ac63ac355a34ed4b007f4df5adef8d00f /src/MTS_IO_CellularRadio.cpp
parente8412ebb27c8ff995795951d609377b003c8d6b1 (diff)
downloadlibmts-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_CellularRadio.cpp')
-rw-r--r--src/MTS_IO_CellularRadio.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index 3f0c037..e171341 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -770,6 +770,34 @@ ICellularRadio::CODE CellularRadio::getRegistration(REGISTRATION& eRegistration)
return SUCCESS;
}
+ICellularRadio::CODE CellularRadio::getCellularMode(CELLULAR_MODES &networks) {
+ networks = CELLULAR_MODE_NA;
+ std::string cmdResult = sendCommand("AT+COPS?");
+ if (cmdResult.find(ICellularRadio::RSP_OK) == std::string::npos) {
+ printDebug("%s| AT+COPS returned unexpected response: AT+COPS? [%s]", getName().c_str(), cmdResult.c_str());
+ return FAILURE;
+ }
+
+ size_t cursor = 0;
+ const std::vector<std::string> &reply = MTS::Text::split(MTS::Text::getLine(MTS::Text::trim(cmdResult), cursor, cursor), ',');
+ uint8_t op;
+ if (reply.size() < 4 || !MTS::Text::parse(op, reply[3])) {
+ printDebug("Error parsing reply from AT+COPS");
+ return FAILURE;
+ }
+ if (op == 0) {
+ networks = CELLULAR_MODE_2G;
+ } else if (op >= 2 && op <= 6) {
+ networks = CELLULAR_MODE_3G;
+ } else if (op == 7) {
+ networks = CELLULAR_MODE_4G;
+ } else {
+ printDebug("Error: AT+COPS unknown Radio Access Technology");
+ return FAILURE;
+ }
+ return SUCCESS;
+}
+
ICellularRadio::CODE CellularRadio::convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) {
ICellularRadio::CODE eCode = FAILURE;