47 lines
1000 B
C++

#ifndef __HTTPSERVER_H
#define __HTTPSERVER_H
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
#include <ESP8266WebServer.h>
#include <stdarg.h>
#include "filesys.h"
#include "treppe.h"
// debug log <ESP8266WebServer.h>
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
#define TBUF_LEN 256
class HTTPServer : public ESP8266WebServer {
private:
const char* rootDir = "/";
const char* log_prefix = "[HTTPServer] ";
size_t tbuf_head = 0;
char tbuf[TBUF_LEN];
void listRoot() {
ls(rootDir);
}
Treppe* treppe;
public:
HTTPServer(const int _port, const char* _rootDir, Treppe* _treppe) :
ESP8266WebServer(_port), rootDir(_rootDir), treppe(_treppe)
{ }
~HTTPServer()
{
Serial.printf("[HTTPServer] shut down ...\n\r");
}
bool start();
void start_apps();
void logf(const char *format, ...);
void logt(const char *format, ...);
};
#endif // __HTTPSERVER_H