2 * Copyright (c) 2010-2020 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.Arrays;
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.openhab.core.util.HexUtils;
22 * @author Daniel Weber - Initial contribution
24 public class RDVersionResponse extends Response {
26 protected String appVersion = "";
27 protected String apiVersion = "";
28 protected String chipId = "";
29 protected String description = "";
31 public RDVersionResponse(Response response) {
32 this(response.getPayload().length, 0, response.getPayload());
35 RDVersionResponse(int dataLength, int optionalDataLength, byte[] payload) {
36 super(dataLength, optionalDataLength, payload);
38 if (payload.length < 33) {
43 appVersion = String.format("%d.%d.%d.%d", payload[1] & 0xff, payload[2] & 0xff, payload[3] & 0xff,
45 apiVersion = String.format("%d.%d.%d.%d", payload[5] & 0xff, payload[6] & 0xff, payload[7] & 0xff,
48 chipId = HexUtils.bytesToHex(Arrays.copyOfRange(payload, 9, 13));
50 StringBuffer sb = new StringBuffer();
51 for (int i = 17; i < payload.length; i++) {
52 sb.append((char) (payload[i] & 0xff));
54 description = sb.toString();
57 } catch (Exception e) {
58 responseType = ResponseType.RET_ERROR;
63 public String getAPPVersion() {
68 public String getAPIVersion() {
73 public String getChipID() {
78 public String getDescription() {