]> git.basschouten.com Git - openhab-addons.git/blob
1da53766f66f27ec70ea7799bc6a5ce659a694bd
[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.openhab.binding.enocean.internal.messages.ERP1Message;
18
19 /**
20  *
21  * @author Daniel Weber - Initial contribution
22  */
23 public class UTEResponse extends _VLDMessage {
24
25     public static final byte TeachIn_MASK = 0x3f;
26     public static final byte CommunicationType_MASK = (byte) 0x80;
27     public static final byte ResponseNeeded_MASK = 0x40;
28     public static final byte TeachIn_NotSpecified = 0x20;
29
30     public UTEResponse(ERP1Message packet, boolean teachIn) {
31         int dataLength = packet.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
32
33         setData(packet.getPayload(ESP3_RORG_LENGTH, dataLength));
34         bytes[0] = (byte) (teachIn ? 0x91 : 0xA1); // bidirectional communication, teach in accepted or teach out, teach
35                                                    // in response
36
37         setStatus((byte) 0x80);
38         setSuppressRepeating(true);
39         setDestinationId(packet.getSenderId());
40     }
41 }