Android가 AVRCP 서비스(BlueZ-5.69)에 대한 연결을 거부합니다.

Android가 AVRCP 서비스(BlueZ-5.69)에 대한 연결을 거부합니다.

예전 차에는 기본 Bluetooth 오디오가 없었기 때문에 휴대폰으로 음악을 듣기 위해 Bluetooth 수신기를 자동차의 3.5mm 보조 잭에 연결했습니다. 문제는 운전 중에 휴대폰을 조작하지 않고 휴대폰 재생을 제어하는 ​​것입니다(이는 불법입니다 >:)).

그래서 재미있는 주말 프로젝트는 바나나 파이를 자동차의 CAN 버스에 연결하여 스티어링 휠의 미디어 버튼(aux에서 재생할 때는 사용되지 않음)을 듣고 바나나 파이가 A/B 역할을 하도록 하는 것이라고 생각했습니다. V Bluetooth 연결을 통해 휴대폰 미디어 플레이어를 제어하는 ​​휴대폰 미디어 컨트롤러입니다.

이 중 가장 쉬운 부분은 CAN 버스를 연결하고 스니핑하는 것입니다. 블루투스 부분은 그리 많지 않습니다. (제가 왜 약 20년 동안 블루투스 제품을 전혀 만지지 않았는지 기억하시나요?)

저는 Arch Linux에서 BlueZ-5.69를 사용하고 있습니다. AVRCP 프로필을 제외한 모든 항목을 비활성화했습니다.

[bluetooth]# show
Controller AA:AA:AA:AA:AA:AA (public)
  Name: "Car Controller"
  Alias: "Car Controller"
  Class: 0x0000050c (1292)
  Powered: yes
  PowerState: on
  Discoverable: no
  DiscoverableTimeout: 0x000000b4 (180)
  Pairable: yes
  UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
  UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
  UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
  Modalias: usb:v1D6Bp0246d0545
  Discovering: no
  Roles: central
  Roles: peripheral
  ExperimentalFeatures: BlueZ Experimental ISO... (6fbaf188-05e0-496a-9885-d6ddfdb4e03e)

내가 이해한 바로는 이렇게 하면 휴대폰이 연결되고 미디어 플레이어 컨트롤이 통과해야 합니다 dbus. 검색 및 페어링이 제대로 작동하는 것 같지만 페어링이 완료된 후 휴대폰 연결이 끊어지고 다시 연결이 거부됩니다(실제로 NAP 설정을 시도했습니다). bt-network 구성 파일을 사용하면 이제 전화기는 실제로 제공된 네트워크를 사용하여 연결을 유지합니다.

이것은 관점에서 휴대폰이 페어링될 때 발생하는 현상입니다 bluetoothctl.

[NEW] Device 3C:38:F4:93:55:61 Xperia 10 Ⅳ
Request confirmation
[agent] Confirm passkey 935792 (yes/no): yes
[CHG] Device 3C:38:F4:93:55:61 Bonded: yes
[CHG] Device 3C:38:F4:93:55:61 Modalias: usb:v0FCEp020Cd0010
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 3C:38:F4:93:55:61 UUIDs: a82efa21-ae5c-3dde-9bbc-f16da7b16c5a
[CHG] Device 3C:38:F4:93:55:61 ServicesResolved: yes
[CHG] Device 3C:38:F4:93:55:61 Paired: yes
[CHG] Device 3C:38:F4:93:55:61 ServicesResolved: no
[CHG] Device 3C:38:F4:93:55:61 Connected: no

bleutoothd로그 도 있어요

