stagelinq

package module
v0.0.0-...-3326363 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 15 Imported by: 0

README

StagelinQ for Golang

Go Reference

This library implements Denon's StagelinQ protocol, allowing any Go application to talk to devices that are compatible with this protocol on the network.

An example application is provided that, if running successfully, will output information like this:

Screenshot of the example CLI

Features

  • Automatically discover StagelinQ-compatible devices on the network
  • Access state map information such as currently playing track metadata, fader values, etc.

Stability

The code of this project is an experimental reverse-engineering effort and therefor can behave erratically in untested cases. Currently, this code only has been practically tested with the Denon Prime 4.

If you have any other Denon devices you would like to test this library against, please do! Even better, you can let me know if you run into any bugs by reporting them as an issue ticket.

Testing

This project uses Go tests, they can be run with this command:

go test ./...

License

This code is licensed under the MIT license. For more information, please read LICENSE.

Documentation

Index

Constants

View Source
const (
	ClientLibrarianDevicesControllerCurrentDevice         = "/Client/Librarian/DevicesController/CurrentDevice"
	ClientLibrarianDevicesControllerHasSDCardConnected    = "/Client/Librarian/DevicesController/HasSDCardConnected"
	ClientLibrarianDevicesControllerHasUsbDeviceConnected = "/Client/Librarian/DevicesController/HasUsbDeviceConnected"
	ClientPreferencesLayerB                               = "/Client/Preferences/LayerB"
	ClientPreferencesPlayer                               = "/Client/Preferences/Player"
	ClientPreferencesProfileApplicationPlayerColor1       = "/Client/Preferences/Profile/Application/PlayerColor1"
	ClientPreferencesProfileApplicationPlayerColor1A      = "/Client/Preferences/Profile/Application/PlayerColor1A"
	ClientPreferencesProfileApplicationPlayerColor1B      = "/Client/Preferences/Profile/Application/PlayerColor1B"
	ClientPreferencesProfileApplicationPlayerColor2       = "/Client/Preferences/Profile/Application/PlayerColor2"
	ClientPreferencesProfileApplicationPlayerColor2A      = "/Client/Preferences/Profile/Application/PlayerColor2A"
	ClientPreferencesProfileApplicationPlayerColor2B      = "/Client/Preferences/Profile/Application/PlayerColor2B"
	ClientPreferencesProfileApplicationPlayerColor3       = "/Client/Preferences/Profile/Application/PlayerColor3"
	ClientPreferencesProfileApplicationPlayerColor3A      = "/Client/Preferences/Profile/Application/PlayerColor3A"
	ClientPreferencesProfileApplicationPlayerColor3B      = "/Client/Preferences/Profile/Application/PlayerColor3B"
	ClientPreferencesProfileApplicationPlayerColor4       = "/Client/Preferences/Profile/Application/PlayerColor4"
	ClientPreferencesProfileApplicationPlayerColor4A      = "/Client/Preferences/Profile/Application/PlayerColor4A"
	ClientPreferencesProfileApplicationPlayerColor4B      = "/Client/Preferences/Profile/Application/PlayerColor4B"
	ClientPreferencesProfileApplicationSyncMode           = "/Client/Preferences/Profile/Application/SyncMode"
	EngineDeck1CurrentBPM                                 = "/Engine/Deck1/CurrentBPM"
	EngineDeck1ExternalMixerVolume                        = "/Engine/Deck1/ExternalMixerVolume"
	EngineDeck1ExternalScratchWheelTouch                  = "/Engine/Deck1/ExternalScratchWheelTouch"
	EngineDeck1PadsView                                   = "/Engine/Deck1/Pads/View"
	EngineDeck1Play                                       = "/Engine/Deck1/Play"
	EngineDeck1PlayState                                  = "/Engine/Deck1/PlayState"
	EngineDeck1PlayStatePath                              = "/Engine/Deck1/PlayStatePath"
	EngineDeck1Speed                                      = "/Engine/Deck1/Speed"
	EngineDeck1SpeedNeutral                               = "/Engine/Deck1/SpeedNeutral"
	EngineDeck1SpeedOffsetDown                            = "/Engine/Deck1/SpeedOffsetDown"
	EngineDeck1SpeedOffsetUp                              = "/Engine/Deck1/SpeedOffsetUp"
	EngineDeck1SpeedRange                                 = "/Engine/Deck1/SpeedRange"
	EngineDeck1SpeedState                                 = "/Engine/Deck1/SpeedState"
	EngineDeck1SyncMode                                   = "/Engine/Deck1/SyncMode"
	EngineDeck1TrackArtistName                            = "/Engine/Deck1/Track/ArtistName"
	EngineDeck1TrackBleep                                 = "/Engine/Deck1/Track/Bleep"
	EngineDeck1TrackCuePosition                           = "/Engine/Deck1/Track/CuePosition"
	EngineDeck1TrackCurrentBPM                            = "/Engine/Deck1/Track/CurrentBPM"
	EngineDeck1TrackCurrentKeyIndex                       = "/Engine/Deck1/Track/CurrentKeyIndex"
	EngineDeck1TrackCurrentLoopInPosition                 = "/Engine/Deck1/Track/CurrentLoopInPosition"
	EngineDeck1TrackCurrentLoopOutPosition                = "/Engine/Deck1/Track/CurrentLoopOutPosition"
	EngineDeck1TrackCurrentLoopSizeInBeats                = "/Engine/Deck1/Track/CurrentLoopSizeInBeats"
	EngineDeck1TrackKeyLock                               = "/Engine/Deck1/Track/KeyLock"
	EngineDeck1TrackLoopEnableState                       = "/Engine/Deck1/Track/LoopEnableState"
	EngineDeck1TrackLoopQuickLoop1                        = "/Engine/Deck1/Track/Loop/QuickLoop1"
	EngineDeck1TrackLoopQuickLoop2                        = "/Engine/Deck1/Track/Loop/QuickLoop2"
	EngineDeck1TrackLoopQuickLoop3                        = "/Engine/Deck1/Track/Loop/QuickLoop3"
	EngineDeck1TrackLoopQuickLoop4                        = "/Engine/Deck1/Track/Loop/QuickLoop4"
	EngineDeck1TrackLoopQuickLoop5                        = "/Engine/Deck1/Track/Loop/QuickLoop5"
	EngineDeck1TrackLoopQuickLoop6                        = "/Engine/Deck1/Track/Loop/QuickLoop6"
	EngineDeck1TrackLoopQuickLoop7                        = "/Engine/Deck1/Track/Loop/QuickLoop7"
	EngineDeck1TrackLoopQuickLoop8                        = "/Engine/Deck1/Track/Loop/QuickLoop8"
	EngineDeck1TrackPlayPauseLEDState                     = "/Engine/Deck1/Track/PlayPauseLEDState"
	EngineDeck1TrackSampleRate                            = "/Engine/Deck1/Track/SampleRate"
	EngineDeck1TrackSongAnalyzed                          = "/Engine/Deck1/Track/SongAnalyzed"
	EngineDeck1TrackSongLoaded                            = "/Engine/Deck1/Track/SongLoaded"
	EngineDeck1TrackSongName                              = "/Engine/Deck1/Track/SongName"
	EngineDeck1TrackSoundSwitchGUID                       = "/Engine/Deck1/Track/SoundSwitchGuid"
	EngineDeck1TrackTrackBytes                            = "/Engine/Deck1/Track/TrackBytes"
	EngineDeck1TrackTrackData                             = "/Engine/Deck1/Track/TrackData"
	EngineDeck1TrackTrackLength                           = "/Engine/Deck1/Track/TrackLength"
	EngineDeck1TrackTrackName                             = "/Engine/Deck1/Track/TrackName"
	EngineDeck1TrackTrackNetworkPath                      = "/Engine/Deck1/Track/TrackNetworkPath"
	EngineDeck1TrackTrackURI                              = "/Engine/Deck1/Track/TrackUri"
	EngineDeck1TrackTrackWasPlayed                        = "/Engine/Deck1/Track/TrackWasPlayed"
	EngineDeck2CurrentBPM                                 = "/Engine/Deck2/CurrentBPM"
	EngineDeck2ExternalMixerVolume                        = "/Engine/Deck2/ExternalMixerVolume"
	EngineDeck2ExternalScratchWheelTouch                  = "/Engine/Deck2/ExternalScratchWheelTouch"
	EngineDeck2PadsView                                   = "/Engine/Deck2/Pads/View"
	EngineDeck2Play                                       = "/Engine/Deck2/Play"
	EngineDeck2PlayState                                  = "/Engine/Deck2/PlayState"
	EngineDeck2PlayStatePath                              = "/Engine/Deck2/PlayStatePath"
	EngineDeck2Speed                                      = "/Engine/Deck2/Speed"
	EngineDeck2SpeedNeutral                               = "/Engine/Deck2/SpeedNeutral"
	EngineDeck2SpeedOffsetDown                            = "/Engine/Deck2/SpeedOffsetDown"
	EngineDeck2SpeedOffsetUp                              = "/Engine/Deck2/SpeedOffsetUp"
	EngineDeck2SpeedRange                                 = "/Engine/Deck2/SpeedRange"
	EngineDeck2SpeedState                                 = "/Engine/Deck2/SpeedState"
	EngineDeck2SyncMode                                   = "/Engine/Deck2/SyncMode"
	EngineDeck2TrackArtistName                            = "/Engine/Deck2/Track/ArtistName"
	EngineDeck2TrackBleep                                 = "/Engine/Deck2/Track/Bleep"
	EngineDeck2TrackCuePosition                           = "/Engine/Deck2/Track/CuePosition"
	EngineDeck2TrackCurrentBPM                            = "/Engine/Deck2/Track/CurrentBPM"
	EngineDeck2TrackCurrentKeyIndex                       = "/Engine/Deck2/Track/CurrentKeyIndex"
	EngineDeck2TrackCurrentLoopInPosition                 = "/Engine/Deck2/Track/CurrentLoopInPosition"
	EngineDeck2TrackCurrentLoopOutPosition                = "/Engine/Deck2/Track/CurrentLoopOutPosition"
	EngineDeck2TrackCurrentLoopSizeInBeats                = "/Engine/Deck2/Track/CurrentLoopSizeInBeats"
	EngineDeck2TrackKeyLock                               = "/Engine/Deck2/Track/KeyLock"
	EngineDeck2TrackLoopEnableState                       = "/Engine/Deck2/Track/LoopEnableState"
	EngineDeck2TrackLoopQuickLoop1                        = "/Engine/Deck2/Track/Loop/QuickLoop1"
	EngineDeck2TrackLoopQuickLoop2                        = "/Engine/Deck2/Track/Loop/QuickLoop2"
	EngineDeck2TrackLoopQuickLoop3                        = "/Engine/Deck2/Track/Loop/QuickLoop3"
	EngineDeck2TrackLoopQuickLoop4                        = "/Engine/Deck2/Track/Loop/QuickLoop4"
	EngineDeck2TrackLoopQuickLoop5                        = "/Engine/Deck2/Track/Loop/QuickLoop5"
	EngineDeck2TrackLoopQuickLoop6                        = "/Engine/Deck2/Track/Loop/QuickLoop6"
	EngineDeck2TrackLoopQuickLoop7                        = "/Engine/Deck2/Track/Loop/QuickLoop7"
	EngineDeck2TrackLoopQuickLoop8                        = "/Engine/Deck2/Track/Loop/QuickLoop8"
	EngineDeck2TrackPlayPauseLEDState                     = "/Engine/Deck2/Track/PlayPauseLEDState"
	EngineDeck2TrackSampleRate                            = "/Engine/Deck2/Track/SampleRate"
	EngineDeck2TrackSongAnalyzed                          = "/Engine/Deck2/Track/SongAnalyzed"
	EngineDeck2TrackSongLoaded                            = "/Engine/Deck2/Track/SongLoaded"
	EngineDeck2TrackSongName                              = "/Engine/Deck2/Track/SongName"
	EngineDeck2TrackSoundSwitchGUID                       = "/Engine/Deck2/Track/SoundSwitchGuid"
	EngineDeck2TrackTrackBytes                            = "/Engine/Deck2/Track/TrackBytes"
	EngineDeck2TrackTrackData                             = "/Engine/Deck2/Track/TrackData"
	EngineDeck2TrackTrackLength                           = "/Engine/Deck2/Track/TrackLength"
	EngineDeck2TrackTrackName                             = "/Engine/Deck2/Track/TrackName"
	EngineDeck2TrackTrackNetworkPath                      = "/Engine/Deck2/Track/TrackNetworkPath"
	EngineDeck2TrackTrackURI                              = "/Engine/Deck2/Track/TrackUri"
	EngineDeck2TrackTrackWasPlayed                        = "/Engine/Deck2/Track/TrackWasPlayed"
	EngineDeck3CurrentBPM                                 = "/Engine/Deck3/CurrentBPM"
	EngineDeck3ExternalMixerVolume                        = "/Engine/Deck3/ExternalMixerVolume"
	EngineDeck3ExternalScratchWheelTouch                  = "/Engine/Deck3/ExternalScratchWheelTouch"
	EngineDeck3PadsView                                   = "/Engine/Deck3/Pads/View"
	EngineDeck3Play                                       = "/Engine/Deck3/Play"
	EngineDeck3PlayState                                  = "/Engine/Deck3/PlayState"
	EngineDeck3PlayStatePath                              = "/Engine/Deck3/PlayStatePath"
	EngineDeck3Speed                                      = "/Engine/Deck3/Speed"
	EngineDeck3SpeedNeutral                               = "/Engine/Deck3/SpeedNeutral"
	EngineDeck3SpeedOffsetDown                            = "/Engine/Deck3/SpeedOffsetDown"
	EngineDeck3SpeedOffsetUp                              = "/Engine/Deck3/SpeedOffsetUp"
	EngineDeck3SpeedRange                                 = "/Engine/Deck3/SpeedRange"
	EngineDeck3SpeedState                                 = "/Engine/Deck3/SpeedState"
	EngineDeck3SyncMode                                   = "/Engine/Deck3/SyncMode"
	EngineDeck3TrackArtistName                            = "/Engine/Deck3/Track/ArtistName"
	EngineDeck3TrackBleep                                 = "/Engine/Deck3/Track/Bleep"
	EngineDeck3TrackCuePosition                           = "/Engine/Deck3/Track/CuePosition"
	EngineDeck3TrackCurrentBPM                            = "/Engine/Deck3/Track/CurrentBPM"
	EngineDeck3TrackCurrentKeyIndex                       = "/Engine/Deck3/Track/CurrentKeyIndex"
	EngineDeck3TrackCurrentLoopInPosition                 = "/Engine/Deck3/Track/CurrentLoopInPosition"
	EngineDeck3TrackCurrentLoopOutPosition                = "/Engine/Deck3/Track/CurrentLoopOutPosition"
	EngineDeck3TrackCurrentLoopSizeInBeats                = "/Engine/Deck3/Track/CurrentLoopSizeInBeats"
	EngineDeck3TrackKeyLock                               = "/Engine/Deck3/Track/KeyLock"
	EngineDeck3TrackLoopEnableState                       = "/Engine/Deck3/Track/LoopEnableState"
	EngineDeck3TrackLoopQuickLoop1                        = "/Engine/Deck3/Track/Loop/QuickLoop1"
	EngineDeck3TrackLoopQuickLoop2                        = "/Engine/Deck3/Track/Loop/QuickLoop2"
	EngineDeck3TrackLoopQuickLoop3                        = "/Engine/Deck3/Track/Loop/QuickLoop3"
	EngineDeck3TrackLoopQuickLoop4                        = "/Engine/Deck3/Track/Loop/QuickLoop4"
	EngineDeck3TrackLoopQuickLoop5                        = "/Engine/Deck3/Track/Loop/QuickLoop5"
	EngineDeck3TrackLoopQuickLoop6                        = "/Engine/Deck3/Track/Loop/QuickLoop6"
	EngineDeck3TrackLoopQuickLoop7                        = "/Engine/Deck3/Track/Loop/QuickLoop7"
	EngineDeck3TrackLoopQuickLoop8                        = "/Engine/Deck3/Track/Loop/QuickLoop8"
	EngineDeck3TrackPlayPauseLEDState                     = "/Engine/Deck3/Track/PlayPauseLEDState"
	EngineDeck3TrackSampleRate                            = "/Engine/Deck3/Track/SampleRate"
	EngineDeck3TrackSongAnalyzed                          = "/Engine/Deck3/Track/SongAnalyzed"
	EngineDeck3TrackSongLoaded                            = "/Engine/Deck3/Track/SongLoaded"
	EngineDeck3TrackSongName                              = "/Engine/Deck3/Track/SongName"
	EngineDeck3TrackSoundSwitchGUID                       = "/Engine/Deck3/Track/SoundSwitchGuid"
	EngineDeck3TrackTrackBytes                            = "/Engine/Deck3/Track/TrackBytes"
	EngineDeck3TrackTrackData                             = "/Engine/Deck3/Track/TrackData"
	EngineDeck3TrackTrackLength                           = "/Engine/Deck3/Track/TrackLength"
	EngineDeck3TrackTrackName                             = "/Engine/Deck3/Track/TrackName"
	EngineDeck3TrackTrackNetworkPath                      = "/Engine/Deck3/Track/TrackNetworkPath"
	EngineDeck3TrackTrackURI                              = "/Engine/Deck3/Track/TrackUri"
	EngineDeck3TrackTrackWasPlayed                        = "/Engine/Deck3/Track/TrackWasPlayed"
	EngineDeck4CurrentBPM                                 = "/Engine/Deck4/CurrentBPM"
	EngineDeck4ExternalMixerVolume                        = "/Engine/Deck4/ExternalMixerVolume"
	EngineDeck4ExternalScratchWheelTouch                  = "/Engine/Deck4/ExternalScratchWheelTouch"
	EngineDeck4PadsView                                   = "/Engine/Deck4/Pads/View"
	EngineDeck4Play                                       = "/Engine/Deck4/Play"
	EngineDeck4PlayState                                  = "/Engine/Deck4/PlayState"
	EngineDeck4PlayStatePath                              = "/Engine/Deck4/PlayStatePath"
	EngineDeck4Speed                                      = "/Engine/Deck4/Speed"
	EngineDeck4SpeedNeutral                               = "/Engine/Deck4/SpeedNeutral"
	EngineDeck4SpeedOffsetDown                            = "/Engine/Deck4/SpeedOffsetDown"
	EngineDeck4SpeedOffsetUp                              = "/Engine/Deck4/SpeedOffsetUp"
	EngineDeck4SpeedRange                                 = "/Engine/Deck4/SpeedRange"
	EngineDeck4SpeedState                                 = "/Engine/Deck4/SpeedState"
	EngineDeck4SyncMode                                   = "/Engine/Deck4/SyncMode"
	EngineDeck4TrackArtistName                            = "/Engine/Deck4/Track/ArtistName"
	EngineDeck4TrackBleep                                 = "/Engine/Deck4/Track/Bleep"
	EngineDeck4TrackCuePosition                           = "/Engine/Deck4/Track/CuePosition"
	EngineDeck4TrackCurrentBPM                            = "/Engine/Deck4/Track/CurrentBPM"
	EngineDeck4TrackCurrentKeyIndex                       = "/Engine/Deck4/Track/CurrentKeyIndex"
	EngineDeck4TrackCurrentLoopInPosition                 = "/Engine/Deck4/Track/CurrentLoopInPosition"
	EngineDeck4TrackCurrentLoopOutPosition                = "/Engine/Deck4/Track/CurrentLoopOutPosition"
	EngineDeck4TrackCurrentLoopSizeInBeats                = "/Engine/Deck4/Track/CurrentLoopSizeInBeats"
	EngineDeck4TrackKeyLock                               = "/Engine/Deck4/Track/KeyLock"
	EngineDeck4TrackLoopEnableState                       = "/Engine/Deck4/Track/LoopEnableState"
	EngineDeck4TrackLoopQuickLoop1                        = "/Engine/Deck4/Track/Loop/QuickLoop1"
	EngineDeck4TrackLoopQuickLoop2                        = "/Engine/Deck4/Track/Loop/QuickLoop2"
	EngineDeck4TrackLoopQuickLoop3                        = "/Engine/Deck4/Track/Loop/QuickLoop3"
	EngineDeck4TrackLoopQuickLoop4                        = "/Engine/Deck4/Track/Loop/QuickLoop4"
	EngineDeck4TrackLoopQuickLoop5                        = "/Engine/Deck4/Track/Loop/QuickLoop5"
	EngineDeck4TrackLoopQuickLoop6                        = "/Engine/Deck4/Track/Loop/QuickLoop6"
	EngineDeck4TrackLoopQuickLoop7                        = "/Engine/Deck4/Track/Loop/QuickLoop7"
	EngineDeck4TrackLoopQuickLoop8                        = "/Engine/Deck4/Track/Loop/QuickLoop8"
	EngineDeck4TrackPlayPauseLEDState                     = "/Engine/Deck4/Track/PlayPauseLEDState"
	EngineDeck4TrackSampleRate                            = "/Engine/Deck4/Track/SampleRate"
	EngineDeck4TrackSongAnalyzed                          = "/Engine/Deck4/Track/SongAnalyzed"
	EngineDeck4TrackSongLoaded                            = "/Engine/Deck4/Track/SongLoaded"
	EngineDeck4TrackSongName                              = "/Engine/Deck4/Track/SongName"
	EngineDeck4TrackSoundSwitchGUID                       = "/Engine/Deck4/Track/SoundSwitchGuid"
	EngineDeck4TrackTrackBytes                            = "/Engine/Deck4/Track/TrackBytes"
	EngineDeck4TrackTrackData                             = "/Engine/Deck4/Track/TrackData"
	EngineDeck4TrackTrackLength                           = "/Engine/Deck4/Track/TrackLength"
	EngineDeck4TrackTrackName                             = "/Engine/Deck4/Track/TrackName"
	EngineDeck4TrackTrackNetworkPath                      = "/Engine/Deck4/Track/TrackNetworkPath"
	EngineDeck4TrackTrackURI                              = "/Engine/Deck4/Track/TrackUri"
	EngineDeck4TrackTrackWasPlayed                        = "/Engine/Deck4/Track/TrackWasPlayed"
	EngineDeckCount                                       = "/Engine/DeckCount"
	GUIDecksDeckActiveDeck                                = "/GUI/Decks/Deck/ActiveDeck"
	GUIViewLayerLayerB                                    = "/GUI/ViewLayer/LayerB"
	MixerCH1faderPosition                                 = "/Mixer/CH1faderPosition"
	MixerCH2faderPosition                                 = "/Mixer/CH2faderPosition"
	MixerCH3faderPosition                                 = "/Mixer/CH3faderPosition"
	MixerCH4faderPosition                                 = "/Mixer/CH4faderPosition"
	MixerCrossfaderPosition                               = "/Mixer/CrossfaderPosition"
)

