Sample Header Ad - 728x90

Android refuses to connect to AVRCP service (BlueZ-5.69)

1 vote
0 answers
220 views
I have an old car with no native Bluetooth for audio, so to use my phone for music, I have a Bluetooth receiver connected to the 3.5mm aux jack in my car. The problem is controlling the playback on the phone without having to handle the phone while driving (it's illegal you know >:) ). So, I got the idea that a fun weekend project would be to hook up my Banana Pi to the car's CAN bus in order to listen for the media buttons on the steering wheel (not used while playing from aux) while also having the Banana Pi act as an A/V Media Controller for the phone to connect to via Bluetooth to control the phones media player. The easy part in all of this was connecting and sniffing the CAN bus. The Bluetooth part, not so much. (remember why I haven't touched anything Bluetooth in about 20 years..) I'm using BlueZ-5.69 under Arch Linux. I have disabled all the features except for the AVRCP profile. [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) As I understand, this should allow the phone to connect and the media player controls should be exposed via dbus. Discovery and pairing seem to be working fine, but after pairing is done, the phone disconnects and refuses to connect again (I actually tried setting up a NAP profile as well with bt-network and now the phone actually stays connected using the network provided). This is what happens when paring the phone seen from the bluetoothctl perspective. [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 And the bleutoothd logs Sep 22 14:52:32 alarm bluetoothd: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000b Sep 22 14:52:32 alarm bluetoothd: src/adapter.c:connected_callback() hci0 device 3C:38:F4:93:55:61 connected eir_len 20 Sep 22 14:52:32 alarm bluetoothd: src/device.c:device_create() dst 3C:38:F4:93:55:61 Sep 22 14:52:32 alarm bluetoothd: src/device.c:device_new() address 3C:38:F4:93:55:61 Sep 22 14:52:32 alarm bluetoothd: src/device.c:device_new() Creating device /org/bluez/hci0/dev_3C_38_F4_93_55_61 Sep 22 14:52:32 alarm bluetoothd: src/device.c:device_set_class() /org/bluez/hci0/dev_3C_38_F4_93_55_61 0x5A020C Sep 22 14:52:32 alarm bluetoothd: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000f Sep 22 14:52:32 alarm bluetoothd: src/adapter.c:user_confirm_request_callback() hci0 3C:38:F4:93:55:61 confirm_hint 0 Sep 22 14:52:32 alarm bluetoothd: src/device.c:new_auth() Requesting agent authentication for 3C:38:F4:93:55:61 Sep 22 14:52:32 alarm bluetoothd: src/agent.c:agent_ref() 0x1752050: ref=2 Sep 22 14:52:32 alarm bluetoothd: 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: src/agent.c:agent_ref() 0x1752050: ref=3 Sep 22 14:52:37 alarm bluetoothd: src/adapter.c:btd_adapter_confirm_reply() hci0 addr 3C:38:F4:93:55:61 success 1 Sep 22 14:52:37 alarm bluetoothd: src/agent.c:agent_unref() 0x1752050: ref=2 Sep 22 14:52:37 alarm bluetoothd: src/agent.c:agent_unref() 0x1752050: ref=1 Sep 22 14:52:37 alarm bluetoothd: src/shared/mgmt.c:send_request() [0x0000] command 0x001c Sep 22 14:52:37 alarm bluetoothd: src/shared/mgmt.c:can_read_data() [0x0000] command 0x001c complete: 0x00 Sep 22 14:52:39 alarm bluetoothd: src/shared/mgmt.c:can_read_data() [0x0000] event 0x0009 Sep 22 14:52:39 alarm bluetoothd: 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: src/device.c:device_set_bonded() setting bonded for device to true Sep 22 14:52:39 alarm bluetoothd: src/device.c:btd_device_set_temporary() temporary 0 Sep 22 14:52:39 alarm bluetoothd: src/device.c:device_bonding_complete() bonding (nil) status 0x00 Sep 22 14:52:39 alarm bluetoothd: src/device.c:device_bonding_complete() setting timer for reverse service discovery Sep 22 14:52:39 alarm bluetoothd: src/adapter.c:resume_discovery() Sep 22 14:52:39 alarm bluetoothd: src/shared/mgmt.c:send_request() [0x0000] command 0x0033 Sep 22 14:52:39 alarm bluetoothd: src/shared/mgmt.c:can_read_data() [0x0000] event 0x002a Sep 22 14:52:39 alarm bluetoothd: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0033 complete: 0x00 Sep 22 14:52:39 alarm bluetoothd: 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: 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: 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: src/service.c:btd_service_ref() 0x17458d0: ref=2 Sep 22 14:52:41 alarm bluetoothd: 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: 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: src/service.c:btd_service_ref() 0x17524c0: ref=2 Sep 22 14:52:41 alarm bluetoothd: 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: 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: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c Sep 22 14:52:47 alarm bluetoothd: src/adapter.c:dev_disconnected() Device 3C:38:F4:93:55:61 disconnected, reason 3 Sep 22 14:52:47 alarm bluetoothd: src/adapter.c:adapter_remove_connection() Sep 22 14:52:47 alarm bluetoothd: 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: src/device.c:device_bonding_complete() bonding (nil) status 0x0e Sep 22 14:52:47 alarm bluetoothd: src/device.c:device_bonding_failed() status 14 Reading this line Sep 22 14:52:41 alarm bluetoothd: profiles/audio/control.c:control_init() Registered interface org.bluez.MediaControl1 on path /org/bluez/hci0/dev_3C_38_F4_93_55_61, it looks promising, but it disconnects after just a second or less. So, after getting this far, I went down the rabbit hole of Bluetooth standards for about a week, implementing my own AVRCP profile and service until I gave up. Then I dug up an old iPhone and paired it with the Banana Pi and just pressed connect on the phone and this is what I got back [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) It works! So my question now is why does the iPhone connect to the Media Controller service without any problems when any Android phone (3 of which I have available) won't even try to connect after pairing? I'm really at a loss here, so any insight would be greatly appreciated.
Asked by Patrik (61 rep)
Sep 22, 2023, 03:13 PM
Last activity: Sep 25, 2023, 05:07 AM