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.BlueGigaDeviceCommand;
19 * Class to implement the BlueGiga command <b>readByHandle</b>.
21 * This command reads a remote attribute's value with the given handle. Read by handle can be
22 * used to read attributes up to 22 bytes long. For longer attributes command must be used.
24 * This class provides methods for processing BlueGiga API commands.
26 * Note that this code is autogenerated. Manual changes may be overwritten.
28 * @author Chris Jackson - Initial contribution of Java code generator
29 * @author Pauli Anttila - Added message builder
32 public class BlueGigaReadByHandleCommand extends BlueGigaDeviceCommand {
33 public static final int COMMAND_CLASS = 0x04;
34 public static final int COMMAND_METHOD = 0x04;
36 private BlueGigaReadByHandleCommand(CommandBuilder builder) {
37 super.setConnection(builder.connection);
38 this.chrHandle = builder.chrHandle;
44 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
46 private int chrHandle;
49 public int[] serialize() {
50 // Serialize the header
51 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
53 // Serialize the fields
54 serializeUInt8(connection);
55 serializeUInt16(chrHandle);
61 public String toString() {
62 final StringBuilder builder = new StringBuilder();
63 builder.append("BlueGigaReadByHandleCommand [connection=");
64 builder.append(connection);
65 builder.append(", chrHandle=");
66 builder.append(chrHandle);
68 return builder.toString();
71 public static class CommandBuilder {
72 private int connection;
73 private int chrHandle;
76 * Set connection handle.
78 * @param connection the connection to set as {@link int}
80 public CommandBuilder withConnection(int connection) {
81 this.connection = connection;
88 * @param chrHandle the chrHandle to set as {@link int}
90 public CommandBuilder withChrHandle(int chrHandle) {
91 this.chrHandle = chrHandle;
95 public BlueGigaReadByHandleCommand build() {
96 return new BlueGigaReadByHandleCommand(this);