]> git.basschouten.com Git - openhab-addons.git/blob
ed60b6a0d54b601894d375913c8bfaee4244cb55
[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.security;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.bluegiga.internal.BlueGigaCommand;
17
18 /**
19  * Class to implement the BlueGiga command <b>encryptStart</b>.
20  * <p>
21  * This command starts the encryption for a given connection.
22  * <p>
23  * This class provides methods for processing BlueGiga API commands.
24  * <p>
25  * Note that this code is autogenerated. Manual changes may be overwritten.
26  *
27  * @author Chris Jackson - Initial contribution of Java code generator
28  */
29 @NonNullByDefault
30 public class BlueGigaEncryptStartCommand extends BlueGigaCommand {
31     public static final int COMMAND_CLASS = 0x05;
32     public static final int COMMAND_METHOD = 0x00;
33
34     /**
35      * Bonding handle of a device. This handle can be obtained for example from events like: Scan
36      * Response Status - If handle is 0xFF, all bondings will be deleted
37      * <p>
38      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
39      */
40     private int handle;
41
42     /**
43      * Create bonding if devices are not already bonded. 0: Do not create bonding. 1: Creating
44      * bonding
45      * <p>
46      * BlueGiga API type is <i>boolean</i> - Java type is {@link boolean}
47      */
48     private boolean bonding;
49
50     /**
51      * Bonding handle of a device. This handle can be obtained for example from events like: Scan
52      * Response Status - If handle is 0xFF, all bondings will be deleted
53      *
54      * @param handle the handle to set as {@link int}
55      */
56     public void setHandle(int handle) {
57         this.handle = handle;
58     }
59
60     /**
61      * Create bonding if devices are not already bonded. 0: Do not create bonding. 1: Creating
62      * bonding
63      *
64      * @param bonding the bonding to set as {@link boolean}
65      */
66     public void setBonding(boolean bonding) {
67         this.bonding = bonding;
68     }
69
70     @Override
71     public int[] serialize() {
72         // Serialize the header
73         serializeHeader(COMMAND_CLASS, COMMAND_METHOD);
74
75         // Serialize the fields
76         serializeUInt8(handle);
77         serializeBoolean(bonding);
78
79         return getPayload();
80     }
81
82     @Override
83     public String toString() {
84         final StringBuilder builder = new StringBuilder();
85         builder.append("BlueGigaEncryptStartCommand [handle=");
86         builder.append(handle);
87         builder.append(", bonding=");
88         builder.append(bonding);
89         builder.append(']');
90         return builder.toString();
91     }
92 }