]> git.basschouten.com Git - openhab-addons.git/blob
af3d1c1385ada8063732a20845f121b13589ae85
[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.BlueGigaResponse;
17
18 /**
19  * Class to implement the BlueGiga command <b>bondStatusEvent</b>.
20  * <p>
21  * This event outputs bonding status information.
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 BlueGigaBondStatusEvent extends BlueGigaResponse {
31     public static final int COMMAND_CLASS = 0x05;
32     public static final int COMMAND_METHOD = 0x04;
33
34     /**
35      * Bonding handle
36      * <p>
37      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
38      */
39     private int bond;
40
41     /**
42      * Encryption key size used in long-term key
43      * <p>
44      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
45      */
46     private int keysize;
47
48     /**
49      * Was Man-in-the-Middle mode was used in pairing. 0: No MITM used. 1: MITM was used
50      * <p>
51      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
52      */
53     private int mitm;
54
55     /**
56      * Keys stored for bonding. See: Bonding Keys
57      * <p>
58      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
59      */
60     private int keys;
61
62     /**
63      * Event constructor
64      */
65     public BlueGigaBondStatusEvent(int[] inputBuffer) {
66         // Super creates deserializer and reads header fields
67         super(inputBuffer);
68
69         event = (inputBuffer[0] & 0x80) != 0;
70
71         // Deserialize the fields
72         bond = deserializeUInt8();
73         keysize = deserializeUInt8();
74         mitm = deserializeUInt8();
75         keys = deserializeUInt8();
76     }
77
78     /**
79      * Bonding handle
80      * <p>
81      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
82      *
83      * @return the current bond as {@link int}
84      */
85     public int getBond() {
86         return bond;
87     }
88
89     /**
90      * Encryption key size used in long-term key
91      * <p>
92      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
93      *
94      * @return the current keysize as {@link int}
95      */
96     public int getKeysize() {
97         return keysize;
98     }
99
100     /**
101      * Was Man-in-the-Middle mode was used in pairing. 0: No MITM used. 1: MITM was used
102      * <p>
103      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
104      *
105      * @return the current mitm as {@link int}
106      */
107     public int getMitm() {
108         return mitm;
109     }
110
111     /**
112      * Keys stored for bonding. See: Bonding Keys
113      * <p>
114      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
115      *
116      * @return the current keys as {@link int}
117      */
118     public int getKeys() {
119         return keys;
120     }
121
122     @Override
123     public String toString() {
124         final StringBuilder builder = new StringBuilder();
125         builder.append("BlueGigaBondStatusEvent [bond=");
126         builder.append(bond);
127         builder.append(", keysize=");
128         builder.append(keysize);
129         builder.append(", mitm=");
130         builder.append(mitm);
131         builder.append(", keys=");
132         builder.append(keys);
133         builder.append(']');
134         return builder.toString();
135     }
136 }