start a web server on port 80, serving static HTML from SPIFFS
This commit is contained in:
parent
1e3a247a4b
commit
811bd445cb
@ -28,8 +28,10 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
#include <SPIFFS.h>
|
||||||
#include <ArduinoOSC.h>
|
#include <ArduinoOSC.h>
|
||||||
#include <NeoPixelBus.h>
|
#include <NeoPixelBus.h>
|
||||||
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include "sacn.h"
|
#include "sacn.h"
|
||||||
#include "strobe_esp32.h"
|
#include "strobe_esp32.h"
|
||||||
@ -81,6 +83,7 @@ struct config_ config;
|
|||||||
Strobe *strobe;
|
Strobe *strobe;
|
||||||
NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod> *strip;
|
NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod> *strip;
|
||||||
ESPAsyncE131 *e131 = new ESPAsyncE131();
|
ESPAsyncE131 *e131 = new ESPAsyncE131();
|
||||||
|
AsyncWebServer server(80);
|
||||||
Preferences prefs;
|
Preferences prefs;
|
||||||
|
|
||||||
//// static hardware
|
//// static hardware
|
||||||
@ -161,6 +164,18 @@ bool loadConfig() {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start the async web server
|
||||||
|
*/
|
||||||
|
void startHTTPD() {
|
||||||
|
server.serveStatic("/", SPIFFS, "/www/").setDefaultFile("index.html");
|
||||||
|
|
||||||
|
server.onNotFound([](AsyncWebServerRequest * request) {
|
||||||
|
request->send(404, "text/plain", "Not found");
|
||||||
|
});
|
||||||
|
|
||||||
|
server.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -204,6 +219,12 @@ void setup() {
|
|||||||
Serial.println("Disabling Bluetooth.");
|
Serial.println("Disabling Bluetooth.");
|
||||||
btStop();
|
btStop();
|
||||||
|
|
||||||
|
Serial.println("Mounting SPI Flash FS.");
|
||||||
|
SPIFFS.begin();
|
||||||
|
|
||||||
|
Serial.println("Starting HTTP interface.");
|
||||||
|
startHTTPD();
|
||||||
|
|
||||||
|
|
||||||
//// start fixtures hardware:
|
//// start fixtures hardware:
|
||||||
// battery monitor
|
// battery monitor
|
||||||
|
Loading…
Reference in New Issue
Block a user