bluetoothd (BlueZ 5)가 어떤 장치와도 연결되지 않습니다


9

해결되었습니다. 편집 : 아래를 참조하십시오.

나는이 문제에 대해 오랫동안 인터넷을 닦았다 고 생각합니다. 여러 번 요청되었지만 해결책이 없습니다. 저에너지 기능을 궁극적으로 사용하고 싶기 때문에 BlueZ 5로 업그레이드했습니다. 하지만 지금은 기기를 페어링 할 수도 없습니다. 이것은 임베디드 리눅스 시스템을위한 것이기 때문에 GUI를 사용할 수 없습니다. 따라서 대화 형 세션이 필요하기 때문에 bluetoothctl도 사용할 수 없다고 생각합니다. (나는 틀릴 수도 있습니다.) 따라서 모든 것이 BASH, C 또는 Python을 통해 순서대로 이루어지기를 바랍니다. 또한 자동화가 필요하기 때문에 리눅스 박스가 아닌 블루투스 장치에서 페어링 및 연결을 시작해야합니다. 마지막으로 모든 장치는 a2dp 프로파일을 사용해야합니다.

많은 접근법이있는 것처럼 보이지만 한쪽 끝과 다른 쪽 끝이 어디인지는 확실하지 않습니다.

접근법 1 :

a) $ sudo bluetoothd -d -n # 상세 모드에서 블루투스로 실행

b) $ hciconfig hci1 up# 기기를 켭니다

$ hciconfig -a # 기기 속성 참조

    Type: BR/EDR  Bus: USB
    BD Address: 00:02:72:C5:D8:E0  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING PSCAN ISCAN 
    RX bytes:32875 acl:761 sco:0 events:1037 errors:0
    TX bytes:20178 acl:780 sco:0 commands:329 errors:0
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
    Link policy: RSWITCH SNIFF 
    Link mode: SLAVE ACCEPT 
    Name: 'Adapter-1'
    Class: 0x00010c
    Service Classes: Unspecified
    Device Class: Computer, Laptop
    HCI Version: 4.0 (0x6)  Revision: 0x1000
    LMP Version: 4.0 (0x6)  Subversion: 0x220e
    Manufacturer: Broadcom Corporation (15)

c) 장치와 페어링을 시도하십시오.

결과 : 블루투스에서 :

bluetoothd[5359]: src/adapter.c:connected_callback() hci1 device 70:72:3C:62:49:7F connected eir_len 15
bluetoothd[5359]: src/adapter.c:user_confirm_request_callback() hci1 70:72:3C:62:49:7F confirm_hint 1
bluetoothd[5359]: src/device.c:new_auth() Requesting agent authentication for 70:72:3C:62:49:7F
** bluetoothd[5359]: No agent available for request type 2
** bluetoothd[5359]: device_confirm_passkey: Operation not permitted 
bluetoothd[5359]: src/adapter.c:btd_adapter_confirm_reply() hci1 addr 70:72:3C:62:49:7F success 0
bluetoothd[5359]: src/adapter.c:bonding_attempt_complete() hci1 bdaddr 70:72:3C:62:49:7F type 0 status 0x5
bluetoothd[5359]: src/device.c:device_bonding_complete() bonding (nil) status 0x05
bluetoothd[5359]: src/device.c:device_bonding_failed() status 5
bluetoothd[5359]: src/adapter.c:resume_discovery() 
bluetoothd[5359]: src/adapter.c:dev_disconnected() Device 70:72:3C:62:49:7F disconnected, reason 3
bluetoothd[5359]: src/adapter.c:adapter_remove_connection() 
bluetoothd[5359]: src/adapter.c:bonding_attempt_complete() hci1 bdaddr 70:72:3C:62:49:7F type 0 status 0xe
bluetoothd[5359]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[5359]: src/device.c:device_bonding_failed() status 14
bluetoothd[5359]: src/adapter.c:resume_discovery()

PIN 또는 패스 키가 잘못되어 장치 가 Adapter-1과 페어링 할 수 없습니다.

