Last active
September 25, 2017 18:54
-
-
Save ChunMinChang/c4278506bf91d1aad3d7 to your computer and use it in GitHub Desktop.
Trying PyBluez
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment