]> git.basschouten.com Git - openhab-addons.git/blob
45ff9777ca36d17fc5c9f42bafa02a4549fc57bd
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.bluetooth.bluegiga.internal.command.attributedb;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceCommand;
17
18 /**
19  * Class to implement the BlueGiga command <b>userWriteResponse</b>.
20  * <p>
21  * This command is used by the GATT server to acknowledge to the remote device that the
22  * attribute's value was written. This feature again allows the user application to
23  * acknowledged the attribute write operations instead of the Smart stack doing it
24  * automatically. Bluetooth The command should be used when an event is received where the
25  * reason why value has changed Value corresponds to
26  * attributes_attribute_change_reason_write_request_user. This response must be sent
27  * within 30 seconds or otherwise a timeout will occur.
28  * <p>
29  * This class provides methods for processing BlueGiga API commands.
30  * <p>
31  * Note that this code is autogenerated. Manual changes may be overwritten.
32  *
33  * @author Chris Jackson - Initial contribution of Java code generator
34  */
35 @NonNullByDefault
36 public class BlueGigaUserWriteResponseCommand extends BlueGigaDeviceCommand {
37     public static int COMMAND_CLASS = 0x02;
38     public static int COMMAND_METHOD = 0x04;
39
40     /**
41      * 0: User Read Request is responded with data. In case of an error an application specific error
42      * code can be sent.
43      * <p>
44      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
45      */
46     private int attError;
47
48     /**
49      * 0: User Read Request is responded with data. In case of an error an application specific error
50      * code can be sent.
51      *
52      * @param attError the attError to set as {@link int}
53      */
54     public void setAttError(int attError) {
55         this.attError = attError;
56     }
57
58     @Override
59     public int[] serialize() {
60         // Serialize the header
61         serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
62
63         // Serialize the fields
64         serializeUInt8(connection);
65         serializeUInt8(attError);
66
67         return getPayload();
68     }
69
70     @Override
71     public String toString() {
72         final StringBuilder builder = new StringBuilder();
73         builder.append("BlueGigaUserWriteResponseCommand [connection=");
74         builder.append(connection);
75         builder.append(", attError=");
76         builder.append(attError);
77         builder.append(']');
78         return builder.toString();
79     }
80 }