Last active
January 6, 2016 23:05
-
-
Save hackolite/34ce1a3475ed96c188f3 to your computer and use it in GitHub Desktop.
This file contains 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
# simple inquiry example | |
# votre module bluetooth doit etre connecte au prealable | |
import bluetooth | |
import sys | |
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)) | |
#mettre l'addresse mac de votre device | |
bd_addr = "20:15:05:11:00:99" | |
# a verifier | |
port = 1 | |
sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) | |
sock.connect((bd_addr, port)) | |
try: | |
while True: | |
sock.send("d") | |
data = sock.recv(1024) | |
if len(data) == 0: break | |
print("received [%s]" % data) | |
except IOError: | |
pass | |
sock.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment