2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.rfxcom.internal.messages;
15 import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
17 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
18 import org.openhab.core.types.Type;
21 * RFXCOM data class for transmitter message.
23 * @author Pauli Anttila - Initial contribution
25 public class RFXComTransmitterMessage extends RFXComBaseMessage {
27 public enum SubType implements ByteEnumWrapper {
28 ERROR_RECEIVER_DID_NOT_LOCK(0),
31 private final int subType;
33 SubType(int subType) {
34 this.subType = subType;
38 public byte toByte() {
39 return (byte) subType;
43 public enum Response implements ByteEnumWrapper {
44 ACK(0), // ACK, transmit OK
45 ACK_DELAYED(1), // ACK, but transmit started after 3 seconds delay
46 // anyway with RF receive data
47 NAK(2), // NAK, transmitter did not lock on the requested transmit
49 NAK_INVALID_AC_ADDRESS(3); // NAK, AC address zero in id1-id4 not
52 private final int response;
54 Response(int response) {
55 this.response = response;
59 public byte toByte() {
60 return (byte) response;
64 public SubType subType;
65 public Response response;
67 public RFXComTransmitterMessage() {
68 super(PacketType.TRANSMITTER_MESSAGE);
71 public RFXComTransmitterMessage(byte[] data) throws RFXComException {
76 public String toString() {
79 str += super.toString();
81 if (subType == SubType.RESPONSE) {
82 str += ", Sub type = " + subType;
83 str += ", Response = " + response;
85 str += ", Sub type = " + subType;
93 public void encodeMessage(byte[] data) throws RFXComException {
94 super.encodeMessage(data);
96 subType = fromByte(SubType.class, super.subType);
97 response = fromByte(Response.class, data[4]);
101 public byte[] decodeMessage() {
102 byte[] data = new byte[5];
105 data[1] = RFXComBaseMessage.PacketType.TRANSMITTER_MESSAGE.toByte();
106 data[2] = subType.toByte();
108 data[4] = response.toByte();
114 public void convertFromState(String channelId, Type type) {
115 throw new UnsupportedOperationException();