Variables

View Source
var ErrInvalidDiscovererActionReceived = errors.New("invalid discoverer action received")

ErrInvalidDiscovererActionReceived is returned by Listener.Discover if a valid StagelinQ discovery message has been received by another device but it is reporting neither that it is leaving nor joining the network. This would indicate another application trying to speak via the StagelinQ protocol but it is sending invalid data. You can check the returned device object for the source address of the bad message.

View Source
var ErrInvalidMessageReceived = errors.New("invalid message received")

ErrInvalidMessageReceived is returned by Listener.Discover if a message has been received but it is not a StagelinQ message. This would indicate another application using UDP port 51337 on the network for broadcasts.

View Source
var ErrTooShortDiscoveryMessageReceived = errors.New("too short discovery message received")

ErrTooShortDiscoveryMessageReceived is returned by Listener.Discover if a too short message has been received on the StagelinQ discovery port. This would indicate another application using UDP port 51337 on the network for broadcasts.

Functions

This section is empty.

Types

type Device

type Device struct {
	IP              net.IP
	Name            string
	SoftwareName    string
	SoftwareVersion string
	// contains filtered or unexported fields
}

Device presents information about a discovered StagelinQ device on the network.

func (*Device) Connect

func (device *Device) Connect(token Token, offeredServices []*Service) (conn *MainConnection, err error)

