×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    18

    Tranfering file by bluetooth

    Hello am using OBEX to transfer file via bluetooth i use this code for the server
    Code:
    # This script lets 2 phones exchange a file via OBEX.
    # This is the server, the corresponding client is obex_client.py
    from socket import *
    import appuifw
    
    # Create a bluetooth socket in waiting state to be connected to
    s = socket(AF_BT, SOCK_STREAM)
    port = bt_rfcomm_get_available_server_channel(s)
    print "Binding service to port %s"%port
    s.bind(("", port))
    print "Service bound."
    
    # Advertise the OBEX service, so it can be seen by other phones
    service_name=u"Test OBEX service"
    
    print "Advertising service as %s"%repr(service_name)
    bt_advertise_service(service_name, s, True, OBEX)
    
    try: 
        print "Setting security to AUTH."
        set_security(s, AUTH)
    
        receive_path = u"c:\\Data\\tst.txt"
    	
        print "Receiving file."
        bt_obex_receive(s, receive_path)
        print "File received."
    
        import e32
        e32.ao_sleep(1)
    finally:
        print "Stopping service advertising."
        bt_advertise_service(service_name, s, False, OBEX)
    
    print "Closing socket."
    s.close()
    print "Socket closed."
    print "Finished."
    and for the Client i used the program:
    Code:
    # this file lets 2 phones exchange a file via OBEX
    # this file is the client side
    # the corresponding server side file is called obex_server.py
    
    from socket import *
    import appuifw
    import e32
    
    # JL: you don't need a socket for this!
    ## create socket
    #s=socket(AF_BT,SOCK_STREAM)
    
    # scan for other phones offering OBEX service
    addr,services=bt_obex_discover()
    print "Discovered: %s, %s"%(addr,services)
    if len(services)>0:
        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)
    
    # create file to be sent
    send_path = u"c:\\Data\\tt.txt"
    f=open(send_path, 'w')
    f.write("hello")
    f.close() # NOTE: parens were missing here before!
    
    # send file via OBEX
    print "Sending file %s to host %s port %s"%(send_path, address[0], address[1])
    bt_obex_send_file(address[0], address[1], send_path)
    print "File sent."
    when i execute the client he give me 2 choices (port 9 and Port 3 ) when i choose the port 9, the client file send the file to the server fone but the server progrm stops after priting "Receiving file." and never execute the bt_obex_receive(s, receive_path)
    but when i shoose the port 3 the client program show me an error on bt_obex_send_file(address[0], address[1], send_path).

    can u help me plz

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: Tranfering file by bluetooth

    Hi,

    When you are using port 9, the file is transferred to the server and the script stops. That is what you have coded for, you don't have in your code that the script should run after receiving thr file. You can use the loop to get this. Basically your code is just for one file transfer.

    I still can't figure out why you get 2 ports ?
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    18

    Re: Tranfering file by bluetooth

    Quote Originally Posted by kandyfloss View Post
    Hi,

    When you are using port 9, the file is transferred to the server and the script stops. That is what you have coded for, you don't have in your code that the script should run after receiving thr file. You can use the loop to get this. Basically your code is just for one file transfer.

    I still can't figure out why you get 2 ports ?
    the first which is port 9 is : "OBEX push Object".
    the second port is 3 and show me called: "Test OBEX service", when i chose this port the client fone show me an error on

    Code:
    bt_obex_send_file(address[0], address[1], send_path)
    the error is (32)Broken pipe

    Why the server program doesnt execute the
    Code:
    bt_obex_receive(s, receive_path)
    how can i make the server fone receive the file at the receive_path??

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    18

    Re: Tranfering file by bluetooth

    Can anyone Help Plz???

  5. #5
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: Tranfering file by bluetooth

    Hi, i am getting the same error, did you find out the solution?

  6. #6
    Registered User
    Join Date
    Feb 2008
    Posts
    18

    Re: Tranfering file by bluetooth

    Quote Originally Posted by Alpinet View Post
    Hi, i am getting the same error, did you find out the solution?
    No i didnt find a solution so i let it down

Similar Threads

  1. Accessing File System of a CellPhone with another CellPhone via Bluetooth
    By Aaypee in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-09-20, 05:59
  2. Send file throwgh Bluetooth in Motorola PUAG!
    By Pepper_91 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-04-18, 11:53
  3. N70 - saving swf file sent over bluetooth
    By petes in forum General Development Questions
    Replies: 2
    Last Post: 2007-01-26, 04:00
  4. 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
  •  
×