2 * Copyright (c) 2010-2024 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;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * @author Daniel Weber - Initial contribution
24 public class EventMessage extends BasePacket {
26 public enum EventMessageType {
27 UNKNOWN((byte) 0x00, 1),
28 SA_RECLAIM_NOT_SUCCESSFUL((byte) 0x01, 1),
29 SA_CONFIRM_LEARN((byte) 0x02, 17),
30 SA_LEARN_ACK((byte) 0x03, 4),
31 CO_READY((byte) 0x04, 2),
32 CO_EVENT_SECUREDEVICES((byte) 0x05, 6),
33 CO_DUTYCYCLE_LIMIT((byte) 0x06, 2),
34 CO_TRANSMIT_FAILED((byte) 0x07, 2);
37 private int dataLength;
39 EventMessageType(byte value, int dataLength) {
41 this.dataLength = dataLength;
44 public byte getValue() {
48 public int getDataLength() {
52 public static EventMessageType getEventMessageType(byte value) {
53 return Stream.of(EventMessageType.values()).filter(t -> t.value == value).findFirst().orElse(UNKNOWN);
57 private EventMessageType type;
59 EventMessage(int dataLength, int optionalDataLength, byte[] payload) {
60 super(dataLength, optionalDataLength, ESPPacketType.EVENT, payload);
62 type = EventMessageType.getEventMessageType(payload[0]);
65 public EventMessageType getEventMessageType() {