diff options
author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2019-06-12 16:30:46 +0300 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2019-06-12 16:39:08 +0300 |
commit | d388f51c9611d0f5009abf105aba44c85fcee4b0 (patch) | |
tree | a1cbe07efd449f6835233cba6a6a85150dc848c8 | |
parent | 6647e6fbb8f742727229309c9372d6c66291f805 (diff) | |
download | libmts-io-d388f51c9611d0f5009abf105aba44c85fcee4b0.tar.gz libmts-io-d388f51c9611d0f5009abf105aba44c85fcee4b0.tar.bz2 libmts-io-d388f51c9611d0f5009abf105aba44c85fcee4b0.zip |
[MTS-MTQ] QuectelRadio implementation
Changed implementation of the QuectelRadio::getService
- Replaced sscanf with functions from MTS::Text
- Emulated the behaviour of TelitRadio::getService - return FAILURE
when <Act> is not available
The TelitRadio::getService returns FAILURE when device stays without
a SIM card (probably, until it will be registered to the network)
-rw-r--r-- | src/MTS_IO_QuectelRadio.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/MTS_IO_QuectelRadio.cpp b/src/MTS_IO_QuectelRadio.cpp index 6c6ab4b..20a2a21 100644 --- a/src/MTS_IO_QuectelRadio.cpp +++ b/src/MTS_IO_QuectelRadio.cpp @@ -104,10 +104,16 @@ CellularRadio::CODE QuectelRadio::getService(std::string& sService) { return FAILURE; } + size_t start = sResult.find(":") + 1; //Position right after "+COPS:" + std::vector<std::string> vParts = MTS::Text::split(MTS::Text::trim(sResult.substr(start, end-start)), ','); + + int32_t iAccessTechnology; + // +COPS: <mode>[,<format>[,<oper>][,<Act>]] - // %*[^,] in scanf - ignore all symbols until next comma - int32_t iAccessTechnology = -1; - sscanf(sResult.c_str(), "+COPS: %*d,%*d,%*[^,],%d", &iAccessTechnology); + if (vParts.size() < 4 || !MTS::Text::parse(iAccessTechnology, vParts[3])) { + printWarning("%s| Unable to get Service from radio using command [%s]", getName().c_str(), sCmd.c_str()); + return FAILURE; + } switch(iAccessTechnology) { case 0 : sService = "GPRS" ; break; // GSM |