nanocoap_sock.h

nanocoap high-level API

int nanocoap_server(sock/udp.h::sock_udp_ep_t * local, uint8_t * buf, msp430_types.h::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

local:local UDP endpoint to bind to
buf:input buffer to use
bufsize:size of buf

Return values

  • -1 on error
msp430_types.h::ssize_t nanocoap_get(sock/udp.h::sock_udp_ep_t * remote, const char * path, uint8_t * buf, msp430_types.h::size_t len)

Simple synchronous CoAP (confirmable) get.

Parameters

remote:remote UDP endpoint
path:remote path
buf:buffer to write response to
len:length of buffer

Return values

  • length of response payload on success
  • <0 on error
msp430_types.h::ssize_t nanocoap_request(coap_pkt_t * pkt, sock/udp.h::sock_udp_ep_t * local, sock/udp.h::sock_udp_ep_t * remote, msp430_types.h::size_t len)

Simple synchronous CoAP request.

Parameters

pkt:Packet struct containing the request. Is reused for the response
local:Local UDP endpoint, may be NULL
remote:remote UDP endpoint
len:Total length of the buffer associated with the request

Return values

  • length of response on success
  • <0 on error