Merged
This commit is contained in:
commit
ab1c8e9ac1
@ -1,44 +1,44 @@
|
|||||||
#include <SystemStatus.h>
|
#include <SystemStatus.h>
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#include <esp_spiffs.h>
|
#include <esp_spiffs.h>
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) {
|
SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) {
|
||||||
server->on(SYSTEM_STATUS_SERVICE_PATH,
|
server->on(SYSTEM_STATUS_SERVICE_PATH,
|
||||||
HTTP_GET,
|
HTTP_GET,
|
||||||
securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1),
|
securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1),
|
||||||
AuthenticationPredicates::IS_AUTHENTICATED));
|
AuthenticationPredicates::IS_AUTHENTICATED));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemStatus::systemStatus(AsyncWebServerRequest* request) {
|
void SystemStatus::systemStatus(AsyncWebServerRequest* request) {
|
||||||
AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE);
|
AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE);
|
||||||
JsonObject root = response->getRoot();
|
JsonObject root = response->getRoot();
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
root["esp_platform"] = "esp32";
|
root["esp_platform"] = "esp32";
|
||||||
root["max_alloc_heap"] = ESP.getMaxAllocHeap();
|
root["max_alloc_heap"] = ESP.getMaxAllocHeap();
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
root["esp_platform"] = "esp8266";
|
root["esp_platform"] = "esp8266";
|
||||||
root["max_alloc_heap"] = ESP.getMaxFreeBlockSize();
|
root["max_alloc_heap"] = ESP.getMaxFreeBlockSize();
|
||||||
#endif
|
#endif
|
||||||
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
|
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
|
||||||
root["free_heap"] = ESP.getFreeHeap();
|
root["free_heap"] = ESP.getFreeHeap();
|
||||||
root["sketch_size"] = ESP.getSketchSize();
|
root["sketch_size"] = ESP.getSketchSize();
|
||||||
root["free_sketch_space"] = ESP.getFreeSketchSpace();
|
root["free_sketch_space"] = ESP.getFreeSketchSpace();
|
||||||
root["sdk_version"] = ESP.getSdkVersion();
|
root["sdk_version"] = ESP.getSdkVersion();
|
||||||
root["flash_chip_size"] = ESP.getFlashChipSize();
|
root["flash_chip_size"] = ESP.getFlashChipSize();
|
||||||
root["flash_chip_speed"] = ESP.getFlashChipSpeed();
|
root["flash_chip_speed"] = ESP.getFlashChipSpeed();
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
if (esp_spiffs_mounted(NULL)) {
|
if (esp_spiffs_mounted(NULL)) {
|
||||||
root["spiffs_used"] = SPIFFS.usedBytes();
|
root["spiffs_used"] = SPIFFS.usedBytes();
|
||||||
root["spiffs_size"] = SPIFFS.totalBytes();
|
root["spiffs_size"] = SPIFFS.totalBytes();
|
||||||
}
|
}
|
||||||
#elif !defined(PROGMEM_WWW) //couldn't find an esp8266 alternative to esp_spiffs_mounted()
|
#elif !defined(PROGMEM_WWW) //couldn't find an esp8266 alternative to esp_spiffs_mounted()
|
||||||
root["spiffs_used"] = SPIFFS.usedBytes();
|
root["spiffs_used"] = SPIFFS.usedBytes();
|
||||||
root["spiffs_size"] = SPIFFS.totalBytes();
|
root["spiffs_size"] = SPIFFS.totalBytes();
|
||||||
#endif
|
#endif
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user