Extend Status (#121)

* Added Sdk Version and ~heap fragmentation to system page
* Add flash chip speed to status page

Co-authored-by: kasedy <kasedy@gmail.com>
This commit is contained in:
rjwats 2020-05-21 22:52:07 +01:00 committed by GitHub
parent 13f97b630f
commit db0d98d425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -34,6 +34,11 @@ class SystemStatusForm extends Component<SystemStatusFormProps, SystemStatusForm
processing: false
}
approxHeapFragmentation = (): number => {
const { data: { max_alloc_heap, free_heap } } = this.props;
return 100 - Math.round((max_alloc_heap / free_heap) * 100);
}
createListItems() {
const { data } = this.props
return (
@ -44,7 +49,7 @@ class SystemStatusForm extends Component<SystemStatusFormProps, SystemStatusForm
<DevicesIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Platform" secondary={data.esp_platform} />
<ListItemText primary="Device (Platform / SDK)" secondary={data.esp_platform + ' / ' + data.sdk_version} />
</ListItem>
<Divider variant="inset" component="li" />
<ListItem >
@ -62,7 +67,7 @@ class SystemStatusForm extends Component<SystemStatusFormProps, SystemStatusForm
<MemoryIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Free Heap" secondary={data.free_heap + ' bytes'} />
<ListItemText primary="Heap (Free / Max Alloc)" secondary={data.free_heap + ' / ' + data.max_alloc_heap + ' bytes (~' + this.approxHeapFragmentation() + '% fragmentation)'} />
</ListItem>
<Divider variant="inset" component="li" />
<ListItem >
@ -71,7 +76,7 @@ class SystemStatusForm extends Component<SystemStatusFormProps, SystemStatusForm
<DataUsageIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Sketch Size (used/max)" secondary={data.sketch_size + ' / ' + data.free_sketch_space + ' bytes'} />
<ListItemText primary="Sketch (Size / Free)" secondary={data.sketch_size + ' / ' + data.free_sketch_space + ' bytes'} />
</ListItem>
<Divider variant="inset" component="li" />
<ListItem >
@ -80,7 +85,7 @@ class SystemStatusForm extends Component<SystemStatusFormProps, SystemStatusForm
<SdStorageIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Flash Chip Size" secondary={data.flash_chip_size + ' bytes'} />
<ListItemText primary="Flash Chip (Size / Speed)" secondary={data.flash_chip_size + ' bytes / ' + (data.flash_chip_speed / 1000000).toFixed(0) + ' MHz'} />
</ListItem>
<Divider variant="inset" component="li" />
</Fragment>

View File

@ -1,10 +1,13 @@
export interface SystemStatus {
esp_platform: string;
max_alloc_heap: number;
cpu_freq_mhz: number;
free_heap: number;
sketch_size: number;
free_sketch_space: number;
sdk_version: string;
flash_chip_size: number;
flash_chip_speed: number;
}
export interface OTASettings {

View File

@ -12,8 +12,10 @@ void SystemStatus::systemStatus(AsyncWebServerRequest* request) {
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();