london

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: Apache-2.0 Imports: 11 Imported by: 1

README

london-driver

Documentation

Index

Constants

View Source
const (
	DI_SETSV                = 0x88
	DI_SETSVPERCENT         = 0x8d
	DI_SUBSCRIBESV          = 0x89
	DI_SUBSCRIBESVPERCENT   = 0x8e
	DI_UNSUBSCRIBESV        = 0x8a
	DI_UNSUBSCRIBESVPERCENT = 0x8f
)
View Source
const LEN_ADDR = 5
View Source
const LEN_NODE = 2

Variables

View Source
var ACK = byte(0x06)
View Source
var DECODE = map[string]int{
	"STX":    0x1b82,
	"ETX":    0x1b83,
	"ACK":    0x1b86,
	"NAK":    0x1b95,
	"escape": 0x1b9b,
}
View Source
var ENCODE = map[string]int{
	"STX":    0x02,
	"ETX":    0x03,
	"ACK":    0x06,
	"NAK":    0x15,
	"escape": 0x1b,
}
View Source
var ETX = byte(0x03)
View Source
var RATE = []byte{0x00, 0x00, 0x00, 0x32} //represents 50 ms, the shortest interval
View Source
var STX = byte(0x02)
View Source
var VIRTUAL_DEVICE = byte(0x03)

VIRTUAL_DEVICE byte should be the same for all cases!

Functions

func GetChecksumByte

func GetChecksumByte(message []byte) byte

generates a checksum byte according to the exclusive or of all bytes in the message

func MakeSubstitutions

func MakeSubstitutions(command []byte, toCheck map[string]int) ([]byte, error)

func Unwrap

func Unwrap(message []byte) ([]byte, error)

removes STX and ETX bytes @pre: slice begins with STX and ends with ETX @post: slice does not contain STX nor ETX bytes

func Validate

func Validate(message []byte) ([]byte, error)

@pre: STX and ETX removed, subsitutions made for reserved bytes @post: checksum removed generates a checksum byte and compares it to the checksum supplied a checksum that does not match returns an error

func Wrap

func Wrap(message []byte) ([]byte, error)

prepends STX byte and appends ETX byte @pre: slice does not contain STX nor ETX @post: slice begins with STX and ends with ETX bytes

Types

type DSP

type DSP struct {
	Address string
	// contains filtered or unexported fields
}

func NewDSP

func NewDSP(addr string, opts ...Option) *DSP

func (*DSP) BuildCommand

func (d *DSP) BuildCommand(ctx context.Context, input, status string, data []byte, method Method) ([]byte, error)

BuildCommand .

func (*DSP) BuildRawCommand

func (d *DSP) BuildRawCommand(ctx context.Context, input, state string, data []byte, method Method) ([]byte, error)

BuildRawCommand .

func (*DSP) BuildRawMuteCommand

func (d *DSP) BuildRawMuteCommand(ctx context.Context, input, status string) ([]byte, error)

func (*DSP) BuildRawVolumeCommand

func (d *DSP) BuildRawVolumeCommand(ctx context.Context, input string, volume int) ([]byte, error)

func (*DSP) GetCommandAddress

func (d *DSP) GetCommandAddress(ctx context.Context, commandByte byte) ([]byte, error)

builds command, node, virtual device, and object

func (*DSP) GetInfo

func (d *DSP) GetInfo(ctx context.Context) (interface{}, error)

func (*DSP) GetMutedByBlock

func (d *DSP) GetMutedByBlock(ctx context.Context, block string) (bool, error)

GetMute .

func (*DSP) GetStatus

func (d *DSP) GetStatus(ctx context.Context, subscribe, unsubscribe []byte, pconn connpool.Conn) ([]byte, error)

GetStatus .

func (*DSP) GetVolumeByBlock

func (d *DSP) GetVolumeByBlock(ctx context.Context, block string) (int, error)

GetVolume .

func (*DSP) ParseMuteStatus

func (d *DSP) ParseMuteStatus(ctx context.Context, message []byte) (bool, error)

@pre: checksum byte removed

func (*DSP) ParseVolumeStatus

func (d *DSP) ParseVolumeStatus(ctx context.Context, message []byte) (int, error)

@pre: checksum byte removed

func (*DSP) SetMutedByBlock

func (d *DSP) SetMutedByBlock(ctx context.Context, block string, muted bool) error

func (*DSP) SetVolumeByBlock

func (d *DSP) SetVolumeByBlock(ctx context.Context, block string, volume int) error

SetVolume gets an volume level (int) and sets it on device

type Method

type Method int
const (
	Set Method = 1 + iota
	SetPercent
	Subscribe
	Unsubscribe
	SubscribePercent
	UnsubscribePercent
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithDelay

func WithDelay(t time.Duration) Option

func WithTTL

func WithTTL(t time.Duration) Option

type RawDICommand

type RawDICommand struct {
	Address string `json:"address"`
	Port    string `json:"port"`
	Command string `json:"command"`
}

type RawDIResponse

type RawDIResponse struct {
	Response []string `json:"response"`
}

type State

type State string
const (
	GAIN State = "gain"
	MUTE State = "mute"
)

Jump to

Keyboard shortcuts

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