esp32-sk6812/include/WebServer.h

56 lines
1.9 KiB
C++

#pragma once
#include <HTTPRequest.hpp>
#include <HTTPResponse.hpp>
#include <HTTPServer.hpp>
#include <FreeRTOS.h>
#include <freertos/semphr.h>
#include "ChallengeResponse.h"
class Fader;
class AnimationController;
class WebServer
{
public:
bool start(void);
void setFader(Fader *fader) { m_fader = fader;}
void setAnimationController(AnimationController *controller) { m_animController = controller;}
void setLedLockoutMutex(SemaphoreHandle_t *ledLockoutMutex) { m_ledLockoutMutex = ledLockoutMutex; }
static WebServer &instance(void)
{
static WebServer theInstance;
return theInstance;
}
private:
httpsserver::HTTPServer *m_server;
ChallengeResponse m_cr;
Fader *m_fader;
AnimationController *m_animController;
SemaphoreHandle_t *m_ledLockoutMutex;
WebServer(void);
static void serverTask(void *arg);
static bool serveFile(String filename, httpsserver::HTTPResponse *res);
// handlers
static void handleRoot(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleColor(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleSetAnim(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleListAnim(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleText(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleChallenge(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleAuthTest(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleUpdate(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
static void handleStatic(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
};