Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/libcoap: Add in libcoap CoAP library support #19889

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/libcoap-client/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.
#
menu "libcoap-client"
depends on USEPKG_LIBCOAP

config LIBCOAP_CLIENT_URI
string "CoAP URI to connect to"
default "coap://[fe80::405:5aff:fe15:9b7f]/.well-known/core"
config LIBCOAP_USE_PSK
string "Secret to use for PSK communications"
default "secretPSK"
depends on USEMODULE_TINYDTLS
config LIBCOAP_USE_PSK_ID
string "User ID to use for PSK communications"
default "user_abc"
depends on USEMODULE_TINYDTLS

endmenu # libcoap-client
69 changes: 69 additions & 0 deletions examples/libcoap-client/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# name of your application
APPLICATION = libcoap-client

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

# Include packages that pull up and auto-init the link layer.
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
USEMODULE += netdev_default
USEMODULE += auto_init_gnrc_netif

# Activate ICMPv6 error messages
USEMODULE += gnrc_icmpv6_error

# Specify the mandatory networking module for a IPv6 routing node
USEMODULE += gnrc_ipv6_router_default

# Add a routing protocol
USEMODULE += gnrc_rpl
USEMODULE += auto_init_gnrc_rpl

# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo

# Specify the mandatory networking modules for IPv6 and UDP
USEMODULE += gnrc_ipv6_default
USEMODULE += memarray
USEMODULE += ipv4_addr

# a cryptographically secure implementation of PRNG is needed for tinydtls
# Uncomment the following 3 lines for tinydtls support
CFLAGS += -DWITH_RIOT_SOCK
USEPKG += tinydtls
USEMODULE += prng_sha1prng

# libcoap support
USEPKG += libcoap
# Uncomment to enable libcoap OSCORE support
# USEMODULE += libcoap_oscore

# Configure if DNS is required
# USEMODULE += sock_dns

# Support 64 bit ticks
USEMODULE += ztimer64_xtimer_compat

# Add also the shell, some shell commands
USEMODULE += shell
USEMODULE += shell_cmds_default
USEMODULE += ps
USEMODULE += netstats_l2
USEMODULE += netstats_ipv6
USEMODULE += netstats_rpl

# libcoap needs some space
CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(3*THREAD_STACKSIZE_DEFAULT\)

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 1

# Change this to 0 show compiler invocation lines by default:
# QUIET ?= 1

include $(RIOTBASE)/Makefile.include
70 changes: 70 additions & 0 deletions examples/libcoap-client/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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 \
bluepill-stm32f030c8 \
bluepill-stm32f103c8 \
bluepill-stm32f103cb \
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 \
nucleo-f030r8 \
nucleo-f031k6 \
nucleo-f042k6 \
nucleo-f070rb \
nucleo-f072rb \
nucleo-f103rb \
nucleo-f302r8 \
nucleo-f303k8 \
nucleo-f334r8 \
nucleo-l011k4 \
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 \
stm32f030f4-demo \
stm32f0discovery \
stm32f7508-dk \
stm32g0316-disco \
stm32l0538-disco \
stm32mp157c-dk2 \
telosb \
waspmote-pro \
yunjia-nrf51822 \
z1 \
zigduino \
#
24 changes: 24 additions & 0 deletions examples/libcoap-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# libcoap client example

This example shows how to configure a client to use libcoap

## Fast configuration (Between RIOT instances):

Preparing the logical interfaces:

sudo ./../../dist/tools/tapsetup/tapsetup --create 2

## Client invocation
For the client:

PORT=tap0 make term
coapc coap://[ip6-address]/some/path

The IP address to connect to needs to be that as returned by libcoap_server,
or that of the tap0 interface, etc.

## Handling the static memory allocation

libcoap for RIOT is using the `sys/memarray` module and therefore there
are certain limits. Said resources are defined in `libcoap/src/coap_mem.c`,
but can be overwritten at compile time.
8 changes: 8 additions & 0 deletions examples/libcoap-client/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CONFIG_LIBCOAP_CLIENT_SUPPORT=y

CONFIG_LIBCOAP_CLIENT_URI="coap://[fe80::405:5aff:fe15:9b7f]/.well-known/core"

CONFIG_LIBCOAP_USE_PSK="secretPSK"
CONFIG_LIBCOAP_USE_PSK_ID="user_abc"

# Logging levels are defined in pkg/libcoap using Kconfig
Loading
Loading