|
Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
|
CoAP TCP client API. More...
Data Structures | |
| union | coap_client_tcp_event_data |
| Event data for CoAP TCP signaling events. More... | |
| struct | coap_client_tcp_option |
| Representation of extra options for the CoAP TCP client request. More... | |
| struct | coap_client_tcp_request |
| Representation of a CoAP TCP client request. More... | |
Macros | |
| #define | MAX_COAP_TCP_MSG_LEN |
| Maximum size of a CoAP TCP message. | |
Typedefs | |
| typedef void(* | coap_client_tcp_response_cb_t) (const struct coap_client_response_data *data, void *user_data) |
| Callback for CoAP TCP request. | |
| typedef int(* | coap_client_tcp_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 TCP request. | |
| typedef int(* | coap_client_tcp_socket_config_cb_t) (int fd, void *user_data) |
| Callback to configure the socket before connecting. | |
| typedef void(* | coap_client_tcp_event_cb_t) (struct coap_client_tcp *client, enum coap_client_tcp_event event, const union coap_client_tcp_event_data *data, void *user_data) |
| Callback for CoAP TCP signaling events (Release/Abort). | |
Enumerations | |
| enum | coap_client_tcp_event { COAP_CLIENT_TCP_EVENT_CSM_UPDATED , COAP_CLIENT_TCP_EVENT_PONG_RECEIVED , COAP_CLIENT_TCP_EVENT_RELEASE , COAP_CLIENT_TCP_EVENT_ABORT } |
| CoAP TCP client event types for signaling. More... | |
Functions | |
| int | coap_client_tcp_init (struct coap_client_tcp *client, const char *info) |
| Initialize the TCP CoAP client. | |
| int | coap_client_tcp_connect (struct coap_client_tcp *client, const struct net_sockaddr *addr, net_socklen_t addrlen, int proto) |
| Connect the CoAP TCP client to a server. | |
| int | coap_client_tcp_close (struct coap_client_tcp *client) |
| Close the CoAP TCP client connection. | |
| int | coap_client_tcp_req (struct coap_client_tcp *client, struct coap_client_tcp_request *req) |
| Send CoAP request over TCP. | |
| int | coap_client_tcp_csm_req (struct coap_client_tcp *client, uint32_t max_block_size, coap_client_tcp_response_cb_t cb, void *user_data) |
| Send CSM (Capabilities and Settings Message) over TCP. | |
| void | coap_client_tcp_cancel_requests (struct coap_client_tcp *client) |
| Cancel all current TCP requests. | |
| void | coap_client_tcp_cancel_and_reset_all (struct coap_client_tcp *client) |
| Cancel and fully reset all requests when changing socket. | |
| struct coap_client_tcp_option | coap_client_tcp_option_initial_block2 (struct coap_client_tcp *client) |
| Get initial Block2 option for TCP (BERT-aware). | |
| bool | coap_client_tcp_has_ongoing_exchange (struct coap_client_tcp *client) |
| Check if TCP client has ongoing exchange. | |
| int | coap_client_tcp_ping (struct coap_client_tcp *client) |
| Send a Ping signal to the server (RFC 8323). | |
| int | coap_client_tcp_release (struct coap_client_tcp *client, const char *alt_addr, uint32_t hold_off_sec) |
| Send a Release signal to the server (RFC 8323). | |
| void | coap_client_tcp_set_event_cb (struct coap_client_tcp *client, coap_client_tcp_event_cb_t cb, void *user_data) |
| Set callback for signaling events (Release/Abort). | |
CoAP TCP client API.
| #define MAX_COAP_TCP_MSG_LEN |
#include <zephyr/net/coap_client_tcp.h>
Maximum size of a CoAP TCP message.
| typedef void(* coap_client_tcp_event_cb_t) (struct coap_client_tcp *client, enum coap_client_tcp_event event, const union coap_client_tcp_event_data *data, void *user_data) |
#include <zephyr/net/coap_client_tcp.h>
Callback for CoAP TCP signaling events (Release/Abort).
| client | The client instance that received the event. |
| event | The signaling event type. |
| data | Event-specific data (may be NULL for some events). |
| user_data | User provided context. |
| typedef int(* coap_client_tcp_payload_cb_t) (size_t offset, const uint8_t **payload, size_t *len, bool *last_block, void *user_data) |
#include <zephyr/net/coap_client_tcp.h>
Callback for providing a payload for the CoAP TCP request.
| offset | Payload offset from the beginning of a blockwise transfer. |
| payload | A pointer for the buffer containing the payload block. |
| len | Requested (maximum) block size on input. The actual payload length on output. |
| last_block | A pointer to the flag indicating whether more payload blocks are expected. |
| user_data | User provided context. |
| typedef void(* coap_client_tcp_response_cb_t) (const struct coap_client_response_data *data, void *user_data) |
#include <zephyr/net/coap_client_tcp.h>
Callback for CoAP TCP request.
| data | The CoAP response data. |
| user_data | User provided context. |
| typedef int(* coap_client_tcp_socket_config_cb_t) (int fd, void *user_data) |
#include <zephyr/net/coap_client_tcp.h>
Callback to configure the socket before connecting.
Called after socket creation but before connect, allowing the application to set socket options (e.g. TLS credentials).
| fd | The socket file descriptor. |
| user_data | User provided context. |
#include <zephyr/net/coap_client_tcp.h>
CoAP TCP client event types for signaling.
| void coap_client_tcp_cancel_and_reset_all | ( | struct coap_client_tcp * | client | ) |
#include <zephyr/net/coap_client_tcp.h>
Cancel and fully reset all requests when changing socket.
Use when tearing down a transport to ensure clean state for a new socket.
| client | Client instance. |
| void coap_client_tcp_cancel_requests | ( | struct coap_client_tcp * | client | ) |
#include <zephyr/net/coap_client_tcp.h>
Cancel all current TCP requests.
| client | Client instance. |
| int coap_client_tcp_close | ( | struct coap_client_tcp * | client | ) |
#include <zephyr/net/coap_client_tcp.h>
Close the CoAP TCP client connection.
Cancels any ongoing requests and closes the underlying socket. For graceful shutdown, send a Release signal with coap_client_tcp_release before calling this.
| client | Client instance. |
| int coap_client_tcp_connect | ( | struct coap_client_tcp * | client, |
| const struct net_sockaddr * | addr, | ||
| net_socklen_t | addrlen, | ||
| int | proto ) |
#include <zephyr/net/coap_client_tcp.h>
Connect the CoAP TCP client to a server.
Unlike the UDP client, the TCP client manages the socket internally. This function creates a TCP socket, connects to the server, and automatically sends a CSM (Capabilities and Settings Message) to negotiate capabilities per RFC 8323.
| client | Client instance. |
| addr | Destination address of the server. |
| addrlen | Length of the address structure. |
| proto | Protocol to use (IPPROTO_TCP or IPPROTO_TLS_1_2). |
| int coap_client_tcp_csm_req | ( | struct coap_client_tcp * | client, |
| uint32_t | max_block_size, | ||
| coap_client_tcp_response_cb_t | cb, | ||
| void * | user_data ) |
#include <zephyr/net/coap_client_tcp.h>
Send CSM (Capabilities and Settings Message) over TCP.
Per RFC 8323, CSM should be exchanged when a CoAP-over-TCP connection is established. This negotiates capabilities like max message size and BERT.
| client | Client instance (must be connected via coap_client_tcp_connect). |
| max_block_size | Maximum block size to advertise. |
| cb | Response callback (can be NULL since server may not respond). |
| user_data | User data for callback. |
| bool coap_client_tcp_has_ongoing_exchange | ( | struct coap_client_tcp * | client | ) |
#include <zephyr/net/coap_client_tcp.h>
Check if TCP client has ongoing exchange.
| client | Pointer to the CoAP TCP client instance. |
| int coap_client_tcp_init | ( | struct coap_client_tcp * | client, |
| const char * | info ) |
#include <zephyr/net/coap_client_tcp.h>
Initialize the TCP CoAP client.
| [in] | client | Client instance. |
| [in] | info | Name for the receiving thread (NULL for default). |
| struct coap_client_tcp_option coap_client_tcp_option_initial_block2 | ( | struct coap_client_tcp * | client | ) |
#include <zephyr/net/coap_client_tcp.h>
Get initial Block2 option for TCP (BERT-aware).
| client | Client instance. |
| int coap_client_tcp_ping | ( | struct coap_client_tcp * | client | ) |
#include <zephyr/net/coap_client_tcp.h>
Send a Ping signal to the server (RFC 8323).
This sends a Ping signal and waits for Pong response. Can be used for connection keep-alive or RTT measurement.
| client | Client instance (must be connected). |
| int coap_client_tcp_release | ( | struct coap_client_tcp * | client, |
| const char * | alt_addr, | ||
| uint32_t | hold_off_sec ) |
#include <zephyr/net/coap_client_tcp.h>
Send a Release signal to the server (RFC 8323).
This signals graceful connection termination. The server should complete pending requests before closing.
| client | Client instance (must be connected). |
| alt_addr | Alternative address suggestion (NULL if none). |
| hold_off_sec | Hold-off time in seconds (0 if none). |
| int coap_client_tcp_req | ( | struct coap_client_tcp * | client, |
| struct coap_client_tcp_request * | req ) |
#include <zephyr/net/coap_client_tcp.h>
Send CoAP request over TCP.
| client | Client instance (must be connected via coap_client_tcp_connect). |
| req | CoAP request structure. |
| void coap_client_tcp_set_event_cb | ( | struct coap_client_tcp * | client, |
| coap_client_tcp_event_cb_t | cb, | ||
| void * | user_data ) |
#include <zephyr/net/coap_client_tcp.h>
Set callback for signaling events (Release/Abort).
| client | Client instance. |
| cb | Callback function to invoke on events. |
| user_data | User data passed to callback. |