Loading...
Searching...
No Matches
nanocoap_sock.h File Reference

nanocoap high-level API More...

Detailed Description

nanocoap high-level API

Author
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e

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...
 

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.
 

Enumerations

enum  nanocoap_socket_type_t { COAP_SOCKET_TYPE_UDP , COAP_SOCKET_TYPE_DTLS }
 NanoCoAP socket types. More...
 

Functions

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_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_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_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.