Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexander-zimmermann/31fa235c9b9801398704dc6d06179f03 to your computer and use it in GitHub Desktop.
Save alexander-zimmermann/31fa235c9b9801398704dc6d06179f03 to your computer and use it in GitHub Desktop.
knx-go TCP debug
package main
import (
"log"
"os"
"github.com/vapourismo/knx-go/knx"
//"github.com/vapourismo/knx-go/knx/cemi"
"github.com/vapourismo/knx-go/knx/dpt"
"github.com/vapourismo/knx-go/knx/util"
)
func main() {
// Setup logger for auxiliary logging. This enables us to see log messages from internal
// routines.
util.Logger = log.New(os.Stdout, "", log.LstdFlags)
// Connect to the gateway.
tunnelconfig := knx.DefaultTunnelConfig
tunnelconfig.UseTCP = true
client, err := knx.NewGroupTunnel("192.168.1.173:3671", tunnelconfig)
if err != nil {
log.Fatal(err)
}
// Close upon exiting. Even if the gateway closes the connection, we still have to clean up.
defer client.Close()
// Receive messages from the gateway. The inbound channel is closed with the connection.
for msg := range client.Inbound() {
var temp dpt.DPT_7012
err := temp.Unpack(msg.Data)
if err != nil {
util.Logger.Printf("Unpack fails: %v", err)
continue
}
util.Logger.Printf("%+v: %v", msg, temp)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment