Implementation with iwd
This commit is contained in:
parent
2b3a5b89f8
commit
17d665e21a
10 changed files with 755 additions and 171 deletions
39
internal/wifi/iwd/agentmanager.go
Normal file
39
internal/wifi/iwd/agentmanager.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package iwd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
)
|
||||
|
||||
// AgentManager handles agent registration with iwd
|
||||
type AgentManager struct {
|
||||
conn *dbus.Conn
|
||||
obj dbus.BusObject
|
||||
}
|
||||
|
||||
// NewAgentManager creates a new AgentManager instance
|
||||
func NewAgentManager(conn *dbus.Conn) *AgentManager {
|
||||
return &AgentManager{
|
||||
conn: conn,
|
||||
obj: conn.Object(Service, "/net/connman/iwd"),
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterAgent registers an agent with iwd
|
||||
func (am *AgentManager) RegisterAgent(agentPath dbus.ObjectPath) error {
|
||||
err := am.obj.Call(AgentManagerInterface+".RegisterAgent", 0, agentPath).Err
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to register agent: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnregisterAgent unregisters an agent from iwd
|
||||
func (am *AgentManager) UnregisterAgent(agentPath dbus.ObjectPath) error {
|
||||
err := am.obj.Call(AgentManagerInterface+".UnregisterAgent", 0, agentPath).Err
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unregister agent: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue