added full support for config file
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Waiting to run
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Waiting to run
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Waiting to run
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Waiting to run
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Waiting to run
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Waiting to run
This commit is contained in:
1 parent
0c4183843f
commit
6e85d8e922
21 files changed
+209
-254
No files matched your search
@@ -35,19 +35,6 @@ namespace api
|
||||
response.set_content(R"({"access":"reject"})", JSON_TYPE);
|
||||
return;
|
||||
}
|
||||
// std::ifstream wifisettingsfile(WIFI_SETTINGS_PATH);
|
||||
// std::string wifi_channel;
|
||||
// std::string wifisettingsbuffer;
|
||||
// while (std::getline(wifisettingsfile, wifisettingsbuffer))
|
||||
// {
|
||||
// if (wifisettingsbuffer.find("channel=") == 0)
|
||||
// {
|
||||
// wifi_channel = wifisettingsbuffer;
|
||||
// wifi_channel.erase(0, 8);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// wifisettingsfile.close();
|
||||
int wifi_channel = config::config.getConfig()["settings"]["wifi"]["channel"];
|
||||
std::stringstream responsedata;
|
||||
responsedata << R"({"channel":")" << wifi_channel << R"("})";
|
||||
@@ -97,20 +84,12 @@ namespace api
|
||||
system("rc restart hostapd");
|
||||
std::string syslogstring = "WIFI channel changed to " + new_channel;
|
||||
syslog(LOG_INFO, "%s", syslogstring.c_str());
|
||||
|
||||
std::ifstream changedwifisettingsfile(WIFI_SETTINGS_PATH);
|
||||
std::string wifi_channel;
|
||||
std::string changedwifisettingsbuffer;
|
||||
while (std::getline(changedwifisettingsfile, changedwifisettingsbuffer))
|
||||
{
|
||||
if (changedwifisettingsbuffer.find("channel=") == 0)
|
||||
{
|
||||
wifi_channel = changedwifisettingsbuffer;
|
||||
wifi_channel.erase(0, 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
changedwifisettingsfile.close();
|
||||
config::config.setConfig(std::string("../config.json"));
|
||||
nlohmann::json new_config = config::config.getConfig();
|
||||
new_config["settings"]["wifi"]["channel"] = std::stoi(new_channel);
|
||||
config::config.setConfig(new_config);
|
||||
config::config.saveConfig();
|
||||
int wifi_channel = config::config.getConfig()["settings"]["wifi"]["channel"];
|
||||
std::stringstream responsedata;
|
||||
responsedata << R"({"channel":")" << wifi_channel << R"("})";
|
||||
response.set_content(responsedata.str(), JSON_TYPE);
|
||||
|
||||
Reference in new issue
Block a user