Files
libcoap/examples/zephyr
Marco Casaroli a90916a4fe zephyr: mbedlts improvements
Add some improvements to make secure coap work on Zephyr 4.3.0
with mbedtls (not using Zephyr TLS protocol options).

We now set the build options to zephyr, so we make use of the
internal mbedtl in zephyr, so we do not require a specific header
file anymore.

In older versions of Zephyr, where mbedtls does not expose the
configuration, we can force-set the macro in the C flags, so that
mbedtls will have our required function.

This way, we do not need to change the mbedtls included in Zephyr,
while still supporting a few older versions.
2026-01-30 16:18:34 +00:00
..
2026-01-30 16:18:34 +00:00
2025-08-21 12:17:41 +01:00
2025-08-21 12:17:41 +01:00
2026-01-30 16:18:34 +00:00
2025-07-19 12:17:38 +01:00

Example of libcoap running in Zephyr
====================================
If the Zephyr project environment is already installed outside of the libcoap
environment, then ZEPHYR_PROJECT need to be set to where it is already installed
(i.e export ZEPHYR_PROJECT=~/zephyrproject ).

If ZEPHYR_PROJECT is not set, then this defaults in this Makefile to the directory
zephyrproject under the examples/zephyr directory.

To build the coap-client example, do

    $ make

The executable gets built in ${ZEPHYR_PROJECT}/zephyr/build/zephyr/zephyr.exe
which is then copied to coap-client in the examples/zephyr directory.

./coap-client does a 'GET coaps://libcoap-net' using PSK with logging enabled.

For using the native_sim board using Linux, you may need to do something like
the following (ens32 is the external interface name, your environment may
be different)

    $ sudo ${ZEPHYR_PROJECT}/tools/net-tools/net-setup.sh start
    $ sudo iptables -t nat -A POSTROUTING -o ens32 -j MASQUERADE
    $ sudo sysctl -w net.ipv4.conf.all.forwarding=1

so that ./coap-client is able to route traffic out onto the internet and get
responses.