Skip to content

Commit

Permalink
gestion de null sur Name et Model
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Rouge committed May 21, 2021
1 parent ed48012 commit ac77c87
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions ap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package iwd

import "github.com/godbus/dbus/v5"

const (
objectAp = "net.connman.iwd.Ap"
callApActivate = "net.connman.iwd.Station.Scan"
)

// Station refers to net.connman.iwd.Station
type Ap struct {
Path dbus.ObjectPath
ConnectedNetwork dbus.ObjectPath
Scanning bool
State string
}
14 changes: 13 additions & 1 deletion iwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,21 @@ func New(conn *dbus.Conn) Iwd {
for resource, obj := range v {
switch resource {
case objectAdapter:
model := ""
name := ""
if obj["Model"].Value() == nil {
model = ""
} else {
model = obj["Model"].Value().(string)
}
if obj["Name"].Value() == nil {
name = ""
} else {
name = obj["Name"].Value().(string)
}
i.Adapters = append(i.Adapters, Adapter{
Path: k,
Model: obj["Model"].Value().(string), Name: obj["Name"].Value().(string),
Model: model, Name: name,
Powered: obj["Powered"].Value().(bool), SupportedModes: obj["SupportedModes"].Value().([]string),
Vendor: obj["Vendor"].Value().(string),
})
Expand Down

0 comments on commit ac77c87

Please sign in to comment.