41#ifndef COAP_SERVER_SUPPORT
42 #define COAP_SERVER_SUPPORT ENABLED
43#elif (COAP_SERVER_SUPPORT != ENABLED && COAP_SERVER_SUPPORT != DISABLED)
44 #error COAP_SERVER_SUPPORT parameter is not valid
48#ifndef COAP_SERVER_DTLS_SUPPORT
49 #define COAP_SERVER_DTLS_SUPPORT DISABLED
50#elif (COAP_SERVER_DTLS_SUPPORT != ENABLED && COAP_SERVER_DTLS_SUPPORT != DISABLED)
51 #error COAP_SERVER_DTLS_SUPPORT parameter is not valid
55#ifndef COAP_SERVER_STACK_SIZE
56 #define COAP_SERVER_STACK_SIZE 650
57#elif (COAP_SERVER_STACK_SIZE < 1)
58 #error COAP_SERVER_STACK_SIZE parameter is not valid
62#ifndef COAP_SERVER_MAX_SESSIONS
63 #define COAP_SERVER_MAX_SESSIONS 4
64#elif (COAP_SERVER_MAX_SESSIONS < 1)
65 #error COAP_SERVER_MAX_SESSIONS parameter is not valid
69#ifndef COAP_SERVER_TICK_INTERVAL
70 #define COAP_SERVER_TICK_INTERVAL 500
71#elif (COAP_SERVER_TICK_INTERVAL < 100)
72 #error COAP_SERVER_TICK_INTERVAL parameter is not valid
76#ifndef COAP_SERVER_SESSION_TIMEOUT
77 #define COAP_SERVER_SESSION_TIMEOUT 60000
78#elif (COAP_SERVER_SESSION_TIMEOUT < 0)
79 #error COAP_SERVER_SESSION_TIMEOUT parameter is not valid
83#ifndef COAP_SERVER_BUFFER_SIZE
84 #define COAP_SERVER_BUFFER_SIZE 2048
85#elif (COAP_SERVER_BUFFER_SIZE < 1)
86 #error COAP_SERVER_BUFFER_SIZE parameter is not valid
90#ifndef COAP_SERVER_MAX_COOKIE_SECRET_SIZE
91 #define COAP_SERVER_MAX_COOKIE_SECRET_SIZE 32
92#elif (COAP_SERVER_MAX_COOKIE_SECRET_SIZE < 1)
93 #error COAP_SERVER_MAX_COOKIE_SECRET_SIZE parameter is not valid
97#ifndef COAP_SERVER_MAX_URI_LEN
98 #define COAP_SERVER_MAX_URI_LEN 128
99#elif (COAP_SERVER_MAX_URI_LEN < 1)
100 #error COAP_SERVER_MAX_URI_LEN parameter is not valid
104#ifndef COAP_SERVER_PRIORITY
105 #define COAP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL
109#ifndef COAP_SERVER_PRIVATE_CONTEXT
110 #define COAP_SERVER_PRIVATE_CONTEXT
114#if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
115 #include "core/crypto.h"
121#define CoapServerContext struct _CoapServerContext
125#define CoapDtlsSession struct _CoapDtlsSession
134#if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
141 TlsContext *dtlsContext);
151 CoapCode method,
const char_t *uri);
162#if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
175 CoapServerContext *context;
179#if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
180 TlsContext *dtlsContext;
197#if (OS_STATIC_TASK_SUPPORT == ENABLED)
205#if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
208 CoapDtlsSession
session[COAP_SERVER_MAX_SESSIONS];
212 char_t
uri[COAP_SERVER_MAX_URI_LEN + 1];
215 COAP_SERVER_PRIVATE_CONTEXT
222error_t coapServerInit(CoapServerContext *context,
225error_t coapServerSetCookieSecret(CoapServerContext *context,
226 const uint8_t *cookieSecret,
size_t cookieSecretLen);
228error_t coapServerStart(CoapServerContext *context);
229error_t coapServerStop(CoapServerContext *context);
231void coapServerTask(CoapServerContext *context);
233void coapServerDeinit(CoapServerContext *context);
Definitions common to CoAP client and server.
CoapCode
CoAP method and response codes.
Definition coap_common.h:113
CoAP message formatting and parsing.
CoAP option formatting and parsing.
error_t(* CoapServerRequestCallback)(CoapServerContext *context, CoapCode method, const char_t *uri)
CoAP request callback function.
Definition coap_server.h:150
error_t(* CoapServerDtlsInitCallback)(CoapServerContext *context, TlsContext *dtlsContext)
DTLS initialization callback.
Definition coap_server.h:140
error_t
Error codes.
Definition error.h:43
uint_t OsEvent
Event object.
Definition os_port_none.h:104
uint_t OsTaskId
Task identifier.
Definition os_port_none.h:97
uint32_t systime_t
System time.
Definition os_port_none.h:90
CoAP message.
Definition coap_message.h:56
CoAP server settings.
Definition coap_server.h:159
CoapServerDtlsInitCallback dtlsInitCallback
DTLS initialization callback.
Definition coap_server.h:163
CoapServerRequestCallback requestCallback
CoAP request callback.
Definition coap_server.h:165
uint16_t port
CoAP port number.
Definition coap_server.h:161
NetInterface * interface
Underlying network interface.
Definition coap_server.h:160
IP network address.
Definition ip.h:72
DTLS session.
Definition coap_server.h:174
CoAP server context.
Definition coap_server.h:191
size_t bufferLen
Length of the buffer, in bytes.
Definition coap_server.h:211
CoapDtlsSession session[COAP_SERVER_MAX_SESSIONS]
DTLS sessions.
Definition coap_server.h:208
Socket * socket
Underlying socket.
Definition coap_server.h:201
CoapMessage response
CoAP response message.
Definition coap_server.h:214
OsStackType taskStack[COAP_SERVER_STACK_SIZE]
Task stack.
Definition coap_server.h:199
char_t uri[COAP_SERVER_MAX_URI_LEN+1]
Resource identifier.
Definition coap_server.h:212
size_t cookieSecretLen
Length of the cookie secret, in bytes.
Definition coap_server.h:207
bool_t running
Operational state of the CoAP server.
Definition coap_server.h:193
CoapMessage request
CoAP request message.
Definition coap_server.h:213
bool_t stop
Stop request.
Definition coap_server.h:194
OsTaskId taskId
Task identifier.
Definition coap_server.h:196
uint16_t clientPort
Client's port.
Definition coap_server.h:204
IpAddr clientIpAddr
Client's IP address.
Definition coap_server.h:203
IpAddr serverIpAddr
Server's IP address.
Definition coap_server.h:202
CoapServerSettings settings
User settings.
Definition coap_server.h:192
OsTaskTcb taskTcb
Task control block.
Definition coap_server.h:198
uint8_t cookieSecret[COAP_SERVER_MAX_COOKIE_SECRET_SIZE]
Cookie secret.
Definition coap_server.h:206
uint8_t buffer[COAP_SERVER_BUFFER_SIZE]
Memory buffer for input/output operations.
Definition coap_server.h:210
OsEvent event
Event object used to poll the underlying socket.
Definition coap_server.h:195