2024-08-29 22:28:40 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Adafruit_SCD30.h>
|
2025-01-03 22:45:10 +01:00
|
|
|
#include <Adafruit_BME680.h>
|
2024-08-29 22:28:40 +02:00
|
|
|
|
|
|
|
#include <HTTPRequest.hpp>
|
|
|
|
#include <HTTPResponse.hpp>
|
|
|
|
#include <HTTPServer.hpp>
|
|
|
|
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
#include <freertos/semphr.h>
|
|
|
|
|
|
|
|
class WebServer
|
|
|
|
{
|
|
|
|
public:
|
2025-01-03 22:45:10 +01:00
|
|
|
bool start(Adafruit_SCD30 *scd30, Adafruit_BME680 *bme680);
|
2024-08-29 22:28:40 +02:00
|
|
|
|
|
|
|
static WebServer &instance(void)
|
|
|
|
{
|
|
|
|
static WebServer theInstance;
|
|
|
|
return theInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
httpsserver::HTTPServer *m_server;
|
|
|
|
|
|
|
|
Adafruit_SCD30 *m_scd30;
|
2025-01-03 22:45:10 +01:00
|
|
|
Adafruit_BME680 *m_bme680;
|
2024-08-29 22:28:40 +02:00
|
|
|
|
|
|
|
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 handleCalibrate(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
|
2024-08-29 23:16:01 +02:00
|
|
|
static void handleReadout(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
|
2024-08-29 22:28:40 +02:00
|
|
|
static void handleStatic(httpsserver::HTTPRequest *req, httpsserver::HTTPResponse *res);
|
|
|
|
};
|