Skip to content

Commit

Permalink
RIOT: library fixes for different build types
Browse files Browse the repository at this point in the history
coap_debug.h: Support logging level set to _COAP_LOG_EMERG
coap_pdu.h: handle small ints
coap_pdu_internal.h: handle small ints
coap_session_internal.h: handle small ints
coap_uthash_internal.h: handle small ints
coap_block.c: Handle small ints
coap_debug.c: Fix use of vsnprintf() and vfprintf()
coap_pdu.c: Handle small ints
coap_tinydtls.c: Handle small ints
coap_uri.c: Fix alignment issue in coap_new_uri()

uncrustify run on RIOT examples to conform to RIOT's coding standards/
  • Loading branch information
mrdeep1 committed Oct 23, 2023
1 parent 05d02be commit 203d228
Show file tree
Hide file tree
Showing 42 changed files with 1,456 additions and 805 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: astyle_py
files: '^.*\.(c|cpp|cxx|h|h.in|h.riot|h.riot.in|h.windows|h.windows.in|h.contiki|hpp|inc)$'
exclude: '^.*/(coap_uthash_internal.h|coap_utlist_internal.h)$|examples/riot/examples_libcoap_.*$'
exclude: '^.*/(coap_uthash_internal.h|coap_utlist_internal.h)$|examples/riot/examples_libcoap_.*$|examples/riot/tests_pkg_libcoap/.*$'
args: ['--style=google',
'--align-pointer=name',
'--align-reference=name',
Expand Down
9 changes: 9 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ EXTRA_DIST = \
examples/riot/pkg_libcoap/Makefile.dep \
examples/riot/pkg_libcoap/Makefile.include \
examples/riot/pkg_libcoap/Makefile.libcoap \
examples/riot/tests_pkg_libcoap/app.config \
examples/riot/tests_pkg_libcoap/Kconfig \
examples/riot/tests_pkg_libcoap/libcoap-test.c \
examples/riot/tests_pkg_libcoap/libcoap-test.h \
examples/riot/tests_pkg_libcoap/main.c \
examples/riot/tests_pkg_libcoap/Makefile \
examples/riot/tests_pkg_libcoap/Makefile.ci \
examples/riot/tests_pkg_libcoap/README.md \
examples/riot/tests_pkg_libcoap/tests/01-run.py \
examples/riot/README \
Makefile.libcoap \
include/coap$(LIBCOAP_API_VERSION)/coap_internal.h \
Expand Down
32 changes: 29 additions & 3 deletions coap_config.h.riot
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,33 @@
#define COAP_CONSTRAINED_STACK 1
#endif

/*
* For systems that define int as being 2 bytes, need to make sure the
* minimum configuration is set up (overridden if explicitely defined).
*/
#include <limits.h>

#if (UINT_MAX <= 65535)
#define COAP_DISABLE_TCP 1
#define COAP_AF_UNIX_SUPPORT 0
#define COAP_OSCORE_SUPPORT 0
#define COAP_WITH_OBSERVE_PERSIST 0
#define COAP_WS_SUPPORT 0
#define COAP_Q_BLOCK_SUPPORT 0
#define COAP_MAX_LOGGING_LEVEL 0
#endif /* UINT_MAX < 65536 */

#ifdef CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
#ifndef COAP_MAX_LOGGING_LEVEL
/* Define to 1 to build without TCP support. */
/* Define 0-8 for max logging levels. */
#define COAP_MAX_LOGGING_LEVEL CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
#endif /* COAP_MAX_LOGGING_LEVEL */
#endif /* CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
#else /* ! CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
#ifndef COAP_MAX_LOGGING_LEVEL
/* Define 0-8 for max logging levels. */
#define COAP_MAX_LOGGING_LEVEL 4
#endif /* COAP_MAX_LOGGING_LEVEL */
#endif /* ! CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */

#ifdef CONFIG_LIBCOAP_IPV4_SUPPORT
#ifndef COAP_IPV4_SUPPORT
Expand Down Expand Up @@ -51,7 +72,12 @@
/* Define to 1 to build without TCP support. */
#define COAP_DISABLE_TCP 0
#endif /* COAP_DISABLE_TCP */
#endif /* CONFIG_LIBCOAP_TCP_SUPPORT */
#else /* ! CONFIG_LIBCOAP_TCP_SUPPORT */
#ifndef COAP_DISABLE_TCP
/* Define to 1 to build without TCP support. */
#define COAP_DISABLE_TCP 1
#endif /* ! COAP_DISABLE_TCP */
#endif /* ! CONFIG_LIBCOAP_TCP_SUPPORT */

#ifdef CONFIG_LIBCOAP_OSCORE_SUPPORT
#ifndef COAP_OSCORE_SUPPORT
Expand Down
32 changes: 29 additions & 3 deletions coap_config.h.riot.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,33 @@
#define COAP_CONSTRAINED_STACK 1
#endif

/*
* For systems that define int as being 2 bytes, need to make sure the
* minimum configuration is set up (overridden if explicitely defined).
*/
#include <limits.h>

#if (UINT_MAX <= 65535)
#define COAP_DISABLE_TCP 1
#define COAP_AF_UNIX_SUPPORT 0
#define COAP_OSCORE_SUPPORT 0
#define COAP_WITH_OBSERVE_PERSIST 0
#define COAP_WS_SUPPORT 0
#define COAP_Q_BLOCK_SUPPORT 0
#define COAP_MAX_LOGGING_LEVEL 0
#endif /* UINT_MAX < 65536 */

#ifdef CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
#ifndef COAP_MAX_LOGGING_LEVEL
/* Define to 1 to build without TCP support. */
/* Define 0-8 for max logging levels. */
#define COAP_MAX_LOGGING_LEVEL CONFIG_LIBCOAP_MAX_LOGGING_LEVEL
#endif /* COAP_MAX_LOGGING_LEVEL */
#endif /* CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
#else /* ! CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */
#ifndef COAP_MAX_LOGGING_LEVEL
/* Define 0-8 for max logging levels. */
#define COAP_MAX_LOGGING_LEVEL 4
#endif /* COAP_MAX_LOGGING_LEVEL */
#endif /* ! CONFIG_LIBCOAP_MAX_LOGGING_LEVEL */

#ifdef CONFIG_LIBCOAP_IPV4_SUPPORT
#ifndef COAP_IPV4_SUPPORT
Expand Down Expand Up @@ -51,7 +72,12 @@
/* Define to 1 to build without TCP support. */
#define COAP_DISABLE_TCP 0
#endif /* COAP_DISABLE_TCP */
#endif /* CONFIG_LIBCOAP_TCP_SUPPORT */
#else /* ! CONFIG_LIBCOAP_TCP_SUPPORT */
#ifndef COAP_DISABLE_TCP
/* Define to 1 to build without TCP support. */
#define COAP_DISABLE_TCP 1
#endif /* ! COAP_DISABLE_TCP */
#endif /* ! CONFIG_LIBCOAP_TCP_SUPPORT */

#ifdef CONFIG_LIBCOAP_OSCORE_SUPPORT
#ifndef COAP_OSCORE_SUPPORT
Expand Down
11 changes: 10 additions & 1 deletion examples/riot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
RIOT=RIOT
TARGET?=native

all: RIOT pkg examples client server
all: RIOT pkg examples client server tests

RIOT:
git clone --depth 1 https://github.com/RIOT-OS/RIOT.git $@
Expand Down Expand Up @@ -38,14 +38,23 @@ examples:
cd examples_libcoap_client && cp -r * ../RIOT/examples/libcoap-client
rm -rf RIOT/examples/libcoap-server && mkdir RIOT/examples/libcoap-server
cd examples_libcoap_server && cp -r * ../RIOT/examples/libcoap-server
rm -rf RIOT/tests/pkg/libcoap && mkdir -p RIOT/tests/pkg/libcoap
cd tests_pkg_libcoap && cp -r * ../RIOT/tests/pkg/libcoap

client: RIOT pkg examples
$(MAKE) -C RIOT/examples/libcoap-client/ RIOT_CI_BUILD=1

server: RIOT pkg examples
$(MAKE) -C RIOT/examples/libcoap-server/ RIOT_CI_BUILD=1

tests: RIOT pkg examples
$(MAKE) -C RIOT/tests/pkg/libcoap/ RIOT_CI_BUILD=1

run_tests:
$(MAKE) -C RIOT/tests/pkg/libcoap/ test

clean:
rm -rf RIOT/pkg/libcoap
rm -rf RIOT/examples/libcoap-client
rm -rf RIOT/examples/libcoap-server
rm -rf RIOT/tests/pkg/libcoap
6 changes: 0 additions & 6 deletions examples/riot/examples_libcoap_client/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ config LIBCOAP_USE_PSK_ID
string "User ID to use for PSK communications"
default "user_abc"
depends on USEMODULE_TINYDTLS
config LIBCOAP_SERVER_SUPPORT
bool "Set to y if server support is required"
default n
config LIBCOAP_CLIENT_SUPPORT
bool "Set to y if client support is required"
default y
endif # USEMODULE_LIBCOAP
21 changes: 21 additions & 0 deletions examples/riot/examples_libcoap_client/Makefile.ci
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
BOARD_INSUFFICIENT_MEMORY := \
airfy-beacon \
arduino-duemilanove \
arduino-leonardo \
arduino-mega2560 \
arduino-nano \
arduino-uno \
atmega256rfr2-xpro \
atmega328p \
atmega328p-xplained-mini \
atmega8 \
atxmega-a3bu-xplained \
b-l072z-lrwan1 \
blackpill-stm32f103c8 \
blackpill-stm32f103cb \
Expand All @@ -9,13 +19,17 @@ BOARD_INSUFFICIENT_MEMORY := \
calliope-mini \
cc2650-launchpad \
cc2650stk \
derfmega128 \
hifive1 \
hifive1b \
i-nucleo-lrwan1 \
im880b \
lsn50 \
maple-mini \
microbit \
microduino-corerf \
msb-430 \
msb-430h \
nrf51dk \
nrf51dongle \
nrf6310 \
Expand All @@ -32,10 +46,13 @@ BOARD_INSUFFICIENT_MEMORY := \
nucleo-l031k6 \
nucleo-l053r8 \
nucleo-l073rz \
olimex-msp430-h1611 \
olimex-msp430-h2618 \
opencm904 \
samd10-xmini \
saml10-xpro \
saml11-xpro \
samr21-xpro \
slstk3400a \
spark-core \
stk3200 \
Expand All @@ -45,5 +62,9 @@ BOARD_INSUFFICIENT_MEMORY := \
stm32g0316-disco \
stm32l0538-disco \
stm32mp157c-dk2 \
telosb \
waspmote-pro \
yunjia-nrf51822 \
z1 \
zigduino \
#
2 changes: 2 additions & 0 deletions examples/riot/examples_libcoap_client/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ CONFIG_LIBCOAP_USE_PSK_ID="user_abc"

CONFIG_KCONFIG_USEPKG_LIBCOAP=y
# Logging levels are defined in pkg/libcoap using Kconfig

CONFIG_KCONFIG_USEPKG_TINYDTLS=y
Loading

0 comments on commit 203d228

Please sign in to comment.