Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
LE_Features.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2021 Gothel Software e.K.
4 * Copyright (c) 2021 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 * LE Link Layer Feature Set (bitmask)
29 * <pre>
30 * BT Core Spec v5.2: Vol 6, Part B, 4.6 (LE LL) Feature Support
31 *
32 * BT Core Spec v5.2: Vol 4, Part E, 7.8.3 LE Read Local Supported Features command
33 *
34 * BT Core Spec v5.2: Vol 4, Part E, 7.8.21 LE Read Remote Features command
35 * BT Core Spec v5.2: Vol 4, Part E, 7.7.65.4 LE Read Remote Features Complete event
36 *
37 * BT Core Spec v5.2: Vol 6, Part B, 7.8.115 LE Set Host Feature Command
38 * </pre>
39 *
40 * @since 2.4.0
41 */
42public class LE_Features {
43
44 /**
45 * Each enum represents a 'LE Link Layer Feature' bit value.
46 *
47 * @since 2.4.0
48 */
49 public enum Feature {
71 AoD(21),
72 AoA(22),
86
87 Feature(final int v) {
88 value = 1L << v;
89 }
90 public final long value;
91 }
92
93 public long mask;
94
95
96 public LE_Features(final long v) {
97 mask = v;
98 }
99
100 public boolean isSet(final Feature bit) { return 0 != ( mask & bit.value ); }
101 public void set(final Feature bit) { mask = mask | bit.value; }
102
103 @Override
104 public String toString() {
105 int count = 0;
106 final StringBuilder out = new StringBuilder();
107 for (final Feature f : Feature.values()) {
108 if( isSet(f) ) {
109 if( 0 < count ) { out.append(", "); }
110 out.append(f.name()); count++;
111 }
112 }
113 if( 1 < count ) {
114 out.insert(0, "[");
115 out.append("]");
116 }
117 return out.toString();
118 }
119}
LE Link Layer Feature Set (bitmask)
boolean isSet(final Feature bit)
Each enum represents a 'LE Link Layer Feature' bit value.