Skip to content

Commit

Permalink
Merge pull request #8 from andy-shi88/add-read-currentBSS-and-current…
Browse files Browse the repository at this point in the history
…Network

add CurrentBSS and CurrentNetwork getter
  • Loading branch information
mark2b authored Apr 16, 2021
2 parents c6056dd + 74b7f8c commit d5e7b6c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion internal/wpa_dbus/wpa_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package wpa_dbus
import (
"fmt"

"github.com/mark2b/wpa-connect/internal/log"
"github.com/godbus/dbus"
"github.com/mark2b/wpa-connect/internal/log"
)

type InterfaceWPA struct {
Expand Down Expand Up @@ -212,3 +212,27 @@ func (self *InterfaceWPA) RemoveSignalsObserver() *InterfaceWPA {
}
return self
}

func (self *InterfaceWPA) ReadCurrentBSS() *InterfaceWPA {
if self.Error == nil {
if value, err := self.WPA.get("fi.w1.wpa_supplicant1.Interface.CurrentBSS", self.Object); err == nil {
bssObjectPath := value.(dbus.ObjectPath)
self.CurrentBSS = &BSSWPA{Interface: self, Object: self.WPA.Connection.Object("fi.w1.wpa_supplicant1", bssObjectPath)}
} else {
self.Error = err
}
}
return self
}

func (self *InterfaceWPA) ReadCurrentNetwork() *InterfaceWPA {
if self.Error == nil {
if network, err := self.WPA.get("fi.w1.wpa_supplicant1.Interface.CurrentNetwork", self.Object); err == nil {
networkObjectPath := network.(dbus.ObjectPath)
self.CurrentNetwork = &NetworkWPA{Interface: self, Object: self.WPA.Connection.Object("fi.w1.wpa_supplicant1", networkObjectPath)}
} else {
self.Error = err
}
}
return self
}

0 comments on commit d5e7b6c

Please sign in to comment.