player-lejos.py 488 B

123456789101112131415161718
  1. import bluetooth
  2. # pybluez
  3. nearby_devices = bluetooth.discover_devices(lookup_names=True)
  4. print("found %d devices" % len(nearby_devices))
  5. for addr, name in nearby_devices:
  6. print(" %s - %s" % (addr, name))
  7. serverMACAddress = '00:16:53:17:ea:9d'
  8. port = 3
  9. s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
  10. s.connect((serverMACAddress, port))
  11. while 1:
  12. text = raw_input() # Note change to the old (Python 2) raw_input
  13. if text == "quit":
  14. break
  15. s.send(text)
  16. sock.close()