nanocoap high-level API More...
nanocoap high-level API
Definition in file nanocoap_sock.h.
#include <stdint.h>
#include <unistd.h>
#include "random.h"
#include "net/nanocoap.h"
#include "net/sock/udp.h"
#include "net/sock/util.h"
Go to the source code of this file.
Data Structures | |
struct | nanocoap_sock_t |
NanoCoAP socket struct. More... | |
struct | coap_block_request_t |
Blockwise request helper struct. More... | |
struct | nanocoap_server_response_ctx_t |
Context from CoAP request for separate response. More... | |
Macros | |
#define | CONFIG_NANOCOAP_SOCK_DTLS_TAG (0xc0ab) |
Credman tag used for NanoCoAP Tag together with the credential type (PSK) needs to be unique. | |
#define | CONFIG_NANOCOAP_SERVER_BUF_SIZE |
CoAP server work buf size Used both for RX and TX, needs to hold payload block + header. | |
#define | CONFIG_NANOCOAP_SERVER_STACK_SIZE THREAD_STACKSIZE_DEFAULT |
CoAP server thread stack size. | |
#define | CONFIG_NANOCOAP_SOCK_BLOCK_TOKEN (0) |
Include a random token with block-wise transfers. | |
Enumerations | |
enum | nanocoap_socket_type_t { COAP_SOCKET_TYPE_UDP , COAP_SOCKET_TYPE_DTLS } |
NanoCoAP socket types. More... | |
Functions | |
int | nanocoap_server_prepare_separate (nanocoap_server_response_ctx_t *ctx, coap_pkt_t *pkt, const coap_request_ctx_t *req) |
Prepare the context for a separate response. | |
int | nanocoap_server_send_separate (const nanocoap_server_response_ctx_t *ctx, unsigned code, unsigned type, const void *payload, size_t len) |
Send a separate response to a CoAP request. | |
static uint16_t | nanocoap_sock_next_msg_id (nanocoap_sock_t *sock) |
Get next consecutive message ID for use when building a new CoAP request. | |
int | nanocoap_server (sock_udp_ep_t *local, uint8_t *buf, size_t bufsize) |
Start a nanocoap server instance. | |
kernel_pid_t | nanocoap_server_start (const sock_udp_ep_t *local) |
Create and start the nanoCoAP server thread. | |
static int | nanocoap_sock_connect (nanocoap_sock_t *sock, const sock_udp_ep_t *local, const sock_udp_ep_t *remote) |
Create a CoAP client socket. | |
int | nanocoap_sock_dtls_connect (nanocoap_sock_t *sock, sock_udp_ep_t *local, const sock_udp_ep_t *remote, credman_tag_t tag) |
Create a DTLS secured CoAP client socket. | |
int | nanocoap_sock_url_connect (const char *url, nanocoap_sock_t *sock) |
Create a CoAP client socket by URL. | |
static void | nanocoap_sock_close (nanocoap_sock_t *sock) |
Close a CoAP client socket. | |
ssize_t | nanocoap_sock_get (nanocoap_sock_t *sock, const char *path, void *buf, size_t len) |
Simple synchronous CoAP (confirmable) GET. | |
ssize_t | nanocoap_sock_get_non (nanocoap_sock_t *sock, const char *path, void *response, size_t len_max) |
Simple non-confirmable GET. | |
ssize_t | nanocoap_sock_put (nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max) |
Simple synchronous CoAP (confirmable) PUT. | |
ssize_t | nanocoap_sock_put_non (nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max) |
Simple non-confirmable PUT. | |
ssize_t | nanocoap_sock_put_url (const char *url, const void *request, size_t len, void *response, size_t len_max) |
Simple synchronous CoAP (confirmable) PUT to URL. | |
ssize_t | nanocoap_sock_post (nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max) |
Simple synchronous CoAP (confirmable) POST. | |
ssize_t | nanocoap_sock_post_non (nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max) |
Simple non-confirmable POST. | |
ssize_t | nanocoap_sock_post_url (const char *url, const void *request, size_t len, void *response, size_t len_max) |
Simple synchronous CoAP (confirmable) POST to URL. | |
ssize_t | nanocoap_sock_fetch (nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max) |
Simple synchronous CoAP (confirmable) FETCH (RFC 8132) | |
ssize_t | nanocoap_sock_fetch_non (nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max) |
Simple non-confirmable FETCH (RFC 8132) | |
ssize_t | nanocoap_sock_fetch_url (const char *url, const void *request, size_t len, void *response, size_t len_max) |
Simple synchronous CoAP (confirmable) FETCH to URL (RFC 8132) | |
ssize_t | nanocoap_sock_delete (nanocoap_sock_t *sock, const char *path) |
Simple synchronous CoAP (confirmable) DELETE. | |
ssize_t | nanocoap_sock_delete_url (const char *url) |
Simple synchronous CoAP (confirmable) DELETE for URL. | |
int | nanocoap_sock_get_blockwise (nanocoap_sock_t *sock, const char *path, coap_blksize_t blksize, coap_blockwise_cb_t callback, void *arg) |
Performs a blockwise coap get request on a socket. | |
int | nanocoap_sock_get_slice (nanocoap_sock_t *sock, const char *path, coap_blksize_t blksize, size_t offset, void *dst, size_t len) |
Performs a blockwise coap get request to the specified url, store the response in a buffer. | |
int | nanocoap_get_blockwise_url (const char *url, coap_blksize_t blksize, coap_blockwise_cb_t callback, void *arg) |
Performs a blockwise coap get request to the specified url. | |
ssize_t | nanocoap_get_blockwise_url_to_buf (const char *url, coap_blksize_t blksize, void *buf, size_t len) |
Performs a blockwise coap get request to the specified url, store the response in a buffer. | |
ssize_t | nanocoap_get_blockwise_to_buf (nanocoap_sock_t *sock, const char *path, coap_blksize_t blksize, void *buf, size_t len) |
Performs a blockwise CoAP GET request, store the response in a buffer. | |
ssize_t | nanocoap_sock_request (nanocoap_sock_t *sock, coap_pkt_t *pkt, size_t len) |
Simple synchronous CoAP request. | |
ssize_t | nanocoap_sock_request_cb (nanocoap_sock_t *sock, coap_pkt_t *pkt, coap_request_cb_t cb, void *arg) |
Simple synchronous CoAP request with callback. | |
ssize_t | nanocoap_request (coap_pkt_t *pkt, const sock_udp_ep_t *local, const sock_udp_ep_t *remote, size_t len) |
Simple synchronous CoAP request. | |
static int | nanocoap_block_request_connect_url (coap_block_request_t *ctx, nanocoap_sock_t *sock, const char *url, coap_method_t method, coap_blksize_t blksize) |
Initialize block request context by URL and connect a socket. | |
int | nanocoap_sock_block_request (coap_block_request_t *ctx, const void *data, size_t len, bool more, coap_request_cb_t cb, void *arg) |
Do a block-wise request, send a single block. | |