Skip to content

Commit

Permalink
Better logging for boards without PSRAM, fewer logs when compiling wi…
Browse files Browse the repository at this point in the history
…th NO_SDCARD
  • Loading branch information
tueddy committed Nov 8, 2023
1 parent 9e48dc5 commit df49f8d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## DEV-branch

* 08.11.2023: Better logging for boards without PSRAM, fewer logs when compiling with NO_SDCARD
* 07.11.2023: Set timezone after startup, thank's to @Joe91 !

## Version 2 (07.11.2023)
Expand Down
4 changes: 3 additions & 1 deletion html/management.html
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,9 @@ <h5 class="modal-title" data-i18n="tools.nvserase.title"></h5>
content += i18next.t("systeminfo.hardware", { hwmodel: info.hardware.model, hwrevision: info.hardware.revision, hwfreq: info.hardware.freq }) + "\n";
content += i18next.t("systeminfo.freeheap", { freeheap: info.memory.freeHeap }) + "\n";
content += i18next.t("systeminfo.largestfreeblock", { largestfreeblock: info.memory.largestFreeBlock }) + "\n";
content += i18next.t("systeminfo.freepsram", { freepsram: info.memory.freePSRam }) + "\n";
if (info.memory.freePSRam) {
content += i18next.t("systeminfo.freepsram", { freepsram: info.memory.freePSRam }) + "\n";
}
content += i18next.t("systeminfo.currentip", { currentip: info.wifi.ip }) + "\n";
content += i18next.t("systeminfo.rssi", { rssi: info.wifi.rssi }) + "\n";
content += i18next.t("systeminfo.audiotimetotal", { firststart: secondsToDate(info.audio.firstStart), audiotimetotal: timestampToDuration(info.audio.playtimeTotal, false)})+ "\n";
Expand Down
17 changes: 15 additions & 2 deletions src/Web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,17 @@ void webserverStart(void) {
} else {
if (WiFi.getMode() == WIFI_STA) {
// serve management.html in station-mode
#ifdef NO_SDCARD
response = request->beginResponse_P(200, "text/html", (const uint8_t *) management_BIN, sizeof(management_BIN));
response->addHeader("Content-Encoding", "gzip");
#else
if (gFSystem.exists("/.html/index.htm")) {
response = request->beginResponse(gFSystem, "/.html/index.htm", String(), false);
response = request->beginResponse(gFSystem, "/.html/index.htm", "text/html", false);
} else {
response = request->beginResponse_P(200, "text/html", (const uint8_t *) management_BIN, sizeof(management_BIN));
response->addHeader("Content-Encoding", "gzip");
}
#endif
} else {
// serve accesspoint.html in AP-mode
response = request->beginResponse_P(200, "text/html", (const uint8_t *) accesspoint_BIN, sizeof(accesspoint_BIN));
Expand Down Expand Up @@ -487,6 +492,7 @@ void webserverStart(void) {

// ESPuino logo
wServer.on("/logo", HTTP_GET, [](AsyncWebServerRequest *request) {
#ifndef NO_SDCARD
Log_Println("logo request", LOGLEVEL_DEBUG);
if (gFSystem.exists("/.html/logo.png")) {
request->send(gFSystem, "/.html/logo.png", "image/png");
Expand All @@ -496,14 +502,17 @@ void webserverStart(void) {
request->send(gFSystem, "/.html/logo.svg", "image/svg+xml");
return;
};
#endif
request->redirect("https://www.espuino.de/Espuino.webp");
});
// ESPuino favicon
wServer.on("/favicon.ico", HTTP_GET, [](AsyncWebServerRequest *request) {
#ifndef NO_SDCARD
if (gFSystem.exists("/.html/favicon.ico")) {
request->send(gFSystem, "/.html/favicon.png", "image/x-icon");
return;
};
#endif
request->redirect("https://espuino.de/espuino/favicon.ico");
});
// ESPuino settings
Expand Down Expand Up @@ -845,7 +854,7 @@ void handleGetInfo(AsyncWebServerRequest *request) {
JsonObject memoryObj = infoObj.createNestedObject("memory");
memoryObj["freeHeap"] = ESP.getFreeHeap();
memoryObj["largestFreeBlock"] = (uint32_t) heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
if (psramInit()) {
if (psramFound()) {
memoryObj["freePSRam"] = ESP.getFreePsram();
}
}
Expand Down Expand Up @@ -1244,6 +1253,10 @@ void explorerHandleFileStorageTask(void *parameter) {
// Sends a list of the content of a directory as JSON file
// requires a GET parameter path for the directory
void explorerHandleListRequest(AsyncWebServerRequest *request) {
#ifdef NO_SDCARD
request->send(200, "application/json; charset=utf-8", "[]"); // maybe better to send 404 here?
return;
#endif
#ifdef BOARD_HAS_PSRAM
SpiRamJsonDocument jsonBuffer(65636);
#else
Expand Down
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ void setup() {
Led_Indicate(LedIndicatorType::BootComplete);

Log_Printf(LOGLEVEL_DEBUG, "%s: %u", freeHeapAfterSetup, ESP.getFreeHeap());
Log_Printf(LOGLEVEL_DEBUG, "PSRAM: %u bytes", ESP.getPsramSize());
if (psramFound()) {
Log_Printf(LOGLEVEL_DEBUG, "PSRAM: %u bytes", ESP.getPsramSize());
} else {
Log_Println("PSRAM: --", LOGLEVEL_DEBUG);
}
Log_Printf(LOGLEVEL_DEBUG, "Flash-size: %u bytes", ESP.getFlashChipSize());

// setup timezone & show internal RTC date/time if available
Expand Down
2 changes: 1 addition & 1 deletion src/revision.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#include "gitrevision.h"
constexpr const char softwareRevision[] = "Software-revision: 20231107-1-DEV";
constexpr const char softwareRevision[] = "Software-revision: 20231108-1-DEV";

0 comments on commit df49f8d

Please sign in to comment.