]> git.basschouten.com Git - openhab-addons.git/blob
2462a87282f3a83cfacf89cadf85e9a62f00f88d
[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.dsmr.internal.device;
14
15 import org.openhab.binding.dsmr.internal.DSMRBindingConstants;
16
17 /**
18  * Class describing the DSMR bridge user configuration
19  *
20  * @author M. Volaart - Initial contribution
21  * @author Hilbrand Bouwkamp - added receivedTimeout configuration
22  */
23 public class DSMRDeviceConfiguration {
24
25     /**
26      * Serial port name
27      */
28     public String serialPort;
29
30     /**
31      * Serial port baud rate
32      */
33     public int baudrate;
34
35     /**
36      * Serial port data bits
37      */
38     public int databits;
39
40     /**
41      * Serial port parity
42      */
43     public String parity;
44
45     /**
46      * Serial port stop bits
47      */
48     public String stopbits;
49
50     /**
51      * The Luxembourgish/Austria smart meter decryption key
52      */
53     public String decryptionKey;
54
55     /**
56      * Austria smart meter additional decryption key
57      */
58     public String additionalKey = DSMRBindingConstants.ADDITIONAL_KEY_DEFAULT;
59
60     /**
61      * When no message was received after the configured number of seconds action will be taken.
62      */
63     public int receivedTimeout;
64
65     /**
66      * @return true if serial port settings are all set.
67      */
68     public boolean isSerialFixedSettings() {
69         return baudrate > 0 && databits > 0 && !(parity != null && parity.isBlank())
70                 && !(stopbits != null && stopbits.isBlank());
71     }
72
73     @Override
74     public String toString() {
75         return "DSMRDeviceConfiguration [serialPort=" + serialPort + ", Baudrate=" + baudrate + ", Databits=" + databits
76                 + ", Parity=" + parity + ", Stopbits=" + stopbits + ", decryptionKey=" + decryptionKey
77                 + ", additionalKey=" + additionalKey + ", receivedTimeout=" + receivedTimeout + "]";
78     }
79 }