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;
19 * Class to implement the BlueGiga command <b>connectSelective</b>.
21 * This command will start the GAP direct connection establishment procedure to a set of
22 * dedicated Bluetooth Smart devices. When this command is issued the the module will enter a
23 * state where it scans connectable Bluetooth advertisement packets from the remote devices
24 * which are registered in the local white list. Upon receiving an advertisement packet from
25 * one of the registered devices, the module will send a connection request to this device, and a
26 * successful connection will produce a connection status event. The connect selective
27 * command can be cancelled with End Procedure command. When in Initiating State there are no
28 * scan response events.
30 * This class provides methods for processing BlueGiga API commands.
32 * Note that this code is autogenerated. Manual changes may be overwritten.
34 * @author Chris Jackson - Initial contribution of Java code generator
37 public class BlueGigaConnectSelectiveCommand extends BlueGigaCommand {
38 public static int COMMAND_CLASS = 0x06;
39 public static int COMMAND_METHOD = 0x05;
42 * Minimum Connection Interval (in units of 1.25ms). Range: 6 - 3200 The lowest possible
43 * Connection Interval is 7.50ms and the largest is 4000ms.
45 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
47 private int connIntervalMin;
50 * Maximum Connection Interval (in units of 1.25ms). Range: 6 - 3200 Must be equal or bigger than
51 * minimum Connection Interval.
53 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
55 private int connIntervalMax;
58 * Supervision Timeout (in units of 10ms). The Supervision Timeout defines how long the
59 * devices can be out of range before the connection is closed. Range: 10 - 3200 Minimum time for
60 * the Supervision Timeout is 100ms and maximum value is 32000ms. According to the
61 * specification, the Supervision Timeout in milliseconds shall be larger than (1 + latency) *
62 * conn_interval_max * 2, where conn_interval_max is given in milliseconds.
64 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
69 * This parameter configures the slave latency. Slave latency defines how many connection
70 * intervals a slave device can skip. Increasing slave latency will decrease the energy
71 * consumption of the slave in scenarios where slave does not have data to send at every
72 * connection interval. Range: 0 - 500 0 : Slave latency is disabled. Example: Connection
73 * interval is 10ms and slave latency is 9: this means that the slave is allowed to communicate
74 * every 100ms, but it can communicate every 10ms if needed.
76 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
81 * Minimum Connection Interval (in units of 1.25ms). Range: 6 - 3200 The lowest possible
82 * Connection Interval is 7.50ms and the largest is 4000ms.
84 * @param connIntervalMin the connIntervalMin to set as {@link int}
86 public void setConnIntervalMin(int connIntervalMin) {
87 this.connIntervalMin = connIntervalMin;
91 * Maximum Connection Interval (in units of 1.25ms). Range: 6 - 3200 Must be equal or bigger than
92 * minimum Connection Interval.
94 * @param connIntervalMax the connIntervalMax to set as {@link int}
96 public void setConnIntervalMax(int connIntervalMax) {
97 this.connIntervalMax = connIntervalMax;
101 * Supervision Timeout (in units of 10ms). The Supervision Timeout defines how long the
102 * devices can be out of range before the connection is closed. Range: 10 - 3200 Minimum time for
103 * the Supervision Timeout is 100ms and maximum value is 32000ms. According to the
104 * specification, the Supervision Timeout in milliseconds shall be larger than (1 + latency) *
105 * conn_interval_max * 2, where conn_interval_max is given in milliseconds.
107 * @param timeout the timeout to set as {@link int}
109 public void setTimeout(int timeout) {
110 this.timeout = timeout;
114 * This parameter configures the slave latency. Slave latency defines how many connection
115 * intervals a slave device can skip. Increasing slave latency will decrease the energy
116 * consumption of the slave in scenarios where slave does not have data to send at every
117 * connection interval. Range: 0 - 500 0 : Slave latency is disabled. Example: Connection
118 * interval is 10ms and slave latency is 9: this means that the slave is allowed to communicate
119 * every 100ms, but it can communicate every 10ms if needed.
121 * @param latency the latency to set as {@link int}
123 public void setLatency(int latency) {
124 this.latency = latency;
128 public int[] serialize() {
129 // Serialize the header
130 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
132 // Serialize the fields
133 serializeUInt16(connIntervalMin);
134 serializeUInt16(connIntervalMax);
135 serializeUInt16(timeout);
136 serializeUInt16(latency);
142 public String toString() {
143 final StringBuilder builder = new StringBuilder();
144 builder.append("BlueGigaConnectSelectiveCommand [connIntervalMin=");
145 builder.append(connIntervalMin);
146 builder.append(", connIntervalMax=");
147 builder.append(connIntervalMax);
148 builder.append(", timeout=");
149 builder.append(timeout);
150 builder.append(", latency=");
151 builder.append(latency);
153 return builder.toString();