coap_retransmittimer_restart(context);
#endif
- debug("** retransmission #%d of transaction %d\n", node->retransmit_cnt,
- ntohs(node->pdu->hdr->id));
+ debug("** retransmission #%d of transaction %d for coap pdu\n", node->retransmit_cnt, node->id);
+ coap_show_pdu(node->pdu);
flag = (coap_send_flags_t)(SEND_RETX | (node->secure ? SEND_SECURE_PORT : 0));
tid = coap_send(context, (coap_address_t *)&(node->remote),node->pdu, flag, NULL);
return (tid == COAP_INVALID_TID)? COAP_INVALID_TID : node->id;
if (!queue || !*queue)
return 0;
- debug("*** looking for transaction %u == %u\n", id, (*queue)->id);
+ debug("*** looking for transaction ID %u for pdu:\n", id);
+ coap_show_pdu((*queue)->pdu);
/* replace queue head if PDU's time is less than head's time */
if (id == (*queue)->id) { /* found transaction */
context->sendqueue->pdu->hdr->token_length)) {
q = context->sendqueue;
context->sendqueue = q->next;
- debug("**** removed transaction %d\n", ntohs(q->pdu->hdr->id));
+ debug("**** removed transaction %d for coap pdu\n", q->id);
+ coap_show_pdu(q->pdu);
coap_delete_node(q);
}
&& token_match(token, token_length, q->pdu->hdr->token,
q->pdu->hdr->token_length)) {
p->next = q->next;
- debug("**** removed transaction %d\n", ntohs(q->pdu->hdr->id));
+ debug("**** removed transaction %d for coap pdu\n", q->id);
+ coap_show_pdu(q->pdu);
coap_delete_node(q);
q = p->next;
} else {
break;
case COAP_MESSAGE_CON: /* check for unknown critical options */
+ // Receiving a response should stop retransmissions
+ if (COAP_MESSAGE_IS_RESPONSE(rcvd->pdu->hdr))
+ {
+ coap_remove_from_queue(&context->sendqueue, rcvd->id, &sent);
+ }
if (coap_option_check_critical(context, rcvd->pdu, opt_filter)
== 0) {
/* FIXME: send response only if we have received a request. Otherwise,
{
request->requestComplete = 1;
}
- }
- else
- {
- OC_LOG(INFO, TAG, PCF("This is either a repeated Server Request or blocked Server Request"));
- }
- if(request->requestComplete)
- {
- OC_LOG(INFO, TAG, PCF("This Server Request is complete"));
- result = DetermineResourceHandling (request, &resHandling, &resource);
- if (result == OC_STACK_OK)
+ if(request->requestComplete)
{
- result = ProcessRequest(resHandling, resource, request);
+ OC_LOG(INFO, TAG, PCF("This Server Request is complete"));
+ result = DetermineResourceHandling (request, &resHandling, &resource);
+ if (result == OC_STACK_OK)
+ {
+ result = ProcessRequest(resHandling, resource, request);
+ }
+ else
+ {
+ result = OC_STACK_ERROR;
+ }
}
else
{
- result = OC_STACK_ERROR;
+ OC_LOG(INFO, TAG, PCF("This Server Request is incomplete"));
+ result = OC_STACK_CONTINUE;
}
}
else
{
- OC_LOG(INFO, TAG, PCF("This Server Request is incomplete"));
- result = OC_STACK_CONTINUE;
+ OC_LOG(INFO, TAG, PCF("This is either a repeated Server Request or blocked Server Request"));
+ result = OC_STACK_REPEATED_REQUEST;
}
+
return result;
}