@@ -1840,8 +1840,7 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
1840
1840
src_addr_ptr ,
1841
1841
received_coap_msg_ptr -> payload_len ,
1842
1842
received_coap_msg_ptr -> payload_ptr ,
1843
- received_coap_msg_ptr -> options_list_ptr -> block1 >> 4 );
1844
-
1843
+ received_coap_msg_ptr -> options_list_ptr -> block2 >> 4 );
1845
1844
/* If not last block (more value is set) */
1846
1845
if (received_coap_msg_ptr -> options_list_ptr -> block2 & 0x08 ) {
1847
1846
coap_blockwise_msg_s * previous_blockwise_msg_ptr = NULL ;
@@ -1867,18 +1866,6 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
1867
1866
return 0 ;
1868
1867
}
1869
1868
1870
- ns_list_remove (& handle -> linked_list_blockwise_sent_msgs , previous_blockwise_msg_ptr );
1871
- if ( previous_blockwise_msg_ptr -> coap_msg_ptr ){
1872
- if (previous_blockwise_msg_ptr -> coap_msg_ptr -> payload_ptr ){
1873
- handle -> sn_coap_protocol_free (previous_blockwise_msg_ptr -> coap_msg_ptr -> payload_ptr );
1874
- previous_blockwise_msg_ptr -> coap_msg_ptr -> payload_ptr = 0 ;
1875
- }
1876
- sn_coap_parser_release_allocated_coap_msg_mem (handle , previous_blockwise_msg_ptr -> coap_msg_ptr );
1877
- previous_blockwise_msg_ptr -> coap_msg_ptr = 0 ;
1878
- }
1879
- handle -> sn_coap_protocol_free (previous_blockwise_msg_ptr );
1880
- previous_blockwise_msg_ptr = 0 ;
1881
-
1882
1869
/* * * Then build CoAP Acknowledgement message * * */
1883
1870
1884
1871
if (sn_coap_parser_alloc_options (handle , src_coap_blockwise_ack_msg_ptr ) == NULL ) {
@@ -1902,6 +1889,34 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
1902
1889
1903
1890
src_coap_blockwise_ack_msg_ptr -> options_list_ptr -> block2 = (block_number << 4 ) | block_temp ;
1904
1891
1892
+
1893
+ /* Set BLOCK2 (subsequent) GET msg code and copy uri path from previous msg*/
1894
+ if (received_coap_msg_ptr -> msg_code == COAP_MSG_CODE_RESPONSE_CONTENT ) {
1895
+ src_coap_blockwise_ack_msg_ptr -> msg_code = COAP_MSG_CODE_REQUEST_GET ;
1896
+ if (previous_blockwise_msg_ptr -> coap_msg_ptr -> uri_path_ptr ) {
1897
+ src_coap_blockwise_ack_msg_ptr -> uri_path_len = previous_blockwise_msg_ptr -> coap_msg_ptr -> uri_path_len ;
1898
+ src_coap_blockwise_ack_msg_ptr -> uri_path_ptr = handle -> sn_coap_protocol_malloc (previous_blockwise_msg_ptr -> coap_msg_ptr -> uri_path_len );
1899
+ if (!src_coap_blockwise_ack_msg_ptr -> uri_path_ptr ) {
1900
+ sn_coap_parser_release_allocated_coap_msg_mem (handle , src_coap_blockwise_ack_msg_ptr );
1901
+ tr_error ("sn_coap_handle_blockwise_message - failed to allocate for uri path ptr!" );
1902
+ return NULL ;
1903
+ }
1904
+ memcpy (src_coap_blockwise_ack_msg_ptr -> uri_path_ptr , previous_blockwise_msg_ptr -> coap_msg_ptr -> uri_path_ptr , previous_blockwise_msg_ptr -> coap_msg_ptr -> uri_path_len );
1905
+ }
1906
+ }
1907
+
1908
+ ns_list_remove (& handle -> linked_list_blockwise_sent_msgs , previous_blockwise_msg_ptr );
1909
+ if (previous_blockwise_msg_ptr -> coap_msg_ptr ) {
1910
+ if (previous_blockwise_msg_ptr -> coap_msg_ptr -> payload_ptr ) {
1911
+ handle -> sn_coap_protocol_free (previous_blockwise_msg_ptr -> coap_msg_ptr -> payload_ptr );
1912
+ previous_blockwise_msg_ptr -> coap_msg_ptr -> payload_ptr = 0 ;
1913
+ }
1914
+ sn_coap_parser_release_allocated_coap_msg_mem (handle , previous_blockwise_msg_ptr -> coap_msg_ptr );
1915
+ previous_blockwise_msg_ptr -> coap_msg_ptr = 0 ;
1916
+ }
1917
+ handle -> sn_coap_protocol_free (previous_blockwise_msg_ptr );
1918
+ previous_blockwise_msg_ptr = 0 ;
1919
+
1905
1920
/* Then get needed memory count for Packet data */
1906
1921
dst_packed_data_needed_mem = sn_coap_builder_calc_needed_packet_data_size_2 (src_coap_blockwise_ack_msg_ptr ,handle -> sn_coap_block_data_size );
1907
1922
0 commit comments