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.gap;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaCommand;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.GapDiscoverMode;
20 * Class to implement the BlueGiga command <b>discover</b>.
22 * This command starts the GAP discovery procedure to scan for advertising devices i.e. to
23 * perform a device discovery. Scanning parameters can be configured with the Set Scan
24 * Parameters command before issuing this command. To cancel on an ongoing discovery process
25 * use the End Procedure command.
27 * This class provides methods for processing BlueGiga API commands.
29 * Note that this code is autogenerated. Manual changes may be overwritten.
31 * @author Chris Jackson - Initial contribution of Java code generator
34 public class BlueGigaDiscoverCommand extends BlueGigaCommand {
35 public static final int COMMAND_CLASS = 0x06;
36 public static final int COMMAND_METHOD = 0x02;
38 private BlueGigaDiscoverCommand(CommandBuilder builder) {
39 this.mode = builder.mode;
43 * see:GAP Discover Mode.
45 * BlueGiga API type is <i>GapDiscoverMode</i> - Java type is {@link GapDiscoverMode}
47 private GapDiscoverMode mode;
50 public int[] serialize() {
51 // Serialize the header
52 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
54 // Serialize the fields
55 serializeGapDiscoverMode(mode);
61 public String toString() {
62 final StringBuilder builder = new StringBuilder();
63 builder.append("BlueGigaDiscoverCommand [mode=");
66 return builder.toString();
69 public static class CommandBuilder {
70 private GapDiscoverMode mode = GapDiscoverMode.UNKNOWN;
73 * see:GAP Discover Mode.
75 * @param mode the mode to set as {@link GapDiscoverMode}
77 public CommandBuilder withMode(GapDiscoverMode mode) {
82 public BlueGigaDiscoverCommand build() {
83 return new BlueGigaDiscoverCommand(this);