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.responses;
15 import java.util.Arrays;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.enocean.internal.messages.Response;
19 import org.openhab.core.util.HexUtils;
23 * @author Daniel Weber - Initial contribution
26 public class RDVersionResponse extends Response {
28 protected String appVersion = "";
29 protected String apiVersion = "";
30 protected String chipId = "";
31 protected String description = "";
33 public RDVersionResponse(Response response) {
34 this(response.getPayload().length, 0, response.getPayload());
37 RDVersionResponse(int dataLength, int optionalDataLength, byte[] payload) {
38 super(dataLength, optionalDataLength, payload);
40 if (payload.length < 33) {
45 appVersion = String.format("%d.%d.%d.%d", payload[1] & 0xff, payload[2] & 0xff, payload[3] & 0xff,
47 apiVersion = String.format("%d.%d.%d.%d", payload[5] & 0xff, payload[6] & 0xff, payload[7] & 0xff,
50 chipId = HexUtils.bytesToHex(Arrays.copyOfRange(payload, 9, 13));
52 StringBuffer sb = new StringBuffer();
53 for (int i = 17; i < payload.length; i++) {
54 sb.append((char) (payload[i] & 0xff));
56 description = sb.toString();
59 } catch (Exception e) {
60 responseType = ResponseType.RET_ERROR;
64 public String getAPPVersion() {
68 public String getAPIVersion() {
72 public String getChipID() {
76 public String getDescription() {