libcoap  4.2.1
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...
 
COAP_DEPRECATED void coap_set_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...
 
COAP_DEPRECATED void coap_clear_event_handler (struct coap_context_t *context)
 Clears the event handler registered with 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 33 of file coap_event.h.

◆ COAP_EVENT_DTLS_CONNECTED

#define COAP_EVENT_DTLS_CONNECTED   0x01DE

Definition at line 34 of file coap_event.h.

◆ COAP_EVENT_DTLS_ERROR

#define COAP_EVENT_DTLS_ERROR   0x0200

Definition at line 36 of file coap_event.h.

◆ COAP_EVENT_DTLS_RENEGOTIATE

#define COAP_EVENT_DTLS_RENEGOTIATE   0x01DF

Definition at line 35 of file coap_event.h.

◆ COAP_EVENT_SESSION_CLOSED

#define COAP_EVENT_SESSION_CLOSED   0x2002

Definition at line 49 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 48 of file coap_event.h.

◆ COAP_EVENT_SESSION_FAILED

#define COAP_EVENT_SESSION_FAILED   0x2003

Definition at line 50 of file coap_event.h.

◆ COAP_EVENT_TCP_CLOSED

#define COAP_EVENT_TCP_CLOSED   0x1002

Definition at line 42 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 41 of file coap_event.h.

◆ COAP_EVENT_TCP_FAILED

#define COAP_EVENT_TCP_FAILED   0x1003

Definition at line 43 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 60 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 28 of file coap_event.h.

Function Documentation

◆ coap_clear_event_handler()

COAP_DEPRECATED void coap_clear_event_handler ( struct coap_context_t context)

Clears the event handler registered with context.

Deprecated:
Use coap_register_event_handler() instead with NULL for hnd.
Parameters
contextThe CoAP context whose event handler is to be removed.

Definition at line 29 of file coap_event.c.

◆ 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.

◆ coap_set_event_handler()

COAP_DEPRECATED void coap_set_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.

Deprecated:
Use coap_register_event_handler() instead.
Parameters
contextThe CoAP context to register the event handler with.
hndThe event handler to be registered.

Definition at line 23 of file coap_event.c.