Bluez 5-从Bluez启动到iPhone的avrcp连接 [英] Bluez 5 - initiate avrcp connection to iPhone from Bluez

查看:779
本文介绍了Bluez 5-从Bluez启动到iPhone的avrcp连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bluez 5.28

Bluez 5.28

目标-控制iOS曲目跳过,并以编程方式从Bluez启动连接.不想a2dp.

Goal - Control iOS track skip, and initiate connection from Bluez programmatically. Do not want a2dp.

如果我启动从iPhone/iPad的连接(转到BT设置,单击Pi设备),一切都很好,我想避免这种情况,而不必摆弄手机. (使用Pi进行汽车设置).我有控制权,可以跟踪元数据等.

Everything works fine if I initiate connection from iPhone/iPad (go to BT settings, click on Pi device), which I want to avoid and not have to fiddle with the phone. (car setup with Pi). I have control, track metadata, etc.

在bluetoothctl中执行connect xx:xx:xx:xx:xx:xx会得到:

Doing a connect xx:xx:xx:xx:xx:xx in bluetoothctl yields:

 a2dp-source profile connect failed for 6C:70:9F:7E:EF:A8: Protocol not available

好的.它需要pulseaudio +模块.我安装了它,现在可以从Bluez连接了. 但是,它现在添加并自动选择Bluez作为音频输出设备.不想那样,必须再次摆弄手机.只需要控制.尽管我一点也不喜欢它,因为我可以在OS&的任何地方更改输出设备.不必进行设置.

Ok. It needs pulseaudio + modules. I install that, and now I can connect from Bluez. However, it now adds and automatically selects Bluez as an audio output device. Do not want that and have to fiddle with the phone again. Only want control. Though I prefer this if nothing at all, as I can change output device from anywhere in the OS & not have to go to settings.

好吧,让我一起禁用a2dp看看.

Well, let me disable a2dp all together and see.

/usr/libexec/bluetooth/bluetoothd -d -C -n --noplugin=a2dp

/usr/libexec/bluetooth/bluetoothd -d -C -n --plugin=avrcp

上述两项的结果相同

bluetoothd[14176]: src/device.c:connect_profiles() /org/bluez/hci0/dev_6C_70_9F_7E_EF_A8 (all), client :1.57
bluetoothd[14176]: src/device.c:connect_profiles() Resolving services for /org/bluez/hci0/dev_6C_70_9F_7E_EF_A8
bluetoothd[14176]: src/adapter.c:connected_callback() hci0 device 6C:70:9F:7E:EF:A8 connected eir_len 19
bluetoothd[14176]: src/device.c:search_cb() 6C:70:9F:7E:EF:A8: No service update
bluetoothd[14176]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_6C_70_9F_7E_EF_A8 err 0
bluetoothd[14176]: src/device.c:connect_profiles() /org/bluez/hci0/dev_6C_70_9F_7E_EF_A8 (all), client :1.57
bluetoothd[14176]: src/adapter.c:dev_disconnected() Device 6C:70:9F:7E:EF:A8 disconnected, reason 3
bluetoothd[14176]: src/adapter.c:adapter_remove_connection() 
bluetoothd[14176]: plugins/policy.c:disconnect_cb() reason 3
bluetoothd[14176]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 6C:70:9F:7E:EF:A8 type 0 status 0xe
bluetoothd[14176]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[14176]: src/device.c:device_bonding_failed() status 14
bluetoothd[14176]: src/adapter.c:resume_discovery() 

同样,如果我进入了蓝牙设置& ;;单击iPhone上的设备.问题是从Bluez获得连接.

Again, everything works exactly how I want it to if I go into Bluetooth settings & click on the device on the iPhone. The problem is getting the connection going from Bluez.

在我看来,iOS正在请求a2dp,但我不确定如何使Bluez超越这一标准,或者停止宣传其可用的产品.我知道有禁用个人资料的jaibreak选项,但尝试保持其清洁.

It looks to me like iOS is requesting a2dp, and I'm not sure how to make Bluez go past that, or stop advertising that its available. I know there are jaibreak options for disabling profiles, but trying to keep it clean.

我还尝试了HID设置,该设置可以发送击键,但随后隐藏了屏幕键盘.

I also experimented with HID setup that worked to send it keystrokes, but then it hides the on-screen keyboard.

谢谢!

推荐答案

使用源代码构建的5.28使其可以执行我想要的操作,但必须对其进行轻松地编辑.

Got it to do what I want to with 5.28 built from source, but had to edit it lightly.

不确定有什么副作用,但是我的目标很狭窄,所以我不在乎.

Not sure of any side-effects, but my goal is pretty narrow, so I don't really care.

修改profiles/audio/avrcp.c

添加

.auto_connect = true,

static struct btd_profile avrcp_target_profile = { @ 第3863行

static struct btd_profile avrcp_controller_profile = { @ 第3946行

make && make install

static struct btd_profile avrcp_target_profile = {
        .name           = "audio-avrcp-target",
        .remote_uuid    = AVRCP_TARGET_UUID,
        .device_probe   = avrcp_target_probe,
        .device_remove  = avrcp_target_remove,
        .auto_connect   = true,
        .connect        = avrcp_connect,
        .disconnect     = avrcp_disconnect,
        .adapter_probe  = avrcp_target_server_probe,
        .adapter_remove = avrcp_target_server_remove,
};

...

static struct btd_profile avrcp_controller_profile = {
        .name           = "avrcp-controller",
        .remote_uuid    = AVRCP_REMOTE_UUID,
        .device_probe   = avrcp_controller_probe,
        .device_remove  = avrcp_controller_remove,
        .auto_connect   = true,
        .connect        = avrcp_connect,
        .disconnect     = avrcp_disconnect,
        .adapter_probe  = avrcp_controller_server_probe,
        .adapter_remove = avrcp_controller_server_remove,
};

这篇关于Bluez 5-从Bluez启动到iPhone的avrcp连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