forked from xXAfoeXx/iwd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice.go
35 lines (29 loc) · 847 Bytes
/
device.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
package iwd
import "github.com/godbus/dbus/v5"
const (
objectDevice = "net.connman.iwd.Device"
)
// Device refers to the iwd network device like "wlan0" for example: /net/connman/iwd/0/4
type Device struct {
Path dbus.ObjectPath
Adapter dbus.ObjectPath
Address string
Mode string
Name string
Powered bool
}
func (d Device) SetAp(conn *dbus.Conn) error {
obj := conn.Object(objectIwd, d.Path)
err := obj.SetProperty(objectDevice+".Mode", dbus.MakeVariant("ap"))
return err
}
func (d Device) SetOn(conn *dbus.Conn) error {
obj := conn.Object(objectIwd, d.Path)
err := obj.SetProperty(objectDevice+".Powered", dbus.MakeVariant(true))
return err
}
func (d Device) SetOff(conn *dbus.Conn) error {
obj := conn.Object(objectIwd, d.Path)
err := obj.SetProperty(objectDevice+".Powered", dbus.MakeVariant(false))
return err
}