summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
index be87d06..7617c4a 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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;
+}