Skip to content

Commit 5b7e67e

Browse files
Antti Yli-Tokolaadbridge
authored andcommitted
Update mbed-coap to version 4.4.1
- Fixes error: IOTCLT-2539 Block wise messaging call-backs not working logically - Allow TCP+TLS transport method to send larger messages without blockwising. NOTE! These are internal changes required for cloud client. This has no direct relevance to any mbed-os functionality.
1 parent 204aa9f commit 5b7e67e

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

features/FEATURE_COMMON_PAL/mbed-coap/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## [v4.4.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.4.1)
4+
**Closed issues:**
5+
- IOTCLT-2539 Block wise messaging call-backs not working logically
6+
7+
Improve TCP+TLS transport layer to allow send larger messages without blockwising.
8+
9+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.4.0...v4.4.1)
10+
311
## [v4.4.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.4.0)
412
**New feature:**
513
- Make sn_coap_protocol_send_rst as public needed for CoAP ping sending

features/FEATURE_COMMON_PAL/mbed-coap/mbed-coap/sn_config.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@
9292
*/
9393
#undef SN_COAP_MAX_INCOMING_MESSAGE_SIZE /* UINT16_MAX */
9494

95+
/**
96+
* \def SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE
97+
* \brief Sets the maximum payload size allowed before blockwising the message.
98+
* This option should only be used when using TCP and TLS as transport
99+
* with known maximum fragment size. This optimizes the number of messages
100+
* if it is possible to send larger than 1kB messages without blockwise transfer.
101+
* If payload length is larger than SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE
102+
* it will be sent using blockwise transfer.
103+
* By default, this feature is disabled, 0 disables the feature, set to positive
104+
* value larger than SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE to enable.
105+
* Note that value should be less than transport layer maximum fragment size.
106+
* Note that value has no effect if blockwise transfer is disabled.
107+
*/
108+
#undef SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE /* 0 */
109+
95110
#ifdef MBED_CLIENT_USER_CONFIG_FILE
96111
#include MBED_CLIENT_USER_CONFIG_FILE
97112
#endif

features/FEATURE_COMMON_PAL/mbed-coap/module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mbed-coap",
3-
"version": "4.4.0",
3+
"version": "4.4.1",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

features/FEATURE_COMMON_PAL/mbed-coap/source/include/sn_coap_protocol_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ struct sn_coap_hdr_;
117117
#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE 0 /**< Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 */
118118
#endif
119119

120+
#ifndef SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE
121+
#define SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE 0
122+
#endif
123+
120124
#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
121125
#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
122126
#endif

features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_builder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
341341
}
342342
}
343343
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
344-
if ((src_coap_msg_ptr->payload_len > blockwise_payload_size) && (blockwise_payload_size > 0)) {
344+
if ((src_coap_msg_ptr->payload_len > SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE) &&
345+
(src_coap_msg_ptr->payload_len > blockwise_payload_size) &&
346+
(blockwise_payload_size > 0)) {
345347
returned_byte_count += blockwise_payload_size;
346348
} else {
347349
returned_byte_count += src_coap_msg_ptr->payload_len;

features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_protocol.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t ms
372372
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwising is not used at all, this part of code will not be compiled */
373373
int8_t prepare_blockwise_message(struct coap_s *handle, sn_coap_hdr_s *src_coap_msg_ptr)
374374
{
375-
if ((src_coap_msg_ptr->payload_len > handle->sn_coap_block_data_size) && (handle->sn_coap_block_data_size > 0)) {
375+
if ((src_coap_msg_ptr->payload_len > SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE) &&
376+
(src_coap_msg_ptr->payload_len > handle->sn_coap_block_data_size) &&
377+
(handle->sn_coap_block_data_size > 0)) {
376378
/* * * * Add Blockwise option to send CoAP message * * */
377379

378380
/* Allocate memory for less used options */
@@ -436,15 +438,15 @@ int16_t sn_coap_protocol_build(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_p
436438
}
437439

438440
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwising is not used at all, this part of code will not be compiled */
439-
440441
/* If blockwising needed */
441-
if ((src_coap_msg_ptr->payload_len > handle->sn_coap_block_data_size) && (handle->sn_coap_block_data_size > 0)) {
442+
if ((src_coap_msg_ptr->payload_len > SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE) &&
443+
(src_coap_msg_ptr->payload_len > handle->sn_coap_block_data_size) &&
444+
(handle->sn_coap_block_data_size > 0)) {
442445
/* Store original Payload length */
443446
original_payload_len = src_coap_msg_ptr->payload_len;
444447
/* Change Payload length of send message because Payload is blockwised */
445448
src_coap_msg_ptr->payload_len = handle->sn_coap_block_data_size;
446449
}
447-
448450
#endif
449451
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
450452
/* * * * Build Packet data from CoAP message by using CoAP Header builder * * * */
@@ -1264,6 +1266,15 @@ static void sn_coap_protocol_linked_list_blockwise_payload_store(struct coap_s *
12641266
return;
12651267
}
12661268

1269+
// Do not add duplicates to list, this could happen if server needs to retransmit block message again
1270+
ns_list_foreach(coap_blockwise_payload_s, payload_info_ptr, &handle->linked_list_blockwise_received_payloads) {
1271+
if (0 == memcmp(addr_ptr->addr_ptr, payload_info_ptr->addr_ptr, addr_ptr->addr_len)) {
1272+
if (payload_info_ptr->port == addr_ptr->port && payload_info_ptr->block_number == block_number) {
1273+
return;
1274+
}
1275+
}
1276+
}
1277+
12671278
coap_blockwise_payload_s *stored_blockwise_payload_ptr = NULL;
12681279

12691280
/* * * * Allocating memory for stored Payload * * * */

0 commit comments

Comments
 (0)