deleted sstream
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
958a65ba1f
commit
0f05518140
9 files changed
+67
-44
No files matched your search
@@ -1,6 +1,5 @@
|
||||
#include <settings/wifi/wifi.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <syslog.h>
|
||||
|
||||
@@ -15,24 +14,30 @@ namespace api
|
||||
void set_wifi_channel(int new_channel)
|
||||
{
|
||||
std::ifstream wifisettingsfile(WIFI_SETTINGS_PATH);
|
||||
std::string old_channel;
|
||||
std::string old_channel_string;
|
||||
std::string wifisettingsbuffer;
|
||||
while (std::getline(wifisettingsfile, wifisettingsbuffer))
|
||||
{
|
||||
if (wifisettingsbuffer.find("channel=") == 0)
|
||||
{
|
||||
old_channel = wifisettingsbuffer;
|
||||
old_channel.erase(0, 8);
|
||||
old_channel_string = wifisettingsbuffer;
|
||||
old_channel_string.erase(0, 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
wifisettingsfile.close();
|
||||
std::stringstream systemrequest;
|
||||
systemrequest << "sed -i \"/channel=" << old_channel << "/s//channel=" << new_channel << "/\" /etc/hostapd/hostapd.conf";
|
||||
std::cout << systemrequest.str() << std::endl;
|
||||
system(systemrequest.str().c_str());
|
||||
std::cout << old_channel_string << std::endl;
|
||||
int old_channel = std::stoi(old_channel_string);
|
||||
std::string systemrequest;
|
||||
systemrequest += "sed -i \"/channel=" \
|
||||
+ std::to_string(old_channel) \
|
||||
+ "/s//channel=" \
|
||||
+ std::to_string(new_channel) \
|
||||
+ "/\" /etc/hostapd/hostapd.conf";
|
||||
std::cout << systemrequest << std::endl;
|
||||
system(systemrequest.c_str());
|
||||
system("rc restart hostapd");
|
||||
std::string syslogstring = "WIFI channel changed to " + new_channel;
|
||||
std::string syslogstring = "WIFI channel changed to " + std::to_string(new_channel);
|
||||
syslog(LOG_INFO, "%s", syslogstring.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user