systematically fetch heap mem settings, before allocating buffers so console and web show same results

This commit is contained in:
Proddy
2023-01-11 23:34:27 +01:00
parent 97451d2b7a
commit 3dc2ab54ac
4 changed files with 43 additions and 12 deletions

View File

@@ -12,13 +12,16 @@ SystemStatus::SystemStatus(AsyncWebServer * server, SecurityManager * securityMa
}
void SystemStatus::systemStatus(AsyncWebServerRequest * request) {
emsesp::EMSESP::system_.refreshHeapMem(); // refresh free heap and max alloc heap
AsyncJsonResponse * response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE);
JsonObject root = response->getRoot();
root["emsesp_version"] = EMSESP_APP_VERSION;
root["esp_platform"] = EMSESP_PLATFORM;
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
root["max_alloc_heap"] = ESP.getMaxAllocHeap() / 1024;
root["free_heap"] = ESP.getFreeHeap() / 1024;
root["max_alloc_heap"] = emsesp::EMSESP::system_.getMaxAllocMem();
root["free_heap"] = emsesp::EMSESP::system_.getHeapMem();
root["sdk_version"] = ESP.getSdkVersion();
root["flash_chip_size"] = ESP.getFlashChipSize() / 1024;
root["flash_chip_speed"] = ESP.getFlashChipSpeed();
@@ -33,7 +36,7 @@ void SystemStatus::systemStatus(AsyncWebServerRequest * request) {
root["free_psram"] = ESP.getFreePsram() / 1024;
}
const esp_partition_t * factory_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
root["has_loader"] = factory_partition != NULL;
root["has_loader"] = factory_partition != NULL;
response->setLength();
request->send(response);