×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    23

    bt_discover on N95

    Hi all,
    I need to make a Bluetooth RFCOMM connection on N95s running Python for S60 1.4.1 but for the N95 it doesn't work. Does anybody know why?

    Script Server-side:

    Code:
    from socket import *
    import appuifw
    
    server_socket = socket(AF_BT, SOCK_STREAM)
    p = bt_rfcomm_get_available_server_channel(server_socket)
    server_socket.bind(("", p))
    print "bind done"
    server_socket.listen(1)
    bt_advertise_service( u"jurgen", server_socket, True, RFCOMM)
    set_security(server_socket, AUTH)
    print "I am listening"
    
    # Note: Don't call .send or .recv on the server_socket!
    # Use the sock object returned by server_socket.accept().
    (sock,peer_addr) = server_socket.accept()
    print "Connection from %s"%peer_addr
    test = appuifw.query(u"Type words", "text", u"")
    sock.send(test+'\n')
    print "sending done"
    import e32
    # Allow time for data to be sent to work around a bug in the socket
    # module.
    e32.ao_sleep(1)
    sock.close()
    Script Client-side:

    Code:
    import socket
    import appuifw
    import e32
    
    class BTReader:
        def connect(self):
            self.sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
            addr,services=socket.bt_discover()
            print "Discovered: %s, %s"%(addr,services)
            if len(services)>0:
                import appuifw
                choices=services.keys()
                choices.sort()
                choice=appuifw.popup_menu([unicode(services[x])+": "+x
                                           for x in choices],u'Choose port:')
                port=services[choices[choice]]
            else:
                port=services[services.keys()[0]]
            address=(addr,port)
            print "Connecting to "+str(address)+"...",
            self.sock.connect(address)
            print "OK." 
        def readline(self):
            line=[]
            while 1:
                ch=self.sock.recv(1)
                if(ch=='\n'):
                    break
                line.append(ch)
            return ''.join(line)
        def close(self):
            self.sock.close()
    
    bt=BTReader()
    bt.connect()
    print "Received: "+bt.readline()
    bt.close()
    I have also tried this code with some N71s(running Python for S60 1.4.1). it works in these cases:

    Server: N71 - Client N71
    Server: N71 - Client N95

    it doesn't work if:

    Server: N95 - Client N95
    Server: N95 - Client N71

    In particular what happened is this: on the server side the script seems to be running; on the client side the application make the bt_discover but when i select the server-device on the list the application is turned off.

    I hope you can help me
    thank you, Chiara

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    23

    Re: bt_discover on N95

    Hi,
    the problem is the bluetooth discovery. I tried also this simple code and python got turned off if I select an N95 in the list of the devices.

    Code:
    import socket   
    address, services = socket.bt_discover()   
    print "Chosen device:", address, services
    I have also tried to use the lightblue package, but also with it the bluetooth discover of N95 doesn't work.
    Have someone tried this code?

    Chiara

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    2

    Re: bt_discover on N95

    I also get the same problem. I tested various combinations of phone types and this bug appears only when N95 is to be discovered (no matter by whom).

    Moreover - it is enough to have bluetooth turned on in the N95 - it doesn't matter if you have any server-script running or not.
    Also using symbian open-signd python shell didn't help.

    Any ideas, anyone?
    Thanx in advance
    Grin

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    2

    Unhappy Re: bt_discover on N95

    After enabling panic code display (with sis file form http://www.symbianresources.com/cgi-...bo/dl.pl?ErrRd ) I can now see that the Python closes with error "KERN-EXEC 3", that I found to be described as Null Pointer Exception.. Doesn't sound optymistic...
    I hope someone will find out the bug and fix it..

    greetings
    Grin

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    Re: bt_discover on N95

    I have the exact same issue
    Any solutions yet? It is really annoying Hope there will be a solution soon...

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: bt_discover on N95

    Quote Originally Posted by ham_se17 View Post
    I have the exact same issue
    Any solutions yet? It is really annoying Hope there will be a solution soon...
    hi ham_se17
    first of all a warm welcome to the python dibo.
    dont worry if it is a bug then it will be fixed as early as possible. But upto that keep up trying some alternatives.

  7. #7
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    Re: bt_discover on N95

    Quote Originally Posted by gaba88 View Post
    hi ham_se17
    first of all a warm welcome to the python dibo.
    dont worry if it is a bug then it will be fixed as early as possible. But upto that keep up trying some alternatives.
    thanks for the welcome
    well, I think it must be a bug, I can reproduce the error on 3 different N95, both signed and selfsigned version of python shell (1.4.2) has the same "bug". I need this to work soon because I have a school project where I need a server/client bluetooth communication module...

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    12

    Re: bt_discover on N95

    Since this is my first post on this forum welcome everybody.

    I have similiar error with lightblue library.
    However I can discover the N95 with lightblue.finddevices() but when I try to get list of services with lightblue.findservices() Python crashes.
    So far it works correctly with other phones.
    My N95 is firmware V 20.0.015.

    greetings
    Tom

  9. #9
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: bt_discover on N95

    Quote Originally Posted by pantomas View Post
    Since this is my first post on this forum welcome everybody.

    I have similiar error with lightblue library.
    However I can discover the N95 with lightblue.finddevices() but when I try to get list of services with lightblue.findservices() Python crashes.
    So far it works correctly with other phones.
    My N95 is firmware V 20.0.015.

    greetings
    Tom
    hi phantomas
    welcome to the python dibo i hope you will get the best support and help here.
    yes this is really a bug. i hope any of the moderator have a look at this thread and should have a comment abt the bug or is it something else.
    thanks

  10. #10
    Registered User
    Join Date
    Jun 2008
    Posts
    8

    Re: bt_discover on N95

    Hello everyone,

    I am using the lightblue module. What I would like to do is find the blue tooth devices and launch the available devices in a menu. I would like for someone to be able to choose their "home" device from the list and store their selection. Here's what I have so far but I'm having a hard time dynamically creating the menu. Does anyone have any examples of this?

    Code:
    import appuifw
    import lightblue
    
    localDevices = lightblue.finddevices()
    
    List = []
    for i in range(0,len(localDevices)):
         print "Device"+str(i+1)+":"
         print localDevices[i][1]
         List.append(localDevices[i][1]
    
    index = appuifw.popup_menu(List, u"Set Home Device")

  11. #11
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: bt_discover on N95

    Hi,

    I'm not sure I understand your question. If you are looking for a more simple (and shorter) way of populating the List array with the elements from localDevices, try this:
    Code:
    import appuifw
    import lightblue
    
    localDevices = lightblue.finddevices()
    
    List = [localDevices[i][1] for i in range(len(localDevices))]
    
    index = appuifw.popup_menu(List, u"Set Home Device")

  12. #12
    Registered User
    Join Date
    Jun 2008
    Posts
    8

    Re: bt_discover on N95

    I think my problem had to do with the way I was appending items to the list. Thanks for your help!

  13. #13
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: bt_discover on N95

    hi trdillah

    i feel that it will be bit difficult to execute your demand in a menu other than that you can opt for the selection list which will be very easy.

    Enjoy Pythoning
    Gaba88

  14. #14
    Registered User
    Join Date
    Jun 2008
    Posts
    8

    Re: bt_discover on N95

    Hi,

    Thanks for the tip. I'm having a couple of problems that I'm not able to explain. First of all, the following code is returning "No data" as a result of the finddevices call although the Bluetooth Console works fine. Secondly, I would like to know if there is a way to show some type of progress bar, or indicator to the user to indicate that the application is still running. Here is the code I'm working with below:

    Code:
    import appuifw
    import lightblue
    
    
    localDevices = []
    
    def connectToBTDevice():
    	localDevices = lightblue.finddevices()
    	List = [localDevices[i][1] for i in range(len(localDevices))]
    	#index = appuifw.popup_menu(List, u"Set Home Device")
    	index = appuifw.selection_list(choices=List , search_field=1)
    	if index >= 0:
    		localDevices = localDevices[index]
    
    appuifw.app.menu = [(u"Setup Bluetooth Connection", connectToBTDevice)]
    
    # Can there be some type of progress bar to indicate to the user that the #app is still running (besides text)?
    
    running = 1
    
    while(running):
            # now run finddevices again and see if any of the devices were found
    
    	newList = lightblue.finddevices()
    	if len(localDevices) > 0:
    		for i in range(len(newList)):
    			if localDevices == newList[i]:
    				print "Match Found!!!"
    				running = 0

  15. #15
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: bt_discover on N95

    Quote Originally Posted by trdillah View Post
    Hi,

    Thanks for the tip. I'm having a couple of problems that I'm not able to explain. First of all, the following code is returning "No data" as a result of the finddevices call although the Bluetooth Console works fine.
    hi
    i havent use the lightblue extension but why dont you use the simple socket module to get the list of bluetooth devices.please see the python documentation to get more information.

    Quote Originally Posted by trdillah View Post
    Secondly, I would like to know if there is a way to show some type of progress bar, or indicator to the user to indicate that the application is still running. Here is the code I'm working with below:
    i feel that this is not yet possible in PyS60 but i am not sure.

    Enjoy Pythoning
    Gaba88

Similar Threads

  1. N95 Accelerometer & JSR-256
    By AnthonyAndrews in forum Mobile Java General
    Replies: 9
    Last Post: 2009-04-21, 22:12
  2. ActivateViewL to open Settings on N95
    By dracula78 in forum Symbian User Interface
    Replies: 5
    Last Post: 2008-12-10, 10:09
  3. Replies: 84
    Last Post: 2008-03-04, 23:25
  4. Classic N95 vs US ver. N95
    By qwerty0824 in forum General Development Questions
    Replies: 5
    Last Post: 2007-09-13, 18:09
  5. N95 Some Questions & Suggestions
    By subzero_brighton in forum General Development Questions
    Replies: 0
    Last Post: 2007-06-22, 15:37

Posting Permissions

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