49 lines
977 B
Go
49 lines
977 B
Go
package supervised
|
|
|
|
import (
|
|
"github.com/godbus/dbus/v5"
|
|
"github.com/godbus/dbus/v5/introspect"
|
|
"github.com/godbus/dbus/v5/prop"
|
|
|
|
logging "github.com/home-assistant/os-agent/utils/log"
|
|
)
|
|
|
|
const (
|
|
objectPath = "/io/hass/os/Boards/Supervised"
|
|
ifaceName = "io.hass.os.Boards.Supervised"
|
|
)
|
|
|
|
type supervised struct {
|
|
conn *dbus.Conn
|
|
}
|
|
|
|
func InitializeDBus(conn *dbus.Conn) {
|
|
d := supervised{
|
|
conn: conn,
|
|
}
|
|
|
|
err := conn.Export(d, objectPath, ifaceName)
|
|
if err != nil {
|
|
logging.Critical.Panic(err)
|
|
}
|
|
|
|
node := &introspect.Node{
|
|
Name: objectPath,
|
|
Interfaces: []introspect.Interface{
|
|
introspect.IntrospectData,
|
|
prop.IntrospectData,
|
|
{
|
|
Name: ifaceName,
|
|
Methods: introspect.Methods(d),
|
|
},
|
|
},
|
|
}
|
|
|
|
err = conn.Export(introspect.NewIntrospectable(node), objectPath, "org.freedesktop.DBus.Introspectable")
|
|
if err != nil {
|
|
logging.Critical.Panic(err)
|
|
}
|
|
|
|
logging.Info.Printf("Exposing object %s with interface %s ...", objectPath, ifaceName)
|
|
}
|