]> git.basschouten.com Git - openhab-addons.git/blob
2476960a3e45e51e17ca96f7d7b4ddaf752dda93
[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.BlueGigaDeviceResponse;
17
18 /**
19  * Class to implement the BlueGiga command <b>userReadRequestEvent</b>.
20  * <p>
21  * This event is generated when a remote device tries to read an attribute which has the user
22  * property enabled. This event should be responded within 30 seconds with User Read Response
23  * command either containing the data or an error code.
24  * <p>
25  * This class provides methods for processing BlueGiga API commands.
26  * <p>
27  * Note that this code is autogenerated. Manual changes may be overwritten.
28  *
29  * @author Chris Jackson - Initial contribution of Java code generator
30  */
31 @NonNullByDefault
32 public class BlueGigaUserReadRequestEvent extends BlueGigaDeviceResponse {
33     public static int COMMAND_CLASS = 0x02;
34     public static int COMMAND_METHOD = 0x01;
35
36     /**
37      * Attribute handle requested
38      * <p>
39      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
40      */
41     private int handle;
42
43     /**
44      * Attribute offset to send data from
45      * <p>
46      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
47      */
48     private int offset;
49
50     /**
51      * Maximum data size to respond with. If more data is sent than indicated by this parameter, the
52      * extra bytes will be ignored.
53      * <p>
54      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
55      */
56     private int maxsize;
57
58     /**
59      * Event constructor
60      */
61     public BlueGigaUserReadRequestEvent(int[] inputBuffer) {
62         // Super creates deserializer and reads header fields
63         super(inputBuffer);
64
65         event = (inputBuffer[0] & 0x80) != 0;
66
67         // Deserialize the fields
68         connection = deserializeUInt8();
69         handle = deserializeUInt16();
70         offset = deserializeUInt16();
71         maxsize = deserializeUInt8();
72     }
73
74     /**
75      * Attribute handle requested
76      * <p>
77      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
78      *
79      * @return the current handle as {@link int}
80      */
81     public int getHandle() {
82         return handle;
83     }
84
85     /**
86      * Attribute offset to send data from
87      * <p>
88      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
89      *
90      * @return the current offset as {@link int}
91      */
92     public int getOffset() {
93         return offset;
94     }
95
96     /**
97      * Maximum data size to respond with. If more data is sent than indicated by this parameter, the
98      * extra bytes will be ignored.
99      * <p>
100      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
101      *
102      * @return the current maxsize as {@link int}
103      */
104     public int getMaxsize() {
105         return maxsize;
106     }
107
108     @Override
109     public String toString() {
110         final StringBuilder builder = new StringBuilder();
111         builder.append("BlueGigaUserReadRequestEvent [connection=");
112         builder.append(connection);
113         builder.append(", handle=");
114         builder.append(handle);
115         builder.append(", offset=");
116         builder.append(offset);
117         builder.append(", maxsize=");
118         builder.append(maxsize);
119         builder.append(']');
120         return builder.toString();
121     }
122 }