ESP8266_Treppenlicht/lib/httpserver/httpserver.h

43 lines
868 B
C
Raw Normal View History

2021-06-27 00:01:25 +00:00
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
#pragma once
2021-06-22 18:25:27 +00:00
#include <ESP8266WebServer.h>
2021-06-26 19:11:19 +00:00
#include <stdarg.h>
#include "filesys.h"
// debug log <ESP8266WebServer.h>
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
2021-06-26 19:11:19 +00:00
2021-06-30 18:33:16 +00:00
#define TBUF_LEN 256
2021-06-26 19:11:19 +00:00
2021-06-22 18:25:27 +00:00
2021-06-23 14:12:19 +00:00
class HTTPServer : public ESP8266WebServer {
2021-06-22 18:25:27 +00:00
private:
2021-06-26 19:11:19 +00:00
const char* rootDir = "/";
2021-06-30 18:33:16 +00:00
const char* log_prefix = "[HTTPServer] ";
size_t tbuf_head = 0;
char tbuf[TBUF_LEN];
2021-06-23 13:22:38 +00:00
void listRoot() {
ls(rootDir);
}
2021-06-30 18:33:16 +00:00
2021-06-22 18:25:27 +00:00
public:
2021-06-23 14:12:19 +00:00
HTTPServer(const int _port, const char* _rootDir) :
ESP8266WebServer(_port), rootDir(_rootDir)
2021-06-23 13:22:38 +00:00
{ }
2021-07-02 15:51:16 +00:00
~HTTPServer()
2021-06-23 13:22:38 +00:00
{
2021-06-23 14:12:19 +00:00
Serial.printf("[HTTPServer] shut down ...\n\r");
2021-07-02 15:51:16 +00:00
}
2021-06-30 18:33:16 +00:00
bool start();
2021-06-30 18:33:16 +00:00
void start_apps();
void logf(const char *format, ...);
void logt(const char *format, ...);
2021-06-22 18:25:27 +00:00
};