diff --git a/src/WebOTA.cpp b/src/WebOTA.cpp index 46d824a..99fbc50 100644 --- a/src/WebOTA.cpp +++ b/src/WebOTA.cpp @@ -78,8 +78,9 @@ long WebOTA::max_sketch_size() { } // R Macro string literal https://en.cppreference.com/w/cpp/language/string_literal -const char ota_html[] PROGMEM = "

WebOTA Version: " WEBOTA_VERSION "

" -R"!^!( +const char ota_version_html[] PROGMEM = "

WebOTA Version: " WEBOTA_VERSION "

"; + +const char ota_upload_form[] PROGMEM = R"!^!(
@@ -150,7 +151,15 @@ int WebOTA::add_http_routes(WebServer *server, const char *path) { // Upload firmware page server->on(path, HTTP_GET, [server,this]() { - server->send_P(200, "text/html", ota_html); + String html = ""; + if (this->custom_html != NULL) { + html += this->custom_html; + } else { + html += ota_version_html; + } + + html += ota_upload_form; + server->send_P(200, "text/html", html.c_str()); }); // Handling uploading firmware file @@ -211,6 +220,9 @@ void WebOTA::delay(unsigned int ms) { } } +void WebOTA::set_custom_html(char const * const html) { + this->custom_html = html; +} /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// diff --git a/src/WebOTA.h b/src/WebOTA.h index 801f60d..3ab856a 100644 --- a/src/WebOTA.h +++ b/src/WebOTA.h @@ -26,9 +26,12 @@ class WebOTA { #endif int handle(); + + void set_custom_html(char const * const html); + private: bool init_has_run; - + char const * custom_html = NULL; String get_ota_html(); long max_sketch_size(); };