Documentation ¶
Index ¶
- Constants
- Variables
- func PropagationDelay(ttl uint8, l int) (pd time.Duration)
- type Address
- func (a *Address) Bytes() []byte
- func (a *Address) Get() interface{}
- func (a Address) MarshalJSON() ([]byte, error)
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) Put(buf []byte)
- func (a *Address) Set(str string) error
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(data []byte) (err error)
- func (a *Address) UnmarshalText(text []byte) error
- type Category
- type DevCat
- type Domain
- type EngineVersion
- type FirmwareVersion
- type Flags
- func (f Flags) Ack() bool
- func (f Flags) Extended() bool
- func (f Flags) MaxTTL() uint8
- func (f Flags) Nak() bool
- func (f *Flags) SetMaxTTL(ttl uint8)
- func (f *Flags) SetTTL(ttl uint8)
- func (f Flags) Standard() bool
- func (f Flags) String() string
- func (f Flags) TTL() uint8
- func (f Flags) Type() MessageType
- type Group
- type LinkID
- type LinkRecord
- func (l *LinkRecord) Equal(other *LinkRecord) bool
- func (l *LinkRecord) ID() LinkID
- func (l *LinkRecord) MarshalBinary() ([]byte, error)
- func (l *LinkRecord) MarshalText() ([]byte, error)
- func (l LinkRecord) String() string
- func (l *LinkRecord) UnmarshalBinary(buf []byte) (err error)
- func (l *LinkRecord) UnmarshalText(buf []byte) (err error)
- type Message
- type MessageType
- type ProductKey
- type RecordControlFlags
- func (rcf RecordControlFlags) Available() bool
- func (rcf *RecordControlFlags) ClearLastRecord()
- func (rcf RecordControlFlags) Controller() bool
- func (rcf RecordControlFlags) InUse() bool
- func (rcf RecordControlFlags) LastRecord() bool
- func (rcf RecordControlFlags) Responder() bool
- func (rcf *RecordControlFlags) SetAvailable()
- func (rcf *RecordControlFlags) SetController()
- func (rcf *RecordControlFlags) SetInUse()
- func (rcf *RecordControlFlags) SetLastRecord()
- func (rcf *RecordControlFlags) SetResponder()
- func (rcf RecordControlFlags) String() string
- func (rcf *RecordControlFlags) UnmarshalText(text []byte) (err error)
Constants ¶
const ( GeneralizeDomain Domain = 0x00 DimmerDomain = 0x01 SwitchDomain = 0x02 NetworkDomain = 0x03 IrrigationDomain = 0x04 ThermostatDomain = 0x05 PoolSpaDomain = 0x06 SensorActuatorDomain = 0x07 HomeEntertainmentDomain = 0x08 EnergyMgmtDomain = 0x09 ApplianceDomain = 0x0a PlumbingDomain = 0x0b CommunicationDomain = 0x0c ComputerDomain = 0x0d WindowCoveringsDomain = 0x0e AccessDomain = 0x0f SecurityDomain = 0x10 SurveillanceDomain = 0x11 AutomotiveDomain = 0x12 PetCareDomain = 0x13 ToysDomain = 0x14 TimekeepingDomain = 0x15 HolidayDomain = 0x16 UnassignedDomain = 0xff )
const ( AvailableController = RecordControlFlags(0x40) AvailableResponder = RecordControlFlags(0x00) )
RecordControlFlags indicating the different availability/type of link records
const ( // StandardMsgLen is the length of an insteon standard message minus one byte (the crc byte) StandardMsgLen = 9 // ExtendedMsgLen is the length of an insteon extended message minus one byte (the crc byte) ExtendedMsgLen = 23 )
const ( MsgTypeDirect MessageType = 0 // D 0b0000 0000 MsgTypeDirectAck = 0x20 // D (Ack) 0b0010 0000 MsgTypeDirectNak = 0xA0 // D (Nak) 0b1010 0000 MsgTypeAllLinkCleanup = 0x40 // C 0b0100 0000 MsgTypeAllLinkCleanupAck = 0x60 // C (Ack) 0b0110 0000 MsgTypeAllLinkCleanupNak = 0xE0 // C (Nak) 0b1110 0000 MsgTypeBroadcast = 0x80 // B 0b1000 0000 MsgTypeAllLinkBroadcast = 0xC0 // A 0b1100 0000 )
All of the valid message types
const ( StandardBroadcast = Flags(0x8a) StandardAllLinkBroadcast = Flags(0xca) StandardDirectMessage = Flags(0x0a) StandardDirectAck = Flags(0x2a) StandardDirectNak = Flags(0xaa) ExtendedDirectMessage = Flags(0x1a) ExtendedDirectAck = Flags(0x3a) ExtendedDirectNak = Flags(0xba) )
Flags for common message types
Variables ¶
var ( // ErrBufferTooShort indicates a buffer underrun when unmarshalling data ErrBufferTooShort = errors.New("Buffer is too short") // ErrReadTimeout indicates the timeout period expired while waiting for // a specific message ErrReadTimeout = errors.New("Read Timeout") // ErrAckTimeout indicates the timeout period expired while waiting for // ack message for a previously sent Direct message ErrAckTimeout = errors.New("Ack Timeout") // ErrWriteTimeout indicates the timeout period expired while waiting to // write a message ErrWriteTimeout = errors.New("Write Timeout") // ErrNotSupported indicates some feature (namely an updateable All-Link database) is // not supported by the underlying Insteon device ErrNotSupported = errors.New("Feature is not supported by the device") // ErrNotImplemented indicates that a device function has not yet been implemented ErrNotImplemented = errors.New("Command is not yet implemented") // ErrNotLinkable indicates a linking function was requested on a non-linkable device ErrNotLinkable = errors.New("Device is not remotely linkable") // ErrUnknownCommand is returned by the device (as a Nak) in response to an unknown command byte ErrUnknownCommand = errors.New("Unknown command") // ErrUnknown is returned by a connection when a NAK occurred but the error code // is not known ErrUnknown = errors.New("Device returned unknown error") // ErrPreNak is returned by I2Cs devices (this error condition is not documented) ErrPreNak = errors.New("Database search took too long") // ErrAddrFormat is returned when unmarshalling an address from text and the // text is in an unsupported format ErrAddrFormat = errors.New("address format is xx.xx.xx (digits in hex)") // ErrInvalidMemAddress indicates a link record memory address is invalid ErrInvalidMemAddress = errors.New("Invalid memory address") // ErrVersion is returned when an engine version value is not known ErrVersion = errors.New("Unknown Insteon Engine Version") )
Functions ¶
func PropagationDelay ¶
PropagationDelay attempts to calculate the amount of time an Insteon message needs in order to completely propagate (including relays) throughout the network. This is based on the number of AC zero crossings, the number of times a message can be repeated (ttl) and whether or not the message is an extended message
Types ¶
type Address ¶
type Address uint32
Address is a 3 byte insteon address
func (Address) MarshalJSON ¶
MarshalJSON will convert the address to a JSON string
func (Address) MarshalText ¶
MarshalText fulfills the requiresments of encoding.TextMarshaler so that Address can be used as a map key in other encoding
func (Address) String ¶
String will format the Address object into a form common to Insteon devices: 00.00.00 where each byte is represented in hexadecimal form (e.g. 01.b4.a5) the string will always be 8 characters long, bytes are zero padded
func (*Address) UnmarshalJSON ¶
UnmarshalJSON will populate the address from the input JSON string
func (*Address) UnmarshalText ¶
UnmarshalText converts a human readable string into an Insteon address. If the address cannot be parsed then UnmarshalText returns an ErrAddressFormat error
type Category ¶
type Category byte
Category indicates the specific kind of device within a domain. For instance, a LampLing and a SwitchLinc Dimmer are both within the Dimmable device domain
type DevCat ¶
type DevCat [2]byte
DevCat is a 2 byte value including a device category and sub-category. Devices are grouped by categories (thermostat, light, etc) and then each category has specific types of devices such as on/off switches and dimmer switches
func (DevCat) Category ¶
Category returns the device's category. For instance a DevCat with the Domain "Dimmable" may return the Category for LampLinc or SwitchLinc Dimmer
func (DevCat) MarshalJSON ¶
MarshalJSON will convert the DevCat to a valid JSON byte string
func (DevCat) String ¶
String returns a string representation of the DevCat in the form of category.subcategory where those fields are the 2 digit hex representation of their corresponding values
func (*DevCat) UnmarshalJSON ¶
UnmarshalJSON will unmarshal the input json byte string into the DevCat receiver
type Domain ¶
type Domain byte
Domain represents an entire domain of similar devices (dimmers, switches, thermostats, etc)
type EngineVersion ¶
type EngineVersion int
EngineVersion indicates the Insteon engine version that the device is running
const ( VerI1 EngineVersion = iota VerI2 VerI2Cs )
Insteon Engine Versions
func (EngineVersion) String ¶
func (ev EngineVersion) String() string
type FirmwareVersion ¶
type FirmwareVersion int
FirmwareVersion indicates the software/firmware revision number of a device
func (FirmwareVersion) String ¶
func (fv FirmwareVersion) String() string
String will return the hexadecimal string of the firmware version
type Flags ¶
type Flags byte
Flags is the flags byte in an insteon message
func Flag ¶
func Flag(messageType MessageType, extended bool, hopsLeft, maxHops uint8) Flags
Flag allows building of MessageFlags from component parts.
type Group ¶
type Group byte
Group is the Insteon group to which the Link Record corresponds
func (*Group) UnmarshalText ¶
UnmarshalText takes an input string and converts it to its Group equivalent. The decimal input value must be positive and less than 256
type LinkID ¶
type LinkID [5]byte
LinkID is the combination of bit 6 of the record control flags (controller/responder), the group ID and the 3 byte address
type LinkRecord ¶
type LinkRecord struct { Flags RecordControlFlags `json:"flags"` Group Group `json:"group"` Address Address `json:"address"` Data [3]byte `json:"data"` }
LinkRecord is a single All-Link record in an All-Link database
func ControllerLink ¶
func ControllerLink(group Group, address Address) LinkRecord
ControllerLink creates a LinkRecord that is set as a controller record with the group and responder address set to the given arguments
func ResponderLink ¶
func ResponderLink(group Group, address Address) LinkRecord
ResponderLink creates a LinkRecord that is set as a responder record with the group and controller address set to the given arguments
func (*LinkRecord) Equal ¶
func (l *LinkRecord) Equal(other *LinkRecord) bool
Equal will determine if another LinkRecord is equivalent. The records are equivalent if they both have the same availability, type (controller/responder) address and group
func (*LinkRecord) ID ¶
func (l *LinkRecord) ID() LinkID
func (*LinkRecord) MarshalBinary ¶
func (l *LinkRecord) MarshalBinary() ([]byte, error)
MarshalBinary converts the link-record to a byte string that can be used in a record request
func (*LinkRecord) MarshalText ¶
func (l *LinkRecord) MarshalText() ([]byte, error)
MarshalText will convert the LinkRecord to a text string that can be used as input to the UnmarshalText. This is useful in allowing a user to manuall edit link records
func (LinkRecord) String ¶
func (l LinkRecord) String() string
String converts the LinkRecord to a human readable string that looks similar to:
UR 1 01.02.03 00 1c 01
func (*LinkRecord) UnmarshalBinary ¶
func (l *LinkRecord) UnmarshalBinary(buf []byte) (err error)
UnmarshalBinary will convert the byte string received in a message request to a LinkRecord
func (*LinkRecord) UnmarshalText ¶
func (l *LinkRecord) UnmarshalText(buf []byte) (err error)
UnmarshalText takes an input text string and assigns the values to the RecordControlFlags receiver. The input text string should be in the following form:
Flags Group Address Data UR 1 01.02.03 00 1c 01
Each field is unmarshaled using the corresponding type's UnmarshalText functions
type Message ¶
Message is a single insteon message
func ReadWithTimeout ¶
ReadWithTimeout will attempt to read a message from a channel and will return the read message. If no message is received after the timeout duration, then ErrReadTimeout is returned
func (*Message) Duplicate ¶
Duplicate indicates whether everything except the ttl matches the other message. This is usefule for detecting re-transmitted messages where the ttl is decremented
func (*Message) MarshalBinary ¶
MarshalBinary will convert the Message to a byte slice appropriate for sending out onto the insteon network
func (*Message) UnmarshalBinary ¶
UnmarshalBinary will take a byte slice and unmarshal it into the Message fields
type MessageType ¶
type MessageType int
MessageType is an integer representing the type of message (Direct, Direct ACK, etc). The following table displays the bit setting tha correspond to the message flags for the various message types: Flags (8 Bit/1 Byte)
Description | Message Type (3 bits) Direct | 0 0 0 Direct Ack | 0 0 1 AllLink Cleanup | 0 1 0 AllLink CleanupAck | 0 1 1 Broadcast | 1 0 0 Direct Nak | 1 0 1 AllLink Broadcast | 1 1 0 AllLink CleanupNak | 1 1 1
func (MessageType) AllLink ¶
func (m MessageType) AllLink() bool
func (MessageType) Broadcast ¶
func (m MessageType) Broadcast() bool
Broadcast will indicate whether the MessageType represents a broadcast message
func (MessageType) Direct ¶
func (m MessageType) Direct() bool
Direct will indicate whether the MessageType represents a direct message
func (MessageType) String ¶
func (m MessageType) String() string
type ProductKey ¶
type ProductKey [3]byte
ProductKey is a 3 byte code assigned by Insteon
func (ProductKey) String ¶
func (p ProductKey) String() string
String returns the hexadecimal string for the product key
type RecordControlFlags ¶
type RecordControlFlags byte
RecordControlFlags indicate whether a link record is a controller or responder and whether it is available or in use
func (RecordControlFlags) Available ¶
func (rcf RecordControlFlags) Available() bool
Available indicates if a link record is available and can be overwritten by a new record. Available is synonmous with "deleted"
func (*RecordControlFlags) ClearLastRecord ¶
func (rcf *RecordControlFlags) ClearLastRecord()
func (RecordControlFlags) Controller ¶
func (rcf RecordControlFlags) Controller() bool
Controller indicates that the device is a controller for the device in the link record
func (RecordControlFlags) InUse ¶
func (rcf RecordControlFlags) InUse() bool
InUse indicates if a link record is currently in use by the device
func (RecordControlFlags) LastRecord ¶
func (rcf RecordControlFlags) LastRecord() bool
LastRecord indicates if this link record is the last record (also known as the high water mark) in the database.
func (RecordControlFlags) Responder ¶
func (rcf RecordControlFlags) Responder() bool
Responder indicates that the device is a reponder to the device listed in the link record
func (*RecordControlFlags) SetAvailable ¶
func (rcf *RecordControlFlags) SetAvailable()
SetAvailable indicates that the record is no longer in use and can be overwritten
func (*RecordControlFlags) SetController ¶
func (rcf *RecordControlFlags) SetController()
func (*RecordControlFlags) SetInUse ¶
func (rcf *RecordControlFlags) SetInUse()
SetInUse indicates the the record is active/in use and cannot be overwritten
func (*RecordControlFlags) SetLastRecord ¶
func (rcf *RecordControlFlags) SetLastRecord()
func (*RecordControlFlags) SetResponder ¶
func (rcf *RecordControlFlags) SetResponder()
func (RecordControlFlags) String ¶
func (rcf RecordControlFlags) String() string
String will be "A" or "U" (available or in use) followed by "C" or "R" (controller or responder). This string will always be two characters wide
func (*RecordControlFlags) UnmarshalText ¶
func (rcf *RecordControlFlags) UnmarshalText(text []byte) (err error)
UnmarshalText takes a two character input string and converts it to the correct RecordControlFlags. The first character can be either "A" for available or "U" for unavailable (in use) and the second character is either "C" for controller or "R" for responder