coap_client.h File Reference

CoAP client. 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.h"
#include "coap_client_request.h"

Go to the source code of this file.

Data Structures

struct  _CoapClientContext
 CoAP client context. More...
 

Macros

#define COAP_CLIENT_SUPPORT   ENABLED
 
#define COAP_CLIENT_DTLS_SUPPORT   DISABLED
 
#define COAP_CLIENT_OBSERVE_SUPPORT   ENABLED
 
#define COAP_CLIENT_BLOCK_SUPPORT   ENABLED
 
#define COAP_CLIENT_TICK_INTERVAL   100
 
#define COAP_CLIENT_DEFAULT_TIMEOUT   20000
 
#define COAP_CLIENT_NSTART   1
 
#define COAP_CLIENT_MAX_RETRANSMIT   4
 
#define COAP_CLIENT_ACK_TIMEOUT_MIN   2000
 
#define COAP_CLIENT_ACK_TIMEOUT_MAX   3000
 
#define COAP_CLIENT_RAND_DELAY_MIN   5000
 
#define COAP_CLIENT_RAND_DELAY_MAX   15000
 
#define COAP_CLIENT_DEFAULT_TOKEN_LEN   4
 
#define COAP_CLIENT_PRIVATE_CONTEXT
 
#define CoapClientContext   struct _CoapClientContext
 
#define CoapClientRequest   struct _CoapClientRequest
 

Typedefs

typedef error_t(* CoapClientDtlsInitCallback) (CoapClientContext *context, TlsContext *dtlsContext)
 DTLS initialization callback. More...
 

Enumerations

enum  CoapClientState { COAP_CLIENT_STATE_DISCONNECTED = 0 , COAP_CLIENT_STATE_CONNECTING = 1 , COAP_CLIENT_STATE_CONNECTED = 2 }
 CoAP client states. More...
 

Functions

error_t coapClientInit (CoapClientContext *context)
 Initialize CoAP client context. More...
 
error_t coapClientSetTransportProtocol (CoapClientContext *context, CoapTransportProtocol transportProtocol)
 Set the transport protocol to be used. More...
 
error_t coapClientRegisterDtlsInitCallback (CoapClientContext *context, CoapClientDtlsInitCallback callback)
 Register DTLS initialization callback function. More...
 
error_t coapClientSetTimeout (CoapClientContext *context, systime_t timeout)
 Set default request timeout. More...
 
error_t coapClientSetTokenLength (CoapClientContext *context, size_t length)
 Set the length of the token. More...
 
error_t coapClientBindToInterface (CoapClientContext *context, NetInterface *interface)
 Bind the CoAP client to a particular network interface. More...
 
