esp8266-react-framework/lib/framework/SystemStatus.cpp
Rick Watson 62f3d3fc7a fix broken imports under ESP32
use ESP32 rather than ESP_PLATFORM - it's ambigious
standardise to ifdef ESP32 elif defined(ESP8266)
use ifdef over if defined where possible
2019-12-24 11:19:19 +00:00

28 lines
1.1 KiB
C++

#include <SystemStatus.h>
SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) {
server->on(SYSTEM_STATUS_SERVICE_PATH,
HTTP_GET,
securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1),
AuthenticationPredicates::IS_AUTHENTICATED));
}
void SystemStatus::systemStatus(AsyncWebServerRequest* request) {
AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE);
JsonObject root = response->getRoot();
#ifdef ESP32
root["esp_platform"] = "esp32";
#elif defined(ESP8266)
root["esp_platform"] = "esp8266";
#endif
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
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);
}