hdhomerun

package module
v0.0.0-...-3a67857 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: Apache-2.0 Imports: 16 Imported by: 1

README

hdhomerun

Build Status GoDoc Coverage Status

======

Overview

Use this package to connect to and interact with HD HomeRun devices.

Installation

go get github.com/mh-orange/hdhomerun

Examples

Discover devices:

package main

import(
  "fmt"
  "github.com/mh-orange/hdhomerun"
)

func main() {
  for discoverResult := range hdhomerun.Discover(nil, time.Millisecond*200) {
    if discoverResult.Err != nil {
      fmt.Printf("Error during discovery: %v\n", discoverResult.Err)
    } else {
      fmt.Printf("hdhomerun device %s found at %s\n", discoverResult.Device.ID(), discoverResult.Device.Addr())
    }
  }
}
Tune to a channel:
package main

import(
  "github.com/mh-orange/hdhomerun"
  "net"
)

func main() {
  device, _ := hdhomerun.ConnectTCP(&net.TCPAddr{net.IP{192,168,1,100}, 65001, ""})
  tuner := device.Tuner(0)
  tuner.Tune("auto", 177000000)
}
Scan available channels:
package main

import(
  "fmt"
  "github.com/mh-orange/hdhomerun"
  "net"
)

func main() {
  device, _ := hdhomerun.ConnectTCP(&net.TCPAddr{net.IP{192,168,1,100}, 65001, ""})
  tuner := device.Tuner(0)
  for result := range tuner.Scan() {
    if result.Err != nil {
      fmt.Printf("Error scanning for channels: %v\n", err)
      continue
    }
    fmt.Printf("Found channel %s\n", result.Channel.Name)
  }
}

Documentation

Index

Constants

View Source
const (
	ProgramTypeNormal = iota
	ProgramTypeNoData
	ProgramTypeControl
	ProgramTypeEncrypted
)

Variables

View Source
var (
	ErrTimeout  = fmt.Errorf("Timeout")
	ErrNoSignal = fmt.Errorf("Signal Strength Too Low")
)
View Source
var (
	DeviceTypeWildcard []byte = []byte{0xFF, 0xFF, 0xFF, 0xFF}
	DeviceTypeTuner    []byte = []byte{0x00, 0x00, 0x00, 0x01}
	DeviceTypeStorage  []byte = []byte{0x00, 0x00, 0x00, 0x05}
	DeviceIdWildcard   []byte = []byte{0xFF, 0xFF, 0xFF, 0xFF}
)
View Source
var (
	ErrCrc error = errors.New("Invalid CRC")
)
View Source
var Logger = log.New(os.Stderr, "HDHomerun", log.LstdFlags)

Functions

func Channels

func Channels(channelMap string) chan Channel

func Discover

func Discover(ip net.IP, timeout time.Duration) chan DiscoverResult

Types

type Channel

type Channel struct {
	Number     int
	Frequency  int
	Modulation string
	Name       string
	TSID       int
	ONID       int
	Programs   []Program
}

func (*Channel) ONIDDetected

func (c *Channel) ONIDDetected() bool

func (*Channel) TSIDDetected

func (c *Channel) TSIDDetected() bool

func (*Channel) UnmarshalText

func (c *Channel) UnmarshalText(text []byte) (err error)

type Decoder

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

func NewDecoder

func NewDecoder(reader io.Reader) *Decoder

func (*Decoder) Next

func (d *Decoder) Next() (*Packet, error)

type Device

type Device interface {
	Get(string) (TagValue, error)
	Set(string, string) (TagValue, error)
	Tuner(int) *Tuner
}

type DeviceID

type DeviceID []byte

func (DeviceID) String

func (d DeviceID) String() string

type DiscoverResult

type DiscoverResult struct {
	Device Device
	ID     DeviceID
	Addr   net.Addr
	Err    error
}

type Encoder

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

func NewEncoder

