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"
Include dependency graph for nanocoap_sock.h:
This graph shows which files directly or indirectly include this file: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 | coap_observe_client_t |
| Observe Client 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. More... | |
| #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. More... | |
| #define | CONFIG_NANOCOAP_SOCK_EVENT_PRIO EVENT_PRIO_MEDIUM |
| Event priority for nanoCoAP sock events (e.g. More... | |
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. More... | |
| bool | nanocoap_server_is_remote_in_response_ctx (const nanocoap_server_response_ctx_t *ctx, const coap_request_ctx_t *req) |
| Check if a given separate response context was prepared for the remote endpoint of a given request. More... | |
| int | nanocoap_server_send_separate (const nanocoap_server_response_ctx_t *ctx, unsigned code, unsigned type, const void *payload, size_t len) |
| Build and send a separate response to a CoAP request. More... | |
| ssize_t | nanocoap_server_build_separate (const nanocoap_server_response_ctx_t *ctx, void *buf, size_t buf_len, unsigned code, unsigned type, uint16_t msg_id) |
| Build a separate response header to a CoAP request. More... | |
| int | nanocoap_server_sendv_separate (const nanocoap_server_response_ctx_t *ctx, const iolist_t *reply) |
| Send an already build separate response. More... | |
| int | nanocoap_register_observer (const coap_request_ctx_t *req_ctx, coap_pkt_t *req_pkt) |
| Register an observer. More... | |
| void | nanocoap_unregister_observer (const coap_request_ctx_t *req_ctx, const coap_pkt_t *req_pkt) |
| Unregister an observer. More... | |
| void | nanocoap_unregister_observer_due_to_reset (const sock_udp_ep_t *ep, uint16_t msg_id) |
| Unregister a stale observation due to a reset message received. More... | |
| void | nanocoap_notify_observers (const coap_resource_t *res, const iolist_t *iol) |
| Notify all currently registered observers of the given resource. More... | |
| void | nanocoap_notify_observers_simple (const coap_resource_t *res, uint32_t obs, const void *payload, size_t payload_len) |
| Build and send notification to observers registered to a specific resource. More... | |
| 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. More... | |
| int | nanocoap_server (sock_udp_ep_t *local, void *buf, size_t bufsize) |
| Start a nanoCoAP server instance. More... | |
| kernel_pid_t | nanocoap_server_start (const sock_udp_ep_t *local) |
| Create and start the nanoCoAP server thread. More... | |
| 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. More... | |
| 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. More... | |
| int | nanocoap_sock_url_connect (const char *url, nanocoap_sock_t *sock) |
| Create a CoAP client socket by URL. More... | |
| static void | nanocoap_sock_close (nanocoap_sock_t *sock) |
| Close a CoAP client socket. More... | |
| ssize_t | nanocoap_sock_observe_url (const char *url, coap_observe_client_t *ctx, coap_request_cb_t cb, void *arg) |
| Observe a CoAP resource behind a URL (via GET) More... | |
| ssize_t | nanocoap_sock_unobserve_url (const char *url, coap_observe_client_t *ctx) |
| Stop observing a CoAP resource. More... | |
| ssize_t | nanocoap_sock_get (nanocoap_sock_t *sock, const char *path, void *response, size_t len_max) |
| Simple synchronous CoAP (confirmable) GET. More... | |
| ssize_t | nanocoap_sock_get_non (nanocoap_sock_t *sock, const char *path, void *response, size_t len_max) |
| Simple non-confirmable GET. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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) More... | |
| 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) More... | |
| 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) More... | |
| ssize_t | nanocoap_sock_delete (nanocoap_sock_t *sock, const char *path) |
| Simple synchronous CoAP (confirmable) DELETE. More... | |
| ssize_t | nanocoap_sock_delete_url (const char *url) |
| Simple synchronous CoAP (confirmable) DELETE for URL. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| ssize_t | nanocoap_sock_request (nanocoap_sock_t *sock, coap_pkt_t *pkt, size_t len) |
| Simple synchronous CoAP request. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |