Go to the documentation of this file.
31 #ifndef _COAP_SERVER_H
32 #define _COAP_SERVER_H
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)
121 #define CoapServerContext struct _CoapServerContext
125 #define CoapDtlsSession struct _CoapDtlsSession
142 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
172 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
189 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
212 #if (COAP_SERVER_DTLS_SUPPORT == ENABLED)
233 const uint8_t *cookieSecret,
size_t cookieSecretLen);
CoapDtlsSession session[COAP_SERVER_MAX_SESSIONS]
DTLS sessions.
OsTaskParameters taskParams
Task parameters.
NetInterface * interface
Underlying network interface.
error_t(* CoapServerUdpInitCallback)(CoapServerContext *context, Socket *socket)
UDP initialization callback function.
CoapServerUdpInitCallback udpInitCallback
UDP initialization callback.
#define COAP_SERVER_MAX_SESSIONS
CoAP message formatting and parsing.
OsTaskId taskId
Task identifier.
uint16_t port
CoAP port number.
OsTaskParameters task
Task parameters.
OsEvent event
Event object used to poll the underlying socket.
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
char_t uri[COAP_SERVER_MAX_URI_LEN+1]
Resource identifier.
void coapServerDeinit(CoapServerContext *context)
Release CoAP server context.
CoapMessage response
CoAP response message.
error_t coapServerStop(CoapServerContext *context)
Stop CoAP server.
General definitions for cryptographic algorithms.
size_t bufferLen
Length of the buffer, in bytes.
IpAddr serverIpAddr
Server's IP address.
uint32_t systime_t
System time.
uint8_t buffer[COAP_SERVER_BUFFER_SIZE]
Memory buffer for input/output operations.
CoapServerContext * context
uint16_t clientPort
Client's port.
#define COAP_SERVER_MAX_URI_LEN
#define CoapServerContext
CoapServerRequestCallback requestCallback
CoAP request callback.
uint8_t cookieSecret[COAP_SERVER_MAX_COOKIE_SECRET_SIZE]
Cookie secret.
error_t(* CoapServerRequestCallback)(CoapServerContext *context, CoapCode method, const char_t *uri)
CoAP request callback function.
CoapMessage request
CoAP request message.
void coapServerGetDefaultSettings(CoapServerSettings *settings)
Initialize settings with default values.
IpAddr clientIpAddr
Client's IP address.
TLS (Transport Layer Security)
error_t coapServerStart(CoapServerContext *context)
Start CoAP server.
CoapServerSettings settings
User settings.
#define COAP_SERVER_PRIVATE_CONTEXT
CoapServerDtlsInitCallback dtlsInitCallback
DTLS initialization callback.
bool_t running
Operational state of the CoAP server.
thread_t * OsTaskId
Task identifier.
#define COAP_SERVER_MAX_COOKIE_SECRET_SIZE
error_t(* CoapServerDtlsInitCallback)(CoapServerContext *context, TlsContext *dtlsContext)
DTLS initialization callback.
void coapServerTask(CoapServerContext *context)
CoAP server task.
size_t cookieSecretLen
Length of the cookie secret, in bytes.
Socket * socket
Underlying socket.
#define COAP_SERVER_BUFFER_SIZE
CoapCode
CoAP method and response codes.
Definitions common to CoAP client and server.
Formatting and parsing of CoAP options.
error_t coapServerInit(CoapServerContext *context, const CoapServerSettings *settings)
CoAP server initialization.
error_t coapServerSetCookieSecret(CoapServerContext *context, const uint8_t *cookieSecret, size_t cookieSecretLen)
Set cookie secret.