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.bluetooth.bluegiga.internal.command.attributedb;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaResponse;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.BgApiResponse;
20 * Class to implement the BlueGiga command <b>read</b>.
22 * The command reads the given attribute's value from the local database. There is a 32-byte
23 * limit in the amount of data that can be read at a time. In order to read larger values multiple
24 * read commands must be used with the offset properly used.
26 * This class provides methods for processing BlueGiga API commands.
28 * Note that this code is autogenerated. Manual changes may be overwritten.
30 * @author Chris Jackson - Initial contribution of Java code generator
33 public class BlueGigaReadResponse extends BlueGigaResponse {
34 public static final int COMMAND_CLASS = 0x02;
35 public static final int COMMAND_METHOD = 0x01;
38 * Handle of the attribute which was read
40 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
47 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
52 * 0 : the command was successful. Otherwise an error occurred
54 * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
56 private BgApiResponse result;
59 * Value of the attribute
61 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
66 * Response constructor
68 public BlueGigaReadResponse(int[] inputBuffer) {
69 // Super creates deserializer and reads header fields
72 event = (inputBuffer[0] & 0x80) != 0;
74 // Deserialize the fields
75 handle = deserializeUInt16();
76 offset = deserializeUInt16();
77 result = deserializeBgApiResponse();
78 value = deserializeUInt8Array();
82 * Handle of the attribute which was read
84 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
86 * @return the current handle as {@link int}
88 public int getHandle() {
95 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
97 * @return the current offset as {@link int}
99 public int getOffset() {
104 * 0 : the command was successful. Otherwise an error occurred
106 * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
108 * @return the current result as {@link BgApiResponse}
110 public BgApiResponse getResult() {
115 * Value of the attribute
117 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
119 * @return the current value as {@link int[]}
121 public int[] getValue() {
126 public String toString() {
127 final StringBuilder builder = new StringBuilder();
128 builder.append("BlueGigaReadResponse [handle=");
129 builder.append(handle);
130 builder.append(", offset=");
131 builder.append(offset);
132 builder.append(", result=");
133 builder.append(result);
134 builder.append(", value=");
135 for (int c = 0; c < value.length; c++) {
139 builder.append(String.format("%02X", value[c]));
142 return builder.toString();