首先,如果有人知道在我的raspberry pi zero w上用python编写蓝牙代码的好教程,可以打开发现、监听配对请求、连接并保存配对设备等等,那将是非常棒的。我测试蓝牙发现的代码如下。在
import bluetooth
print("performing inquiry...")
nearby_devices = bluetooth.discover_devices(
duration=8, lookup_names=True, flush_cache=True)
print("found %d devices" % len(nearby_devices))
for addr, name in nearby_devices:
try:
print(" %s - %s" % (addr, name))
except UnicodeEncodeError:
print(" %s - %s" % (addr, name.encode('utf-8', 'replace')))
回溯如下
^{pr2}$
(“访问蓝牙设备时出错”)就是线索。 是的-如前所述,您需要提升权限。 只需使用sudo运行脚本。。。 例如sudo pythonmyscript.py 输入您的密码 它现在应该可以工作了…用于测试目的。 用户将创建一个具有特权的bin/用户,并将其添加为false。 然后使用该用户运行所有脚本。。在
相关问题 更多 >
编程相关推荐