Advertisement
snakerdlk

PC led toggle client python

Aug 8th, 2011
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import bluetooth
  2. bd_addr = “INSERT MODULE MAC ADDRESS”
  3.  
  4. port = 1
  5.  
  6. print “creating socket
  7. sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
  8.  
  9. print “connecting: “+bd_addr+”:”+str(port)
  10. sock.connect((bd_addr, port))
  11.  
  12. print “sending string
  13. sock.send(“led”)
  14.  
  15. print “waiting for answer”
  16. buff = “”
  17. while(buff != “OK” and buff != “ERROR”):
  18.     buff += sock.recv(1)
  19. print buff
  20.  
  21. print “closing socket
  22. sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement