Fix 5168 (#5181)
* Fix slop from 5168 Remove the redundant field from the info structure and report what we actually want to know. * Fix psram size estimate Shorten the name, and round up -- getPsramSize() is the usable size, not the total size (the difference is allocator overhead). * Let psram builds work without it * Remove impossible cases in psram reports
This commit is contained in:
@@ -3396,8 +3396,8 @@ function reportUpgradeEvent(info, oldVersion) {
|
||||
};
|
||||
|
||||
// Add optional fields if available
|
||||
if (infoData.psramPresent !== undefined) upgradeData.psramPresent = infoData.psramPresent; // Whether device has PSRAM
|
||||
if (infoData.psramSize !== undefined) upgradeData.psramSize = infoData.psramSize; // Total PSRAM size in MB
|
||||
if (infoData.psrSz !== undefined) upgradeData.psramSize = infoData.psrSz; // Total PSRAM size in MB; can be 0
|
||||
|
||||
// Note: partitionSizes not currently available in /json/info endpoint
|
||||
|
||||
// Make AJAX call to postUpgradeEvent API
|
||||
|
||||
@@ -840,16 +840,12 @@ void serializeInfo(JsonObject root)
|
||||
#endif
|
||||
|
||||
root[F("freeheap")] = getFreeHeapSize();
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM)
|
||||
// Report PSRAM information
|
||||
bool hasPsram = psramFound();
|
||||
root[F("psramPresent")] = hasPsram;
|
||||
if (hasPsram) {
|
||||
#if defined(BOARD_HAS_PSRAM)
|
||||
root[F("psram")] = ESP.getFreePsram(); // Free PSRAM in bytes (backward compatibility)
|
||||
#endif
|
||||
root[F("psramSize")] = ESP.getPsramSize() / (1024UL * 1024UL); // Total PSRAM size in MB
|
||||
}
|
||||
// Free PSRAM in bytes (backward compatibility)
|
||||
root[F("psram")] = ESP.getFreePsram();
|
||||
// Total PSRAM size in MB, round up to correct for allocator overhead
|
||||
root[F("psrSz")] = (ESP.getPsramSize() + (1024U * 1024U - 1)) / (1024U * 1024U);
|
||||
#endif
|
||||
root[F("uptime")] = millis()/1000 + rolloverMillis*4294967;
|
||||
|
||||
|
||||
@@ -423,9 +423,13 @@ void WLED::setup()
|
||||
|
||||
#if defined(BOARD_HAS_PSRAM)
|
||||
// if JSON buffer allocation fails requestJsonBufferLock() will always return false preventing crashes
|
||||
pDoc = new PSRAMDynamicJsonDocument(2 * JSON_BUFFER_SIZE);
|
||||
DEBUG_PRINTF_P(PSTR("JSON buffer size: %ubytes\n"), (2 * JSON_BUFFER_SIZE));
|
||||
DEBUG_PRINTF_P(PSTR("PSRAM: %dkB/%dkB\n"), ESP.getFreePsram()/1024, ESP.getPsramSize()/1024);
|
||||
if (psramFound() && ESP.getPsramSize()) {
|
||||
pDoc = new PSRAMDynamicJsonDocument(2 * JSON_BUFFER_SIZE);
|
||||
DEBUG_PRINTF_P(PSTR("JSON buffer size: %ubytes\n"), (2 * JSON_BUFFER_SIZE));
|
||||
DEBUG_PRINTF_P(PSTR("PSRAM: %dkB/%dkB\n"), ESP.getFreePsram()/1024, ESP.getPsramSize()/1024);
|
||||
} else {
|
||||
pDoc = new DynamicJsonDocument(JSON_BUFFER_SIZE); // Use onboard RAM instead as a fallback
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
|
||||
Reference in New Issue
Block a user