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.connection;
15 import java.util.HashSet;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceResponse;
20 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.BluetoothAddressType;
21 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.ConnectionStatusFlag;
24 * Class to implement the BlueGiga command <b>connectionStatusEvent</b>.
26 * This event indicates the connection status and parameters.
28 * This class provides methods for processing BlueGiga API commands.
30 * Note that this code is autogenerated. Manual changes may be overwritten.
32 * @author Chris Jackson - Initial contribution of Java code generator
35 public class BlueGigaConnectionStatusEvent extends BlueGigaDeviceResponse {
36 public static int COMMAND_CLASS = 0x03;
37 public static int COMMAND_METHOD = 0x00;
40 * Connection status flags use connstatus-enumerator
42 * BlueGiga API type is <i>ConnectionStatusFlag</i> - Java type is {@link ConnectionStatusFlag}
43 * Parameter allows multiple options so implemented as a {@link Set}.
45 private Set<ConnectionStatusFlag> flags = new HashSet<>();
48 * Remote devices Bluetooth address
50 * BlueGiga API type is <i>bd_addr</i> - Java type is {@link String}
52 private String address;
55 * Remote address type see: Bluetooth Address Types--gap
57 * BlueGiga API type is <i>BluetoothAddressType</i> - Java type is {@link BluetoothAddressType}
59 private BluetoothAddressType addressType;
62 * Current connection interval (units of 1.25ms)
64 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
66 private int connInterval;
69 * Current supervision timeout (units of 10ms)
71 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
76 * Slave latency which tells how many connection intervals the slave may skip.
78 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
83 * Bonding handle if the device has been bonded with. Otherwise: 0xFF
85 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
92 public BlueGigaConnectionStatusEvent(int[] inputBuffer) {
93 // Super creates deserializer and reads header fields
96 event = (inputBuffer[0] & 0x80) != 0;
98 // Deserialize the fields
99 connection = deserializeUInt8();
100 flags = deserializeConnectionStatusFlag();
101 address = deserializeAddress();
102 addressType = deserializeBluetoothAddressType();
103 connInterval = deserializeUInt16();
104 timeout = deserializeUInt16();
105 latency = deserializeUInt16();
106 bonding = deserializeUInt8();
110 * Connection status flags use connstatus-enumerator
112 * BlueGiga API type is <i>ConnectionStatusFlag</i> - Java type is {@link ConnectionStatusFlag}
114 * @return the current flags as {@link Set} of {@link ConnectionStatusFlag}
116 public Set<ConnectionStatusFlag> getFlags() {
121 * Remote devices Bluetooth address
123 * BlueGiga API type is <i>bd_addr</i> - Java type is {@link String}
125 * @return the current address as {@link String}
127 public String getAddress() {
132 * Remote address type see: Bluetooth Address Types--gap
134 * BlueGiga API type is <i>BluetoothAddressType</i> - Java type is {@link BluetoothAddressType}
136 * @return the current address_type as {@link BluetoothAddressType}
138 public BluetoothAddressType getAddressType() {
143 * Current connection interval (units of 1.25ms)
145 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
147 * @return the current conn_interval as {@link int}
149 public int getConnInterval() {
154 * Current supervision timeout (units of 10ms)
156 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
158 * @return the current timeout as {@link int}
160 public int getTimeout() {
165 * Slave latency which tells how many connection intervals the slave may skip.
167 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
169 * @return the current latency as {@link int}
171 public int getLatency() {
176 * Bonding handle if the device has been bonded with. Otherwise: 0xFF
178 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
180 * @return the current bonding as {@link int}
182 public int getBonding() {
187 public String toString() {
188 final StringBuilder builder = new StringBuilder();
189 builder.append("BlueGigaConnectionStatusEvent [connection=");
190 builder.append(connection);
191 builder.append(", flags=");
192 builder.append(flags);
193 builder.append(", address=");
194 builder.append(address);
195 builder.append(", addressType=");
196 builder.append(addressType);
197 builder.append(", connInterval=");
198 builder.append(connInterval);
199 builder.append(", timeout=");
200 builder.append(timeout);
201 builder.append(", latency=");
202 builder.append(latency);
203 builder.append(", bonding=");
204 builder.append(bonding);
206 return builder.toString();