From 7c0d126edc2e6120fee606378bad27aed7f81916 Mon Sep 17 00:00:00 2001 From: cpq Date: Wed, 19 May 2021 08:10:38 +0100 Subject: [PATCH] Build with -DMG_ENABLE_FS=1 --- examples/stm32-freertos-tcp/Makefile | 2 +- examples/stm32-freertos-tcp/main.c | 10 ++++++---- mongoose.h | 4 ++++ src/arch_freertos_tcp.h | 4 ++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/stm32-freertos-tcp/Makefile b/examples/stm32-freertos-tcp/Makefile index 47dc14f0..8486b2a5 100644 --- a/examples/stm32-freertos-tcp/Makefile +++ b/examples/stm32-freertos-tcp/Makefile @@ -6,7 +6,7 @@ DOCKER ?= docker run -it --rm -v $(PROJECT_ROOT_PATH):$(PROJECT_ROOT_PATH) -w $( FREERTOS_KERNEL_PATH ?= $(PROJECT_ROOT_PATH)/test/freertos-kernel FREERTOS_PLUS_TCP_PATH ?= $(PROJECT_ROOT_PATH)/test/freertos-tcp -MONGOOSE_FLAGS = -DMG_ARCH=MG_ARCH_FREERTOS_TCP -DMG_ENABLE_FS=0 +MONGOOSE_FLAGS = -DMG_ARCH=MG_ARCH_FREERTOS_TCP -DMG_ENABLE_FS=1 MCU_FLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=softfp -mfpu=vfpv4 #-mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard diff --git a/examples/stm32-freertos-tcp/main.c b/examples/stm32-freertos-tcp/main.c index 5d5dba63..b17e1cf6 100644 --- a/examples/stm32-freertos-tcp/main.c +++ b/examples/stm32-freertos-tcp/main.c @@ -10,7 +10,12 @@ static const char *s_listening_address = "http://0.0.0.0:80"; // Event handler for the listening connection. static void cb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { if (ev == MG_EV_HTTP_MSG) { +#if MG_ENABLE_FS + struct mg_http_serve_opts opts = {.root_dir = "/"}; + mg_http_serve_dir(c, ev_data, &opts); +#else mg_http_reply(c, 200, "", "hello, %s!\n", "world"); +#endif } (void) fn_data; (void) ev_data; @@ -33,7 +38,6 @@ static void blinker(void *args) { gpio_toggle(pin); vTaskDelay(pdMS_TO_TICKS(ms)); LOG(LL_INFO, ("blink %s, RAM: %u", (char *) args, xPortGetFreeHeapSize())); - // printf("blink %s, RAM: %u\n", (char *) args, xPortGetFreeHeapSize()); } } @@ -88,8 +92,6 @@ uint32_t SystemCoreClock = 216000000; uint32_t HAL_RCC_GetHCLKFreq(void) { return SystemCoreClock; } -// void assert_failed(void) { -//} uint32_t HAL_GetTick(void) { return configTICK_RATE_HZ; @@ -138,4 +140,4 @@ int vLoggingPrintf(const char *fmt, ...) { void *_sbrk(ptrdiff_t incr) { (void) incr; return NULL; -} \ No newline at end of file +} diff --git a/mongoose.h b/mongoose.h index 9d56f03f..9cede6ea 100644 --- a/mongoose.h +++ b/mongoose.h @@ -132,6 +132,10 @@ #include #include +#if MG_ENABLE_FS +#include +#endif + #include #include #include diff --git a/src/arch_freertos_tcp.h b/src/arch_freertos_tcp.h index c6ab15e0..fd76e111 100644 --- a/src/arch_freertos_tcp.h +++ b/src/arch_freertos_tcp.h @@ -13,6 +13,10 @@ #include #include +#if MG_ENABLE_FS +#include +#endif + #include #include #include