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

Blockwise transfer #62

Open
deavmi opened this issue Sep 21, 2023 · 0 comments
Open

Blockwise transfer #62

deavmi opened this issue Sep 21, 2023 · 0 comments

Comments

@deavmi
Copy link

deavmi commented Sep 21, 2023

Good morning, I have been working on getting a blockwise transfer working as part of a POST request.

I effectively have a large amount of data I want to send, I want the Java CoAP library to handle the block transfer, and once done have it unblock from the future to be able to obtain the fully reassembled payload.

I have been struggling to get this right, so far this is the code I have going:

/**
* Grab a hold of the resource as a target for our POST.
* 
* Then pack into the request our DLMS xAPDU with the
* DLMS content type.
* 
* Then also set the headers:
*/
String uriHostStr = (this.remoteHost.getAddress()+":"+this.remoteHost.getPort()).replace("/", "");
log.warning("Computed URI host string: '"+uriHostStr+"'");

CoapRequestTarget resourceTarget = this.client.resource(this.resourcePath)
  .payload(payloadToSend, this.contentType)
  .con()
  .host(uriHostStr)
  .token(getAToken());
//  .query("");

// Pack the headers in
resourceTarget = packHeaderOptions(resourceTarget);



log.finer("POST to be sent: '"+resourceTarget+"'");

// Now POST it and wait for it to complete
CompletableFuture<CoapPacket> postFuture = resourceTarget.post(); 

// Wait for the response Coap packet
CoapPacket postResp = postFuture.get();
log.finer("Post response: '"+postResp+"'");

byte[] responsePayload = postResp.getPayload();
log.info("Post payload: '"+Arrays.toString(responsePayload)+"'");

How could I go about this? (Below is attached one of the ways I need to accomplish this)

IMG-20230921-WA0000.jpg

IMG-20230921-WA0001.jpg

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

No branches or pull requests

1 participant