upnp

package
v0.0.0-...-bf4a537 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2018 License: BSD-3-Clause Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DDDRoute     = "ddd"
	ControlRoute = "control"
	SCPDRoute    = "scpd"
	IconRoute    = "icon"
)
View Source
const (
	InvalidActionErrorCode        = 401
	ActionFailedErrorCode         = 501
	ArgumentValueInvalidErrorCode = 600
)
View Source
const (
	ServiceControlPath   = "/control"
	SCPDPath             = "/scpd.xml"
	ServiceSubscribePath = "/subscribe"
)

Variables

View Source
var (
	InvalidActionError        = Errorf(InvalidActionErrorCode, "Invalid Action")
	ArgumentValueInvalidError = Errorf(ArgumentValueInvalidErrorCode, "The argument value is invalid")
)

Functions

func ExpandTypes

func ExpandTypes(t string) (ts []string, err error)

Types

type Action

type Action interface {
	soap.Action
	EmptyReturnValue() interface{}
}

func ActionFunc

func ActionFunc(f interface{}) (a Action, err error)

type Device

type Device interface {
	AddIcon(Icon)
	AddService(*Service) error

	DDDLocation() (*url.URL, error)
	UniqueDeviceName() string
	ConfigID() int32
	DeviceTypes() []string
	ServiceTypes() []string
}

func NewDevice

func NewDevice(spec DeviceSpec, router *mux.Router) (ret Device, err error)

type DeviceSpec

type DeviceSpec 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      uint   `xml:"modelNumber"`
	ModelURL         string `xml:"modelURL"`
	UDN              string
	UPC              string
	LastModified     time.Time `xml:"-"`
}

type Error

type Error struct {
	XMLName xml.Name `xml:"urn:schemas-upnp-org:control-1-0 UPnPError"`
	Code    uint     `xml:"errorCode"`
	Desc    string   `xml:"errorDescription"`
}

func ConvertError

func ConvertError(err error) *Error

ConvertError converts any error to an UPNP error

func Errorf

func Errorf(code uint, tpl string, args ...interface{}) *Error

Errorf creates an UPNP error from the given code and description

func (*Error) Error

func (e *Error) Error() string

type Icon

type Icon struct {
	Mimetype string `xml:"mimetype"`
	URL      string `xml:"url"`
	Width    int    `xml:"width"`
	Height   int    `xml:"height"`
	Depth    int    `xml:"depth"`
}

type Service

type Service struct {
	XMLName           xml.Name            `xml:"urn:schemas-upnp-org:service-1-0 scpd"`
	SpecVersion       specVersion         `xml:"specVersion"`
	ActionList        []actionDesc        `xml:"actionList>action"`
	ServiceStateTable []stateVariableDesc `xml:"serviceStateTable>stateVariable"`
	// contains filtered or unexported fields
}

Service describes an UPNP Service

func NewService

func NewService(id, urn string) *Service

NewService initializes a new Service

func (*Service) AddAction

func (s *Service) AddAction(name string, action Action) (err error)

AddAction adds a new action the service specs.

func (*Service) AddActionFunc

func (s *Service) AddActionFunc(name string, f interface{}) (err error)

AddActionFunc converts the given function to an action and adds it to the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL