PUT with multipacket ?

Help
kamou
2009-04-10
2013-05-01
  • kamou

    kamou - 2009-04-10

    hi !

    I just was reading the code of OBEX_ObjectNew

    And I was quiet disturbed by this line:
    obex_object_setcmd(object, cmd, (uint8_t) (cmd | OBEX_FINAL));

    why adding the OBEX_FINAL flag ??

    my question is:
    if I want to send a file via obex, how can I do it by sending n packets instead of just one big packet ?
    I'm working on an embedded device, and I'd rather not load the whole file in memory for sending it.

    is there another function that creates a new object with the final bit NOT set ?

     
    • Christian W. Zuckschwerdt

      Wether we use the final bit is determined later on.
      See obex_object.c line 523. As you'd expect it depends the actual number of packets needed.
      There is just no API representation of the Final bit -- it's automatic.

       
    • kamou

      kamou - 2009-04-10

      ok, but, then, how can I choose to send which part of my file ?

      this is what is done in ussp-push (buf is the file):

      oo = OBEX_ObjectNew(handle, OBEX_CMD_PUT);
      hv.bs = (uint8_t *) namebuf;
      OBEX_ObjectAddHeader(handle, oo, OBEX_HDR_NAME, hv, name_len, 0);
      hv.bq4 = file_size;
      OBEX_ObjectAddHeader(handle, oo, OBEX_HDR_LENGTH, hv, sizeof(uint32_t), 0);
      hv.bs = buf;
      OBEX_ObjectAddHeader(handle, oo, OBEX_HDR_BODY, hv, file_size, 0);

      err = OBEX_Request(handle, oo);

      Do I have to create as many objects as packets I want to send ?
      for example, would this code work:

      oo = OBEX_ObjectNew(handle, OBEX_CMD_PUT);
      hv.bs = (uint8_t *) namebuf;
      OBEX_ObjectAddHeader(handle, oo, OBEX_HDR_NAME, hv, name_len, 0);
      hv.bq4 = file_size;
      OBEX_ObjectAddHeader(handle, oo, OBEX_HDR_LENGTH, hv, sizeof(uint32_t), 0);
      hv.bs = buf;
      OBEX_ObjectAddHeader(handle, oo, OBEX_HDR_BODY, hv, file_size/2, 0);

      err = OBEX_Request(handle, oo);

      oo2 = OBEX_ObjectNew(handle, OBEX_CMD_PUT);

      hv.bs = buf+file_size/2;
      OBEX_ObjectAddHeader(handle, oo2, OBEX_HDR_BODY, hv, file_size/2, 0);

      err = OBEX_Request(handle, oo2);

       
      • Christian W. Zuckschwerdt

        You don't need to care about actual packets. Just use a streaming method, i.e. refill the send buffer as needed by openobex. Perhaps have a look at streaming in ObexFTP (client.c)

         
    • kamou

      kamou - 2009-04-10

      just tested it... it doesn't work...

      do you have any idea on how I could send my file part by part ?

       
    • kamou

      kamou - 2009-04-10

      the problem is that obexFTP is not supported in STLinux (that's the distrib I'm working on) :(

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks