Created
August 20, 2022 08:21
-
-
Save alexander-zimmermann/48cff0f9876150aceb07cce3af955ef3 to your computer and use it in GitHub Desktop.
knx-go TCP connection
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" | |
//"github.com/alexander-zimmermann/knx-go/knx" | |
//"github.com/alexander-zimmermann/knx-go/knx/cemi" | |
//"github.com/alexander-zimmermann/knx-go/knx/dpt" | |
//"github.com/alexander-zimmermann/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 { | |
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