Skip to content

Commit 9923899

Browse files
author
Cruz Monrreal
authored
Merge pull request #6883 from anttiylitokola/master
Update mbed-coap to version 4.4.3
2 parents d3cc4e1 + 511df14 commit 9923899

File tree

6 files changed

+57
-16
lines changed

6 files changed

+57
-16
lines changed

features/frameworks/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.3](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.4.3)
4+
**Closed issues:**
5+
- IOTCLT-2506 [GitHub] Cannot set registration time if server does not use max age option
6+
7+
Extend blockwise message transfer status to have states for sending as well.
8+
9+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.4.2...v4.4.3)
10+
311
## [v4.4.2](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.4.2)
412
**Closed issues:**
513
- IOTCLT-2469 CoAP UDP retransmission does not work for blocks after first one for requests (Eg. registration POST)

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,16 @@ typedef enum sn_coap_status_ {
158158
COAP_STATUS_PARSER_BLOCKWISE_MSG_REJECTED = 5, /**< Blockwise message received but not supported by compiling switch */
159159
COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED = 6, /**< Blockwise message fully received and returned to app.
160160
User must take care of releasing whole payload of the blockwise messages */
161-
COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED = 7 /**< When re-transmissions have been done and ACK not received, CoAP library calls
161+
COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED = 7, /**< When re-transmissions have been done and ACK not received, CoAP library calls
162162
RX callback with this status */
163+
164+
COAP_STATUS_BUILDER_BLOCK_SENDING_FAILED = 8, /**< Blockwise message sending timeout.
165+
The msg_id in sn_coap_hdr_s* parameter of RX callback is set to the same value
166+
as in the first block sent, and parameter sn_nsdl_addr_s* is set as NULL. */
167+
COAP_STATUS_BUILDER_BLOCK_SENDING_DONE = 9 /**< Blockwise message sending, last block sent.
168+
The msg_id in sn_coap_hdr_s* parameter of RX callback is set to the same value
169+
as in the first block sent, and parameter sn_nsdl_addr_s* is set as NULL. */
170+
163171
} sn_coap_status_e;
164172

165173

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.2",
3+
"version": "4.4.3",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ typedef struct coap_blockwise_msg_ {
185185
sn_coap_hdr_s *coap_msg_ptr;
186186
struct coap_s *coap; /* CoAP library handle */
187187

188-
ns_list_link_t link;
188+
void *param;
189+
uint16_t msg_id;
190+
191+
ns_list_link_t link;
189192
} coap_blockwise_msg_s;
190193

191194
typedef NS_LIST_HEAD(coap_blockwise_msg_s, link) coap_blockwise_msg_list_t;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ sn_coap_options_list_s *sn_coap_parser_alloc_options(struct coap_s *handle, sn_c
102102
/* XXX not technically legal to memset pointers to 0 */
103103
memset(coap_msg_ptr->options_list_ptr, 0x00, sizeof(sn_coap_options_list_s));
104104

105-
coap_msg_ptr->options_list_ptr->max_age = COAP_OPTION_MAX_AGE_DEFAULT;
105+
coap_msg_ptr->options_list_ptr->max_age = 0;
106106
coap_msg_ptr->options_list_ptr->uri_port = COAP_OPTION_URI_PORT_NONE;
107107
coap_msg_ptr->options_list_ptr->observe = COAP_OBSERVE_NONE;
108108
coap_msg_ptr->options_list_ptr->accept = COAP_CT_NONE;

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

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static bool sn_coap_protocol_linked_list_blockwise_payload_comp
6161
static void sn_coap_protocol_linked_list_blockwise_payload_remove(struct coap_s *handle, coap_blockwise_payload_s *removed_payload_ptr);
6262
static void sn_coap_protocol_linked_list_blockwise_payload_remove_oldest(struct coap_s *handle);
6363
static uint32_t sn_coap_protocol_linked_list_blockwise_payloads_get_len(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr);
64-
static void sn_coap_protocol_linked_list_blockwise_remove_old_data(struct coap_s *handle);
64+
static void sn_coap_protocol_handle_blockwise_timout(struct coap_s *handle);
6565
static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr, sn_coap_hdr_s *received_coap_msg_ptr, void *param);
6666
static sn_coap_hdr_s *sn_coap_protocol_copy_header(struct coap_s *handle, sn_coap_hdr_s *source_header_ptr);
6767
#endif
@@ -538,6 +538,8 @@ int16_t sn_coap_protocol_build(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_p
538538
memcpy(stored_blockwise_msg_ptr->coap_msg_ptr->payload_ptr, src_coap_msg_ptr->payload_ptr, stored_blockwise_msg_ptr->coap_msg_ptr->payload_len);
539539

540540
stored_blockwise_msg_ptr->coap = handle;
541+
stored_blockwise_msg_ptr->param = param;
542+
stored_blockwise_msg_ptr->msg_id = stored_blockwise_msg_ptr->coap_msg_ptr->msg_id;
541543
ns_list_add_to_end(&handle->linked_list_blockwise_sent_msgs, stored_blockwise_msg_ptr);
542544
}
543545

