Beispiel #1
0
func ExampleTranslatePacketStatus() {
	pkt, _ := gorfxtrx.Parse([]byte{0x0d, 0x01, 0x00, 0x01, 0x02, 0x53, 0x3e, 0x00, 0x0c, 0x2f, 0x01, 0x01, 0x00, 0x00})
	ev := translatePacket(pkt)
	fmt.Println(ev)
	// Output:
	// <nil>
}
Beispiel #2
0
func ExampleTranslatePacketChime() {
	pkt, _ := gorfxtrx.Parse([]byte{0x07, 0x16, 0x00, 0x06, 0x00, 0x7a, 0x01, 0x70})
	ev := translatePacket(pkt)
	loc, _ := time.LoadLocation("UTC")
	ev.Timestamp = time.Date(2014, 1, 2, 3, 4, 5, 987654321, loc)
	fmt.Println(ev)
	// Output:
	//{"battery":0,"chime":1,"command":"on","origin":"rfxtrx","source":"byronsx.007a","timestamp":"2014-01-02 03:04:05.987654","topic":"chime"}
}
Beispiel #3
0
func ExampleTranslatePacketHE() {
	pkt, _ := gorfxtrx.Parse([]byte{0x0b, 0x11, 0x00, 0x2a, 0x01, 0x23, 0x45, 0x67, 0x05, 0x02, 0x08, 0x70})
	ev := translatePacket(pkt)
	loc, _ := time.LoadLocation("UTC")
	ev.Timestamp = time.Date(2014, 1, 2, 3, 4, 5, 987654321, loc)
	fmt.Println(ev)
	// Output:
	// {"command":"set level","origin":"rfxtrx","source":"12345675","timestamp":"2014-01-02 03:04:05.987654","topic":"homeeasy"}
}
Beispiel #4
0
func ExampleTranslatePacketX10() {
	pkt, _ := gorfxtrx.Parse([]byte{0x07, 0x10, 0x00, 0x2a, 0x45, 0x05, 0x01, 0x70})
	ev := translatePacket(pkt)
	loc, _ := time.LoadLocation("UTC")
	ev.Timestamp = time.Date(2014, 1, 2, 3, 4, 5, 987654321, loc)
	fmt.Println(ev)
	// Output:
	// {"command":"on","group":"e","origin":"rfxtrx","source":"e05","timestamp":"2014-01-02 03:04:05.987654","topic":"x10"}
}