@@ -61,7 +61,7 @@ static bool sn_coap_protocol_linked_list_blockwise_payload_comp
61
61
static void sn_coap_protocol_linked_list_blockwise_payload_remove (struct coap_s * handle , coap_blockwise_payload_s * removed_payload_ptr );
62
62
static void sn_coap_protocol_linked_list_blockwise_payload_remove_oldest (struct coap_s * handle );
63
63
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 );
65
65
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 );
66
66
static sn_coap_hdr_s * sn_coap_protocol_copy_header (struct coap_s * handle , sn_coap_hdr_s * source_header_ptr );
67
67
#endif
@@ -538,6 +538,8 @@ int16_t sn_coap_protocol_build(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_p
538
538
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 );
539
539
540
540
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 ;
541
543
ns_list_add_to_end (& handle -> linked_list_blockwise_sent_msgs , stored_blockwise_msg_ptr );
542
544
}
543
545
@@ -564,6 +566,8 @@ int16_t sn_coap_protocol_build(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_p
564
566
}
565
567
566
568
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 ;
567
571
ns_list_add_to_end (& handle -> linked_list_blockwise_sent_msgs , stored_blockwise_msg_ptr );
568
572
}
569
573
@@ -794,12 +798,12 @@ int8_t sn_coap_protocol_exec(struct coap_s *handle, uint32_t current_time)
794
798
795
799
/* * * * Store current System time * * * */
796
800
handle -> system_time = current_time ;
801
+
797
802
#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 );
800
805
#endif
801
806
802
-
803
807
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
804
808
/* * * * Remove old duplication messages * * * */
805
809
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
1455
1459
}
1456
1460
1457
1461
/**************************************************************************/ /**
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)
1459
1463
*
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.
1461
1467
*****************************************************************************/
1462
1468
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 )
1464
1470
{
1465
- /* Loop all stored Blockwise messages in Linked list */
1471
+ /* Loop all outgoing blockwise messages */
1466
1472
ns_list_foreach_safe (coap_blockwise_msg_s , removed_blocwise_msg_ptr , & handle -> linked_list_blockwise_sent_msgs ) {
1467
1473
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?
1469
1474
1470
- /* * * * Old Blockise message found , remove it from Linked list * * * */
1475
+ /* * * * This messages has timed out , remove it from Linked list * * * */
1471
1476
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
+
1472
1485
if (removed_blocwise_msg_ptr -> coap_msg_ptr -> payload_ptr ){
1473
1486
handle -> sn_coap_protocol_free (removed_blocwise_msg_ptr -> coap_msg_ptr -> payload_ptr );
1474
1487
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
1480
1493
}
1481
1494
}
1482
1495
1483
- /* Loop all stored Blockwise payloads in Linked list */
1496
+ /* Loop all incoming Blockwise messages */
1484
1497
ns_list_foreach_safe (coap_blockwise_payload_s , removed_blocwise_payload_ptr , & handle -> linked_list_blockwise_received_payloads ) {
1485
1498
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 * * * */
1487
1500
sn_coap_protocol_linked_list_blockwise_payload_remove (handle , removed_blocwise_payload_ptr );
1488
1501
}
1489
1502
}
@@ -2056,6 +2069,8 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
2056
2069
2057
2070
stored_blockwise_msg_ptr -> coap_msg_ptr = src_coap_blockwise_ack_msg_ptr ;
2058
2071
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 ;
2059
2074
ns_list_add_to_end (& handle -> linked_list_blockwise_sent_msgs , stored_blockwise_msg_ptr );
2060
2075
2061
2076
/* * * 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
2201
2216
stored_blockwise_msg_temp_ptr -> coap_msg_ptr -> payload_ptr = original_payload_ptr ;
2202
2217
2203
2218
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
+
2204
2226
sn_coap_protocol_linked_list_blockwise_msg_remove (handle , stored_blockwise_msg_temp_ptr );
2205
2227
}
2206
2228
0 commit comments