@@ -564,6 +566,8 @@ int16_t sn_coap_protocol_build(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_p
564566
}
565567

566568
stored_blockwise_msg_ptr->coap = handle;
569+
stored_blockwise_msg_ptr->param = param;
570+
stored_blockwise_msg_ptr->msg_id = stored_blockwise_msg_ptr->coap_msg_ptr->msg_id;
567571
ns_list_add_to_end(&handle->linked_list_blockwise_sent_msgs, stored_blockwise_msg_ptr);
568572
}
569573

@@ -794,12 +798,12 @@ int8_t sn_coap_protocol_exec(struct coap_s *handle, uint32_t current_time)
794798

795799
/* * * * Store current System time * * * */
796800
handle->system_time = current_time;
801+
797802
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
798-
/* * * * Remove old blocwise data * * * */
799-
sn_coap_protocol_linked_list_blockwise_remove_old_data(handle);
803+
/* * * * Handle block transfer timed outs * * * */
804+
sn_coap_protocol_handle_blockwise_timout(handle);
800805
#endif
801806

802-
803807
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
804808
/* * * * Remove old duplication messages * * * */
805809
sn_coap_protocol_linked_list_duplication_info_remove_old_ones(handle);
@@ -1455,20 +1459,29 @@ static uint32_t sn_coap_protocol_linked_list_blockwise_payloads_get_len(struct c
14551459
}
14561460

14571461
/**************************************************************************//**
1458-
* \fn static void sn_coap_protocol_linked_list_blockwise_remove_old_data(struct coap_s *handle)
1462+
* \fn static void sn_coap_protocol_handle_blockwise_timout(struct coap_s *handle)
14591463
*
1460-
* \brief Removes old stored Blockwise messages and payloads from Linked list
1464+
* \brief Check incoming and outgoing blockwise messages for time out.
1465+
* Remove timed out messages from lists. Notify application if
1466+
* outgoing message times out.
14611467
*****************************************************************************/
14621468

