Using PyS60 2.0.0 on E75 (3rd ed FP2).

The program should turn on Bluetooth if a connection fails using BtToggleApp. Then it should retry and connect, but it keeps failing. I realize this is a bad approach for a lot of applications, but I'm just controlling a personal robot. BlueS looks good but it isn't available signed

I thought for sure this would work, but after Bluetooth is turned on using BtToggleApp.exe connection attempts still fail. Perhaps this is because the previous attempt failed which resulted in turning Bluetooth on. Here is the snippet of code:

Code:
  s = btsocket.socket( btsocket.AF_BT, btsocket.SOCK_STREAM )
    found = False
    
    try:
        s.connect( (target_address, port) )
    except:
        e32.start_exe(u'BtToggleApp.exe','0')
        print "Attempting to connect\n"
        time.sleep(15)

        for n in range(10):
            if not found:
                try:
                    print 'attempt %d' % n
                    time.sleep(15)
                    s.connect( (target_address, port) )
                    print 'connected'
                    found = True
                except:
                    print 'attempt %d failed' % n
                    if n == 9:
                        appuifw.app.set_exit()
I basically want to know why future attempts fail every time, my code gives way more than ample time for Bluetooth to turn on and connect (unless I need to use a non-blocking sleep/time delay). Feel free to give me any additional pointers to my code, I'm a newbie Thanks!