위의 별표 표시된 답변을 바탕으로 상담원이없는 이유를 조사했습니다. 요원이 뭐야? 누가 알지만, 나는 그것이 내 장치와 블루투스 데몬 사이의 중개인이라고 추론했습니다.

d) # $ ../bluey-5.15/test/simple-agent 이 명령으로 sudo를 사용해 보았습니다.

또는 $ ../bluey-5.15/test/simple-agent hci1

이것은 들어오는 페어링 요청을 처리하는 파이썬 스크립트입니다. 성공하면 '신뢰'및 '연결'을 시도합니다.

산출: Agent registered

e) 그런 다음 장치와 다시 페어링을 시도합니다.

간단한 에이전트 출력 :

RequestConfirmation (/org/bluez/hci1/dev_70_72_3C_62_49_7F, 110643)
Confirm passkey (yes/no): yes 

BT 장치에서 페어를 쳤는데 페어링되었다고하지만 간단한 에이전트가 중단됩니다. BlueZ 4를 사용했으며 "New Device XX_XX_XX_XX_XX_XX"와 같은 문구를 사용해야합니다.

블루투스 출력 :

** bluetoothd[5359]: src/agent.c:set_default_agent() Default agent set to :1.126 /test/agent
bluetoothd[5359]: src/adapter.c:connected_callback() hci1 device 70:72:3C:62:49:7F connected eir_len 15
bluetoothd[5359]: src/adapter.c:user_confirm_request_callback() hci1 70:72:3C:62:49:7F confirm_hint 0
bluetoothd[5359]: src/device.c:new_auth() Requesting agent authentication for 70:72:3C:62:49:7F
bluetoothd[5359]: src/agent.c:agent_ref() 0xa59290: ref=2
bluetoothd[5359]: src/agent.c:agent_request_confirmation() Calling Agent.RequestConfirmation: name=:1.126, path=/test/agent, passkey=110643
bluetoothd[5359]: src/agent.c:agent_ref() 0xa59290: ref=3
bluetoothd[5359]: src/adapter.c:btd_adapter_confirm_reply() hci1 addr 70:72:3C:62:49:7F success 1
bluetoothd[5359]: src/agent.c:agent_unref() 0xa59290: ref=2
bluetoothd[5359]: src/agent.c:agent_unref() 0xa59290: ref=1
bluetoothd[5359]: src/adapter.c:new_link_key_callback() hci1 new key for 70:72:3C:62:49:7F type 5 pin_len 0
bluetoothd[5359]: src/device.c:device_set_bonded() 
bluetoothd[5359]: src/device.c:device_bonding_complete() bonding (nil) status 0x00
bluetoothd[5359]: src/adapter.c:resume_discovery() 
bluetoothd[5359]: src/adapter.c:dev_disconnected() Device 70:72:3C:62:49:7F disconnected, reason 3
bluetoothd[5359]: src/adapter.c:adapter_remove_connection() 
bluetoothd[5359]: src/adapter.c:bonding_attempt_complete() hci1 bdaddr 70:72:3C:62:49:7F type 0 status 0xe
bluetoothd[5359]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[5359]: src/device.c:device_bonding_failed() status 14
bluetoothd[5359]: src/adapter.c:resume_discovery()

그래서 이것은 무언가를합니다.

hcidump 출력 :

$ hcidump -i hci1

HCI sniffer - Bluetooth packet analyzer ver 5.15
device: hci1 snap_len: 1500 filter: 0xffffffffffffffff
> HCI Event: Connect Request (0x04) plen 10
    bdaddr 70:72:3C:62:49:7F class 0x5a020c type ACL
> HCI Event: Command Status (0x0f) plen 4
    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 11 bdaddr 70:72:3C:62:49:7F type ACL encrypt 0x00
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
> HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 11
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Command Complete (0x0e) plen 10
    IO Capability Request Reply (0x01|0x002b) ncmd 1
    status 0x00 bdaddr 70:72:3C:62:49:7F
