Merge pull request #5168 from wled/copilot/update-info-endpoint-p-sram

Add psramPresent and psramSize fields to /info endpoint and usage reports
This commit is contained in:
Will Tatam
2025-12-10 19:33:47 +00:00
committed by GitHub
2 changed files with 12 additions and 3 deletions

View File

@@ -3443,7 +3443,8 @@ function reportUpgradeEvent(info, oldVersion) {
};
// Add optional fields if available
if (infoData.psram !== undefined) upgradeData.psramSize = Math.round(infoData.psram / (1024 * 1024)); // convert bytes to MB
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
// Note: partitionSizes not currently available in /json/info endpoint
// Make AJAX call to postUpgradeEvent API

View File

@@ -839,8 +839,16 @@ void serializeInfo(JsonObject root)
#endif
root[F("freeheap")] = getFreeHeapSize();
#if defined(BOARD_HAS_PSRAM)
root[F("psram")] = ESP.getFreePsram();
#ifdef ARDUINO_ARCH_ESP32
// 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
}
#endif
root[F("uptime")] = millis()/1000 + rolloverMillis*4294967;