Skip to content

Create and establish a connection

danielwippermann edited this page Mar 15, 2016 · 1 revision

Create and establish a connection

A Connection instance can be used to receive and transmit VBus live data.

The following steps are combined in the "livelogger" example application which can be found here: https://github.com/danielwippermann/resol-vbus-java/blob/master/vbus-example/src/main/java/de/resol/vbus/example/livelogger/Main.java

Prerequisites

Create a Connection instance

The DataSource#connectLive method can be used to easily open a Connection to a known DataSource (like a LAN-enabled VBus device).

TcpDataSource dataSource = ...;  // described in Prerequisites sections

All LAN-enabled devices need a password to successfully establish a connection to them. This password can be changed (e.g. in their web interface). The password must be given to the DataSource instance before trying to establish the connection:

dataSource.setLivePassword("secret");

Now the connection can be established. Calling the DataSource#connectLive method returns the Connnection instance. It required two parameters:

  • a channel number if the device is a DL3 (which supports up to six channels numbered 1 to 6) and
  • a VBus address that is used as a source address if the connection is used to send out commands to the controller.

Establishing a connection to a DL2 (which only supports channel 0) looks like this in code:

int channel = 0;
int selfAddress = 0x0020;
Connection connection = dataSource.connectLive(0, selfAddress);

After you received the Connection instance you can use it to:

Clone this wiki locally