goodspeaker

package module
v0.0.0-...-05f8a1c Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2022 License: MIT Imports: 7 Imported by: 2

README

goodspeaker

This package speaks the LG speaker wire protocol which is used by both LG Music Flow Player and LG Wi-Fi Speaker, perhaps others as well. The name comes from Go, LG (Life's Good) and well, speakers.

Both encrypted and unencrypted communication are supported, but encryption IV and key may need to be adjusted depending on what type of speaker we're communicating with.

See github.com/mafredri/musicflow for an actual implementation using this protocol.

Usage

go get -u github.com/mafredri/goodspeaker

For decoding captured packets, see cmd/pcap-decode.

Documentation

Overview

Package goodspeaker implements a reader and writer for communicating with LG speakers (usually over TCP port 9741).

By providing the AES encryption key and IV, encrypted messages can also be read and written. At least some speakers support plain-text communication, in those cases the encryption key is not mandatory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(ctx context.Context, addr string) (net.Conn, error)

Dial connects to the speaker at the provided address.

Building for js is supported.

Types

type Option

type Option func(*options)

Option configures the reader and writer.

func WithAES

func WithAES(key, iv []byte) (Option, error)

WithAES enables AES encrypted communication, requires a valid encryption key and IV.

type Reader

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

Reader reads LG speaker messages.

func NewReader

func NewReader(rd io.Reader, opts ...Option) *Reader

NewReader returns a new reader that reads LG speaker messages. The reader can read both plain text messages and decrypt encrypted messages if the encryption option is provided.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read reads the next message or blocks until one is available.

type Writer

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

Writer writes LG speaker messages.

func NewWriter

func NewWriter(wr io.Writer, opts ...Option) *Writer

NewWriter returns a new writer that writes LG speaker messages. The writer will only write encrypted messages if the encryption option is provided.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write a message either in plain text or encrypted format (see Writer options).

Directories

Path Synopsis
cmd
js
net

Jump to

Keyboard shortcuts

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