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.attributeclient;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceResponse;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.AttributeValueType;
20 * Class to implement the BlueGiga command <b>attributeValueEvent</b>.
22 * This event is produced at the GATT client side when an attribute value is passed from the GATT
23 * server to the GATT client. This event is for example produced after a successful Read by
24 * Handle operation or when an attribute is indicated or notified by the remote device.
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 BlueGigaAttributeValueEvent extends BlueGigaDeviceResponse {
34 public static int COMMAND_CLASS = 0x04;
35 public static int COMMAND_METHOD = 0x05;
40 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
42 private int attHandle;
47 * BlueGiga API type is <i>AttributeValueType</i> - Java type is {@link AttributeValueType}
49 private AttributeValueType type;
52 * Attribute value (data)
54 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
61 public BlueGigaAttributeValueEvent(int[] inputBuffer) {
62 // Super creates deserializer and reads header fields
65 event = (inputBuffer[0] & 0x80) != 0;
67 // Deserialize the fields
68 connection = deserializeUInt8();
69 attHandle = deserializeUInt16();
70 type = deserializeAttributeValueType();
71 value = deserializeUInt8Array();
77 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
79 * @return the current att_handle as {@link int}
81 public int getAttHandle() {
88 * BlueGiga API type is <i>AttributeValueType</i> - Java type is {@link AttributeValueType}
90 * @return the current type as {@link AttributeValueType}
92 public AttributeValueType getType() {
97 * Attribute value (data)
99 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
101 * @return the current value as {@link int[]}
103 public int[] getValue() {
108 public String toString() {
109 final StringBuilder builder = new StringBuilder();
110 builder.append("BlueGigaAttributeValueEvent [connection=");
111 builder.append(connection);
112 builder.append(", attHandle=");
113 builder.append(attHandle);
114 builder.append(", type=");
115 builder.append(type);
116 builder.append(", value=");
117 for (int c = 0; c < value.length; c++) {
121 builder.append(String.format("%02X", value[c]));
124 return builder.toString();