mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
use nmcli to do the connect/disconnect job
This commit is contained in:
parent
d3f3a4350b
commit
261702bc62
@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
//"os"
|
//"os"
|
||||||
// "os/exec"
|
// "os/exec"
|
||||||
gotime "time"
|
// gotime "time"
|
||||||
|
|
||||||
//"github.com/godbus/dbus"
|
//"github.com/godbus/dbus"
|
||||||
|
|
||||||
@ -472,12 +472,8 @@ func (self *WifiList) GenNetworkList() {
|
|||||||
func (self *WifiList) Disconnect() {
|
func (self *WifiList) Disconnect() {
|
||||||
self.Connecting = false
|
self.Connecting = false
|
||||||
|
|
||||||
wpa_cli_disconnect := []string{"wpa_cli","disconnect",self.CurEssid,"-i",sysgo.WifiDev}
|
nmcli_disconnect := []string{"nmcli","con","down",self.CurEssid}
|
||||||
UI.ExecCmd( wpa_cli_disconnect )
|
UI.ExecCmd( nmcli_disconnect )
|
||||||
fmt.Println(wpa_cli_disconnect)
|
|
||||||
dhcp_release := []string{"dhclient","-r",sysgo.WifiDev}
|
|
||||||
UI.ExecCmd(dhcp_release)
|
|
||||||
|
|
||||||
self.CurEssid = ""
|
self.CurEssid = ""
|
||||||
self.CurBssid = ""
|
self.CurBssid = ""
|
||||||
|
|
||||||
@ -557,28 +553,18 @@ func (self *WifiList) ConfigWireless(password string) {
|
|||||||
|
|
||||||
self.Connecting = true
|
self.Connecting = true
|
||||||
|
|
||||||
if conn, err := GsConnectManager.Connect(ssid, password, gotime.Second * 20); err == nil {
|
out := UI.System(fmt.Sprintf("nmcli dev wifi connect %s password \"%s\"",ssid,password))
|
||||||
fmt.Println("Connected!", conn.NetInterface, conn.SSID, conn.IP4.String(), conn.IP6.String())
|
if strings.Contains(out,"successfully") {
|
||||||
self.CurEssid = self.MyList[self.PsIndex].Essid
|
self.CurEssid = self.MyList[self.PsIndex].Essid
|
||||||
self.CurBssid = self.MyList[self.PsIndex].Bssid
|
self.CurBssid = self.MyList[self.PsIndex].Bssid
|
||||||
self.MyList[self.PsIndex].Password = password
|
self.MyList[self.PsIndex].Password = password
|
||||||
dhcp := []string{"dhclient" ,sysgo.WifiDev}
|
|
||||||
UI.ExecCmd(dhcp)
|
|
||||||
GsConnectManager.ReadNetAddress(gotime.Second*3)
|
|
||||||
self.CurIP = GsConnectManager.IPv4().String()
|
|
||||||
self.ShowBox("Connected")
|
self.ShowBox("Connected")
|
||||||
} else {
|
}else {
|
||||||
err_str := err.Error()
|
self.ShowBox("Wifi connect error")
|
||||||
s := strings.Split(err_str,":")
|
|
||||||
if len(s)> 1 && s[1] == "15" {
|
|
||||||
self.ShowBox("Wifi auth error")
|
|
||||||
}else {
|
|
||||||
self.ShowBox(err_str)
|
|
||||||
}
|
|
||||||
|
|
||||||
self.CurEssid = ""
|
self.CurEssid = ""
|
||||||
self.CurBssid = ""
|
self.CurBssid = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
self.Connecting = false
|
self.Connecting = false
|
||||||
|
|
||||||
self.UpdateListActive()
|
self.UpdateListActive()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user