Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
GAPFlags.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2022 Gothel Software e.K.
4 * Copyright (c) 2022 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 * Bit mask of 'Extended Inquiry Response' (EIR) data fields,
29 * indicating a set of related data.
30 *
31 * @since 2.5.3
32 *
33 * @see {@link EInfoReport}
34 */
35public class GAPFlags {
36
37 /**
38 * Each enum represents a 'Extended Inquiry Response' (EIR) data field type bit.
39 *
40 * @since 2.5.3
41 *
42 * @see {@link GAPFlags}
43 * @see {@link EInfoReport}
44 */
45 public enum Bit {
46 NONE ((byte)0),
47 LE_Ltd_Disc ((byte)(1 << 0)),
48 LE_Gen_Disc ((byte)(1 << 1)),
49 BREDR_UNSUP ((byte)(1 << 2)),
50 Dual_SameCtrl ((byte)(1 << 3)),
51 Dual_SameHost ((byte)(1 << 4)),
52 RESERVED1 ((byte)(1 << 5)),
53 RESERVED2 ((byte)(1 << 6)),
54 RESERVED3 ((byte)(1 << 7));
55
56 Bit(final byte v) { value = v; }
57 public final byte value;
58 }
59
60 public byte mask;
61
62 public GAPFlags(final byte v) {
63 mask = v;
64 }
65
66 public boolean isSet(final Bit bit) { return 0 != ( mask & bit.value ); }
67 public void set(final Bit bit) { mask = (byte)(mask | bit.value); }
68
69 @Override
70 public String toString() {
71 int count = 0;
72 final StringBuilder out = new StringBuilder();
73 for (final Bit dt : Bit.values()) {
74 if( isSet(dt) ) {
75 if( 0 < count ) { out.append(", "); }
76 out.append(dt.name()); count++;
77 }
78 }
79 if( 1 < count ) {
80 out.insert(0, "[");
81 out.append("]");
82 }
83 return out.toString();
84 }
85}
Bit mask of 'Extended Inquiry Response' (EIR) data fields, indicating a set of related data.
Definition: GAPFlags.java:35
boolean isSet(final Bit bit)
Definition: GAPFlags.java:66
GAPFlags(final byte v)
Definition: GAPFlags.java:62
Each enum represents a 'Extended Inquiry Response' (EIR) data field type bit.
Definition: GAPFlags.java:45