hci error code

见hcidefs.h

/*
 *  Defentions for HCI Error Codes that are past in the events
*/
#define HCI_SUCCESS 0x00
#define HCI_PENDING 0x00
#define HCI_ERR_ILLEGAL_COMMAND 0x01
#define HCI_ERR_NO_CONNECTION 0x02
#define HCI_ERR_HW_FAILURE 0x03
#define HCI_ERR_PAGE_TIMEOUT 0x04
#define HCI_ERR_AUTH_FAILURE 0x05
#define HCI_ERR_KEY_MISSING 0x06
#define HCI_ERR_MEMORY_FULL 0x07
#define HCI_ERR_CONNECTION_TOUT 0x08
#define HCI_ERR_MAX_NUM_OF_CONNECTIONS 0x09
#define HCI_ERR_MAX_NUM_OF_SCOS 0x0A
#define HCI_ERR_CONNECTION_EXISTS 0x0B
#define HCI_ERR_COMMAND_DISALLOWED 0x0C
#define HCI_ERR_HOST_REJECT_RESOURCES 0x0D
#define HCI_ERR_HOST_REJECT_SECURITY 0x0E
#define HCI_ERR_HOST_REJECT_DEVICE 0x0F
#define HCI_ERR_HOST_TIMEOUT 0x10
#define HCI_ERR_UNSUPPORTED_VALUE 0x11
#define HCI_ERR_ILLEGAL_PARAMETER_FMT 0x12
#define HCI_ERR_PEER_USER 0x13
#define HCI_ERR_PEER_LOW_RESOURCES 0x14
#define HCI_ERR_PEER_POWER_OFF 0x15
#define HCI_ERR_CONN_CAUSE_LOCAL_HOST 0x16
#define HCI_ERR_REPEATED_ATTEMPTS 0x17
#define HCI_ERR_PAIRING_NOT_ALLOWED 0x18
#define HCI_ERR_UNKNOWN_LMP_PDU 0x19
#define HCI_ERR_UNSUPPORTED_REM_FEATURE 0x1A
#define HCI_ERR_SCO_OFFSET_REJECTED 0x1B
#define HCI_ERR_SCO_INTERVAL_REJECTED 0x1C
#define HCI_ERR_SCO_AIR_MODE 0x1D
#define HCI_ERR_INVALID_LMP_PARAM 0x1E
#define HCI_ERR_UNSPECIFIED 0x1F
#define HCI_ERR_UNSUPPORTED_LMP_FEATURE 0x20
#define HCI_ERR_ROLE_CHANGE_NOT_ALLOWED 0x21
#define HCI_ERR_LMP_RESPONSE_TIMEOUT 0x22
#define HCI_ERR_LMP_ERR_TRANS_COLLISION 0x23
#define HCI_ERR_LMP_PDU_NOT_ALLOWED 0x24
#define HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE 0x25
#define HCI_ERR_UNIT_KEY_USED 0x26
#define HCI_ERR_QOS_NOT_SUPPORTED 0x27
#define HCI_ERR_INSTANT_PASSED 0x28
#define HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED 0x29
#define HCI_ERR_DIFF_TRANSACTION_COLLISION 0x2A
#define HCI_ERR_UNDEFINED_0x2B 0x2B
#define HCI_ERR_QOS_UNACCEPTABLE_PARAM 0x2C
#define HCI_ERR_QOS_REJECTED 0x2D
#define HCI_ERR_CHAN_CLASSIF_NOT_SUPPORTED 0x2E
#define HCI_ERR_INSUFFCIENT_SECURITY 0x2F
#define HCI_ERR_PARAM_OUT_OF_RANGE 0x30
#define HCI_ERR_UNDEFINED_0x31 0x31
#define HCI_ERR_ROLE_SWITCH_PENDING 0x32
#define HCI_ERR_UNDEFINED_0x33 0x33
#define HCI_ERR_RESERVED_SLOT_VIOLATION 0x34
#define HCI_ERR_ROLE_SWITCH_FAILED 0x35
#define HCI_ERR_INQ_RSP_DATA_TOO_LARGE 0x36
#define HCI_ERR_SIMPLE_PAIRING_NOT_SUPPORTED 0x37
#define HCI_ERR_HOST_BUSY_PAIRING 0x38
#define HCI_ERR_REJ_NO_SUITABLE_CHANNEL 0x39
#define HCI_ERR_CONTROLLER_BUSY 0x3A
#define HCI_ERR_UNACCEPT_CONN_INTERVAL 0x3B
#define HCI_ERR_ADVERTISING_TIMEOUT 0x3C
#define HCI_ERR_CONN_TOUT_DUE_TO_MIC_FAILURE 0x3D
#define HCI_ERR_CONN_FAILED_ESTABLISHMENT 0x3E
#define HCI_ERR_LIMIT_REACHED 0x43
#define HCI_ERR_MAC_CONNECTION_FAILED 0x3F

比如我们经常碰到的disconnect (下面从core_4.0截取的)

bt_btm_sec: btm_sec_disconnected clearing pending flag handle:2 reason:22

bte_main.cc

void post_to_hci_message_loop(const tracked_objects::Location& from_here,
                              BT_HDR* p_msg) {
  base::MessageLoop* hci_message_loop = get_message_loop();
  if (!hci_message_loop || !hci_message_loop->task_runner().get()) {
    LOG_ERROR(LOG_TAG, "%s: HCI message loop not running, accessed from %s",
              __func__, from_here.ToString().c_str());
    return;
  }

  hci_message_loop->task_runner()->PostTask(
      from_here, base::Bind(&btu_hci_msg_process, p_msg));
}
 

btu_hcif.cc

void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id, BT_HDR* p_msg) 

    case HCI_DISCONNECTION_COMP_EVT:
      btu_hcif_disconnection_comp_evt(p);

btu_hcif_disconnection_comp_evt(uint8_t* p)

  /* Notify security manager */
  btm_sec_disconnected(handle, reason);

btm_sec.cc

 btm_sec_disconnected(uint16_t handle, uint8_t reason)

  LOG_INFO(LOG_TAG, "%s clearing pending flag handle:%d reason:%d", __func__,
           handle, reason);

如果是本地主动断开,通常在java层有主动断开的日志, 不过往往在settings里没有这个打印,但可以以下也可以看出是主动断开的(以a2dp为例)

BluetoothHeadset: disconnect(*********** )

bt_btif : BTHF: disconnect

BluetoothA2dp: disconnect(*********** )

A2dpService: Enter Disconnect

CachedBluetoothDevice: Command sent successfully:DISCONNECT Address:***********  Profile:A2DP

bt_btif : disconnect

bt_btif : btif_av_state_opened_handler event:BTIF_AV_DISCONNECT_REQ_EVT flags 0 peer_sep 1 and index 0

bt_btm_sec: btm_sec_disconnected clearing pending flag handle:3 reason:22

bt_btm  : btm_sec_disconnected sec_req:x3080 state:IDLE reason:22 bd_addr:***********  remote_name:****

HeadsetStateMachine: A2DP connection for device ***********  is disconnected. Removing it

从上面可以看出HCI_ERR_CONN_CAUSE_LOCAL_HOST 0x16(22), 如果不是java层调用的,就需要检查本地是否有问题

从HCI上也可以看出是本地主动断开的

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值