]> git.basschouten.com Git - openhab-addons.git/blob
e83be01bbafbd006bf234b24dfb1ffaf37a73e5d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.rfxcom.internal.messages;
14
15 import org.openhab.binding.rfxcom.internal.config.RFXComBridgeConfiguration;
16 import org.openhab.core.types.Type;
17
18 /**
19  * RFXCOM data class for control message.
20  *
21  * @author Pauli Anttila - Initial contribution
22  * @author Mike Jagdis
23  */
24 public class RFXComInterfaceControlMessage extends RFXComBaseMessage {
25     private byte[] data = new byte[14];
26
27     public RFXComInterfaceControlMessage(RFXComInterfaceMessage.TransceiverType transceiverType,
28             RFXComBridgeConfiguration configuration) {
29         data[0] = 0x0D;
30         data[1] = RFXComBaseMessage.PacketType.INTERFACE_CONTROL.toByte();
31         data[2] = 0;
32         data[3] = 2;
33         data[4] = RFXComInterfaceMessage.Commands.SET_MODE.toByte();
34         data[5] = transceiverType.toByte();
35         data[6] = (byte) (configuration.transmitPower + 18);
36
37         //@formatter:off
38         data[7] = (byte) (
39                   (configuration.enableUndecoded        ? 0x80 : 0x00)
40                 | (configuration.enableImagintronixOpus ? 0x40 : 0x00)
41                 | (configuration.enableByronSX          ? 0x20 : 0x00)
42                 | (configuration.enableRSL              ? 0x10 : 0x00)
43                 | (configuration.enableLighting4        ? 0x08 : 0x00)
44                 | (configuration.enableFineOffsetViking ? 0x04 : 0x00)
45                 | (configuration.enableRubicson         ? 0x02 : 0x00)
46                 | (configuration.enableAEBlyss          ? 0x01 : 0x00));
47
48         data[8] = (byte) (
49                   (configuration.enableBlindsT1T2T3T4   ? 0x80 : 0x00)
50                 | (configuration.enableBlindsT0         ? 0x40 : 0x00)
51                 | (configuration.enableProGuard         ? 0x20 : 0x00)
52                 | (configuration.enableFS20             ? 0x10 : 0x00)
53                 | (configuration.enableLaCrosse         ? 0x08 : 0x00)
54                 | (configuration.enableHidekiUPM        ? 0x04 : 0x00)
55                 | (configuration.enableADLightwaveRF    ? 0x02 : 0x00)
56                 | (configuration.enableMertik           ? 0x01 : 0x00));
57
58         data[9] = (byte) (
59                   (configuration.enableVisonic          ? 0x80 : 0x00)
60                 | (configuration.enableATI              ? 0x40 : 0x00)
61                 | (configuration.enableOregonScientific ? 0x20 : 0x00)
62                 | (configuration.enableMeiantech        ? 0x10 : 0x00)
63                 | (configuration.enableHomeEasyEU       ? 0x08 : 0x00)
64                 | (configuration.enableAC               ? 0x04 : 0x00)
65                 | (configuration.enableARC              ? 0x02 : 0x00)
66                 | (configuration.enableX10              ? 0x01 : 0x00));
67
68         data[10] = (byte) (
69                   (configuration.enableHomeConfort      ? 0x02 : 0x00)
70                 | (configuration.enableKEELOQ           ? 0x01 : 0x00));
71
72         data[11] = 0;
73         data[12] = 0;
74         data[13] = 0;
75         //@formatter:on
76     }
77
78     public RFXComInterfaceControlMessage(byte[] data) {
79         // We should never receive control messages
80         throw new UnsupportedOperationException();
81     }
82
83     @Override
84     public byte[] decodeMessage() {
85         return data;
86     }
87
88     @Override
89     public void encodeMessage(byte[] data) {
90         throw new UnsupportedOperationException();
91     }
92
93     @Override
94     public void convertFromState(String channelId, Type type) {
95         throw new UnsupportedOperationException();
96     }
97 }