我正在尝试让我的树莓手机扫描我家周围的设备,看看我家周围的交通情况。我遇到的问题是,我在github上找到的pybluez脚本可以工作,但它找不到设备。
因此,我立即跳到命令行并运行蓝牙扫描。命令行中的扫描起作用了,但是脚本一直告诉我没有发现任何设备。我还尝试下载了多个支持pybluez的蓝牙库,但仍然不起作用。
这就是我得到它的脚本。
```print "performing inquiry..."```print "found %d devices" % len(nearby_devices) print " %s - %s" % (addr, name)
This is what I get when I run this script.
```found 0 devices发布于 2019-08-31 02:45:24
我是一个为我工作的新user...this脚本:
# file: inquiry.py
# auth: Albert Huang <albert@csail.mit.edu>
# desc: performs a simple device inquiry followed by a remote name request of
# each discovered device
# $Id: inquiry.py 401 2006-05-05 19:07:48Z albert $
#
import bluetooth
print("performing inquiry...")
nearby_devices = bluetooth.discover_devices(
duration=8, lookup_names=True, flush_cache=True, lookup_class=False)
print("found %d device(s)" % 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')))该脚本发现我的蓝牙mouse...MAC地址部分隐藏:
performing inquiry...
found 1 device(s)
98:xx:xx:xx:xx:xx - HP Bluetooth Mouse X4000b
[Finished in 10.575s]发布于 2020-01-03 00:30:17
也许你现在已经解决了你的问题。在我的例子中,它是硬件的方向(raspberry pi 3b)。我认为蓝牙的探测范围因方向不同而不同。
https://stackoverflow.com/questions/57173208
复制相似问题