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.BlueGigaResponse;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.BgApiResponse;
20 * Class to implement the BlueGiga command <b>connectDirect</b>.
22 * This command will start the GAP direct connection establishment procedure to a dedicated
23 * Smart Bluetooth device. The module will enter a state where it continuously scans for the
24 * connectable advertisement packets Bluetooth from the remote device which matches the
25 * Bluetooth address gives as a parameter. Upon receiving the advertisement packet, the
26 * module will send a connection request packet to the target device to imitate a Bluetooth
27 * connection. A successful connection will be indicated by an event. Status If the device is
28 * configured to support more than one connection, the smallest connection interval which is
29 * divisible by maximum_connections * 2.5ms will be selected. Thus, it is important to provide
30 * minimum and maximum connection intervals so that such a connection interval is available
31 * within the range. The connection establishment procedure can be cancelled with End
34 * This class provides methods for processing BlueGiga API commands.
36 * Note that this code is autogenerated. Manual changes may be overwritten.
38 * @author Chris Jackson - Initial contribution of Java code generator
41 public class BlueGigaConnectDirectResponse extends BlueGigaResponse {
42 public static int COMMAND_CLASS = 0x06;
43 public static int COMMAND_METHOD = 0x03;
46 * 0 : procedure was successfully started Non-zero: An error occurred
48 * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
50 private BgApiResponse result;
53 * Connection handle that is reserved for new connection
55 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
57 private int connectionHandle;
60 * Response constructor
62 public BlueGigaConnectDirectResponse(int[] inputBuffer) {
63 // Super creates deserializer and reads header fields
66 event = (inputBuffer[0] & 0x80) != 0;
68 // Deserialize the fields
69 result = deserializeBgApiResponse();
70 connectionHandle = deserializeUInt8();
74 * 0 : procedure was successfully started Non-zero: An error occurred
76 * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
78 * @return the current result as {@link BgApiResponse}
80 public BgApiResponse getResult() {
85 * Connection handle that is reserved for new connection
87 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
89 * @return the current connection_handle as {@link int}
91 public int getConnectionHandle() {
92 return connectionHandle;
96 public String toString() {
97 final StringBuilder builder = new StringBuilder();
98 builder.append("BlueGigaConnectDirectResponse [result=");
99 builder.append(result);
100 builder.append(", connectionHandle=");
101 builder.append(connectionHandle);
103 return builder.toString();