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.attributeclient;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceCommand;
19 * Class to implement the BlueGiga command <b>prepareWrite</b>.
21 * This command will send a prepare write request to a remote device for queued writes. Queued
22 * writes can for example be used to write large attribute values by transmitting the data in
23 * chunks using prepare write command. Once the data has been transmitted with multiple
24 * prepare write commands the write must then be executed or canceled with Execute Write
25 * command, which if acknowledged by the remote device triggers a Procedure Completed event.
27 * This class provides methods for processing BlueGiga API commands.
29 * Note that this code is autogenerated. Manual changes may be overwritten.
31 * @author Chris Jackson - Initial contribution of Java code generator
34 public class BlueGigaPrepareWriteCommand extends BlueGigaDeviceCommand {
35 public static int COMMAND_CLASS = 0x04;
36 public static int COMMAND_METHOD = 0x09;
41 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
43 private int attHandle;
48 * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
53 * Data to write. Maximum amount of data that can be sent in single command is 18 bytes.
55 * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
57 private int[] data = new int[0];
62 * @param attHandle the attHandle to set as {@link int}
64 public void setAttHandle(int attHandle) {
65 this.attHandle = attHandle;
71 * @param offset the offset to set as {@link int}
73 public void setOffset(int offset) {
78 * Data to write. Maximum amount of data that can be sent in single command is 18 bytes.
80 * @param data the data to set as {@link int[]}
82 public void setData(int[] data) {
87 public int[] serialize() {
88 // Serialize the header
89 serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
91 // Serialize the fields
92 serializeUInt8(connection);
93 serializeUInt16(attHandle);
94 serializeUInt16(offset);
95 serializeUInt8Array(data);
101 public String toString() {
102 final StringBuilder builder = new StringBuilder();
103 builder.append("BlueGigaPrepareWriteCommand [connection=");
104 builder.append(connection);
105 builder.append(", attHandle=");
106 builder.append(attHandle);
107 builder.append(", offset=");
108 builder.append(offset);
109 builder.append(", data=");
110 for (int c = 0; c < data.length; c++) {
114 builder.append(String.format("%02X", data[c]));
117 return builder.toString();