From c7e173e42b63c462889d8365a71bb78999bf0146 Mon Sep 17 00:00:00 2001 From: Maksym Telychko Date: Tue, 30 Jul 2019 10:17:29 +0300 Subject: MTX-2891 mpower: 2-3-4g switch implementation --- main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/main.cpp b/main.cpp index be87d06..7617c4a 100644 --- a/main.cpp +++ b/main.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -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 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