【问题标题】:Bluez 5 - initiate avrcp connection to iPhone from BluezBluez 5 - 从 Bluez 启动到 iPhone 的 avrcp 连接
【发布时间】:2015-05-08 22:05:27
【问题描述】:

Bluez 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 设置,它可以向它发送击键,但随后它隐藏了屏幕键盘。

谢谢!

【问题讨论】:

    标签: bluetooth bluez a2dp avrcp


    【解决方案1】:

    使用从源代码构建的 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

    完成块

    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 启动 avrcp 服务的?
    • 假设这些是您必须安装的附加模块:pulseaudio_6.0, pulseaudio-module-bluetooth-discover, pulseaudio-module-bluetooth-policy, pulseaudio-module-bluez5-device, pulseaudio-module-bluez5-discover
    猜你喜欢
    • 2019-02-12
    • 2016-03-23
    • 1970-01-01
    • 2017-09-17
    • 2014-05-11
    • 2015-03-08
    • 2018-07-08
    • 2015-11-24
    • 2019-03-04
    相关资源
    最近更新 更多