]> git.basschouten.com Git - openhab-addons.git/blob
24d6331484d5494b21f9539f9205d44b8989b38c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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         /*
38          * These are actually dependent on the type of device and
39          * firmware, this list is mainly for RFXtrx443 at 433.92MHz,
40          * which most of our users use.
41          *
42          * TODO: At some point, we should reconcile this with the SDK
43          * and accommodate for other devices and protocols. This is
44          * probably not worth doing until someone needs it and has
45          * suitable devices to test with!
46          */
47
48         //@formatter:off
49         data[7] = (byte) (
50                   (configuration.enableUndecoded        ? 0x80 : 0x00)
51                 | (configuration.enableImagintronixOpus ? 0x40 : 0x00)
52                 | (configuration.enableByronSX          ? 0x20 : 0x00)
53                 | (configuration.enableRSL              ? 0x10 : 0x00)
54                 | (configuration.enableLighting4        ? 0x08 : 0x00)
55                 | (configuration.enableFineOffsetViking ? 0x04 : 0x00)
56                 | (configuration.enableRubicson         ? 0x02 : 0x00)
57                 | (configuration.enableAEBlyss          ? 0x01 : 0x00));
58
59         data[8] = (byte) (
60                   (configuration.enableBlindsT1T2T3T4   ? 0x80 : 0x00)
61                 | (configuration.enableBlindsT0         ? 0x40 : 0x00)
62                 | (configuration.enableProGuard         ? 0x20 : 0x00)
63                 | (configuration.enableFS20             ? 0x10 : 0x00)
64                 | (configuration.enableLaCrosse         ? 0x08 : 0x00)
65                 | (configuration.enableHidekiUPM        ? 0x04 : 0x00)
66                 | (configuration.enableADLightwaveRF    ? 0x02 : 0x00)
67                 | (configuration.enableMertik           ? 0x01 : 0x00));
68
69         data[9] = (byte) (
70                   (configuration.enableVisonic          ? 0x80 : 0x00)
71                 | (configuration.enableATI              ? 0x40 : 0x00)
72                 | (configuration.enableOregonScientific ? 0x20 : 0x00)
73                 | (configuration.enableMeiantech        ? 0x10 : 0x00)
74                 | (configuration.enableHomeEasyEU       ? 0x08 : 0x00)
75                 | (configuration.enableAC               ? 0x04 : 0x00)
76                 | (configuration.enableARC              ? 0x02 : 0x00)
77                 | (configuration.enableX10              ? 0x01 : 0x00));
78
79         data[10] = (byte) (
80                   (configuration.enableHomeConfort      ? 0x02 : 0x00)
81                 | (configuration.enableKEELOQ           ? 0x01 : 0x00));
82
83         data[11] = 0;
84         data[12] = 0;
85         data[13] = 0;
86         //@formatter:on
87     }
88
89     public RFXComInterfaceControlMessage(byte[] data) {
90         // We should never receive control messages
91         throw new UnsupportedOperationException();
92     }
93
94     @Override
95     public byte[] decodeMessage() {
96         return data;
97     }
98
99     @Override
100     public void encodeMessage(byte[] data) {
101         throw new UnsupportedOperationException();
102     }
103
104     @Override
105     public void convertFromState(String channelId, Type type) {
106         throw new UnsupportedOperationException();
107     }
108 }