2 * Copyright (c) 2010-2022 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.enocean.internal.messages;
15 import java.util.stream.Stream;
19 * @author Daniel Weber - Initial contribution
21 public class EventMessage extends BasePacket {
23 public enum EventMessageType {
24 UNKNOWN((byte) 0x00, 1),
25 SA_RECLAIM_NOT_SUCCESSFUL((byte) 0x01, 1),
26 SA_CONFIRM_LEARN((byte) 0x02, 17),
27 SA_LEARN_ACK((byte) 0x03, 4),
28 CO_READY((byte) 0x04, 2),
29 CO_EVENT_SECUREDEVICES((byte) 0x05, 6),
30 CO_DUTYCYCLE_LIMIT((byte) 0x06, 2),
31 CO_TRANSMIT_FAILED((byte) 0x07, 2);
34 private int dataLength;
36 EventMessageType(byte value, int dataLength) {
38 this.dataLength = dataLength;
41 public byte getValue() {
45 public int getDataLength() {
49 public static EventMessageType getEventMessageType(byte value) {
50 return Stream.of(EventMessageType.values()).filter(t -> t.value == value).findFirst().orElse(UNKNOWN);
54 private EventMessageType type;
56 EventMessage(int dataLength, int optionalDataLength, byte[] payload) {
57 super(dataLength, optionalDataLength, ESPPacketType.EVENT, payload);
59 type = EventMessageType.getEventMessageType(payload[0]);
62 public EventMessageType getEventMessageType() {