Skip to content

Commit

Permalink
Adds configuration option to exclude the webserver on esp32. (#3369)
Browse files Browse the repository at this point in the history
* Adds configuration option to not build/include the webserver.

* Adds configuration option to not build/include the webserver.

* Keep initApiServer when excluding webserver

* fixes for failed formatting check

* Once more with feeling! Fix for regression.

* Fix includes for ARCH_ESP32

* Format changes from trunk

* Merge updates from origin

* Revert "Format changes from trunk"

This reverts commit 436e631.

* jeez!

* tryfix proto conflict

---------

Co-authored-by: Thomas Göttgens <[email protected]>
  • Loading branch information
jimwhitelaw and caveman99 authored Mar 21, 2024
1 parent 7aa21f6 commit f4095ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
// #include <driver/rtc_io.h>

#ifdef ARCH_ESP32
#if !MESHTASTIC_EXCLUDE_WEBSERVER
#include "mesh/http/WebServer.h"
#endif
#include "nimble/NimbleBluetooth.h"
NimbleBluetooth *nimbleBluetooth;
#endif
Expand Down Expand Up @@ -864,7 +866,7 @@ void setup()
#endif
#endif

#ifdef ARCH_ESP32
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WEBSERVER
// Start web server thread.
webServerThread = new WebServerThread();
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/mesh/http/ContentHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !MESHTASTIC_EXCLUDE_WEBSERVER
#include "NodeDB.h"
#include "PowerFSM.h"
#include "RadioLibInterface.h"
Expand Down Expand Up @@ -855,3 +856,4 @@ void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)
res->print(value->Stringify().c_str());
delete value;
}
#endif
6 changes: 3 additions & 3 deletions src/mesh/http/WebServer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !MESHTASTIC_EXCLUDE_WEBSERVER
#include "mesh/http/WebServer.h"
#include "NodeDB.h"
#include "graphics/Screen.h"
Expand Down Expand Up @@ -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");
Expand All @@ -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");

Expand Down Expand Up @@ -210,4 +209,5 @@ void initWebServer()
} else {
LOG_ERROR("Web Servers Failed! ;-( \n");
}
}
}
#endif
12 changes: 7 additions & 5 deletions src/mesh/wifi/WiFiAPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include <WiFi.h>
#include <WiFiUdp.h>
#ifdef ARCH_ESP32
#if !MESHTASTIC_EXCLUDE_WEBSERVER
#include "mesh/http/WebServer.h"
#endif
#include <ESPmDNS.h>
#include <esp_wifi.h>
static void WiFiEvent(WiFiEvent_t event);
Expand Down Expand Up @@ -92,11 +94,10 @@ static void onNetworkConnected()
syslog.enable();
}

#ifdef ARCH_ESP32
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WEBSERVER
initWebServer();
#endif
initApiServer();

APStartupComplete = true;
}

Expand Down Expand Up @@ -146,7 +147,6 @@ static int32_t reconnectWiFi()

perhapsSetRTC(RTCQualityNTP, &tv);
lastrun_ntp = millis();

} else {
LOG_DEBUG("NTP Update failed\n");
}
Expand Down Expand Up @@ -204,7 +204,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
Expand Down Expand Up @@ -405,4 +407,4 @@ static void WiFiEvent(WiFiEvent_t event)
uint8_t getWifiDisconnectReason()
{
return wifiDisconnectReason;
}
}

0 comments on commit f4095ce

Please sign in to comment.