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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceCommand;
19 * Class to implement the BlueGiga command <b>update</b>.
21 * This command updates the connection parameters of a given connection. The parameters have
22 * the same meaning and follow the same rules as for the GAP class command: Connect Direct. If
23 * this command is issued at a master device, it will send parameter update request to the link
24 * layer. Bluetooth On the other hand if this command is issued at a slave device, it will send
25 * L2CAP connection parameter update request to the master, which may either accept or reject
26 * it. It will take an amount of time corresponding to at least six times the current connection
27 * interval before the new connection parameters will become active.
29 * This class provides methods for processing BlueGiga API commands.
31 * Note that this code is autogenerated. Manual changes may be overwritten.
33 * @author Chris Jackson - Initial contribution of Java code generator
36 public class BlueGigaUpdateCommand extends BlueGigaDeviceCommand {
37 public static int COMMAND_CLASS = 0x03;
38 public static int COMMAND_METHOD = 0x02;
41 * Minimum connection interval (units of 1.25ms)
43 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
45 private int intervalMin;
48 * Maximum connection interval (units of 1.25ms)
50 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
52 private int intervalMax;
55 * Slave latency which defines how many connections intervals a slave may skip.
57 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
62 * Supervision timeout (units of 10ms)
64 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
69 * Minimum connection interval (units of 1.25ms)
71 * @param intervalMin the intervalMin to set as {@link int}
73 public void setIntervalMin(int intervalMin) {
74 this.intervalMin = intervalMin;
78 * Maximum connection interval (units of 1.25ms)
80 * @param intervalMax the intervalMax to set as {@link int}
82 public void setIntervalMax(int intervalMax) {
83 this.intervalMax = intervalMax;
87 * Slave latency which defines how many connections intervals a slave may skip.
89 * @param latency the latency to set as {@link int}
91 public void setLatency(int latency) {
92 this.latency = latency;
96 * Supervision timeout (units of 10ms)
98 * @param timeout the timeout to set as {@link int}
100 public void setTimeout(int timeout) {
101 this.timeout = timeout;
105 public int[] serialize() {
106 // Serialize the header
107 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
109 // Serialize the fields
110 serializeUInt8(connection);
111 serializeUInt16(intervalMin);
112 serializeUInt16(intervalMax);
113 serializeUInt16(latency);
114 serializeUInt16(timeout);
120 public String toString() {
121 final StringBuilder builder = new StringBuilder();
122 builder.append("BlueGigaUpdateCommand [connection=");
123 builder.append(connection);
124 builder.append(", intervalMin=");
125 builder.append(intervalMin);
126 builder.append(", intervalMax=");
127 builder.append(intervalMax);
128 builder.append(", latency=");
129 builder.append(latency);
130 builder.append(", timeout=");
131 builder.append(timeout);
133 return builder.toString();