error_t coapClientConnect (CoapClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
 Establish connection with the CoAP server. More...
 
error_t coapClientTask (CoapClientContext *context, systime_t timeout)
 Process CoAP client events. More...
 
error_t coapClientDisconnect (CoapClientContext *context)
 Disconnect from the CoAP server. More...
 
void coapClientDeinit (CoapClientContext *context)
 Release CoAP client context. More...
 

Detailed Description

CoAP client.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file coap_client.h.

Macro Definition Documentation

◆ COAP_CLIENT_ACK_TIMEOUT_MAX

#define COAP_CLIENT_ACK_TIMEOUT_MAX   3000

Definition at line 105 of file coap_client.h.

◆ COAP_CLIENT_ACK_TIMEOUT_MIN

#define COAP_CLIENT_ACK_TIMEOUT_MIN   2000

Definition at line 98 of file coap_client.h.

◆ COAP_CLIENT_BLOCK_SUPPORT

#define COAP_CLIENT_BLOCK_SUPPORT   ENABLED

Definition at line 63 of file coap_client.h.

◆ COAP_CLIENT_DEFAULT_TIMEOUT

#define COAP_CLIENT_DEFAULT_TIMEOUT   20000

Definition at line 77 of file coap_client.h.

◆ COAP_CLIENT_DEFAULT_TOKEN_LEN

#define COAP_CLIENT_DEFAULT_TOKEN_LEN   4

Definition at line 126 of file coap_client.h.

◆ COAP_CLIENT_DTLS_SUPPORT

#define COAP_CLIENT_DTLS_SUPPORT   DISABLED

Definition at line 49 of file coap_client.h.

◆ COAP_CLIENT_MAX_RETRANSMIT

#define COAP_CLIENT_MAX_RETRANSMIT   4

Definition at line 91 of file coap_client.h.

◆ COAP_CLIENT_NSTART

#define COAP_CLIENT_NSTART   1

Definition at line 84 of file coap_client.h.

◆ COAP_CLIENT_OBSERVE_SUPPORT

#define COAP_CLIENT_OBSERVE_SUPPORT   ENABLED

Definition at line 56 of file coap_client.h.

◆ COAP_CLIENT_PRIVATE_CONTEXT

#define COAP_CLIENT_PRIVATE_CONTEXT

Definition at line 133 of file coap_client.h.

◆ COAP_CLIENT_RAND_DELAY_MAX

#define COAP_CLIENT_RAND_DELAY_MAX   15000

Definition at line 119 of file coap_client.h.

◆ COAP_CLIENT_RAND_DELAY_MIN

#define COAP_CLIENT_RAND_DELAY_MIN   5000

Definition at line 112 of file coap_client.h.

◆ COAP_CLIENT_SUPPORT

#define COAP_CLIENT_SUPPORT   ENABLED

Definition at line 42 of file coap_client.h.

◆ COAP_CLIENT_TICK_INTERVAL

#define COAP_CLIENT_TICK_INTERVAL   100

Definition at line 70 of file coap_client.h.

◆ CoapClientContext

#define CoapClientContext   struct _CoapClientContext

Definition at line 144 of file coap_client.h.

◆ CoapClientRequest

#define CoapClientRequest   struct _CoapClientRequest

Definition at line 148 of file coap_client.h.

Typedef Documentation

◆ CoapClientDtlsInitCallback

typedef error_t(* CoapClientDtlsInitCallback) (CoapClientContext *context, TlsContext *dtlsContext)

DTLS initialization callback.

Definition at line 178 of file coap_client.h.

Enumeration Type Documentation

◆ CoapClientState

CoAP client states.

Enumerator
COAP_CLIENT_STATE_DISCONNECTED 
COAP_CLIENT_STATE_CONNECTING 
COAP_CLIENT_STATE_CONNECTED 

Definition at line 163 of file coap_client.h.

Function Documentation

◆ coapClientBindToInterface()

error_t coapClientBindToInterface ( CoapClientContext context,
NetInterface interface 
)

Bind the CoAP client to a particular network interface.

Parameters
[in]contextPointer to the CoAP client context
[in]interfaceNetwork interface to be used
Returns
Error code

Definition at line 240 of file coap_client.c.

◆ coapClientConnect()

error_t coapClientConnect ( CoapClientContext context,
const IpAddr serverIpAddr,
uint16_t  serverPort 
)

Establish connection with the CoAP server.

Parameters
[in]contextPointer to the CoAP client context
[in]serverIpAddrIP address of the CoAP server to connect to
[in]serverPortUDP port number that will be used
Returns
Error code

Definition at line 267 of file coap_client.c.

◆ coapClientDeinit()

void coapClientDeinit ( CoapClientContext context)

Release CoAP client context.

Parameters
[in]contextPointer to the CoAP client context

Definition at line 438 of file coap_client.c.

◆ coapClientDisconnect()

error_t coapClientDisconnect ( CoapClientContext context)

Disconnect from the CoAP server.

Parameters
[in]contextPointer to the CoAP client context
Returns
Error code

Definition at line 399 of file coap_client.c.

◆ coapClientInit()

error_t coapClientInit ( CoapClientContext context)

Initialize CoAP client context.

Parameters
[in]contextPointer to the CoAP client context
Returns
Error code

Definition at line 53 of file coap_client.c.

◆ coapClientRegisterDtlsInitCallback()

error_t coapClientRegisterDtlsInitCallback ( CoapClientContext context,
CoapClientDtlsInitCallback  callback 
)

Register DTLS initialization callback function.

Parameters
[in]contextPointer to the CoAP client context
[in]callbackDTLS initialization callback function
Returns
Error code

Definition at line 158 of file coap_client.c.

◆ coapClientSetTimeout()

error_t coapClientSetTimeout ( CoapClientContext context,
systime_t  timeout 
)

Set default request timeout.

Parameters
[in]contextPointer to the CoAP client context
[in]timeoutTimeout value, in milliseconds
Returns
Error code

Definition at line 186 of file coap_client.c.

◆ coapClientSetTokenLength()

error_t coapClientSetTokenLength ( CoapClientContext context,
size_t  length 
)

Set the length of the token.

Parameters
[in]contextPointer to the CoAP client context
[in]lengthToken length
Returns
Error code

Definition at line 211 of file coap_client.c.

◆ coapClientSetTransportProtocol()

error_t coapClientSetTransportProtocol ( CoapClientContext context,
CoapTransportProtocol  transportProtocol 
)

Set the transport protocol to be used.

Parameters
[in]contextPointer to the CoAP client context
[in]transportProtocolTransport protocol to be used (UDP or DTLS)
Returns
Error code

Definition at line 130 of file coap_client.c.

◆ coapClientTask()

error_t coapClientTask ( CoapClientContext context,
systime_t  timeout 
)

Process CoAP client events.

Parameters
[in]contextPointer to the CoAP client context
[in]timeoutMaximum time to wait before returning
Returns
Error code

Definition at line 373 of file coap_client.c.