Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
LE_PHYs.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 Transport PHY bit values (bitmask)
29 * <pre>
30 * BT Core Spec v5.2: Vol 4, Part E, 7.8.47 LE Read PHY command (we transfer the sequential value to this bitmask for unification)
31 * BT Core Spec v5.2: Vol 4, Part E, 7.8.48 LE Set Default PHY command
32 * </pre>
33 *
34 * @since 2.4.0
35 */
36public class LE_PHYs {
37
38 /**
39 * Each enum represents a 'LE Transport PHY' bit value.
40 *
41 * @since 2.4.0
42 */
43 public enum PHY {
47
48 PHY(final int v) {
49 value = (byte)( 1 << v );
50 }
51 public final byte value;
52 }
53
54 public byte mask;
55
56 public LE_PHYs() {
57 mask = 0;
58 }
59 public LE_PHYs(final byte v) {
60 mask = v;
61 }
62 public LE_PHYs(final PHY v) {
63 mask = v.value;
64 }
65
66 public boolean isSet(final PHY bit) { return 0 != ( mask & bit.value ); }
67 public void set(final PHY 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 PHY f : PHY.values()) {
74 if( isSet(f) ) {
75 if( 0 < count ) { out.append(", "); }
76 out.append(f.name()); count++;
77 }
78 }
79 if( 1 < count ) {
80 out.insert(0, "[");
81 out.append("]");
82 }
83 return out.toString();
84 }
85}
LE Transport PHY bit values (bitmask)
Definition: LE_PHYs.java:36
LE_PHYs(final PHY v)
Definition: LE_PHYs.java:62
LE_PHYs(final byte v)
Definition: LE_PHYs.java:59
boolean isSet(final PHY bit)
Definition: LE_PHYs.java:66
Each enum represents a 'LE Transport PHY' bit value.
Definition: LE_PHYs.java:43