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.BluetoothAddressType;
18 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.ScanResponseType;
21 * Class to implement the BlueGiga command <b>scanResponseEvent</b>.
23 * This is a scan response event. This event is normally received by a Master which is scanning
24 * for advertisement and scan response packets from Slaves.
26 * This class provides methods for processing BlueGiga API commands.
28 * Note that this code is autogenerated. Manual changes may be overwritten.
30 * @author Chris Jackson - Initial contribution of Java code generator
33 public class BlueGigaScanResponseEvent extends BlueGigaResponse {
34 public static final int COMMAND_CLASS = 0x06;
35 public static final int COMMAND_METHOD = 0x00;
38 * RSSI value (dBm). Range: -103 to -38
40 * BlueGiga API type is <i>int8</i> - Java type is {@link int}
45 * Scan response header. 0: Connectable Advertisement packet. 2: Non Connectable
46 * Advertisement packet. 4: Scan response packet. 6: Discoverable advertisement packet
48 * BlueGiga API type is <i>ScanResponseType</i> - Java type is {@link ScanResponseType}
50 private ScanResponseType packetType;
55 * BlueGiga API type is <i>bd_addr</i> - Java type is {@link String}
57 private String sender;
60 * Advertiser address type. 1: random address. 0: public address
62 * BlueGiga API type is <i>BluetoothAddressType</i> - Java type is {@link BluetoothAddressType}
64 private BluetoothAddressType addressType;
67 * Bond handle if there is known bond for this device, 0xff otherwise
69 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
76 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
83 public BlueGigaScanResponseEvent(int[] inputBuffer) {
84 // Super creates deserializer and reads header fields
87 event = (inputBuffer[0] & 0x80) != 0;
89 // Deserialize the fields
90 rssi = deserializeInt8();
91 packetType = deserializeScanResponseType();
92 sender = deserializeAddress();
93 addressType = deserializeBluetoothAddressType();
94 bond = deserializeUInt8();
95 data = deserializeUInt8Array();
99 * RSSI value (dBm). Range: -103 to -38
101 * BlueGiga API type is <i>int8</i> - Java type is {@link int}
103 * @return the current rssi as {@link int}
105 public int getRssi() {
110 * Scan response header. 0: Connectable Advertisement packet. 2: Non Connectable
111 * Advertisement packet. 4: Scan response packet. 6: Discoverable advertisement packet
113 * BlueGiga API type is <i>ScanResponseType</i> - Java type is {@link ScanResponseType}
115 * @return the current packet_type as {@link ScanResponseType}
117 public ScanResponseType getPacketType() {
122 * Advertisers address
124 * BlueGiga API type is <i>bd_addr</i> - Java type is {@link String}
126 * @return the current sender as {@link String}
128 public String getSender() {
133 * Advertiser address type. 1: random address. 0: public address
135 * BlueGiga API type is <i>BluetoothAddressType</i> - Java type is {@link BluetoothAddressType}
137 * @return the current address_type as {@link BluetoothAddressType}
139 public BluetoothAddressType getAddressType() {
144 * Bond handle if there is known bond for this device, 0xff otherwise
146 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
148 * @return the current bond as {@link int}
150 public int getBond() {
157 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
159 * @return the current data as {@link int[]}
161 public int[] getData() {
166 public String toString() {
167 final StringBuilder builder = new StringBuilder();
168 builder.append("BlueGigaScanResponseEvent [rssi=");
169 builder.append(rssi);
170 builder.append(", packetType=");
171 builder.append(packetType);
172 builder.append(", sender=");
173 builder.append(sender);
174 builder.append(", addressType=");
175 builder.append(addressType);
176 builder.append(", bond=");
177 builder.append(bond);
178 builder.append(", data=");
179 for (int c = 0; c < data.length; c++) {
183 builder.append(String.format("%02X", data[c]));
186 return builder.toString();