Skip to content

Instantly share code, notes, and snippets.

@bholota
Created October 12, 2014 17:17
Show Gist options
  • Save bholota/5143fa49f3b4aef9d09c to your computer and use it in GitHub Desktop.
Save bholota/5143fa49f3b4aef9d09c to your computer and use it in GitHub Desktop.
import lightblue
server_sock = lightblue.socket()
server_sock.bind(("", 0))
server_sock.listen(1)
lightblue.advertise("RFCOMM mini server", server_sock, lightblue.RFCOMM)
client_sock, client_info = server_sock.accept()
print "Accepted connection from ", client_info
try:
while True:
client_sock.send("ASDF")
data = client_sock.recv(1024)
if len(data) == 0: break;
print("received [%s]" % data)
except IOError:
pass
print("disconnected")
client_sock.close()
server_sock.close()
print("all done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment