]> git.basschouten.com Git - openhab-addons.git/blob
0dc3e8802c97b7cb60569f0c66ecd02d614948cf
[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>connectSelective</b>.
21  * <p>
22  * This command will start the GAP direct connection establishment procedure to a set of
23  * dedicated Bluetooth Smart devices. When this command is issued the the module will enter a
24  * state where it scans connectable Bluetooth advertisement packets from the remote devices
25  * which are registered in the local white list. Upon receiving an advertisement packet from
26  * one of the registered devices, the module will send a connection request to this device, and a
27  * successful connection will produce a connection status event. The connect selective
28  * command can be cancelled with End Procedure command. When in Initiating State there are no
29  * scan response events.
30  * <p>
31  * This class provides methods for processing BlueGiga API commands.
32  * <p>
33  * Note that this code is autogenerated. Manual changes may be overwritten.
34  *
35  * @author Chris Jackson - Initial contribution of Java code generator
36  */
37 @NonNullByDefault
38 public class BlueGigaConnectSelectiveResponse extends BlueGigaResponse {
39     public static int COMMAND_CLASS = 0x06;
40     public static int COMMAND_METHOD = 0x05;
41
42     /**
43      * 0 : procedure was successfully started Non-zero: An error occurred
44      * <p>
45      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
46      */
47     private BgApiResponse result;
48
49     /**
50      * Connection handle that is reserved for new connection
51      * <p>
52      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
53      */
54     private int connectionHandle;
55
56     /**
57      * Response constructor
58      */
59     public BlueGigaConnectSelectiveResponse(int[] inputBuffer) {
60         // Super creates deserializer and reads header fields
61         super(inputBuffer);
62
63         event = (inputBuffer[0] & 0x80) != 0;
64
65         // Deserialize the fields
66         result = deserializeBgApiResponse();
67         connectionHandle = deserializeUInt8();
68     }
69
70     /**
71      * 0 : procedure was successfully started Non-zero: An error occurred
72      * <p>
73      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
74      *
75      * @return the current result as {@link BgApiResponse}
76      */
77     public BgApiResponse getResult() {
78         return result;
79     }
80
81     /**
82      * Connection handle that is reserved for new connection
83      * <p>
84      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
85      *
86      * @return the current connection_handle as {@link int}
87      */
88     public int getConnectionHandle() {
89         return connectionHandle;
90     }
91
92     @Override
93     public String toString() {
94         final StringBuilder builder = new StringBuilder();
95         builder.append("BlueGigaConnectSelectiveResponse [result=");
96         builder.append(result);
97         builder.append(", connectionHandle=");
98         builder.append(connectionHandle);
99         builder.append(']');
100         return builder.toString();
101     }
102 }