×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    How to disconnect WiFi connection?

    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.

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    Re: How to disconnect WiFi connection?

    Sorry for reminding, but it is still bugging me.
    Can anybody help?

  3. #3
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: How to disconnect WiFi connection?

    Quote Originally Posted by pingwing View Post
    Sorry for reminding, but it is still bugging me.
    Can anybody help?
    Unfortunately I can't. Even when people call stop() from btsocket API, I have seen users reporting that sometimes the connection remains open.

  4. #4
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: How to disconnect WiFi connection?

    maybe a second try can help ???

    i mean something like
    try:
    con.close()
    execpt:
    do something else

    or even try to connect again and then disconnect again :P (of course if disconnect is successful in only a few cases ...)

Similar Threads

  1. how can I establish a wifi connection?
    By lmyuanhang in forum Symbian
    Replies: 3
    Last Post: 2009-09-18, 07:30
  2. How can I find some simple example code about wifi connection?
    By luckyapplehead in forum Wired and Wireless interfaces (Closed)
    Replies: 1
    Last Post: 2008-04-11, 23:14
  3. How to detect if we lost wifi connection?
    By oslario in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-03-20, 11:49
  4. Wifi and Bluetooth using at the same time
    By josiahchoi in forum General Development Questions
    Replies: 0
    Last Post: 2007-08-21, 10:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×