Skip to content

Commit

Permalink
Changed icon to gz
Browse files Browse the repository at this point in the history
  • Loading branch information
mp-se committed Jul 30, 2024
1 parent fa77f6c commit 9b9985e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion example/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ html_files =
html/index.html
html/app.js.gz
html/app.css.gz
html/favicon.ico
html/favicon.ico.gz

[env:esplib8266-debug]
platform = espressif8266 @ 4.2.1
Expand Down
2 changes: 1 addition & 1 deletion src/basewebserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SOFTWARE.
INCBIN(IndexHtml, "html/index.html");
INCBIN(AppJs, "html/app.js.gz");
INCBIN(AppCss, "html/app.css.gz");
INCBIN(Favicon, "html/favicon.ico");
INCBIN(FaviconIco, "html/favicon.ico.gz");
#endif

BaseWebServer::BaseWebServer(WebConfig *config, int dynamicJsonSize) {
Expand Down
16 changes: 9 additions & 7 deletions src/basewebserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ SOFTWARE.
INCBIN_EXTERN(IndexHtml);
INCBIN_EXTERN(AppJs);
INCBIN_EXTERN(AppCss);
INCBIN_EXTERN(Favicon);
INCBIN_EXTERN(FaviconIco);
#else
extern const uint8_t indexHtmlStart[] asm("_binary_html_index_html_start");
extern const uint8_t indexHtmlEnd[] asm("_binary_html_index_html_end");
extern const uint8_t appJsStart[] asm("_binary_html_app_js_gz_start");
extern const uint8_t appJsEnd[] asm("_binary_html_app_js_gz_end");
extern const uint8_t appCssStart[] asm("_binary_html_app_css_gz_start");
extern const uint8_t appCssEnd[] asm("_binary_html_app_css_gz_end");
extern const uint8_t faviconStart[] asm("_binary_html_favicon_ico_start");
extern const uint8_t faviconEnd[] asm("_binary_html_favicon_ico_end");
extern const uint8_t faviconIcoStart[] asm("_binary_html_favicon_ico_gz_start");
extern const uint8_t faviconIcoEnd[] asm("_binary_html_favicon_ico_gz_end");
#endif

class BaseWebServer {
Expand Down Expand Up @@ -117,7 +117,8 @@ class BaseWebServer {
void webReturnFavicon(AsyncWebServerRequest *request) {
Log.notice(F("WEB : webServer callback for /favicon.ico (Memory)." CR));
AsyncWebServerResponse *response = request->beginResponse_P(
200, "image/x-icon", (const uint8_t *)gFaviconData, gFaviconSize);
200, "image/x-icon", (const uint8_t *)gFaviconIcoData, gFaviconIcoSize);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
}
#else
Expand Down Expand Up @@ -156,9 +157,10 @@ class BaseWebServer {
void webReturnFavicon(AsyncWebServerRequest *request) {
Log.notice(F("WEB : webServer callback for /favicon.ico (Memory)." CR));
AsyncWebServerResponse *response = request->beginResponse_P(
200, "image/x-icon", (const uint8_t *)faviconStart,
reinterpret_cast<uint32_t>(&faviconEnd[0]) -
reinterpret_cast<uint32_t>(&faviconStart[0]));
200, "image/x-icon", (const uint8_t *)faviconIcoStart,
reinterpret_cast<uint32_t>(&faviconIcoEnd[0]) -
reinterpret_cast<uint32_t>(&faviconIcoStart[0]));
request->send(response);
request->send(response);
}
#endif
Expand Down

0 comments on commit 9b9985e

Please sign in to comment.