错误码定义:
/* Success code */
#define HCI_SUCCESS 0x00
/* Possible error codes */
#define HCI_UNKNOWN_HCI_COMMAND 0x01
#define HCI_NO_CONNECTION 0x02
#define HCI_HW_FAILURE 0x03
#define HCI_PAGE_TIMEOUT 0x04
#define HCI_AUTHENTICATION_FAILURE 0x05
#define HCI_KEY_MISSING 0x06
#define HCI_MEMORY_FULL 0x07
#define HCI_CONN_TIMEOUT 0x08
#define HCI_MAX_NUMBER_OF_CONNECTIONS 0x09
#define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS_TO_DEVICE 0x0A
#define HCI_ACL_CONNECTION_EXISTS 0x0B
#define HCI_COMMAND_DISSALLOWED 0x0C
#define HCI_HOST_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D
#define HCI_HOST_REJECTED_DUE_TO_SECURITY_REASONS 0x0E
#define HCI_HOST_REJECTED_DUE_TO_REMOTE_DEVICE_ONLY_PERSONAL_SERVICE 0x0F
#define HCI_HOST_TIMEOUT 0x10
#define HCI_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE 0x11
#define HCI_INVALID_HCI_COMMAND_PARAMETERS 0x12
#define HCI_OTHER_END_TERMINATED_CONN_USER_ENDED 0x13
#define HCI_OTHER_END_TERMINATED_CONN_LOW_RESOURCES 0x14
#define HCI_OTHER_END_TERMINATED_CONN_ABOUT_TO_POWER_OFF 0x15
#define HCI_CONN_TERMINATED_BY_LOCAL_HOST 0x16
#define HCI_REPETED_ATTEMPTS 0x17
#define HCI_PAIRING_NOT_ALLOWED 0x18
#define HCI_UNKNOWN_LMP_PDU 0x19
#define HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A
#define HCI_SCO_OFFSET_REJECTED 0x1B
#define HCI_SCO_INTERVAL_REJECTED 0x1C
#define HCI_SCO_AIR_MODE_REJECTED 0x1D
#define HCI_INVALID_LMP_PARAMETERS 0x1E
#define HCI_UNSPECIFIED_ERROR 0x1F
#define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20
#define HCI_ROLE_CHANGE_NOT_ALLOWED 0x21
#define HCI_LMP_RESPONSE_TIMEOUT 0x22
#define HCI_LMP_ERROR_TRANSACTION_COLLISION 0x23
#define HCI_LMP_PDU_NOT_ALLOWED 0x24
#define HCI_ENCRYPTION_MODE_NOT_ACCEPTABLE 0x25
#define HCI_UNIT_KEY_USED 0x26
#define HCI_QOS_NOT_SUPPORTED 0x27
#define HCI_INSTANT_PASSED 0x28
#define HCI_PAIRING_UNIT_KEY_NOT_SUPPORTED 0x29
hci_get_err_code:
char * hci_get_error_code(u8_t code) {
switch(code) {
case HCI_SUCCESS:
return("Success");
case HCI_UNKNOWN_HCI_COMMAND:
return("Unknown HCI Command");
case HCI_NO_CONNECTION:
return("No Connection");
case HCI_HW_FAILURE:
return("Hardware Failure");
case HCI_PAGE_TIMEOUT:
return("Page Timeout");
case HCI_AUTHENTICATION_FAILURE:
return("Authentication Failure");
case HCI_KEY_MISSING:
return("Key Missing");
case HCI_MEMORY_FULL:
return("Memory Full");
case HCI_CONN_TIMEOUT:
return("Connection Timeout");
case HCI_MAX_NUMBER_OF_CONNECTIONS:
return("Max Number Of Connections");
case HCI_MAX_NUMBER_OF_SCO_CONNECTIONS_TO_DEVICE:
return("Max Number Of SCO Connections To A Device");
case HCI_ACL_CONNECTION_EXISTS:
return("ACL connection already exists");
case HCI_COMMAND_DISSALLOWED:
return("Command Disallowed");
case HCI_HOST_REJECTED_DUE_TO_LIMITED_RESOURCES:
return("Host Rejected due to limited resources");
case HCI_HOST_REJECTED_DUE_TO_SECURITY_REASONS:
return("Host Rejected due to security reasons");
case HCI_HOST_REJECTED_DUE_TO_REMOTE_DEVICE_ONLY_PERSONAL_SERVICE:
return("Host Rejected due to remote device is only a personal device");
case HCI_HOST_TIMEOUT:
return("Host Timeout");
case HCI_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE:
return("Unsupported Feature or Parameter Value");
case HCI_INVALID_HCI_COMMAND_PARAMETERS:
return("Invalid HCI Command Parameters");
case HCI_OTHER_END_TERMINATED_CONN_USER_ENDED:
return("Other End Terminated Connection: User Ended Connection");
case HCI_OTHER_END_TERMINATED_CONN_LOW_RESOURCES:
return("Other End Terminated Connection: Low Resources");
case HCI_OTHER_END_TERMINATED_CONN_ABOUT_TO_POWER_OFF:
return("Other End Terminated Connection: About to Power Off");
case HCI_CONN_TERMINATED_BY_LOCAL_HOST:
return("Connection Terminated by Local Host");
case HCI_REPETED_ATTEMPTS:
return("Repeated Attempts");
case HCI_PAIRING_NOT_ALLOWED:
return("Pairing Not Allowed");
case HCI_UNKNOWN_LMP_PDU:
return("Unknown LMP PDU");
case HCI_UNSUPPORTED_REMOTE_FEATURE:
return("Unsupported Remote Feature");
case HCI_SCO_OFFSET_REJECTED:
return("SCO Offset Rejected");
case HCI_SCO_INTERVAL_REJECTED:
return("SCO Interval Rejected");
case HCI_SCO_AIR_MODE_REJECTED:
return("SCO Air Mode Rejected");
case HCI_INVALID_LMP_PARAMETERS:
return("Invalid LMP Parameters");
case HCI_UNSPECIFIED_ERROR:
return("Unspecified Error");
case HCI_UNSUPPORTED_LMP_PARAMETER_VALUE:
return("Unsupported LMP Parameter Value");
case HCI_ROLE_CHANGE_NOT_ALLOWED:
return("Role Change Not Allowed");
case HCI_LMP_RESPONSE_TIMEOUT:
return("LMP Response Timeout");
case HCI_LMP_ERROR_TRANSACTION_COLLISION:
return("LMP Error Transaction Collision");
case HCI_LMP_PDU_NOT_ALLOWED:
return("LMP PDU Not Allowed");
case HCI_ENCRYPTION_MODE_NOT_ACCEPTABLE:
return("Encryption Mode Not Acceptable");
case HCI_UNIT_KEY_USED:
return("Unit Key Used");
case HCI_QOS_NOT_SUPPORTED:
return("QoS is Not Supported");
case HCI_INSTANT_PASSED:
return("Instant Passed");
case HCI_PAIRING_UNIT_KEY_NOT_SUPPORTED:
return("Pairing with Unit Key Not Supported");
default:
return("Error code unknown");
}
}
代码摘自:lwBT Bluetooth stack