diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-11-28 05:45:20 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-12-18 00:00:27 +0300 |
commit | 7bb6daa4bf09947142e38ff468b7f62baae110fd (patch) | |
tree | c120e9ec800525116ad922e6c4cff21064a40538 /platformio/relayctl/src/http_server.h | |
parent | 16d47968b4938f3b60b97f374d45ad39bb0071b1 (diff) |
esp8266 relay controller wip
Diffstat (limited to 'platformio/relayctl/src/http_server.h')
-rw-r--r-- | platformio/relayctl/src/http_server.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/platformio/relayctl/src/http_server.h b/platformio/relayctl/src/http_server.h new file mode 100644 index 0000000..c7e3d9c --- /dev/null +++ b/platformio/relayctl/src/http_server.h @@ -0,0 +1,37 @@ +#pragma once + +#include <memory> +#include <list> +#include <Ticker.h> +#include <utility> +#include <ESPAsyncWebServer.h> +#include "static.h" +#include "config.h" +#include "wifi.h" + +namespace homekit { + +using files::StaticFile; + +class HttpServer { +private: + AsyncWebServer _server; + Ticker restartTimer; + std::shared_ptr<std::list<wifi::ScanResult>> _scanResults; + char buf1k[1024]; + + static void sendGzip(AsyncWebServerRequest* req, StaticFile file, const char* content_type); + static void sendError(AsyncWebServerRequest* req, const String& message); + + static bool handleInputStr(AsyncWebServerRequest* req, const char* field_name, size_t max_len, char** dst); + // static bool handle_input_addr(AsyncWebServerRequest* req, const char* field_name, ConfigIPv4Addr* addr_dst); + +public: + explicit HttpServer(std::shared_ptr<std::list<wifi::ScanResult>> scanResults) + : _server(80) + , _scanResults(std::move(scanResults)) {}; + + void start(); +}; + +}
\ No newline at end of file |