From fa6dce369aac99ddfa4131c9446cfa0d408f5d85 Mon Sep 17 00:00:00 2001 From: Jim Whitelaw Date: Mon, 11 Mar 2024 00:31:29 -0600 Subject: [PATCH] Adds configuration option to not build/include the webserver. --- src/main.cpp | 4 +++- src/mesh/http/ContentHandler.cpp | 2 ++ src/mesh/http/WebServer.cpp | 6 +++--- src/mesh/wifi/WiFiAPClient.cpp | 13 ++++++++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ef1cd53c36..b10cddef4a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,9 @@ // #include #ifdef ARCH_ESP32 +#if !MESHTASTIC_EXCLUDE_WEBSERVER #include "mesh/http/WebServer.h" +#endif #include "nimble/NimbleBluetooth.h" NimbleBluetooth *nimbleBluetooth; #endif @@ -859,7 +861,7 @@ void setup() #endif #endif -#ifdef ARCH_ESP32 +#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WEBSERVER // Start web server thread. webServerThread = new WebServerThread(); #endif diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 7640e879c9..1557948d8b 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -1,3 +1,4 @@ +#if !MESHTASTIC_EXCLUDE_WEBSERVER #include "NodeDB.h" #include "PowerFSM.h" #include "RadioLibInterface.h" @@ -855,3 +856,4 @@ void handleScanNetworks(HTTPRequest *req, HTTPResponse *res) res->print(value->Stringify().c_str()); delete value; } +#endif \ No newline at end of file diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 7814f2c296..83fe20dd85 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -1,3 +1,4 @@ +#if !MESHTASTIC_EXCLUDE_WEBSERVER #include "mesh/http/WebServer.h" #include "NodeDB.h" #include "graphics/Screen.h" @@ -92,7 +93,6 @@ static void taskCreateCert(void *parameter) LOG_DEBUG("Retrieved Private Key: %d Bytes\n", cert->getPKLength()); LOG_DEBUG("Retrieved Certificate: %d Bytes\n", cert->getCertLength()); - } else { LOG_INFO("Creating the certificate. This may take a while. Please wait...\n"); @@ -105,7 +105,6 @@ static void taskCreateCert(void *parameter) if (createCertResult != 0) { LOG_ERROR("Creating the certificate failed\n"); - } else { LOG_INFO("Creating the certificate was successful\n"); @@ -210,4 +209,5 @@ void initWebServer() } else { LOG_ERROR("Web Servers Failed! ;-( \n"); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index b0b033ba0b..0bfa9f08f8 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -4,13 +4,17 @@ #include "concurrency/Periodic.h" #include "configuration.h" #include "main.h" +#if !MESHTASTIC_EXCLUDE_WEBSERVER #include "mesh/api/WiFiServerAPI.h" +#endif #include "mqtt/MQTT.h" #include "target_specific.h" #include #include #ifdef ARCH_ESP32 +#if !MESHTASTIC_EXCLUDE_WEBSERVER #include "mesh/http/WebServer.h" +#endif #include #include static void WiFiEvent(WiFiEvent_t event); @@ -92,11 +96,13 @@ static void onNetworkConnected() syslog.enable(); } +#if !MESHTASTIC_EXCLUDE_WEBSERVER + #ifdef ARCH_ESP32 initWebServer(); #endif initApiServer(); - +#endif APStartupComplete = true; } @@ -146,7 +152,6 @@ static int32_t reconnectWiFi() perhapsSetRTC(RTCQualityNTP, &tv); lastrun_ntp = millis(); - } else { LOG_DEBUG("NTP Update failed\n"); } @@ -204,7 +209,9 @@ bool initWifi() const char *wifiPsw = config.network.wifi_psk; #ifndef ARCH_RP2040 - createSSLCert(); // For WebServer +#if !MESHTASTIC_EXCLUDE_WEBSERVER + createSSLCert(); // For WebServer +#endif esp_wifi_set_storage(WIFI_STORAGE_RAM); // Disable flash storage for WiFi credentials #endif if (!*wifiPsw) // Treat empty password as no password