libcoap  4.3.0beta
Event API

API functions for event delivery from lower-layer library functions. More...

Macros

#define COAP_EVENT_DTLS_CLOSED   0x0000
 (D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS More...
 
#define COAP_EVENT_DTLS_CONNECTED   0x01DE
 
#define COAP_EVENT_DTLS_RENEGOTIATE   0x01DF
 
#define COAP_EVENT_DTLS_ERROR   0x0200
 
#define COAP_EVENT_TCP_CONNECTED   0x1001
 TCP events for COAP_PROTO_TCP and COAP_PROTO_TLS. More...
 
#define COAP_EVENT_TCP_CLOSED   0x1002
 
#define COAP_EVENT_TCP_FAILED   0x1003
 
#define COAP_EVENT_SESSION_CONNECTED   0x2001
 CSM exchange events for reliable protocols only. More...
 
#define COAP_EVENT_SESSION_CLOSED   0x2002
 
#define COAP_EVENT_SESSION_FAILED   0x2003
 

Typedefs

typedef unsigned int coap_event_t
 Scalar type to represent different events, e.g. More...
 
typedef int(* coap_event_handler_t) (struct coap_context_t *, coap_event_t event, struct coap_session_t *session)
 Type for event handler functions that can be registered with a CoAP context using the unction coap_set_event_handler(). More...
 

Functions

void coap_register_event_handler (struct coap_context_t *context, coap_event_handler_t hnd)
 Registers the function hnd as callback for events from the given CoAP context context. More...
 

Detailed Description

API functions for event delivery from lower-layer library functions.

Macro Definition Documentation

◆ COAP_EVENT_DTLS_CLOSED

#define COAP_EVENT_DTLS_CLOSED   0x0000

(D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS

Definition at line 30 of file coap_event.h.

◆ COAP_EVENT_DTLS_CONNECTED

#define COAP_EVENT_DTLS_CONNECTED   0x01DE

Definition at line 31 of file coap_event.h.

◆ COAP_EVENT_DTLS_ERROR

#define COAP_EVENT_DTLS_ERROR   0x0200

Definition at line 33 of file coap_event.h.

◆ COAP_EVENT_DTLS_RENEGOTIATE

#define COAP_EVENT_DTLS_RENEGOTIATE   0x01DF

Definition at line 32 of file coap_event.h.

◆ COAP_EVENT_SESSION_CLOSED

#define COAP_EVENT_SESSION_CLOSED   0x2002

Definition at line 46 of file coap_event.h.

◆ COAP_EVENT_SESSION_CONNECTED

#define COAP_EVENT_SESSION_CONNECTED   0x2001

CSM exchange events for reliable protocols only.

Definition at line 45 of file coap_event.h.

◆ COAP_EVENT_SESSION_FAILED

#define COAP_EVENT_SESSION_FAILED   0x2003

Definition at line 47 of file coap_event.h.

◆ COAP_EVENT_TCP_CLOSED

#define COAP_EVENT_TCP_CLOSED   0x1002

Definition at line 39 of file coap_event.h.

◆ COAP_EVENT_TCP_CONNECTED

#define COAP_EVENT_TCP_CONNECTED   0x1001

TCP events for COAP_PROTO_TCP and COAP_PROTO_TLS.

Definition at line 38 of file coap_event.h.

◆ COAP_EVENT_TCP_FAILED

#define COAP_EVENT_TCP_FAILED   0x1003

Definition at line 40 of file coap_event.h.

Typedef Documentation

◆ coap_event_handler_t

typedef int(* coap_event_handler_t) (struct coap_context_t *, coap_event_t event, struct coap_session_t *session)

Type for event handler functions that can be registered with a CoAP context using the unction coap_set_event_handler().

When called by the library, the first argument will be the coap_context_t object where the handler function has been registered. The second argument is the event type that may be complemented by event-specific data passed as the third argument.

Definition at line 57 of file coap_event.h.

◆ coap_event_t

typedef unsigned int coap_event_t

Scalar type to represent different events, e.g.

DTLS events or retransmission timeouts.

Definition at line 25 of file coap_event.h.

Function Documentation

◆ coap_register_event_handler()

void coap_register_event_handler ( struct coap_context_t context,
coap_event_handler_t  hnd 
)

Registers the function hnd as callback for events from the given CoAP context context.

Any event handler that has previously been registered with context will be overwritten by this operation.

Parameters
contextThe CoAP context to register the event handler with.
hndThe event handler to be registered. NULL if to be de-registered.

Definition at line 17 of file coap_event.c.