1463-
static void sn_coap_protocol_linked_list_blockwise_remove_old_data(struct coap_s *handle)
1469+
static void sn_coap_protocol_handle_blockwise_timout(struct coap_s *handle)
14641470
{
1465-
/* Loop all stored Blockwise messages in Linked list */
1471+
/* Loop all outgoing blockwise messages */
14661472
ns_list_foreach_safe(coap_blockwise_msg_s, removed_blocwise_msg_ptr, &handle->linked_list_blockwise_sent_msgs) {
14671473
if ((handle->system_time - removed_blocwise_msg_ptr->timestamp) > SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED) {
1468-
//TODO: Check do we need to check handle == removed_blocwise_msg_ptr->coap here?
14691474

1470-
/* * * * Old Blockise message found, remove it from Linked list * * * */
1475+
/* * * * This messages has timed out, remove it from Linked list * * * */
14711476
if( removed_blocwise_msg_ptr->coap_msg_ptr ){
1477+
1478+
if (handle->sn_coap_rx_callback) {
1479+
/* Notify the application about the time out */
1480+
removed_blocwise_msg_ptr->coap_msg_ptr->coap_status = COAP_STATUS_BUILDER_BLOCK_SENDING_FAILED;
1481+
removed_blocwise_msg_ptr->coap_msg_ptr->msg_id = removed_blocwise_msg_ptr->msg_id;
1482+
handle->sn_coap_rx_callback(removed_blocwise_msg_ptr->coap_msg_ptr, NULL, removed_blocwise_msg_ptr->param);
1483+
}
1484+
14721485
if(removed_blocwise_msg_ptr->coap_msg_ptr->payload_ptr){
14731486
handle->sn_coap_protocol_free(removed_blocwise_msg_ptr->coap_msg_ptr->payload_ptr);
14741487
removed_blocwise_msg_ptr->coap_msg_ptr->payload_ptr = 0;
@@ -1480,10 +1493,10 @@ static void sn_coap_protocol_linked_list_blockwise_remove_old_data(struct coap_s
14801493
}
14811494
}
14821495

1483-
/* Loop all stored Blockwise payloads in Linked list */
1496+
/* Loop all incoming Blockwise messages */
14841497
ns_list_foreach_safe(coap_blockwise_payload_s, removed_blocwise_payload_ptr, &handle->linked_list_blockwise_received_payloads) {
14851498
if ((handle->system_time - removed_blocwise_payload_ptr->timestamp) > SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED) {
1486-
/* * * * Old Blockise payload found, remove it from Linked list * * * */
1499+
/* * * * This messages has timed out, remove it from Linked list * * * */
14871500
sn_coap_protocol_linked_list_blockwise_payload_remove(handle, removed_blocwise_payload_ptr);
14881501
}
14891502
}
@@ -2056,6 +2069,8 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
20562069

20572070
stored_blockwise_msg_ptr->coap_msg_ptr = src_coap_blockwise_ack_msg_ptr;
20582071
stored_blockwise_msg_ptr->coap = handle;
2072+
stored_blockwise_msg_ptr->param = param;
2073+
stored_blockwise_msg_ptr->msg_id = stored_blockwise_msg_ptr->coap_msg_ptr->msg_id;
20592074
ns_list_add_to_end(&handle->linked_list_blockwise_sent_msgs, stored_blockwise_msg_ptr);
20602075

20612076
/* * * Then release memory of CoAP Acknowledgement message * * */
@@ -2201,6 +2216,13 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
22012216
stored_blockwise_msg_temp_ptr->coap_msg_ptr->payload_ptr = original_payload_ptr;
22022217

22032218
if ((block_size * (block_number + 1)) >= stored_blockwise_msg_temp_ptr->coap_msg_ptr->payload_len) {
2219+
2220+
if (handle->sn_coap_rx_callback) {
2221+
stored_blockwise_msg_temp_ptr->coap_msg_ptr->coap_status = COAP_STATUS_BUILDER_BLOCK_SENDING_DONE;
2222+
stored_blockwise_msg_temp_ptr->coap_msg_ptr->msg_id = stored_blockwise_msg_temp_ptr->msg_id;
2223+
handle->sn_coap_rx_callback(stored_blockwise_msg_temp_ptr->coap_msg_ptr, NULL, stored_blockwise_msg_temp_ptr->param);
2224+
}
2225+
22042226
sn_coap_protocol_linked_list_blockwise_msg_remove(handle, stored_blockwise_msg_temp_ptr);
22052227
}
22062228

0 commit comments

Comments
 (0)