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)
138 #include "core/crypto.h"
144#define CoapClientContext struct _CoapClientContext
148#define CoapClientRequest struct _CoapClientRequest
165 COAP_CLIENT_STATE_DISCONNECTED = 0,
166 COAP_CLIENT_STATE_CONNECTING = 1,
167 COAP_CLIENT_STATE_CONNECTED = 2
172#if (COAP_CLIENT_DTLS_SUPPORT == ENABLED)
179 TlsContext *dtlsContext);
196#if (COAP_CLIENT_DTLS_SUPPORT == ENABLED)
205 CoapClientRequest
request[COAP_CLIENT_NSTART];
207 COAP_CLIENT_PRIVATE_CONTEXT
212error_t coapClientInit(CoapClientContext *context);
214error_t coapClientSetTransportProtocol(CoapClientContext *context,
217#if (COAP_CLIENT_DTLS_SUPPORT == ENABLED)
219error_t coapClientRegisterDtlsInitCallback(CoapClientContext *context,
225error_t coapClientSetTokenLength(CoapClientContext *context,
size_t length);
227error_t coapClientBindToInterface(CoapClientContext *context,
228 NetInterface *interface);
230error_t coapClientConnect(CoapClientContext *context,
231 const IpAddr *serverIpAddr, uint16_t serverPort);
235error_t coapClientDisconnect(CoapClientContext *context);
237void coapClientDeinit(CoapClientContext *context);
CoapClientState
CoAP client states.
Definition coap_client.h:164
error_t(* CoapClientDtlsInitCallback)(CoapClientContext *context, TlsContext *dtlsContext)
DTLS initialization callback.
Definition coap_client.h:178
Definitions common to CoAP client and server.
CoapTransportProtocol
CoAP transport protocols.
Definition coap_common.h:77
CoAP message formatting and parsing.
CoAP option formatting and parsing.
error_t
Error codes.
Definition error.h:43
uint_t OsMutex
Mutex object.
Definition os_port_none.h:118
uint_t OsEvent
Event object.
Definition os_port_none.h:104
uint32_t systime_t
System time.
Definition os_port_none.h:90
CoAP message.
Definition coap_message.h:56
IP network address.
Definition ip.h:72
CoAP client context.
Definition coap_client.h:189
CoapClientState state
CoAP client state.
Definition coap_client.h:192
CoapMessage response
CoAP response message.
Definition coap_client.h:206
OsEvent event
Event object used to receive notifications.
Definition coap_client.h:191
TlsContext * dtlsContext
DTLS context.
Definition coap_client.h:197
uint16_t mid
Message identifier.
Definition coap_client.h:203
Socket * socket
Underlying UDP socket.
Definition coap_client.h:195
size_t tokenLen
Token length.
Definition coap_client.h:204
TlsSessionState dtlsSession
DTLS session state.
Definition coap_client.h:198
OsMutex mutex
Mutex preventing simultaneous access to the context.
Definition coap_client.h:190
systime_t timeout
Timeout value.
Definition coap_client.h:202
CoapTransportProtocol transportProtocol
Transport protocol (UDP or DTLS)
Definition coap_client.h:193
systime_t startTime
Start time.
Definition coap_client.h:201
CoapClientDtlsInitCallback dtlsInitCallback
DTLS initialization callback.
Definition coap_client.h:199
NetInterface * interface
Underlying network interface.
Definition coap_client.h:194
CoapClientRequest request[COAP_CLIENT_NSTART]
Outstanding CoAP requests.
Definition coap_client.h:205
CoAP request.
Definition coap_client_request.h:91
CoapClientContext * context
CoAP client context.
Definition coap_client_request.h:93