#635 - Added memory usage statistics

This commit is contained in:
Jm 2021-01-17 00:29:29 -08:00
parent 125eb2b784
commit 8e8264efb0

View File

@ -1169,6 +1169,16 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
res->println("},"); res->println("},");
res->println("\"memory\": {");
res->printf("\"heap_total\": %u,\n", ESP.getHeapSize());
res->printf("\"heap_free\": %u,\n", ESP.getFreeHeap());
res->printf("\"psram_total\": %s,\n", ESP.getPsramSize());
res->printf("\"psram_free\": %s,\n", ESP.getFreePsram());
res->print("\"spiffs_total\" : " + String(SPIFFS.totalBytes()) + ",");
res->print("\"spiffs_used\" : " + String(SPIFFS.usedBytes()) + ",");
res->print("\"spiffs_free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes()));
res->println("},");
res->println("\"power\": {"); res->println("\"power\": {");
#define BoolToString(x) ((x) ? "true" : "false") #define BoolToString(x) ((x) ? "true" : "false")
res->printf("\"battery_percent\": %u,\n", powerStatus->getBatteryChargePercent()); res->printf("\"battery_percent\": %u,\n", powerStatus->getBatteryChargePercent());