]> git.basschouten.com Git - openhab-addons.git/blob
8abcc72e9e974fa4e7938850c8b1400aac0cdc9d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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>readByType</b>.
22  * <p>
23  * The command reads the value of each attribute of a given type (UUID) and in a given attribute
24  * handle range. The command can for example be used to discover the characteristic
25  * declarations (UUID: 0x2803) within a service.
26  * <p>
27  * This class provides methods for processing BlueGiga API commands.
28  * <p>
29  * Note that this code is autogenerated. Manual changes may be overwritten.
30  *
31  * @author Chris Jackson - Initial contribution of Java code generator
32  */
33 @NonNullByDefault
34 public class BlueGigaReadByTypeCommand extends BlueGigaDeviceCommand {
35     public static int COMMAND_CLASS = 0x04;
36     public static int COMMAND_METHOD = 0x02;
37
38     /**
39      * First attribute handle
40      * <p>
41      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
42      */
43     private int start;
44
45     /**
46      * Last attribute handle
47      * <p>
48      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
49      */
50     private int end;
51
52     /**
53      * Attribute type (UUID)
54      * <p>
55      * BlueGiga API type is <i>uuid</i> - Java type is {@link UUID}
56      */
57     private UUID uuid = new UUID(0, 0);
58
59     /**
60      * First attribute handle
61      *
62      * @param start the start to set as {@link int}
63      */
64     public void setStart(int start) {
65         this.start = start;
66     }
67
68     /**
69      * Last attribute handle
70      *
71      * @param end the end to set as {@link int}
72      */
73     public void setEnd(int end) {
74         this.end = end;
75     }
76
77     /**
78      * Attribute type (UUID)
79      *
80      * @param uuid the uuid to set as {@link UUID}
81      */
82     public void setUuid(UUID uuid) {
83         this.uuid = uuid;
84     }
85
86     @Override
87     public int[] serialize() {
88         // Serialize the header
89         serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
90
91         // Serialize the fields
92         serializeUInt8(connection);
93         serializeUInt16(start);
94         serializeUInt16(end);
95         serializeUuid(uuid);
96
97         return getPayload();
98     }
99
100     @Override
101     public String toString() {
102         final StringBuilder builder = new StringBuilder();
103         builder.append("BlueGigaReadByTypeCommand [connection=");
104         builder.append(connection);
105         builder.append(", start=");
106         builder.append(start);
107         builder.append(", end=");
108         builder.append(end);
109         builder.append(", uuid=");
110         builder.append(uuid);
111         builder.append(']');
112         return builder.toString();
113     }
114 }