2

I'm running bluez=4.99-2 on a Raspberry with Raspian installed and an old usb dongle 0a5c:200a Broadcom Corp. BCM2035.

I use an Android device to connect to it, the dongle doesn't support sspmode so on the Pi I launch bluez-simple-agent on another shell to wait for the pin, when I connect from Android a Dialog pop up with a random pin, I enter it on Pi and everything seems fine, Android show Pi is paired, great.

But in real the connection is dropped right after pairing. I've tried three different application which create a different sdp record and listen on different bt socket type, all with the same result, they reach into accept() but never return.

Below is bluetoothd log with the pin request and the connection dropped:

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() 

(I'm particularly attracted by bonding (nil) with status 0 ...)

hcidump log of the same time-frame:

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

Two of the three application I'm checking should register a keyboard sdp, return from accept() and start sending events from a physical usb keyboard to the paired device.

(A real physical bt keyboard paired with an Android device show connected until isn't manually disconnected, those I'm running doesn't)

(If I pair an Android phone after I enter the pin, the phone seems to hang, then sometime pair, often doesn't)

In /etc/bluetooth/main.conf I've disabled all bluez plugins (sdptool browse local show nothing before I launch the application), I don't understand all those unrelated Audio entries in hcidump log

sdptool browse local (the application registered and advertising its sdp record):

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

What the heck is going on? Why disconnect?

Any clue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.