summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hatch <jhatch@multitech.com>2020-02-25 10:40:22 -0600
committerJeff Hatch <jhatch@multitech.com>2020-02-25 10:40:22 -0600
commitff6e2d6a828d26db31832f7fa3eb3c5789332421 (patch)
tree1b2b8ffbff7fa12fcefba46e3914c90caa044a48
parent51dc05074c338a15a9e37e4e3ed7cd61c981279e (diff)
parentb66c9a18a9e61911ca87ba7364d74d15b0756797 (diff)
downloadradio-query-ff6e2d6a828d26db31832f7fa3eb3c5789332421.tar.gz
radio-query-ff6e2d6a828d26db31832f7fa3eb3c5789332421.tar.bz2
radio-query-ff6e2d6a828d26db31832f7fa3eb3c5789332421.zip
Merge branch 'sk/MTX-3239-dynamic-cell-mode' into 'master'
[MTX-3239] Add "cellularMode" value to the radio-query --dynamic See merge request !5
-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;
-}