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 java.util.UUID;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceCommand;
21 * Class to implement the BlueGiga command <b>readByGroupType</b>.
23 * This command reads the value of each attribute of a given type and in a given handle range. The
24 * command is typically used for primary (UUID: 0x2800) and secondary (UUID: 0x2801) service
25 * discovery. Discovered services are reported by Group Found event. Finally when the
26 * procedure is completed a Procedure Completed event is generated.
28 * This class provides methods for processing BlueGiga API commands.
30 * Note that this code is autogenerated. Manual changes may be overwritten.
32 * @author Chris Jackson - Initial contribution of Java code generator
33 * @author Pauli Anttila - Added message builder
36 public class BlueGigaReadByGroupTypeCommand extends BlueGigaDeviceCommand {
37 public static int COMMAND_CLASS = 0x04;
38 public static int COMMAND_METHOD = 0x01;
40 private BlueGigaReadByGroupTypeCommand(CommandBuilder builder) {
41 super.setConnection(builder.connection);
42 this.start = builder.start;
43 this.end = builder.end;
44 this.uuid = builder.uuid;
48 * First requested handle number
50 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
55 * Last requested handle number
57 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
64 * BlueGiga API type is <i>uuid</i> - Java type is {@link UUID}
69 public int[] serialize() {
70 // Serialize the header
71 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
73 // Serialize the fields
74 serializeUInt8(connection);
75 serializeUInt16(start);
83 public String toString() {
84 final StringBuilder builder = new StringBuilder();
85 builder.append("BlueGigaReadByGroupTypeCommand [connection=");
86 builder.append(connection);
87 builder.append(", start=");
88 builder.append(start);
89 builder.append(", end=");
91 builder.append(", uuid=");
94 return builder.toString();
97 public static class CommandBuilder {
98 private int connection;
101 private UUID uuid = new UUID(0, 0);
104 * Set connection handle.
106 * @param connection the connection to set as {@link int}
108 public CommandBuilder withConnection(int connection) {
109 this.connection = connection;
114 * First requested handle number
116 * @param start the start to set as {@link int}
118 public CommandBuilder withStart(int start) {
124 * Last requested handle number
126 * @param end the end to set as {@link int}
128 public CommandBuilder withEnd(int end) {
136 * @param uuid the uuid to set as {@link UUID}
138 public CommandBuilder withUuid(UUID uuid) {
143 public BlueGigaReadByGroupTypeCommand build() {
144 return new BlueGigaReadByGroupTypeCommand(this);