Skip to content

Commit

Permalink
cleanup style warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ndecker committed Dec 12, 2022
1 parent 650faef commit 3defd66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
11 changes: 5 additions & 6 deletions fritzbox_upnp/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ type Argument struct {
StateVariable *StateVariable
}

// A state variable that can be manipulated through actions
// StateVariable that can be manipulated through actions
type StateVariable struct {
Name string `xml:"name"`
DataType string `xml:"dataType"`
DefaultValue string `xml:"defaultValue"`
}

// The result of a Call() contains all output arguments of the call.
// Result of a Call() contains all output arguments of the call.
// The map is indexed by the name of the state variable.
// The type of the value is string, uint64 or bool depending of the DataType of the variable.
// The type of the value is string, uint64 or bool depending on the DataType of the variable.
type Result map[string]interface{}

// Call an action.
// Currently only actions without input arguments are supported.
func (a *Action) Call() (Result, error) {
bodystr := fmt.Sprintf(`
bodyStr := fmt.Sprintf(`
<?xml version='1.0' encoding='utf-8'?>
<s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body>
Expand All @@ -64,7 +64,7 @@ func (a *Action) Call() (Result, error) {
`, a.Name, a.service.ServiceType)

url := a.service.Device.root.baseUrl + a.service.ControlUrl
body := strings.NewReader(bodystr)
body := strings.NewReader(bodyStr)

req, err := http.NewRequest("POST", url, body)
if err != nil {
Expand Down Expand Up @@ -94,7 +94,6 @@ func (a *Action) Call() (Result, error) {
}

return a.parseSoapResponse(data)

}

func (a *Action) parseSoapResponse(data []byte) (Result, error) {
Expand Down
15 changes: 4 additions & 11 deletions fritzbox_upnp/service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Query UPNP variables from Fritz!Box devices.
// Package fritzbox_upnp queries UPNP variables from Fritz!Box devices.
package fritzbox_upnp

// Copyright 2016 Nils Decker
Expand Down Expand Up @@ -26,13 +26,7 @@ import (
)

// curl http://fritz.box:49000/igddesc.xml
// curl http://fritz.box:49000/any.xml
// curl http://fritz.box:49000/igdconnSCPD.xml
// curl http://fritz.box:49000/igdicfgSCPD.xml
// curl http://fritz.box:49000/igddslSCPD.xml
// curl http://fritz.box:49000/igd2ipv6fwcSCPD.xml

// For TR64: curl http://fritz.box:49000/tr64desc.xmll
// curl http://fritz.box:49000/tr64desc.xmll

const textXml = `text/xml; charset="utf-8"`

Expand Down Expand Up @@ -62,7 +56,7 @@ type Root struct {
Services map[string]*Service // Map of all services indexed by .ServiceType
}

// An UPNP Device
// Device represents a UPNP Device
type Device struct {
root *Root

Expand All @@ -82,7 +76,7 @@ type Device struct {
PresentationUrl string `xml:"presentationURL"`
}

// An UPNP Service
// Service represents a UPNP Service
type Service struct {
Device *Device

Expand Down Expand Up @@ -114,7 +108,6 @@ func (d *Device) fillServices(r *Root) error {
}

var scpd scpdRoot

dec := xml.NewDecoder(response.Body)
err = dec.Decode(&scpd)
if err != nil {
Expand Down

0 comments on commit 3defd66

Please sign in to comment.