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:
Code:
if e32.inactivity() > 120:
if connected:
disconnect()
del client
else:
if connected == 0:
client = connect()
connect 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
disconnect function:
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
I import the library using code:
Code:
sys.path.append("E:\\Python")
import mpd
In the library function close sends "goodbye" to server and disconnect does:
Code:
def disconnect(self):
self._rfile.close()
self._wfile.close()
self._sock.close()
self._reset()
But even after I do disconnect WiFi stays ON and uses battery.
What can I do?
WiFi connections is closed only after I close Python interpreter.