×

Discussion Board

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

    Question Bluetooth sockets problem. Permission Denied Error

    Hi Guys,
    I'm having a problem where I am connecting my phone via BT to an external device. If I power down my phone, and then run the script it works perfectly however when I try to run the script again I get an error:

    address,services = socket.bt_discover()
    error: (13, 'Permission Denied')
    This happens when the discovery starts on the mobile. Closing the python shell does not help, neither does turning off and on the bluetooth module.

    It happens when the script gracefully closes as well as when it crashes.

    Any ideas????

    Below is the relevant code:
    Code:
    import appuifw
    import e32
    import socket
    
    def bt_connect():
        print "starting to connect"
        global sock
        sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
        target=''
        if not target:
            address,services=socket.bt_discover()
            print "Discovered: %s, %s"%(address,services)
            if len(services)>1:
                import appuifw
                choices=services.keys()
                choices.sort()
                choice=appuifw.popup_menu([unicode(services[x])+": "+x
                                            for x in choices],u'Choose port:')
                target=(address,services[choices[choice]])
            else:
                target=(address,services.values()[0])
        print "Connecting to "+str(target)
        sock.connect(target)
        print "OK."
    
    		
    def bt_send_data(string): #send data to BT module. sends raw strings. 
    	global sock
    	sock.send(string)
    	#print string
    
    def bt_receive_data(): #return from bt.
        global sock
        i = 0
        buffer = [] 
        while(i <= 60):
             data = sock.recv(1)
             print str(ord(data))
             buffer.append(data)
             i = i + 1
        return buffer
    
    bt_connect() # connect to bt module. 
    
    def bt_close(): #close the bt sock when exiting
    	global sock
    	sock.close()
    	print "BTconnection closed"
    
    def format_bt(type,number):
    	number_string = str.zfill(str(number),4)
    	type = type[0]
    	output = type + number_string
    	return output
    
    def send_bt(type, number):
    	stringtosend = format_bt(type, number)
    	bt_send_data(stringtosend)
    
    
    def stop_controller():
    	send_bt('S',1)
    
    def flush_controller():
    	send_bt('S',2)
    
    initialise_controller()		
    
    	
    def exit_key_handler():
    	bt_close()
    	app_lock.signal()
    
    def singleshot(): 
    	send_bt("C",1)
    
    
    # create an Active Object
    app_lock = e32.Ao_lock()
    # create the tabs with its names in unicode as a list, include the tab handler
    appuifw.app.set_tabs([u"Single Shot", u"Fast Shot", u"Intervalometer", u"Pano",u"Config"],handle_tab)
    # set the title of the script
    appuifw.app.title = u'Canon 400D V2.011'
    # set app.body to app1 (for start of script)
    appuifw.app.body = app1
    #exit key handler
    appuifw.app.exit_key_handler = exit_key_handler
    
    #wait for lock
    app_lock.wait()
    Last edited by reg.orton; 2009-04-16 at 13:07. Reason: Title change

Similar Threads

  1. Bluesoleil Software
    By kencooper in forum Bluetooth Technology
    Replies: 9
    Last Post: 2008-08-29, 19:46
  2. Bluetooth Sockets with L2CAP
    By Shilpa13 in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-11-09, 05:37
  3. Bluetooth Sockets with L2CAP
    By Shilpa13 in forum Symbian
    Replies: 1
    Last Post: 2006-11-09, 02:56
  4. How To Make The S60 Emulator See My USB Bluetooth Dongle ?
    By Mo7ammed_01 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-07-25, 00:14
  5. Nokia 7650 support Bluetooth audo?
    By ovjo12 in forum Bluetooth Technology
    Replies: 5
    Last Post: 2003-07-17, 18:50

Posting Permissions

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