forked from BellerophonMobile/gonetworkmanager
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathDeviceDummy.go
44 lines (33 loc) · 875 Bytes
/
DeviceDummy.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
package gonetworkmanager
import (
"encoding/json"
"github.com/godbus/dbus/v5"
)
const (
DeviceDummyInterface = DeviceInterface + ".Dummy"
/* Properties */
DeviceDummyPropertyHwAddress = DeviceDummyInterface + ".HwAddress" // readable s
)
type DeviceDummy interface {
Device
// Hardware address of the device.
GetPropertyHwAddress() (string, error)
}
func NewDeviceDummy(objectPath dbus.ObjectPath) (DeviceDummy, error) {
var d deviceDummy
return &d, d.init(NetworkManagerInterface, objectPath)
}
type deviceDummy struct {
device
}
func (d *deviceDummy) GetPropertyHwAddress() (string, error) {
return d.getStringProperty(DeviceDummyPropertyHwAddress)
}
func (d *deviceDummy) MarshalJSON() ([]byte, error) {
m, err := d.device.marshalMap()
if err != nil {
return nil, err
}
m["HwAddress"], _ = d.GetPropertyHwAddress()
return json.Marshal(m)
}