hello guys,
I want your help about my code.
the problem is when I want to apply in my phone show me this message error.
(NameError:name 'app_lock' is not defined).
this is my code :
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()
**** is anyone help me please.