ESP8266 Treppenlichtsteuerung mit OTA zum Firmware Upload
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

httpserver.h 860B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Wrapper for ESP8266WebServer with Filesystem as HTTP source
  2. #pragma once
  3. #include <ESP8266WebServer.h>
  4. #include <stdarg.h>
  5. #include "filesys.h"
  6. // debug log <ESP8266WebServer.h>
  7. // #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
  8. #define LOG_STR "[HTTPServer]"
  9. class HTTPServer : public ESP8266WebServer {
  10. private:
  11. const char* rootDir = "/";
  12. void listRoot() {
  13. ls(rootDir);
  14. }
  15. void logf(const char *format, ...) {
  16. va_list args;
  17. va_start(args, format);
  18. Serial.print(LOG_STR);
  19. Serial.printf(format, args);
  20. va_end(args);
  21. }
  22. public:
  23. HTTPServer(const int _port, const char* _rootDir) :
  24. ESP8266WebServer(_port), rootDir(_rootDir)
  25. { }
  26. ~HTTPServer()
  27. {
  28. Serial.printf("[HTTPServer] shut down ...\n\r");
  29. }
  30. bool start();
  31. };