coap_event: Add COAP_EVENT_MSG_RETRANSMITTED

Apart from debug log messages, there is no way for a user to be
notified when a message retransmission happens.

This event can be useful for diagnosing issues related to
lossy networks or unresponsive CoAP servers (e.g. user can
track total retransmissions as an indicator for general link
quality).

Assigned event ID to 0x5002 to avoid creating a new 0x6000
event group, and because it's similar to COAP_EVENT_BAD_PACKET (0x5001).
This commit is contained in:
Nick Miller authored and mrdeep1 committed 2022-10-19 16:34:07 +01:00
1 parent f5251e682c
commit 312a0561e4
5 files changed
+10 -3

No files matched your search

+1
View File
@@ -358,6 +358,7 @@ event_handler(coap_session_t *session COAP_UNUSED,
case COAP_EVENT_SERVER_SESSION_NEW:
case COAP_EVENT_SERVER_SESSION_DEL:
case COAP_EVENT_BAD_PACKET:
case COAP_EVENT_MSG_RETRANSMITTED:
default:
break;
}
+1
View File
@@ -1582,6 +1582,7 @@ proxy_event_handler(coap_session_t *session,
case COAP_EVENT_SERVER_SESSION_NEW:
case COAP_EVENT_SERVER_SESSION_DEL:
case COAP_EVENT_BAD_PACKET:
case COAP_EVENT_MSG_RETRANSMITTED:
default:
break;
}
+4 -2
View File
@@ -94,10 +94,12 @@ typedef enum {
COAP_EVENT_SERVER_SESSION_DEL = 0x4002,
/*
* Received packet formatting errors
* Message receive and transmit events
*/
/** Triggered when badly formatted packet received */
COAP_EVENT_BAD_PACKET = 0x5001
COAP_EVENT_BAD_PACKET = 0x5001,
/** Triggered when a message is retransmitted */
COAP_EVENT_MSG_RETRANSMITTED = 0x5002
} coap_event_t;
+2 -1
View File
@@ -219,9 +219,10 @@ COAP_EVENT_XMIT_BLOCK_FAIL 0x3002
COAP_EVENT_SERVER_SESSION_NEW 0x4001
COAP_EVENT_SERVER_SESSION_DEL 0x4002
/**
* Unrecognizable received packet events
* Message receive and transmit events
*/
COAP_EVENT_BAD_PACKET 0x5001
COAP_EVENT_MSG_RETRANSMITTED 0x5002
----
EXAMPLES
+2
View File
@@ -1439,6 +1439,8 @@ coap_retransmit(coap_context_t *context, coap_queue_t *node) {
coap_tick_t now;
node->retransmit_cnt++;
coap_handle_event(context, COAP_EVENT_MSG_RETRANSMITTED, node->session);
coap_ticks(&now);
if (context->sendqueue == NULL) {
node->t = node->timeout << node->retransmit_cnt;