nanocoap_sock.h File Reference

nanocoap high-level API More...

Detailed Description

nanocoap high-level API

Kaspar Schleiser

Definition in file nanocoap_sock.h.

#include <stdint.h>
#include <unistd.h>
#include "net/sock/udp.h"
+ Include dependency graph for nanocoap_sock.h:

Go to the source code of this file.

int nanocoap_server (sock_udp_ep_t *local, uint8_t *buf, size_t bufsize)
 Start a nanocoap server instance. More...
ssize_t nanocoap_get (sock_udp_ep_t *remote, const char *path, uint8_t *buf, size_t len)
 Simple synchronous CoAP (confirmable) get. More...
ssize_t nanocoap_request (coap_pkt_t *pkt, sock_udp_ep_t *local, sock_udp_ep_t *remote, size_t len)
 Simple synchronous CoAP request. More...

Function Documentation

◆ nanocoap_get()

ssize_t nanocoap_get ( sock_udp_ep_t remote,
const char *  path,
uint8_t *  buf,
size_t  len 

Simple synchronous CoAP (confirmable) get.

[in]remoteremote UDP endpoint
[in]pathremote path
[out]bufbuffer to write response to
[in]lenlength of buffer
length of response payload on success
<0 on error

◆ nanocoap_request()

ssize_t nanocoap_request ( coap_pkt_t pkt,
sock_udp_ep_t local,
sock_udp_ep_t remote,
size_t  len 

Simple synchronous CoAP request.

[in,out]pktPacket struct containing the request. Is reused for the response
[in]localLocal UDP endpoint, may be NULL
[in]remoteremote UDP endpoint
[in]lenTotal length of the buffer associated with the request
length of response on success
<0 on error

◆ nanocoap_server()

int nanocoap_server ( sock_udp_ep_t local,
uint8_t *  buf,
size_t  bufsize 

Start a nanocoap server instance.

This function only returns if there's an error binding to local, or if receiving of UDP packets fails.

[in]locallocal UDP endpoint to bind to
[in]bufinput buffer to use
[in]bufsizesize of buf
-1 on error