Documentation
¶
Overview ¶
Package desc implements data types to map to the content from description XML files
Index ¶
Constants ¶
const (
// UPNPRootDeviceType is the UPnP root device indicator
UPNPRootDeviceType = "upnp:rootdevice"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
Action represents an action from a service description
type AllowedValueRange ¶
type AllowedValueRange struct { Minimum string `xml:"minimum"` Maximum string `xml:"maximum"` Step string `xml:"step"` }
AllowedValueRange represents the allowed value range of aa state variable
func (*AllowedValueRange) IsZero ¶
func (me *AllowedValueRange) IsZero() bool
IsZero returns true if the allowed value range is empty, otherwise false
type Argument ¶
type Argument struct { Name string `xml:"name"` Direction string `xml:"direction"` RelatedStateVariable string `xml:"relatedStateVariable"` }
Argument represents an argument from a service description
type Device ¶
type Device struct { DeviceType string `xml:"deviceType"` FriendlyName string `xml:"friendlyName"` Manufacturer string `xml:"manufacturer"` ManufacturerURL string `xml:"manufacturerURL"` ModelDescription string `xml:"modelDescription"` ModelName string `xml:"modelName"` ModelNumber string `xml:"modelNumber"` ModelURL string `xml:"modelURL"` SerialNumber string `xml:"serialNumber"` UDN string `xml:"UDN"` UPC string `xml:"UPC,omitempty"` Icons []Icon `xml:"iconList>icon,omitempty"` Services []ServiceReference `xml:"serviceList>service,omitempty"` Devices []Device `xml:"deviceList>device,omitempty"` PresentationURL string `xml:"presentationURL"` }
Device represents a device description
func (*Device) ClearAttr ¶ added in v0.3.3
func (me *Device) ClearAttr()
ClearAttr clear attributes that are under the control of the UPnP server
type Icon ¶
type Icon struct { Mimetype string `xml:"mimetype"` Width uint32 `xml:"width"` Height uint32 `xml:"height"` Depth uint32 `xml:"depth"` URL string `xml:"url"` }
Icon represents the icon part of a device description
type RootDevice ¶
type RootDevice struct { XMLName xml.Name `xml:"urn:schemas-upnp-org:device-1-0 root"` ConfigID uint32 `xml:"configId,attr"` SpecVersion SpecVersion `xml:"specVersion"` Device Device `xml:"device"` }
RootDevice represents a device description as described in https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf
func LoadRootDevice ¶
func LoadRootDevice(filepath string) (dvc *RootDevice, err error)
LoadRootDevice reads a root device description file and creates a root device object from it
func (*RootDevice) ClearAttr ¶ added in v0.3.3
func (me *RootDevice) ClearAttr()
ClearAttr clear attributes that are under the control of the UPnP server such as ConfigID
func (*RootDevice) Hash ¶
func (me *RootDevice) Hash() (hash uint64, err error)
Hash calculates the FNV hash of the XML representation of a root device description
func (*RootDevice) Validate ¶
func (me *RootDevice) Validate() (ok bool, res []string)
Validate checks whether the attribute values are OK. Problem messages are stored in res.
type Service ¶
type Service struct { XMLName xml.Name `xml:"urn:schemas-upnp-org:service-1-0 scpd"` ConfigID uint32 `xml:"configId,attr"` SpecVersion SpecVersion `xml:"specVersion"` Actions []Action `xml:"actionList>action"` ServiceStateTable []StateVariable `xml:"serviceStateTable>stateVariable"` }
Service represents a service description as described in https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf
func LoadService ¶
LoadService reads a service description file and creates a service object from it
func (*Service) ClearAttr ¶ added in v0.3.3
func (me *Service) ClearAttr()
ClearAttr clear attributes that are under the control of the UPnP server such as ConfigID
type ServiceMap ¶
ServiceMap maps a service id to the correspondingh service description
type ServiceReference ¶
type ServiceReference struct { ServiceType string `xml:"serviceType"` ServiceID string `xml:"serviceId"` SCPDURL string `xml:"SCPDURL"` ControlURL string `xml:"controlURL"` EventSubURL string `xml:"eventSubURL"` }
ServiceReference represents the service information that is contained in a device description
func (*ServiceReference) ClearAttr ¶ added in v0.3.3
func (me *ServiceReference) ClearAttr()
ClearAttr clear attributes that are under the control of the UPnP server such as service URLs
func (*ServiceReference) Trim ¶
func (me *ServiceReference) Trim()
Trim removes leading and trailing spaces for some attributes
func (*ServiceReference) Validate ¶
func (me *ServiceReference) Validate(res *[]string) (ok bool)
Validate executes a trim and checks whether the attribute values are OK. Problem messages are added to res.
type SpecVersion ¶
SpecVersion is part of a RootDevice, describes the version of the specification that the data adheres to.
type StateVariable ¶
type StateVariable struct { Name string `xml:"name"` SendEvents string `xml:"sendEvents,attr,omitempty"` Multicast string `xml:"multicast,attr,omitempty"` DataType string `xml:"dataType"` DefaultValue string `xml:"defaultValue"` AllowedValueList []string `xml:"allowedValueList>allowedValue,omitempty"` AllowedValueRange AllowedValueRange `xml:"allowedValueRange,omitempty"` }
StateVariable represents a state variable from a service description
func (*StateVariable) Trim ¶
func (me *StateVariable) Trim()
Trim removes leading and trailing spaces for some attributes
func (*StateVariable) Validate ¶
func (me *StateVariable) Validate(res *[]string) (ok bool)
Validate checks whether the attribute values are OK. Problem messages are added to res.