Bluetoothctl 无需任何用户交互

Mar*_*ark 7 linux bluetooth agent a2dp hfp

现在我可以通过这种方式成功配对并将手机连接到我的机器,而无需任何用户交互:

$bluetoothctl
#power on
#discoverable on
#pairable on
#agent NoInputNoOutput
#default-agent
Run Code Online (Sandbox Code Playgroud)

我从我的手机中搜索 BT 设备,它会自动配对和连接。现在我有两个问题:

  1. 它仍然要求授权服务:

    授权服务

    [代理] 授权服务 0000110e-0000-1000-8000-00805f9b34fb(是/否):

但这不好,因为我已经指定了NoInputNoOutput

  1. 如何信任一个设备?打字就足够了,trust但出于同样的原因,我需要自动执行此操作。

一般来说,是否有任何可靠的 C++ 库来处理蓝牙连接和 A2DP 和 HFP 等常见配置文件?

小智 2

我使用具有 NoInputNoOutput 功能的 bt-agent,并且不需要 A2DP 和 HFPprofiles 的任何权限。

bt-agent --capability=NoInputNoOutput
Run Code Online (Sandbox Code Playgroud)

检查链接了解更多详情。 https://www.kynetics.com/docs/2018/pairing_agents_bluez/