> HCI Event: Read Remote Extended Features (0x23) plen 13
    status 0x00 handle 11 page 1 max 1
    Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr 70:72:3C:62:49:7F name 'Prism II'
> HCI Event: Command Complete (0x0e) plen 10
    User Confirmation Request Reply (0x01|0x002c) ncmd 1
    status 0x00 bdaddr 70:72:3C:62:49:7F
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 11 reason 0x13
    Reason: Remote User Terminated Connection

심지어 bluetoothctl을 시도했지만 동일한 결과가 있습니다. 재미있는 것은 BlueZ의 일부 스크립트 (예 : test-device)가 일부 명령에 대해서는 BT 장치를 볼 수 있지만 다른 명령은 볼 수 없다는 것입니다. 예를 들어 test-device는 장치를 '신뢰'하지만 '제거'하려고 할 때 존재하지 않습니다.

접근법 2 :

dbus-send --system 명령을 직접 사용하는 DBUS. 장치를 연결하고 연결할 때까지 이러한 명령 중 어느 것도 나에게 도움이되지 않는다고 생각합니다.

접근법 3 :

게시물 에 대한 모든 제안을 시도 했습니다 . BlueZ 5에는 /etc/bluetooth/hcid.conf가 없습니다. 하나를 만들어야합니까? rfcomm 명령이 연결되지만 바로 연결이 끊어집니다.

$ sudo rfcomm connect /dev/rfcomm0 70:72:3C:62:49:7F 1
Connected /dev/rfcomm0 to 70:72:3C:62:49:7F on channel 1
Press CTRL-C for hangup
Disconnected

블루투스 출력 :

bluetoothd[5359]: src/adapter.c:connected_callback() hci1 device 70:72:3C:62:49:7F connected eir_len 10
bluetoothd[5359]: src/adapter.c:dev_disconnected() Device 70:72:3C:62:49:7F disconnected, reason 3
bluetoothd[5359]: src/adapter.c:adapter_remove_connection() 
bluetoothd[5359]: src/adapter.c:bonding_attempt_complete() hci1 bdaddr 70:72:3C:62:49:7F type 0 status 0xe
bluetoothd[5359]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[5359]: src/device.c:device_bonding_failed() status 14
bluetoothd[5359]: src/adapter.c:resume_discovery()

hcidump 출력 :

$ hcidump -i hci1
HCI sniffer - Bluetooth packet analyzer ver 5.15
device: hci1 snap_len: 1500 filter: 0xffffffffffffffff
> HCI Event: Command Status (0x0f) plen 4
    Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 11 bdaddr 70:72:3C:62:49:7F type ACL encrypt 0x00
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
> HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 11
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Read Remote Extended Features (0x23) plen 13
    status 0x00 handle 11 page 1 max 1
    Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr 70:72:3C:62:49:7F name 'Prism II'
> HCI Event: Command Status (0x0f) plen 4
    Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
> HCI Event: Command Complete (0x0e) plen 10
    Link Key Request Reply (0x01|0x000b) ncmd 1
    status 0x00 bdaddr 70:72:3C:62:49:7F
> HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 11
> HCI Event: Command Status (0x0f) plen 4
    Set Connection Encryption (0x01|0x0013) status 0x00 ncmd 1
> HCI Event: Encrypt Change (0x08) plen 4
    status 0x00 handle 11 encrypt 0x01
> HCI Event: Command Status (0x0f) plen 4
    Exit Sniff Mode (0x02|0x0004) status 0x0c ncmd 1
    Error: Command Disallowed
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 11 reason 0x13
    Reason: Remote User Terminated Connection

어떤 제안? 나는 :

  • 정말 분명한 것을 잊었습니까?

  • 도구를 잘못 사용하십니까?

  • 설정 파일을 잊어 버리셨습니까?

편집하다:

bluez simple-agent가 유용한 오류를 제공하지 않았기 때문에 내 자신의 페어링 에이전트를 작성했습니다. 한 번 연결하면 연결할 수 없었습니다. bluetoothd에서이 새로운 오류가 발생했습니다.

