knx

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package knx provides the means to communicate with KNXnet/IP gateways and routers.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRouterConfig = RouterConfig{
	RetainCount: 32,
}

DefaultRouterConfig is a good default configuration for a Router client.

View Source
var DefaultTunnelConfig = TunnelConfig{
	ResendInterval:    500 * time.Millisecond,
	HeartbeatInterval: 10 * time.Second,
	ResponseTimeout:   10 * time.Second,
}

DefaultTunnelConfig is a good default configuration for a Tunnel client.

Functions

func Discover

func Discover(multicastDiscoveryAddress string, searchTimeout time.Duration) ([]*knxnet.SearchRes, error)

Discover all KNXnet/IP Server

func DiscoverOnInterface

func DiscoverOnInterface(ifi *net.Interface, multicastDiscoveryAddress string, searchTimeout time.Duration) ([]*knxnet.SearchRes, error)

DiscoverOnInterface discovers all KNXnet/IP Server on a specific interface. If the interface is nil, the system-assigned multicast interface is used.

Types

type GroupClient

type GroupClient interface {
	Send(event GroupEvent) error
	Inbound() <-chan GroupEvent
}

A GroupClient is a KNX client which supports group communication.

type GroupCommand

type GroupCommand uint8

GroupCommand determines the meaning of a group event.

const (
	GroupRead     GroupCommand = 0
	GroupResponse GroupCommand = 1
	GroupWrite    GroupCommand = 2
)

These are known group commands.

func (GroupCommand) String

func (cmd GroupCommand) String() string

String generates a string representation of the command.

type GroupEvent

type GroupEvent struct {
	Command     GroupCommand
	Source      cemi.IndividualAddr
	Destination cemi.GroupAddr
	Data        []byte
}

GroupEvent represents a group communication event.

type GroupRouter

type GroupRouter struct {
	*Router
	// contains filtered or unexported fields
}

GroupRouter is a Router that provides only a group communication interface.

func NewGroupRouter

func NewGroupRouter(multicastAddress string, config RouterConfig) (gr GroupRouter, err error)

NewGroupRouter creates a new Router for group communication.

func (*GroupRouter) Inbound

func (gr *GroupRouter) Inbound() <-chan GroupEvent

Inbound returns the channel on which group communication can be received.

func (*GroupRouter) Send

func (gr *GroupRouter) Send(event GroupEvent) error

Send a group communication.

type GroupTunnel

type GroupTunnel struct {
	*Tunnel
	// contains filtered or unexported fields
}

GroupTunnel is a Tunnel that provides only a group communication interface.

func NewGroupTunnel

func NewGroupTunnel(gatewayAddr string, config TunnelConfig) (gt GroupTunnel, err error)

NewGroupTunnel creates a new Tunnel for group communication.

func (*GroupTunnel) Inbound

func (gt *GroupTunnel) Inbound() <-chan GroupEvent

Inbound returns the channel on which group communication can be received.

func (*GroupTunnel) Send

func (gt *GroupTunnel) Send(event GroupEvent) error

Send a group communication.

type Router

type Router struct {
	// contains filtered or unexported fields
}

A Router provides the means to communicate with KNXnet/IP routers in a IP multicast group. It supports sending and receiving CEMI-encoded frames, aswell as basic flow control.

func NewRouter

func NewRouter(multicastAddress string, config RouterConfig) (*Router, error)

NewRouter creates a new Router that joins the given multicast group. You may pass a zero-initialized value as parameter config, the default values will be set up.

func (*Router) Close

func (router *Router) Close()

Close closes the underlying socket and terminates the Router thereby.

func (*Router) Inbound

func (router *Router) Inbound() <-chan cemi.Message

Inbound returns the channel which transmits incoming data. The channel will be closed when the underlying Socket closes its inbound channel (which happens on read errors or upon closing it).

func (*Router) Send

func (router *Router) Send(data cemi.Message) error

Send transmits a packet.

type RouterConfig

type RouterConfig struct {
	// Specify how many sent messages to retain. This is important for when a router indicates that
	// it has lost some messages. If you do not expect to saturate the router, keep this low.
	RetainCount uint
	// Specifies the interface used to send and receive KNXNet/IP packets. If the interface
	// is nil, the system-assigned multicast interface is used.
	Interface *net.Interface
}

A RouterConfig determines certain properties of a Router.

type Tunnel

type Tunnel struct {
	// contains filtered or unexported fields
}

A Tunnel provides methods to communicate with a KNXnet/IP gateway.

func NewTunnel

func NewTunnel(gatewayAddr string, layer knxnet.TunnelLayer, config TunnelConfig) (*Tunnel, error)

NewTunnel establishes a connection to a gateway. You can pass a zero initialized ClientConfig; the function will take care of filling in the default values.

func (*Tunnel) Close

func (conn *Tunnel) Close()

Close will terminate the connection and wait for the server routine to exit. Although a disconnect request is sent, it does not wait for a disconnect response.

func (*Tunnel) Inbound

func (conn *Tunnel) Inbound() <-chan cemi.Message

Inbound retrieves the channel which transmits incoming data. The channel is closed when the underlying Socket closes its inbound channel or when the connection is terminated.

func (*Tunnel) Send

func (conn *Tunnel) Send(data cemi.Message) error

Send relays a tunnel request to the gateway with the given contents.

type TunnelConfig

type TunnelConfig struct {
	// ResendInterval is the interval with which requests will be resend if no response is received.
	ResendInterval time.Duration

	// HeartbeatInterval specifies the time interval which triggers a heartbeat check.
	HeartbeatInterval time.Duration

	// ResponseTimeout specifies how long to wait for a response.
	ResponseTimeout time.Duration
}

TunnelConfig allows you to configure the tunnel client's behavior.

Directories

Path Synopsis
Package cemi provides the functionality to parse and generate KNX CEMI-encoded frames.
Package cemi provides the functionality to parse and generate KNX CEMI-encoded frames.
Package knxnet provides the means to parse and generate frames of the KNXnet/IP protocol.
Package knxnet provides the means to parse and generate frames of the KNXnet/IP protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL