From b1e61e17a57d9b7e3d470aa19ca8cf3a12499bb1 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Fri, 10 Mar 2023 15:52:53 -0800 Subject: [PATCH] Make get_board_type() a function --- src/WebOTA.cpp | 18 +++++++++++++++++- src/WebOTA.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/WebOTA.cpp b/src/WebOTA.cpp index 8a85000..98f7d76 100644 --- a/src/WebOTA.cpp +++ b/src/WebOTA.cpp @@ -204,6 +204,21 @@ domReady(function() { }); )!^!"; +String WebOTA::get_board_type() { + +#if defined(ESP8266) + String BOARD_NAME = "ESP8266"; +#elif defined(ESP32S2) + String BOARD_NAME = "ESP32-S2"; +#elif defined(ESP32) + String BOARD_NAME = "ESP32"; +#else + String BOARD_NAME = "Unknown"; +#endif + + return BOARD_NAME; +} + #ifdef ESP8266 int WebOTA::add_http_routes(ESP8266WebServer *server, const char *path) { #endif @@ -232,10 +247,11 @@ int WebOTA::add_http_routes(WebServer *server, const char *path) { #endif String uptime_str = human_time(millis() / 1000); + String board_type = webota.get_board_type(); const char* mac_addr = WiFi.macAddress().c_str(); char buf[1024]; - snprintf_P(buf, sizeof(buf), INDEX_HTML, WEBOTA_VERSION, BOARD_NAME, mac_addr, uptime_str.c_str()); + snprintf_P(buf, sizeof(buf), INDEX_HTML, WEBOTA_VERSION, board_type, mac_addr, uptime_str.c_str()); html = buf; } diff --git a/src/WebOTA.h b/src/WebOTA.h index 4705e8b..861ae41 100644 --- a/src/WebOTA.h +++ b/src/WebOTA.h @@ -34,6 +34,7 @@ class WebOTA { char const * custom_html = NULL; String get_ota_html(); String human_time(uint32_t sec); + String get_board_type(); long max_sketch_size(); };