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>setAdvParameters</b>.
21 * This command is used to set the advertising parameters. Example: If the minimum
22 * advertisement interval is 40ms and the maximum advertisement interval is 100ms then the
23 * real advertisement interval will be mostly the middle value (70ms) plus a randomly added
24 * 20ms delay, which needs to be added according to the Bluetooth specification.
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 BlueGigaSetAdvParametersCommand extends BlueGigaCommand {
34 public static int COMMAND_CLASS = 0x06;
35 public static int COMMAND_METHOD = 0x08;
38 * Minimum advertisement interval in units of 625us. Range: 0x20 to 0x4000. Default: 0x200
39 * (320ms) Explanation: 0x200 = 512 512 * 625us = 320000us = 320ms
41 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
43 private int advIntervalMin;
46 * Maximum advertisement interval in units of 625us. Range: 0x20 to 0x4000. Default: 0x200
49 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
51 private int advIntervalMax;
54 * A bit mask to identify which of the three advertisement channels are used. Examples: 0x07:
55 * All three channels are used 0x03: Advertisement channels 37 and 38 are used. 0x04: Only
56 * advertisement channel 39 is used
58 * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
60 private int advChannels;
63 * Minimum advertisement interval in units of 625us. Range: 0x20 to 0x4000. Default: 0x200
64 * (320ms) Explanation: 0x200 = 512 512 * 625us = 320000us = 320ms
66 * @param advIntervalMin the advIntervalMin to set as {@link int}
68 public void setAdvIntervalMin(int advIntervalMin) {
69 this.advIntervalMin = advIntervalMin;
73 * Maximum advertisement interval in units of 625us. Range: 0x20 to 0x4000. Default: 0x200
76 * @param advIntervalMax the advIntervalMax to set as {@link int}
78 public void setAdvIntervalMax(int advIntervalMax) {
79 this.advIntervalMax = advIntervalMax;
83 * A bit mask to identify which of the three advertisement channels are used. Examples: 0x07:
84 * All three channels are used 0x03: Advertisement channels 37 and 38 are used. 0x04: Only
85 * advertisement channel 39 is used
87 * @param advChannels the advChannels to set as {@link int}
89 public void setAdvChannels(int advChannels) {
90 this.advChannels = advChannels;
94 public int[] serialize() {
95 // Serialize the header
96 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
98 // Serialize the fields
99 serializeUInt16(advIntervalMin);
100 serializeUInt16(advIntervalMax);
101 serializeUInt8(advChannels);
107 public String toString() {
108 final StringBuilder builder = new StringBuilder();
109 builder.append("BlueGigaSetAdvParametersCommand [advIntervalMin=");
110 builder.append(advIntervalMin);
111 builder.append(", advIntervalMax=");
112 builder.append(advIntervalMax);
113 builder.append(", advChannels=");
114 builder.append(advChannels);
116 return builder.toString();