-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathcoap_event.h
104 lines (91 loc) · 2.99 KB
/
coap_event.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* coap_event.h -- libcoap Event API
*
* Copyright (C) 2016 Olaf Bergmann <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef COAP_EVENT_H_
#define COAP_EVENT_H_
#include "libcoap.h"
/**
* @defgroup events Event API
* API functions for event delivery from lower-layer library functions.
* @{
*/
/**
* Scalar type to represent different events, e.g. DTLS events or
* retransmission timeouts.
*/
typedef enum coap_event_t {
/**
* (D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS
*/
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
*/
COAP_EVENT_TCP_CONNECTED = 0x1001,
COAP_EVENT_TCP_CLOSED = 0x1002,
COAP_EVENT_TCP_FAILED = 0x1003,
/**
* CSM exchange events for reliable protocols only
*/
COAP_EVENT_SESSION_CONNECTED = 0x2001,
COAP_EVENT_SESSION_CLOSED = 0x2002,
COAP_EVENT_SESSION_FAILED = 0x2003,
/**
* (Q-)BLOCK receive errors
*/
COAP_EVENT_PARTIAL_BLOCK = 0x3001
} coap_event_t;
/**
* 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.
*/
typedef int (*coap_event_handler_t)(coap_session_t *session,
const coap_event_t event);
/**
* Registers the function @p hnd as callback for events from the given
* CoAP context @p context. Any event handler that has previously been
* registered with @p context will be overwritten by this operation.
*
* @param context The CoAP context to register the event handler with.
* @param hnd The event handler to be registered. @c NULL if to be
* de-registered.
*/
void coap_register_event_handler(coap_context_t *context,
coap_event_handler_t hnd);
/** @} */
/**
* Registers the function @p hnd as callback for events from the given
* CoAP context @p context. Any event handler that has previously been
* registered with @p context will be overwritten by this operation.
*
* @deprecated Use coap_register_event_handler() instead.
*
* @param context The CoAP context to register the event handler with.
* @param hnd The event handler to be registered.
*/
COAP_DEPRECATED
void coap_set_event_handler(coap_context_t *context,
coap_event_handler_t hnd);
/**
* Clears the event handler registered with @p context.
*
* @deprecated Use coap_register_event_handler() instead with NULL for hnd.
*
* @param context The CoAP context whose event handler is to be removed.
*/
COAP_DEPRECATED
void coap_clear_event_handler(coap_context_t *context);
#endif /* COAP_EVENT_H */