Connect starts a new main connection with the device. You need to pass the StagelinQ token announced for your own device. You also need to pass services you want to provide; if you don't have any, pass an empty array.

func (*Device) Dial

func (device *Device) Dial(port uint16) (conn net.Conn, err error)

Dial starts a TCP connection with the device on the given port.

func (*Device) IsEqual

func (device *Device) IsEqual(anotherDevice *Device) bool

IsEqual checks if this device has the same address and values as the other given device.

type DeviceState

type DeviceState byte

DeviceState represents a device's state in the network. Possible values are DevicePresent and DeviceLeaving.

const (
	// DevicePresent indicates that a device is actively announcing itself to the network.
	DevicePresent DeviceState = iota

	// DeviceLeaving indicates that a device has announced that it is leaving the network. It will no longer send announcements after this.
	DeviceLeaving
)

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener listens on UDP port 51337 for StagelinQ devices and announces itself in the same way.

func Listen

func Listen() (listener *Listener, err error)

Listen sets up a StagelinQ listener.

func ListenWithConfiguration

func ListenWithConfiguration(listenerConfig *ListenerConfiguration) (listener *Listener, err error)

ListenWithConfiguration sets up a StagelinQ listener with the given configuration.

func (*Listener) Announce

func (l *Listener) Announce() error

