提交 3794d622 authored 作者: blu's avatar blu

new feature: evwifi

上级 a442a339
...@@ -70,13 +70,12 @@ class WifiMgr { ...@@ -70,13 +70,12 @@ class WifiMgr {
fileApd << apdContent; fileApd << apdContent;
fileApd.close(); fileApd.close();
// start hostapd // start hostapd
system("systemctl stop wpa_supplicant@wlan1;ifconfig wlan1 down;" auto t = thread([](){
system("systemctl stop wpa_supplicant@wlan1;ifconfig wlan1 down;"
"ifconfig wlan1 up;ifconfig wlan1 192.168.0.1;hostapd /etc/apd.conf -B"); "ifconfig wlan1 up;ifconfig wlan1 192.168.0.1;hostapd /etc/apd.conf -B");
// TODO: check result // TODO: check result
});
//scan t.detach();
scanWifi();
}else{ }else{
ret["code"] = 1; ret["code"] = 1;
string msg = fmt::format("failed to write ap config file to {}", apdCfgPath); string msg = fmt::format("failed to write ap config file to {}", apdCfgPath);
...@@ -105,15 +104,9 @@ class WifiMgr { ...@@ -105,15 +104,9 @@ class WifiMgr {
// delay for rest return (ifdown caused no networking available) // delay for rest return (ifdown caused no networking available)
this_thread::sleep_for(chrono::seconds(1)); this_thread::sleep_for(chrono::seconds(1));
system("pkill hostapd; pkill dhclient;systemctl enable wpa_supplicant@wlan1;systemctl restart wpa_supplicant@wlan1;" system("pkill hostapd; pkill dhclient;systemctl enable wpa_supplicant@wlan1;systemctl restart wpa_supplicant@wlan1;"
"/sbin/ifdown -a --read-environment;/sbin/ifup -a --read-environment"); "/sbin/ifdown -a --read-environment;/sbin/ifup -a --read-environment;systemctl restart evdaemon");
}); });
t.detach(); t.detach();
// exec("ifconfig wlan1 down");
// exec("ifconfig wlan1 up");
// exec("systemctl enable wpa_supplicant@wlan1");
// exec("systemctl restart wpa_supplicant@wlan1");
// exec("dhclient -r wlan1");
}else{ }else{
string msg = fmt::format("failed write wpa config to {}", wpaCfgPath); string msg = fmt::format("failed write wpa config to {}", wpaCfgPath);
ret["code"] = 2; ret["code"] = 2;
...@@ -131,7 +124,7 @@ class WifiMgr { ...@@ -131,7 +124,7 @@ class WifiMgr {
public: public:
WifiMgr(){ WifiMgr(){
LVDB::getSn(this->info); LVDB::getSn(this->info);
wifiData["sn"] = this->info; wifiData["info"] = this->info;
wifiData["wifi"] = json(); wifiData["wifi"] = json();
wifiData["wifi"]["ssids"] = json(); wifiData["wifi"]["ssids"] = json();
//wifiData["wifi"]["ssid"] = string; //wifiData["wifi"]["ssid"] = string;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论