import btle
from time import sleep

class MyDelegate(btle.DefaultDelegate):
    def __init__(self, params=None):
        btle.DefaultDelegate.__init__(self)

    def handleNotification(self, cHandle, data):
        print data


address = "60:64:05:d1:43:ed"
addrType = "public"
uuid = "0000ffe0-0000-1000-8000-00805f9b34fb"

conn = btle.Peripheral(address, addrType)
conn.setDelegate(MyDelegate())
service = conn.getServiceByUUID(uuid)
char = service.getCharacteristics()[0]
char.write("Ready...")

print "Starting terminal, press 'Ctrl+C' to quit"
try:
	while True:
	    if conn.waitForNotifications(1.0):
	        # handleNotification() was called
	        continue

except:
	conn.disconnect()   
#print "Starting terminal, press 'Ctrl+C' to quit"
#try:
#	while True:
#		received = char.read();
		#if len(received) > 1:
		#print received,
#except:
#	conn.disconnect()
