coap_client_misc.c File Reference

Helper functions for CoAP client. More...

#include <stdlib.h>
#include "core/net.h"
#include "coap/coap_client.h"
#include "coap/coap_client_observe.h"
#include "coap/coap_client_transport.h"
#include "coap/coap_client_misc.h"
#include "coap/coap_common.h"
#include "coap/coap_debug.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   COAP_TRACE_LEVEL
 

Functions

error_t coapClientProcessEvents (CoapClientContext *context, systime_t timeout)
 Process CoAP client events. More...
 
error_t coapClientProcessRequestEvents (CoapClientRequest *request)
 Process request-specific events. More...
 
error_t coapClientChangeRequestState (CoapClientRequest *request, CoapRequestState newState)
 Update CoAP request state. More...
 
error_t coapClientMatchResponse (const CoapClientRequest *request, const CoapMessage *response)
 Check whether a response matches the specified request. More...
 
error_t coapClientProcessResponse (CoapClientRequest *request, const CoapMessage *response)
 Process CoAP response. More...
 
error_t coapClientRejectResponse (CoapClientContext *context, const CoapMessage *response)
 Reject a CoAP response. More...
 
error_t coapClientSendAck (CoapClientContext *context, uint16_t mid)
 Send Acknowledgment message. More...
 
error_t coapClientSendReset (CoapClientContext *context, uint16_t mid)
 Send Reset message. More...
 
void coapClientGenerateMessageId (CoapClientContext *context, CoapMessageHeader *header)
 Generate a new message identifier. More...
 
void coapClientGenerateToken (CoapClientContext *context, CoapMessageHeader *header)
 Generate a new token. More...
 

Detailed Description

Helper functions for 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_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   COAP_TRACE_LEVEL

Definition at line 32 of file coap_client_misc.c.

Function Documentation

◆ coapClientChangeRequestState()

error_t coapClientChangeRequestState ( CoapClientRequest request,
CoapRequestState  newState 
)

Update CoAP request state.

Parameters
[in]requestCoAP request handle
[in]newStateNew state to switch to
Returns
Error code

Definition at line 342 of file coap_client_misc.c.

◆ coapClientGenerateMessageId()

void coapClientGenerateMessageId ( CoapClientContext context,
CoapMessageHeader header 
)

Generate a new message identifier.

Parameters
[in]contextPointer to the CoAP client context
[in]headerPointer to the CoAP message header

Definition at line 768 of file coap_client_misc.c.

◆ coapClientGenerateToken()

void coapClientGenerateToken ( CoapClientContext context,
CoapMessageHeader header 
)

Generate a new token.

Parameters
[in]contextPointer to the CoAP client context
[in]headerPointer to the CoAP message header

Definition at line 786 of file coap_client_misc.c.

◆ coapClientMatchResponse()

error_t coapClientMatchResponse ( const CoapClientRequest request,
const CoapMessage response 
)

Check whether a response matches the specified request.

Parameters
[in]requestCoAP request handle
[in]responsePointer to the response message
Returns
Error code

Definition at line 432 of file coap_client_misc.c.

◆ coapClientProcessEvents()

error_t coapClientProcessEvents ( 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 56 of file coap_client_misc.c.

◆ coapClientProcessRequestEvents()

error_t coapClientProcessRequestEvents ( CoapClientRequest request)

Process request-specific events.

Parameters
[in]requestCoAP request handle
Returns
Error code

Definition at line 198 of file coap_client_misc.c.

◆ coapClientProcessResponse()

error_t coapClientProcessResponse ( CoapClientRequest request,
const CoapMessage response 
)

Process CoAP response.

Parameters
[in]requestCoAP request handle
[in]responsePointer to the response message
Returns
Error code

Definition at line 570 of file coap_client_misc.c.

◆ coapClientRejectResponse()

error_t coapClientRejectResponse ( CoapClientContext context,
const CoapMessage response 
)

Reject a CoAP response.

Parameters
[in]contextPointer to the CoAP client context
[in]responsePointer to the response message to be rejected
Returns
Error code

Definition at line 658 of file coap_client_misc.c.

◆ coapClientSendAck()

error_t coapClientSendAck ( CoapClientContext context,
uint16_t  mid 
)

Send Acknowledgment message.

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

Definition at line 703 of file coap_client_misc.c.

◆ coapClientSendReset()

error_t coapClientSendReset ( CoapClientContext context,
uint16_t  mid 
)

Send Reset message.

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

Definition at line 736 of file coap_client_misc.c.