Created
August 20, 2022 08:32
-
-
Save alexander-zimmermann/31fa235c9b9801398704dc6d06179f03 to your computer and use it in GitHub Desktop.
knx-go TCP debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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