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