]> git.basschouten.com Git - openhab-addons.git/blob
bea53adb04d3d0e22bfb130fd8736749a21c9536
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.bluetooth.bluegiga.internal.command.gap;
14
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;
18
19 /**
20  * Class to implement the BlueGiga command <b>connectDirect</b>.
21  * <p>
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
32  * Procedure command.
33  * <p>
34  * This class provides methods for processing BlueGiga API commands.
35  * <p>
36  * Note that this code is autogenerated. Manual changes may be overwritten.
37  *
38  * @author Chris Jackson - Initial contribution of Java code generator
39  */
40 @NonNullByDefault
41 public class BlueGigaConnectDirectResponse extends BlueGigaResponse {
42     public static final int COMMAND_CLASS = 0x06;
43     public static final int COMMAND_METHOD = 0x03;
44
45     /**
46      * 0 : procedure was successfully started Non-zero: An error occurred
47      * <p>
48      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
49      */
50     private BgApiResponse result;
51
52     /**
53      * Connection handle that is reserved for new connection
54      * <p>
55      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
56      */
57     private int connectionHandle;
58
59     /**
60      * Response constructor
61      */
62     public BlueGigaConnectDirectResponse(int[] inputBuffer) {
63         // Super creates deserializer and reads header fields
64         super(inputBuffer);
65
66         event = (inputBuffer[0] & 0x80) != 0;
67
68         // Deserialize the fields
69         result = deserializeBgApiResponse();
70         connectionHandle = deserializeUInt8();
71     }
72
73     /**
74      * 0 : procedure was successfully started Non-zero: An error occurred
75      * <p>
76      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
77      *
78      * @return the current result as {@link BgApiResponse}
79      */
80     public BgApiResponse getResult() {
81         return result;
82     }
83
84     /**
85      * Connection handle that is reserved for new connection
86      * <p>
87      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
88      *
89      * @return the current connection_handle as {@link int}
90      */
91     public int getConnectionHandle() {
92         return connectionHandle;
93     }
94
95     @Override
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);
102         builder.append(']');
103         return builder.toString();
104     }
105 }