diff options
author | Jeff Hatch <jhatch@multitech.com> | 2019-08-13 08:02:32 -0500 |
---|---|---|
committer | Jeff Hatch <jhatch@multitech.com> | 2019-08-13 08:02:32 -0500 |
commit | 07eb755bbdc2700f31ff4e5fd9a7ac04a14e69e8 (patch) | |
tree | d1b30c78bbb2e81576cf193a7be809c0a2e0676b /src/MTS_IO_CellularRadio.cpp | |
parent | f6f7d0e174d2bf5eb4494e2508c17d3d7fbdc4e9 (diff) | |
parent | 4e5c4eb9d3b9a8974429810ebe5afc3387753643 (diff) | |
download | libmts-io-07eb755bbdc2700f31ff4e5fd9a7ac04a14e69e8.tar.gz libmts-io-07eb755bbdc2700f31ff4e5fd9a7ac04a14e69e8.tar.bz2 libmts-io-07eb755bbdc2700f31ff4e5fd9a7ac04a14e69e8.zip |
Merge branch 'MTX-2891-mpower-2g-3g-4g' into 'master'
Mtx 2891 mpower 2g 3g 4g
See merge request !2
Diffstat (limited to 'src/MTS_IO_CellularRadio.cpp')
-rw-r--r-- | src/MTS_IO_CellularRadio.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp index 3f0c037..6df92e0 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) { + printError("%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])) { + printError("%s| AT+COPS Error parsing reply [AT+COPS?][%s]", getName().c_str(), cmdResult.c_str()); + 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 { + printError("%s| AT+COPS unknown Radio Access Technology [AT+COPS?][%s]", getName().c_str(), cmdResult.c_str()); + return FAILURE; + } + return SUCCESS; +} + ICellularRadio::CODE CellularRadio::convertRegistrationToString(REGISTRATION eRegistration, std::string& sRegistration) { ICellularRadio::CODE eCode = FAILURE; |