Documentation
¶
Overview ¶
Package gorfxtrx is a library for the RFXcom RFXtrx433 USB transceiver.
http://www.rfxcom.com/store/Transceivers/12103
Supported transmitter / receivers:
- Oregon weather devices (THGR810, WTGR800, THN132N, PCR800, etc.)
- X10 RF devices (Domia Lite, HE403, etc.)
- HomeEasy devices (HE300, HE301, HE303, HE305, etc.)
RFXcom devices tested:
- RFXcom RFXtrx433 USB Transceiver
Example usage:
import (
"fmt"
"github.com/barnybug/gorfxtrx"
)
func main() {
dev, err := gorfxtrx.Open("/dev/serial/by-id/usb-RFXCOM-...", true)
if err != nil {
panic("Error opening device")
}
for {
packet, err := dev.Read()
if err != nil {
continue
}
fmt.Println("Received", packet)
}
dev.Close()
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var PacketTypes = map[byte]PacketType{ 0x1: PacketType{20, "Status", func() Packet { return &Status{} }}, 0x2: PacketType{4, "TransmitAck", func() Packet { return &TransmitAck{} }}, 0x10: PacketType{7, "LightingX10", func() Packet { return &LightingX10{} }}, 0x11: PacketType{11, "LightingHE", func() Packet { return &LightingHE{} }}, 0x16: PacketType{7, "Chime", func() Packet { return &Chime{} }}, 0x50: PacketType{8, "Temp", func() Packet { return &Temp{} }}, 0x52: PacketType{10, "TempHumid", func() Packet { return &TempHumid{} }}, 0x55: PacketType{11, "Rain", func() Packet { return &Rain{} }}, 0x59: PacketType{13, "Elec1", func() Packet { return &Elec1{} }}, 0x56: PacketType{16, "Wind", func() Packet { return &Wind{} }}, 0x5a: PacketType{17, "Elec3", func() Packet { return &Elec3{} }}, }
var States = map[uint8]string{
0: "ACK",
1: "ACK_DELAYED",
2: "NACK",
3: "NACK_INVALID_AC_ADDRESS",
255: "UNKNOWN",
}
Functions ¶
This section is empty.
Types ¶
type Chime ¶
type Chime struct {
SequenceNumber byte
Chime byte
Battery byte
Rssi byte
// contains filtered or unexported fields
}
Struct for the Chime packets.
Example ¶
x, _ := Parse([]byte{0x07, 0x16, 0x00, 0x06, 0x00, 0x7a, 0x01, 0x70})
chime := *x.(*Chime)
fmt.Printf("%+v\n", chime)
fmt.Printf("%+v\n", chime.Id())
fmt.Printf("%+v\n", chime.Type())
Output: {typeId:0 SequenceNumber:6 id:122 Chime:1 Battery:0 Rssi:7} 00:7a Byron SX
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device representing the serial connection to the USB device.
type Elec1 ¶
type Elec1 struct {
Subtype uint8
SeqNr uint8
SensorId uint16
Count uint8
Current1 float64
Current2 float64
Current3 float64
Signal uint8
Battery byte
}
Elec1 devices: OWL CM113, cent-a-meter, Electrisave
type Elec3 ¶
type Elec3 struct {
Subtype uint8
SeqNr uint8
SensorId uint16
Power uint32
Total float64
Signal uint8
Battery byte
}
Elec3 devices: OWL CM180
type LightingHE ¶
type LightingHE struct {
SequenceNumber byte
HouseCode uint32
UnitCode byte
Level byte
// contains filtered or unexported fields
}
Struct for Homeeasy lighting packets.
Example ¶
x, _ := Parse([]byte{0x0b, 0x11, 0x00, 0x2a, 0x01, 0x23, 0x45, 0x67, 0x05, 0x02, 0x08, 0x70})
lighting := *x.(*LightingHE)
fmt.Printf("%+v\n", lighting)
fmt.Println(lighting.Type())
fmt.Println(lighting.Id())
fmt.Println(lighting.Command())
Output: {typeId:0 SequenceNumber:42 HouseCode:19088743 UnitCode:5 command:2 Level:8} AC 12345675 set level
func NewLightingHE ¶
func NewLightingHE(typeId byte, id string, command string) (*LightingHE, error)
func (*LightingHE) Receive ¶
func (self *LightingHE) Receive(data []byte)
func (*LightingHE) Send ¶
func (self *LightingHE) Send() []byte
type LightingX10 ¶
type LightingX10 struct {
SequenceNumber byte
HouseCode byte
UnitCode byte
// contains filtered or unexported fields
}
Struct for X10 Lighting packets.
Example ¶
x, _ := Parse([]byte{0x07, 0x10, 0x00, 0x2a, 0x45, 0x05, 0x01, 0x70})
lighting := *x.(*LightingX10)
fmt.Printf("%+v\n", lighting)
fmt.Println(lighting.Type())
fmt.Println(lighting.Id())
fmt.Println(lighting.Command())
Output: {typeId:0 SequenceNumber:42 HouseCode:69 UnitCode:5 command:1} X10 lighting e05 on
func NewLightingX10 ¶
func NewLightingX10(typeId byte, id string, command string) (*LightingX10, error)
func (*LightingX10) Receive ¶
func (self *LightingX10) Receive(data []byte)
func (*LightingX10) Send ¶
func (self *LightingX10) Send() []byte
type LogReadWriteCloser ¶
type LogReadWriteCloser struct {
// contains filtered or unexported fields
}
A logging ReadWriteCloser for debugging
func (LogReadWriteCloser) Close ¶
func (self LogReadWriteCloser) Close() error
type MockSerialPort ¶
type MockSerialPort struct {
// contains filtered or unexported fields
}
func NewMockSerialPort ¶
func NewMockSerialPort(replay [][]byte) *MockSerialPort
func (*MockSerialPort) Close ¶
func (self *MockSerialPort) Close() error
type OutPacket ¶
type OutPacket interface {
// Serialize packet to wire format
Send() []byte
}
Interface representing a transmittable packet.
type Packet ¶
type Packet interface {
// Deserialize packet from wire format
Receive(data []byte)
}
Interface representing a received packet.
type PacketType ¶
type PacketType struct {
// contains filtered or unexported fields
}
type Rain ¶
type Rain struct {
SequenceNumber byte
RainRate float64
RainTotal float64
Battery byte
Rssi byte
// contains filtered or unexported fields
}
Struct for the Rain packets.
Example ¶
x, _ := Parse([]byte{0x0b, 0x55, 0x02, 0x03, 0x12, 0x34, 0x02, 0x50, 0x01, 0x23, 0x45, 0x57})
rain := *x.(*Rain)
fmt.Printf("%+v\n", rain)
fmt.Println(rain.Id())
fmt.Println(rain.Type())
Output: {typeId:2 SequenceNumber:3 id:4660 RainRate:5.92 RainTotal:7456.5 Battery:70 Rssi:5} 12:34 PCR800
type SetMode ¶
type SetMode struct {
AeBlyss bool
Rubicson bool
FineoffsetViking bool
Lighting4 bool
Rsl bool
ByronSX bool
Rfu6 bool
Edisplay bool
Mertik bool
Lightwarerf bool
Hideki bool
Lacrosse bool
Fs20 bool
Proguard bool
Blindst0 bool
Blindst1 bool
X10 bool
Arc bool
Ac bool
Homeeasy bool
Ikeakoppla bool
Oregon bool
Ati bool
Visonic bool
}
Struct for the SetMode packet type.
type Status ¶
type Status struct {
TransceiverType byte
FirmwareVersion byte
// contains filtered or unexported fields
}
Struct for the Status packet type.
Example ¶
pkt, err := Parse([]byte{0x14, 0x01, 0x00, 0x01, 0x03, 0x53, 0x09, 0x20, 0x00, 0x2f, 0x00, 0x01, 0x01, 0x1c, 0x01, 0x00, 0x049, 0x00, 0x00, 0x00, 0x00})
fmt.Printf("%v\n", pkt)
fmt.Println(err)
Output: Status: type: 433.92MHz transceiver: 83 firmware: 9 protocols: ac, arc, byron sx, homeeasy, oregon, x10 <nil>
type Temp ¶
type Temp struct {
SequenceNumber byte
Temp float64
Battery byte
Rssi byte
// contains filtered or unexported fields
}
Struct for the Temp packets.
Example ¶
x, _ := Parse([]byte{0x08, 0x50, 0x02, 0x2a, 0x96, 0x03, 0x81, 0x41, 0x79})
temp := *x.(*Temp)
fmt.Printf("%+v\n", temp)
fmt.Printf("%+v\n", temp.Id())
fmt.Printf("%+v\n", temp.Type())
Output: {typeId:2 SequenceNumber:42 id:38403 Temp:-32.1 Battery:90 Rssi:7} 96:03 THC238/268,THN132,THWR288,THRN122,THN122,AW129/131
type TempHumid ¶
type TempHumid struct {
TypeId byte
SequenceNumber byte
Temp float64
Humidity byte
HumidityStatus byte
Battery byte
Rssi byte
// contains filtered or unexported fields
}
Struct for the TempHumid packets
Example ¶
x, _ := Parse([]byte{0x0a, 0x52, 0x01, 0x2a, 0x96, 0x03, 0x81, 0x41, 0x60, 0x03, 0x79})
temp := *x.(*TempHumid)
fmt.Printf("%+v\n", temp)
fmt.Printf("%+v\n", temp.Id())
fmt.Printf("%+v\n", temp.Type())
Output: {TypeId:1 SequenceNumber:42 id:38403 Temp:-32.1 Humidity:96 HumidityStatus:3 Battery:90 Rssi:7} 96:03 THGN122/123, THGN132, THGR122/228/238/268
type TransmitAck ¶
Struct for the TransmitAck packets.
Example ¶
pkt, err := Parse([]byte{0x04, 0x02, 0x01, 0x00, 0x00})
fmt.Printf("%v\n", pkt)
fmt.Println(err)
Output: TransmitAck: ACK <nil>
func (*TransmitAck) OK ¶
func (self *TransmitAck) OK() bool
func (*TransmitAck) Receive ¶
func (self *TransmitAck) Receive(data []byte)
func (*TransmitAck) String ¶
func (self *TransmitAck) String() string
type Unknown ¶
type Unknown struct {
// contains filtered or unexported fields
}
Struct for an Unknown packet type.
Example ¶
pkt, _ := Parse([]byte{0x01, 0xFF})
fmt.Printf("%+v\n", pkt)
Output: Unknown: 01ff
type Wind ¶
type Wind struct {
SequenceNumber byte
Direction uint16
AverageSpeed float64
Gust float64
Battery byte
Rssi byte
// contains filtered or unexported fields
}
Struct for the Wind packets.
Example ¶
x, _ := Parse([]byte{0x10, 0x56, 0x01, 0x03, 0x2F, 0x00, 0x00, 0xF7, 0x00, 0x20, 0x00, 0x24, 0x01, 0x60, 0x00, 0x00, 0x59})
wind := *x.(*Wind)
fmt.Printf("%+v\n", wind)
fmt.Println(wind.Id())
fmt.Println(wind.Type())
Output: {data:[16 86 1 3 47 0 0 247 0 32 0 36 1 96 0 0 89] typeId:1 SequenceNumber:3 id:12032 Direction:247 AverageSpeed:3.2 Gust:3.6 Battery:90 Rssi:5} 2f:00 WTGR800