1
0
mirror of https://github.com/obgm/libcoap.git synced 2025-10-14 02:19:34 +08:00

Zephyr: Enable CI builds

Fix a Zephyr unexpected success response for ioctl FIONBIO.
This commit is contained in:
Jon Shallow
2025-07-19 10:53:25 +01:00
committed by Jon Shallow
parent b359512f8d
commit 79a041414c
4 changed files with 44 additions and 12 deletions

View File

@@ -160,7 +160,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
OS: ["contiki", "lwip", "riot"]
OS: ["contiki", "lwip", "riot", "zephyr"]
steps:
- uses: actions/checkout@v4
- name: setup

View File

@@ -1,8 +1,27 @@
ZEPHYR_PROJECT?=~/zephyrproject
ZEPHYR_PROJECT?=zephyrproject
all: coap-client
all: $(ZEPHYR_PROJECT) coap-client
coap-client: client-src/src/main.c client-src/*
${ZEPHYR_PROJECT}:
python3 -m venv ${ZEPHYR_PROJECT}/.venv ;\
ls -l ${ZEPHYR_PROJECT}/.venv/bin/activate ;\
. ${ZEPHYR_PROJECT}/.venv/bin/activate ;\
pip install west ;\
west init ${ZEPHYR_PROJECT} ;\
cd ${ZEPHYR_PROJECT} ;\
west update -n ;\
west zephyr-export ;\
west packages pip --install ;\
cd zephyr ;\
if [ "${GITHUB_WORKSPACE}"a = "a" ] ; then \
west sdk install --install-base=$(ZEPHYR_PROJECT)/../ ;\
else \
west sdk install --install-base=$(ZEPHYR_PROJECT)/../ -t x86_64-zephyr-elf ;\
fi ;\
cd ../../ ;\
deactivate
coap-client: client-src/src/main.c client-src/* ../../src/*.c ../../include/*/*
@LIBCOAP_DIR=`pwd`/../.. ;\
(if [ -f $(ZEPHYR_PROJECT)/.venv/bin/activate ]; then \
. $(ZEPHYR_PROJECT)/.venv/bin/activate ;\

View File

@@ -1,20 +1,28 @@
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 ).
The Zephyr project environment needs to be pre-installed. By default, the
libcoap Makefile assumes that this is located at ~/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 ~/zephyrproject/zephyr/build/zephyr/zephyr.exe
which is then copied to coap-client .
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)
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 get out onto the internet.
so that ./coap-client is able to route traffic out onto the internet and get
responses.

View File

@@ -258,8 +258,13 @@ coap_socket_connect_udp(coap_socket_t *sock,
if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR)
#endif
{
coap_log_warn("coap_socket_connect_udp: ioctl FIONBIO: %s\n",
coap_socket_strerror());
/* Ignore Zephyr unexpected Success response */
if (errno != 0) {
int keep_errno = errno;
coap_log_warn("coap_socket_connect_udp: ioctl FIONBIO: %s (%d)\n",
coap_socket_strerror(), keep_errno);
}
}
switch (connect_addr.addr.sa.sa_family) {