Skip to content

Commit 3ffa1d5

Browse files
juhaylinencarlescufi
authored andcommitted
net: coap: Fix coap client timeout
Fix bug in timeout_expired() function. Coap client was resending pending messages after 500 ms (COAP_PERIODIC_TIMEOUT) and didn't wait for retransmission timeout. Use 64-bit k_uptime_get() Signed-off-by: Juha Ylinen <[email protected]>
1 parent e836427 commit 3ffa1d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/net/lib/coap/coap_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static void report_callback_error(struct coap_client_internal_request *internal_
369369
static bool timeout_expired(struct coap_client_internal_request *internal_req)
370370
{
371371
return (internal_req->request_ongoing &&
372-
internal_req->pending.timeout <= k_uptime_get_32());
372+
internal_req->pending.timeout <= (k_uptime_get() - internal_req->pending.t0));
373373
}
374374

375375
static int resend_request(struct coap_client *client,
@@ -649,7 +649,7 @@ static int handle_response(struct coap_client *client, const struct coap_packet
649649
/* Separate response coming */
650650
if (payload_len == 0 && response_type == COAP_TYPE_ACK &&
651651
response_code == COAP_CODE_EMPTY) {
652-
internal_req->pending.t0 = k_uptime_get_32();
652+
internal_req->pending.t0 = k_uptime_get();
653653
internal_req->pending.timeout = internal_req->pending.t0 + COAP_SEPARATE_TIMEOUT;
654654
internal_req->pending.retries = 0;
655655
return 1;

0 commit comments

Comments
 (0)