Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
SMPPairingState.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  */
25 package org.direct_bt;
26 
27 /**
28  * SMP Pairing Process state definition
29  * <pre>
30  * Vol 3, Part H (SM): APPENDIX C MESSAGE SEQUENCE CHARTS
31  * </pre>
32  * <p>
33  * See {@link #get(byte)} for its native integer mapping.
34  * </p>
35  * @see PairingMode
36  * @since 2.1.0
37  */
38 public enum SMPPairingState {
39  /** No pairing in process. Current {@link PairingMode} shall be {@link PairingMode#NONE}. */
40  NONE((byte)0),
41 
42  /** Pairing failed. Current {@link PairingMode} shall be {@link PairingMode#NONE}. */
43  FAILED((byte)1),
44 
45  /**
46  * Phase 0: Pairing requested by responding (slave) device via SMPSecurityReqMsg.<br>
47  * Signals initiating (host) device to start the Pairing Feature Exchange.<br>
48  * Current {@link PairingMode} shall be {@link PairingMode#NEGOTIATING}.
49  */
51 
52  /**
53  * Phase 1: Pairing requested by initiating (master) device via SMPPairingMsg.<br>
54  * Starts the Pairing Feature Exchange.<br>
55  * Current {@link PairingMode} shall be {@link PairingMode#NEGOTIATING}.
56  */
58 
59  /**
60  * Phase 1: Pairing responded by responding (slave) device via SMPPairingMsg.<br>
61  * Completes the Pairing Feature Exchange. Optional user input shall be given for Phase 2.<br>
62  * Current {@link PairingMode} shall be set to a definitive value.
63  */
65 
66  /** Phase 2: Authentication (MITM) PASSKEY expected, see {@link PairingMode#PASSKEY_ENTRY_ini} */
67  PASSKEY_EXPECTED((byte)5),
68  /** Phase 2: Authentication (MITM) Numeric Comparison Reply expected, see {@link PairingMode#NUMERIC_COMPARE_ini} */
70  /** Phase 2: Authentication (MITM) OOB data expected, see {@link PairingMode#OUT_OF_BAND} */
71  OOB_EXPECTED((byte)7),
72 
73  /** Phase 3: Key & value distribution started after SMPPairConfirmMsg or SMPPairPubKeyMsg (LE Secure Connection) exchange between initiating (master) and responding (slave) device. */
74  KEY_DISTRIBUTION((byte)8),
75 
76  /**
77  * Phase 3: Key & value distribution completed by responding (slave) device sending SMPIdentInfoMsg (#1) , SMPIdentAddrInfoMsg (#2) or SMPSignInfoMsg (#3),<br>
78  * depending on the key distribution field SMPKeyDistFormat SMPPairingMsg::getInitKeyDist() and SMPPairingMsg::getRespKeyDist().
79  * <p>
80  * The link is assumed to be encrypted from here on and {@link AdapterStatusListener#deviceReady(BluetoothDevice, long)} gets called on all listener.
81  * </p>
82  */
83  COMPLETED((byte)9);
84 
85  public final byte value;
86 
87  /**
88  * Maps the specified name to a constant of {@link SMPPairingState}.
89  * <p>
90  * Implementation simply returns {@link #valueOf(String)}.
91  * This maps the constant names itself to their respective constant.
92  * </p>
93  * @param name the string name to be mapped to a constant of this enum type.
94  * @return the corresponding constant of this enum type.
95  * @throws IllegalArgumentException if the specified name can't be mapped to a constant of this enum type
96  * as described above.
97  */
98  public static SMPPairingState get(final String name) throws IllegalArgumentException {
99  return valueOf(name);
100  }
101 
102  /**
103  * Maps the specified integer value to a constant of {@link SMPPairingState}.
104  * @param value the integer value to be mapped to a constant of this enum type.
105  * @return the corresponding constant of this enum type, using {@link #NONE} if not supported.
106  */
107  public static SMPPairingState get(final byte value) {
108  switch(value) {
109  case (byte) 0x01: return FAILED;
110  case (byte) 0x02: return REQUESTED_BY_RESPONDER;
111  case (byte) 0x03: return FEATURE_EXCHANGE_STARTED;
112  case (byte) 0x04: return FEATURE_EXCHANGE_COMPLETED;
113  case (byte) 0x05: return PASSKEY_EXPECTED;
114  case (byte) 0x06: return NUMERIC_COMPARE_EXPECTED;
115  case (byte) 0x07: return OOB_EXPECTED;
116  case (byte) 0x08: return KEY_DISTRIBUTION;
117  case (byte) 0x09: return COMPLETED;
118  default: return NONE;
119  }
120  }
121 
122  SMPPairingState(final byte v) {
123  value = v;
124  }
125 }
org.direct_bt.SMPPairingState.FEATURE_EXCHANGE_COMPLETED
FEATURE_EXCHANGE_COMPLETED
Phase 1: Pairing responded by responding (slave) device via SMPPairingMsg.
Definition: SMPPairingState.java:64
org.direct_bt.SMPPairingState.PASSKEY_EXPECTED
PASSKEY_EXPECTED
Phase 2: Authentication (MITM) PASSKEY expected, see PairingMode#PASSKEY_ENTRY_ini.
Definition: SMPPairingState.java:67
org.direct_bt.SMPPairingState.SMPPairingState
SMPPairingState(final byte v)
Definition: SMPPairingState.java:122
org.direct_bt.SMPPairingState.FEATURE_EXCHANGE_STARTED
FEATURE_EXCHANGE_STARTED
Phase 1: Pairing requested by initiating (master) device via SMPPairingMsg.
Definition: SMPPairingState.java:57
org.direct_bt.SMPPairingState.NONE
NONE
No pairing in process.
Definition: SMPPairingState.java:40
org.direct_bt.SMPPairingState.OOB_EXPECTED
OOB_EXPECTED
Phase 2: Authentication (MITM) OOB data expected, see PairingMode#OUT_OF_BAND.
Definition: SMPPairingState.java:71
org.direct_bt.SMPPairingState.FAILED
FAILED
Pairing failed.
Definition: SMPPairingState.java:43
org.direct_bt.SMPPairingState
SMP Pairing Process state definition.
Definition: SMPPairingState.java:38
org.direct_bt.SMPPairingState.COMPLETED
COMPLETED
Phase 3: Key & value distribution completed by responding (slave) device sending SMPIdentInfoMsg (#1)...
Definition: SMPPairingState.java:83
org.direct_bt.SMPPairingState.NUMERIC_COMPARE_EXPECTED
NUMERIC_COMPARE_EXPECTED
Phase 2: Authentication (MITM) Numeric Comparison Reply expected, see PairingMode#NUMERIC_COMPARE_ini...
Definition: SMPPairingState.java:69
org.direct_bt.SMPPairingState.REQUESTED_BY_RESPONDER
REQUESTED_BY_RESPONDER
Phase 0: Pairing requested by responding (slave) device via SMPSecurityReqMsg.
Definition: SMPPairingState.java:50
org.direct_bt.SMPPairingState.value
final byte value
Definition: SMPPairingState.java:85
org.direct_bt.SMPPairingState.KEY_DISTRIBUTION
KEY_DISTRIBUTION
Phase 3: Key & value distribution started after SMPPairConfirmMsg or SMPPairPubKeyMsg (LE Secure Conn...
Definition: SMPPairingState.java:74