2021-07-07 18:28:05 +02:00
|
|
|
#ifndef __HTTPSERVER_H
|
|
|
|
#define __HTTPSERVER_H
|
2021-06-27 02:01:25 +02:00
|
|
|
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
|
|
|
|
|
2021-06-27 01:56:30 +02:00
|
|
|
#include "filesys.h"
|
2021-07-05 19:51:55 +02:00
|
|
|
#include "treppe.h"
|
2021-07-10 04:12:50 +02:00
|
|
|
#include <ESP8266WebServer.h>
|
|
|
|
#include <stdarg.h>
|
2021-06-27 01:56:30 +02:00
|
|
|
|
|
|
|
// debug log <ESP8266WebServer.h>
|
|
|
|
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
2021-06-26 21:11:19 +02:00
|
|
|
|
2021-06-30 20:33:16 +02:00
|
|
|
#define TBUF_LEN 256
|
2021-06-26 21:11:19 +02:00
|
|
|
|
2021-06-23 16:12:19 +02:00
|
|
|
class HTTPServer : public ESP8266WebServer {
|
2021-06-27 01:56:30 +02:00
|
|
|
|
2021-06-22 20:25:27 +02:00
|
|
|
private:
|
2021-07-10 04:12:50 +02:00
|
|
|
const char *rootDir = "/";
|
|
|
|
const char *log_prefix = "[HTTPServer] ";
|
|
|
|
|
|
|
|
size_t tbuf_head = 0;
|
|
|
|
char tbuf[TBUF_LEN];
|
2021-06-30 20:33:16 +02:00
|
|
|
|
2021-07-10 04:12:50 +02:00
|
|
|
void listRoot() { ls(rootDir); }
|
|
|
|
Treppe *treppe;
|
2021-06-30 20:33:16 +02:00
|
|
|
|
2021-06-22 20:25:27 +02:00
|
|
|
public:
|
2021-07-10 04:12:50 +02:00
|
|
|
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 20:25:27 +02:00
|
|
|
};
|
2021-07-07 18:28:05 +02:00
|
|
|
|
|
|
|
#endif // __HTTPSERVER_H
|