Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.1 KiB

  1. #include <SystemStatus.h>
  2. SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) {
  3. server->on(SYSTEM_STATUS_SERVICE_PATH,
  4. HTTP_GET,
  5. securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1),
  6. AuthenticationPredicates::IS_AUTHENTICATED));
  7. }
  8. void SystemStatus::systemStatus(AsyncWebServerRequest* request) {
  9. AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE);
  10. JsonObject root = response->getRoot();
  11. #ifdef ESP32
  12. root["esp_platform"] = "esp32";
  13. #elif defined(ESP8266)
  14. root["esp_platform"] = "esp8266";
  15. #endif
  16. root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
  17. root["free_heap"] = ESP.getFreeHeap();
  18. root["sketch_size"] = ESP.getSketchSize();
  19. root["free_sketch_space"] = ESP.getFreeSketchSpace();
  20. root["sdk_version"] = ESP.getSdkVersion();
  21. root["flash_chip_size"] = ESP.getFlashChipSize();
  22. root["flash_chip_speed"] = ESP.getFlashChipSpeed();
  23. response->setLength();
  24. request->send(response);
  25. }