【发布时间】:2021-01-18 17:07:30
【问题描述】:
我正在开发一个项目,通过蓝牙连接使用 HC-05 蓝牙模块在树莓派和一系列 Arduino 之间进行通信。我可以使用 bluetoothctl 配对 arduino 并使用 python 脚本进行通信,但我也想在我的脚本中包含配对过程,但我还没有找到在脚本中包含蓝牙配对引脚的解决方案。
我尝试过的:
- PyBluez 库,但无法配对。
- 子进程,但我无法响应 pin 请求(代码如下),但这会导致错误 参数过多(对于 bluetoothctl)。
import subprocess, shlex
addr = "00:14:03:06:12:84"
pinCode = "1234"
args = ["bluetoothctl", f"pair {addr}", pinCode]
args = shlex(args)
subprocess.Popen(args)
- 我也尝试使用bluetoothctl wrapper,但这里也没有 pin 选项。
可以通过 python 配对吗?
【问题讨论】:
标签: bluetooth subprocess raspberry-pi3 hc-05