Go to the documentation of this file.
31 #ifndef _COAP_CLIENT_H
32 #define _COAP_CLIENT_H
41 #ifndef COAP_CLIENT_SUPPORT
42 #define COAP_CLIENT_SUPPORT ENABLED
43 #elif (COAP_CLIENT_SUPPORT != ENABLED && COAP_CLIENT_SUPPORT != DISABLED)
44 #error COAP_CLIENT_SUPPORT parameter is not valid
48 #ifndef COAP_CLIENT_DTLS_SUPPORT
49 #define COAP_CLIENT_DTLS_SUPPORT DISABLED
50 #elif (COAP_CLIENT_DTLS_SUPPORT != ENABLED && COAP_CLIENT_DTLS_SUPPORT != DISABLED)
51 #error COAP_CLIENT_DTLS_SUPPORT parameter is not valid
55 #ifndef COAP_CLIENT_OBSERVE_SUPPORT
56 #define COAP_CLIENT_OBSERVE_SUPPORT ENABLED
57 #elif (COAP_CLIENT_OBSERVE_SUPPORT != ENABLED && COAP_CLIENT_OBSERVE_SUPPORT != DISABLED)
58 #error COAP_CLIENT_OBSERVE_SUPPORT parameter is not valid
62 #ifndef COAP_CLIENT_BLOCK_SUPPORT
63 #define COAP_CLIENT_BLOCK_SUPPORT ENABLED
64 #elif (COAP_CLIENT_BLOCK_SUPPORT != ENABLED && COAP_CLIENT_BLOCK_SUPPORT != DISABLED)
65 #error COAP_CLIENT_BLOCK_SUPPORT parameter is not valid
69 #ifndef COAP_CLIENT_TICK_INTERVAL
70 #define COAP_CLIENT_TICK_INTERVAL 100
71 #elif (COAP_CLIENT_TICK_INTERVAL < 10)
72 #error COAP_CLIENT_TICK_INTERVAL parameter is not valid
76 #ifndef COAP_CLIENT_DEFAULT_TIMEOUT
77 #define COAP_CLIENT_DEFAULT_TIMEOUT 20000
78 #elif (COAP_CLIENT_DEFAULT_TIMEOUT < 0)
79 #error COAP_CLIENT_DEFAULT_TIMEOUT parameter is not valid
83 #ifndef COAP_CLIENT_NSTART
84 #define COAP_CLIENT_NSTART 1
85 #elif (COAP_CLIENT_NSTART < 1)
86 #error COAP_CLIENT_NSTART parameter is not valid
90 #ifndef COAP_CLIENT_MAX_RETRANSMIT
91 #define COAP_CLIENT_MAX_RETRANSMIT 4
92 #elif (COAP_CLIENT_MAX_RETRANSMIT < 1)
93 #error COAP_CLIENT_MAX_RETRANSMIT parameter is not valid
97 #ifndef COAP_CLIENT_ACK_TIMEOUT_MIN
98 #define COAP_CLIENT_ACK_TIMEOUT_MIN 2000
99 #elif (COAP_CLIENT_ACK_TIMEOUT_MIN < 1000)
100 #error COAP_CLIENT_ACK_TIMEOUT_MIN parameter is not valid
104 #ifndef COAP_CLIENT_ACK_TIMEOUT_MAX
105 #define COAP_CLIENT_ACK_TIMEOUT_MAX 3000
106 #elif (COAP_CLIENT_ACK_TIMEOUT_MAX < COAP_CLIENT_ACK_TIMEOUT_MIN)
107 #error COAP_CLIENT_ACK_TIMEOUT_MAX parameter is not valid
111 #ifndef COAP_CLIENT_RAND_DELAY_MIN
112 #define COAP_CLIENT_RAND_DELAY_MIN 5000
113 #elif (COAP_CLIENT_RAND_DELAY_MIN < 1000)
114 #error COAP_CLIENT_RAND_DELAY_MIN parameter is not valid
118 #ifndef COAP_CLIENT_RAND_DELAY_MAX
119 #define COAP_CLIENT_RAND_DELAY_MAX 15000
120 #elif (COAP_CLIENT_RAND_DELAY_MAX < COAP_CLIENT_RAND_DELAY_MIN)
121 #error COAP_CLIENT_RAND_DELAY_MAX parameter is not valid
125 #ifndef COAP_CLIENT_DEFAULT_TOKEN_LEN
126 #define COAP_CLIENT_DEFAULT_TOKEN_LEN 4
127 #elif (COAP_CLIENT_DEFAULT_TOKEN_LEN < 0 || COAP_CLIENT_DEFAULT_TOKEN_LEN > 8)
128 #error COAP_CLIENT_DEFAULT_TOKEN_LEN parameter is not valid
132 #ifndef COAP_CLIENT_PRIVATE_CONTEXT
133 #define COAP_CLIENT_PRIVATE_CONTEXT
137 #if (COAP_CLIENT_DTLS_SUPPORT == ENABLED)
144 #define CoapClientContext struct _CoapClientContext
148 #define CoapClientRequest struct _CoapClientRequest
172 #if (COAP_CLIENT_DTLS_SUPPORT == ENABLED)
196 #if (COAP_CLIENT_DTLS_SUPPORT == ENABLED)
217 #if (COAP_CLIENT_DTLS_SUPPORT == ENABLED)
231 const IpAddr *serverIpAddr, uint16_t serverPort);
error_t coapClientBindToInterface(CoapClientContext *context, NetInterface *interface)
Bind the CoAP client to a particular network interface.
CoapClientState
CoAP client states.
CoapClientState state
CoAP client state.
CoapClientDtlsInitCallback dtlsInitCallback
DTLS initialization callback.
TlsContext * dtlsContext
DTLS context.
error_t coapClientSetTokenLength(CoapClientContext *context, size_t length)
Set the length of the token.
systime_t timeout
Timeout value.
#define CoapClientContext
CoapClientRequest request[COAP_CLIENT_NSTART]
Outstanding CoAP requests.
#define COAP_CLIENT_NSTART
#define CoapClientRequest
CoAP message formatting and parsing.
CoapTransportProtocol
CoAP transport protocols.
error_t coapClientRegisterDtlsInitCallback(CoapClientContext *context, CoapClientDtlsInitCallback callback)
Register DTLS initialization callback function.
error_t coapClientTask(CoapClientContext *context, systime_t timeout)
Process CoAP client events.
OsMutex mutex
Mutex preventing simultaneous access to the context.
error_t(* CoapClientDtlsInitCallback)(CoapClientContext *context, TlsContext *dtlsContext)
DTLS initialization callback.
@ COAP_CLIENT_STATE_DISCONNECTED
General definitions for cryptographic algorithms.
error_t coapClientDisconnect(CoapClientContext *context)
Disconnect from the CoAP server.
void coapClientDeinit(CoapClientContext *context)
Release CoAP client context.
error_t coapClientSetTransportProtocol(CoapClientContext *context, CoapTransportProtocol transportProtocol)
Set the transport protocol to be used.
NetInterface * interface
Underlying network interface.
CoapClientContext * context
CoAP client context.
error_t coapClientSetTimeout(CoapClientContext *context, systime_t timeout)
Set default request timeout.
uint32_t systime_t
System time.
#define COAP_CLIENT_PRIVATE_CONTEXT
uint16_t mid
Message identifier.
CoapTransportProtocol transportProtocol
Transport protocol (UDP or DTLS)
OsEvent event
Event object used to receive notifications.
CoapMessage response
CoAP response message.
TlsSessionState dtlsSession
DTLS session state.
TLS (Transport Layer Security)
@ COAP_CLIENT_STATE_CONNECTED
error_t coapClientConnect(CoapClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
Establish connection with the CoAP server.
@ COAP_CLIENT_STATE_CONNECTING
Socket * socket
Underlying UDP socket.
size_t tokenLen
Token length.
error_t coapClientInit(CoapClientContext *context)
Initialize CoAP client context.
Definitions common to CoAP client and server.
Formatting and parsing of CoAP options.
systime_t startTime
Start time.