]> git.basschouten.com Git - openhab-addons.git/blob
ec95a5b0a565806450e921dd37c6e2b5a3d921e9
[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>passkeyDisplayEvent</b>.
20  * <p>
21  * This event tells a passkey should be printed to the user for bonding. This passkey must be
22  * entered in the remote device for bonding to be successful.
23  * <p>
24  * This class provides methods for processing BlueGiga API commands.
25  * <p>
26  * Note that this code is autogenerated. Manual changes may be overwritten.
27  *
28  * @author Chris Jackson - Initial contribution of Java code generator
29  */
30 @NonNullByDefault
31 public class BlueGigaPasskeyDisplayEvent extends BlueGigaResponse {
32     public static final int COMMAND_CLASS = 0x05;
33     public static final int COMMAND_METHOD = 0x02;
34
35     /**
36      * Bluetooth connection handle
37      * <p>
38      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
39      */
40     private int handle;
41
42     /**
43      * Passkey range: 000000-999999
44      * <p>
45      * BlueGiga API type is <i>uint32</i> - Java type is {@link long}
46      */
47     private long passkey;
48
49     /**
50      * Event constructor
51      */
52     public BlueGigaPasskeyDisplayEvent(int[] inputBuffer) {
53         // Super creates deserializer and reads header fields
54         super(inputBuffer);
55
56         event = (inputBuffer[0] & 0x80) != 0;
57
58         // Deserialize the fields
59         handle = deserializeUInt8();
60         passkey = deserializeUInt32();
61     }
62
63     /**
64      * Bluetooth connection handle
65      * <p>
66      * BlueGiga API type is <i>uint8</i> - Java type is {@link int}
67      *
68      * @return the current handle as {@link int}
69      */
70     public int getHandle() {
71         return handle;
72     }
73
74     /**
75      * Passkey range: 000000-999999
76      * <p>
77      * BlueGiga API type is <i>uint32</i> - Java type is {@link long}
78      *
79      * @return the current passkey as {@link long}
80      */
81     public long getPasskey() {
82         return passkey;
83     }
84
85     @Override
86     public String toString() {
87         final StringBuilder builder = new StringBuilder();
88         builder.append("BlueGigaPasskeyDisplayEvent [handle=");
89         builder.append(handle);
90         builder.append(", passkey=");
91         builder.append(passkey);
92         builder.append(']');
93         return builder.toString();
94     }
95 }