]> git.basschouten.com Git - openhab-addons.git/blob
cbbc98b0138951dc9871bc6ee82389090a3fc7d5
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.knx.internal.client;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.knx.internal.handler.GroupAddressListener;
18
19 import tuwien.auto.calimero.IndividualAddress;
20 import tuwien.auto.calimero.KNXException;
21 import tuwien.auto.calimero.datapoint.Datapoint;
22
23 /**
24  * Client for communicating with the KNX bus.
25  *
26  * @author Simon Kaufmann - initial contribution and API
27  *
28  */
29 @NonNullByDefault
30 public interface KNXClient {
31
32     /**
33      * Check whether the client is connected
34      *
35      * @return {@code true} if the client currently is connected
36      */
37     boolean isConnected();
38
39     /**
40      * Determines whether the supplied address is occupied by a device in the KNX network or not.
41      *
42      * @param address the individual address to check
43      * @return {@code true} if the address is occupied
44      * @throws KNXException on network or send errors
45      */
46     boolean isReachable(@Nullable IndividualAddress address) throws KNXException;
47
48     /**
49      * Get the {@link DeviceInfoClient} which allows further device inspection.
50      *
51      * @return the device infor client
52      * @throws IllegalStateException in case the client is not connected
53      */
54     DeviceInfoClient getDeviceInfoClient();
55
56     /**
57      * Initiates a basic restart of the device with the given address.
58      *
59      * @param address the individual address of the device
60      */
61     void restartNetworkDevice(@Nullable IndividualAddress address);
62
63     /**
64      * Register the given listener to be informed on KNX bus traffic.
65      *
66      * @param listener the listener
67      * @return {@code true} if it wasn't registered before
68      */
69     boolean registerGroupAddressListener(GroupAddressListener listener);
70
71     /**
72      * Remove the given listener.
73      *
74      * @param listener the listener
75      * @return {@code true} if it was successfully removed
76      */
77     boolean unregisterGroupAddressListener(GroupAddressListener listener);
78
79     /**
80      * Schedule the given data point for asynchronous reading.
81      *
82      * @param datapoint the datapoint
83      */
84     void readDatapoint(Datapoint datapoint);
85
86     /**
87      * Write a command to the KNX bus.
88      *
89      * @param commandSpec the outbound spec
90      * @throws KNXException if any problem with the communication arises.
91      */
92     void writeToKNX(OutboundSpec commandSpec) throws KNXException;
93
94     /**
95      * Send a state as a read-response to the KNX bus.
96      *
97      * @param responseSpec the outbound spec
98      * @throws KNXException if any problem with the communication arises.
99      */
100     void respondToKNX(OutboundSpec responseSpec) throws KNXException;
101 }