mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-17 05:19:05 +03:00
Merge pull request #366 from mrdeep1/size1_addition
Add SIZE1 Option when sending BLOCK1 Option in packets in Client
This commit is contained in:
1 file changed
+13
-1
+13
-1
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user