diff --git a/fritzbox_upnp/action.go b/fritzbox_upnp/action.go index 7ebad69..be89a62 100644 --- a/fritzbox_upnp/action.go +++ b/fritzbox_upnp/action.go @@ -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(` @@ -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 { @@ -94,7 +94,6 @@ func (a *Action) Call() (Result, error) { } return a.parseSoapResponse(data) - } func (a *Action) parseSoapResponse(data []byte) (Result, error) { diff --git a/fritzbox_upnp/service.go b/fritzbox_upnp/service.go index 34535c6..a217ada 100644 --- a/fritzbox_upnp/service.go +++ b/fritzbox_upnp/service.go @@ -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 @@ -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"` @@ -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 @@ -82,7 +76,7 @@ type Device struct { PresentationUrl string `xml:"presentationURL"` } -// An UPNP Service +// Service represents a UPNP Service type Service struct { Device *Device @@ -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 {