bluez 已配对但已断开连接

bluez 已配对但已断开连接

bluez=4.99-2我在安装了 Raspian 和旧 USB 适配器的 Raspberry 上运行0a5c:200a Broadcom Corp. BCM2035

我使用 Android 设备连接到它,加密狗不支持,sspmode因此在 Pi 上我bluez-simple-agent在另一个 shell 上启动以等待 pin,当我从 Android 连接时,会弹出一个带有随机 pin 的对话框,我在 Pi 上输入它一切看起来都很好,Android 显示 Pi 已配对,太棒了。

但实际上,配对后连接立即断开。我尝试了三个不同的应用程序,它们创建不同的 sdp 记录并侦听不同的 bt 套接字类型,所有这些都具有相同的结果,它们到达accept()但从未返回。

以下是bluetoothd包含 pin 请求和连接断开的日志:

plugins/hciops.c:conn_complete() status 0x00
src/adapter.c:adapter_get_device() AC:22:0B:08:4B:52
plugins/hciops.c:remote_features_information() hci0 status 0
plugins/hciops.c:remote_name_information() hci0 status 0
plugins/hciops.c:pin_code_request() hci0 PIN request for AC:22:0B:08:4B:52
src/adapter.c:adapter_get_device() AC:22:0B:08:4B:52
src/device.c:device_request_authentication() Requesting agent authentication for AC:22:0B:08:4B:52
plugins/hciops.c:hciops_pincode_reply() hci0 dba AC:22:0B:08:4B:52
plugins/hciops.c:link_key_notify() hci0 dba AC:22:0B:08:4B:52 type 0
plugins/hciops.c:link_key_notify() key type 0x00 old key type 0x00
plugins/hciops.c:link_key_notify() local auth 0xff and remote auth 0xff
src/adapter.c:adapter_get_device() AC:22:0B:08:4B:52
src/event.c:btd_event_link_key_notify() storing link key of type 0x00
src/device.c:device_set_bonded() bonded 1
plugins/hciops.c:bonding_complete() status 0x00
src/adapter.c:adapter_get_device() AC:22:0B:08:4B:52
src/device.c:device_bonding_complete() bonding (nil) status 0x00
plugins/hciops.c:disconn_complete() handle 7 status 0x00
src/event.c:btd_event_disconn_complete() 
src/adapter.c:adapter_remove_connection() 

(我特别被bonding (nil)状态 0 所吸引......)

同一时间范围内的 hcidump 日志:

2015-08-16 09:11:59.633055 > HCI Event: Connect Request (0x04) plen 10
    bdaddr AC:22:0B:08:4B:52 class 0x5a020c type ACL
2015-08-16 09:11:59.633293 < HCI Command: Accept Connection Request (0x01|0x0009) plen 7
    bdaddr AC:22:0B:08:4B:52 role 0x01
    Role: Slave
2015-08-16 09:11:59.636061 > HCI Event: Command Status (0x0f) plen 4
    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
2015-08-16 09:11:59.654028 > HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 7 bdaddr AC:22:0B:08:4B:52 type ACL encrypt 0x00
2015-08-16 09:11:59.654691 < HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
    handle 7
2015-08-16 09:11:59.659064 > HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
2015-08-16 09:11:59.659379 < HCI Command: Change Connection Packet Type (0x01|0x000f) plen 4
    handle 7 ptype 0xcc18
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 
2015-08-16 09:11:59.663150 > HCI Event: Command Status (0x0f) plen 4
    Change Connection Packet Type (0x01|0x000f) status 0x0c ncmd 1
    Error: Command Disallowed
2015-08-16 09:11:59.681058 > HCI Event: Max Slots Change (0x1b) plen 3
    handle 7 slots 5
2015-08-16 09:11:59.703080 > HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 7
    Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x5b 0x87
2015-08-16 09:11:59.703417 < HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr AC:22:0B:08:4B:52 mode 2 clkoffset 0x0000
2015-08-16 09:11:59.703489 < ACL data: handle 7 flags 0x02 dlen 10
    L2CAP(s): Info req: type 2
2015-08-16 09:11:59.708084 > HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
2015-08-16 09:11:59.726961 > ACL data: handle 7 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x02fb
        Flow control mode
        Retransmission mode
        Enhanced Retransmission mode
        Streaming mode
        FCS Option
        Extended Flow Specification
        Fixed Channels
        Unicast Connectless Data Reception
2015-08-16 09:11:59.727426 < ACL data: handle 7 flags 0x02 dlen 10
    L2CAP(s): Info req: type 3
2015-08-16 09:11:59.764588 > ACL data: handle 7 flags 0x02 dlen 20
    L2CAP(s): Info rsp: type 3 result 0
      Fixed channel list 0x0000000e
        L2CAP Signalling Channel
        L2CAP Connless
        AMP Manager Protocol
2015-08-16 09:11:59.785034 > HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr AC:22:0B:08:4B:52 name 'ME173X'
2015-08-16 09:12:00.120080 > HCI Event: PIN Code Request (0x16) plen 6
    bdaddr AC:22:0B:08:4B:52
2015-08-16 09:12:04.416097 < HCI Command: PIN Code Request Reply (0x01|0x000d) plen 23
    bdaddr AC:22:0B:08:4B:52 len 4 pin '2276'
2015-08-16 09:12:04.419627 > HCI Event: Command Complete (0x0e) plen 10
    PIN Code Request Reply (0x01|0x000d) ncmd 1
    status 0x00 bdaddr AC:22:0B:08:4B:52
2015-08-16 09:12:04.523619 > HCI Event: Link Key Notification (0x18) plen 23
    bdaddr AC:22:0B:08:4B:52 key A0531A79732842487A17C6851D213AD2 type 0
    Type: Combination Key
