From d97ad88c4269521ac772e4a58db66f79270433c5 Mon Sep 17 00:00:00 2001 From: Eric Blankenhorn Date: Fri, 26 Jul 2024 15:51:09 -0500 Subject: [PATCH] Fix Zephyr port build issues --- examples/mqttport.h | 17 +++++++++++++++++ zephyr/README.md | 6 ++++-- zephyr/samples/client/user_settings.h | 7 +++++++ zephyr/samples/client_tls/user_settings.h | 7 +++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/examples/mqttport.h b/examples/mqttport.h index 8d4d48a69..488e8356e 100644 --- a/examples/mqttport.h +++ b/examples/mqttport.h @@ -141,10 +141,27 @@ extern "C" { #define SOCKET_INVALID (-1) + typedef zsock_fd_set fd_set; + #define FD_ZERO ZSOCK_FD_ZERO + #define FD_SET ZSOCK_FD_SET + #define FD_ISSET ZSOCK_FD_ISSET + #define select zsock_select + #ifdef WOLFSSL_ZEPHYR /* wolfSSL takes care of most defines */ #include #else + #define addrinfo zsock_addrinfo + #define getaddrinfo zsock_getaddrinfo + #define freeaddrinfo zsock_freeaddrinfo + #define socket zsock_socket + #define close zsock_close + #define SOCK_CONNECT zsock_connect + #define getsockopt zsock_getsockopt + #define setsockopt zsock_setsockopt + #define send zsock_send + #define recv zsock_recv + #define MSG_PEEK ZSOCK_MSG_PEEK #ifndef NO_FILESYSTEM #define XFOPEN z_fs_open #define XFCLOSE z_fs_close diff --git a/zephyr/README.md b/zephyr/README.md index d1e121167..87b21532a 100644 --- a/zephyr/README.md +++ b/zephyr/README.md @@ -58,11 +58,11 @@ Follow the [instructions](https://docs.zephyrproject.org/latest/connectivity/net sudo ./loop-slip-tap.sh ``` -Run the following commands in parallel in this order in the `zephyrproject` directory to setup a MQTT broker and subscriber. +Run the following commands in parallel in this order in the `zephyrproject` directory to setup a MQTT broker and subscriber (on port 11883 as defined in the mosquitto config). ```bash cd modules/lib/wolfmqtt && mosquitto -c scripts/broker_test/mosquitto.conf -mosquitto_sub -t sensors +mosquitto_sub -p 11883 -t sensors ``` ### Build and Run client Test Application @@ -76,6 +76,8 @@ west build -t run ``` ### Build and Run client TLS Test Application +Prerequisite: +Add wolfSSL Zephyr module: https://github.com/wolfSSL/wolfssl/blob/master/zephyr/README.md build and execute `client TLS` diff --git a/zephyr/samples/client/user_settings.h b/zephyr/samples/client/user_settings.h index 3e7768c2e..d4e74e9c3 100644 --- a/zephyr/samples/client/user_settings.h +++ b/zephyr/samples/client/user_settings.h @@ -5,6 +5,13 @@ extern "C" { #endif +#include + +/* If a custom user_settings file is provided use it instead */ +#ifdef WOLFMQTT_SETTINGS_FILE +#include WOLFMQTT_SETTINGS_FILE +#endif + #undef NO_FILESYSTEM #define NO_FILESYSTEM diff --git a/zephyr/samples/client_tls/user_settings.h b/zephyr/samples/client_tls/user_settings.h index c0a567390..42cac5545 100644 --- a/zephyr/samples/client_tls/user_settings.h +++ b/zephyr/samples/client_tls/user_settings.h @@ -5,8 +5,11 @@ extern "C" { #endif -#ifdef CONFIG_WOLFSSL_SETTINGS_FILE -#include CONFIG_WOLFSSL_SETTINGS_FILE +#include + +/* If a custom user_settings file is provided use it instead */ +#ifdef WOLFMQTT_SETTINGS_FILE +#include WOLFMQTT_SETTINGS_FILE #endif #undef NO_FILESYSTEM