mirror of
https://github.com/obgm/libcoap.git
synced 2026-12-05 20:02:19 +03:00
RIOT: Add help documentation
General documentation tidy up.
This commit is contained in:
1 parent
db7b7e8207
commit
48559f0016
18 files changed
+120
-77
No files matched your search
@@ -1,7 +1,6 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2023-2026 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
menu "libcoap_client"
|
||||
depends on USEPKG_LIBCOAP
|
||||
|
||||
|
||||
@@ -3,11 +3,19 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* client_coap.c -- RIOT client example
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief libcoap Client Example Implementation
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*
|
||||
* @author Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <thread.h>
|
||||
@@ -127,11 +135,23 @@ void client_coap_init(int argc, char **argv)
|
||||
char portbuf[8];
|
||||
unsigned int wait_ms = 0;
|
||||
int result = -1;
|
||||
#define BUFSIZE 100
|
||||
unsigned char buf[BUFSIZE];
|
||||
unsigned char buf[100];
|
||||
int res;
|
||||
const char *coap_uri = COAP_CLIENT_URI;
|
||||
|
||||
if (argc > 1 && (strcmp(argv[1], "--help") == 0 ||
|
||||
strcmp(argv[1], "help")) == 0) {
|
||||
printf("usage: %s [<coap uri>]\n", argv[0]);
|
||||
printf(" <coap_uri> is optional which is of the form\n"
|
||||
" <scheme><host>[:<port>][<path>][?<query>\n"
|
||||
" <scheme> is one of coap:// or coaps://\n"
|
||||
" <host> is in [ipv6] or [ipv6%%interface] format\n"
|
||||
" <port> is optional, default is 5683 (coap) or 5684 (coaps)\n"
|
||||
" <path> is optional\n"
|
||||
" <query> is optional\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (argc > 1) {
|
||||
coap_uri = argv[1];
|
||||
}
|
||||
@@ -148,6 +168,8 @@ void client_coap_init(int argc, char **argv)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
coap_log_info("Sending request '%s'\n", coap_uri);
|
||||
|
||||
snprintf(portbuf, sizeof(portbuf), "%d", uri.port);
|
||||
snprintf((char *)buf, sizeof(buf), "%*.*s", (int)uri.host.length,
|
||||
(int)uri.host.length, (const char *)uri.host.s);
|
||||
|
||||
@@ -3,15 +3,23 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* client-coap.h -- RIOT client example
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief libcoap Client Example Implementation
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*
|
||||
* @author Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* @file
|
||||
* @brief Example application for libcoap client
|
||||
*
|
||||
* @author Raul Fuentes <>
|
||||
* @author Raul Fuentes <> <raul.fuentes-samaniego@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
@@ -28,10 +28,7 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
|
||||
extern int client_coap_init(int argc, char **argv);
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "coapc", "Start a libcoap client", client_coap_init },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
SHELL_COMMAND(coapc, "Start a libcoap client", client_coap_init);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -44,7 +41,7 @@ int main(void)
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2023-2026 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
menu "libcoap_server"
|
||||
depends on USEPKG_LIBCOAP
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* @file
|
||||
* @brief Example application for libcoap server
|
||||
*
|
||||
* @author Raul Fuentes <>
|
||||
* @author Raul Fuentes <> <raul.fuentes-samaniego@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
@@ -28,10 +28,7 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
|
||||
extern int server_coap_init(int argc, char **argv);
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "coaps", "Start a libcoap server", server_coap_init },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
SHELL_COMMAND(coaps, "Start a libcoap server", server_coap_init);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -44,7 +41,7 @@ int main(void)
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
|
||||
@@ -3,11 +3,19 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* server_coap.c -- RIOT example
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief libcoap Server Example Implementation
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*
|
||||
* @author Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "coap_config.h"
|
||||
@@ -270,7 +278,8 @@ static void stop_server(void)
|
||||
|
||||
void server_coap_init(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
if (argc < 2 || strcmp(argv[1], "--help") == 0 ||
|
||||
strcmp(argv[1], "help") == 0) {
|
||||
printf("usage: %s start|stop\n", argv[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,15 +3,23 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* server_coap.h -- RIOT client example
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief libcoap Server Example Implementation
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*
|
||||
* @author Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019 HAW Hamburg
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
menu "libcoap"
|
||||
depends on USEPKG_LIBCOAP
|
||||
|
||||
@@ -239,7 +238,7 @@ config LIBCOAP_MAX_LG_XMITS
|
||||
|
||||
config LIBCOAP_MAX_STRING_SIZE
|
||||
int "Max size of string memory allocation"
|
||||
default 64
|
||||
default 120
|
||||
help
|
||||
The maximum size of a supported string.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
PKG_NAME=libcoap
|
||||
PKG_URL=https://github.com/obgm/libcoap
|
||||
# develop branch as of 20th April 2026
|
||||
PKG_VERSION=86b778167a554bd4add3b9282893df1fc22c2366
|
||||
# develop branch as of 19th May 2026
|
||||
PKG_VERSION=db7b7e82079dda6819f023ffe7e62ea4ace69fb4
|
||||
PKG_LICENSE=BSD-2-Clause
|
||||
|
||||
LIBCOAP_BUILD_DIR=$(BINDIR)/pkg/$(PKG_NAME)
|
||||
@@ -10,12 +10,14 @@ LIBCOAP_INCLUDE_DIR=$(RIOTBASE)/build/pkg/$(PKG_NAME)/include/coap3
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
||||
LIBCOAP_MODULES = libcoap
|
||||
|
||||
ifneq (,$(filter libcoap_oscore,$(USEMODULE)))
|
||||
all: libcoap libcoap_oscore
|
||||
else
|
||||
all: libcoap
|
||||
LIBCOAP_MODULES += libcoap_oscore
|
||||
endif
|
||||
|
||||
all: $(LIBCOAP_MODULES)
|
||||
|
||||
libcoap:
|
||||
$(QQ)@cp $(LIBCOAP_SOURCE_DIR)/coap_config.h.riot $(LIBCOAP_SOURCE_DIR)/coap_config.h
|
||||
$(QQ)"$(MAKE)" -C $(LIBCOAP_SOURCE_DIR)/src -f $(CURDIR)/Makefile.libcoap
|
||||
|
||||
@@ -5,7 +5,3 @@ USEMODULE += sock_async_event
|
||||
ifneq (,$(filter libcoap,$(USEPKG)))
|
||||
USEMODULE += libcoap
|
||||
endif
|
||||
|
||||
ifneq (,$(filter libcoap_oscore,$(USEPKG)))
|
||||
USEMODULE += libcoap_oscore
|
||||
endif
|
||||
@@ -1,7 +1,6 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2023-2026 Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
menu "tests_libcoap"
|
||||
depends on USEPKG_LIBCOAP
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
This test is to check that the libcoap client and server logic talk to
|
||||
each other.
|
||||
|
||||
THe client request generates a CoAP request, which is sent to the server
|
||||
The client request generates a CoAP request, which is sent to the server
|
||||
who responds back to the client.
|
||||
@@ -3,11 +3,19 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* libcoap-test.c -- RIOT example
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief libcoap Test
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*
|
||||
* @author Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "coap_config.h"
|
||||
@@ -28,9 +36,9 @@
|
||||
# define COAP_USE_PSK_ID NULL
|
||||
#endif /* CONFIG_LIBCOAP_USE_PSK_ID */
|
||||
|
||||
static int quit;
|
||||
static volatile int quit;
|
||||
|
||||
#define INDEX "This is a DTLS loopback test client/server made with libcoap\n"
|
||||
#define INDEX "This is DTLS loopback test client/server made with libcoap's response\n"
|
||||
|
||||
static void hnd_get_index(coap_resource_t *resource, coap_session_t *session,
|
||||
const coap_pdu_t *request, const coap_string_t *query,
|
||||
@@ -175,8 +183,7 @@ static int coap_client_init(coap_context_t *ctx)
|
||||
char portbuf[8];
|
||||
coap_optlist_t *optlist = NULL;
|
||||
|
||||
#define BUFSIZE 100
|
||||
unsigned char buf[BUFSIZE];
|
||||
unsigned char buf[100];
|
||||
int res;
|
||||
const char *coap_uri = "coaps://[::1]";
|
||||
|
||||
|
||||
@@ -3,16 +3,23 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* libcoap-test.h -- RIOT client example
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief libcoap Test
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*
|
||||
* @author Jon Shallow <supjps-libcoap@jpshallow.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Example test application for libcoap
|
||||
* @brief Test for libcoap
|
||||
*
|
||||
* @author Raul Fuentes <>
|
||||
* @author Raul Fuentes <raul.fuentes-samaniego@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg
|
||||
#
|
||||
# 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.
|
||||
# SPDX-FileCopyrightText: 2020 Otto-von-Guericke-Universität Magdeburg
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
import sys
|
||||
from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact("This is a DTLS loopback test client/server made with libcoap\r\n")
|
||||
child.expect_exact("This is DTLS loopback test client/server made with libcoap's response\r\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+8
-11
@@ -46,7 +46,7 @@ static int fail_counts[COAP_MEM_TAG_LAST];
|
||||
* memory blocks.
|
||||
*/
|
||||
#ifndef COAP_MAX_STRING_SIZE
|
||||
#define COAP_MAX_STRING_SIZE (64U)
|
||||
#define COAP_MAX_STRING_SIZE (120U)
|
||||
#endif /* COAP_MAX_STRING_SIZE */
|
||||
|
||||
/**
|
||||
@@ -220,29 +220,26 @@ static int fail_counts[COAP_MEM_TAG_LAST];
|
||||
#endif /* ! COAP_SERVER_SUPPORT */
|
||||
#endif /* COAP_MAX_LG_XMITS */
|
||||
|
||||
/* The memstr is the storage for holding coap_string_t structure
|
||||
* together with its contents. */
|
||||
union memstr_t {
|
||||
coap_string_t s;
|
||||
char buf[sizeof(coap_string_t) + COAP_MAX_STRING_SIZE];
|
||||
/* The memstr is the storage for holding coap_string_t contents. */
|
||||
struct memstr_t {
|
||||
char buf[COAP_MAX_STRING_SIZE];
|
||||
};
|
||||
|
||||
/* The attrstr is the storage for holding coap_string_t structures to
|
||||
* serve as attribute names or values. As these are typically short,
|
||||
* they are stored in a different arena than generic strings. */
|
||||
union attrstr_t {
|
||||
coap_string_t s;
|
||||
char buf[sizeof(coap_string_t) + COAP_MAX_ATTRIBUTE_SIZE];
|
||||
struct attrstr_t {
|
||||
char buf[COAP_MAX_ATTRIBUTE_SIZE];
|
||||
};
|
||||
|
||||
static union memstr_t string_storage_data[COAP_MAX_STRINGS];
|
||||
static struct memstr_t string_storage_data[COAP_MAX_STRINGS];
|
||||
static memarray_t string_storage;
|
||||
|
||||
#if COAP_SERVER_SUPPORT
|
||||
static coap_endpoint_t endpoint_storage_data[COAP_MAX_ENDPOINTS];
|
||||
static memarray_t endpoint_storage;
|
||||
|
||||
static union attrstr_t attr_storage_data[COAP_MAX_ATTRIBUTE_STRINGS];
|
||||
static struct attrstr_t attr_storage_data[COAP_MAX_ATTRIBUTE_STRINGS];
|
||||
static memarray_t attr_storage;
|
||||
|
||||
static coap_attr_t resattr_storage_data[COAP_MAX_ATTRIBUTES];
|
||||
|
||||
Reference in new issue
Block a user