Sep 22 14:52:32 alarm bluetoothd[628]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000b
Sep 22 14:52:32 alarm bluetoothd[628]: src/adapter.c:connected_callback() hci0 device 3C:38:F4:93:55:61 connected eir_len 20
Sep 22 14:52:32 alarm bluetoothd[628]: src/device.c:device_create() dst 3C:38:F4:93:55:61
Sep 22 14:52:32 alarm bluetoothd[628]: src/device.c:device_new() address 3C:38:F4:93:55:61
Sep 22 14:52:32 alarm bluetoothd[628]: src/device.c:device_new() Creating device /org/bluez/hci0/dev_3C_38_F4_93_55_61
Sep 22 14:52:32 alarm bluetoothd[628]: src/device.c:device_set_class() /org/bluez/hci0/dev_3C_38_F4_93_55_61 0x5A020C
Sep 22 14:52:32 alarm bluetoothd[628]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000f
Sep 22 14:52:32 alarm bluetoothd[628]: src/adapter.c:user_confirm_request_callback() hci0 3C:38:F4:93:55:61 confirm_hint 0
Sep 22 14:52:32 alarm bluetoothd[628]: src/device.c:new_auth() Requesting agent authentication for 3C:38:F4:93:55:61
Sep 22 14:52:32 alarm bluetoothd[628]: src/agent.c:agent_ref() 0x1752050: ref=2
Sep 22 14:52:32 alarm bluetoothd[628]: src/agent.c:agent_request_confirmation() Calling Agent.RequestConfirmation: name=:1.62, path=/org/bluez/agent, passkey=935792
Sep 22 14:52:37 alarm bluetoothd[628]: src/agent.c:agent_ref() 0x1752050: ref=3
Sep 22 14:52:37 alarm bluetoothd[628]: src/adapter.c:btd_adapter_confirm_reply() hci0 addr 3C:38:F4:93:55:61 success 1
Sep 22 14:52:37 alarm bluetoothd[628]: src/agent.c:agent_unref() 0x1752050: ref=2
Sep 22 14:52:37 alarm bluetoothd[628]: src/agent.c:agent_unref() 0x1752050: ref=1
Sep 22 14:52:37 alarm bluetoothd[628]: src/shared/mgmt.c:send_request() [0x0000] command 0x001c
Sep 22 14:52:37 alarm bluetoothd[628]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x001c complete: 0x00
Sep 22 14:52:39 alarm bluetoothd[628]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x0009
Sep 22 14:52:39 alarm bluetoothd[628]: src/adapter.c:new_link_key_callback() hci0 new key for 3C:38:F4:93:55:61 type 8 pin_len 0 store_hint 1
Sep 22 14:52:39 alarm bluetoothd[628]: src/device.c:device_set_bonded() setting bonded for device to true
Sep 22 14:52:39 alarm bluetoothd[628]: src/device.c:btd_device_set_temporary() temporary 0
Sep 22 14:52:39 alarm bluetoothd[628]: src/device.c:device_bonding_complete() bonding (nil) status 0x00
Sep 22 14:52:39 alarm bluetoothd[628]: src/device.c:device_bonding_complete() setting timer for reverse service discovery
Sep 22 14:52:39 alarm bluetoothd[628]: src/adapter.c:resume_discovery()
Sep 22 14:52:39 alarm bluetoothd[628]: src/shared/mgmt.c:send_request() [0x0000] command 0x0033
Sep 22 14:52:39 alarm bluetoothd[628]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x002a
Sep 22 14:52:39 alarm bluetoothd[628]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0033 complete: 0x00
Sep 22 14:52:39 alarm bluetoothd[628]: src/adapter.c:add_accept_list_complete() 3C:38:F4:93:55:61 added to kernel accept list
Sep 22 14:52:41 alarm bluetoothd[628]: profiles/audio/avrcp.c:avrcp_controller_probe() path /org/bluez/hci0/dev_3C_38_F4_93_55_61
Sep 22 14:52:41 alarm bluetoothd[628]: profiles/audio/control.c:control_init() Registered interface org.bluez.MediaControl1 on path /org/bluez/hci0/dev_3C_38_F4_93_55_61
Sep 22 14:52:41 alarm bluetoothd[628]: src/service.c:btd_service_ref() 0x17458d0: ref=2
Sep 22 14:52:41 alarm bluetoothd[628]: src/service.c:change_state() 0x17458d0: device 3C:38:F4:93:55:61 profile avrcp-controller state changed: unavailable -> disconnected (0)
Sep 22 14:52:41 alarm bluetoothd[628]: profiles/audio/avrcp.c:avrcp_target_probe() path /org/bluez/hci0/dev_3C_38_F4_93_55_61
Sep 22 14:52:41 alarm bluetoothd[628]: src/service.c:btd_service_ref() 0x17524c0: ref=2
Sep 22 14:52:41 alarm bluetoothd[628]: src/service.c:change_state() 0x17524c0: device 3C:38:F4:93:55:61 profile audio-avrcp-target state changed: unavailable -> disconnected (0)
Sep 22 14:52:41 alarm bluetoothd[628]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_3C_38_F4_93_55_61 err 0
Sep 22 14:52:47 alarm bluetoothd[628]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c
Sep 22 14:52:47 alarm bluetoothd[628]: src/adapter.c:dev_disconnected() Device 3C:38:F4:93:55:61 disconnected, reason 3
Sep 22 14:52:47 alarm bluetoothd[628]: src/adapter.c:adapter_remove_connection()
Sep 22 14:52:47 alarm bluetoothd[628]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 3C:38:F4:93:55:61 type 0 status 0xe
Sep 22 14:52:47 alarm bluetoothd[628]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
Sep 22 14:52:47 alarm bluetoothd[628]: src/device.c:device_bonding_failed() status 14

이 줄을 읽으면 Sep 22 14:52:41 alarm bluetoothd[628]: profiles/audio/control.c:control_init() Registered interface org.bluez.MediaControl1 on path /org/bluez/hci0/dev_3C_38_F4_93_55_61유망해 보이지만 1초 이내에 연결이 끊어집니다.

그래서 이 지점에 도달한 후 포기할 때까지 나만의 AVRCP 프로필과 서비스를 구현하면서 약 일주일 동안 Bluetooth 표준 토끼굴을 따라갔습니다. 그러다가 오래된 아이폰을 꺼내서 바나나파이와 페어링하고 휴대폰의 연결버튼을 눌렀더니 이런 내용이 나왔습니다.

[agent] Authorize service 0000110e-0000-1000-8000-00805f9b34fb (yes/no): yes
[NEW] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 [default]
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Repeat: off
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Shuffle: off
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Status: stopped
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Key: Title
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Value:
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Key: TrackNumber
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Value: 0x00000000 (0)
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Key: NumberOfTracks
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Value: 0x00000000 (0)
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Key: Duration
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Value: 0x00000000 (0)
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Key: Album
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Value:
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Key: Artist
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Value:
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Key: Genre
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Track Value:
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Position: 0x00000000 (0)
[CHG] Player /org/bluez/hci0/dev_58_E2_8F_62_31_7C/player0 Position: 0x00000000 (0)

효과가있다!

이제 내 질문은 iPhone은 미디어 컨트롤러 서비스에 연결하는 데 문제가 없는 반면 Android 휴대폰(그 중 3개가 있습니다)은 페어링 후 연결을 시도조차 할 수 없는 이유입니다. 나는 여기서 정말 헤매고 있으므로 어떤 통찰력이라도 크게 감사하겠습니다.

관련 정보