diff --git a/ESP32/.cproject b/ESP32/.cproject index 0d4d3cc..3f927c8 100644 --- a/ESP32/.cproject +++ b/ESP32/.cproject @@ -19,6 +19,7 @@ + diff --git a/ESP32/data/www/index.html b/ESP32/data/www/index.html new file mode 100644 index 0000000..beb8acd --- /dev/null +++ b/ESP32/data/www/index.html @@ -0,0 +1,7 @@ + + + ESP Web Server + + +

Hello world! This file is served from the SPIFFS

+ diff --git a/ESP32/vehicle-monitor.cpp b/ESP32/vehicle-monitor.cpp index cf79120..799d27e 100644 --- a/ESP32/vehicle-monitor.cpp +++ b/ESP32/vehicle-monitor.cpp @@ -1,28 +1,23 @@ #include #include +#include +#include #include #include "wifi-credentials.h" AsyncWebServer server(80); -const char index_html[] PROGMEM = R"rawliteral( - - - - ESP Web Server - - -

Hello world!

- - -)rawliteral"; - void setup() { Serial.begin(115200); + if(!SPIFFS.begin(false)){ + Serial.println("SPIFFS Mount Failed"); + return; + } + // Connect to Wi-Fi WiFi.begin(wifi_ssid, wifi_password); while (WiFi.status() != WL_CONNECTED) @@ -35,10 +30,7 @@ void setup() Serial.print("Wifi connected, ip="); Serial.println(WiFi.localIP()); - server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) - { - request->send(200, "text/html", index_html); - }); + server.serveStatic("/", SPIFFS, "/www/").setDefaultFile("index.html"); server.begin(); Serial.println("HTTP server started");