Skip to content

Commit

Permalink
Merge pull request #733 from mrdeep1/event_enum
Browse files Browse the repository at this point in the history
coap_event.h: Make coap_event_t an enum
  • Loading branch information
obgm authored Aug 2, 2021
2 parents 12eb676 + 8ce139d commit 65e380a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
8 changes: 8 additions & 0 deletions examples/coap-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ event_handler(coap_session_t *session COAP_UNUSED,
case COAP_EVENT_SESSION_CLOSED:
quit = 1;
break;
case COAP_EVENT_DTLS_CONNECTED:
case COAP_EVENT_DTLS_RENEGOTIATE:
case COAP_EVENT_DTLS_ERROR:
case COAP_EVENT_TCP_CONNECTED:
case COAP_EVENT_TCP_FAILED:
case COAP_EVENT_SESSION_CONNECTED:
case COAP_EVENT_SESSION_FAILED:
case COAP_EVENT_PARTIAL_BLOCK:
default:
break;
}
Expand Down
8 changes: 8 additions & 0 deletions examples/coap-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,14 @@ proxy_event_handler(coap_session_t *session,
/* Need to remove any proxy associations */
remove_proxy_association(session, 0);
break;
case COAP_EVENT_DTLS_CONNECTED:
case COAP_EVENT_DTLS_RENEGOTIATE:
case COAP_EVENT_DTLS_ERROR:
case COAP_EVENT_TCP_CONNECTED:
case COAP_EVENT_TCP_FAILED:
case COAP_EVENT_SESSION_CONNECTED:
case COAP_EVENT_SESSION_FAILED:
case COAP_EVENT_PARTIAL_BLOCK:
default:
break;
}
Expand Down
28 changes: 14 additions & 14 deletions include/coap3/coap_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@
* Scalar type to represent different events, e.g. DTLS events or
* retransmission timeouts.
*/
typedef unsigned int coap_event_t;

typedef enum coap_event_t {
/**
* (D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS
*/
#define COAP_EVENT_DTLS_CLOSED 0x0000
#define COAP_EVENT_DTLS_CONNECTED 0x01DE
#define COAP_EVENT_DTLS_RENEGOTIATE 0x01DF
#define COAP_EVENT_DTLS_ERROR 0x0200
COAP_EVENT_DTLS_CLOSED = 0x0000,
COAP_EVENT_DTLS_CONNECTED = 0x01DE,
COAP_EVENT_DTLS_RENEGOTIATE = 0x01DF,
COAP_EVENT_DTLS_ERROR = 0x0200,

/**
* TCP events for COAP_PROTO_TCP and COAP_PROTO_TLS
*/
#define COAP_EVENT_TCP_CONNECTED 0x1001
#define COAP_EVENT_TCP_CLOSED 0x1002
#define COAP_EVENT_TCP_FAILED 0x1003
COAP_EVENT_TCP_CONNECTED = 0x1001,
COAP_EVENT_TCP_CLOSED = 0x1002,
COAP_EVENT_TCP_FAILED = 0x1003,

/**
* CSM exchange events for reliable protocols only
*/
#define COAP_EVENT_SESSION_CONNECTED 0x2001
#define COAP_EVENT_SESSION_CLOSED 0x2002
#define COAP_EVENT_SESSION_FAILED 0x2003
COAP_EVENT_SESSION_CONNECTED = 0x2001,
COAP_EVENT_SESSION_CLOSED = 0x2002,
COAP_EVENT_SESSION_FAILED = 0x2003,

/**
* BLOCK2 receive errors
* (Q-)BLOCK receive errors
*/
#define COAP_EVENT_PARTIAL_BLOCK 0x3001
COAP_EVENT_PARTIAL_BLOCK = 0x3001
} coap_event_t;

/**
* Type for event handler functions that can be registered with a CoAP
Expand Down

0 comments on commit 65e380a

Please sign in to comment.