Hi.
I am writing an app to control my MPD (Music Player Daemon) with my Nokia E51 by wifi.
There is a generic python client library which uses socket module.
I am using pys60 1.9.7.
Everything is working very well, but I wanted to add powersaving to my app.
Here is code I wrote:
connect function:Code:if e32.inactivity() > 120: if connected: disconnect() del client else: if connected == 0: client = connect()
disconnect function:Code:def connect(): global ip_serwera global connected client = mpd.MPDClient() # create client object try: client.connect(ip_serwera, 6600) # connect to ip:6600 connected = 1 except: change_ip() return client
I import the library using code:Code:def disconnect(): global client global connected if connected: client.close() # send the close command client.disconnect() # disconnect from the server connected = 0 return 1
In the library function close sends "goodbye" to server and disconnect does:Code:sys.path.append("E:\\Python") import mpd
But even after I do disconnect WiFi stays ON and uses battery.Code:def disconnect(self): self._rfile.close() self._wfile.close() self._sock.close() self._reset()
What can I do?
WiFi connections is closed only after I close Python interpreter.

Reply With Quote



