ESP8266_Treppenlicht/lib/httpserver/httpserver.h

40 lines
974 B
C
Raw Normal View History

#ifndef __HTTPSERVER_H
#define __HTTPSERVER_H
2021-06-27 00:01:25 +00:00
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
#include "filesys.h"
#include "treppe.h"
#include <ESP8266WebServer.h>
#include <stdarg.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-23 14:12:19 +00:00
class HTTPServer : public ESP8266WebServer {
2021-06-22 18:25:27 +00:00
private:
const char *rootDir = "/";
const char *log_prefix = "[HTTPServer] ";
size_t tbuf_head = 0;
char tbuf[TBUF_LEN];
2021-06-30 18:33:16 +00:00
void listRoot() { ls(rootDir); }
Treppe *treppe;
2021-06-30 18:33:16 +00:00
2021-06-22 18:25:27 +00:00
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();
template <class... Args>
void logf(const char *format, Args... args) const;
void logt(const char *format, ...);
2021-06-22 18:25:27 +00:00
};
#endif // __HTTPSERVER_H