123456789101112131415161718 |
- import bluetooth
- 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))
- serverMACAddress = '00:16:53:17:ea:9d'
- port = 3
- s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- s.connect((serverMACAddress, port))
- while 1:
- text = raw_input()
- if text == "quit":
- break
- s.send(text)
- sock.close()
|