Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoAP Blockwise transfer #41

Open
SachinEdwin opened this issue Jan 31, 2016 · 4 comments
Open

CoAP Blockwise transfer #41

SachinEdwin opened this issue Jan 31, 2016 · 4 comments
Labels

Comments

@SachinEdwin
Copy link

Hi,
I am new to this CoAP project and i am making using use of coap.net.
Working on blockwise transfer in order to GET payload of 100 bytes.
How do I start with this? I read the latest RFC on blockwise transfer where it says make use of blockoption 2 for GET method.
Any way to approach this / sample code / pointers would be appreciated

Best Regards,
Sachin Edwin

@longshine
Copy link
Member

Hi~

You don't have to specify a Block2 option. In this case the size of blocks will be negotiated between the client and server. The lib will decide automatically whether a blockwise transfer is needed according to the size of payload.

If you prefer any other size of one block, you may specify a Block2 option before sending the request:

  /*
   * In this case, the 2nd param (num) must be 0;
   * the 3rd param (szx) stands for the block size:
   *   block size = 1 << (szx + 4)
   * 1 for 32 bytes per block
   * It must between 0 and 6.
   */
  request.SetOption(new BlockOption(OptionType.Block2, 0, 1, false));

You may try the CoAP.Example/CoAP.Client example to get the '/large' resource in the CoAP.Example/CoAP.Server example to see the result.

@SachinEdwin
Copy link
Author

Hi,

Thanks for your reply.
I am using a stack from openwsn , the above block option is independent of which stack I use?
blockoption is not implemented in openwsn stack (server side), so will this work?

@longshine
Copy link
Member

Sorry that this feature will not work without support on the server side.

@janaki2
Copy link

janaki2 commented Jan 19, 2017

Hi,

I have a question on SZX in the Block2 Option.

Does the payload bytes of the response packet MUST be exactly same as the SZX chosen in Block2 Option
or
Can it differ with that of SZX?

For example, I send a Block which is NOT the last block and I choose SZX = 2 (i.e., Block size is 64 bytes). But the actual payload in the response is 75 bytes or 57 bytes not 64 bytes. Is this valid?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants