Loading

python绝技 — 搜寻蓝牙设备

需要安装蓝牙模块:pybluez

sudo pip install pybluez

代码

#!/usr/bin/env python
#--*--coding=utf-8--*--
#P191
#sudo pip install pybluez

import time
from bluetooth import *
alreadyFound = []
def findDevs():
	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)

while True:
	findDevs()
	time.sleep(5)

 

 

  

posted @ 2016-11-28 09:17  ssooking  阅读(12932)  评论(2编辑  收藏  举报