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.NonNull;
18 import org.openhab.binding.enocean.internal.messages.Response;
19 import org.openhab.core.util.HexUtils;
23 * @author Daniel Weber - Initial contribution
25 public class RDVersionResponse extends Response {
27 protected String appVersion = "";
28 protected String apiVersion = "";
29 protected String chipId = "";
30 protected String description = "";
32 public RDVersionResponse(Response response) {
33 this(response.getPayload().length, 0, response.getPayload());
36 RDVersionResponse(int dataLength, int optionalDataLength, byte[] payload) {
37 super(dataLength, optionalDataLength, payload);
39 if (payload.length < 33) {
44 appVersion = String.format("%d.%d.%d.%d", payload[1] & 0xff, payload[2] & 0xff, payload[3] & 0xff,
46 apiVersion = String.format("%d.%d.%d.%d", payload[5] & 0xff, payload[6] & 0xff, payload[7] & 0xff,
49 chipId = HexUtils.bytesToHex(Arrays.copyOfRange(payload, 9, 13));
51 StringBuffer sb = new StringBuffer();
52 for (int i = 17; i < payload.length; i++) {
53 sb.append((char) (payload[i] & 0xff));
55 description = sb.toString();
58 } catch (Exception e) {
59 responseType = ResponseType.RET_ERROR;
64 public String getAPPVersion() {
69 public String getAPIVersion() {
74 public String getChipID() {
79 public String getDescription() {