/* * Copyright (C) 2017 Kaspar Schleiser * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @ingroup sys_net_nanocoap * * @{ * * @file * @brief nanocoap high-level API * * @author Kaspar Schleiser */ #ifndef NET_NANOCOAP_SOCK_H #define NET_NANOCOAP_SOCK_H #include #include #include "net/sock/udp.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Start a nanocoap server instance * * This function only returns if there's an error binding to @p local, or if * receiving of UDP packets fails. * * @param[in] local local UDP endpoint to bind to * @param[in] buf input buffer to use * @param[in] bufsize size of @p buf * * @returns -1 on error */ int nanocoap_server(sock_udp_ep_t *local, uint8_t *buf, size_t bufsize); /** * @brief Simple synchronous CoAP get * * @param[in] remote remote UDP endpoint * @param[in] path remote path * @param[out] buf buffer to write response to * @param[in] len length of @p buffer * * @returns length of response on success * @returns <0 on error */ ssize_t nanocoap_get(sock_udp_ep_t *remote, const char *path, uint8_t *buf, size_t len); #ifdef __cplusplus } #endif #endif /* NET_NANOCOAP_SOCK_H */ /** @} */