A N95 cell phone is used to communicate with Arduino BT via bluetooth. In N95 side, I tried to run the following code named socket_test.py (in e folder). But an error appeared:
File "C:\private\2000b1a5/default.py", line 65, in query_and_exec execfile(script_list[index][1].encode('utf-8'), script_namespace.namespace)
File "e:\python\socket_test.py", line 1 {rtf1\ansi\ansicpg1252\cocoartf1038\cocasubrtf320
SyntaxError: invalid token

Anyone knows the reasons?

import socket, e32, appuifw

def choose_service(services):
names = []
channels = []
for name, channel in services.items():
names.append(name)
channels.append(channel)
index = appuifw.popup_menu(names, u"Choose service")
return channels[index]

def connect():
global sock
address, services = socket.bt_discover()
channel = choose_service(services)
sock = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
sock.connect((address, channel))

def receive():
global sock
data = sock.recv(1)
if data == "1":
appuifw.note(u"LED ON", "info")
elif data == "0":
appuifw.note(u"LED OFF", "info")

def bt_send_data1():
global sock
sock.send("1")
receive()

def bt_send_data2():
global sock
sock.send("0")
receive()

def exit_key_handler():
print "socket closed"
sock.close()
app_lock.signal()

app_lock = e32.Ao_lock()
appuifw.app.menu = [(u"LED on", bt_send_data1),(u"LED off", bt_send_data2),(u"connect", connect)]
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()