Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
BTMode.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 */
25package org.direct_bt;
26
27/**
28 * Bluetooth adapter operating mode
29 * <p>
30 * See {@link #get(byte)} for its native integer mapping.
31 * </p>
32 * @since 2.0.0
33 */
34public enum BTMode {
35 /** Zero mode, neither DUAL, BREDR nor LE. Usually an error. */
36 NONE ((byte)0),
37 /** Dual Bluetooth mode, i.e. BREDR + LE. */
38 DUAL ((byte)1),
39 /** BREDR only Bluetooth mode */
40 BREDR ((byte)2),
41 /** LE only Bluetooth mode */
42 LE ((byte)3);
43
44 public final byte value;
45
46 /**
47 * Maps the specified name to a constant of BTMode.
48 * <p>
49 * Implementation simply returns {@link #valueOf(String)}.
50 * This maps the constant names itself to their respective constant.
51 * </p>
52 * @param name the string name to be mapped to a constant of this enum type.
53 * @return the corresponding constant of this enum type.
54 * @throws IllegalArgumentException if the specified name can't be mapped to a constant of this enum type
55 * as described above.
56 */
57 public static BTMode get(final String name) throws IllegalArgumentException {
58 return valueOf(name);
59 }
60
61 /**
62 * Maps the specified integer value to a constant of {@link BTMode}.
63 * @param value the integer value to be mapped to a constant of this enum type.
64 * @return the corresponding constant of this enum type, using {@link #NONE} if not supported.
65 */
66 public static BTMode get(final byte value) {
67 switch(value) {
68 case (byte)0x01: return DUAL;
69 case (byte)0x02: return BREDR;
70 case (byte)0x03: return LE;
71 default: return NONE;
72 }
73 }
74
75 BTMode(final byte v) {
76 value = v;
77 }
78}
Bluetooth adapter operating mode.
Definition: BTMode.java:34
LE
LE only Bluetooth mode.
Definition: BTMode.java:42
BREDR
BREDR only Bluetooth mode.
Definition: BTMode.java:40
BTMode(final byte v)
Definition: BTMode.java:75
DUAL
Dual Bluetooth mode, i.e.
Definition: BTMode.java:38
NONE
Zero mode, neither DUAL, BREDR nor LE.
Definition: BTMode.java:36
final byte value
Definition: BTMode.java:44