]> git.basschouten.com Git - openhab-addons.git/blob
abf10bc9af7666f55a68a7e7b7fb7d9350c1b904
[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.BlueGigaResponse;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.BgApiResponse;
18
19 /**
20  * Class to implement the BlueGiga command <b>readType</b>.
21  * <p>
22  * This command reads the given attribute's type (UUID) from the local database.
23  * <p>
24  * This class provides methods for processing BlueGiga API commands.
25  * <p>
26  * Note that this code is autogenerated. Manual changes may be overwritten.
27  *
28  * @author Chris Jackson - Initial contribution of Java code generator
29  */
30 @NonNullByDefault
31 public class BlueGigaReadTypeResponse extends BlueGigaResponse {
32     public static final int COMMAND_CLASS = 0x02;
33     public static final int COMMAND_METHOD = 0x02;
34
35     /**
36      * Handle of the attribute which was read
37      * <p>
38      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
39      */
40     private int handle;
41
42     /**
43      * 0 : the command was successful. Otherwise an error occurred
44      * <p>
45      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
46      */
47     private BgApiResponse result;
48
49     /**
50      * Value of the attribute type (UUID)
51      * <p>
52      * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
53      */
54     private int[] value;
55
56     /**
57      * Response constructor
58      */
59     public BlueGigaReadTypeResponse(int[] inputBuffer) {
60         // Super creates deserializer and reads header fields
61         super(inputBuffer);
62
63         event = (inputBuffer[0] & 0x80) != 0;
64
65         // Deserialize the fields
66         handle = deserializeUInt16();
67         result = deserializeBgApiResponse();
68         value = deserializeUInt8Array();
69     }
70
71     /**
72      * Handle of the attribute which was read
73      * <p>
74      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
75      *
76      * @return the current handle as {@link int}
77      */
78     public int getHandle() {
79         return handle;
80     }
81
82     /**
83      * 0 : the command was successful. Otherwise an error occurred
84      * <p>
85      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
86      *
87      * @return the current result as {@link BgApiResponse}
88      */
89     public BgApiResponse getResult() {
90         return result;
91     }
92
93     /**
94      * Value of the attribute type (UUID)
95      * <p>
96      * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
97      *
98      * @return the current value as {@link int[]}
99      */
100     public int[] getValue() {
101         return value;
102     }
103
104     @Override
105     public String toString() {
106         final StringBuilder builder = new StringBuilder();
107         builder.append("BlueGigaReadTypeResponse [handle=");
108         builder.append(handle);
109         builder.append(", result=");
110         builder.append(result);
111         builder.append(", value=");
112         for (int c = 0; c < value.length; c++) {
113             if (c > 0) {
114                 builder.append(' ');
115             }
116             builder.append(String.format("%02X", value[c]));
117         }
118         builder.append(']');
119         return builder.toString();
120     }
121 }