2019-05-26 23:04:29 +00:00
|
|
|
#include <SystemStatus.h>
|
|
|
|
|
2019-09-28 20:29:46 +00:00
|
|
|
SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) {
|
2019-12-03 23:16:06 +00:00
|
|
|
server->on(SYSTEM_STATUS_SERVICE_PATH,
|
|
|
|
HTTP_GET,
|
|
|
|
securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1),
|
|
|
|
AuthenticationPredicates::IS_AUTHENTICATED));
|
2019-05-26 23:04:29 +00:00
|
|
|
}
|
|
|
|
|
2019-12-03 23:16:06 +00:00
|
|
|
void SystemStatus::systemStatus(AsyncWebServerRequest* request) {
|
|
|
|
AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE);
|
2019-05-26 23:04:29 +00:00
|
|
|
JsonObject root = response->getRoot();
|
2019-12-24 11:19:19 +00:00
|
|
|
#ifdef ESP32
|
2019-05-26 23:04:29 +00:00
|
|
|
root["esp_platform"] = "esp32";
|
2019-12-24 11:19:19 +00:00
|
|
|
#elif defined(ESP8266)
|
|
|
|
root["esp_platform"] = "esp8266";
|
2019-05-26 23:04:29 +00:00
|
|
|
#endif
|
2019-12-03 23:16:06 +00:00
|
|
|
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
|
2019-05-26 23:04:29 +00:00
|
|
|
root["free_heap"] = ESP.getFreeHeap();
|
|
|
|
root["sketch_size"] = ESP.getSketchSize();
|
|
|
|
root["free_sketch_space"] = ESP.getFreeSketchSpace();
|
|
|
|
root["sdk_version"] = ESP.getSdkVersion();
|
|
|
|
root["flash_chip_size"] = ESP.getFlashChipSize();
|
|
|
|
root["flash_chip_speed"] = ESP.getFlashChipSpeed();
|
|
|
|
response->setLength();
|
|
|
|
request->send(response);
|
|
|
|
}
|