diff options
author | Jeff Hatch <jhatch@multitech.com> | 2019-08-13 08:02:23 -0500 |
---|---|---|
committer | Jeff Hatch <jhatch@multitech.com> | 2019-08-13 08:02:23 -0500 |
commit | 7152de5483b6257f87a7ead5c29e4e768a4bab39 (patch) | |
tree | 7a6a32690372485d0d207898032d8eaf1b8f84a8 | |
parent | 31e4dac26cea6f3d6f49d5bdc9a16aa7961896dd (diff) | |
parent | c7e173e42b63c462889d8365a71bb78999bf0146 (diff) | |
download | radio-query-7152de5483b6257f87a7ead5c29e4e768a4bab39.tar.gz radio-query-7152de5483b6257f87a7ead5c29e4e768a4bab39.tar.bz2 radio-query-7152de5483b6257f87a7ead5c29e4e768a4bab39.zip |
Merge branch 'MTX-2891-mpower-2g-3g-4g' into 'master'
0.8
MTX-2891 mpower: 2-3-4g switch implementation
See merge request !2
-rw-r--r-- | main.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -31,6 +31,7 @@ #include <string.h> #include <stdio.h> #include <iostream> +#include <climits> #include <fstream> #include <signal.h> #include <unistd.h> @@ -88,6 +89,8 @@ const uint32_t OPT_SIM_STATUS = 0x00040000; const uint32_t OPT_SUMMARY_STATIC = 0x01000000; const uint32_t OPT_SUMMARY_NETWORK = 0x02000000; +const uint32_t OPT_CELL_MODE = 0x04000000; +const uint32_t OPT_SUPPORTED_CELL_MODE = 0x08000000; void handle_sigterm(int signum); void printHelp(const std::string& sApp); @@ -95,6 +98,7 @@ void parseOptions(int argc, char** argv); void initializeCache(); void shutdown(); template<class T> bool writeToCache(const std::string& sFile, const T& tValue); +std::string cellularModeStr(MTS::IO::ICellularRadio::CELLULAR_MODES networks); Json::Value getStaticData(); Json::Value getNetworkData(); @@ -286,6 +290,18 @@ int main(int argc, char** argv) { if(result == ICellularRadio::SUCCESS) { printf("%s", sValue.c_str()); } + } else if(g_iOptions & OPT_SUPPORTED_CELL_MODE) { + ICellularRadio::CELLULAR_MODES networks; + result = g_apRadio->getSupportedCellularModes(networks); + if (result == ICellularRadio::SUCCESS) { + printf("%s", cellularModeStr(networks).c_str()); + } + } else if(g_iOptions & OPT_CELL_MODE) { + ICellularRadio::CELLULAR_MODES networks; + result = g_apRadio->getCellularMode(networks); + if (result == ICellularRadio::SUCCESS) { + printf("%s", cellularModeStr(networks).c_str()); + } } if (g_bIstty && result == ICellularRadio::CODE::SUCCESS) @@ -538,6 +554,8 @@ void parseOptions(int argc, char** argv) { { "sim-status", no_argument, &iOption, OPT_SIM_STATUS }, { "static", no_argument, &iOption, OPT_SUMMARY_STATIC }, { "dynamic", no_argument, &iOption, OPT_SUMMARY_NETWORK }, + { "cellular-mode",no_argument, &iOption, OPT_CELL_MODE }, + { "supported-cellular-modes", no_argument, &iOption, OPT_SUPPORTED_CELL_MODE }, { 0, 0, 0, 0 } }; /* getopt_long stores the option index here. */ @@ -643,9 +661,27 @@ void printHelp(const std::string& sApp) { printf("\t--carrier\n"); printf("\t--datetime\n"); printf("\t--sim-status\n"); + printf("\t--cellular-mode\n"); + printf("\t--supported-cellular-modes\n"); // Applicable for LTE910-NA1 dual FW images only // printf("\t--active-firmware\n"); printf("\n"); 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; +} |