Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
HCIStatusCode.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 */
25package org.direct_bt;
26
27/**
28 * BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes
29 * <p>
30 * BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 2 Error code descriptions
31 * </p>
32 * @since 2.0.0
33 */
34public enum HCIStatusCode {
35 SUCCESS((byte) 0x00),
36 UNKNOWN_COMMAND((byte) 0x01),
38 HARDWARE_FAILURE((byte) 0x03),
39 PAGE_TIMEOUT((byte) 0x04),
41 PIN_OR_KEY_MISSING((byte) 0x06),
43 CONNECTION_TIMEOUT((byte) 0x08),
47 COMMAND_DISALLOWED((byte) 0x0c),
58 REPEATED_ATTEMPTS((byte) 0x17),
59 PAIRING_NOT_ALLOWED((byte) 0x18),
60 UNKNOWN_LMP_PDU((byte) 0x19),
62 SCO_OFFSET_REJECTED((byte) 0x1b),
66 UNSPECIFIED_ERROR((byte) 0x1f),
70 LMP_OR_LL_COLLISION((byte) 0x23),
71 LMP_PDU_NOT_ALLOWED((byte) 0x24),
75 INSTANT_PASSED((byte) 0x28),
79 QOS_REJECTED((byte) 0x2d),
83 ROLE_SWITCH_PENDING((byte) 0x32),
85 ROLE_SWITCH_FAILED((byte) 0x35),
86 EIR_TOO_LARGE((byte) 0x36),
88 HOST_BUSY_PAIRING((byte) 0x38),
90 CONTROLLER_BUSY((byte) 0x3a),
92 ADVERTISING_TIMEOUT((byte) 0x3c),
95 MAX_CONNECTION_FAILED ((byte) 0x3f),
99 LIMIT_REACHED((byte) 0x43),
101 PACKET_TOO_LONG((byte) 0x45),
102
103 // MgmtStatus -> HCIStatusCode
104
105 FAILED((byte) 0xc3),
106 CONNECT_FAILED((byte) 0xc4),
107 AUTH_FAILED((byte) 0xc5),
108 NOT_PAIRED((byte) 0xc6),
109 NO_RESOURCES((byte) 0xc7),
110 TIMEOUT((byte) 0xc8),
111 ALREADY_CONNECTED((byte) 0xc9),
112 BUSY((byte) 0xca),
113 REJECTED((byte) 0xcb),
114 NOT_SUPPORTED((byte) 0xcc),
115 INVALID_PARAMS((byte) 0xcd),
116 DISCONNECTED((byte) 0xce),
117 NOT_POWERED((byte) 0xcf),
118 CANCELLED((byte) 0xd0),
119 INVALID_INDEX((byte) 0xd1),
120 RFKILLED((byte) 0xd2),
121 ALREADY_PAIRED((byte) 0xd3),
122 PERMISSION_DENIED((byte) 0xd4),
123
124 // Direct-BT
125
126 INTERNAL_TIMEOUT((byte) 0xfd),
127 INTERNAL_FAILURE((byte) 0xfe),
128 UNKNOWN((byte) 0xff);
129
130 public final byte value;
131
132 /**
133 * Maps the specified name to a constant of HCIStatusCode.
134 * <p>
135 * Implementation simply returns {@link #valueOf(String)}.
136 * This maps the constant names itself to their respective constant.
137 * </p>
138 * @param name the string name to be mapped to a constant of this enum type.
139 * @return the corresponding constant of this enum type.
140 * @throws IllegalArgumentException if the specified name can't be mapped to a constant of this enum type
141 * as described above.
142 */
143 public static HCIStatusCode get(final String name) throws IllegalArgumentException {
144 return valueOf(name);
145 }
146
147 /**
148 * Maps the specified integer value to a constant of HCIStatusCode.
149 * @param value the integer value to be mapped to a constant of this enum type.
150 * @return the corresponding constant of this enum type.
151 * @throws IllegalArgumentException if the specified name can't be mapped to a constant of this enum type
152 * as described above.
153 */
154 public static HCIStatusCode get(final byte value) throws IllegalArgumentException {
155 switch( value ) {
156 case (byte) 0x00: return SUCCESS;
157 case (byte) 0x01: return UNKNOWN_COMMAND;
158 case (byte) 0x02: return UNKNOWN_CONNECTION_IDENTIFIER;
159 case (byte) 0x03: return HARDWARE_FAILURE;
160 case (byte) 0x04: return PAGE_TIMEOUT;
161 case (byte) 0x05: return AUTHENTICATION_FAILURE;
162 case (byte) 0x06: return PIN_OR_KEY_MISSING;
163 case (byte) 0x07: return MEMORY_CAPACITY_EXCEEDED;
164 case (byte) 0x08: return CONNECTION_TIMEOUT;
165 case (byte) 0x09: return CONNECTION_LIMIT_EXCEEDED;
166 case (byte) 0x0a: return SYNC_DEVICE_CONNECTION_LIMIT_EXCEEDED;
167 case (byte) 0x0b: return CONNECTION_ALREADY_EXISTS;
168 case (byte) 0x0c: return COMMAND_DISALLOWED;
169 case (byte) 0x0d: return CONNECTION_REJECTED_LIMITED_RESOURCES;
170 case (byte) 0x0e: return CONNECTION_REJECTED_SECURITY;
171 case (byte) 0x0f: return CONNECTION_REJECTED_UNACCEPTABLE_BD_ADDR;
172 case (byte) 0x10: return CONNECTION_ACCEPT_TIMEOUT_EXCEEDED;
173 case (byte) 0x11: return UNSUPPORTED_FEATURE_OR_PARAM_VALUE;
174 case (byte) 0x12: return INVALID_HCI_COMMAND_PARAMETERS;
175 case (byte) 0x13: return REMOTE_USER_TERMINATED_CONNECTION;
176 case (byte) 0x14: return REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES;
177 case (byte) 0x15: return REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF;
178 case (byte) 0x16: return CONNECTION_TERMINATED_BY_LOCAL_HOST;
179 case (byte) 0x17: return REPEATED_ATTEMPTS;
180 case (byte) 0x18: return PAIRING_NOT_ALLOWED;
181 case (byte) 0x19: return UNKNOWN_LMP_PDU;
182 case (byte) 0x1a: return UNSUPPORTED_REMOTE_OR_LMP_FEATURE;
183 case (byte) 0x1b: return SCO_OFFSET_REJECTED;
184 case (byte) 0x1c: return SCO_INTERVAL_REJECTED;
185 case (byte) 0x1d: return SCO_AIR_MODE_REJECTED;
186 case (byte) 0x1e: return INVALID_LMP_OR_LL_PARAMETERS;
187 case (byte) 0x1f: return UNSPECIFIED_ERROR;
188 case (byte) 0x20: return UNSUPPORTED_LMP_OR_LL_PARAMETER_VALUE;
189 case (byte) 0x21: return ROLE_CHANGE_NOT_ALLOWED;
190 case (byte) 0x22: return LMP_OR_LL_RESPONSE_TIMEOUT;
191 case (byte) 0x23: return LMP_OR_LL_COLLISION;
192 case (byte) 0x24: return LMP_PDU_NOT_ALLOWED;
193 case (byte) 0x25: return ENCRYPTION_MODE_NOT_ACCEPTED;
194 case (byte) 0x26: return LINK_KEY_CANNOT_BE_CHANGED;
195 case (byte) 0x27: return REQUESTED_QOS_NOT_SUPPORTED;
196 case (byte) 0x28: return INSTANT_PASSED;
197 case (byte) 0x29: return PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED;
198 case (byte) 0x2a: return DIFFERENT_TRANSACTION_COLLISION;
199 case (byte) 0x2c: return QOS_UNACCEPTABLE_PARAMETER;
200 case (byte) 0x2d: return QOS_REJECTED;
201 case (byte) 0x2e: return CHANNEL_ASSESSMENT_NOT_SUPPORTED;
202 case (byte) 0x2f: return INSUFFICIENT_SECURITY;
203 case (byte) 0x30: return PARAMETER_OUT_OF_RANGE;
204 case (byte) 0x32: return ROLE_SWITCH_PENDING;
205 case (byte) 0x34: return RESERVED_SLOT_VIOLATION;
206 case (byte) 0x35: return ROLE_SWITCH_FAILED;
207 case (byte) 0x36: return EIR_TOO_LARGE;
208 case (byte) 0x37: return SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST;
209 case (byte) 0x38: return HOST_BUSY_PAIRING;
210 case (byte) 0x39: return CONNECTION_REJECTED_NO_SUITABLE_CHANNEL;
211 case (byte) 0x3a: return CONTROLLER_BUSY;
212 case (byte) 0x3b: return UNACCEPTABLE_CONNECTION_PARAM;
213 case (byte) 0x3c: return ADVERTISING_TIMEOUT;
214 case (byte) 0x3d: return CONNECTION_TERMINATED_MIC_FAILURE;
215 case (byte) 0x3e: return CONNECTION_EST_FAILED_OR_SYNC_TIMEOUT;
216 case (byte) 0x3f: return MAX_CONNECTION_FAILED;
217 case (byte) 0x40: return COARSE_CLOCK_ADJ_REJECTED;
218 case (byte) 0x41: return TYPE0_SUBMAP_NOT_DEFINED;
219 case (byte) 0x42: return UNKNOWN_ADVERTISING_IDENTIFIER;
220 case (byte) 0x43: return LIMIT_REACHED;
221 case (byte) 0x44: return OPERATION_CANCELLED_BY_HOST;
222 case (byte) 0x45: return PACKET_TOO_LONG;
223
224 case (byte) 0xc3: return FAILED;
225 case (byte) 0xc4: return CONNECT_FAILED;
226 case (byte) 0xc5: return AUTH_FAILED;
227 case (byte) 0xc6: return NOT_PAIRED;
228 case (byte) 0xc7: return NO_RESOURCES;
229 case (byte) 0xc8: return TIMEOUT;
230 case (byte) 0xc9: return ALREADY_CONNECTED;
231 case (byte) 0xca: return BUSY;
232 case (byte) 0xcb: return REJECTED;
233 case (byte) 0xcc: return NOT_SUPPORTED;
234 case (byte) 0xcd: return INVALID_PARAMS;
235 case (byte) 0xce: return DISCONNECTED;
236 case (byte) 0xcf: return NOT_POWERED;
237 case (byte) 0xd0: return CANCELLED;
238 case (byte) 0xd1: return INVALID_INDEX;
239 case (byte) 0xd2: return RFKILLED;
240 case (byte) 0xd3: return ALREADY_PAIRED;
241 case (byte) 0xd4: return PERMISSION_DENIED;
242
243 case (byte) 0xfd: return INTERNAL_TIMEOUT;
244 case (byte) 0xfe: return INTERNAL_FAILURE;
245 case (byte) 0xff: return UNKNOWN;
246 }
247 throw new IllegalArgumentException("Unsupported value "+value);
248 }
249
250 HCIStatusCode(final byte v) {
251 value = v;
252 }
253}
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.