plm

package
v0.0.0-...-fe5e139 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LinkCmdFindFirst    recordRequestCommand = 0x00
	LinkCmdFindNext     recordRequestCommand = 0x01
	LinkCmdModFirst     recordRequestCommand = 0x20
	LinkCmdModFirstCtrl recordRequestCommand = 0x40
	LinkCmdModFirstResp recordRequestCommand = 0x41
	LinkCmdDeleteFirst  recordRequestCommand = 0x80
)

Variables

View Source
var (
	ErrReadTimeout        = errors.New("Timeout reading from plm")
	ErrNoSync             = errors.New("No sync byte received")
	ErrNotImplemented     = errors.New("IM command not implemented")
	ErrAckTimeout         = errors.New("Timeout waiting for Ack from the PLM")
	ErrRetryCountExceeded = errors.New("Retry count exceeded sending command")
	ErrNoAck              = errors.New("Received non-ack packet after transmit")
	ErrWrongAck           = errors.New("Command in ACK does not match TX packet")
	ErrWrongPayload       = errors.New("Payload in ACK does not match TX packet")
	ErrNak                = errors.New("PLM responded with a NAK.  Resend command")
)
View Source
var (
	Log      = log.New(os.Stderr, "", log.LstdFlags)
	LogDebug = log.New(ioutil.Discard, "DEBUG ", log.LstdFlags)
)

Functions

func Snoop

func Snoop(rx, tx io.Reader) devices.MessageWriter

Types

type Command

type Command byte
const (
	CmdNak                   Command = 0x15 // NAK
	CmdStdMsgReceived        Command = 0x50 // Std Msg Received
	CmdExtMsgReceived        Command = 0x51 // Ext Msg Received
	CmdX10MsgReceived        Command = 0x52 // X10 Msg Received
	CmdAllLinkComplete       Command = 0x53 // All Link Complete
	CmdButtonEventReport     Command = 0x54 // Button Event Report
	CmdUserResetDetected     Command = 0x55 // User Reset Detected
	CmdAllLinkCleanupFailure Command = 0x56 // Link Cleanup Report
	CmdAllLinkRecordResp     Command = 0x57 // Link Record Resp
	CmdAllLinkCleanupStatus  Command = 0x58 // Link Cleanup Status
	CmdGetInfo               Command = 0x60 // Get Info
	CmdSendAllLink           Command = 0x61 // Send All Link
	CmdSendInsteonMsg        Command = 0x62 // Send INSTEON Msg
	CmdSendX10               Command = 0x63 // Send X10 Msg
	CmdStartAllLink          Command = 0x64 // Start All Link
	CmdCancelAllLink         Command = 0x65 // Cancel All Link
	CmdSetHostCategory       Command = 0x66 // Set Host Category
	CmdReset                 Command = 0x67 // Reset
	CmdSetAckMsg             Command = 0x68 // Set ACK Msg
	CmdGetFirstAllLink       Command = 0x69 // Get First All Link
	CmdGetNextAllLink        Command = 0x6a // Get Next All Link
	CmdSetConfig             Command = 0x6b // Set Config
	CmdGetAllLinkForSender   Command = 0x6c // Get Sender All Link
	CmdLedOn                 Command = 0x6d // LED On
	CmdLedOff                Command = 0x6e // LED Off
	CmdManageAllLinkRecord   Command = 0x6f // Manage All Link Record
	CmdSetNakMsgByte         Command = 0x70 // Set NAK Msg Byte
	CmdSetNameMsgTwoBytes    Command = 0x71 // Set NAK Msg Two Bytes
	CmdRfSleep               Command = 0x72 // RF Sleep
	CmdGetConfig             Command = 0x73 // Get Config
)

func (Command) String

func (i Command) String() string

type Config

type Config byte

func (*Config) AutomaticLED

func (config *Config) AutomaticLED() bool

func (*Config) AutomaticLinking

func (config *Config) AutomaticLinking() bool

func (*Config) ClearAutomaticLED

func (config *Config) ClearAutomaticLED()

func (*Config) ClearAutomaticLinking

func (config *Config) ClearAutomaticLinking()

func (*Config) ClearDeadmanMode

