-
Notifications
You must be signed in to change notification settings - Fork 3
/
dev_wireless.go
56 lines (42 loc) · 1.06 KB
/
dev_wireless.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package nm
import (
"launchpad.net/~jamesh/go-dbus/trunk"
)
func (dev *Device) RequestScan(opts map[string]interface{}) error {
if err := dev.mustBe(Wireless); err != nil {
return err
}
_, err := dev.Call(NM_DEV_WIRELESS_IFACE, "RequestScan", opts)
if err != nil {
return err
}
return nil
}
func (dev *Device) GetAccessPoints() ([]*AccessPoint, error) {
if err := dev.mustBe(Wireless); err != nil {
return nil, err
}
msg, err := dev.Call(NM_DEV_WIRELESS_IFACE, "GetAccessPoints")
if err != nil {
return nil, err
}
var paths []dbus.ObjectPath
if err = msg.Args(&paths); err != nil {
return nil, err
}
ret := make([]*AccessPoint, 0, len(paths))
for _, path := range paths {
ret = append(ret, dev.cli.newAccessPoint(dev, path))
}
return ret, nil
}
func (dev *Device) GetActive() (*AccessPoint, error) {
if err := dev.mustBe(Wireless); err != nil {
return nil, err
}
tmp, err := dev.Get(NM_DEV_WIRELESS_IFACE, "ActiveAccessPoint")
if err != nil {
return nil, err
}
return dev.cli.newAccessPoint(dev, tmp.(dbus.ObjectPath)), nil
}