Documentation ¶
Overview ¶
goupnp is an implementation of a client for various UPnP services.
For most uses, it is recommended to use the code-generated packages under github.com/huin/goupnp/dcps. Example use is shown at http://godoc.org/github.com/huin/goupnp/example
A commonly used client is internetgateway1.WANPPPConnection1: http://godoc.org/github.com/huin/goupnp/dcps/internetgateway1#WANPPPConnection1
Currently only a couple of schemas have code generated for them from the UPnP example XML specifications. Not all methods will work on these clients, because the generated stubs contain the full set of specified methods from the XML specifications, and the discovered services will likely support a subset of those methods.
Index ¶
Constants ¶
const (
DeviceXMLNamespace = "urn:schemas-upnp-org:device-1-0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextError ¶
ContextError is an error that wraps an error with some context information.
func (ContextError) Error ¶
func (err ContextError) Error() string
type Device ¶
type Device struct { DeviceType string `xml:"deviceType"` FriendlyName string `xml:"friendlyName"` Manufacturer string `xml:"manufacturer"` ManufacturerURL URLField `xml:"manufacturerURL"` ModelDescription string `xml:"modelDescription"` ModelName string `xml:"modelName"` ModelNumber string `xml:"modelNumber"` ModelURL URLField `xml:"modelURL"` SerialNumber string `xml:"serialNumber"` UDN string `xml:"UDN"` UPC string `xml:"UPC,omitempty"` Icons []Icon `xml:"iconList>icon,omitempty"` Services []Service `xml:"serviceList>service,omitempty"` Devices []Device `xml:"deviceList>device,omitempty"` // Extra observed elements: PresentationURL URLField `xml:"presentationURL"` }
Device is a UPnP device. It can have child devices.
func (*Device) FindService ¶
FindService finds all (if any) Services under the device and its descendents that have the given ServiceType.
func (*Device) SetURLBase ¶
SetURLBase sets the URLBase for the Device and its underlying components.
func (*Device) VisitDevices ¶
VisitDevices calls visitor for the device, and all its descendent devices.
func (*Device) VisitServices ¶
VisitServices calls visitor for all Services under the device and all its descendent devices.
type Icon ¶
type Icon struct { Mimetype string `xml:"mimetype"` Width int32 `xml:"width"` Height int32 `xml:"height"` Depth int32 `xml:"depth"` URL URLField `xml:"url"` }
Icon is a representative image that a device might include in its description.
func (*Icon) SetURLBase ¶
SetURLBase sets the URLBase for the Icon.
type MaybeRootDevice ¶
type MaybeRootDevice struct { Root *RootDevice Err error }
MaybeRootDevice contains either a RootDevice or an error.
func DiscoverDevices ¶
func DiscoverDevices(searchTarget string) ([]MaybeRootDevice, error)
DiscoverDevices attempts to find targets of the given type. This is typically the entry-point for this package. searchTarget is typically a URN in the form "urn:schemas-upnp-org:device:..." or "urn:schemas-upnp-org:service:...". A single error is returned for errors while attempting to send the query. An error or RootDevice is returned for each discovered RootDevice.
type RootDevice ¶
type RootDevice struct { XMLName xml.Name `xml:"root"` SpecVersion SpecVersion `xml:"specVersion"` URLBase url.URL `xml:"-"` URLBaseStr string `xml:"URLBase"` Device Device `xml:"device"` }
RootDevice is the device description as described by section 2.3 "Device description" in http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf
func (*RootDevice) SetURLBase ¶
func (root *RootDevice) SetURLBase(urlBase *url.URL)
SetURLBase sets the URLBase for the RootDevice and its underlying components.
type Service ¶
type Service struct { ServiceType string `xml:"serviceType"` ServiceId string `xml:"serviceId"` SCPDURL URLField `xml:"SCPDURL"` ControlURL URLField `xml:"controlURL"` EventSubURL URLField `xml:"eventSubURL"` }
Service is a service provided by a UPnP Device.
func (*Service) NewSOAPClient ¶
func (srv *Service) NewSOAPClient() *soap.SOAPClient
func (*Service) RequestSCDP ¶
RequestSCDP requests the SCPD (soap actions and state variables description) for the service.
func (*Service) SetURLBase ¶
SetURLBase sets the URLBase for the Service.
type ServiceClient ¶
type ServiceClient struct { SOAPClient *soap.SOAPClient RootDevice *RootDevice Service *Service }
ServiceClient is a SOAP client, root device and the service for the SOAP client rolled into one value. The root device and service are intended to be informational.
func NewServiceClients ¶
func NewServiceClients(searchTarget string) (clients []ServiceClient, errors []error, err error)
func (*ServiceClient) GetServiceClient ¶
func (client *ServiceClient) GetServiceClient() *ServiceClient
GetServiceClient returns the ServiceClient itself. This is provided so that the service client attributes can be accessed via an interface method on a wrapping type.
type SpecVersion ¶
SpecVersion is part of a RootDevice, describes the version of the specification that the data adheres to.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
dcps
|
|
internetgateway1
Client for UPnP Device Control Protocol Internet Gateway Device v1.
|
Client for UPnP Device Control Protocol Internet Gateway Device v1. |
internetgateway2
Client for UPnP Device Control Protocol Internet Gateway Device v2.
|
Client for UPnP Device Control Protocol Internet Gateway Device v2. |
Serves as examples of using the goupnp library.
|
Serves as examples of using the goupnp library. |