]> git.basschouten.com Git - openhab-addons.git/blob
613b098bf82694463b71b0b7c4446a367d70fc49
[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.attributeclient;
14
15 import java.util.UUID;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceCommand;
19
20 /**
21  * Class to implement the BlueGiga command <b>findByTypeValue</b>.
22  * <p>
23  * This command can be used to find specific attributes on a remote device based on their 16-bit
24  * UUID value and value. The search can be limited by a starting and ending handle values.
25  * <p>
26  * This class provides methods for processing BlueGiga API commands.
27  * <p>
28  * Note that this code is autogenerated. Manual changes may be overwritten.
29  *
30  * @author Chris Jackson - Initial contribution of Java code generator
31  */
32 @NonNullByDefault
33 public class BlueGigaFindByTypeValueCommand extends BlueGigaDeviceCommand {
34     public static int COMMAND_CLASS = 0x04;
35     public static int COMMAND_METHOD = 0x00;
36
37     /**
38      * First requested handle number
39      * <p>
40      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
41      */
42     private int start;
43
44     /**
45      * Last requested handle number
46      * <p>
47      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
48      */
49     private int end;
50
51     /**
52      * 2 octet UUID to find
53      * <p>
54      * BlueGiga API type is <i>uuid</i> - Java type is {@link UUID}
55      */
56     private UUID uuid = new UUID(0, 0);
57
58     /**
59      * Attribute value to find
60      * <p>
61      * BlueGiga API type is <i>uint8array</i> - Java type is {@link int[]}
62      */
63     private int[] value = new int[0];
64
65     /**
66      * First requested handle number
67      *
68      * @param start the start to set as {@link int}
69      */
70     public void setStart(int start) {
71         this.start = start;
72     }
73
74     /**
75      * Last requested handle number
76      *
77      * @param end the end to set as {@link int}
78      */
79     public void setEnd(int end) {
80         this.end = end;
81     }
82
83     /**
84      * 2 octet UUID to find
85      *
86      * @param uuid the uuid to set as {@link UUID}
87      */
88     public void setUuid(UUID uuid) {
89         this.uuid = uuid;
90     }
91
92     /**
93      * Attribute value to find
94      *
95      * @param value the value to set as {@link int[]}
96      */
97     public void setValue(int[] value) {
98         this.value = value;
99     }
100
101     @Override
102     public int[] serialize() {
103         // Serialize the header
104         serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
105
106         // Serialize the fields
107         serializeUInt8(connection);
108         serializeUInt16(start);
109         serializeUInt16(end);
110         serializeUuid(uuid);
111         serializeUInt8Array(value);
112
113         return getPayload();
114     }
115
116     @Override
117     public String toString() {
118         final StringBuilder builder = new StringBuilder();
119         builder.append("BlueGigaFindByTypeValueCommand [connection=");
120         builder.append(connection);
121         builder.append(", start=");
122         builder.append(start);
123         builder.append(", end=");
124         builder.append(end);
125         builder.append(", uuid=");
126         builder.append(uuid);
127         builder.append(", value=");
128         for (int c = 0; c < value.length; c++) {
129             if (c > 0) {
130                 builder.append(' ');
131             }
132             builder.append(String.format("%02X", value[c]));
133         }
134         builder.append(']');
135         return builder.toString();
136     }
137 }