From aa04cfd80cfa86bda63084defc100b19b022da77 Mon Sep 17 00:00:00 2001 From: Rick Watson Date: Mon, 25 May 2020 11:00:42 +0100 Subject: [PATCH] fix imports use FSInfo struct for esp8266 --- interface/src/system/SystemStatusForm.tsx | 9 +++++---- interface/src/system/types.ts | 4 ++-- lib/framework/SystemStatus.cpp | 16 ++++++++++------ lib/framework/SystemStatus.h | 2 ++ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/interface/src/system/SystemStatusForm.tsx b/interface/src/system/SystemStatusForm.tsx index 88fc7aa..fadf1e7 100644 --- a/interface/src/system/SystemStatusForm.tsx +++ b/interface/src/system/SystemStatusForm.tsx @@ -27,7 +27,7 @@ interface SystemStatusFormState { type SystemStatusFormProps = AuthenticatedContextProps & RestFormProps; -function formatNumber(num: number){ +function formatNumber(num: number) { return new Intl.NumberFormat().format(num); } @@ -93,18 +93,19 @@ class SystemStatusForm extends Component + - - + + ); - } + } renderRestartDialog() { return ( diff --git a/interface/src/system/types.ts b/interface/src/system/types.ts index c1c3bc0..336ba65 100644 --- a/interface/src/system/types.ts +++ b/interface/src/system/types.ts @@ -8,8 +8,8 @@ export interface SystemStatus { sdk_version: string; flash_chip_size: number; flash_chip_speed: number; - spiffs_size:number; - spiffs_used:number; + spiffs_used: number; + spiffs_total: number; } export interface OTASettings { diff --git a/lib/framework/SystemStatus.cpp b/lib/framework/SystemStatus.cpp index 0750184..71b9a9b 100644 --- a/lib/framework/SystemStatus.cpp +++ b/lib/framework/SystemStatus.cpp @@ -1,9 +1,4 @@ #include -#ifdef ESP32 -#include -#elif defined(ESP8266) -#include -#endif SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) { server->on(SYSTEM_STATUS_SERVICE_PATH, @@ -29,8 +24,17 @@ void SystemStatus::systemStatus(AsyncWebServerRequest* request) { root["sdk_version"] = ESP.getSdkVersion(); root["flash_chip_size"] = ESP.getFlashChipSize(); root["flash_chip_speed"] = ESP.getFlashChipSpeed(); + +#ifdef ESP32 + root["spiffs_total"] = SPIFFS.totalBytes(); root["spiffs_used"] = SPIFFS.usedBytes(); - root["spiffs_size"] = SPIFFS.totalBytes(); +#elif defined(ESP8266) + FSInfo fs_info; + SPIFFS.info(fs_info); + root["spiffs_total"] = fs_info.totalBytes; + root["spiffs_used"] = fs_info.usedBytes; +#endif + response->setLength(); request->send(response); } diff --git a/lib/framework/SystemStatus.h b/lib/framework/SystemStatus.h index aa44623..397869b 100644 --- a/lib/framework/SystemStatus.h +++ b/lib/framework/SystemStatus.h @@ -4,9 +4,11 @@ #ifdef ESP32 #include #include +#include #elif defined(ESP8266) #include #include +#include #endif #include