Documentation ¶
Overview ¶
A module to support bookmarking discovered UPnP devices.
This module is intended to solve the problem of addressing commands to a specific UPnP device, where each device is known by a user-unfriendly UUID, where network addresses are subject to change, ala DHCP, and where it is not desirable to repeat device discovery each time a command is to be sent.
Since device discovery is slow, it should only be run once in a while when DHCP leases would have expired. The discovery process writes the list of discovered devices to the list of bookmarks.
Once, when the device is installed, an association is added to the list of bookmarks, making a memorable alias, i.e. 'kitchen', point to a particular UUID.
Now whenever network addresses change disovery can be rerun, with aliases automatically pointing to the new address associated with the static UUID.
Look at sonos_test.go for examples of how this class is used.
Index ¶
- type Bookmark
- type Bookmarks
- type Config
- func (this *Config) AddAlias(uuid ssdp.UUID, alias string)
- func (this *Config) AddBookmark(ident, product, productVersion string, location ssdp.Location, uuid ssdp.UUID)
- func (this *Config) ClearAlias(alias string)
- func (this *Config) ClearAliases()
- func (this *Config) Init()
- func (this *Config) Lookup(ident string) ssdp.Device
- func (this *Config) Save()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bookmark ¶
type Bookmark struct { // A memorable string standing in for a UUID Alias string `json:"alias,omitempty"` // The name of the device's product, e.g. 'Sonos' Product string `json:"product,omitempty"` // The product version (e.g. "28.1-83040 (BR100)") ProductVersion string `json:"productVersion,omitempty"` // The last know location of the device Location ssdp.Location `json:"location,omitempty"` // The device's UUID UUID ssdp.UUID `json:"uuid"` }
A strucutre that holds all of the fields required to build a UPnP device without first trying to discover it.
type Bookmarks ¶
A map holding a set of bookmarks, where the key is alternately the UUID of the device, or an alias to a device.
type Config ¶
type Config struct { // A set of discovered devices Bookmarks Bookmarks // contains filtered or unexported fields }
A container for the runtime configuration used by go-sonos application.
func MakeConfig ¶
Create a configuration object where @dir is the path to the configuration directory. Note that Init() must be called in order to use the newly created object.
func (*Config) AddBookmark ¶
func (this *Config) AddBookmark(ident, product, productVersion string, location ssdp.Location, uuid ssdp.UUID)
Add a bookmark to the bookmark set where @ident is either the uuid or the alias to add; @product is the product string, such as 'Sonos'; @localtion is the network location of the resource; and @uuid is the device's UUID. When adding a device @ident and @uuid should be the same; when adding an alias @ident and @uuid will be different.
func (*Config) ClearAlias ¶
Remove any association of a device to the alias @alias. If @alias is a UUID this method is a noop.
func (*Config) ClearAliases ¶
func (this *Config) ClearAliases()
Remove all aliases from the set of bookmarks.
func (*Config) Init ¶
func (this *Config) Init()
Initialize the configuration object by loading any existing configuration from disk. This method creates the configuration directory, if needed.