【发布时间】:2021-12-05 06:45:15
【问题描述】:
所以,我要做的是创建一个 Python 脚本,它允许我通过蓝牙将安卓手机与树莓派连接起来。如果我手动执行此操作(在命令行中编写指令),它工作得很好,我可以搜索、配对和连接范围内的任何设备。
但是,如果我通过脚本执行此操作,当我尝试激活代理时会弹出消息没有注册代理,这意味着我将无法配对任何设备,因为这是使树莓派和安卓手机显示的确认码一致的工具。
我使用的代码有点像这样。
import os
import sys
import time
os.system('sudo systemctl enable bluetooth')
os.system('sudo systemctl start bluetooth')
os.system('bluetoothctl discoverable on')
os.system('bluetoothctl agent on')
os.system('bluetoothctl default-agent')
os.system('bluetoothctl pairable on')
os.system('timeout 30 bluetoothctl scan on')
os.system('bluetoothctl pair XX:XX:XX:XX:XX:XX')
任何帮助或想法将不胜感激
【问题讨论】:
标签: python-3.x bluetooth raspberry-pi