Direct-BT
v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
java
org
direct_bt
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
*/
25
package
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
*/
36
public
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
{
44
LE_1M
(0),
45
LE_2M
(1),
46
LE_CODED
(2);
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
}
org.direct_bt.LE_PHYs
LE Transport PHY bit values (bitmask)
Definition:
LE_PHYs.java:36
org.direct_bt.LE_PHYs.toString
String toString()
Definition:
LE_PHYs.java:70
org.direct_bt.LE_PHYs.LE_PHYs
LE_PHYs()
Definition:
LE_PHYs.java:56
org.direct_bt.LE_PHYs.mask
byte mask
Definition:
LE_PHYs.java:54
org.direct_bt.LE_PHYs.LE_PHYs
LE_PHYs(final PHY v)
Definition:
LE_PHYs.java:62
org.direct_bt.LE_PHYs.LE_PHYs
LE_PHYs(final byte v)
Definition:
LE_PHYs.java:59
org.direct_bt.LE_PHYs.isSet
boolean isSet(final PHY bit)
Definition:
LE_PHYs.java:66
org.direct_bt.LE_PHYs.PHY
Each enum represents a 'LE Transport PHY' bit value.
Definition:
LE_PHYs.java:43
org.direct_bt.LE_PHYs.PHY.LE_2M
LE_2M
Definition:
LE_PHYs.java:45
org.direct_bt.LE_PHYs.PHY.LE_1M
LE_1M
Definition:
LE_PHYs.java:44
org.direct_bt.LE_PHYs.PHY.LE_CODED
LE_CODED
Definition:
LE_PHYs.java:46
org.direct_bt.LE_PHYs.PHY.value
final byte value
Definition:
LE_PHYs.java:51
org.direct_bt.LE_PHYs.PHY.PHY
PHY(final int v)
Definition:
LE_PHYs.java:48
Generated on Sun May 12 2024 09:26:40 for Direct-BT by
1.9.4