From 8aec99c1006878cf33ed9ee3cc2707a47fa82270 Mon Sep 17 00:00:00 2001 From: "andrii.davydenko" Date: Thu, 11 Nov 2021 15:39:02 +0200 Subject: [MTX-4190] mPower R.6.0: Update MODBUS slave feature to support Quectel and newer Telit radios Add query for selected bands Signed-off-by: andrii.davydenko --- main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.cpp b/main.cpp index f30a417..310d6fd 100644 --- a/main.cpp +++ b/main.cpp @@ -97,6 +97,7 @@ 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; +const uint32_t OPT_SELECTED_BANDS = 0x20000000; int32_t g_iAuxOptions = 0; const uint32_t AOPT_VOICE_SUPPORT = 0x00000001; @@ -367,6 +368,12 @@ int main(int argc, char** argv) { if (result == ICellularRadio::SUCCESS) { printf("%s", jValue.toStyledString().c_str()); } + } else if (g_iOptions & OPT_SELECTED_BANDS) { + Json::Value jValue; + result = g_apRadio->getSelectedBands(jValue); + if (result == ICellularRadio::SUCCESS) { + printf("%s", jValue.toStyledString().c_str()); + } } if (g_bIstty && result == ICellularRadio::CODE::SUCCESS) @@ -660,6 +667,7 @@ void parseOptions(int argc, char** argv) { { "ue-mode-of-operation", no_argument,&iOption, OPT_UE_MODE_OF_OPERATION }, { "sim-mcc-mnc", no_argument, &iOption, OPT_SIM_MCC_MNC }, { "voice-support",no_argument, &iAuxOption, AOPT_VOICE_SUPPORT }, + { "selected-bands", no_argument, &iOption, OPT_SELECTED_BANDS }, { 0, 0, 0, 0 } }; /* getopt_long stores the option index here. */ @@ -774,6 +782,7 @@ void printHelp(const std::string& sApp) { printf("\t--ue-mode-of-operation\n"); printf("\t--sim-mcc-mnc\n"); printf("\t--voice-support\n"); + printf("\t--selected-bands\n"); // Applicable for LTE910-NA1 dual FW images only // printf("\t--active-firmware\n"); printf("\n"); -- cgit v1.2.3 From 4e8bb625fbd9db99ecf8b5e33fbee79cf7702f7b Mon Sep 17 00:00:00 2001 From: "andrii.davydenko" Date: Mon, 22 Nov 2021 16:32:52 +0200 Subject: [MTX-4190] mPower R.6.0: Update MODBUS slave feature to support Quectel and newer Telit radios Implement printing json array by one line Change all json printing to custom one Signed-off-by: andrii.davydenko --- main.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 310d6fd..f7e919f 100644 --- a/main.cpp +++ b/main.cpp @@ -113,6 +113,8 @@ std::string cellularModeStr(MTS::IO::ICellularRadio::CELLULAR_MODES networks); Json::Value getStaticData(); Json::Value getNetworkData(); +std::string toCompactStyledString(const Json::Value& jData); + bool g_bIstty = false; int main(int argc, char** argv) { @@ -167,14 +169,14 @@ int main(int argc, char** argv) { ICellularRadio::CODE result = ICellularRadio::CODE::SUCCESS; if(g_iOptions & OPT_SUMMARY_NETWORK) { - printf("%s", getNetworkData().toStyledString().c_str()); + printf("%s", toCompactStyledString(getNetworkData()).c_str()); } else if(g_iOptions & OPT_SUMMARY_STATIC) { - printf("%s", getStaticData().toStyledString().c_str()); + printf("%s", toCompactStyledString(getStaticData()).c_str()); } else if(g_iOptions & OPT_SIM_STATUS) { Json::Value jValue; result = g_apRadio->getSimStatusSummary(jValue); if(result == ICellularRadio::SUCCESS) { - printf("%s", jValue.toStyledString().c_str()); + printf("%s", toCompactStyledString(jValue).c_str()); } } else if(g_iOptions & OPT_RSSI) { int32_t iValue; @@ -360,19 +362,19 @@ int main(int argc, char** argv) { if (result == ICellularRadio::SUCCESS) { jValue[MTS::IO::ICellularRadio::KEY_SIM_MCC] = sMcc; jValue[MTS::IO::ICellularRadio::KEY_SIM_MNC] = sMnc; - printf("%s", jValue.toStyledString().c_str()); + printf("%s", toCompactStyledString(jValue).c_str()); } } else if (g_iAuxOptions & AOPT_VOICE_SUPPORT) { Json::Value jValue; result = g_apRadio->getVoiceSupport(jValue); if (result == ICellularRadio::SUCCESS) { - printf("%s", jValue.toStyledString().c_str()); + printf("%s", toCompactStyledString(jValue).c_str()); } } else if (g_iOptions & OPT_SELECTED_BANDS) { Json::Value jValue; result = g_apRadio->getSelectedBands(jValue); if (result == ICellularRadio::SUCCESS) { - printf("%s", jValue.toStyledString().c_str()); + printf("%s", toCompactStyledString(jValue).c_str()); } } @@ -408,7 +410,7 @@ void initializeCache() { //Gather Static Information const Json::Value jData = getStaticData(); - printTrace("Static Data:\n%s\n", jData.toStyledString().c_str()); + printTrace("Static Data:\n%s\n", toCompactStyledString(jData).c_str()); //Save to radio cache directory std::ofstream ofile; @@ -789,3 +791,14 @@ void printHelp(const std::string& sApp) { printf("\tSupported Radios:\n"); printf("\t\tHE910, GE910, DE910, CE910, LE910, ME910, EG95, EG25\n"); } + +std::string toCompactStyledString(const Json::Value& jData) { + Json::StreamWriterBuilder builder; + builder["indentation"] = "\t"; + builder["commentStyle"] = "None"; + + std::string sOut = Json::writeString(builder, jData); + sOut += '\n'; + + return sOut; +} -- cgit v1.2.3