如何在Python中找到可见的蓝牙设备?

Ufo*_*guy 5 python wireless bluetooth

我需要在我的蓝牙调制解调器范围内找到可见蓝牙设备列表及其各自的详细信息.我只需要做蓝牙2.0及以下版本.我不需要做蓝牙4.0.

就像你在Android手机上使用"搜索设备"一样.

对不起,我不能提供任何我试过的代码,因为我不知道如何用python做蓝牙.

Kob*_*i K 9

PyBluez:

from bluetooth import *

print "performing inquiry..."

nearby_devices = discover_devices(lookup_names = True)

print "found %d devices" % len(nearby_devices)

for name, addr in nearby_devices:
     print " %s - %s" % (addr, name)
Run Code Online (Sandbox Code Playgroud)

另请参阅使用Python编程蓝牙

重要的是你可以使用 lookup_names = True

来自bluez文件:

if lookup_names is False, returns a list of bluetooth addresses.
if lookup_names is True, returns a list of (address, name) tuples
Run Code Online (Sandbox Code Playgroud)