add application info, all memory info in kb

This commit is contained in:
MichaelDvP
2022-09-23 21:36:01 +02:00
parent ab4e1f63c5
commit d54843635a
15 changed files with 6944 additions and 2376 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -27,7 +27,7 @@
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.2",
"react-icons": "^4.4.0",
"react-router-dom": "^6.4.0",
"react-router-dom": "^6.4.1",
"react-scripts": "5.0.1",
"sockette": "^2.0.6",
"typesafe-i18n": "^5.13.0",

View File

@@ -22,6 +22,7 @@ import ShowChartIcon from '@mui/icons-material/ShowChart';
import MemoryIcon from '@mui/icons-material/Memory';
import AppsIcon from '@mui/icons-material/Apps';
import SdStorageIcon from '@mui/icons-material/SdStorage';
import SdCardAlertIcon from '@mui/icons-material/SdCardAlert';
import FolderIcon from '@mui/icons-material/Folder';
import RefreshIcon from '@mui/icons-material/Refresh';
import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew';
@@ -272,14 +273,14 @@ const SystemStatusForm: FC = () => {
primary={LL.HEAP()}
secondary={
formatNumber(data.free_heap) +
' / ' +
' kb / ' +
formatNumber(data.max_alloc_heap) +
' bytes ' +
' kb ' +
(data.esp_platform === EspPlatform.ESP8266 ? '(' + data.heap_fragmentation + '% fragmentation)' : '')
}
/>
</ListItem>
{data.esp_platform === EspPlatform.ESP32 && data.psram_size > 0 && (
{data.esp_platform === EspPlatform.ESP32 && data.psram_size !== undefined && data.free_psram !== undefined && (
<>
<Divider variant="inset" component="li" />
<ListItem>
@@ -290,7 +291,7 @@ const SystemStatusForm: FC = () => {
</ListItemAvatar>
<ListItemText
primary={LL.PSRAM()}
secondary={formatNumber(data.psram_size) + ' / ' + formatNumber(data.free_psram) + ' bytes'}
secondary={formatNumber(data.psram_size) + ' kb / ' + formatNumber(data.free_psram) + ' kb'}
/>
</ListItem>
</>
@@ -305,7 +306,21 @@ const SystemStatusForm: FC = () => {
<ListItemText
primary={LL.FLASH()}
secondary={
formatNumber(data.flash_chip_size) + ' bytes / ' + (data.flash_chip_speed / 1000000).toFixed(0) + ' MHz'
formatNumber(data.flash_chip_size) + ' kb / ' + (data.flash_chip_speed / 1000000).toFixed(0) + ' MHz'
}
/>
</ListItem>
<Divider variant="inset" component="li" />
<ListItem>
<ListItemAvatar>
<Avatar>
<SdCardAlertIcon />
</Avatar>
</ListItemAvatar>
<ListItemText
primary={LL.APPSIZE()}
secondary={
formatNumber(data.app_size) + ' kb / ' + formatNumber(data.app_free) + ' kb'
}
/>
</ListItem>
@@ -320,11 +335,11 @@ const SystemStatusForm: FC = () => {
primary={LL.FILESYSTEM()}
secondary={
formatNumber(data.fs_used) +
' / ' +
' kb / ' +
formatNumber(data.fs_total) +
' bytes (' +
' kb (' +
formatNumber(data.fs_total - data.fs_used) +
'\xa0bytes free)'
'\xa0kb free)'
}
/>
</ListItem>

View File

@@ -182,6 +182,7 @@ const de: Translation = {
HEAP: 'RAM Speicher (Frei / Max Belegt)',
PSRAM: 'PSRAM (Größe / Frei)',
FLASH: 'Flash Speicher (Größe / Geschwindigkeit)',
APPSIZE: 'Programm (Größe / Frei)',
FILESYSTEM: 'Dateisystem (Genutzt / Gesamt)',
BUFFER_SIZE: 'Puffergröße',
COMPACT: 'Kompakte Darstellung',

View File

@@ -182,6 +182,7 @@ const en: BaseTranslation = {
HEAP: 'Heap (Free / Max Alloc)',
PSRAM: 'PSRAM (Size / Free)',
FLASH: 'Flash Chip (Size / Speed)',
APPSIZE: 'Application (Size / Free)',
FILESYSTEM: 'File System (Used / Total)',
BUFFER_SIZE: 'Buffer Size',
COMPACT: 'Compact',

View File

@@ -729,6 +729,10 @@ type RootTranslation = {
* Flash Chip (Size / Speed)
*/
FLASH: string
/**
* Application (Size / Free)
*/
APPSIZE: string
/**
* File System (Used / Total)
*/
@@ -1742,6 +1746,10 @@ export type TranslationFunctions = {
* Flash Chip (Size / Speed)
*/
FLASH: () => LocalizedString
/**
* Application (Size / Free)
*/
APPSIZE: () => LocalizedString
/**
* File System (Used / Total)
*/

View File

@@ -183,6 +183,7 @@ const nl: BaseTranslation = {
HEAP: 'Heap (Free / Max Alloc)',
PSRAM: 'PSRAM (Size / Free)',
FLASH: 'Flash Chip (Size / Speed)',
APPSIZE: 'Application (Size / Free)',
FILESYSTEM: 'File System (Used / Total)',
BUFFER_SIZE: 'Buffer Size',
COMPACT: 'Compact',

View File

@@ -182,6 +182,7 @@ const no: BaseTranslation = {
HEAP: 'Heap (Free / Max Alloc)',
PSRAM: 'PSRAM (Size / Free)',
FLASH: 'Flash Chip (Size / Speed)',
APPSIZE: 'Application (Size / Free)',
FILESYSTEM: 'File System (Used / Total)',
BUFFER_SIZE: 'Buffer Size',
COMPACT: 'Compact',

View File

@@ -184,6 +184,7 @@ const pl: BaseTranslation = {
HEAP: 'Pamięć (Wolna / Zaalokowana)',
PSRAM: 'PSRAM (Rozmiar / Wolna)',
FLASH: 'Pamięć flash ( Rozmiar / Taktowanie)',
APPSIZE: 'Application (Size / Free)',
FILESYSTEM: 'System plików (Wykorzystano / Cała pojemność)',
BUFFER_SIZE: 'Rozmiar bufora',
COMPACT: 'Kompaktowy',

View File

@@ -181,6 +181,7 @@ const se: BaseTranslation = {
HEAP: 'Heap (Ledigt / Max allokerat)',
PSRAM: 'PSRAM (Storlek / Ledigt)',
FLASH: 'Flash Chip (Storlek / Hastighet)',
APPSIZE: 'Application (Size / Free)',
FILESYSTEM: 'Filsystem (Använt / Totalt)',
BUFFER_SIZE: 'Bufferstorlek',
COMPACT: 'Komprimera',

View File

@@ -12,6 +12,8 @@ interface ESPSystemStatus {
sdk_version: string;
flash_chip_size: number;
flash_chip_speed: number;
app_size: number;
app_free: number;
fs_used: number;
fs_total: number;
uptime: string;
@@ -20,8 +22,8 @@ interface ESPSystemStatus {
export interface ESP32SystemStatus extends ESPSystemStatus {
esp_platform: EspPlatform.ESP32;
psram_size: number;
free_psram: number;
psram_size?: number;
free_psram?: number;
}
export interface ESP8266SystemStatus extends ESPSystemStatus {

View File

@@ -15,17 +15,21 @@ void SystemStatus::systemStatus(AsyncWebServerRequest * request) {
JsonObject root = response->getRoot();
root["emsesp_version"] = EMSESP_APP_VERSION;
root["esp_platform"] = "ESP32";
root["max_alloc_heap"] = ESP.getMaxAllocHeap();
root["psram_size"] = ESP.getPsramSize();
root["free_psram"] = ESP.getFreePsram();
root["max_alloc_heap"] = ESP.getMaxAllocHeap() / 1024;
#if defined(BOARD_HAS_PSRAM)
root["psram_size"] = ESP.getPsramSize() / 1024;
root["free_psram"] = ESP.getFreePsram() / 1024;
#endif
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
root["free_heap"] = ESP.getFreeHeap();
root["free_heap"] = ESP.getFreeHeap() / 1024;
root["sdk_version"] = ESP.getSdkVersion();
root["flash_chip_size"] = ESP.getFlashChipSize();
root["flash_chip_size"] = ESP.getFlashChipSize() / 1024;
root["flash_chip_speed"] = ESP.getFlashChipSpeed();
root["fs_total"] = emsesp::EMSESP::system_.FStotal();
root["fs_used"] = LittleFS.usedBytes();
root["app_used"] = emsesp::EMSESP::system_.appUsed();
root["app_free"] = emsesp::EMSESP::system_.appFree();
uint32_t FSused = LittleFS.usedBytes() / 1024;
root["fs_used"] = FSused;
root["fs_free"] = emsesp::EMSESP::system_.FStotal() - FSused;
root["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);
response->setLength();

View File

@@ -383,7 +383,9 @@ void System::start() {
if (low_clock_) {
setCpuFrequencyMhz(160);
}
fstotal_ = LittleFS.totalBytes(); // read only once, it takes 500 ms to read
fstotal_ = LittleFS.totalBytes() / 1024; // read only once, it takes 500 ms to read
appused_ = ESP.getSketchSize() / 1024;
appfree_ = ESP.getFreeSketchSpace() / 1024 - appused_;
#endif
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
@@ -566,7 +568,7 @@ bool System::heartbeat_json(JsonObject & output) {
}
#ifndef EMSESP_STANDALONE
output["freemem"] = ESP.getFreeHeap() / 1000L; // kilobytes
output["freemem"] = ESP.getFreeHeap() / 1024; // kilobytes
#endif
#ifndef EMSESP_STANDALONE
@@ -794,8 +796,10 @@ void System::show_system(uuid::console::Shell & shell) {
#ifndef EMSESP_STANDALONE
shell.printfln(F(" SDK version: %s"), ESP.getSdkVersion());
shell.printfln(F(" CPU frequency: %lu MHz"), ESP.getCpuFreqMHz());
shell.printfln(F(" Free heap: %lu bytes"), (uint32_t)ESP.getFreeHeap());
shell.printfln(F(" FS used/total: %lu/%lu (bytes)"), LittleFS.usedBytes(), FStotal());
shell.printfln(F(" Free heap: %lu kb"), (uint32_t)ESP.getFreeHeap() / 1024);
shell.printfln(F(" App used/free: %lu kb / %lu kb"), appUsed(), appFree());
uint32_t FSused = LittleFS.usedBytes() / 1024;
shell.printfln(F(" FS used/free: %lu kb / %lu kb"), FSused / 1024, FStotal() - FSused);
shell.println();
shell.println("Network:");
@@ -975,7 +979,8 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
node["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);
// node["uptime (seconds)"] = uuid::get_uptime_sec();
#ifndef EMSESP_STANDALONE
node["freemem"] = ESP.getFreeHeap() / 1000L; // kilobytes
node["freemem"] = ESP.getFreeHeap() / 1024; // kilobytes
node["free_app"] = EMSESP::system_.appFree(); // kilobytes
#endif
node["reset reason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1);

View File

@@ -223,6 +223,12 @@ class System {
uint32_t FStotal() {
return fstotal_;
}
uint32_t appFree() {
return appfree_;
}
uint32_t appUsed() {
return appused_;
}
private:
static uuid::log::Logger logger_;
@@ -299,6 +305,8 @@ class System {
uint8_t eth_clock_mode_;
uint32_t fstotal_;
uint32_t appused_;
uint32_t appfree_;
};
} // namespace emsesp

View File

@@ -284,7 +284,7 @@ void WebSettingsService::onUpdate() {
}
if (WebSettings::has_flags(WebSettings::ChangeFlags::MQTT)) {
emsesp::EMSESP::mqtt_.reset_mqtt(); // reload MQTT, init HA etc
emsesp::Mqtt::reset_mqtt(); // reload MQTT, init HA etc
}
WebSettings::reset_flags();