]> git.basschouten.com Git - openhab-addons.git/blob
8097205b248888d708d9c1181d6419284ba72ff5
[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.enocean.internal.eep.Base;
14
15 import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.enocean.internal.messages.ERP1Message;
19
20 /**
21  *
22  * @author Daniel Weber - Initial contribution
23  */
24 @NonNullByDefault
25 public class UTEResponse extends _VLDMessage {
26
27     public static final byte TEACHIN_MASK = 0x3f;
28     public static final byte COMMUNICATION_TYPE_MASK = (byte) 0x80;
29     public static final byte RESPONSE_NEEDED_MASK = 0x40;
30     public static final byte TEACHIN_NPTSPECIFIED = 0x20;
31
32     public UTEResponse(ERP1Message packet, boolean teachIn) {
33         int dataLength = packet.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
34
35         setData(packet.getPayload(ESP3_RORG_LENGTH, dataLength));
36         bytes[0] = (byte) (teachIn ? 0x91 : 0xA1); // bidirectional communication, teach in accepted or teach out, teach
37                                                    // in response
38
39         setStatus((byte) 0x80);
40         setSuppressRepeating(true);
41         setDestinationId(packet.getSenderId());
42     }
43 }