小编Pat*_*ckB的帖子

我无法列出 Raspberry Pi 附近的 BLE 设备(python、btmgmt)

我想使用从 cron 脚本调用的 python 脚本来扫描 Raspberry 环境中的 ble 设备。但是当我在 cron 中执行此操作时(我的意思是我添加到 sudo crontab -e),我最终总是得到一个空列表。

当我以 pi 用户身份登录时 - btmgmt 可以(仅)在 su 权限下正常工作:

pi@Pluto:~ $ btmgmt find
Unable to start discovery. status 0x14 (Permission Denied)

pi@Pluto:~ $ sudo btmgmt find
Discovery started
hci0 type 7 discovering on
hci0 dev_found: 77:F8:D7:8A:1E:E5 type LE Random rssi -83 flags 0x0000 
...
Run Code Online (Sandbox Code Playgroud)

所以在我的python脚本中我写道:

flog.write("P01:\r\n")
out = subprocess.Popen(['sudo', '/usr/bin/btmgmt', 'find'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = out.communicate()
flog.write("stderr: " + str(stderr) + "\r\n")
cDvc = stdout.split('\n')
flog.write("Amount …
Run Code Online (Sandbox Code Playgroud)

python cron raspberry-pi bluez

5
推荐指数
1
解决办法
485
查看次数

标签 统计

bluez ×1

cron ×1

python ×1

raspberry-pi ×1