Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
SMPIOCapability.java
Go to the documentation of this file.
1 /**
2  * Author: Sven Gothel <sgothel@jausoft.com>
3  * Copyright (c) 2020 Gothel Software e.K.
4  * Copyright (c) 2020 ZAFENA AB
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 package org.direct_bt;
26 
27 /**
28  * SMP IO Capability value.
29  * <p>
30  * Vol 3, Part H, 2.3.2 IO capabilities
31  * </p>
32  * <p>
33  * See {@link #get(byte)} for its native integer mapping.
34  * </p>
35  * @since 2.1.0
36  */
37 public enum SMPIOCapability {
38  /** Display output only, value 0. */
39  DISPLAY_ONLY ((byte)0),
40  /** Display output and boolean confirmation input keys only, value 1. */
41  DISPLAY_YES_NO ((byte)1),
42  /** Keyboard input only, value 2. */
43  KEYBOARD_ONLY ((byte)2),
44  /** No input not output, value 3. */
45  NO_INPUT_NO_OUTPUT ((byte)3),
46  /** Display output and keyboard input, value 4. */
47  KEYBOARD_DISPLAY ((byte)4),
48  /** Denoting unset value, i.e. not defined. */
49  UNSET ((byte)0xff);
50 
51  public final byte value;
52 
53  /**
54  * Maps the specified name to a constant of SMPIOCapability.
55  * <p>
56  * Implementation simply returns {@link #valueOf(String)}.
57  * This maps the constant names itself to their respective constant.
58  * </p>
59  * @param name the string name to be mapped to a constant of this enum type.
60  * @return the corresponding constant of this enum type.
61  * @throws IllegalArgumentException if the specified name can't be mapped to a constant of this enum type
62  * as described above.
63  */
64  public static SMPIOCapability get(final String name) throws IllegalArgumentException {
65  return valueOf(name);
66  }
67 
68  /**
69  * Maps the specified integer value to a constant of {@link SMPIOCapability}.
70  * @param value the integer value to be mapped to a constant of this enum type.
71  * @return the corresponding constant of this enum type, using {@link #UNSET} if not supported.
72  */
73  public static SMPIOCapability get(final byte value) {
74  switch(value) {
75  case (byte)0x00: return DISPLAY_ONLY;
76  case (byte)0x01: return DISPLAY_YES_NO;
77  case (byte)0x02: return KEYBOARD_ONLY;
78  case (byte)0x03: return NO_INPUT_NO_OUTPUT;
79  case (byte)0x04: return KEYBOARD_DISPLAY;
80  default: return UNSET;
81  }
82  }
83 
84  SMPIOCapability(final byte v) {
85  value = v;
86  }
87 }
org.direct_bt.SMPIOCapability
SMP IO Capability value.
Definition: SMPIOCapability.java:37
org.direct_bt.SMPIOCapability.NO_INPUT_NO_OUTPUT
NO_INPUT_NO_OUTPUT
No input not output, value 3.
Definition: SMPIOCapability.java:45
org.direct_bt.SMPIOCapability.value
final byte value
Definition: SMPIOCapability.java:51
org.direct_bt.SMPIOCapability.UNSET
UNSET
Denoting unset value, i.e.
Definition: SMPIOCapability.java:49
org.direct_bt.SMPIOCapability.SMPIOCapability
SMPIOCapability(final byte v)
Definition: SMPIOCapability.java:84
org.direct_bt.SMPIOCapability.KEYBOARD_DISPLAY
KEYBOARD_DISPLAY
Display output and keyboard input, value 4.
Definition: SMPIOCapability.java:47
org.direct_bt.SMPIOCapability.DISPLAY_ONLY
DISPLAY_ONLY
Display output only, value 0.
Definition: SMPIOCapability.java:39
org.direct_bt.SMPIOCapability.DISPLAY_YES_NO
DISPLAY_YES_NO
Display output and boolean confirmation input keys only, value 1.
Definition: SMPIOCapability.java:41
org.direct_bt.SMPIOCapability.KEYBOARD_ONLY
KEYBOARD_ONLY
Keyboard input only, value 2.
Definition: SMPIOCapability.java:43