]> git.basschouten.com Git - openhab-addons.git/blob
d94c0aea3026e0468dafd678f898537acd206160
[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.connection;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaDeviceResponse;
17 import org.openhab.binding.bluetooth.bluegiga.internal.enumeration.BgApiResponse;
18
19 /**
20  * Class to implement the BlueGiga command <b>update</b>.
21  * <p>
22  * This command updates the connection parameters of a given connection. The parameters have
23  * the same meaning and follow the same rules as for the GAP class command: Connect Direct. If
24  * this command is issued at a master device, it will send parameter update request to the link
25  * layer. Bluetooth On the other hand if this command is issued at a slave device, it will send
26  * L2CAP connection parameter update request to the master, which may either accept or reject
27  * it. It will take an amount of time corresponding to at least six times the current connection
28  * interval before the new connection parameters will become active.
29  * <p>
30  * This class provides methods for processing BlueGiga API commands.
31  * <p>
32  * Note that this code is autogenerated. Manual changes may be overwritten.
33  *
34  * @author Chris Jackson - Initial contribution of Java code generator
35  */
36 @NonNullByDefault
37 public class BlueGigaUpdateResponse extends BlueGigaDeviceResponse {
38     public static int COMMAND_CLASS = 0x03;
39     public static int COMMAND_METHOD = 0x02;
40
41     /**
42      * 0 : the update was successful. Non-zero: An error occurred.
43      * <p>
44      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
45      */
46     private BgApiResponse result;
47
48     /**
49      * Response constructor
50      */
51     public BlueGigaUpdateResponse(int[] inputBuffer) {
52         // Super creates deserializer and reads header fields
53         super(inputBuffer);
54
55         event = (inputBuffer[0] & 0x80) != 0;
56
57         // Deserialize the fields
58         connection = deserializeUInt8();
59         result = deserializeBgApiResponse();
60     }
61
62     /**
63      * 0 : the update was successful. Non-zero: An error occurred.
64      * <p>
65      * BlueGiga API type is <i>BgApiResponse</i> - Java type is {@link BgApiResponse}
66      *
67      * @return the current result as {@link BgApiResponse}
68      */
69     public BgApiResponse getResult() {
70         return result;
71     }
72
73     @Override
74     public String toString() {
75         final StringBuilder builder = new StringBuilder();
76         builder.append("BlueGigaUpdateResponse [connection=");
77         builder.append(connection);
78         builder.append(", result=");
79         builder.append(result);
80         builder.append(']');
81         return builder.toString();
82     }
83 }