func NewEncoder(writer io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(p *Packet) error

func (*Encoder) Write

func (e *Encoder) Write(p []byte) (int, error)

type ErrCommunicationError

type ErrCommunicationError struct {
	ConnectionError error
}

type ErrParseError

type ErrParseError string

func (ErrParseError) Error

func (e ErrParseError) Error() string

type ErrRemoteError

type ErrRemoteError string

func (ErrRemoteError) Error

func (e ErrRemoteError) Error() string

type ErrWrongPacketType

type ErrWrongPacketType string

func (ErrWrongPacketType) Error

func (e ErrWrongPacketType) Error() string

type GenericDevice

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

func NewGenericDevice

func NewGenericDevice(rw io.ReadWriter) *GenericDevice

func (*GenericDevice) Get

func (d *GenericDevice) Get(name string) (TagValue, error)

func (*GenericDevice) Set

func (d *GenericDevice) Set(name, value string) (TagValue, error)

func (*GenericDevice) Tuner

func (d *GenericDevice) Tuner(n int) *Tuner

type Packet

type Packet struct {
	Type PacketType
	Tags TagsMap
}

func NewPacket

func NewPacket(t PacketType, tags map[TagType]TagValue) *Packet

func (*Packet) Dump

func (p *Packet) Dump() string

type PacketType

type PacketType uint16
const (
	TypeDiscoverReq PacketType = 0x0002
	TypeDiscoverRpy PacketType = 0x0003
	TypeGetSetReq   PacketType = 0x0004
	TypeGetSetRpy   PacketType = 0x0005
	TypeUpgradeReq  PacketType = 0x0006
	TypeUpgradeRpy  PacketType = 0x0007
)

func (PacketType) String

func (pt PacketType) String() string

type Program

type Program struct {
	Name         string
	Type         ProgramType
	Number       int
	VirtualMajor int
	VirtualMinor int
}

func (*Program) MarshalText

func (p *Program) MarshalText() ([]byte, error)

func (*Program) UnmarshalText

func (p *Program) UnmarshalText(value TagValue) (err error)

type ProgramList

type ProgramList []Program

type ProgramType

type ProgramType int

func (ProgramType) String

func (pt ProgramType) String() string

type TCPDevice

type TCPDevice struct {
	*net.TCPConn
	*GenericDevice
	// contains filtered or unexported fields
}

func ConnectTCP

func ConnectTCP(addr *net.TCPAddr) (d *TCPDevice, err error)

func NewTCPDevice

func NewTCPDevice(addr *net.TCPAddr) *TCPDevice

type Tag

type Tag struct {
	Type  TagType
	Value TagValue
}

func (Tag) Dump

func (t Tag) Dump() string

func (Tag) String

func (t Tag) String() string

type TagType

type TagType uint8
const (
	TagDeviceType    TagType = 0x01
	TagDeviceId      TagType = 0x02
	TagGetSetName    TagType = 0x03
	TagGetSetValue   TagType = 0x04
	TagGetSetLockKey TagType = 0x15
	TagErrorMsg      TagType = 0x05
	TagTunerCount    TagType = 0x10
	TagDeviceAuthBin TagType = 0x29
	TagBaseUrl       TagType = 0x2A
	TagDeviceAuthStr TagType = 0x2B
)

func (TagType) String

func (tt TagType) String() string

type TagValue

type TagValue []byte

func (TagValue) String

func (tv TagValue) String() string

type TagsMap

type TagsMap map[TagType]Tag

func (TagsMap) Iterate

func (tm TagsMap) Iterate(callback func(Tag))

type Tuner

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

func (*Tuner) GetTuner

func (t *Tuner) GetTuner(name string) (TagValue, error)

func (*Tuner) Scan

func (t *Tuner) Scan() chan Channel

func (*Tuner) SetTuner

func (t *Tuner) SetTuner(name, value string) (TagValue, error)

func (*Tuner) Status

func (t *Tuner) Status() (*TunerStatus, error)

func (*Tuner) Stream

func (t *Tuner) Stream(frequency, program int, localAddr *net.UDPAddr) error

func (*Tuner) StreamInfo

func (t *Tuner) StreamInfo() (TagValue, error)

func (*Tuner) Tune

func (t *Tuner) Tune(modulation string, frequency int) error

func (*Tuner) WaitForLock

func (t *Tuner) WaitForLock() (err error)

type TunerStatus

type TunerStatus struct {
	Channel              string
	LockStr              string
	Lock                 bool
	SignalStrength       int
	SignalToNoiseQuality int
	SymbolErrorQuality   int
	BitsPerSecond        int
	PacketsPerSecond     int
}

func (*TunerStatus) Dump

func (ts *TunerStatus) Dump() string

func (*TunerStatus) MarshalText

func (ts *TunerStatus) MarshalText() ([]byte, error)

func (*TunerStatus) SignalPresent

func (ts *TunerStatus) SignalPresent() bool

func (*TunerStatus) UnmarshalText

func (ts *TunerStatus) UnmarshalText(text []byte) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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