12#ifndef ZEPHYR_INCLUDE_NET_COAP_CLIENT_H_
13#define ZEPHYR_INCLUDE_NET_COAP_CLIENT_H_
32#define MAX_COAP_MSG_LEN (CONFIG_COAP_CLIENT_MESSAGE_HEADER_SIZE + \
33 CONFIG_COAP_CLIENT_MESSAGE_SIZE)
35#define MAX_COAP_CLIENT_OPTION_LEN (12)
56#if defined(CONFIG_COAP_CLIENT_MULTICAST) || defined(__DOXYGEN__)
128#if defined(CONFIG_COAP_EXTENDED_OPTIONS_LEN)
142#define MAX_PATH_SIZE (CONFIG_COAP_CLIENT_MAX_PATH_LENGTH + 1)
143#define MAX_EXTRA_OPTIONS CONFIG_COAP_CLIENT_MAX_EXTRA_OPTIONS
162#if defined(CONFIG_COAP_CLIENT_MULTICAST) || defined(__DOXYGEN__)
177struct coap_client_internal_request {
178 struct net_sockaddr_storage addr;
181 uint8_t request_token[COAP_TOKEN_MAX_LEN];
185 bool request_ongoing;
192 uint8_t request_tag[COAP_TOKEN_MAX_LEN];
197 int last_response_id;
198#if defined(CONFIG_COAP_CLIENT_MULTICAST)
213 struct coap_client_internal_request requests[CONFIG_COAP_CLIENT_MAX_REQUESTS];
long atomic_t
Definition atomic_types.h:15
CoAP implementation for Zephyr.
void(* coap_client_response_cb_t)(const struct coap_client_response_data *data, void *user_data)
Callback for CoAP request.
Definition coap_client.h:88
int(* coap_client_payload_cb_t)(size_t offset, const uint8_t **payload, size_t *len, bool *last_block, void *user_data)
Callback for providing a payload for the CoAP request.
Definition coap_client.h:118
void coap_client_cancel_requests(struct coap_client *client)
Cancel all current requests.
struct coap_client_option coap_client_option_initial_block2(void)
Initialise a Block2 option to be added to a request.
#define MAX_COAP_MSG_LEN
Maximum size of a CoAP message.
Definition coap_client.h:32
void coap_client_cancel_request(struct coap_client *client, struct coap_client_request *req)
Cancel matching requests.
#define MAX_COAP_CLIENT_OPTION_LEN
Maximum length in bytes for options specified in coap_client_option.
Definition coap_client.h:35
bool coap_client_has_ongoing_exchange(struct coap_client *client)
Check if client has ongoing exchange.
int coap_client_req(struct coap_client *client, int sock, const struct net_sockaddr *addr, struct coap_client_request *req, struct coap_transmission_parameters *params)
Send CoAP request.
int coap_client_init(struct coap_client *client, const char *info)
Initialize the CoAP client.
coap_method
Available request methods.
Definition coap.h:81
coap_content_format
Set of Content-Format option values for CoAP.
Definition coap.h:242
uint32_t net_socklen_t
Length of a socket address.
Definition net_ip.h:172
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT16_TYPE__ int16_t
Definition stdint.h:73
Represents the current state of a block-wise transaction.
Definition coap.h:829
Representation of extra options for the CoAP client request.
Definition coap_client.h:125
uint16_t code
Option code.
Definition coap_client.h:127
uint8_t value[(12)]
Buffer for the length.
Definition coap_client.h:137
uint8_t len
Option len.
Definition coap_client.h:135
Representation of a CoAP client request.
Definition coap_client.h:149
uint8_t num_options
Number of extra options.
Definition coap_client.h:160
size_t len
Length of the payload.
Definition coap_client.h:155
coap_client_payload_cb_t payload_cb
Optional payload callback.
Definition coap_client.h:156
enum coap_method method
Method of the request.
Definition coap_client.h:150
struct coap_client_option options[MAX_EXTRA_OPTIONS]
Extra options to be added to request.
Definition coap_client.h:158
bool confirmable
CoAP Confirmable/Non-confirmable message.
Definition coap_client.h:151
char path[MAX_PATH_SIZE]
Path of the requested resource.
Definition coap_client.h:152
uint32_t multicast_timeout_ms
Multicast response timeout in milliseconds.
Definition coap_client.h:172
const uint8_t * payload
User allocated buffer for send request.
Definition coap_client.h:154
void * user_data
User provided context.
Definition coap_client.h:161
enum coap_content_format fmt
Content format to be used.
Definition coap_client.h:153
coap_client_response_cb_t cb
Callback when response received.
Definition coap_client.h:157
Representation for CoAP client response data.
Definition coap_client.h:40
const uint8_t * payload
Buffer containing the payload from the response.
Definition coap_client.h:51
int16_t result_code
Result code of the response.
Definition coap_client.h:45
const struct coap_packet * packet
A pointer to the response CoAP packet.
Definition coap_client.h:47
net_socklen_t source_len
Source address length of the response.
Definition coap_client.h:67
bool last_block
Indicates the last block of the response.
Definition coap_client.h:55
size_t payload_len
Size of the payload.
Definition coap_client.h:53
const struct net_sockaddr * source
Source address of the response.
Definition coap_client.h:61
size_t offset
Payload offset from the beginning of a blockwise transfer.
Definition coap_client.h:49
Representation of a CoAP client.
Definition coap_client.h:208
Representation of a CoAP option.
Definition coap.h:361
Representation of a CoAP Packet.
Definition coap.h:342
Represents a request awaiting for an acknowledgment (ACK).
Definition coap.h:406
CoAP transmission parameters.
Definition coap.h:387
Kernel mutex structure.
Definition kernel.h:3437
Kernel timepoint type.
Definition clock.h:291
Generic sockaddr struct.
Definition net_ip.h:449