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;
19 * @author Daniel Weber - Initial contribution
21 public class Response extends BasePacket {
23 public enum ResponseType {
25 RET_ERROR((byte) 0x01),
26 RET_NOT_SUPPORTED((byte) 0x02),
27 RET_WRONG_PARAM((byte) 0x03),
28 RET_OPERATION_DENIED((byte) 0x04),
29 RET_LOCK_SET((byte) 0x05),
30 RET_BUFFER_TO_SMALL((byte) 0x06),
31 RET_NO_FREE_BUFFER((byte) 0x07),
32 RET_FLASH_HW_ERROR((byte) 0x82),
33 RET_BASEID_OUT_OF_RANGE((byte) 0x90),
34 RET_BASEID_MAX_REACHED((byte) 0x91);
38 ResponseType(byte value) {
42 public byte getValue() {
46 public static ResponseType getResponsetype(byte value) {
47 for (ResponseType t : ResponseType.values()) {
48 if (t.value == value) {
53 throw new InvalidParameterException("Unknown response type");
57 protected ResponseType responseType;
58 protected boolean _isValid = false;
60 public Response(int dataLength, int optionalDataLength, byte[] payload) {
61 super(dataLength, optionalDataLength, ESPPacketType.RESPONSE, payload);
64 responseType = ResponseType.getResponsetype(payload[0]);
65 } catch (Exception e) {
66 responseType = ResponseType.RET_ERROR;
70 public ResponseType getResponseType() {
74 public boolean isOK() {
75 return responseType == ResponseType.RET_OK;
78 public boolean isValid() {