Thomas Kolb
8e9124c884
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.
55 lines
1.8 KiB
C++
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);
|
|
};
|