bluetooth - Bluez 5 - 从 Bluez 启动与 iPhone 的 avrcp 连接

标签 bluetooth bluez a2dp avrcp

蓝兹5.28

目标 - 控制 iOS 轨道跳过,并以编程方式启动 Bluez 的连接。不想要 a2dp。

如果我从 iPhone/iPad 启动连接(转到 BT 设置,单击 Pi 设备),一切正常,我想避免这种情况,而不必摆弄手机。 (用 Pi 设置汽车)。我拥有控制权、跟踪元数据等。

在bluetoothctl中执行connect xx:xx:xx:xx:xx:xx会产生:

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

好的。它需要pulseaudio + 模块。我安装了它,现在我可以从 Bluez 进行连接。 但是,它现在添加并自动选择 Bluez 作为音频输出设备。不想这样,只好再次摆弄手机。只想控制。尽管我更喜欢这个(如果没有的话),因为我可以从操作系统中的任何位置更改输出设备,而不必进入设置。

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

/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 获取连接。

在我看来,iOS 正在请求 a2dp,但我不确定如何让 Bluez 超越该要求,或者停止宣传其可用。我知道有越狱选项可以禁用配置文件,但试图保持其干净。

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

谢谢!

最佳答案

使用从源代码构建的 5.28 来实现我想要的功能,但必须对其进行轻微编辑。

不确定是否有任何副作用,但我的目标相当狭窄,所以我不太关心。

编辑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

完整 block

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,
};

关于bluetooth - Bluez 5 - 从 Bluez 启动与 iPhone 的 avrcp 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28913396/

相关文章:

java - 在 PC 上运行的用于监听 Android 设备的 Bluez 应用程序

android - 如何在 Xamarin 中使用 BluetoothA2dp 类

android - 蓝牙接收器响应时间

c - 字符串是发送此数据的最有效方式吗?

linux - 如何编写在程序内部运行的命令脚本

bluetooth - 将音频发送到支持蓝牙的扬声器,IOS

android - 把安卓手机变成蓝牙耳机

java - 如何从我的 Android 设备中发现 UUID?

c - C中的整数获取随机值

c - 如何使用 Bluez Profile1 DBus API 注册连接回调