错误码定义:
1 /* Success code */ 2 #define HCI_SUCCESS 0x00 3 /* Possible error codes */ 4 #define HCI_UNKNOWN_HCI_COMMAND 0x01 5 #define HCI_NO_CONNECTION 0x02 6 #define HCI_HW_FAILURE 0x03 7 #define HCI_PAGE_TIMEOUT 0x04 8 #define HCI_AUTHENTICATION_FAILURE 0x05 9 #define HCI_KEY_MISSING 0x06 10 #define HCI_MEMORY_FULL 0x07 11 #define HCI_CONN_TIMEOUT 0x08 12 #define HCI_MAX_NUMBER_OF_CONNECTIONS 0x09 13 #define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS_TO_DEVICE 0x0A 14 #define HCI_ACL_CONNECTION_EXISTS 0x0B 15 #define HCI_COMMAND_DISSALLOWED 0x0C 16 #define HCI_HOST_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D 17 #define HCI_HOST_REJECTED_DUE_TO_SECURITY_REASONS 0x0E 18 #define HCI_HOST_REJECTED_DUE_TO_REMOTE_DEVICE_ONLY_PERSONAL_SERVICE 0x0F 19 #define HCI_HOST_TIMEOUT 0x10 20 #define HCI_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE 0x11 21 #define HCI_INVALID_HCI_COMMAND_PARAMETERS 0x12 22 #define HCI_OTHER_END_TERMINATED_CONN_USER_ENDED 0x13 23 #define HCI_OTHER_END_TERMINATED_CONN_LOW_RESOURCES 0x14 24 #define HCI_OTHER_END_TERMINATED_CONN_ABOUT_TO_POWER_OFF 0x15 25 #define HCI_CONN_TERMINATED_BY_LOCAL_HOST 0x16 26 #define HCI_REPETED_ATTEMPTS 0x17 27 #define HCI_PAIRING_NOT_ALLOWED 0x18 28 #define HCI_UNKNOWN_LMP_PDU 0x19 29 #define HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A 30 #define HCI_SCO_OFFSET_REJECTED 0x1B 31 #define HCI_SCO_INTERVAL_REJECTED 0x1C 32 #define HCI_SCO_AIR_MODE_REJECTED 0x1D 33 #define HCI_INVALID_LMP_PARAMETERS 0x1E 34 #define HCI_UNSPECIFIED_ERROR 0x1F 35 #define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20 36 #define HCI_ROLE_CHANGE_NOT_ALLOWED 0x21 37 #define HCI_LMP_RESPONSE_TIMEOUT 0x22 38 #define HCI_LMP_ERROR_TRANSACTION_COLLISION 0x23 39 #define HCI_LMP_PDU_NOT_ALLOWED 0x24 40 #define HCI_ENCRYPTION_MODE_NOT_ACCEPTABLE 0x25 41 #define HCI_UNIT_KEY_USED 0x26 42 #define HCI_QOS_NOT_SUPPORTED 0x27 43 #define HCI_INSTANT_PASSED 0x28 44 #define HCI_PAIRING_UNIT_KEY_NOT_SUPPORTED 0x29
hci_get_err_code:
1 char * hci_get_error_code(u8_t code) { 2 switch(code) { 3 case HCI_SUCCESS: 4 return("Success"); 5 case HCI_UNKNOWN_HCI_COMMAND: 6 return("Unknown HCI Command"); 7 case HCI_NO_CONNECTION: 8 return("No Connection"); 9 case HCI_HW_FAILURE: 10 return("Hardware Failure"); 11 case HCI_PAGE_TIMEOUT: 12 return("Page Timeout"); 13 case HCI_AUTHENTICATION_FAILURE: 14 return("Authentication Failure"); 15 case HCI_KEY_MISSING: 16 return("Key Missing"); 17 case HCI_MEMORY_FULL: 18 return("Memory Full"); 19 case HCI_CONN_TIMEOUT: 20 return("Connection Timeout"); 21 case HCI_MAX_NUMBER_OF_CONNECTIONS: 22 return("Max Number Of Connections"); 23 case HCI_MAX_NUMBER_OF_SCO_CONNECTIONS_TO_DEVICE: 24 return("Max Number Of SCO Connections To A Device"); 25 case HCI_ACL_CONNECTION_EXISTS: 26 return("ACL connection already exists"); 27 case HCI_COMMAND_DISSALLOWED: 28 return("Command Disallowed"); 29 case HCI_HOST_REJECTED_DUE_TO_LIMITED_RESOURCES: 30 return("Host Rejected due to limited resources"); 31 case HCI_HOST_REJECTED_DUE_TO_SECURITY_REASONS: 32 return("Host Rejected due to security reasons"); 33 case HCI_HOST_REJECTED_DUE_TO_REMOTE_DEVICE_ONLY_PERSONAL_SERVICE: 34 return("Host Rejected due to remote device is only a personal device"); 35 case HCI_HOST_TIMEOUT: 36 return("Host Timeout"); 37 case HCI_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE: 38 return("Unsupported Feature or Parameter Value"); 39 case HCI_INVALID_HCI_COMMAND_PARAMETERS: 40 return("Invalid HCI Command Parameters"); 41 case HCI_OTHER_END_TERMINATED_CONN_USER_ENDED: 42 return("Other End Terminated Connection: User Ended Connection"); 43 case HCI_OTHER_END_TERMINATED_CONN_LOW_RESOURCES: 44 return("Other End Terminated Connection: Low Resources"); 45 case HCI_OTHER_END_TERMINATED_CONN_ABOUT_TO_POWER_OFF: 46 return("Other End Terminated Connection: About to Power Off"); 47 case HCI_CONN_TERMINATED_BY_LOCAL_HOST: 48 return("Connection Terminated by Local Host"); 49 case HCI_REPETED_ATTEMPTS: 50 return("Repeated Attempts"); 51 case HCI_PAIRING_NOT_ALLOWED: 52 return("Pairing Not Allowed"); 53 case HCI_UNKNOWN_LMP_PDU: 54 return("Unknown LMP PDU"); 55 case HCI_UNSUPPORTED_REMOTE_FEATURE: 56 return("Unsupported Remote Feature"); 57 case HCI_SCO_OFFSET_REJECTED: 58 return("SCO Offset Rejected"); 59 case HCI_SCO_INTERVAL_REJECTED: 60 return("SCO Interval Rejected"); 61 case HCI_SCO_AIR_MODE_REJECTED: 62 return("SCO Air Mode Rejected"); 63 case HCI_INVALID_LMP_PARAMETERS: 64 return("Invalid LMP Parameters"); 65 case HCI_UNSPECIFIED_ERROR: 66 return("Unspecified Error"); 67 case HCI_UNSUPPORTED_LMP_PARAMETER_VALUE: 68 return("Unsupported LMP Parameter Value"); 69 case HCI_ROLE_CHANGE_NOT_ALLOWED: 70 return("Role Change Not Allowed"); 71 case HCI_LMP_RESPONSE_TIMEOUT: 72 return("LMP Response Timeout"); 73 case HCI_LMP_ERROR_TRANSACTION_COLLISION: 74 return("LMP Error Transaction Collision"); 75 case HCI_LMP_PDU_NOT_ALLOWED: 76 return("LMP PDU Not Allowed"); 77 case HCI_ENCRYPTION_MODE_NOT_ACCEPTABLE: 78 return("Encryption Mode Not Acceptable"); 79 case HCI_UNIT_KEY_USED: 80 return("Unit Key Used"); 81 case HCI_QOS_NOT_SUPPORTED: 82 return("QoS is Not Supported"); 83 case HCI_INSTANT_PASSED: 84 return("Instant Passed"); 85 case HCI_PAIRING_UNIT_KEY_NOT_SUPPORTED: 86 return("Pairing with Unit Key Not Supported"); 87 default: 88 return("Error code unknown"); 89 } 90 }
代码摘自:lwBT Bluetooth stack
时间: 2024-10-06 04:29:38