43 lines
868 B
C
Raw Normal View History

2021-06-27 02:01:25 +02:00
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
#pragma once
2021-06-22 20:25:27 +02:00
#include <ESP8266WebServer.h>
2021-06-26 21:11:19 +02: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 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-22 20:25:27 +02:00
2021-06-23 16:12:19 +02:00
class HTTPServer : public ESP8266WebServer {
2021-06-22 20:25:27 +02:00
private:
2021-06-26 21:11:19 +02:00
const char* rootDir = "/";
2021-06-30 20:33:16 +02:00
const char* log_prefix = "[HTTPServer] ";
size_t tbuf_head = 0;
char tbuf[TBUF_LEN];
2021-06-23 15:22:38 +02:00
void listRoot() {
ls(rootDir);
}
2021-06-30 20:33:16 +02:00
2021-06-22 20:25:27 +02:00
public:
2021-06-23 16:12:19 +02:00
HTTPServer(const int _port, const char* _rootDir) :
ESP8266WebServer(_port), rootDir(_rootDir)
2021-06-23 15:22:38 +02:00
{ }
2021-07-02 17:51:16 +02:00
~HTTPServer()
2021-06-23 15:22:38 +02:00
{
2021-06-23 16:12:19 +02:00
Serial.printf("[HTTPServer] shut down ...\n\r");
2021-07-02 17:51:16 +02:00
}
2021-06-30 20:33:16 +02:00
bool start();
2021-06-30 20:33:16 +02:00
void start_apps();
void logf(const char *format, ...);
void logt(const char *format, ...);
2021-06-22 20:25:27 +02:00
};