1 /* 2 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef _BLE_HL_ERROR_H 16 #define _BLE_HL_ERROR_H 17 18 /// Error code from HCI TO HL Range - from 0x90 to 0xD0 19 #define RW_ERR_HCI_TO_HL(err) (((err) != 0) ? ((err) + 0x90) : (0)) 20 21 22 /// Error code from HL TO HCI Range - from 0x90 to 0xD0 23 #define RW_ERR_HL_TO_HCI(err) (((err) > 0x90) ? ((err) - 0x90) : (0)) 24 25 /** 26 * List all HL error codes 27 */ 28 enum hl_err 29 { 30 /// No error 31 GAP_ERR_NO_ERROR = 0x00, 32 33 // ---------------------------------------------------------------------------------- 34 // ------------------------- ATT Specific Error ------------------------------------ 35 // ---------------------------------------------------------------------------------- 36 /// No error 37 ATT_ERR_NO_ERROR = 0x00, 38 /// 0x01: Handle is invalid 39 ATT_ERR_INVALID_HANDLE = 0x01, 40 /// 0x02: Read permission disabled 41 ATT_ERR_READ_NOT_PERMITTED = 0x02, 42 /// 0x03: Write permission disabled 43 ATT_ERR_WRITE_NOT_PERMITTED = 0x03, 44 /// 0x04: Incorrect PDU 45 ATT_ERR_INVALID_PDU = 0x04, 46 /// 0x05: Authentication privilege not enough 47 ATT_ERR_INSUFF_AUTHEN = 0x05, 48 /// 0x06: Request not supported or not understood 49 ATT_ERR_REQUEST_NOT_SUPPORTED = 0x06, 50 /// 0x07: Incorrect offset value 51 ATT_ERR_INVALID_OFFSET = 0x07, 52 /// 0x08: Authorization privilege not enough 53 ATT_ERR_INSUFF_AUTHOR = 0x08, 54 /// 0x09: Capacity queue for reliable write reached 55 ATT_ERR_PREPARE_QUEUE_FULL = 0x09, 56 /// 0x0A: Attribute requested not existing 57 ATT_ERR_ATTRIBUTE_NOT_FOUND = 0x0A, 58 /// 0x0B: Attribute requested not long 59 ATT_ERR_ATTRIBUTE_NOT_LONG = 0x0B, 60 /// 0x0C: Encryption size not sufficient 61 ATT_ERR_INSUFF_ENC_KEY_SIZE = 0x0C, 62 /// 0x0D: Invalid length of the attribute value 63 ATT_ERR_INVALID_ATTRIBUTE_VAL_LEN = 0x0D, 64 /// 0x0E: Operation not fit to condition 65 ATT_ERR_UNLIKELY_ERR = 0x0E, 66 /// 0x0F: Attribute requires encryption before operation 67 ATT_ERR_INSUFF_ENC = 0x0F, 68 /// 0x10: Attribute grouping not supported 69 ATT_ERR_UNSUPP_GRP_TYPE = 0x10, 70 /// 0x11: Resources not sufficient to complete the request 71 ATT_ERR_INSUFF_RESOURCE = 0x11, 72 /// 0x80: Application error (also used in PRF Errors) 73 ATT_ERR_APP_ERROR = 0x80, 74 75 // ---------------------------------------------------------------------------------- 76 // -------------------------- L2C Specific Error ------------------------------------ 77 // ---------------------------------------------------------------------------------- 78 /// Message cannot be sent because connection lost. (disconnected) 79 L2C_ERR_CONNECTION_LOST = 0x30, 80 /// Invalid PDU length exceed MTU 81 L2C_ERR_INVALID_MTU_EXCEED = 0x31, 82 /// Invalid PDU length exceed MPS 83 L2C_ERR_INVALID_MPS_EXCEED = 0x32, 84 /// Invalid Channel ID 85 L2C_ERR_INVALID_CID = 0x33, 86 /// Invalid PDU 87 L2C_ERR_INVALID_PDU = 0x34, 88 /// Connection refused - no resources available 89 L2C_ERR_NO_RES_AVAIL = 0x35, 90 /// Connection refused - insufficient authentication 91 L2C_ERR_INSUFF_AUTHEN = 0x36, 92 /// Connection refused - insufficient authorization 93 L2C_ERR_INSUFF_AUTHOR = 0x37, 94 /// Connection refused - insufficient encryption key size 95 L2C_ERR_INSUFF_ENC_KEY_SIZE = 0x38, 96 /// Connection Refused - insufficient encryption 97 L2C_ERR_INSUFF_ENC = 0x39, 98 /// Connection refused - LE_PSM not supported 99 L2C_ERR_LEPSM_NOT_SUPP = 0x3A, 100 /// No more credit 101 L2C_ERR_INSUFF_CREDIT = 0x3B, 102 /// Command not understood by peer device 103 L2C_ERR_NOT_UNDERSTOOD = 0x3C, 104 /// Credit error, invalid number of credit received 105 L2C_ERR_CREDIT_ERROR = 0x3D, 106 /// Channel identifier already allocated 107 L2C_ERR_CID_ALREADY_ALLOC = 0x3E, 108 /// Unknown PDU 109 L2C_ERR_UNKNOWN_PDU = 0x3F, 110 111 112 // ---------------------------------------------------------------------------------- 113 // -------------------------- GAP Specific Error ------------------------------------ 114 // ---------------------------------------------------------------------------------- 115 /// Invalid parameters set 116 GAP_ERR_INVALID_PARAM = 0x40, 117 /// Problem with protocol exchange, get unexpected response 118 GAP_ERR_PROTOCOL_PROBLEM = 0x41, 119 /// Request not supported by software configuration 120 GAP_ERR_NOT_SUPPORTED = 0x42, 121 /// Request not allowed in current state. 122 GAP_ERR_COMMAND_DISALLOWED = 0x43, 123 /// Requested operation canceled. 124 GAP_ERR_CANCELED = 0x44, 125 /// Requested operation timeout. 126 GAP_ERR_TIMEOUT = 0x45, 127 /// Link connection lost during operation. 128 GAP_ERR_DISCONNECTED = 0x46, 129 /// Search algorithm finished, but no result found 130 GAP_ERR_NOT_FOUND = 0x47, 131 /// Request rejected by peer device 132 GAP_ERR_REJECTED = 0x48, 133 /// Problem with privacy configuration 134 GAP_ERR_PRIVACY_CFG_PB = 0x49, 135 /// Duplicate or invalid advertising data 136 GAP_ERR_ADV_DATA_INVALID = 0x4A, 137 /// Insufficient resources 138 GAP_ERR_INSUFF_RESOURCES = 0x4B, 139 /// Unexpected Error 140 GAP_ERR_UNEXPECTED = 0x4C, 141 /// Feature mismatch 142 GAP_ERR_MISMATCH = 0x4D, 143 144 // ---------------------------------------------------------------------------------- 145 // ------------------------- GATT Specific Error ------------------------------------ 146 // ---------------------------------------------------------------------------------- 147 /// Problem with ATTC protocol response 148 GATT_ERR_INVALID_ATT_LEN = 0x50, 149 /// Error in service search 150 GATT_ERR_INVALID_TYPE_IN_SVC_SEARCH = 0x51, 151 /// Invalid write data 152 GATT_ERR_WRITE = 0x52, 153 /// Signed write error 154 GATT_ERR_SIGNED_WRITE = 0x53, 155 /// No attribute client defined 156 GATT_ERR_ATTRIBUTE_CLIENT_MISSING = 0x54, 157 /// No attribute server defined 158 GATT_ERR_ATTRIBUTE_SERVER_MISSING = 0x55, 159 /// Permission set in service/attribute are invalid 160 GATT_ERR_INVALID_PERM = 0x56, 161 162 // ---------------------------------------------------------------------------------- 163 // ------------------------- SMP Specific Error ------------------------------------- 164 // ---------------------------------------------------------------------------------- 165 // SMP Protocol Errors detected on local device 166 /// The user input of pass key failed, for example, the user canceled the operation. 167 SMP_ERROR_LOC_PASSKEY_ENTRY_FAILED = 0x61, 168 /// The OOB Data is not available. 169 SMP_ERROR_LOC_OOB_NOT_AVAILABLE = 0x62, 170 /// The pairing procedure cannot be performed as authentication requirements cannot be met 171 /// due to IO capabilities of one or both devices. 172 SMP_ERROR_LOC_AUTH_REQ = 0x63, 173 /// The confirm value does not match the calculated confirm value. 174 SMP_ERROR_LOC_CONF_VAL_FAILED = 0x64, 175 /// Pairing is not supported by the device. 176 SMP_ERROR_LOC_PAIRING_NOT_SUPP = 0x65, 177 /// The resultant encryption key size is insufficient for the security requirements of 178 /// this device. 179 SMP_ERROR_LOC_ENC_KEY_SIZE = 0x66, 180 /// The SMP command received is not supported on this device. 181 SMP_ERROR_LOC_CMD_NOT_SUPPORTED = 0x67, 182 /// Pairing failed due to an unspecified reason. 183 SMP_ERROR_LOC_UNSPECIFIED_REASON = 0x68, 184 /// Pairing or Authentication procedure is disallowed because too little time has elapsed 185 /// since last pairing request or security request. 186 SMP_ERROR_LOC_REPEATED_ATTEMPTS = 0x69, 187 /// The command length is invalid or a parameter is outside of the specified range. 188 SMP_ERROR_LOC_INVALID_PARAM = 0x6A, 189 /// Indicates to the remote device that the DHKey Check value received doesn't 190 /// match the one calculated by the local device. 191 SMP_ERROR_LOC_DHKEY_CHECK_FAILED = 0x6B, 192 /// Indicates that the confirm values in the numeric comparison protocol do not match. 193 SMP_ERROR_LOC_NUMERIC_COMPARISON_FAILED = 0x6C, 194 /// Indicates that the pairing over the LE transport failed due to a Pairing Request sent 195 /// over the BR/EDR transport in process. 196 SMP_ERROR_LOC_BREDR_PAIRING_IN_PROGRESS = 0x6D, 197 /// Indicates that the BR/EDR Link Key generated on the BR/EDR transport cannot be 198 /// used to derive and distribute keys for the LE transport. 199 SMP_ERROR_LOC_CROSS_TRANSPORT_KEY_GENERATION_NOT_ALLOWED = 0x6E, 200 // SMP Protocol Errors detected by remote device 201 /// The user input of passkey failed, for example, the user canceled the operation. 202 SMP_ERROR_REM_PASSKEY_ENTRY_FAILED = 0x71, 203 /// The OOB Data is not available. 204 SMP_ERROR_REM_OOB_NOT_AVAILABLE = 0x72, 205 /// The pairing procedure cannot be performed as authentication requirements cannot be 206 /// met due to IO capabilities of one or both devices. 207 SMP_ERROR_REM_AUTH_REQ = 0x73, 208 /// The confirm value does not match the calculated confirm value. 209 SMP_ERROR_REM_CONF_VAL_FAILED = 0x74, 210 /// Pairing is not supported by the device. 211 SMP_ERROR_REM_PAIRING_NOT_SUPP = 0x75, 212 /// The resultant encryption key size is insufficient for the security requirements of 213 /// this device. 214 SMP_ERROR_REM_ENC_KEY_SIZE = 0x76, 215 /// The SMP command received is not supported on this device. 216 SMP_ERROR_REM_CMD_NOT_SUPPORTED = 0x77, 217 /// Pairing failed due to an unspecified reason. 218 SMP_ERROR_REM_UNSPECIFIED_REASON = 0x78, 219 /// Pairing or Authentication procedure is disallowed because too little time has elapsed 220 /// since last pairing request or security request. 221 SMP_ERROR_REM_REPEATED_ATTEMPTS = 0x79, 222 /// The command length is invalid or a parameter is outside of the specified range. 223 SMP_ERROR_REM_INVALID_PARAM = 0x7A, 224 /// Indicates to the remote device that the DHKey Check value received doesn't 225 /// match the one calculated by the local device. 226 SMP_ERROR_REM_DHKEY_CHECK_FAILED = 0x7B, 227 /// Indicates that the confirm values in the numeric comparison protocol do not match. 228 SMP_ERROR_REM_NUMERIC_COMPARISON_FAILED = 0x7C, 229 /// Indicates that the pairing over the LE transport failed due to a Pairing Request sent 230 /// over the BR/EDR transport in process. 231 SMP_ERROR_REM_BREDR_PAIRING_IN_PROGRESS = 0x7D, 232 /// Indicates that the BR/EDR Link Key generated on the BR/EDR transport cannot be 233 /// used to derive and distribute keys for the LE transport. 234 SMP_ERROR_REM_CROSS_TRANSPORT_KEY_GENERATION_NOT_ALLOWED = 0x7E, 235 // SMP Errors triggered by local device 236 /// The provided resolvable address has not been resolved. 237 SMP_ERROR_ADDR_RESOLV_FAIL = 0x20, 238 /// The Signature Verification Failed 239 SMP_ERROR_SIGN_VERIF_FAIL = 0x21, 240 /// The encryption procedure failed because the slave device didn't find the LTK 241 /// needed to start an encryption session. 242 SMP_ERROR_ENC_KEY_MISSING = 0x22, 243 /// The encryption procedure failed because the slave device doesn't support the 244 /// encryption feature. 245 SMP_ERROR_ENC_NOT_SUPPORTED = 0x23, 246 /// A timeout has occurred during the start encryption session. 247 SMP_ERROR_ENC_TIMEOUT = 0x24, 248 249 // ---------------------------------------------------------------------------------- 250 //------------------------ Profiles specific error codes ---------------------------- 251 // ---------------------------------------------------------------------------------- 252 /// Application Error 253 PRF_APP_ERROR = 0x80, 254 /// Invalid parameter in request 255 PRF_ERR_INVALID_PARAM = 0x81, 256 /// Inexistent handle for sending a read/write characteristic request 257 PRF_ERR_INEXISTENT_HDL = 0x82, 258 /// Discovery stopped due to missing attribute according to specification 259 PRF_ERR_STOP_DISC_CHAR_MISSING = 0x83, 260 /// Too many SVC instances found -> protocol violation 261 PRF_ERR_MULTIPLE_SVC = 0x84, 262 /// Discovery stopped due to found attribute with incorrect properties 263 PRF_ERR_STOP_DISC_WRONG_CHAR_PROP = 0x85, 264 /// Too many Char. instances found-> protocol violation 265 PRF_ERR_MULTIPLE_CHAR = 0x86, 266 /// Attribute write not allowed 267 PRF_ERR_NOT_WRITABLE = 0x87, 268 /// Attribute read not allowed 269 PRF_ERR_NOT_READABLE = 0x88, 270 /// Request not allowed 271 PRF_ERR_REQ_DISALLOWED = 0x89, 272 /// Notification Not Enabled 273 PRF_ERR_NTF_DISABLED = 0x8A, 274 /// Indication Not Enabled 275 PRF_ERR_IND_DISABLED = 0x8B, 276 /// Feature not supported by profile 277 PRF_ERR_FEATURE_NOT_SUPPORTED = 0x8C, 278 /// Read value has an unexpected length 279 PRF_ERR_UNEXPECTED_LEN = 0x8D, 280 /// Disconnection occurs 281 PRF_ERR_DISCONNECTED = 0x8E, 282 /// Procedure Timeout 283 PRF_ERR_PROC_TIMEOUT = 0x8F, 284 /// Client characteristic configuration improperly configured 285 PRF_CCCD_IMPR_CONFIGURED = 0xFD, 286 /// Procedure already in progress 287 PRF_PROC_IN_PROGRESS = 0xFE, 288 /// Out of Range 289 PRF_OUT_OF_RANGE = 0xFF, 290 291 // ---------------------------------------------------------------------------------- 292 //-------------------- LL Error codes conveyed to upper layer ----------------------- 293 // ---------------------------------------------------------------------------------- 294 /// Unknown HCI Command 295 LL_ERR_UNKNOWN_HCI_COMMAND = 0x91, 296 /// Unknown Connection Identifier 297 LL_ERR_UNKNOWN_CONNECTION_ID = 0x92, 298 /// Hardware Failure 299 LL_ERR_HARDWARE_FAILURE = 0x93, 300 /// BT Page Timeout 301 LL_ERR_PAGE_TIMEOUT = 0x94, 302 /// Authentication failure 303 LL_ERR_AUTH_FAILURE = 0x95, 304 /// Pin code missing 305 LL_ERR_PIN_MISSING = 0x96, 306 /// Memory capacity exceed 307 LL_ERR_MEMORY_CAPA_EXCEED = 0x97, 308 /// Connection Timeout 309 LL_ERR_CON_TIMEOUT = 0x98, 310 /// Connection limit Exceed 311 LL_ERR_CON_LIMIT_EXCEED = 0x99, 312 /// Synchronous Connection limit exceed 313 LL_ERR_SYNC_CON_LIMIT_DEV_EXCEED = 0x9A, 314 /// ACL Connection exits 315 LL_ERR_ACL_CON_EXISTS = 0x9B, 316 /// Command Disallowed 317 LL_ERR_COMMAND_DISALLOWED = 0x9C, 318 /// Connection rejected due to limited resources 319 LL_ERR_CONN_REJ_LIMITED_RESOURCES = 0x9D, 320 /// Connection rejected due to security reason 321 LL_ERR_CONN_REJ_SECURITY_REASONS = 0x9E, 322 /// Connection rejected due to unacceptable BD Addr 323 LL_ERR_CONN_REJ_UNACCEPTABLE_BDADDR = 0x9F, 324 /// Connection rejected due to Accept connection timeout 325 LL_ERR_CONN_ACCEPT_TIMEOUT_EXCEED = 0xA0, 326 /// Not Supported 327 LL_ERR_UNSUPPORTED = 0xA1, 328 /// invalid parameters 329 LL_ERR_INVALID_HCI_PARAM = 0xA2, 330 /// Remote user terminate connection 331 LL_ERR_REMOTE_USER_TERM_CON = 0xA3, 332 /// Remote device terminate connection due to low resources 333 LL_ERR_REMOTE_DEV_TERM_LOW_RESOURCES = 0xA4, 334 /// Remote device terminate connection due to power off 335 LL_ERR_REMOTE_DEV_POWER_OFF = 0xA5, 336 /// Connection terminated by local host 337 LL_ERR_CON_TERM_BY_LOCAL_HOST = 0xA6, 338 /// Repeated attempts 339 LL_ERR_REPEATED_ATTEMPTS = 0xA7, 340 /// Pairing not Allowed 341 LL_ERR_PAIRING_NOT_ALLOWED = 0xA8, 342 /// Unknown PDU Error 343 LL_ERR_UNKNOWN_LMP_PDU = 0xA9, 344 /// Unsupported remote feature 345 LL_ERR_UNSUPPORTED_REMOTE_FEATURE = 0xAA, 346 /// Sco Offset rejected 347 LL_ERR_SCO_OFFSET_REJECTED = 0xAB, 348 /// SCO Interval Rejected 349 LL_ERR_SCO_INTERVAL_REJECTED = 0xAC, 350 /// SCO air mode Rejected 351 LL_ERR_SCO_AIR_MODE_REJECTED = 0xAD, 352 /// Invalid LMP parameters 353 LL_ERR_INVALID_LMP_PARAM = 0xAE, 354 /// Unspecified error 355 LL_ERR_UNSPECIFIED_ERROR = 0xAF, 356 /// Unsupported LMP Parameter value 357 LL_ERR_UNSUPPORTED_LMP_PARAM_VALUE = 0xB0, 358 /// Role Change Not allowed 359 LL_ERR_ROLE_CHANGE_NOT_ALLOWED = 0xB1, 360 /// LMP Response timeout 361 LL_ERR_LMP_RSP_TIMEOUT = 0xB2, 362 /// LMP Collision 363 LL_ERR_LMP_COLLISION = 0xB3, 364 /// LMP Pdu not allowed 365 LL_ERR_LMP_PDU_NOT_ALLOWED = 0xB4, 366 /// Encryption mode not accepted 367 LL_ERR_ENC_MODE_NOT_ACCEPT = 0xB5, 368 /// Link Key Cannot be changed 369 LL_ERR_LINK_KEY_CANT_CHANGE = 0xB6, 370 /// Quality of Service not supported 371 LL_ERR_QOS_NOT_SUPPORTED = 0xB7, 372 /// Error, instant passed 373 LL_ERR_INSTANT_PASSED = 0xB8, 374 /// Pairing with unit key not supported 375 LL_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUP = 0xB9, 376 /// Transaction collision 377 LL_ERR_DIFF_TRANSACTION_COLLISION = 0xBA, 378 /// Unacceptable parameters 379 LL_ERR_QOS_UNACCEPTABLE_PARAM = 0xBC, 380 /// Quality of Service rejected 381 LL_ERR_QOS_REJECTED = 0xBD, 382 /// Channel class not supported 383 LL_ERR_CHANNEL_CLASS_NOT_SUP = 0xBE, 384 /// Insufficient security 385 LL_ERR_INSUFFICIENT_SECURITY = 0xBF, 386 /// Parameters out of mandatory range 387 LL_ERR_PARAM_OUT_OF_MAND_RANGE = 0xC0, 388 /// Role switch pending 389 LL_ERR_ROLE_SWITCH_PEND = 0xC2, 390 /// Reserved slot violation 391 LL_ERR_RESERVED_SLOT_VIOLATION = 0xC4, 392 /// Role Switch fail 393 LL_ERR_ROLE_SWITCH_FAIL = 0xC5, 394 /// Error, EIR too large 395 LL_ERR_EIR_TOO_LARGE = 0xC6, 396 /// Simple pairing not supported by host 397 LL_ERR_SP_NOT_SUPPORTED_HOST = 0xC7, 398 /// Host pairing is busy 399 LL_ERR_HOST_BUSY_PAIRING = 0xC8, 400 /// Controller is busy 401 LL_ERR_CONTROLLER_BUSY = 0xCA, 402 /// Unacceptable connection initialization 403 LL_ERR_UNACCEPTABLE_CONN_INT = 0xCB, 404 /// Direct Advertising Timeout 405 LL_ERR_DIRECT_ADV_TO = 0xCC, 406 /// Connection Terminated due to a MIC failure 407 LL_ERR_TERMINATED_MIC_FAILURE = 0xCD, 408 /// Connection failed to be established 409 LL_ERR_CONN_FAILED_TO_BE_EST = 0xCE, 410 /// MAC Connection Failed 411 LL_ERR_MAC_CONN_FAILED = 0xCF, 412 /// Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging 413 LL_ERR_CCA_REJ_USE_CLOCK_DRAG = 0xD0, 414 /// Type0 Submap Not Defined 415 LL_ERR_TYPE0_SUBMAP_NOT_DEFINED = 0xD1, 416 /// Unknown Advertising Identifier 417 LL_ERR_UNKNOWN_ADVERTISING_ID = 0xD2, 418 /// Limit Reached 419 LL_ERR_LIMIT_REACHED = 0xD3, 420 /// Operation Cancelled by Host 421 LL_ERR_OPERATION_CANCELED_BY_HOST = 0xD4, 422 }; 423 424 #endif // _BLE_HL_ERROR_H 425