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>setAdvData</b>.
21 * This commands set advertisement or scan response data used in the advertisement and scan
22 * response packets. The command allows application specific data to be broadcasts either in
23 * advertisement or scan response packets. The data set with this command is only used when the
24 * GAP discoverable mode is set to gap_user_data. Notice that advertisement or scan response
25 * data must be formatted in accordance to the Bluetooth Core Specification. See BLUETOOTH
26 * SPECIFICATION Version 4.0 [Vol 3 - Part C - Chapter 11].
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 BlueGigaSetAdvDataCommand extends BlueGigaCommand {
36 public static final int COMMAND_CLASS = 0x06;
37 public static final int COMMAND_METHOD = 0x09;
40 * Advertisement data type. 0 : sets advertisement data. 1 : sets scan response data
42 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
44 private int setScanrsp;
47 * Advertisement data to send
49 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
51 private int[] advData = new int[0];
54 * Advertisement data type. 0 : sets advertisement data. 1 : sets scan response data
56 * @param setScanrsp the setScanrsp to set as {@link int}
58 public void setSetScanrsp(int setScanrsp) {
59 this.setScanrsp = setScanrsp;
63 * Advertisement data to send
65 * @param advData the advData to set as {@link int[]}
67 public void setAdvData(int[] advData) {
68 this.advData = advData;
72 public int[] serialize() {
73 // Serialize the header
74 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
76 // Serialize the fields
77 serializeUInt8(setScanrsp);
78 serializeUInt8Array(advData);
84 public String toString() {
85 final StringBuilder builder = new StringBuilder();
86 builder.append("BlueGigaSetAdvDataCommand [setScanrsp=");
87 builder.append(setScanrsp);
88 builder.append(", advData=");
89 for (int c = 0; c < advData.length; c++) {
93 builder.append(String.format("%02X", advData[c]));
96 return builder.toString();