Add --fix-permission and --list-wifi-country-codes options to PiPedalConfig.
This commit is contained in:
@@ -647,11 +647,16 @@ add_executable(pipedalconfig
|
|||||||
JackServerSettings.hpp JackServerSettings.cpp
|
JackServerSettings.hpp JackServerSettings.cpp
|
||||||
SystemConfigFile.hpp SystemConfigFile.cpp
|
SystemConfigFile.hpp SystemConfigFile.cpp
|
||||||
WifiChannelSelectors.cpp WifiChannelSelectors.hpp
|
WifiChannelSelectors.cpp WifiChannelSelectors.hpp
|
||||||
|
Locale.cpp Locale.hpp
|
||||||
asan_options.cpp
|
asan_options.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(pipedalconfig PRIVATE PiPedalCommon pthread atomic uuid stdc++fs asound
|
target_link_libraries(pipedalconfig PRIVATE PiPedalCommon pthread atomic uuid stdc++fs asound
|
||||||
|
icui18n
|
||||||
|
icuuc
|
||||||
|
icudata
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(pipedal_latency_test
|
add_executable(pipedal_latency_test
|
||||||
|
|||||||
+58
-6
@@ -25,6 +25,8 @@
|
|||||||
#include "SystemConfigFile.hpp"
|
#include "SystemConfigFile.hpp"
|
||||||
#include "ModFileTypes.hpp"
|
#include "ModFileTypes.hpp"
|
||||||
#include "alsaCheck.hpp"
|
#include "alsaCheck.hpp"
|
||||||
|
#include "RegDb.hpp"
|
||||||
|
#include "Locale.hpp"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -1296,6 +1298,11 @@ static void PrintHelp()
|
|||||||
<< "\n\n"
|
<< "\n\n"
|
||||||
<< HangingIndent() << " --list-wifi-channels [<country_code>] \tList valid Wifi channels for the current/specified country."
|
<< HangingIndent() << " --list-wifi-channels [<country_code>] \tList valid Wifi channels for the current/specified country."
|
||||||
<< "\n\n"
|
<< "\n\n"
|
||||||
|
<< HangingIndent() << " --list-wifi-country-codes\tList valid country codes."
|
||||||
|
<< "\n\n"
|
||||||
|
|
||||||
|
<< HangingIndent() << " --fix-permissions\t"
|
||||||
|
<< "Set correct permissions on /var/pipedal directories and sub-directories\n\n"
|
||||||
|
|
||||||
<< Indent(0) << "Country codes:"
|
<< Indent(0) << "Country codes:"
|
||||||
<< "\n\n"
|
<< "\n\n"
|
||||||
@@ -1307,11 +1314,10 @@ static void PrintHelp()
|
|||||||
<< "Without a country code, Wi-Fi must be restricted to channels 1 through 11 "
|
<< "Without a country code, Wi-Fi must be restricted to channels 1 through 11 "
|
||||||
<< "with reduced amplitude and feature sets."
|
<< "with reduced amplitude and feature sets."
|
||||||
<< "\n\n"
|
<< "\n\n"
|
||||||
<< "For the most part, Wi-Fi country codes are taken from the list of ISO 3661 "
|
<< " Wi-Fi country codes are taken from the list of ISO 3661 "
|
||||||
<< "2-letter country codes; although there are a handful of exceptions for small "
|
<< "2-letter country codes.\n\n"
|
||||||
<< "countries and islands. See the Alpha-2 code column of "
|
<< "To see a list of countries and their country codes, run: \n\n"
|
||||||
<< "\n\n"
|
<< Indent(8) << "pipedalconfig --list-wifi-country-codes"
|
||||||
<< Indent(8) << "https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes."
|
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1361,6 +1367,41 @@ void RequireNetworkManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListValidCountryCodes()
|
||||||
|
{
|
||||||
|
RegDb regdb;
|
||||||
|
|
||||||
|
auto ccs = regdb.getRegulatoryDomains();
|
||||||
|
|
||||||
|
if (ccs.size() == 0)
|
||||||
|
{
|
||||||
|
cout << "No regulatory domains found." << endl;
|
||||||
|
} else {
|
||||||
|
using pair = std::pair<std::string,std::string>;
|
||||||
|
std::vector<pair> list;
|
||||||
|
for (auto &cc: ccs)
|
||||||
|
{
|
||||||
|
list.push_back(pair(cc.first,cc.second));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto collator = Locale::GetInstance()->GetCollator();
|
||||||
|
auto compare = [&collator](
|
||||||
|
pair &left,
|
||||||
|
pair &right)
|
||||||
|
{
|
||||||
|
return collator->Compare(
|
||||||
|
left.second, right.second) < 0;
|
||||||
|
};
|
||||||
|
std::sort(list.begin(), list.end(), compare);
|
||||||
|
|
||||||
|
for (const auto &entry: list)
|
||||||
|
{
|
||||||
|
cout << entry.first << " - " << entry.second << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
CommandLineParser parser;
|
CommandLineParser parser;
|
||||||
@@ -1383,9 +1424,11 @@ int main(int argc, char **argv)
|
|||||||
std::string portOption;
|
std::string portOption;
|
||||||
std::string homeNetwork;
|
std::string homeNetwork;
|
||||||
bool noEthernet = false;
|
bool noEthernet = false;
|
||||||
|
bool list_wifi_country_codes = false;
|
||||||
bool noWifi = false;
|
bool noWifi = false;
|
||||||
|
|
||||||
parser.AddOption("--nosudo", &nosudo); // strictly a debugging aid. Run without sudo, until we fail because of permissions.
|
parser.AddOption("--nosudo", &nosudo); // strictly a debugging aid. Run without sudo, until we fail because of permissions.
|
||||||
|
parser.AddOption("--list-wifi-country-codes",&list_wifi_country_codes);
|
||||||
parser.AddOption("--install", &install);
|
parser.AddOption("--install", &install);
|
||||||
parser.AddOption("--uninstall", &uninstall);
|
parser.AddOption("--uninstall", &uninstall);
|
||||||
parser.AddOption("--stop", &stop);
|
parser.AddOption("--stop", &stop);
|
||||||
@@ -1404,12 +1447,16 @@ int main(int argc, char **argv)
|
|||||||
parser.AddOption("--no-wifi", &noWifi);
|
parser.AddOption("--no-wifi", &noWifi);
|
||||||
parser.AddOption("--alsa-devices", &alsaDevices);
|
parser.AddOption("--alsa-devices", &alsaDevices);
|
||||||
parser.AddOption("--alsa-device", &alsaDevice);
|
parser.AddOption("--alsa-device", &alsaDevice);
|
||||||
|
parser.AddOption("--fix-permissions", &fix_permissions);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parser.Parse(argc, (const char **)argv);
|
parser.Parse(argc, (const char **)argv);
|
||||||
|
|
||||||
int actionCount =
|
int actionCount =
|
||||||
(!alsaDevice.empty()) + alsaDevices + help + get_current_port + install + uninstall + stop + start + enable + disable + enable_hotspot + disable_hotspot + restart + enable_p2p + disable_p2p + list_p2p_channels + fix_permissions;
|
(!alsaDevice.empty()) + alsaDevices + help + get_current_port + install +
|
||||||
|
uninstall + stop + start + enable + disable + enable_hotspot +
|
||||||
|
disable_hotspot + restart + enable_p2p + disable_p2p + list_p2p_channels +
|
||||||
|
fix_permissions + list_wifi_country_codes;
|
||||||
if (actionCount > 1)
|
if (actionCount > 1)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Please provide only one action.");
|
throw std::runtime_error("Please provide only one action.");
|
||||||
@@ -1466,6 +1513,11 @@ int main(int argc, char **argv)
|
|||||||
PrintHelp();
|
PrintHelp();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
if (list_wifi_country_codes)
|
||||||
|
{
|
||||||
|
ListValidCountryCodes();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
if (get_current_port)
|
if (get_current_port)
|
||||||
{
|
{
|
||||||
std::cout << "current port: " << GetCurrentWebServicePort() << std::endl;
|
std::cout << "current port: " << GetCurrentWebServicePort() << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user