Announce announces this StagelinQ listener to the network. This function should be called before actually listening in for devices to allow them to pick up our token for communication immediately.

func (*Listener) AnnounceEvery

func (l *Listener) AnnounceEvery(interval time.Duration)

AnnounceEvery will start a goroutine which calls the Announce function at given interval. It will automatically terminate once this listener is shut down. A recommended value for the interval is 1 second.

func (*Listener) Close

func (l *Listener) Close() error

Close shuts down the listener.

func (*Listener) Discover

func (l *Listener) Discover(timeout time.Duration) (device *Device, deviceState DeviceState, err error)

Discover listens for any StagelinQ devices announcing to the network. If no device is found within the given timeout or any non-StagelinQ message has been received, nil is returned for the device. If a device has been discovered before, the returned device object is not going to be the same as when the device was previously discovered. Use device.IsEqual for such comparison.

func (*Listener) Token

func (l *Listener) Token() Token

Token returns our token that is being announced to the StagelinQ network. Use this token for further communication with services on other devices.

func (*Listener) Unannounce

func (l *Listener) Unannounce() error

Unannounce announces this StagelinQ listener leaving from the network. Call this before closing the listener!

type ListenerConfiguration

type ListenerConfiguration struct {
	// Context can be set to allow cancellation of network operations from somewhere else in the code.
	Context context.Context

	// DiscoveryTimeout is the duration for which Listener.Discover will wait for StagelinQ devices to announce themselves.
	// If this is not set, no timeout will occur.
	DiscoveryTimeout time.Duration

	// Name is the name under which we announce ourselves to the network.
	// For example, Resolute uses the computer user name here, and Denon devices use their identifying abbreviation (the Prime 4 uses "prime4").
	Name string

	// SoftwareName is your application's name. It is used for StagelinQ announcements to the network.
	SoftwareName string

	// SoftwareVersion is your application's version. It is used for StagelinQ announcements to the network.
	SoftwareVersion string

	// Token is used as part of announcements and main data communication. It is currently recommended to leave this empty.
	Token Token
}

