londondi

package
v0.0.0-...-6b1d7bb Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

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
View Source
const PORT = "1023"
View Source
const TIMEOUT = 5

TIMEOUT .

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 BuildCommand

func BuildCommand(address, input, status string, data []byte, method Method) ([]byte, error)

BuildCommand .

func BuildRawCommand

func BuildRawCommand(address, input, state string, data []byte, method Method) ([]byte, error)

BuildRawCommand .

func BuildRawMuteCommand

func BuildRawMuteCommand(input, address, status string) ([]byte, error)

func BuildRawVolumeCommand

func BuildRawVolumeCommand(input string, address string, volume string) ([]byte, error)

func GetChecksumByte

func GetChecksumByte(message []byte) byte

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

func GetCommandAddress

func GetCommandAddress(commandByte byte, address string) ([]byte, error)

builds command, node, virtual device, and object

func GetMute

func GetMute(address, input string) (status.Mute, error)

GetMute .

func GetStatus

func GetStatus(subscribe, unsubscribe []byte, address string, pconn pooled.Conn) ([]byte, error)

GetStatus .

func GetVolume

func GetVolume(address, input string) (status.Volume, error)

GetVolume .

func MakeSubstitutions

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

func Mute

func Mute(input string, address string) error

Mute .

func ParseMuteStatus

func ParseMuteStatus(message []byte) (status.Mute, error)

@pre: checksum byte removed

func ParseVolumeStatus

func ParseVolumeStatus(message []byte) (status.Volume, error)

@pre: checksum byte removed

func SetVolume

func SetVolume(input string, address string, volume string) error

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

func UnMute

func UnMute(input string, address string) error

UnMute handler

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 Method

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

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 ReadWrite

type ReadWrite int

ReadWrite .

const (
	Read ReadWrite = 1 + iota
	Write
)

ReadWrite .

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