CoAP request handling. More...
#include <stdlib.h>
#include "core/net.h"
#include "coap/coap_client.h"
#include "coap/coap_client_request.h"
#include "coap/coap_client_block.h"
#include "coap/coap_client_misc.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL COAP_TRACE_LEVEL |
Functions | |
CoapClientRequest * | coapClientCreateRequest (CoapClientContext *context) |
Initialize a new CoAP request. More... | |
error_t | coapClientSetRequestTimeout (CoapClientRequest *request, systime_t timeout) |
Set request timeout. More... | |
error_t | coapClientSendRequest (CoapClientRequest *request, CoapRequestCallback callback, void *param) |
Send a CoAP request. More... | |
error_t | coapClientCancelRequest (CoapClientRequest *request) |
Cancel an outstanding CoAP request. More... | |
void | coapClientDeleteRequest (CoapClientRequest *request) |
Release the resources associated with a CoAP request. More... | |
CoapMessage * | coapClientGetRequestMessage (CoapClientRequest *request) |
Get request message. More... | |
CoapMessage * | coapClientGetResponseMessage (CoapClientRequest *request) |
Get response message. More... | |
error_t | coapClientSetType (CoapMessage *message, CoapMessageType type) |
Set message type. More... | |
error_t | coapClientGetType (const CoapMessage *message, CoapMessageType *type) |
Get message type. More... | |
error_t | coapClientSetMethodCode (CoapMessage *message, CoapCode code) |
Set request method. More... | |
error_t | coapClientGetMethodCode (const CoapMessage *message, CoapCode *code) |
Get request method. More... | |
error_t | coapClientGetResponseCode (const CoapMessage *message, CoapCode *code) |
Get response code. More... | |
error_t | coapClientSetUriPath (CoapMessage *message, const char_t *path) |
Set Uri-Path option. More... | |
error_t | coapClientGetUriPath (const CoapMessage *message, char_t *path, size_t maxLen) |
Get Uri-Path option. More... | |
error_t | coapClientSetUriQuery (CoapMessage *message, const char_t *queryString) |
Set Uri-Query option. More... | |
error_t | coapClientGetUriQuery (const CoapMessage *message, char_t *queryString, size_t maxLen) |
Get Uri-Query option. More... | |
error_t | coapClientGetLocationPath (const CoapMessage *message, char_t *path, size_t maxLen) |
Get Location-Path option. More... | |
error_t | coapClientGetLocationQuery (const CoapMessage *message, char_t *queryString, size_t maxLen) |
Get Location-Query option. More... | |
error_t | coapClientSetOpaqueOption (CoapMessage *message, uint16_t optionNum, uint_t optionIndex, const uint8_t *optionValue, size_t optionLen) |
Add an opaque option to the CoAP message. More... | |
error_t | coapClientSetStringOption (CoapMessage *message, uint16_t optionNum, uint_t optionIndex, const char_t *optionValue) |
Add a string option to the CoAP message. More... | |
error_t | coapClientSetUintOption (CoapMessage *message, uint16_t optionNum, uint_t optionIndex, uint32_t optionValue) |
Add a uint option to the CoAP message. More... | |
error_t | coapClientGetOpaqueOption (const CoapMessage *message, uint16_t optionNum, uint_t optionIndex, const uint8_t **optionValue, size_t *optionLen) |
Read an opaque option from the CoAP message. More... | |
error_t | coapClientGetStringOption (const CoapMessage *message, uint16_t optionNum, uint_t optionIndex, const char_t **optionValue, size_t *optionLen) |
Read a string option from the CoAP message. More... | |
error_t | coapClientGetUintOption (const CoapMessage *message, uint16_t optionNum, uint_t optionIndex, uint32_t *optionValue) |
Read an uint option from the CoAP message. More... | |
error_t | coapClientDeleteOption (CoapMessage *message, uint16_t optionNum, uint_t optionIndex) |
Remove an option from the CoAP message. More... | |
error_t | coapClientSetPayload (CoapMessage *message, const void *payload, size_t payloadLen) |
Set message payload. More... | |
error_t | coapClientGetPayload (const CoapMessage *message, const uint8_t **payload, size_t *payloadLen) |
Get message payload. More... | |
error_t | coapClientWritePayload (CoapMessage *message, const void *data, size_t length) |
Write payload data. More... | |
error_t | coapClientReadPayload (CoapMessage *message, void *data, size_t size, size_t *length) |
Read payload data. More... | |
Detailed Description
CoAP request handling.
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.
- Version
- 2.4.4
Definition in file coap_client_request.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL COAP_TRACE_LEVEL |
Definition at line 32 of file coap_client_request.c.
Function Documentation
◆ coapClientCancelRequest()
error_t coapClientCancelRequest | ( | CoapClientRequest * | request | ) |
Cancel an outstanding CoAP request.
- Parameters
-
[in] request CoAP request handle
- Returns
- Pointer to the CoAP request
Definition at line 275 of file coap_client_request.c.
◆ coapClientCreateRequest()
CoapClientRequest* coapClientCreateRequest | ( | CoapClientContext * | context | ) |
Initialize a new CoAP request.
- Parameters
-
[in] context Pointer to the CoAP client context
- Returns
- Pointer to the new CoAP request
Definition at line 53 of file coap_client_request.c.
◆ coapClientDeleteOption()
error_t coapClientDeleteOption | ( | CoapMessage * | message, |
uint16_t | optionNum, | ||
uint_t | optionIndex | ||
) |
Remove an option from the CoAP message.
- Parameters
-
[in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only)
- Returns
- Error code
Definition at line 808 of file coap_client_request.c.
◆ coapClientDeleteRequest()
void coapClientDeleteRequest | ( | CoapClientRequest * | request | ) |
Release the resources associated with a CoAP request.
- Parameters
-
[in] request CoAP request handle
Definition at line 349 of file coap_client_request.c.
◆ coapClientGetLocationPath()
error_t coapClientGetLocationPath | ( | const CoapMessage * | message, |
char_t * | path, | ||
size_t | maxLen | ||
) |
Get Location-Path option.
- Parameters
-
[in] message Pointer to the CoAP message [out] path Pointer to the buffer where to copy the path component [in] maxLen Maximum number of characters the buffer can hold
- Returns
- Error code
Definition at line 624 of file coap_client_request.c.
◆ coapClientGetLocationQuery()
error_t coapClientGetLocationQuery | ( | const CoapMessage * | message, |
char_t * | queryString, | ||
size_t | maxLen | ||
) |
Get Location-Query option.
- Parameters
-
[in] message Pointer to the CoAP message [out] queryString Pointer to the buffer where to copy the query string [in] maxLen Maximum number of characters the buffer can hold
- Returns
- Error code
Definition at line 645 of file coap_client_request.c.
◆ coapClientGetMethodCode()
error_t coapClientGetMethodCode | ( | const CoapMessage * | message, |
CoapCode * | code | ||
) |
Get request method.
- Parameters
-
[in] message Pointer to the CoAP message [out] code Method code
- Returns
- Error code
Definition at line 508 of file coap_client_request.c.
◆ coapClientGetOpaqueOption()
error_t coapClientGetOpaqueOption | ( | const CoapMessage * | message, |
uint16_t | optionNum, | ||
uint_t | optionIndex, | ||
const uint8_t ** | optionValue, | ||
size_t * | optionLen | ||
) |
Read an opaque option from the CoAP message.
- Parameters
-
[in] message Pointer to the CoAP message [in] optionNum Option number to search for [in] optionIndex Occurrence index (for repeatable options only) [out] optionValue Pointer to the first byte of the option value [out] optionLen Length of the option, in bytes
- Returns
- Error code
Definition at line 743 of file coap_client_request.c.
◆ coapClientGetPayload()
error_t coapClientGetPayload | ( | const CoapMessage * | message, |
const uint8_t ** | payload, | ||
size_t * | payloadLen | ||
) |
Get message payload.
- Parameters
-
[in] message Pointer to the CoAP message [out] payload Pointer to the first byte of the payload [out] payloadLen Length of the payload, in bytes
- Returns
- Error code
Definition at line 852 of file coap_client_request.c.
◆ coapClientGetRequestMessage()
CoapMessage* coapClientGetRequestMessage | ( | CoapClientRequest * | request | ) |
Get request message.
- Parameters
-
[in] request CoAP request handle
- Returns
- Pointer to the request message
Definition at line 370 of file coap_client_request.c.
◆ coapClientGetResponseCode()
error_t coapClientGetResponseCode | ( | const CoapMessage * | message, |
CoapCode * | code | ||
) |
Get response code.
- Parameters
-
[in] message Pointer to the CoAP message [out] code Response code
- Returns
- Error code
Definition at line 526 of file coap_client_request.c.
◆ coapClientGetResponseMessage()
CoapMessage* coapClientGetResponseMessage | ( | CoapClientRequest * | request | ) |
Get response message.
- Parameters
-
[in] request CoAP request handle
- Returns
- Pointer to the response message
Definition at line 414 of file coap_client_request.c.
◆ coapClientGetStringOption()
error_t coapClientGetStringOption | ( | const CoapMessage * | message, |
uint16_t | optionNum, | ||
uint_t | optionIndex, | ||
const char_t ** | optionValue, | ||
size_t * | optionLen | ||
) |
Read a string option from the CoAP message.
- Parameters
-
[in] message Pointer to the CoAP message [in] optionNum Option number to search for [in] optionIndex Occurrence index (for repeatable options only) [out] optionValue Pointer to the first byte of the option value [out] optionLen Length of the option, in characters
- Returns
- Error code
Definition at line 766 of file coap_client_request.c.
◆ coapClientGetType()
error_t coapClientGetType | ( | const CoapMessage * | message, |
CoapMessageType * | type | ||
) |
Get message type.
- Parameters
-
[in] message Pointer to the CoAP message [out] type Message type
- Returns
- Error code
Definition at line 472 of file coap_client_request.c.
◆ coapClientGetUintOption()
error_t coapClientGetUintOption | ( | const CoapMessage * | message, |
uint16_t | optionNum, | ||
uint_t | optionIndex, | ||
uint32_t * | optionValue | ||
) |
Read an uint option from the CoAP message.
- Parameters
-
[in] message Pointer to the CoAP message [in] optionNum Option number to search for [in] optionIndex Occurrence index (for repeatable options only) [out] optionValue Option value (unsigned integer)
- Returns
- Error code
Definition at line 788 of file coap_client_request.c.
◆ coapClientGetUriPath()
error_t coapClientGetUriPath | ( | const CoapMessage * | message, |
char_t * | path, | ||
size_t | maxLen | ||
) |
Get Uri-Path option.
- Parameters
-
[in] message Pointer to the CoAP message [out] path Pointer to the buffer where to copy the path component [in] maxLen Maximum number of characters the buffer can hold
- Returns
- Error code
Definition at line 563 of file coap_client_request.c.
◆ coapClientGetUriQuery()
error_t coapClientGetUriQuery | ( | const CoapMessage * | message, |
char_t * | queryString, | ||
size_t | maxLen | ||
) |
Get Uri-Query option.
- Parameters
-
[in] message Pointer to the CoAP message [out] queryString Pointer to the buffer where to copy the query string [in] maxLen Maximum number of characters the buffer can hold
- Returns
- Error code
Definition at line 603 of file coap_client_request.c.
◆ coapClientReadPayload()
error_t coapClientReadPayload | ( | CoapMessage * | message, |
void * | data, | ||
size_t | size, | ||
size_t * | length | ||
) |
Read payload data.
- Parameters
-
[in] message Pointer to the CoAP message [out] data Buffer into which received data will be placed [in] size Maximum number of bytes that can be received [out] length Number of bytes that have been received
- Returns
- Error code
Definition at line 893 of file coap_client_request.c.
◆ coapClientSendRequest()
error_t coapClientSendRequest | ( | CoapClientRequest * | request, |
CoapRequestCallback | callback, | ||
void * | param | ||
) |
Send a CoAP request.
- Parameters
-
[in] request CoAP request handle [in] callback Callback function to invoke when the request completes [in] param Callback function parameter
- Returns
- Error code
Definition at line 157 of file coap_client_request.c.
◆ coapClientSetMethodCode()
error_t coapClientSetMethodCode | ( | CoapMessage * | message, |
CoapCode | code | ||
) |
Set request method.
- Parameters
-
[in] message Pointer to the CoAP message [in] code Method code (GET, POST, PUT or DELETE)
- Returns
- Error code
Definition at line 490 of file coap_client_request.c.
◆ coapClientSetOpaqueOption()
error_t coapClientSetOpaqueOption | ( | CoapMessage * | message, |
uint16_t | optionNum, | ||
uint_t | optionIndex, | ||
const uint8_t * | optionValue, | ||
size_t | optionLen | ||
) |
Add an opaque option to the CoAP message.
- Parameters
-
[in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only) [in] optionValue Pointer to the first byte of the option value [in] optionLen Length of the option, in bytes
- Returns
- Error code
Definition at line 668 of file coap_client_request.c.
◆ coapClientSetPayload()
error_t coapClientSetPayload | ( | CoapMessage * | message, |
const void * | payload, | ||
size_t | payloadLen | ||
) |
Set message payload.
- Parameters
-
[in] message Pointer to the CoAP message [out] payload Pointer to request payload [out] payloadLen Length of the payload, in bytes
- Returns
- Error code
Definition at line 828 of file coap_client_request.c.
◆ coapClientSetRequestTimeout()
error_t coapClientSetRequestTimeout | ( | CoapClientRequest * | request, |
systime_t | timeout | ||
) |
Set request timeout.
- Parameters
-
[in] request CoAP request handle [in] timeout Timeout value, in milliseconds
- Returns
- Error code
Definition at line 130 of file coap_client_request.c.
◆ coapClientSetStringOption()
error_t coapClientSetStringOption | ( | CoapMessage * | message, |
uint16_t | optionNum, | ||
uint_t | optionIndex, | ||
const char_t * | optionValue | ||
) |
Add a string option to the CoAP message.
- Parameters
-
[in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only) [in] optionValue NULL-terminated string that contains the option value
- Returns
- Error code
Definition at line 694 of file coap_client_request.c.
◆ coapClientSetType()
error_t coapClientSetType | ( | CoapMessage * | message, |
CoapMessageType | type | ||
) |
Set message type.
- Parameters
-
[in] message Pointer to the CoAP message [in] type Message type (Confirmable or Non-confirmable)
- Returns
- Error code
Definition at line 454 of file coap_client_request.c.
◆ coapClientSetUintOption()
error_t coapClientSetUintOption | ( | CoapMessage * | message, |
uint16_t | optionNum, | ||
uint_t | optionIndex, | ||
uint32_t | optionValue | ||
) |
Add a uint option to the CoAP message.
- Parameters
-
[in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only) [in] optionValue Option value (unsigned integer)
- Returns
- Error code
Definition at line 721 of file coap_client_request.c.
◆ coapClientSetUriPath()
error_t coapClientSetUriPath | ( | CoapMessage * | message, |
const char_t * | path | ||
) |
Set Uri-Path option.
- Parameters
-
[in] message Pointer to the CoAP message [in] path NULL-terminated string that contains the path component
- Returns
- Error code
Definition at line 544 of file coap_client_request.c.
◆ coapClientSetUriQuery()
error_t coapClientSetUriQuery | ( | CoapMessage * | message, |
const char_t * | queryString | ||
) |
Set Uri-Query option.
- Parameters
-
[in] message Pointer to the CoAP message [in] queryString NULL-terminated string that contains the query string
- Returns
- Error code
Definition at line 583 of file coap_client_request.c.
◆ coapClientWritePayload()
error_t coapClientWritePayload | ( | CoapMessage * | message, |
const void * | data, | ||
size_t | length | ||
) |
Write payload data.
- Parameters
-
[in] message Pointer to the CoAP message [in] data Pointer to a buffer containing the data to be written [in] length Number of bytes to written
- Returns
- Error code
Definition at line 872 of file coap_client_request.c.