move webserver stuff to plugin

This commit is contained in:
2018-08-29 09:03:38 +02:00
parent 4c32af3e1b
commit 52fdf0e5e0
15 changed files with 156 additions and 24 deletions

View File

@@ -0,0 +1,33 @@
#ifndef __WEB_SERVER_PLUGIN__
#define __WEB_SERVER_PLUGIN__
#include <FS.h>
#include "TaskSchedulerDeclarations.h"
#include "ArduinoOTA.h"
#include "MeshNet.h"
#include "Plugin.h"
#include <plugins/WebSO.h>
using namespace std;
using namespace std::placeholders;
class WebServerPlugin : public Plugin {
private:
WebServerConfig config;
MeshNet* net;
AsyncWebServer* server;
public:
WebServerPlugin(WebServerConfig cfg, AsyncWebServer* webServer){
config = cfg;
server = webServer;
}
void activate(Scheduler* userScheduler, Network* network){
//connectUpdateNetwork(network);
net = static_cast<MeshNet*>(network);
server->serveStatic(config.contextPath, SPIFFS, config.docRoot).setDefaultFile(config.defaultFile);
server->begin();
Serial.println("WebServer activated");
}
};
#endif