integra

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

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

integra

Go library and web server to communicate with Integra (or Onkyo) A/V receivers using the Integra Serial Control Protocol over Ethernet (eISCP)

Library

Package integra provides a client to communicate with an Integra (or Onkyo) A/V receiver device using the Integra Serial Control Protocol over Ethernet (eISCP).

Example usage:

  device, _ := integra.Connect(":60128")
  client := device.NewClient()
  message := integra.Message{"PWR", "01"}
  client.Send(&message)
  message, _ = client.Receive()
  fmt.Println("Got message from Integra A/V receiver:", message)
  client.Close()

See server/server.go for a working example.

Server

Server provides a basic mobile-friendly web app to control and monitor an Integra device such as an A/V receiver. The web app uses WebSockets to display real-time changes to the device, including changes made elsewhere like the volume knob on the receiver or buttons on the remote.

Web App

Server also offers a simple HTTP interface at /integra for sending ISCP (Integra Serial Control Protocol) messages and reading the current state of the device.

The following examples assume this server is running on localhost port 8080.

Example commands to send ISCP power on (PWR01) and volume up (MVLUP) messages to the device by issuing POST requests to /integra:

  $ curl :8080/integra -d PWR01
  ok
  $ curl :8080/integra -d MVLUP
  ok

Up to 10 messages can be sent at once by separating them with newlines in the request body. (Note that the $'string' form causes shells like bash to replace occurrences of \n with newlines.) Example:

  $ curl :8080/integra -d $'PWR01\nMVLUP\nSLI03'
  ok

Example command to query the Integra device state by issuing a GET request to /integra (returns JSON):

  $ curl :8080/integra
  {"MVL":"42","PWR":"01"}

Note that the device state reported by GET /integra is not necessarily complete; it is made up of the messages received from the Integra device since the server was started. If desired values are missing from the reported device state, it can be useful to send a series of QSTN messages to populate the state:

  $ curl :8080/integra
  {}
  $ curl :8080/integra -d $'PWRQSTN\nMVLQSTN\nSLIQSTN'
  ok
  $ curl :8080/integra
  {"MVL":"42","PWR":"01","SLI":"03"}

Documentation

Overview

Package integra provides a client to communicate with an Integra (or Onkyo) A/V receiver device using the Integra Serial Control Protocol over Ethernet (eISCP).

Example usage:

device, _ := integra.Connect(":60128")
client := device.NewClient()
message := integra.Message{"PWR", "01"}
client.Send(&message)
message, _ = client.Receive()
fmt.Println("Got message from Integra A/V receiver:", message)
client.Close()

See server/server.go for a working example.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

A Client is an Integra device network client.

func (*Client) Close

func (c *Client) Close()

Close removes client from device. Client can no longer receive messages.

func (*Client) Receive

func (c *Client) Receive() (*Message, error)

Receive blocks until a new message is received from the Integra device and returns the message.

func (*Client) Send

func (c *Client) Send(m *Message) error

Send sends the given message to the Integra device.

func (*Client) State

func (c *Client) State() map[string]string

State returns a map representing the known state of the Integra device. Keys are ISCP message commands that map to ISCP parameter values. Each pair reflects the most recently received value for the key. Example key:value pair: PWR:01.

To populate the state with a desired command:paremeter pair, send the corresponding QSTN message (e.g., PWRQSTN) prior to calling this method. Note that it may be necessary to sleep for ~50ms in between.

type Device

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

Device represents the Integra device, e.g. an A/V receiver.

func Connect

func Connect(address string) (*Device, error)

Connect establishes a connection to the Integra device and returns a new Device. Only one network peer (i.e., Device) may be used to communicate with the Integra device at a time.

func (*Device) NewClient

func (d *Device) NewClient() *Client

NewClient returns a new Integra device client, ready to send and receive messages.

func (*Device) NewSendOnlyClient

func (d *Device) NewSendOnlyClient() *Client

NewSendOnlyClient returns a new Integra device client, ready to send messages. Client cannot receive messages.

type Message

type Message struct {
	Command   string
	Parameter string
}

A Message is an ISCP message.

func NewMessage

func NewMessage(m []byte) (*Message, error)

NewMessage returns a new Message from the given byte slice making up the message's command and parameter.

func (*Message) String

func (m *Message) String() string

String returns the message as a string.

Directories

Path Synopsis
Mock Integra device server that echoes received messages back to client for testing.
Mock Integra device server that echoes received messages back to client for testing.
Server provides a basic mobile-friendly web app to control and monitor an Integra device such as an A/V receiver.
Server provides a basic mobile-friendly web app to control and monitor an Integra device such as an A/V receiver.

Jump to

Keyboard shortcuts

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