func (config *Config) ClearDeadmanMode()

func (*Config) ClearMonitorMode

func (config *Config) ClearMonitorMode()

func (*Config) DeadmanMode

func (config *Config) DeadmanMode() bool

func (*Config) MarshalBinary

func (config *Config) MarshalBinary() ([]byte, error)

func (*Config) MonitorMode

func (config *Config) MonitorMode() bool

func (*Config) SetAutomaticLED

func (config *Config) SetAutomaticLED()

func (*Config) SetAutomaticLinking

func (config *Config) SetAutomaticLinking()

func (*Config) SetDeadmanMode

func (config *Config) SetDeadmanMode()

func (*Config) SetMonitorMode

func (config *Config) SetMonitorMode()

func (Config) String

func (config Config) String() string

func (*Config) UnmarshalBinary

func (config *Config) UnmarshalBinary(buf []byte) error

type Info

type Info struct {
	Address  insteon.Address
	DevCat   insteon.DevCat
	Firmware Version
}

func (*Info) MarshalBinary

func (info *Info) MarshalBinary() ([]byte, error)

func (*Info) String

func (info *Info) String() string

func (*Info) UnmarshalBinary

func (info *Info) UnmarshalBinary(data []byte) error

type Option

type Option func(p *PLM)

The Option mechanism is based on the method described at https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

func Timeout

func Timeout(timeout time.Duration) Option

func WriteDelay

func WriteDelay(d time.Duration) Option

WriteDelay can be passed as a parameter to New to change the delay used after writing a command before reading the response.

type PLM

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

func New

func New(rw io.ReadWriter, options ...Option) (plm *PLM)

New creates a new PLM instance.

func (*PLM) Address

func (plm *PLM) Address() insteon.Address

func (*PLM) Config

func (plm *PLM) Config() (config Config, err error)

func (*PLM) EnterLinkingMode

func (ldb *PLM) EnterLinkingMode(group insteon.Group) error

func (*PLM) EnterUnlinkingMode

func (ldb *PLM) EnterUnlinkingMode(group insteon.Group) error

func (*PLM) ExitLinkingMode

func (ldb *PLM) ExitLinkingMode() error

func (*PLM) Info

func (plm *PLM) Info() (info *Info, err error)

func (*PLM) IterateDevices

func (ldb *PLM) IterateDevices(cb func(insteon.Address)) error
func (ldb *PLM) Links() ([]insteon.LinkRecord, error)

func (*PLM) RFSleep

func (plm *PLM) RFSleep() error

func (*PLM) Read

func (plm *PLM) Read() (msg *insteon.Message, err error)

func (*PLM) ReadPacket

func (plm *PLM) ReadPacket() (pkt *Packet, err error)

func (*PLM) Reset

func (plm *PLM) Reset() error

Reset will factory reset and erase all data from the PLM. ⚠️ Use with care.

func (*PLM) SetConfig

func (plm *PLM) SetConfig(config Config) error

func (*PLM) SetDeviceCategory

func (plm *PLM) SetDeviceCategory(insteon.Category) error

func (*PLM) String

func (plm *PLM) String() string
func (ldb *PLM) UpdateLinks(...insteon.LinkRecord) error

func (*PLM) Write

func (plm *PLM) Write(msg *insteon.Message) (ack *insteon.Message, err error)

Write insteon message

func (ldb *PLM) WriteLinks(newLinks ...insteon.LinkRecord) (err error)

func (*PLM) WritePacket

func (plm *PLM) WritePacket(pkt *Packet) (ack *Packet, err error)

type Packet

type Packet struct {
	Command Command
	Payload []byte
	Ack     byte
}

func (*Packet) ACK

func (p *Packet) ACK() bool

func (*Packet) Format

func (p *Packet) Format(f fmt.State, c rune)

func (*Packet) MarshalBinary

func (p *Packet) MarshalBinary() (buf []byte, err error)

func (*Packet) NAK

func (p *Packet) NAK() bool

func (*Packet) String

func (p *Packet) String() string

func (*Packet) UnmarshalBinary

func (p *Packet) UnmarshalBinary(buf []byte) (err error)

type Version

type Version byte

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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