Skip to content

Commit c887248

Browse files
author
Antti Yli-Tokola
committed
Update mbed-coap to version 4.5.0
Fix error: IIOTCLT-2769 - mbed-coap: extra response received after registration Added own flag to enable blockwise support, without setting default blockwise payload size. This allows to receive blockwise messages while still sending without blockwise. Fix CoAP request blockwise response handling When request is sent, response can have blockwise option set. All requests must be stored to the linked list.
1 parent 8e170cc commit c887248

File tree

7 files changed

+237
-117
lines changed

7 files changed

+237
-117
lines changed

features/frameworks/mbed-coap/CHANGELOG.md

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

3+
## [v4.5.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.5.0)
4+
**Closed issues:**
5+
- IIOTCLT-2769 - mbed-coap: extra response received after registration
6+
7+
Added own flag to enable blockwise support, without setting default blockwise
8+
payload size. This allows to receive blockwise messages while still sending
9+
without blockwise.
10+
11+
Fix CoAP request blockwise response handling
12+
When request is sent, response can have blockwise option set. All requests must
13+
be stored to the linked list.
14+
15+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.4.4...v4.5.0)
16+
317
## [v4.4.4](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.4.4)
418
**Closed issues:**
519
- IOTCLT-2638 [GitHub] hardfault during reconnection retry with Thread

features/frameworks/mbed-coap/mbed-coap/sn_coap_protocol.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ extern void sn_coap_protocol_clear_sent_blockwise_messages(struct coap_s *handle
268268
*/
269269
extern void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn_nsdl_addr_s *addr_ptr, void *param);
270270

271+
/**
272+
* \fn uint16_t sn_coap_protocol_get_configured_blockwise_size(struct coap_s *handle)
273+
*
274+
* \brief Get configured CoAP payload blockwise size
275+
*
276+
* \param *handle Pointer to CoAP library handle
277+
*/
278+
extern uint16_t sn_coap_protocol_get_configured_blockwise_size(struct coap_s *handle);
279+
271280
#endif /* SN_COAP_PROTOCOL_H_ */
272281

273282
#ifdef __cplusplus

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
*
4040
* \brief For Message blockwising
4141
* Init value for the maximum payload size to be sent and received at one blockwise message
42-
* Setting of this value to 0 will disable this feature, and also reduce use of ROM memory
42+
* Setting of this value to 0 with SN_COAP_BLOCKWISE_ENABLED will disable this feature, and
43+
* also reduce use of ROM memory.
4344
* Note: This define is common for both received and sent Blockwise messages
4445
*/
4546
#undef 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
@@ -107,6 +108,13 @@
107108
*/
108109
#undef SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE /* 0 */
109110

111+
/**
112+
* \def SN_COAP_BLOCKWISE_ENABLED
113+
* \brief Enables the blockwise functionality in CoAP library also when blockwise payload
114+
* size is set to '0' in SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE.
115+
*/
116+
#undef SN_COAP_BLOCKWISE_ENABLED /* 0 */
117+
110118
#ifdef MBED_CLIENT_USER_CONFIG_FILE
111119
#include MBED_CLIENT_USER_CONFIG_FILE
112120
#endif

features/frameworks/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.4",
3+
"version": "4.5.0",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ struct sn_coap_hdr_;
113113
#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
114114
#endif
115115

116+
#ifndef SN_COAP_BLOCKWISE_ENABLED
117+
#define SN_COAP_BLOCKWISE_ENABLED 0 /**< Enable blockwise */
118+
#endif
119+
116120
#ifndef SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
117121
#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 */
118122
#endif
@@ -145,9 +149,7 @@ struct sn_coap_hdr_;
145149
#define COAP_OPTION_BLOCK_NONE (-1) /**< Internal value to represent no Block1/2 option */
146150

147151

148-
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwising is not used at all, this part of code will not be compiled */
149152
int8_t prepare_blockwise_message(struct coap_s *handle, struct sn_coap_hdr_ *coap_hdr_ptr);
150-
#endif
151153

152154
/* Structure which is stored to Linked list for message sending purposes */
153155
typedef struct coap_send_msg_ {
@@ -201,6 +203,8 @@ typedef struct coap_blockwise_payload_ {
201203
uint8_t *addr_ptr;
202204
uint16_t port;
203205
uint32_t block_number;
206+
uint8_t *token_ptr;
207+
uint8_t token_len;
204208

205209
uint16_t payload_len;
206210
uint8_t *payload_ptr;
@@ -228,7 +232,7 @@ struct coap_s {
228232
uint16_t count_duplication_msgs;
229233
#endif
230234

231-
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwise is not used at all, this part of code will not be compiled */
235+
#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwise is not enabled, this part of code will not be compiled */
232236
coap_blockwise_msg_list_t linked_list_blockwise_sent_msgs; /* Blockwise message to to be sent is stored to this Linked list */
233237
coap_blockwise_payload_list_t linked_list_blockwise_received_payloads; /* Blockwise payload to to be received is stored to this Linked list */
234238
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
340340
returned_byte_count += sn_coap_builder_options_build_add_uint_option(NULL, src_coap_msg_ptr->options_list_ptr->size2, COAP_OPTION_SIZE2, &tempInt);
341341
}
342342
}
343-
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
343+
#if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
344344
if ((src_coap_msg_ptr->payload_len > SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE) &&
345345
(src_coap_msg_ptr->payload_len > blockwise_payload_size) &&
346346
(blockwise_payload_size > 0)) {

0 commit comments

Comments
 (0)