bluez가 페어링되었지만 연결이 끊어졌습니다.

bluez가 페어링되었지만 연결이 끊어졌습니다.

bluez=4.99-2저는 Raspian이 설치된 Raspberry와 오래된 USB 어댑터를 사용하고 있습니다 0a5c:200a Broadcom Corp. BCM2035.

Android 장치를 사용하여 연결했는데 동글이 지원되지 않으므로 sspmodePi에서는 bluez-simple-agent핀을 기다리기 위해 다른 셸을 실행합니다. Android에서 연결하면 임의의 핀이 포함된 대화 상자가 나타납니다. Pi를 입력하면 모든 것이 괜찮아 보이고 Android에서는 Pi가 페어링되었음을 표시합니다. 이는 훌륭합니다.

하지만 실제로는 페어링 직후 연결이 끊어집니다. 나는 서로 다른 SDP 레코드를 생성하고 서로 다른 bt 소켓 유형을 듣는 세 가지 다른 응용 프로그램을 시도했지만 모두 동일한 결과를 얻었지만 도착했지만 accept()반환되지 않았습니다.

bluetoothd핀 요청 및 연결 끊김이 포함된 로그 는 다음과 같습니다 .

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

제가 확인하고 있는 앱 3개 중 2개는 키보드 SDP를 등록하고, accept()물리적 USB 키보드에서 돌아와서 페어링된 장치로 이벤트 전송을 시작하도록 되어 있습니다.

(표시된 Android 기기와 페어링된 실제 물리적 BT 키보드연결됨수동 연결 해제가 없을 때까지 내가 실행 중인 제품은 그렇지 않습니다.)

(PIN을 입력한 후 안드로이드 폰을 페어링하면 폰이 끊기는 것 같더니 가끔씩 페어링이 안되는데 보통 안됨)

/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

도대체 무슨 일이 일어난 걸까요? 연결을 끊는 이유는 무엇입니까?

어떤 단서가 있나요?

관련 정보