2015-08-16 09:12:05.007839 > ACL data: handle 7 flags 0x02 dlen 12
    L2CAP(s): Connect req: psm 1 scid 0x0041
2015-08-16 09:12:05.008170 < ACL data: handle 7 flags 0x02 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0041 result 0 status 0
      Connection successful
2015-08-16 09:12:05.008228 < ACL data: handle 7 flags 0x02 dlen 23
    L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 11
      RFC 0x00 (Basic) 
2015-08-16 09:12:05.021707 > ACL data: handle 7 flags 0x02 dlen 16
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
      MTU 1691 
2015-08-16 09:12:05.021948 < ACL data: handle 7 flags 0x02 dlen 18
    L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 4
      MTU 1691 
2015-08-16 09:12:05.031838 > ACL data: handle 7 flags 0x02 dlen 14
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0
      Success
2015-08-16 09:12:05.040844 > ACL data: handle 7 flags 0x02 dlen 22
    L2CAP(d): cid 0x0040 len 18 [psm 1]
        SDP SSA Req: tid 0x6 len 0xd
          pat uuid-16 0x1108 (Headset)
          max 100
          aid(s) 0x0001 (SrvClassIDList)
          cont 00
2015-08-16 09:12:05.045121 < ACL data: handle 7 flags 0x02 dlen 14
    L2CAP(d): cid 0x0041 len 10 [psm 1]
        SDP SSA Rsp: tid 0x6 len 0x5
          count 2
          cont 00
2015-08-16 09:12:05.068467 > ACL data: handle 7 flags 0x02 dlen 22
    L2CAP(d): cid 0x0040 len 18 [psm 1]
        SDP SSA Req: tid 0x7 len 0xd
          pat uuid-16 0x1112 (Headset AG)
          max 100
          aid(s) 0x0001 (SrvClassIDList)
          cont 00
2015-08-16 09:12:05.071095 < ACL data: handle 7 flags 0x02 dlen 14
    L2CAP(d): cid 0x0041 len 10 [psm 1]
        SDP SSA Rsp: tid 0x7 len 0x5
          count 2
          cont 00
2015-08-16 09:12:05.084855 > ACL data: handle 7 flags 0x02 dlen 22
    L2CAP(d): cid 0x0040 len 18 [psm 1]
        SDP SSA Req: tid 0x8 len 0xd
          pat uuid-16 0x111e (Handsfree)
          max 100
          aid(s) 0x0001 (SrvClassIDList)
          cont 00
2015-08-16 09:12:05.087109 < ACL data: handle 7 flags 0x02 dlen 14
    L2CAP(d): cid 0x0041 len 10 [psm 1]
        SDP SSA Rsp: tid 0x8 len 0x5
          count 2
          cont 00
2015-08-16 09:12:05.098741 > ACL data: handle 7 flags 0x02 dlen 22
    L2CAP(d): cid 0x0040 len 18 [psm 1]
        SDP SSA Req: tid 0x9 len 0xd
          pat uuid-16 0x111f (Handsfree AG)
          max 100
          aid(s) 0x0001 (SrvClassIDList)
          cont 00
2015-08-16 09:12:05.099458 < ACL data: handle 7 flags 0x02 dlen 14
    L2CAP(d): cid 0x0041 len 10 [psm 1]
        SDP SSA Rsp: tid 0x9 len 0x5
          count 2
          cont 00
2015-08-16 09:12:05.113860 > ACL data: handle 7 flags 0x02 dlen 22
    L2CAP(d): cid 0x0040 len 18 [psm 1]
        SDP SSA Req: tid 0xa len 0xd
          pat uuid-16 0x110a (AudioSource)
          max 100
          aid(s) 0x0001 (SrvClassIDList)
          cont 00
2015-08-16 09:12:05.114851 < ACL data: handle 7 flags 0x02 dlen 14
    L2CAP(d): cid 0x0041 len 10 [psm 1]
        SDP SSA Rsp: tid 0xa len 0x5
          count 2
          cont 00
2015-08-16 09:12:05.128980 > ACL data: handle 7 flags 0x02 dlen 22
    L2CAP(d): cid 0x0040 len 18 [psm 1]
        SDP SSA Req: tid 0xb len 0xd
          pat uuid-16 0x110b (AudioSink)
          max 100
          aid(s) 0x0001 (SrvClassIDList)
          cont 00
2015-08-16 09:12:10.206340 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 7 reason 0x13
    Reason: Remote User Terminated Connection

我正在检查的三个应用程序中的两个应该注册键盘 sdp、从accept()物理 USB 键盘返回并开始向配对设备发送事件。

(真实的物理 bt 键盘与 Android 设备配对显示连接的直到没有手动断开连接,我正在运行的那些没有)

(如果我在输入 PIN 码后配对 Android 手机,手机似乎挂起,然后有时配对,通常不会)

/etc/bluetooth/main.conf我禁用了所有 bluez 插件(sdptool browse local在启动应用程序之前不显示任何内容)时,我不明白所有这些无关hcidump 日志中的音频条目

sdptool browse local(应用程序注册并公布其 sdp 记录):

Browsing FF:FF:FF:00:00:00 ...
Service Name: Raspberry Pi Virtual Keyboard
Service Description: USB > BT Keyboard
Service Provider: Raspberry Pi
Service RecHandle: 0x10000
Service Class ID List:
  "Human Interface Device" (0x1124)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 17
  "HIDP" (0x0011)
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Human Interface Device" (0x1124)
    Version: 0x0100

到底他妈发生了什么?为什么要断开连接?

有什么线索吗?

相关内容