connect always return -1 in python wrapper.

Help
2008-10-06
2013-05-01
  • Alejandro Leyva
    Alejandro Leyva
    2008-10-06

    Hi, im using python bindings, im trying to develop an application based in openobex.

    I have the following piece of code:

    import obexftp
    dev = "00:1C:A4:FC:8E:56"
    cli = obexftp.client(obexftp.BLUETOOTH)
    print cli.connect(dev, 6, "hci1")

    connect always return -1, but when i run the connect i can see with hcitool -i hci1 con the new connection:

            < ACL 00:1C:A4:FC:8E:56 handle 42 state 1 lm MASTER

    whats the problem? im using:

    -ubuntu
    -libopenobex1   1.3-3ubuntu1

    and i've compiled obexftp 0.22.

    Thanks in advance.

     
    • Can you try using the adapters MAC instead of "hci1"? Also you can compile and install ObexFTP with debug enabled, see the README.

       
    • Alejandro Leyva
      Alejandro Leyva
      2008-10-06

      I've tried with the adapter mac and still the same:

      print cli.connect(dev, 6, "00:18:E4:08:28:F9")
      -1

      ObexFTP compiled with debug enabled:
      >>> import obexftp
      >>> dev = "00:1C:A4:FC:8E:56"
      >>> cli = obexftp.client(obexftp.BLUETOOTH)
      obexftp_open()
      >>> print cli.connect(dev, 6, "00:18:E4:08:28:F9")
      obexftp_connect_src()
      obexftp_connect_src() BT 1
      cli_sync_request()
      obexftp_sync()
      cli_obex_event() OBEX_EV_REQDONE: obex_rsp=43
      client_done()
      obexftp_sync() OBEX_HandleInput = 7
      obexftp_sync() Done success=0
      -1

      Also, i've tried to disconnect with no success, it also returns -1 and with hcitool i still can see the connection, only closing python destroy the connection:

      >>> cli.disconnect()
      obexftp_disconnect()
      cli_sync_request()
      obexftp_sync()
      cli_obex_event() OBEX_EV_REQDONE: obex_rsp=40
      client_done()
      obexftp_sync() OBEX_HandleInput = 3
      obexftp_sync() Done success=0
      -1

      Thanks again.

       
      • The line "obex_rsp=43" is key here. (Given that it should bubble up more visibly.) The response 0x43 means Access Forbidden. So maybe you are using the wrong SDP channel for the given service (OBEXFTP)?

        Btw. the Disconnect is out of context there, thus "Bad Request" (0x40), s.a. http://dev.zuckschwerdt.org/openobex/browser/trunk/include/openobex/obex_const.h

         
    • Alejandro Leyva
      Alejandro Leyva
      2008-10-06

      Is it possible to receive under python the obex rsp? not only the -1

      Thanks for your help.

       
    • Alejandro Leyva
      Alejandro Leyva
      2008-10-06

      I've tried with obexftp in command line and it can connect to channel 6:

      obexftp --hci hci0 --nopath --noconn --uuid none --bluetooth 00:1C:A4:FC:8E:56 --channel 6 -p /root/test.txt --verbose
      Suppressing FBS.
      obexftp_open()
      obexftp_connect_src()
      Connecting...obexftp_connect_src() BT 1
      cli_sync_request()
      obexftp_sync()
      client_done()
      obexftp_sync() OBEX_HandleInput = 7
      obexftp_sync() Done success=1
      done

      But inside python it cant, sometimes it says:
      >>> print cli.connect(dev, 6, "00:02:5B:00:BF:30")
      obexftp_connect_src()
      obexftp_connect_src() BT -1
      -1

      and other:
      >>> print cli.connect(dev, 6, "00:02:5B:00:BF:30")
      obexftp_connect_src()
      obexftp_connect_src() BT 1
      cli_sync_request()
      obexftp_sync()
      cli_obex_event() OBEX_EV_REQDONE: obex_rsp=43
      client_done()
      obexftp_sync() OBEX_HandleInput = 7
      obexftp_sync() Done success=0
      -1

      I dont understand why it is different, the service is Obex push, does it need some other parameters to connect()?

       
      • With obexftp command line you are using "--uuid none" which means OBEX_PUSH. Thats a different SDP service and mostly a different channel too. Try a "sdptool browse" to the mobile.

        The "-1" response indicates that the BT isn't ready. Mostly happens with multiple connects in quick succession.

         
    • Alejandro Leyva
      Alejandro Leyva
      2008-10-06

      Channel 6 is for Object Push, its the same channel im using for python, sdptool show this:

      Service Name: OBEX Object Push
      Service RecHandle: 0x1000b
      Service Class ID List:
        "OBEX Object Push" (0x1105)
      Protocol Descriptor List:
        "L2CAP" (0x0100)
        "RFCOMM" (0x0003)
          Channel: 6
        "OBEX" (0x0008)
      Profile Descriptor List:
        "OBEX Object Push" (0x1105)
          Version: 0x0100

      So, in command line and in python im using the same channel, but in command line it connects and in python dont, why?

       
      • If you really want PUSH then use connectpush in python. Otherwise use the OBEXFTP channel given in the SDP browse.

         
    • Alejandro Leyva
      Alejandro Leyva
      2008-10-06

      Got it! instead of connect() im using connectpush() and now i got success.

      Thanks a lot for your help.