ListenerConfiguration contains configurable values for setting up a StagelinQ listener.

type MainConnection

type MainConnection struct {
	// contains filtered or unexported fields
}

MainConnection represents a connection to the main TCP port of a StagelinQ device.

func (*MainConnection) Close

func (conn *MainConnection) Close() (err error)

Close terminates the connection.

func (*MainConnection) RequestServices

func (conn *MainConnection) RequestServices() (retval []*Service, err error)

RequestServices asks the device to return other TCP ports it is listening on and which services it provides on them.

type Service

type Service struct {
	Name string
	Port uint16
}

Service contains information about a data service a device provides.

type State

type State struct {
	Name  string
	Value map[string]interface{}
}

State represents a received state value.

type StateMapConnection

type StateMapConnection struct {
	// contains filtered or unexported fields
}

StateMapConnection provides functionality to communicate with the StateMap data source.

func NewStateMapConnection

func NewStateMapConnection(conn net.Conn, token Token) (smc *StateMapConnection, err error)

NewStateMapConnection wraps an existing network connection and returns a StateMapConnection, providing the functionality to subscribe to and receive changes of state values. You need to pass the token that you have announced for your own device on the network.

func (*StateMapConnection) ErrorC

func (smc *StateMapConnection) ErrorC() <-chan error

ErrorC returns the channel via which connectionrerors will be returned for this connection.

func (*StateMapConnection) StateC

func (smc *StateMapConnection) StateC() <-chan *State

StateC returns the channel via which state changes will be returned for this connection.

func (*StateMapConnection) Subscribe

func (smc *StateMapConnection) Subscribe(event string) error

Subscribe tells the StagelinQ device to let us know about changes for the given state value.

type Token

type Token [16]byte

Token contains the identifying Token for a device in the StagelinQ network.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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