summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-02-25 15:29:54 +0200
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-02-25 15:29:54 +0200
commitb66c9a18a9e61911ca87ba7364d74d15b0756797 (patch)
tree1b2b8ffbff7fa12fcefba46e3914c90caa044a48
parent51dc05074c338a15a9e37e4e3ed7cd61c981279e (diff)
downloadradio-query-b66c9a18a9e61911ca87ba7364d74d15b0756797.tar.gz
radio-query-b66c9a18a9e61911ca87ba7364d74d15b0756797.tar.bz2
radio-query-b66c9a18a9e61911ca87ba7364d74d15b0756797.zip
[MTX-3239] Add "cellularMode" value to the radio-query --dynamic
Ported "cellularModeStr" function to MTS::IO::CellularRadio class. This function converts integer bitmap to comma-separated list of cellular modes. Please see libmts-io commit 242be3d1f4e34df2cb0fea6fa661d0e27d2b421d for the new implementaion on libmts-io side.
-rw-r--r--main.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/main.cpp b/main.cpp
index f6aa1ae..d0da2a2 100644
--- a/main.cpp
+++ b/main.cpp
@@ -302,16 +302,24 @@ int main(int argc, char** argv) {
printf("%s", sValue.c_str());
}
} else if(g_iOptions & OPT_SUPPORTED_CELL_MODE) {
+ std::string sValue;
ICellularRadio::CELLULAR_MODES networks;
result = g_apRadio->getSupportedCellularModes(networks);
if (result == ICellularRadio::SUCCESS) {
- printf("%s", cellularModeStr(networks).c_str());
+ result = g_apRadio->convertCellModesToString(networks, sValue);
+ if(result == ICellularRadio::SUCCESS) {
+ printf("%s", sValue.c_str());
+ }
}
} else if(g_iOptions & OPT_CELL_MODE) {
+ std::string sValue;
ICellularRadio::CELLULAR_MODES networks;
result = g_apRadio->getCellularMode(networks);
if (result == ICellularRadio::SUCCESS) {
- printf("%s", cellularModeStr(networks).c_str());
+ result = g_apRadio->convertCellModesToString(networks, sValue);
+ if(result == ICellularRadio::SUCCESS) {
+ printf("%s", sValue.c_str());
+ }
}
}
@@ -520,7 +528,7 @@ Json::Value getStaticData() {
ICellularRadio::CELLULAR_MODES supportedCellModes;
if(g_apRadio->getSupportedCellularModes(supportedCellModes) == ICellularRadio::SUCCESS) {
- sSupportedCellModes = cellularModeStr(supportedCellModes).c_str();
+ g_apRadio->convertCellModesToString(supportedCellModes, sSupportedCellModes);
}
jData[MTS::IO::ICellularRadio::KEY_SUPPORTED_CELL_MODES] = sSupportedCellModes;
@@ -690,19 +698,3 @@ void printHelp(const std::string& sApp) {
printf("\tSupported Radios:\n");
printf("\t\tHE910, GE910, DE910, CE910, LE910, ME910\n");
}
-
-std::string cellularModeStr(MTS::IO::ICellularRadio::CELLULAR_MODES networks)
-{
- using namespace MTS::IO;
- std::string result;
- for (size_t i = 0; i<sizeof(networks)*CHAR_BIT; ++i){
- switch (1<<i & networks) {
- case ICellularRadio::CELLULAR_MODE_2G: result += "2g,"; break;
- case ICellularRadio::CELLULAR_MODE_3G: result += "3g,"; break;
- case ICellularRadio::CELLULAR_MODE_4G: result += "4g,"; break;
- case ICellularRadio::CELLULAR_MODE_5G: result += "5g,"; break;
- }
- }
- result.pop_back();
- return result;
-}