CoAP server. More...
#include "core/net.h"#include "coap/coap_common.h"#include "coap/coap_message.h"#include "coap/coap_option.h"#include "core/crypto.h"#include "tls/tls.h"#include "tls/tls_ticket.h"Go to the source code of this file.
Data Structures | |
| struct | CoapServerSettings |
| CoAP server settings. More... | |
| struct | _CoapServerContext |
| CoAP server context. More... | |
| struct | _CoapDtlsSession |
| DTLS session. More... | |
| struct | _CoapResource |
| Observable resource. More... | |
| struct | _CoapObserver |
| Observer. More... | |
Macros | |
| #define | COAP_SERVER_SUPPORT ENABLED |
| #define | COAP_SERVER_DTLS_SUPPORT DISABLED |
| #define | COAP_SERVER_OBSERVE_SUPPORT DISABLED |
| #define | COAP_SERVER_STACK_SIZE 650 |
| #define | COAP_SERVER_TICK_INTERVAL 250 |
| #define | COAP_SERVER_SESSION_TIMEOUT 120000 |
| #define | COAP_SERVER_MAX_RETRANSMIT 4 |
| #define | COAP_SERVER_ACK_TIMEOUT_MIN 2000 |
| #define | COAP_SERVER_ACK_TIMEOUT_MAX 3000 |
| #define | COAP_SERVER_MIN_NON_CONFIRMABLE_NOTIF_INTERVAL 3000 |
| #define | COAP_SERVER_MAX_CONFIRMABLE_NOTIF_INTERVAL 60000 |
| #define | COAP_SERVER_BUFFER_SIZE 2048 |
| #define | COAP_SERVER_MAX_OBS_RESOURCE_SIZE 512 |
| #define | COAP_SERVER_MAX_COOKIE_SECRET_SIZE 32 |
| #define | COAP_SERVER_MAX_URI_LEN 128 |
| #define | COAP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL |
| #define | COAP_SERVER_PRIVATE_CONTEXT |
| #define | CoapServerContext struct _CoapServerContext |
| #define | CoapDtlsSession struct _CoapDtlsSession |
| #define | CoapResource struct _CoapResource |
| #define | CoapObserver struct _CoapObserver |
Typedefs | |
| typedef error_t(* | CoapServerUdpInitCallback) (CoapServerContext *context, Socket *socket) |
| UDP initialization callback function. More... | |
| typedef error_t(* | CoapServerDtlsInitCallback) (CoapServerContext *context, TlsContext *dtlsContext) |
| DTLS initialization callback. More... | |
| typedef error_t(* | CoapServerRequestCallback) (CoapServerContext *context, CoapCode method, const char_t *uri) |
| CoAP request callback function. More... | |
| typedef error_t(* | CoapServerObserveCallback) (CoapServerContext *context, CoapObserver *observer, CoapResource *resource) |
| Observe callback function. More... | |
Enumerations | |
| enum | CoapObserverState { COAP_OBSERVER_STATE_UNREGISTERED = 0, COAP_OBSERVER_STATE_REGISTERED = 1, COAP_OBSERVER_STATE_UPDATING = 2 } |
| Observer states. More... | |
Functions | |
| void | coapServerGetDefaultSettings (CoapServerSettings *settings) |
| Initialize settings with default values. More... | |
| error_t | coapServerInit (CoapServerContext *context, const CoapServerSettings *settings) |
| CoAP server initialization. More... | |
| error_t | coapServerSetCookieSecret (CoapServerContext *context, const uint8_t *cookieSecret, size_t cookieSecretLen) |
| Set cookie secret. More... | |
| error_t | coapServerStart (CoapServerContext *context) |
| Start CoAP server. More... | |
| error_t | coapServerStop (CoapServerContext *context) |
| Stop CoAP server. More... | |
| error_t | coapServerCreateResource (CoapServerContext *context, const char_t *uri) |
| Create a new observable resource. More... | |
| error_t | coapServerUpdateResource (CoapServerContext *context, const char_t *uri, const void *data, size_t length) |
| Update the state of an observable resource. More... | |
| error_t | coapServerDeleteResource (CoapServerContext *context, const char_t *uri) |
| Delete an observable resource. More... | |
| void | coapServerTask (CoapServerContext *context) |
| CoAP server task. More... | |
| void | coapServerDeinit (CoapServerContext *context) |
| Release CoAP server context. More... | |
Detailed Description
CoAP server.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.6.4
Definition in file coap_server.h.
Macro Definition Documentation
◆ COAP_SERVER_ACK_TIMEOUT_MAX
| #define COAP_SERVER_ACK_TIMEOUT_MAX 3000 |
Definition at line 98 of file coap_server.h.
◆ COAP_SERVER_ACK_TIMEOUT_MIN
| #define COAP_SERVER_ACK_TIMEOUT_MIN 2000 |
Definition at line 91 of file coap_server.h.
◆ COAP_SERVER_BUFFER_SIZE
| #define COAP_SERVER_BUFFER_SIZE 2048 |
Definition at line 119 of file coap_server.h.
◆ COAP_SERVER_DTLS_SUPPORT
| #define COAP_SERVER_DTLS_SUPPORT DISABLED |
Definition at line 49 of file coap_server.h.
◆ COAP_SERVER_MAX_CONFIRMABLE_NOTIF_INTERVAL
| #define COAP_SERVER_MAX_CONFIRMABLE_NOTIF_INTERVAL 60000 |
Definition at line 112 of file coap_server.h.
◆ COAP_SERVER_MAX_COOKIE_SECRET_SIZE
| #define COAP_SERVER_MAX_COOKIE_SECRET_SIZE 32 |
Definition at line 133 of file coap_server.h.
◆ COAP_SERVER_MAX_OBS_RESOURCE_SIZE
| #define COAP_SERVER_MAX_OBS_RESOURCE_SIZE 512 |
Definition at line 126 of file coap_server.h.
◆ COAP_SERVER_MAX_RETRANSMIT
| #define COAP_SERVER_MAX_RETRANSMIT 4 |
Definition at line 84 of file coap_server.h.
◆ COAP_SERVER_MAX_URI_LEN
| #define COAP_SERVER_MAX_URI_LEN 128 |
Definition at line 140 of file coap_server.h.
◆ COAP_SERVER_MIN_NON_CONFIRMABLE_NOTIF_INTERVAL
| #define COAP_SERVER_MIN_NON_CONFIRMABLE_NOTIF_INTERVAL 3000 |
Definition at line 105 of file coap_server.h.
◆ COAP_SERVER_OBSERVE_SUPPORT
| #define COAP_SERVER_OBSERVE_SUPPORT DISABLED |
Definition at line 56 of file coap_server.h.
◆ COAP_SERVER_PRIORITY
| #define COAP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL |
Definition at line 147 of file coap_server.h.
◆ COAP_SERVER_PRIVATE_CONTEXT
| #define COAP_SERVER_PRIVATE_CONTEXT |
Definition at line 152 of file coap_server.h.
◆ COAP_SERVER_SESSION_TIMEOUT
| #define COAP_SERVER_SESSION_TIMEOUT 120000 |
Definition at line 77 of file coap_server.h.
◆ COAP_SERVER_STACK_SIZE
| #define COAP_SERVER_STACK_SIZE 650 |
Definition at line 63 of file coap_server.h.
◆ COAP_SERVER_SUPPORT
| #define COAP_SERVER_SUPPORT ENABLED |
Definition at line 42 of file coap_server.h.
◆ COAP_SERVER_TICK_INTERVAL
| #define COAP_SERVER_TICK_INTERVAL 250 |
Definition at line 70 of file coap_server.h.
◆ CoapDtlsSession
| #define CoapDtlsSession struct _CoapDtlsSession |
Definition at line 168 of file coap_server.h.
◆ CoapObserver
| #define CoapObserver struct _CoapObserver |
Definition at line 176 of file coap_server.h.
◆ CoapResource
| #define CoapResource struct _CoapResource |
Definition at line 172 of file coap_server.h.
◆ CoapServerContext
| #define CoapServerContext struct _CoapServerContext |
Definition at line 164 of file coap_server.h.
Typedef Documentation
◆ CoapServerDtlsInitCallback
| typedef error_t(* CoapServerDtlsInitCallback) (CoapServerContext *context, TlsContext *dtlsContext) |
DTLS initialization callback.
Definition at line 211 of file coap_server.h.
◆ CoapServerObserveCallback
| typedef error_t(* CoapServerObserveCallback) (CoapServerContext *context, CoapObserver *observer, CoapResource *resource) |
Observe callback function.
Definition at line 229 of file coap_server.h.
◆ CoapServerRequestCallback
| typedef error_t(* CoapServerRequestCallback) (CoapServerContext *context, CoapCode method, const char_t *uri) |
CoAP request callback function.
Definition at line 221 of file coap_server.h.
◆ CoapServerUdpInitCallback
| typedef error_t(* CoapServerUdpInitCallback) (CoapServerContext *context, Socket *socket) |
UDP initialization callback function.
Definition at line 200 of file coap_server.h.
Enumeration Type Documentation
◆ CoapObserverState
| enum CoapObserverState |
Observer states.
| Enumerator | |
|---|---|
| COAP_OBSERVER_STATE_UNREGISTERED | |
| COAP_OBSERVER_STATE_REGISTERED | |
| COAP_OBSERVER_STATE_UPDATING | |
Definition at line 188 of file coap_server.h.
Function Documentation
◆ coapServerCreateResource()
| error_t coapServerCreateResource | ( | CoapServerContext * | context, |
| const char_t * | uri | ||
| ) |
Create a new observable resource.
- Parameters
-
[in] context Pointer to the CoAP server context [in] uri NULL-terminated string containing the path to the resource
- Returns
- Error code
Definition at line 447 of file coap_server.c.
◆ coapServerDeinit()
| void coapServerDeinit | ( | CoapServerContext * | context | ) |
Release CoAP server context.
- Parameters
-
[in] context Pointer to the CoAP server context
Definition at line 777 of file coap_server.c.
◆ coapServerDeleteResource()
| error_t coapServerDeleteResource | ( | CoapServerContext * | context, |
| const char_t * | uri | ||
| ) |
Delete an observable resource.
- Parameters
-
[in] context Pointer to the CoAP server context [in] uri NULL-terminated string containing the path to the resource
- Returns
- Error code
Definition at line 607 of file coap_server.c.
◆ coapServerGetDefaultSettings()
| void coapServerGetDefaultSettings | ( | CoapServerSettings * | settings | ) |
Initialize settings with default values.
- Parameters
-
[out] settings Structure that contains CoAP server settings
Definition at line 52 of file coap_server.c.
◆ coapServerInit()
| error_t coapServerInit | ( | CoapServerContext * | context, |
| const CoapServerSettings * | settings | ||
| ) |
CoAP server initialization.
- Parameters
-
[in] context Pointer to the CoAP server context [in] settings CoAP server specific settings
- Returns
- Error code
Definition at line 108 of file coap_server.c.
◆ coapServerSetCookieSecret()
| error_t coapServerSetCookieSecret | ( | CoapServerContext * | context, |
| const uint8_t * | cookieSecret, | ||
| size_t | cookieSecretLen | ||
| ) |
Set cookie secret.
This function specifies the cookie secret used while generating and verifying a cookie during the DTLS handshake
- Parameters
-
[in] context Pointer to the CoAP server context [in] cookieSecret Pointer to the secret key [in] cookieSecretLen Length of the secret key, in bytes
- Returns
- Error code
Definition at line 264 of file coap_server.c.
◆ coapServerStart()
| error_t coapServerStart | ( | CoapServerContext * | context | ) |
Start CoAP server.
- Parameters
-
[in] context Pointer to the CoAP server context
- Returns
- Error code
Definition at line 294 of file coap_server.c.
◆ coapServerStop()
| error_t coapServerStop | ( | CoapServerContext * | context | ) |
Stop CoAP server.
- Parameters
-
[in] context Pointer to the CoAP server context
- Returns
- Error code
Definition at line 392 of file coap_server.c.
◆ coapServerTask()
| void coapServerTask | ( | CoapServerContext * | context | ) |
CoAP server task.
- Parameters
-
[in] context Pointer to the CoAP server context
Definition at line 675 of file coap_server.c.
◆ coapServerUpdateResource()
| error_t coapServerUpdateResource | ( | CoapServerContext * | context, |
| const char_t * | uri, | ||
| const void * | data, | ||
| size_t | length | ||
| ) |
Update the state of an observable resource.
- Parameters
-
[in] context Pointer to the CoAP server context [in] uri NULL-terminated string containing the path to the resource [in] data New resource state [in] length Length of the resource state
- Returns
- Error code
Definition at line 525 of file coap_server.c.
