Merge pull request #366 from mrdeep1/size1_addition

Add SIZE1 Option when sending BLOCK1 Option in packets in Client
This commit is contained in:
obgm authored and GitHub committed 2019-06-27 13:59:30 +02:00
commit c4aa140127
1 file changed
+13 -1
+13 -1
View File
@@ -168,8 +168,15 @@ coap_new_request(coap_context_t *ctx,
if (length) {
if ((flags & FLAGS_BLOCK) == 0)
coap_add_data(pdu, length, data);
else
else {
unsigned char buf[4];
coap_add_option(pdu,
COAP_OPTION_SIZE1,
coap_encode_var_safe(buf, sizeof(buf), length),
buf);
coap_add_block(pdu, length, data, block.num, block.szx);
}
}
return pdu;
@@ -539,6 +546,11 @@ message_handler(struct coap_context_t *ctx,
coap_encode_var_safe(buf, sizeof(buf),
(block.num << 4) | (block.m << 3) | block.szx), buf);
coap_add_option(pdu,
COAP_OPTION_SIZE1,
coap_encode_var_safe(buf, sizeof(buf), payload.length),
buf);
coap_add_block(pdu,
payload.length,
payload.s,