fix mppt to not self destruct, log output
This commit is contained in:
@@ -207,6 +207,13 @@ fn get_battery_state(
|
||||
anyhow::Ok(Some(battery_json))
|
||||
}
|
||||
|
||||
fn get_log(
|
||||
_request: &mut Request<&mut EspHttpConnection>,
|
||||
) -> Result<Option<std::string::String>, anyhow::Error> {
|
||||
let output = crate::log::get_log();
|
||||
anyhow::Ok(Some(serde_json::to_string(&output)?))
|
||||
}
|
||||
|
||||
fn get_version_web(
|
||||
_request: &mut Request<&mut EspHttpConnection>,
|
||||
) -> Result<Option<std::string::String>, anyhow::Error> {
|
||||
@@ -354,6 +361,11 @@ pub fn httpd(reboot_now: Arc<AtomicBool>) -> Box<EspHttpServer<'static>> {
|
||||
handle_error_to500(request, get_version_web)
|
||||
})
|
||||
.unwrap();
|
||||
server
|
||||
.fn_handler("/log", Method::Get, |request| {
|
||||
handle_error_to500(request, get_log)
|
||||
})
|
||||
.unwrap();
|
||||
server
|
||||
.fn_handler("/battery", Method::Get, |request| {
|
||||
handle_error_to500(request, get_battery_state)
|
||||
|
Reference in New Issue
Block a user