libcoap  4.3.0
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
 
#define COAP_EVENT_PARTIAL_BLOCK   0x3001
 BLOCK2 receive errors. More...
 

Typedefs

typedef unsigned int coap_event_t
 Scalar type to represent different events, e.g. More...
 
typedef int(* coap_event_handler_t) (coap_session_t *session, const coap_event_t event)
 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 (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 32 of file coap_event.h.

◆ COAP_EVENT_DTLS_CONNECTED

#define COAP_EVENT_DTLS_CONNECTED   0x01DE

Definition at line 33 of file coap_event.h.

◆ COAP_EVENT_DTLS_ERROR

#define COAP_EVENT_DTLS_ERROR   0x0200

Definition at line 35 of file coap_event.h.

◆ COAP_EVENT_DTLS_RENEGOTIATE

#define COAP_EVENT_DTLS_RENEGOTIATE   0x01DF

Definition at line 34 of file coap_event.h.

◆ COAP_EVENT_PARTIAL_BLOCK

#define COAP_EVENT_PARTIAL_BLOCK   0x3001

BLOCK2 receive errors.

Definition at line 54 of file coap_event.h.

◆ COAP_EVENT_SESSION_CLOSED

#define COAP_EVENT_SESSION_CLOSED   0x2002

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

◆ COAP_EVENT_SESSION_FAILED

#define COAP_EVENT_SESSION_FAILED   0x2003

Definition at line 49 of file coap_event.h.

◆ COAP_EVENT_TCP_CLOSED

#define COAP_EVENT_TCP_CLOSED   0x1002

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

◆ COAP_EVENT_TCP_FAILED

#define COAP_EVENT_TCP_FAILED   0x1003

Definition at line 42 of file coap_event.h.

Typedef Documentation

◆ coap_event_handler_t

typedef int(* coap_event_handler_t) (coap_session_t *session, const coap_event_t event)

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 current coap_session_t object which is associated with the original CoAP context. The second parameter is the event type.

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

Function Documentation

◆ coap_register_event_handler()

void coap_register_event_handler ( 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 19 of file coap_event.c.