]> git.basschouten.com Git - openhab-addons.git/blob
5e17a7fdb820f269288c39425a8af810d748a293
[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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceCommand;
17
18 /**
19  * Class to implement the BlueGiga command <b>readLong</b>.
20  * <p>
21  * This command can be used to read long attribute values, which are longer than 22 bytes and
22  * cannot be read with a simple Read by Handle command. The command starts a procedure, where the
23  * client first sends a normal read command to the server and if the returned attribute value
24  * length is equal to MTU, the client will send further read long read requests until rest of the
25  * attribute is read.
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 BlueGigaReadLongCommand extends BlueGigaDeviceCommand {
35     public static int COMMAND_CLASS = 0x04;
36     public static int COMMAND_METHOD = 0x08;
37
38     /**
39      * Attribute handle
40      * <p>
41      * BlueGiga API type is <i>uint16</i> - Java type is {@link int}
42      */
43     private int chrHandle;
44
45     /**
46      * Attribute handle
47      *
48      * @param chrHandle the chrHandle to set as {@link int}
49      */
50     public void setChrHandle(int chrHandle) {
51         this.chrHandle = chrHandle;
52     }
53
54     @Override
55     public int[] serialize() {
56         // Serialize the header
57         serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
58
59         // Serialize the fields
60         serializeUInt8(connection);
61         serializeUInt16(chrHandle);
62
63         return getPayload();
64     }
65
66     @Override
67     public String toString() {
68         final StringBuilder builder = new StringBuilder();
69         builder.append("BlueGigaReadLongCommand [connection=");
70         builder.append(connection);
71         builder.append(", chrHandle=");
72         builder.append(chrHandle);
73         builder.append(']');
74         return builder.toString();
75     }
76 }