2 * Copyright (c) 2010-2023 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.security.InvalidParameterException;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * @author Daniel Weber - Initial contribution
24 public class Response extends BasePacket {
26 public enum ResponseType {
28 RET_ERROR((byte) 0x01),
29 RET_NOT_SUPPORTED((byte) 0x02),
30 RET_WRONG_PARAM((byte) 0x03),
31 RET_OPERATION_DENIED((byte) 0x04),
32 RET_LOCK_SET((byte) 0x05),
33 RET_BUFFER_TO_SMALL((byte) 0x06),
34 RET_NO_FREE_BUFFER((byte) 0x07),
35 RET_FLASH_HW_ERROR((byte) 0x82),
36 RET_BASEID_OUT_OF_RANGE((byte) 0x90),
37 RET_BASEID_MAX_REACHED((byte) 0x91);
41 ResponseType(byte value) {
45 public byte getValue() {
49 public static ResponseType getResponsetype(byte value) {
50 for (ResponseType t : ResponseType.values()) {
51 if (t.value == value) {
56 throw new InvalidParameterException("Unknown response type");
60 protected ResponseType responseType;
61 protected boolean isValid = false;
63 public Response(int dataLength, int optionalDataLength, byte[] payload) {
64 super(dataLength, optionalDataLength, ESPPacketType.RESPONSE, payload);
67 responseType = ResponseType.getResponsetype(payload[0]);
68 } catch (Exception e) {
69 responseType = ResponseType.RET_ERROR;
73 public ResponseType getResponseType() {
77 public boolean isOK() {
78 return responseType == ResponseType.RET_OK;
81 public boolean isValid() {