]> git.basschouten.com Git - openhab-addons.git/blob
a1ebce44a219fb2aa3052f9cf22ca2bd96b1af1d
[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.messages;
14
15 /**
16  *
17  * @author Daniel Weber - Initial contribution
18  */
19 public class SAMessage extends BasePacket {
20
21     public enum SAMessageType {
22         SA_WR_LEARNMODE((byte) 0x01, 7),
23         SA_RD_LEARNMODE((byte) 0x02, 1),
24         SA_WR_LEARNCONFIRM((byte) 0x03, 1),
25         SA_WR_CLIENTLEARNRQ((byte) 0x04, 6),
26         SA_WR_RESET((byte) 0x05, 1),
27         SA_RD_LEARNEDCLIENTS((byte) 0x06, 1),
28         SA_WR_RECLAIMS((byte) 0x07, 1),
29         SA_WR_POSTMASTER((byte) 0x08, 2),
30         SA_RD_MAILBOX_STATUS((byte) 0x09, 9);
31
32         private byte value;
33         private int dataLength;
34
35         SAMessageType(byte value, int dataLength) {
36             this.value = value;
37             this.dataLength = dataLength;
38         }
39
40         public byte getValue() {
41             return this.value;
42         }
43
44         public int getDataLength() {
45             return dataLength;
46         }
47     }
48
49     private SAMessageType type;
50
51     public SAMessage(SAMessageType type) {
52         this(type, new byte[] { type.getValue() });
53     }
54
55     public SAMessage(SAMessageType type, byte[] payload) {
56         super(type.getDataLength(), 0, ESPPacketType.SMART_ACK_COMMAND, payload);
57
58         this.type = type;
59     }
60
61     public SAMessageType getSAMessageType() {
62         return type;
63     }
64 }