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.BlueGigaDeviceCommand;
19 * Class to implement the BlueGiga command <b>userReadResponse</b>.
21 * This command is used to respond to an attribute Read request by a remote device, but only for
22 * attributes which have been configured with the user property. Attributes which have the
23 * user property enabled allow the attribute value to be requested from the application
24 * instead of the Smart stack automatically responding with Bluetooth the data in it's local
25 * GATT database. This command is normally used in response to a User Read Request event, which
26 * is generated when a remote device tries to read an attribute with a user property enabled. The
27 * response to User Read Request events must happen within 30 seconds or otherwise a timeout
30 * This class provides methods for processing BlueGiga API commands.
32 * Note that this code is autogenerated. Manual changes may be overwritten.
34 * @author Chris Jackson - Initial contribution of Java code generator
37 public class BlueGigaUserReadResponseCommand extends BlueGigaDeviceCommand {
38 public static int COMMAND_CLASS = 0x02;
39 public static int COMMAND_METHOD = 0x03;
42 * 0: User Read Request is responded with data. In case of an error an application specific error
45 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
52 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
54 private int[] value = new int[0];
57 * 0: User Read Request is responded with data. In case of an error an application specific error
60 * @param attError the attError to set as {@link int}
62 public void setAttError(int attError) {
63 this.attError = attError;
69 * @param value the value to set as {@link int[]}
71 public void setValue(int[] value) {
76 public int[] serialize() {
77 // Serialize the header
78 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
80 // Serialize the fields
81 serializeUInt8(connection);
82 serializeUInt8(attError);
83 serializeUInt8Array(value);
89 public String toString() {
90 final StringBuilder builder = new StringBuilder();
91 builder.append("BlueGigaUserReadResponseCommand [connection=");
92 builder.append(connection);
93 builder.append(", attError=");
94 builder.append(attError);
95 builder.append(", value=");
96 for (int c = 0; c < value.length; c++) {
100 builder.append(String.format("%02X", value[c]));
103 return builder.toString();