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 "net/sock/udp.h"
+ Include dependency graph for nanocoap_sock.h:

Go to the source code of this file.

Functions

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

Parameters
[in]remoteremote UDP endpoint
[in]pathremote path
[out]bufbuffer to write response to
[in]lenlength of buffer
Returns
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.

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