From 02dd484ff245da74db26ed03c78b0338d5211d4c Mon Sep 17 00:00:00 2001 From: Sam Kumar Date: Sat, 25 Aug 2018 22:15:45 -0700 Subject: [PATCH] Fix bug in CoAP retransmission policy --- os/net/app-layer/coap/coap-transactions.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/os/net/app-layer/coap/coap-transactions.c b/os/net/app-layer/coap/coap-transactions.c index 7e34d22e4..a62e8d21f 100644 --- a/os/net/app-layer/coap/coap-transactions.c +++ b/os/net/app-layer/coap/coap-transactions.c @@ -98,12 +98,11 @@ coap_send_transaction(coap_transaction_t *t) { LOG_DBG("Sending transaction %u\n", t->mid); - coap_sendto(&t->endpoint, t->message, t->message_len); - if(COAP_TYPE_CON == ((COAP_HEADER_TYPE_MASK & t->message[0]) >> COAP_HEADER_TYPE_POSITION)) { - if(t->retrans_counter < COAP_MAX_RETRANSMIT) { + if(t->retrans_counter <= COAP_MAX_RETRANSMIT) { /* not timed out yet */ + coap_sendto(&t->endpoint, t->message, t->message_len); LOG_DBG("Keeping transaction %u\n", t->mid); if(t->retrans_counter == 0) { @@ -138,6 +137,7 @@ coap_send_transaction(coap_transaction_t *t) } } } else { + coap_sendto(&t->endpoint, t->message, t->message_len); coap_clear_transaction(t); } }