2 * Copyright (c) 2010-2022 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.BlueGigaDeviceResponse;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.AttributeChangeReason;
20 * Class to implement the BlueGiga command <b>valueEvent</b>.
22 * This event is produced at the GATT server when a local attribute value was written by a remote
25 * This class provides methods for processing BlueGiga API commands.
27 * Note that this code is autogenerated. Manual changes may be overwritten.
29 * @author Chris Jackson - Initial contribution of Java code generator
32 public class BlueGigaValueEvent extends BlueGigaDeviceResponse {
33 public static int COMMAND_CLASS = 0x02;
34 public static int COMMAND_METHOD = 0x00;
37 * Reason why value has changed see: enum Attribute Change Reason
39 * BlueGiga API type is <i>AttributeChangeReason</i> - Java type is {@link AttributeChangeReason}
41 private AttributeChangeReason reason;
44 * Attribute handle, which was changed
46 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
51 * Offset into attribute value where data starts
53 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
60 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
67 public BlueGigaValueEvent(int[] inputBuffer) {
68 // Super creates deserializer and reads header fields
71 event = (inputBuffer[0] & 0x80) != 0;
73 // Deserialize the fields
74 connection = deserializeUInt8();
75 reason = deserializeAttributeChangeReason();
76 handle = deserializeUInt16();
77 offset = deserializeUInt16();
78 value = deserializeUInt8Array();
82 * Reason why value has changed see: enum Attribute Change Reason
84 * BlueGiga API type is <i>AttributeChangeReason</i> - Java type is {@link AttributeChangeReason}
86 * @return the current reason as {@link AttributeChangeReason}
88 public AttributeChangeReason getReason() {
93 * Attribute handle, which was changed
95 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
97 * @return the current handle as {@link int}
99 public int getHandle() {
104 * Offset into attribute value where data starts
106 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
108 * @return the current offset as {@link int}
110 public int getOffset() {
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("BlueGigaValueEvent [connection=");
129 builder.append(connection);
130 builder.append(", reason=");
131 builder.append(reason);
132 builder.append(", handle=");
133 builder.append(handle);
134 builder.append(", offset=");
135 builder.append(offset);
136 builder.append(", value=");
137 for (int c = 0; c < value.length; c++) {
141 builder.append(String.format("%02X", value[c]));
144 return builder.toString();