Rename /version endpoint to /firmware_info; add heap memory statistics to firmware data and UI.
This commit is contained in:
@@ -1327,12 +1327,17 @@ async fn get_version(
|
||||
let hash = &env!("VERGEN_GIT_SHA")[0..8];
|
||||
|
||||
let board = board.board_hal.get_esp();
|
||||
let heap = esp_alloc::HEAP.stats();
|
||||
VersionInfo {
|
||||
git_hash: branch + "@" + hash,
|
||||
build_time: env!("VERGEN_BUILD_TIMESTAMP").to_owned(),
|
||||
current: format!("{:?}", board.current),
|
||||
slot0_state: format!("{:?}", board.slot0_state),
|
||||
slot1_state: format!("{:?}", board.slot1_state),
|
||||
heap_total: heap.size,
|
||||
heap_used: heap.current_usage,
|
||||
heap_free: heap.size.saturating_sub(heap.current_usage),
|
||||
heap_max_used: heap.max_usage,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,4 +1348,8 @@ struct VersionInfo {
|
||||
current: String,
|
||||
slot0_state: String,
|
||||
slot1_state: String,
|
||||
heap_total: usize,
|
||||
heap_used: usize,
|
||||
heap_free: usize,
|
||||
heap_max_used: usize,
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ pub(crate) async fn get_solar_state<T, const N: usize>(
|
||||
Ok(Some(serde_json::to_string(&state)?))
|
||||
}
|
||||
|
||||
pub(crate) async fn get_version_web<T, const N: usize>(
|
||||
pub(crate) async fn get_firmware_info_web<T, const N: usize>(
|
||||
_request: &mut Connection<'_, T, N>,
|
||||
) -> FatResult<Option<String>> {
|
||||
let mut board = BOARD_ACCESS.get().await.lock().await;
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::fat_error::{FatError, FatResult};
|
||||
use crate::webserver::backup_manager::{backup_config, backup_info, get_backup_config};
|
||||
use crate::webserver::get_json::{
|
||||
delete_save, get_battery_state, get_config, get_live_moisture, get_log_localization_config,
|
||||
get_solar_state, get_time, get_timezones, get_version_web, list_saves, tank_info,
|
||||
get_firmware_info_web, get_solar_state, get_time, get_timezones, list_saves, tank_info,
|
||||
};
|
||||
use crate::webserver::get_log::{get_live_log, get_log};
|
||||
use crate::webserver::get_static::{serve_bundle, serve_favicon, serve_index};
|
||||
@@ -73,7 +73,7 @@ impl Handler for HTTPRequestRouter {
|
||||
"/get_backup_config" => get_backup_config(conn).await?,
|
||||
&_ => {
|
||||
let json = match path {
|
||||
"/version" => Some(get_version_web(conn).await),
|
||||
"/firmware_info" => Some(get_firmware_info_web(conn).await),
|
||||
"/time" => Some(get_time(conn).await),
|
||||
"/battery" => Some(get_battery_state(conn).await),
|
||||
"/solar" => Some(get_solar_state(conn).await),
|
||||
|
||||
Reference in New Issue
Block a user