esp32-sk6812/include/WebServer.h
Thomas Kolb 8e9124c884 Avoid LED update glitches caused by flash access
Now any access to the flash, either through update writing or SPIFFS
access, is blocked while the LED stripes are written. This is
accomplished using a FreeRTOS semaphore.
2019-12-15 18:03:23 +01:00

55 lines
1.8 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 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);
};