@@ -30,9 +30,8 @@ static void cancel_requests_with(struct coap_client *client, int error);
3030static int recv_response (struct coap_client * client , struct coap_packet * response , bool * truncated );
3131static int handle_response (struct coap_client * client , const struct coap_packet * response ,
3232 bool response_truncated );
33- static struct coap_client_internal_request * get_request_with_mid (
34- struct coap_client * client , const struct coap_packet * resp );
35-
33+ static struct coap_client_internal_request * get_request_with_mid (struct coap_client * client ,
34+ uint16_t mid );
3635
3736static int send_request (int sock , const void * buf , size_t len , int flags ,
3837 const struct sockaddr * dest_addr , socklen_t addrlen )
@@ -701,14 +700,12 @@ static struct coap_client_internal_request *get_request_with_token(
701700 return NULL ;
702701}
703702
704- static struct coap_client_internal_request * get_request_with_mid (
705- struct coap_client * client , const struct coap_packet * resp )
703+ static struct coap_client_internal_request * get_request_with_mid (struct coap_client * client ,
704+ uint16_t mid )
706705{
707- uint16_t mid = coap_header_get_id (resp );
708-
709706 for (int i = 0 ; i < CONFIG_COAP_CLIENT_MAX_REQUESTS ; i ++ ) {
710707 if (client -> requests [i ].request_ongoing ) {
711- if (client -> requests [i ].last_id == mid ) {
708+ if (client -> requests [i ].last_id == ( int ) mid ) {
712709 return & client -> requests [i ];
713710 }
714711 }
@@ -717,7 +714,6 @@ static struct coap_client_internal_request *get_request_with_mid(
717714 return NULL ;
718715}
719716
720-
721717static bool find_echo_option (const struct coap_packet * response , struct coap_option * option )
722718{
723719 return coap_find_options (response , COAP_OPTION_ECHO , option , 1 );
@@ -748,7 +744,7 @@ static int handle_response(struct coap_client *client, const struct coap_packet
748744 const uint8_t * payload = coap_packet_get_payload (response , & payload_len );
749745
750746 if (response_type == COAP_TYPE_RESET ) {
751- internal_req = get_request_with_mid (client , response );
747+ internal_req = get_request_with_mid (client , response_id );
752748 if (!internal_req ) {
753749 LOG_WRN ("No matching request for RESET" );
754750 return 0 ;
@@ -761,7 +757,7 @@ static int handle_response(struct coap_client *client, const struct coap_packet
761757 /* Separate response coming */
762758 if (payload_len == 0 && response_type == COAP_TYPE_ACK &&
763759 response_code == COAP_CODE_EMPTY ) {
764- internal_req = get_request_with_mid (client , response );
760+ internal_req = get_request_with_mid (client , response_id );
765761 if (!internal_req ) {
766762 LOG_WRN ("No matching request for ACK" );
767763 return 0 ;
0 commit comments