python蓝牙模块

て烟熏妆下的殇ゞ 提交于 2020-03-08 11:31:55

需要安装蓝牙模块:pybluez

 

#pip install pybluez
 
import time
from bluetooth import *
alreadyFound = []
def findDevs():
    print("start searching...")
    foundDevs = discover_devices(lookup_names=True)
    for(addr,name) in foundDevs:
        if addr not in alreadyFound:
            print("[*] Found Bluetooth Device :  " +str(name))
            print("[+] MAC address :  " +str(addr))
            alreadyFound.append(addr)
 

findDevs()

 

import bluetooth
print("performing inquiry...")
nearby_devices = bluetooth.discover_devices(lookup_names = True)
print("found %d devices" % len(nearby_devices))
for addr, name in nearby_devices:
    print("  %s - %s" % (addr, name))

 

参考:

https://blog.csdn.net/abg49988/article/details/101867060

https://blog.csdn.net/qq_41204464/article/details/89258270

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!