Fix bug in CoAP retransmission policy

This commit is contained in:
Sam Kumar 2018-08-25 22:15:45 -07:00
parent 21042ae748
commit 02dd484ff2

View File

@ -98,12 +98,11 @@ coap_send_transaction(coap_transaction_t *t)
{ {
LOG_DBG("Sending transaction %u\n", t->mid); LOG_DBG("Sending transaction %u\n", t->mid);
coap_sendto(&t->endpoint, t->message, t->message_len);
if(COAP_TYPE_CON == if(COAP_TYPE_CON ==
((COAP_HEADER_TYPE_MASK & t->message[0]) >> COAP_HEADER_TYPE_POSITION)) { ((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 */ /* not timed out yet */
coap_sendto(&t->endpoint, t->message, t->message_len);
LOG_DBG("Keeping transaction %u\n", t->mid); LOG_DBG("Keeping transaction %u\n", t->mid);
if(t->retrans_counter == 0) { if(t->retrans_counter == 0) {
@ -138,6 +137,7 @@ coap_send_transaction(coap_transaction_t *t)
} }
} }
} else { } else {
coap_sendto(&t->endpoint, t->message, t->message_len);
coap_clear_transaction(t); coap_clear_transaction(t);
} }
} }