diff --git a/examples/esp32/device-dashboard/main/mongoose_config.h b/examples/esp32/device-dashboard/main/mongoose_config.h new file mode 100644 index 00000000..910630d4 --- /dev/null +++ b/examples/esp32/device-dashboard/main/mongoose_config.h @@ -0,0 +1 @@ +#define MG_ARCH MG_ARCH_ESP32 diff --git a/examples/esp32/micropython/mongoose/mongoose_config.h b/examples/esp32/micropython/mongoose/mongoose_config.h index d5b597a6..910630d4 100644 --- a/examples/esp32/micropython/mongoose/mongoose_config.h +++ b/examples/esp32/micropython/mongoose/mongoose_config.h @@ -1,2 +1 @@ -// For some reason, IDF detection at build time does not work here #define MG_ARCH MG_ARCH_ESP32 diff --git a/examples/esp32/uart-bridge/main/mongoose_config.h b/examples/esp32/uart-bridge/main/mongoose_config.h new file mode 100644 index 00000000..910630d4 --- /dev/null +++ b/examples/esp32/uart-bridge/main/mongoose_config.h @@ -0,0 +1 @@ +#define MG_ARCH MG_ARCH_ESP32 diff --git a/examples/esp8266/http-client-server/src/main/component.mk b/examples/esp8266/http-client-server/src/main/component.mk index 511c3470..cc264afa 100644 --- a/examples/esp8266/http-client-server/src/main/component.mk +++ b/examples/esp8266/http-client-server/src/main/component.mk @@ -7,4 +7,3 @@ # please read the ESP-IDF documents if you need to do this. # -COMPONENT_INCLUDES += ../../../../../.. diff --git a/examples/esp8266/http-client-server/src/main/mongoose.h b/examples/esp8266/http-client-server/src/main/mongoose.h new file mode 120000 index 00000000..4cd6a2b4 --- /dev/null +++ b/examples/esp8266/http-client-server/src/main/mongoose.h @@ -0,0 +1 @@ +../../../../../mongoose.h \ No newline at end of file diff --git a/examples/esp8266/http-client-server/src/main/mongoose_config.h b/examples/esp8266/http-client-server/src/main/mongoose_config.h new file mode 100644 index 00000000..e659bf60 --- /dev/null +++ b/examples/esp8266/http-client-server/src/main/mongoose_config.h @@ -0,0 +1,2 @@ +#define MG_ARCH MG_ARCH_ESP8266 + diff --git a/examples/rp2040/pico-rmii/CMakeLists.txt b/examples/rp2040/pico-rmii/CMakeLists.txt index b45c77fd..05df7302 100644 --- a/examples/rp2040/pico-rmii/CMakeLists.txt +++ b/examples/rp2040/pico-rmii/CMakeLists.txt @@ -17,8 +17,3 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 1) # Route stdio pico_enable_stdio_uart(firmware 0) # to USB - -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_TCPIP_DRIVER_INIT=0) -add_definitions(-DMG_ENABLE_PACKED_FS=1) diff --git a/examples/rp2040/pico-rmii/mongoose_config.h b/examples/rp2040/pico-rmii/mongoose_config.h new file mode 100644 index 00000000..25ac94af --- /dev/null +++ b/examples/rp2040/pico-rmii/mongoose_config.h @@ -0,0 +1,5 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_PACKED_FS 1 diff --git a/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt b/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt index 8a7c0b67..d2cdb555 100644 --- a/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt +++ b/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt @@ -23,12 +23,7 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio pico_enable_stdio_uart(firmware 1) # to the UART -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_PACKED_FS=1) -add_definitions(-DMG_ENABLE_TCPIP_DRIVER_INIT=0) -add_definitions(-DMG_ENABLE_POSIX_FS=0) -add_definitions(-DDISABLE_ROUTING=1) +# Mongoose build flags in mongoose_config.h # Example build options add_definitions(-DHTTP_URL="http://0.0.0.0/") diff --git a/examples/rp2040/pico-rndis-dashboard/mongoose_config.h b/examples/rp2040/pico-rndis-dashboard/mongoose_config.h new file mode 100644 index 00000000..85fdf388 --- /dev/null +++ b/examples/rp2040/pico-rndis-dashboard/mongoose_config.h @@ -0,0 +1,6 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_PACKED_FS 1 +#define MG_ENABLE_POSIX_FS 0 diff --git a/examples/rp2040/pico-rndis-device/CMakeLists.txt b/examples/rp2040/pico-rndis-device/CMakeLists.txt index 88631158..b3fc0ebf 100644 --- a/examples/rp2040/pico-rndis-device/CMakeLists.txt +++ b/examples/rp2040/pico-rndis-device/CMakeLists.txt @@ -21,9 +21,6 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio pico_enable_stdio_uart(firmware 1) # to the UART -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_TCPIP_DRIVER_INIT=0) -add_definitions(-DMG_ENABLE_POSIX_FS=0) +# Mongoose build flags in mongoose_config.h # Example build options diff --git a/examples/rp2040/pico-rndis-device/mongoose_config.h b/examples/rp2040/pico-rndis-device/mongoose_config.h new file mode 100644 index 00000000..85fdf388 --- /dev/null +++ b/examples/rp2040/pico-rndis-device/mongoose_config.h @@ -0,0 +1,6 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_PACKED_FS 1 +#define MG_ENABLE_POSIX_FS 0 diff --git a/examples/rp2040/pico-w5500/CMakeLists.txt b/examples/rp2040/pico-w5500/CMakeLists.txt index ea693c8b..d2fe3a50 100644 --- a/examples/rp2040/pico-w5500/CMakeLists.txt +++ b/examples/rp2040/pico-w5500/CMakeLists.txt @@ -12,12 +12,7 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio pico_enable_stdio_uart(firmware 1) # to the UART, for remote testing -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_DRIVER_W5500=1) -add_definitions(-DMG_ENABLE_PACKED_FS=1) -add_definitions(-DMG_ENABLE_CUSTOM_RANDOM=1) -add_definitions(-DMG_ENABLE_POSIX_FS=0) +# Mongoose build flags in mongoose_config.h # Example build options add_definitions(-DHTTP_URL="http://0.0.0.0/") diff --git a/examples/rp2040/pico-w5500/mongoose_config.h b/examples/rp2040/pico-w5500/mongoose_config.h new file mode 100644 index 00000000..122f2857 --- /dev/null +++ b/examples/rp2040/pico-w5500/mongoose_config.h @@ -0,0 +1,8 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_DRIVER_W5500 1 +#define MG_ENABLE_CUSTOM_RANDOM 1 +#define MG_ENABLE_PACKED_FS 1 +#define MG_ENABLE_POSIX_FS 0 diff --git a/examples/zephyr/device-dashboard/CMakeLists.txt b/examples/zephyr/device-dashboard/CMakeLists.txt index 6027c10c..883369e9 100644 --- a/examples/zephyr/device-dashboard/CMakeLists.txt +++ b/examples/zephyr/device-dashboard/CMakeLists.txt @@ -6,5 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(device_dashboard) -add_definitions(-DMG_ENABLE_PACKED_FS=1) target_sources(app PRIVATE src/main.c src/mongoose.c src/net.c src/packed_fs.c) diff --git a/examples/zephyr/device-dashboard/src/mongoose_config.h b/examples/zephyr/device-dashboard/src/mongoose_config.h new file mode 100644 index 00000000..bc04f8a4 --- /dev/null +++ b/examples/zephyr/device-dashboard/src/mongoose_config.h @@ -0,0 +1,4 @@ +#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/CMakeLists.txt b/examples/zephyr/http-client/CMakeLists.txt index 75174f0e..797ed4e8 100644 --- a/examples/zephyr/http-client/CMakeLists.txt +++ b/examples/zephyr/http-client/CMakeLists.txt @@ -6,6 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(http_client) -#add_definitions(-DMG_ENABLE_LINES=1) -add_definitions(-DMG_TLS=MG_TLS_MBED -DMG_MBEDTLS_DEBUG_LEVEL=4) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/http-client/src/mongoose_config.h b/examples/zephyr/http-client/src/mongoose_config.h new file mode 100644 index 00000000..bc04f8a4 --- /dev/null +++ b/examples/zephyr/http-client/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/http-server/CMakeLists.txt b/examples/zephyr/http-server/CMakeLists.txt index 312d514a..595d6c96 100644 --- a/examples/zephyr/http-server/CMakeLists.txt +++ b/examples/zephyr/http-server/CMakeLists.txt @@ -6,5 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(http_server) -add_definitions(-DMG_TLS=MG_TLS_MBED) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/http-server/src/mongoose_config.h b/examples/zephyr/http-server/src/mongoose_config.h new file mode 100644 index 00000000..bc04f8a4 --- /dev/null +++ b/examples/zephyr/http-server/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/mqtt-aws-client/CMakeLists.txt b/examples/zephyr/mqtt-aws-client/CMakeLists.txt index f9cf91ae..1bf83b5f 100644 --- a/examples/zephyr/mqtt-aws-client/CMakeLists.txt +++ b/examples/zephyr/mqtt-aws-client/CMakeLists.txt @@ -6,6 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(mqtt_aws_client) -#add_definitions(-DMG_ENABLE_LINES=1) -add_definitions(-DMG_TLS=MG_TLS_MBED -DMG_MBEDTLS_DEBUG_LEVEL=4) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/mqtt-aws-client/src/mongoose_config.h b/examples/zephyr/mqtt-aws-client/src/mongoose_config.h new file mode 100644 index 00000000..bc04f8a4 --- /dev/null +++ b/examples/zephyr/mqtt-aws-client/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/websocket-server/CMakeLists.txt b/examples/zephyr/websocket-server/CMakeLists.txt index 317f8bb5..1d14a963 100644 --- a/examples/zephyr/websocket-server/CMakeLists.txt +++ b/examples/zephyr/websocket-server/CMakeLists.txt @@ -6,6 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(websocket_server) -#add_definitions(-DMG_ENABLE_LINES=1) -add_definitions(-DMG_TLS=MG_TLS_MBED) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/websocket-server/src/mongoose_config.h b/examples/zephyr/websocket-server/src/mongoose_config.h new file mode 100644 index 00000000..bc04f8a4 --- /dev/null +++ b/examples/zephyr/websocket-server/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/mongoose.h b/mongoose.h index 1cbfb414..2011b764 100644 --- a/mongoose.h +++ b/mongoose.h @@ -48,21 +48,6 @@ extern "C" { #define MG_ARCH MG_ARCH_UNIX #elif defined(_WIN32) #define MG_ARCH MG_ARCH_WIN32 -#elif defined(ICACHE_FLASH) || defined(ICACHE_RAM_ATTR) -#define MG_ARCH MG_ARCH_ESP8266 -#elif defined(__ZEPHYR__) -#define MG_ARCH MG_ARCH_ZEPHYR -#elif defined(ESP_PLATFORM) -#define MG_ARCH MG_ARCH_ESP32 -#elif defined(FREERTOS_IP_H) -#define MG_ARCH MG_ARCH_FREERTOS -#define MG_ENABLE_FREERTOS_TCP 1 -#elif defined(AZURE_RTOS_THREADX) -#define MG_ARCH MG_ARCH_AZURERTOS -#elif defined(PICO_TARGET_NAME) -#define MG_ARCH MG_ARCH_RP2040 -#elif defined(__RTTHREAD__) -#define MG_ARCH MG_ARCH_RTTHREAD #endif #endif // !defined(MG_ARCH) @@ -71,7 +56,7 @@ extern "C" { #endif #if !defined(MG_ARCH) -#error "MG_ARCH is not specified and we couldn't guess it. Set -D MG_ARCH=..." +#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in your compiler" #endif // http://esr.ibiblio.org/?p=5095 diff --git a/src/arch.h b/src/arch.h index ac028290..f01ca6bb 100644 --- a/src/arch.h +++ b/src/arch.h @@ -21,21 +21,6 @@ #define MG_ARCH MG_ARCH_UNIX #elif defined(_WIN32) #define MG_ARCH MG_ARCH_WIN32 -#elif defined(ICACHE_FLASH) || defined(ICACHE_RAM_ATTR) -#define MG_ARCH MG_ARCH_ESP8266 -#elif defined(__ZEPHYR__) -#define MG_ARCH MG_ARCH_ZEPHYR -#elif defined(ESP_PLATFORM) -#define MG_ARCH MG_ARCH_ESP32 -#elif defined(FREERTOS_IP_H) -#define MG_ARCH MG_ARCH_FREERTOS -#define MG_ENABLE_FREERTOS_TCP 1 -#elif defined(AZURE_RTOS_THREADX) -#define MG_ARCH MG_ARCH_AZURERTOS -#elif defined(PICO_TARGET_NAME) -#define MG_ARCH MG_ARCH_RP2040 -#elif defined(__RTTHREAD__) -#define MG_ARCH MG_ARCH_RTTHREAD #endif #endif // !defined(MG_ARCH) @@ -44,7 +29,7 @@ #endif #if !defined(MG_ARCH) -#error "MG_ARCH is not specified and we couldn't guess it. Set -D MG_ARCH=..." +#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in your compiler" #endif // http://esr.ibiblio.org/?p=5095