bluez emparelhado mas desconectado

2

Estou executando bluez=4.99-2 em um Raspberry com Raspian instalado e um antigo dongle usb 0a5c:200a Broadcom Corp. BCM2035 .

Eu uso um dispositivo Android para se conectar a ele, o dongle não suporta sspmode , então no Pi eu inicio bluez-simple-agent em outro shell para aguardar o pin, quando eu conecto do Android um diálogo pop-up com um alfinete aleatório, eu entro no Pi e tudo parece bem, o show do Android Pi está emparelhado, ótimo.

Mas, na realidade, a conexão cai logo após o pareamento. Eu tentei três aplicativos diferentes que criam um registro sdp diferente e escutam tipos diferentes de soquetes bt, todos com o mesmo resultado, eles alcançam accept() mas nunca retornam.

Abaixo está o bluetoothd log com a solicitação de pin e a conexão caiu:

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

(sou particularmente atraído por bonding (nil) com status 0 ...)

log hcidump do mesmo período de tempo:

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

Dois dos três aplicativos que estou verificando devem registrar um sdp de teclado, retornar de accept() e começar a enviar eventos de um teclado físico para o dispositivo emparelhado.

(Um teclado bt físico real emparelhado com um dispositivo Android mostrado conectado até que não seja desconectado manualmente, os que eu estou executando não)

(Se eu emparelhar um telefone Android depois que eu inserir o pin, o telefone parece travar, então algum dia pare, muitas vezes não)

Em /etc/bluetooth/main.conf desabilitei todos os plugins bluez ( sdptool browse local não mostra nada antes de lançar o aplicativo), não entendo todas as entradas de áudio não relacionadas no log hcidump

sdptool browse local (o aplicativo registrado e anunciando seu registro 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

O que diabos está acontecendo? Por que desconectar?

Alguma pista?

    
por Alex 16.08.2015 / 12:37

0 respostas