×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    did i break my phone?

    hi guys, been messing about as you can probably tell from my previous posts but now i think i may have broken something!

    my phone will no longer connect bluetooth from the python interpreter. it will accept bluetooth connections from the computer and from the gps unit, however when i run code that used to work it no longer connects or brings up the discover box.

    i have done a hard reset and reinstalled python interpreter but it still doesn't work.

    is there anything else i can do?

    thanks

    docGroup14

  2. #2
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,796

    Re: did i break my phone?

    Quote Originally Posted by docGroup14 View Post

    my phone will no longer connect bluetooth from the python interpreter.
    Hello docGroup14

    Well would you like to share your code that you use to connect your device through bluetooth? I think that may provide some help to ypu as well.Moreover if your Bluetooth connections are working fine outside python interpreter as you have mentioned., then i dont think that there might be some fault with your device..Just a minor code error..So do paste your code here...

    Hope that helps
    Pankaj Nathani
    www.croozeus.com

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    Re: did i break my phone?

    hi, thanks for the reply. i did manage to run bt_discover from some other code so you are right it is indeed a code error.

    here is the code, it crashes, i think because of multiple threads. Y.A.K was helping me in my other thread.

    Code:
    def gps():
            #checks gps
    
    def gpsDaemon():
    	gps()
    	gpsTimer.after(30, gpsDaemon)
    
    def handle_selection():
    	index = lb.current()
    	code = choices[index][1]
    
    	if code == "startGPS":
    		thread.start_new_thread(gpsDaemon,())
           
    	elif code == "stopGPS":
    		gpsTimer.cancel()
    thanks

    docGroup14

    edit: i have also tried it with thread locks as Y.A.K suggested but that crashed too, i have also tried it so that gpsDaemon starts a new thread gps(), but this crashed too!!

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    Re: did i break my phone?

    Code:
    	btSocket = socket.socket(socket.AF_BT, socket.SOCK_STREAM) #create bluetooth socket
    		if mac_address == '':
    			address,services = socket.bt_discover() #search bluetooth devices
    			print "Discovered: %s, %s"%(address, services)
    			mac_address = (address, services.values()[0])
    			if appuifw.query(u"Do you want to always connect to this device?", "query") == True:
    				f = open("c:\\mac_address", 'wb')
    				marshal.dump(mac_address, f)
    				f.close()
    		btSocket.connect(mac_address)
    this is the code that doesn't appear to work. even though it used to however if i just make a new file with socket.socket(socket.AF_BT, socket.SOCK_STREAM) then do bt_discover then it works.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    Re: did i break my phone?

    oh crap, sorry for wasting your time was a really dumb error on my part.

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    386

    Re: did i break my phone?

    Please do share it with us to help others that get themselfes in a simmilar situation.

    The code from your previous post (the one that crashes for you) isn't right. You're sharing a timer between threads there. You should only start gps function in a separate thread.

    Code:
    def gps():
            #checks gps
            pass
    
    def gpsDaemon():
            thread.start_new_thread(gps, ())
    	gpsTimer.after(30, gpsDaemon)
    
    def handle_selection():
    	index = lb.current()
    	code = choices[index][1]
    
    	if code == "startGPS":
                    gpsTimer.after(0, gpsDaemon)
           
    	elif code == "stopGPS":
    		gpsTimer.cancel()
    This really shouln't crash as long as you don't do anything illegal in the gps() function. Illegal would be accessing main thread's active objects or appuifw module. I'm not sure about limitations of gps things thou.

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    Re: did i break my phone?

    thanks Y.A.K i will give it a shot. my dumb error was that im testing for mac_address == ''

    but i tried to load something into mac_address, and if there was an exception i just wrote "pass". when i changed this to mac_address = '' then it worked fine!!!

    the only reason it hadn't failed before was because i was always loading something into mac_address - when i deleted the file being loaded the error popped up!

  8. #8
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    Re: did i break my phone?

    Quote Originally Posted by y.a.k View Post
    Please do share it with us to help others that get themselfes in a simmilar situation.

    The code from your previous post (the one that crashes for you) isn't right. You're sharing a timer between threads there. You should only start gps function in a separate thread.

    Code:
    def gps():
            #checks gps
            pass
    
    def gpsDaemon():
            thread.start_new_thread(gps, ())
    	gpsTimer.after(30, gpsDaemon)
    
    def handle_selection():
    	index = lb.current()
    	code = choices[index][1]
    
    	if code == "startGPS":
                    gpsTimer.after(0, gpsDaemon)
           
    	elif code == "stopGPS":
    		gpsTimer.cancel()
    This really shouln't crash as long as you don't do anything illegal in the gps() function. Illegal would be accessing main thread's active objects or appuifw module. I'm not sure about limitations of gps things thou.
    ah the reason i didn't want to use something like this is because if the gps thread takes longer than 30 seconds to complete, then another thread will still be made. when you told me to use thread.allocate_lock() i thought that you were onto something, but that still crashed so i have no way of knowing when the gps thread finishes and therefore when i should start scheduling a new one.

    unless i can use the locks in the gpsDaemon function.

    by the way, when i say crash i mean the program still ran but was unresponsive - it didn't crash out of the interpreter. it kept hanging / crashing when i made a new thread.

    thanks

    docGroup14

  9. #9
    Registered User
    Join Date
    Jun 2005
    Posts
    386

    Re: did i break my phone?

    You can use a global flag that will tell you if the thread is still running.

  10. #10
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    Re: did i break my phone?

    yeah im going to use that, but i dont like it

    edit: the reason i dont like it, is that it requires a busy wait or a timer waiting until the gps has finished.
    Last edited by docGroup14; 2007-10-22 at 19:26.

Similar Threads

  1. how to retrieve cellid from a mobile phone
    By aloke in forum Symbian
    Replies: 72
    Last Post: 2009-02-05, 11:13
  2. OMA DRM media transfer using PC to Phone using USB
    By venky123 in forum Digital Rights Management & Content Downloading
    Replies: 1
    Last Post: 2008-08-13, 03:02
  3. The Nokia 9210i is the shittiest nokia phone ever!
    By awyeah in forum General Development Questions
    Replies: 2
    Last Post: 2007-10-18, 10:31
  4. Replies: 0
    Last Post: 2005-04-07, 08:22
  5. 7610 Contacts - Formatted Phone Numbers
    By padlon in forum General Development Questions
    Replies: 2
    Last Post: 2004-11-12, 18:02

Posting Permissions

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