|
|
|
@ -1,28 +1,23 @@
|
|
|
|
|
#include <Arduino.h> |
|
|
|
|
|
|
|
|
|
#include <WiFi.h> |
|
|
|
|
#include <FS.h> |
|
|
|
|
#include <SPIFFS.h> |
|
|
|
|
#include <ESPAsyncWebServer.h> |
|
|
|
|
|
|
|
|
|
#include "wifi-credentials.h" |
|
|
|
|
|
|
|
|
|
AsyncWebServer server(80); |
|
|
|
|
|
|
|
|
|
const char index_html[] PROGMEM = R"rawliteral( |
|
|
|
|
<!DOCTYPE HTML> |
|
|
|
|
<html> |
|
|
|
|
<head> |
|
|
|
|
<title>ESP Web Server</title> |
|
|
|
|
</head> |
|
|
|
|
<body> |
|
|
|
|
<p>Hello world!</p> |
|
|
|
|
</body> |
|
|
|
|
</html> |
|
|
|
|
)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"); |
|
|
|
|