python 尝试PyBluez

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 尝试PyBluez相关的知识,希望对你有一定的参考价值。

import bluetooth
from pprint import pprint

def search(searchTime):         
    devices = bluetooth.discover_devices(duration=searchTime, lookup_names = True)
    return devices

if __name__=="__main__":
    print "Start discovering...."
    results = search(10);
    if(results!=None):
        for addr, name in results:
            print "{0} - {1}".format(addr, name)
            service = bluetooth.find_service(address=addr)
            pprint(service)
        #endfor
    else:
        print "nothing found!"
    #endif
import bluetooth

def search(searchTime):         
    devices = bluetooth.discover_devices(duration=searchTime, lookup_names = True)
    return devices

if __name__=="__main__":
    print "Start discovering...."
    results = search(5);
    if(results!=None):
        for addr, name in results:
            print "{0} - {1}".format(addr, name)
        #endfor
    else:
        print "nothing found!"
    #endif
import bluetooth

print "Start discovering...."

nearby_devices = bluetooth.discover_devices()

print "Found devices:"
for bdaddr in nearby_devices:
    print bluetooth.lookup_name( bdaddr ), "with address:", bdaddr

以上是关于python 尝试PyBluez的主要内容,如果未能解决你的问题,请参考以下文章

Python 连接蓝牙 python3.8 安装 pybluez

RFCOMM 没有在 Debian 上使用 PyBluez 配对?

Windows下 python pybluez 安装使用记录

Windows下 python pybluez 安装使用记录

Windows下 python pybluez 安装使用记录

pybluez 未检测到任何设备