From f4ee10a96aad8670ed2563c2d37ccc351aa3a6cb Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Tue, 18 Jun 2024 20:56:31 -0300 Subject: [PATCH] update to latest (again) --- examples/zephyr/device-dashboard/prj.conf | 2 +- examples/zephyr/device-dashboard/src/main.c | 1 + examples/zephyr/device-dashboard/src/mongoose_config.h | 1 - examples/zephyr/http-client/prj.conf | 5 ++++- examples/zephyr/http-client/src/main.c | 1 + examples/zephyr/http-server/prj.conf | 6 +++++- examples/zephyr/http-server/src/main.c | 6 +++--- examples/zephyr/mqtt-aws-client/prj.conf | 5 ++++- examples/zephyr/mqtt-aws-client/src/main.c | 6 +++--- examples/zephyr/websocket-server/prj.conf | 6 +++++- examples/zephyr/websocket-server/src/main.c | 3 ++- 11 files changed, 29 insertions(+), 13 deletions(-) diff --git a/examples/zephyr/device-dashboard/prj.conf b/examples/zephyr/device-dashboard/prj.conf index 252ae39b..0b93e5da 100644 --- a/examples/zephyr/device-dashboard/prj.conf +++ b/examples/zephyr/device-dashboard/prj.conf @@ -21,4 +21,4 @@ CONFIG_IDLE_STACK_SIZE=1024 CONFIG_MINIMAL_LIBC=y CONFIG_MINIMAL_LIBC_RAND=y -CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=32768 +CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32768 diff --git a/examples/zephyr/device-dashboard/src/main.c b/examples/zephyr/device-dashboard/src/main.c index d90100c4..0f513d58 100644 --- a/examples/zephyr/device-dashboard/src/main.c +++ b/examples/zephyr/device-dashboard/src/main.c @@ -3,6 +3,7 @@ #include "mongoose.h" #include "net.h" +#include // Zephyr: Define a semaphore and network management callback to be able to wait // until our IP address is ready. The main function will start and block on this diff --git a/examples/zephyr/device-dashboard/src/mongoose_config.h b/examples/zephyr/device-dashboard/src/mongoose_config.h index bc04f8a4..a6160a9a 100644 --- a/examples/zephyr/device-dashboard/src/mongoose_config.h +++ b/examples/zephyr/device-dashboard/src/mongoose_config.h @@ -1,4 +1,3 @@ #define MG_ARCH MG_ARCH_ZEPHYR #define MG_ENABLE_PACKED_FS 1 -#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/http-client/prj.conf b/examples/zephyr/http-client/prj.conf index 8dca400f..6df5b4ee 100644 --- a/examples/zephyr/http-client/prj.conf +++ b/examples/zephyr/http-client/prj.conf @@ -20,13 +20,16 @@ CONFIG_IDLE_STACK_SIZE=1024 CONFIG_MBEDTLS=y CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=4096 CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y +CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECP_ALL_ENABLED=y CONFIG_MBEDTLS_TLS_VERSION_1_2=y CONFIG_MINIMAL_LIBC=y CONFIG_MINIMAL_LIBC_RAND=y -CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=131072 +CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072 CONFIG_PRINTK=y CONFIG_MBEDTLS_DEBUG=y diff --git a/examples/zephyr/http-client/src/main.c b/examples/zephyr/http-client/src/main.c index edba9e79..3bf27455 100644 --- a/examples/zephyr/http-client/src/main.c +++ b/examples/zephyr/http-client/src/main.c @@ -3,6 +3,7 @@ #include "certs.h" #include "mongoose.h" +#include static time_t s_boot_timestamp = 0; static struct mg_connection *s_sntp_conn = NULL; diff --git a/examples/zephyr/http-server/prj.conf b/examples/zephyr/http-server/prj.conf index 0dcdaf5a..c8042e8e 100644 --- a/examples/zephyr/http-server/prj.conf +++ b/examples/zephyr/http-server/prj.conf @@ -20,9 +20,13 @@ CONFIG_IDLE_STACK_SIZE=1024 CONFIG_MBEDTLS=y CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048 CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y +CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECP_ALL_ENABLED=y +CONFIG_MBEDTLS_TLS_VERSION_1_2=y CONFIG_MINIMAL_LIBC=y CONFIG_MINIMAL_LIBC_RAND=y -CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=32756 +CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32756 diff --git a/examples/zephyr/http-server/src/main.c b/examples/zephyr/http-server/src/main.c index 8b19e91a..4e562488 100644 --- a/examples/zephyr/http-server/src/main.c +++ b/examples/zephyr/http-server/src/main.c @@ -3,6 +3,7 @@ #include "certs.h" #include "mongoose.h" +#include static const char *s_web_dir = "/"; static const char *s_http_addr = "http://0.0.0.0:8000"; @@ -13,7 +14,7 @@ static struct mg_connection *s_sntp_conn = NULL; // Event handler for the listening HTTP/HTTPS connection. static void wcb(struct mg_connection *c, int ev, void *ev_data) { if (ev == MG_EV_ACCEPT && c->fn_data != NULL) { - struct mg_tls_opts opts = {.cert = s_ssl_cert, .key = s_ssl_key}; + struct mg_tls_opts opts = {.cert = (char *) s_ssl_cert, .key = (char *) s_ssl_key}; mg_tls_init(c, &opts); } else if (ev == MG_EV_HTTP_MSG) { struct mg_http_message *hm = ev_data; @@ -85,9 +86,8 @@ int main(int argc, char *argv[]) { struct mg_mgr mgr; - mg_log_set(MG_LL_DEBUG); - mg_mgr_init(&mgr); + mg_log_set(MG_LL_DEBUG); mg_http_listen(&mgr, s_http_addr, wcb, NULL); mg_http_listen(&mgr, s_https_addr, wcb, &mgr); diff --git a/examples/zephyr/mqtt-aws-client/prj.conf b/examples/zephyr/mqtt-aws-client/prj.conf index b5b364e8..974bd1a8 100644 --- a/examples/zephyr/mqtt-aws-client/prj.conf +++ b/examples/zephyr/mqtt-aws-client/prj.conf @@ -20,13 +20,16 @@ CONFIG_IDLE_STACK_SIZE=1024 CONFIG_MBEDTLS=y CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192 CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y +CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECP_ALL_ENABLED=y CONFIG_MBEDTLS_TLS_VERSION_1_2=y CONFIG_MINIMAL_LIBC=y CONFIG_MINIMAL_LIBC_RAND=y -CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=131072 +CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072 CONFIG_PRINTK=y CONFIG_MBEDTLS_DEBUG=y diff --git a/examples/zephyr/mqtt-aws-client/src/main.c b/examples/zephyr/mqtt-aws-client/src/main.c index 3296cc11..c69151c8 100644 --- a/examples/zephyr/mqtt-aws-client/src/main.c +++ b/examples/zephyr/mqtt-aws-client/src/main.c @@ -3,13 +3,13 @@ #include "certs.h" #include "mongoose.h" +#include struct mg_mgr mgr; static time_t s_boot_timestamp = 0; static struct mg_connection *s_sntp_conn = NULL; -static const char *s_url = - "mqtts://a3nkain3cvvy7l-ats.iot.us-east-1.amazonaws.com"; +static const char *s_url = "mqtts://a3nkain3cvvy7l-ats.iot.us-east-1.amazonaws.com"; static const char *s_rx_topic = "d/rx"; static const char *s_tx_topic = "d/tx"; @@ -24,7 +24,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { MG_ERROR(("%p %s", c->fd, (char *) ev_data)); } else if (ev == MG_EV_CONNECT) { // Set up 2-way TLS that is required by AWS IoT - struct mg_tls_opts opts = {.ca = s_ca, .cert = s_cert, .key = s_key}; + struct mg_tls_opts opts = {.ca = (char *) s_ca, .cert = (char *) s_cert, .key = (char *) s_key}; mg_tls_init(c, &opts); } else if (ev == MG_EV_MQTT_OPEN) { // MQTT connect is successful diff --git a/examples/zephyr/websocket-server/prj.conf b/examples/zephyr/websocket-server/prj.conf index 0dcdaf5a..c8042e8e 100644 --- a/examples/zephyr/websocket-server/prj.conf +++ b/examples/zephyr/websocket-server/prj.conf @@ -20,9 +20,13 @@ CONFIG_IDLE_STACK_SIZE=1024 CONFIG_MBEDTLS=y CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048 CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y +CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECP_ALL_ENABLED=y +CONFIG_MBEDTLS_TLS_VERSION_1_2=y CONFIG_MINIMAL_LIBC=y CONFIG_MINIMAL_LIBC_RAND=y -CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=32756 +CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32756 diff --git a/examples/zephyr/websocket-server/src/main.c b/examples/zephyr/websocket-server/src/main.c index a1c7642d..2c91742c 100644 --- a/examples/zephyr/websocket-server/src/main.c +++ b/examples/zephyr/websocket-server/src/main.c @@ -3,6 +3,7 @@ #include "certs.h" #include "mongoose.h" +#include static const char *s_web_dir = "/"; static const char *s_ws_addr = "ws://0.0.0.0:8000"; @@ -17,7 +18,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { if (ev == MG_EV_OPEN) { c->is_hexdumping = 1; } else if (ev == MG_EV_ACCEPT && c->fn_data != NULL) { - struct mg_tls_opts opts = {.cert = s_ssl_cert, .key = s_ssl_key}; + struct mg_tls_opts opts = {.cert = (char *) s_ssl_cert, .key = (char *) s_ssl_key}; mg_tls_init(c, &opts); } else if (ev == MG_EV_HTTP_MSG) { struct mg_http_message *hm = (struct mg_http_message *) ev_data;