try: address, services = socket.bt_discover() except: appuifw.note(u"SPP not available", "error") channel = choose_service(services) conn = socket.socket(socket.AF_BT, socket.SOCK_STREAM) conn.connect((address, channel)) to_peer = conn.makefile("rw", 0) while True: msg = appuifw.query(u"Send a message", "text") if msg: print >> to_peer, msg + "\r" print "Sending: " + msg print "Waiting for reply..." reply = read_and_echo(to_peer).strip() appuifw.note(unicode(reply), "info") if reply.find("bye!") != -1: break else: break