bluetoothd[3078]: profiles/audio/a2dp.c:a2dp_source_connect() path /org/bluez/hci0/dev_70_72_3C_62_49_7F
bluetoothd[3078]: a2dp-source profile connect failed for 70:72:3C:62:49:7F: Protocol not available

이 게시물 은 내 LOCAL 블루투스 어댑터가 내 오디오 소스의 a2dp 프로파일을 지원하지 않았 음을 지적했습니다. (싱크대처럼 행동하지 않음) 그런 다음 많은 사람들이 BlueZ4에서 BlueZ5로 업그레이드하면서 동일한 문제가 발생하는 것을 보았습니다. 이 문제는 BlueZ 메일 링리스트 에도 게시되었습니다 .

지금까지이 프로토콜을 어댑터에 추가하는 방법을 찾지 못했습니다.


bluetoothctl을 사용해 보셨습니까? 올바른 에이전트를 설정하고 default-agent로 설정하십시오. 또한 힘의 도움으로 문제에 더 많은 통찰력을 얻기 btmon

답변 해 주셔서 감사합니다. 예. 새로운 구성 (BlueZ 5 및 PA 5, 아래 참조)으로 bluetoothctl을 사용할 수 있습니다.
MrUser

답변:


8

해결책:

프로파일 (a2dp)이 연결되어 있지 않고 다른 사람들도 동일한 문제가 있음을 확인한 후이 프로파일이 아직 BlueZ5에서 구현되었는지 여부를 조사했습니다. a2dp가 BlueZ 스택에서 GStreamer로 이동 했다고 설명하기 때문에 포팅 가이드를 충분히 읽지 않은 것 같습니다 . GStreamer에 대해 들어 본 적이 없지만 이 게시물 에서 PulseAudio와 JACK도이 프로필을 구현할 것임을 알았 습니다 . PulseAudio를 시도했지만 어댑터에 적절한 UUID를로드하지 않았습니다. 그런 다음 마침내 ArchLinux 위키 에서 게시물을 찾았 습니다. 이 페이지에 백만 번 가봤어야하지만 BlueZ4를 계속 사용하고 있었을 것입니다.

가장 중요한 것은:

-BlueZ5를 지원하는 새로운 PulseAudio 5 소스 코드를 다운로드하여 컴파일하십시오. (아파트 리포지토리에서 최신 버전이 아닙니다.)

-컴파일은 많은 의존성을 가져 왔습니다 (JSON, libsndfile, libcap 등)

-PA5의 경로는 / usr /가 아닌 / usr / local이라는 것을 명심하십시오 (PA가 시작시 libpulsecore-5.0을 찾을 수 있도록 $ LD_LIBRARY_PATH에 넣어야했기 때문에 중요합니다)

ArchLinux 위키가 말했듯이 시작시 실행되는 pulseaudio 서버를 종료하고 새로운 서버를 시작하십시오. 시작시 프로파일을로드하지 않습니다. 또한 데몬이 다시 생성되는지 확인하십시오. (/usr/local//etc/pulse/client.conf에서 설정)

그 후 일반적인 pactl 명령이 작동합니다. PA2로 스트리밍 할 a2dp BT 소스 (즉, iPod)를 확보 한 다음 루프백 모듈을 사용하여 a2dp BT 싱크로 스트리밍 할 수있었습니다!

ALSA와 함께 실행할 수 없었지만 BlueZ5가 더 이상 ALSA pcm 플러그인을 지원하지 않을 수도 있다고 읽었습니다.


2

위의 문제의 핵심은 다음과 같습니다. "발견이 중지되면 3 분 이내에 블루투스로 연결되거나 페어링되지 않은 장치가 자동으로 제거됩니다."

http://www.bluez.org/bluez-5-api-introduction-and-porting-guide/ 에서 장치 검색 섹션을 읽으십시오 .

비슷한 문제가 있었지만 페어링되고 연결되었습니다. 장치를 페어링하고 연결하려면 마지막 3 분 이내에 장치를 검색해야합니다. 간단한 에이전트와 bluetoothctl은 모두 잘 작동합니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.