Created
March 19, 2012 21:25
-
-
Save darkopetrovic/2127217 to your computer and use it in GitHub Desktop.
Python Bluetooth Link Example for the Zephyr BioHarness 3.0
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
# This is a simple example to connect and receiver packet | |
# from the Zephyr BioHarness 3.0 device via Bluetooth. | |
# use of PyBlueZ | |
import bluetooth | |
socket = bluetooth.BluetoothSocket( bluetooth.RFCOMM ) | |
try : | |
# Replace the MAC address | |
socket.connect(("E0:D7:BA:A7:7D:C9", 1)) | |
print "connected" | |
except bluetooth.BluetoothError : raise | |
try: | |
while True: | |
data = socket.recv(1024) | |
if len(data) == 0: break | |
print "received [%s]" % data.encode("hex") | |
# send LifeSign message | |
socket.send("0223000003".decode("hex")); | |
except IOError: | |
pass | |
print "disconnected" | |
socket.close() | |
print "all done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry for the delay :x Did you find a solution?
Seems that this is related to the pybluez package. Try a version that is compatible with python 2.7.
pybluez/pybluez#268