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.BlueGigaCommand;
19 * Class to implement the BlueGiga command <b>read</b>.
21 * The command reads the given attribute's value from the local database. There is a 32-byte
22 * limit in the amount of data that can be read at a time. In order to read larger values multiple
23 * read commands must be used with the offset properly used.
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 BlueGigaReadCommand extends BlueGigaCommand {
33 public static int COMMAND_CLASS = 0x02;
34 public static int COMMAND_METHOD = 0x01;
37 * Handle of the attribute to read
39 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
44 * Offset to read from. Maximum of 32 bytes can be read at a time.
46 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
51 * Handle of the attribute to read
53 * @param handle the handle to set as {@link int}
55 public void setHandle(int handle) {
60 * Offset to read from. Maximum of 32 bytes can be read at a time.
62 * @param offset the offset to set as {@link int}
64 public void setOffset(int offset) {
69 public int[] serialize() {
70 // Serialize the header
71 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
73 // Serialize the fields
74 serializeUInt16(handle);
75 serializeUInt16(offset);
81 public String toString() {
82 final StringBuilder builder = new StringBuilder();
83 builder.append("BlueGigaReadCommand [handle=");
84 builder.append(handle);
85 builder.append(", offset=");
86 builder.append(offset);
88 return builder.toString();