-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

