Browse Source
Merge pull request #128 from rjwats/status-improvements2
Merge pull request #128 from rjwats/status-improvements2
Status improvements - add file systemmaster
rjwats
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 39 deletions
-
21interface/src/system/SystemStatusForm.tsx
-
2interface/src/system/types.ts
-
10lib/framework/ESP8266React.cpp
-
2lib/framework/ESP8266React.h
-
71lib/framework/SystemStatus.cpp
-
2lib/framework/SystemStatus.h
@ -1,29 +1,42 @@ |
|||
#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"; |
|||
root["max_alloc_heap"] = ESP.getMaxAllocHeap(); |
|||
#elif defined(ESP8266)
|
|||
root["esp_platform"] = "esp8266"; |
|||
root["max_alloc_heap"] = ESP.getMaxFreeBlockSize(); |
|||
#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); |
|||
} |
|||
#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"; |
|||
root["max_alloc_heap"] = ESP.getMaxAllocHeap(); |
|||
#elif defined(ESP8266)
|
|||
root["esp_platform"] = "esp8266"; |
|||
root["max_alloc_heap"] = ESP.getMaxFreeBlockSize(); |
|||
#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(); |
|||
|
|||
// TODO - Ideally this class will take an *FS and extract the file system information from there.
|
|||
// ESP8266 and ESP32 do not have feature parity in FS.h which currently makes that difficult.
|
|||
#ifdef ESP32
|
|||
root["fs_total"] = SPIFFS.totalBytes(); |
|||
root["fs_used"] = SPIFFS.usedBytes(); |
|||
#elif defined(ESP8266)
|
|||
FSInfo fs_info; |
|||
SPIFFS.info(fs_info); |
|||
root["fs_total"] = fs_info.totalBytes; |
|||
root["fs_used"] = fs_info.usedBytes; |
|||
#endif
|
|||
|
|||
response->setLength(); |
|||
request->send(response); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue